mirror of
https://github.com/Snigdha-OS/snigdhaos-welcome.git
synced 2025-09-21 06:24:56 +02:00
📝 docs(explain): added & improve functions
This commit is contained in:
@@ -12,7 +12,8 @@ from queue import Queue
|
|||||||
import ui.GUI as GUI
|
import ui.GUI as GUI
|
||||||
from ui.MessageDialog import MessageDialogBootloader
|
from ui.MessageDialog import MessageDialogBootloader
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gtk, GdkPixbuf, GLib, Gdk
|
gi.require_version("Wnck", "3.0")
|
||||||
|
from gi.repository import Gtk, GdkPixbuf, GLib, Gdk, Wnck
|
||||||
|
|
||||||
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
||||||
REMOTE_SERVER = "www.google.com"
|
REMOTE_SERVER = "www.google.com"
|
||||||
@@ -292,17 +293,28 @@ class Main(Gtk.Window):
|
|||||||
md.destroy()
|
md.destroy()
|
||||||
|
|
||||||
def on_gp_clicked(self, widget):
|
def on_gp_clicked(self, widget):
|
||||||
|
"""
|
||||||
|
Handles the "GParted" button click. Checks if GParted is installed and, if not,
|
||||||
|
prompts the user to install it. If installed, launches GParted.
|
||||||
|
"""
|
||||||
|
# Command to launch GParted
|
||||||
app_cmd = ["/usr/bin/gparted"]
|
app_cmd = ["/usr/bin/gparted"]
|
||||||
|
|
||||||
|
# Command to install GParted using pacman
|
||||||
pacman_cmd = [
|
pacman_cmd = [
|
||||||
"pkexec",
|
"pkexec",
|
||||||
"pacman",
|
"pacman",
|
||||||
"-Sy",
|
"-Sy", # Synchronize package databases
|
||||||
"gparted",
|
"gparted", # Install the GParted package
|
||||||
"--noconfirm",
|
"--noconfirm", # Skip confirmation prompts
|
||||||
"--needed",
|
"--needed", # Only install if not already installed
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Check if GParted is installed
|
||||||
if not self.check_package_installed("gparted"):
|
if not self.check_package_installed("gparted"):
|
||||||
|
# Check if the Pacman lockfile exists
|
||||||
if not os.path.exists(self.pacman_lockfile):
|
if not os.path.exists(self.pacman_lockfile):
|
||||||
|
# Display a warning dialog to inform the user that GParted is not installed
|
||||||
md = Gtk.MessageDialog(
|
md = Gtk.MessageDialog(
|
||||||
parent=self,
|
parent=self,
|
||||||
flags=0,
|
flags=0,
|
||||||
@@ -311,29 +323,38 @@ class Main(Gtk.Window):
|
|||||||
text="%s was not found" % "gparted",
|
text="%s was not found" % "gparted",
|
||||||
title="Warning",
|
title="Warning",
|
||||||
)
|
)
|
||||||
|
# Add "Yes" and "No" buttons for user response
|
||||||
md.add_buttons("Yes", 1)
|
md.add_buttons("Yes", 1)
|
||||||
md.add_buttons("No", 0)
|
md.add_buttons("No", 0)
|
||||||
md.format_secondary_markup("Let Snigdha OS - Welcome install it?")
|
md.format_secondary_markup("Let Snigdha OS - Welcome install it?")
|
||||||
|
|
||||||
|
# Capture the user's response
|
||||||
response = md.run()
|
response = md.run()
|
||||||
md.destroy()
|
md.destroy()
|
||||||
if response == 1:
|
|
||||||
|
if response == 1: # User chooses "Yes" to install
|
||||||
|
# Start the package queue checker in a separate thread
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
target=self.check_package_queue, daemon=True
|
target=self.check_package_queue, daemon=True
|
||||||
).start()
|
).start()
|
||||||
|
|
||||||
|
# Start the package installation process in a separate thread
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
target=self.install_package,
|
target=self.install_package,
|
||||||
args=(
|
args=(
|
||||||
app_cmd,
|
app_cmd, # Command to launch GParted after installation
|
||||||
pacman_cmd,
|
pacman_cmd, # Command to install GParted
|
||||||
"gparted",
|
"gparted", # Package name
|
||||||
),
|
),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
).start()
|
).start()
|
||||||
else:
|
else:
|
||||||
|
# Handle the case where a Pacman lockfile exists
|
||||||
print(
|
print(
|
||||||
"[ERROR]: Pacman lockfile found %s, is another pacman process running?"
|
"[ERROR]: Pacman lockfile found %s, is another pacman process running?"
|
||||||
% self.pacman_lockfile
|
% self.pacman_lockfile
|
||||||
)
|
)
|
||||||
|
# Display a warning dialog about the lockfile
|
||||||
md = Gtk.MessageDialog(
|
md = Gtk.MessageDialog(
|
||||||
parent=self,
|
parent=self,
|
||||||
flags=0,
|
flags=0,
|
||||||
@@ -346,8 +367,10 @@ class Main(Gtk.Window):
|
|||||||
md.run()
|
md.run()
|
||||||
md.destroy()
|
md.destroy()
|
||||||
else:
|
else:
|
||||||
|
# If GParted is already installed, launch it in a separate thread
|
||||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||||
|
|
||||||
|
|
||||||
def on_buttonarandr_clicked(self, widget):
|
def on_buttonarandr_clicked(self, widget):
|
||||||
app_cmd = ["/usr/bin/arandr"]
|
app_cmd = ["/usr/bin/arandr"]
|
||||||
pacman_cmd = [
|
pacman_cmd = [
|
||||||
|
Reference in New Issue
Block a user