mirror of
https://github.com/Snigdha-OS/snigdhaos-welcome.git
synced 2025-09-21 14:34:56 +02:00
🐛 fix(_init_): thread safe utilization
This commit is contained in:
@@ -65,35 +65,59 @@ label#label_style_eshan {
|
||||
|
||||
class Main(Gtk.Window):
|
||||
def __init__(self):
|
||||
super(Main, self).__init__(title="Snigdha OS Welcome")
|
||||
self.set_border_width(10)
|
||||
self.set_default_size(860, 450)
|
||||
self.set_icon_from_file(os.path.join(base_dir, "images/snigdhaos-welcome-small.png"))
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
self.results = ""
|
||||
if not os.path.exists(GUI.home + "/.config/snigdhaos-welcome/"):
|
||||
os.mkdir(GUI.home + "/.config/snigdhaos-welcome/")
|
||||
with open(GUI.Settings, "w") as f:
|
||||
f.write("autostart=True")
|
||||
f.close()
|
||||
self.style_provider = Gtk.CssProvider()
|
||||
super(Main, self).__init__(title="Snigdha OS Welcome")
|
||||
|
||||
# Basic Window Configuration
|
||||
self.set_border_width(10) # Set the border width of the window
|
||||
self.set_default_size(860, 450) # Set the default size of the window
|
||||
self.set_icon_from_file(os.path.join(base_dir, "images/snigdhaos-welcome-small.png")) # Set the window icon
|
||||
self.set_position(Gtk.WindowPosition.CENTER) # Center the window on the screen
|
||||
self.results = "" # Initialize results to an empty string
|
||||
|
||||
# Initialize Configuration Directory and Settings
|
||||
config_dir = os.path.join(GUI.home, ".config/snigdhaos-welcome/") # Define the configuration directory path
|
||||
if not os.path.exists(config_dir): # Check if the directory exists
|
||||
try:
|
||||
os.makedirs(config_dir, exist_ok=True) # Create the directory if it doesn't exist
|
||||
with open(GUI.Settings, "w") as f: # Open the settings file in write mode
|
||||
f.write("autostart=True") # Write default settings
|
||||
except OSError as e:
|
||||
print(f"Error initializing configuration: {e}") # Handle any file/directory creation errors
|
||||
|
||||
# CSS Styling
|
||||
self.style_provider = Gtk.CssProvider() # Create a CSS provider
|
||||
try:
|
||||
# Load the CSS data into the style provider
|
||||
self.style_provider.load_from_data(css, len(css))
|
||||
# Apply the style provider to the default screen
|
||||
Gtk.StyleContext.add_provider_for_screen(
|
||||
Gdk.Screen.get_default(),
|
||||
self.style_provider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION, # Set priority for application-specific styles
|
||||
)
|
||||
self.pkg_queue = Queue()
|
||||
self.pacman_lockfile = "/var/lib/pacman/db.lck"
|
||||
self.sudo_username = os.getlogin()
|
||||
self.calamares_polkit = "/usr/bin/calamares_polkit"
|
||||
self.session = None
|
||||
self.get_session()
|
||||
GUI.GUI(self, Gtk, GdkPixbuf)
|
||||
if GUI.username == GUI.user:
|
||||
threading.Thread(
|
||||
target=self.internet_notifier, args=(), daemon=True
|
||||
).start()
|
||||
except GLib.Error as e:
|
||||
print(f"Error loading CSS: {e}") # Handle CSS loading errors
|
||||
|
||||
# Initialize Internal Attributes
|
||||
self.pkg_queue = Queue() # Initialize a queue for package operations
|
||||
self.pacman_lockfile = "/var/lib/pacman/db.lck" # Define the lockfile path for pacman
|
||||
self.sudo_username = os.getlogin() # Get the username of the user running the script
|
||||
self.calamares_polkit = "/usr/bin/calamares_polkit" # Path to the Calamares Polkit executable
|
||||
self.session = None # Initialize session attribute
|
||||
|
||||
# Retrieve Session Information
|
||||
self.get_session() # Fetch the session information (implementation not shown here)
|
||||
|
||||
# Initialize GUI
|
||||
GUI.GUI(self, Gtk, GdkPixbuf) # Initialize the graphical user interface components
|
||||
|
||||
# Start Internet Notifier Thread if the user matches the GUI user
|
||||
if GUI.username == GUI.user: # Check if the username matches
|
||||
internet_notifier_thread = threading.Thread(
|
||||
target=self.internet_notifier, daemon=True # Create a thread for the internet notifier
|
||||
)
|
||||
internet_notifier_thread.start() # Start the thread
|
||||
|
||||
def get_session(self):
|
||||
try:
|
||||
self.session = os.environ.get("XDG_SESSION_TYPE")
|
||||
|
Reference in New Issue
Block a user