mirror of
https://github.com/Snigdha-OS/snigdhaos-welcome.git
synced 2026-03-23 06:28:56 +01:00
upload base files -> snigdhaos-welcome
This commit is contained in:
12
usr/share/applications/snigdhaos-welcome.desktop
Normal file
12
usr/share/applications/snigdhaos-welcome.desktop
Normal file
@@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Name=Snigdha OS Welcome
|
||||
GenericName=Snigdha OS Welcome Welcome
|
||||
X-GNOME-FullName=Snigdha OS Welcome Welcome
|
||||
Comment=Welcome Application for Snigdha OS Installs
|
||||
Exec=/usr/local/bin/snigdhaos-welcome
|
||||
Icon=snigdhaos-welcome
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=GTK;Settings;Security;X-GNOME-Settings-Panel;X-GNOME-SystemSettings;X-Unity-Settings-Panel;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;
|
||||
Keywords=welcome;tool;
|
||||
StartupNotify=true
|
||||
9
usr/share/icons/hicolor/scalable/apps/snigdhaos-icon.svg
Normal file
9
usr/share/icons/hicolor/scalable/apps/snigdhaos-icon.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
82
usr/share/snigdhaos-welcome/conflicts.py
Normal file
82
usr/share/snigdhaos-welcome/conflicts.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# =================================================================
|
||||
# = Authors: Brad Heffernan & Erik Dubois =
|
||||
# =================================================================
|
||||
|
||||
import gi
|
||||
import os
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk # noqa
|
||||
|
||||
base_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
class Conflicts(Gtk.Window):
|
||||
def __init__(self):
|
||||
super(Conflicts, self).__init__(title="Information")
|
||||
self.set_border_width(10)
|
||||
self.set_default_size(550, 250)
|
||||
self.connect("delete-event", self.close)
|
||||
self.set_icon_from_file(os.path.join(base_dir, 'images/snigdhaos-icon.png'))
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||
self.add(vbox)
|
||||
|
||||
# If you want header in middle then remove xalign=0
|
||||
lblh1 = Gtk.Label(xalign=0)
|
||||
lblh1.set_markup("<b><i>Warning 1</i></b>")
|
||||
|
||||
lblm1 = Gtk.Label()
|
||||
lblm1.set_text("xcursor-breeze conflicts with breeze")
|
||||
|
||||
lblh2 = Gtk.Label(xalign=0)
|
||||
lblh2.set_markup("<b><i>Warning 2</i></b>")
|
||||
|
||||
lblm2 = Gtk.Label()
|
||||
lblm2.set_text("visual-studio-code-bin conflicts with code")
|
||||
|
||||
lblh3 = Gtk.Label(xalign=0)
|
||||
lblh3.set_markup("<b><i>Warning 3</i></b>")
|
||||
|
||||
lblm3 = Gtk.Label()
|
||||
lblm3.set_text("synapse (zeitgeist) conflicts with catfish")
|
||||
|
||||
lblh4 = Gtk.Label(xalign=0)
|
||||
lblh4.set_markup("<b><i>Warning 4</i></b>")
|
||||
|
||||
lblm4 = Gtk.Label()
|
||||
lblm4.set_text("Either choose libreoffice-fresh or libreoffice-still")
|
||||
|
||||
lblh5 = Gtk.Label(xalign=0)
|
||||
lblh5.set_markup("<b><i>Warning 5</i></b>")
|
||||
|
||||
lblm5 = Gtk.Label()
|
||||
lblm5.set_text("Either choose virtualbox for linux or linux-lts")
|
||||
|
||||
lblh6 = Gtk.Label(xalign=0)
|
||||
lblh6.set_markup("<b><i>Warning 6</i></b>")
|
||||
|
||||
lblm6 = Gtk.Label()
|
||||
lblm6.set_text("midori (zeitgeist) conflicts with catfish")
|
||||
|
||||
|
||||
vbox.pack_start(lblh1, False, False, 0)
|
||||
vbox.pack_start(lblm1, False, False, 0)
|
||||
|
||||
vbox.pack_start(lblh2, False, False, 0)
|
||||
vbox.pack_start(lblm2, False, False, 0)
|
||||
|
||||
vbox.pack_start(lblh3, False, False, 0)
|
||||
vbox.pack_start(lblm3, False, False, 0)
|
||||
|
||||
vbox.pack_start(lblh4, False, False, 0)
|
||||
vbox.pack_start(lblm4, False, False, 0)
|
||||
|
||||
vbox.pack_start(lblh5, False, False, 0)
|
||||
vbox.pack_start(lblm5, False, False, 0)
|
||||
|
||||
vbox.pack_start(lblh6, False, False, 0)
|
||||
vbox.pack_start(lblm6, False, False, 0)
|
||||
|
||||
def close(self, widget, event):
|
||||
self.destroy()
|
||||
BIN
usr/share/snigdhaos-welcome/images/facebook.png
Normal file
BIN
usr/share/snigdhaos-welcome/images/facebook.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
usr/share/snigdhaos-welcome/images/github.png
Normal file
BIN
usr/share/snigdhaos-welcome/images/github.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
usr/share/snigdhaos-welcome/images/logo.png
Normal file
BIN
usr/share/snigdhaos-welcome/images/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
BIN
usr/share/snigdhaos-welcome/images/snigdhaos-icon.png
Normal file
BIN
usr/share/snigdhaos-welcome/images/snigdhaos-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
BIN
usr/share/snigdhaos-welcome/images/twitter.png
Normal file
BIN
usr/share/snigdhaos-welcome/images/twitter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
733
usr/share/snigdhaos-welcome/snigdhaos-welcome.py
Normal file
733
usr/share/snigdhaos-welcome/snigdhaos-welcome.py
Normal file
@@ -0,0 +1,733 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import gi
|
||||
import os
|
||||
import conflicts
|
||||
# import sys
|
||||
# import wnck
|
||||
import subprocess
|
||||
import threading
|
||||
import shutil
|
||||
import socket
|
||||
from time import sleep
|
||||
from queue import Queue
|
||||
|
||||
import ui.GUI as GUI
|
||||
from ui.MessageDialog import MessageDialogBootloader
|
||||
from ui.MessageDialog import MessageDialog
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
# 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__)))
|
||||
REMOTE_SERVER = "www.google.com"
|
||||
css = """
|
||||
box#stack_box{
|
||||
padding: 10px 10px 10px 10px;
|
||||
}
|
||||
button#button_grub_boot_enabled{
|
||||
font-weight: bold;
|
||||
background-color: @theme_base_color_button;
|
||||
}
|
||||
button#button_systemd_boot_enabled{
|
||||
font-weight: bold;
|
||||
background-color: @theme_base_color_button;
|
||||
}
|
||||
button#button_easy_install_enabled{
|
||||
font-weight: bold;
|
||||
background-color: @theme_base_color_button;
|
||||
}
|
||||
button#button_adv_install_enabled{
|
||||
font-weight: bold;
|
||||
background-color: @theme_base_color_button;
|
||||
}
|
||||
label#label_style {
|
||||
background-color: @theme_base_color;
|
||||
border-top: 1px solid @borders;
|
||||
border-bottom: 1px solid @borders;
|
||||
border-left: 1px solid @borders;
|
||||
border-right: 1px solid @borders;
|
||||
padding: 10px 10px 10px 10px;
|
||||
border-radius: 0px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: pink;
|
||||
}
|
||||
label#label_style_eshan {
|
||||
background-color: @theme_base_color;
|
||||
border-top: 1px solid @borders;
|
||||
border-bottom: 1px solid @borders;
|
||||
border-left: 1px solid @borders;
|
||||
border-right: 1px solid @borders;
|
||||
padding: 10px 10px 10px 10px;
|
||||
border-radius: 0px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #2B65EC;
|
||||
}
|
||||
"""
|
||||
|
||||
class Main(Gtk.Window):
|
||||
def __init__(self):
|
||||
super(Main, self).__init__(title="Snigdha OS Welcome - Arctic")
|
||||
self.set_border_width(10)
|
||||
self.set_default_size(860, 450)
|
||||
self.set_icon_from_file(os.path.join(base_dir, "images/snigdhaos-icon.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()
|
||||
self.style_provider.load_from_data(css, len(css))
|
||||
|
||||
Gtk.StyleContext.add_provider_for_screen(
|
||||
Gdk.Screen.get_default(),
|
||||
self.style_provider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
)
|
||||
|
||||
# a queue to store package install progress
|
||||
self.pkg_queue = Queue()
|
||||
|
||||
# default pacman lockfile
|
||||
self.pacman_lockfile = "/var/lib/pacman/db.lck"
|
||||
|
||||
# get the username of the user running the welcome app
|
||||
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()
|
||||
|
||||
# returns the login session
|
||||
def get_session(self):
|
||||
try:
|
||||
self.session = os.environ.get("XDG_SESSION_TYPE")
|
||||
except Exception as e:
|
||||
print("Exception in get_session(): %s" % e)
|
||||
|
||||
def on_settings_clicked(self, widget):
|
||||
self.toggle_popover()
|
||||
|
||||
def toggle_popover(self):
|
||||
if self.popover.get_visible():
|
||||
self.popover.hide()
|
||||
else:
|
||||
self.popover.show_all()
|
||||
|
||||
# check if path exists
|
||||
# used to check if /sys/firmware/efi/fw_platform_size exists
|
||||
# if yes then display systemd-boot bootloader install option
|
||||
def file_check(self, path):
|
||||
if os.path.isfile(path):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def on_mirror_clicked(self, widget):
|
||||
threading.Thread(target=self.mirror_update, daemon=True).start()
|
||||
|
||||
def on_update_clicked(self, widget):
|
||||
print("Clicked")
|
||||
|
||||
def convert_to_hex(self, rgba_color):
|
||||
red = int(rgba_color.red * 255)
|
||||
green = int(rgba_color.green * 255)
|
||||
blue = int(rgba_color.blue * 255)
|
||||
return "#{r:02x}{g:02x}{b:02x}".format(r=red, g=green, b=blue)
|
||||
|
||||
# offline install option
|
||||
def on_easy_install_clicked(self, widget):
|
||||
if not os.path.exists(self.pacman_lockfile):
|
||||
widget.set_name("button_easy_install_enabled")
|
||||
widget.get_child().set_markup(
|
||||
"<span size='large'>Offline Installation</span>"
|
||||
)
|
||||
# DEPRECATED NOTICE: get_style_context deprecated in gtk 4.10 and will be removed in gtk 5.0
|
||||
selected_bg_color = widget.get_style_context().lookup_color(
|
||||
"theme_selected_bg_color"
|
||||
)
|
||||
if selected_bg_color[0] is True:
|
||||
theme_bg_hex_color = self.convert_to_hex(selected_bg_color[1])
|
||||
|
||||
custom_css = css.replace("@theme_base_color_button", theme_bg_hex_color)
|
||||
|
||||
self.style_provider.load_from_data(custom_css, len(custom_css))
|
||||
|
||||
self.button_adv_install.set_name("button_adv_install")
|
||||
|
||||
settings_beginner_file = "/etc/calamares/settings-beginner.conf"
|
||||
packages_no_sys_update_file = (
|
||||
"/etc/calamares/modules/packages-no-system-update.conf"
|
||||
)
|
||||
|
||||
app_cmd = [
|
||||
"sudo",
|
||||
"cp",
|
||||
settings_beginner_file,
|
||||
"/etc/calamares/settings.conf",
|
||||
]
|
||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
|
||||
app_cmd = [
|
||||
"sudo",
|
||||
"cp",
|
||||
packages_no_sys_update_file,
|
||||
"/etc/calamares/modules/packages.conf",
|
||||
]
|
||||
|
||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
|
||||
efi_file_check = self.file_check("/sys/firmware/efi/fw_platform_size")
|
||||
|
||||
if efi_file_check is True:
|
||||
md = MessageDialogBootloader(
|
||||
title="Choose Bootloader",
|
||||
install_method="Offline Installation",
|
||||
pacman_lockfile=self.pacman_lockfile,
|
||||
run_app=self.run_app,
|
||||
calamares_polkit=self.calamares_polkit,
|
||||
)
|
||||
md.show_all()
|
||||
|
||||
else:
|
||||
subprocess.Popen([self.calamares_polkit, "-d"], shell=False)
|
||||
else:
|
||||
print(
|
||||
"[ERROR]: Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile
|
||||
)
|
||||
md = Gtk.MessageDialog(
|
||||
parent=self,
|
||||
flags=0,
|
||||
message_type=Gtk.MessageType.WARNING,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
text="Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile,
|
||||
title="Warning",
|
||||
)
|
||||
md.run()
|
||||
md.destroy()
|
||||
|
||||
# online install option
|
||||
def on_adv_install_clicked(self, widget):
|
||||
if not os.path.exists(self.pacman_lockfile):
|
||||
widget.set_name("button_adv_install_enabled")
|
||||
widget.get_child().set_markup(
|
||||
"<span size='large'>Online Installation</span>"
|
||||
)
|
||||
|
||||
# DEPRECATED NOTICE: get_style_context deprecated in gtk 4.10 and will be removed in gtk 5.0
|
||||
selected_bg_color = widget.get_style_context().lookup_color(
|
||||
"theme_selected_bg_color"
|
||||
)
|
||||
if selected_bg_color[0] is True:
|
||||
theme_bg_hex_color = self.convert_to_hex(selected_bg_color[1])
|
||||
|
||||
custom_css = css.replace("@theme_base_color_button", theme_bg_hex_color)
|
||||
|
||||
self.style_provider.load_from_data(custom_css, len(custom_css))
|
||||
|
||||
self.button_easy_install.set_name("button_easy_install")
|
||||
|
||||
settings_adv_file = "/etc/calamares/settings-advanced.conf"
|
||||
system_update_file = "/etc/calamares/modules/packages-system-update.conf"
|
||||
|
||||
app_cmd = [
|
||||
"sudo",
|
||||
"cp",
|
||||
settings_adv_file,
|
||||
"/etc/calamares/settings.conf",
|
||||
]
|
||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
|
||||
app_cmd = [
|
||||
"sudo",
|
||||
"cp",
|
||||
system_update_file,
|
||||
"/etc/calamares/modules/packages.conf",
|
||||
]
|
||||
|
||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
|
||||
efi_file_check = self.file_check("/sys/firmware/efi/fw_platform_size")
|
||||
|
||||
if efi_file_check is True:
|
||||
md = MessageDialogBootloader(
|
||||
title="Choose Bootloader",
|
||||
install_method="Online Installation",
|
||||
pacman_lockfile=self.pacman_lockfile,
|
||||
run_app=self.run_app,
|
||||
calamares_polkit=self.calamares_polkit,
|
||||
)
|
||||
md.show_all()
|
||||
|
||||
else:
|
||||
subprocess.Popen([self.calamares_polkit, "-d"], shell=False)
|
||||
|
||||
else:
|
||||
print(
|
||||
"[ERROR]: Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile
|
||||
)
|
||||
md = Gtk.MessageDialog(
|
||||
parent=self,
|
||||
flags=0,
|
||||
message_type=Gtk.MessageType.WARNING,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
text="Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile,
|
||||
title="Warning",
|
||||
)
|
||||
md.run()
|
||||
md.destroy()
|
||||
|
||||
def on_gp_clicked(self, widget):
|
||||
app_cmd = ["/usr/bin/gparted"]
|
||||
pacman_cmd = [
|
||||
"pkexec",
|
||||
"pacman",
|
||||
"-Sy",
|
||||
"gparted",
|
||||
"--noconfirm",
|
||||
"--needed",
|
||||
]
|
||||
if not self.check_package_installed("gparted"):
|
||||
if not os.path.exists(self.pacman_lockfile):
|
||||
md = Gtk.MessageDialog(
|
||||
parent=self,
|
||||
flags=0,
|
||||
message_type=Gtk.MessageType.WARNING,
|
||||
buttons=Gtk.ButtonsType.NONE,
|
||||
text="%s was not found" % "gparted",
|
||||
title="Warning",
|
||||
)
|
||||
md.add_buttons("Yes", 1)
|
||||
md.add_buttons("No", 0)
|
||||
md.format_secondary_markup("Let Snigdha OS - Welcome install it ?")
|
||||
response = md.run()
|
||||
md.destroy()
|
||||
|
||||
if response == 1:
|
||||
threading.Thread(
|
||||
target=self.check_package_queue, daemon=True
|
||||
).start()
|
||||
threading.Thread(
|
||||
target=self.install_package,
|
||||
args=(
|
||||
app_cmd,
|
||||
pacman_cmd,
|
||||
"gparted",
|
||||
),
|
||||
daemon=True,
|
||||
).start()
|
||||
else:
|
||||
print(
|
||||
"[ERROR]: Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile
|
||||
)
|
||||
md = Gtk.MessageDialog(
|
||||
parent=self,
|
||||
flags=0,
|
||||
message_type=Gtk.MessageType.WARNING,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
text="Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile,
|
||||
title="Warning",
|
||||
)
|
||||
md.run()
|
||||
md.destroy()
|
||||
else:
|
||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
|
||||
def on_buttonarandr_clicked(self, widget):
|
||||
app_cmd = ["/usr/bin/arandr"]
|
||||
pacman_cmd = [
|
||||
"pkexec",
|
||||
"pacman",
|
||||
"-Sy",
|
||||
"arandr",
|
||||
"--noconfirm",
|
||||
"--needed",
|
||||
]
|
||||
|
||||
if not self.check_package_installed("arandr"):
|
||||
if not os.path.exists(self.pacman_lockfile):
|
||||
md = Gtk.MessageDialog(
|
||||
parent=self,
|
||||
flags=0,
|
||||
message_type=Gtk.MessageType.WARNING,
|
||||
buttons=Gtk.ButtonsType.NONE,
|
||||
text="%s was not found\n" % "arandr",
|
||||
title="Warning",
|
||||
)
|
||||
md.add_buttons("Yes", 1)
|
||||
md.add_buttons("No", 0)
|
||||
md.format_secondary_markup("Let Snigdha OS - Welcome install it ?")
|
||||
response = md.run()
|
||||
md.destroy()
|
||||
|
||||
if response == 1:
|
||||
threading.Thread(
|
||||
target=self.check_package_queue, daemon=True
|
||||
).start()
|
||||
threading.Thread(
|
||||
target=self.install_package,
|
||||
args=(
|
||||
app_cmd,
|
||||
pacman_cmd,
|
||||
"arandr",
|
||||
),
|
||||
daemon=True,
|
||||
).start()
|
||||
else:
|
||||
print(
|
||||
"[ERROR]: Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile
|
||||
)
|
||||
md = Gtk.MessageDialog(
|
||||
parent=self,
|
||||
flags=0,
|
||||
message_type=Gtk.MessageType.WARNING,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
text="Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile,
|
||||
title="Warning",
|
||||
)
|
||||
md.run()
|
||||
md.destroy()
|
||||
|
||||
else:
|
||||
threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
|
||||
def remove_dev_package(self, pacman_cmd, package):
|
||||
try:
|
||||
self.label_notify.set_name("label_style")
|
||||
GLib.idle_add(
|
||||
self.label_notify.show,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
"<span foreground='orange'><b>Removing dev package %s</b></span>"
|
||||
% package,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.hide,
|
||||
)
|
||||
|
||||
with subprocess.Popen(
|
||||
pacman_cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
bufsize=1,
|
||||
universal_newlines=True,
|
||||
) as process:
|
||||
while True:
|
||||
if process.poll() is not None:
|
||||
break
|
||||
|
||||
for line in process.stdout:
|
||||
print(line.strip())
|
||||
|
||||
if not self.check_package_installed(package):
|
||||
print("[INFO]: Pacman %s uninstall completed" % package)
|
||||
GLib.idle_add(
|
||||
self.label_notify.show,
|
||||
)
|
||||
self.label_notify.set_name("label_style")
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
"<span foreground='orange'><b>Dev package %s removed</b></span>"
|
||||
% package,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.hide,
|
||||
)
|
||||
else:
|
||||
print("[ERROR]: Pacman %s uninstall failed" % package)
|
||||
self.label_notify.set_name("label_style")
|
||||
GLib.idle_add(
|
||||
self.label_notify.show,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
"<span foreground='red'><b>Failed to remove dev package %s</b></span>"
|
||||
% package,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print("[ERROR]: Exception in remove_dev_package(): %s" % e)
|
||||
self.label_notify.set_name("label_style")
|
||||
GLib.idle_add(
|
||||
self.label_notify.show,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
"<span foreground='red'><b>Failed to remove dev package %s</b></span>"
|
||||
% package,
|
||||
)
|
||||
|
||||
def install_package(self, app_cmd, pacman_cmd, package):
|
||||
try:
|
||||
self.label_notify.set_name("label_style")
|
||||
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
"<span foreground='cyan'><b>Installing %s</b></span>" % package,
|
||||
)
|
||||
|
||||
with subprocess.Popen(
|
||||
pacman_cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
bufsize=1,
|
||||
universal_newlines=True,
|
||||
) as process:
|
||||
while True:
|
||||
if process.poll() is not None:
|
||||
break
|
||||
|
||||
for line in process.stdout:
|
||||
print(line.strip())
|
||||
|
||||
if self.check_package_installed(package):
|
||||
self.pkg_queue.put((0, app_cmd, package))
|
||||
print("[INFO]: Pacman package install completed")
|
||||
self.label_notify.set_name("label_style")
|
||||
GLib.idle_add(
|
||||
self.label_notify.show,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
"<span foreground='purple'><b>Package %s installed</b></span>"
|
||||
% package,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.hide,
|
||||
)
|
||||
else:
|
||||
self.pkg_queue.put((1, app_cmd, package))
|
||||
print("[ERROR]: Pacman package install failed")
|
||||
self.label_notify.set_name("label_style")
|
||||
GLib.idle_add(
|
||||
self.label_notify.show,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
"<span foreground='orange'><b>Package %s install failed</b></span>"
|
||||
% package,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print("[ERROR]: Exception in install_package(): %s" % e)
|
||||
self.label_notify.set_name("label_style")
|
||||
GLib.idle_add(
|
||||
self.label_notify.show,
|
||||
)
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
"<span foreground='red'><b>Package install failed</b></span>",
|
||||
)
|
||||
finally:
|
||||
self.pkg_queue.put(None)
|
||||
|
||||
def run_app(self, app_cmd):
|
||||
process = subprocess.run(
|
||||
app_cmd,
|
||||
shell=False,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
)
|
||||
# for debugging print stdout to console
|
||||
if GUI.debug is True:
|
||||
print(process.stdout)
|
||||
|
||||
def startup_toggle(self, widget):
|
||||
if widget.get_active() is True:
|
||||
if os.path.isfile(GUI.dot_desktop):
|
||||
shutil.copy(GUI.dot_desktop, GUI.autostart)
|
||||
else:
|
||||
if os.path.isfile(GUI.autostart):
|
||||
os.unlink(GUI.autostart)
|
||||
self.save_settings(widget.get_active())
|
||||
|
||||
def save_settings(self, state):
|
||||
with open(GUI.Settings, "w") as f:
|
||||
f.write("autostart=" + str(state))
|
||||
f.close()
|
||||
|
||||
def load_settings(self):
|
||||
line = "True"
|
||||
if os.path.isfile(GUI.Settings):
|
||||
with open(GUI.Settings, "r") as f:
|
||||
lines = f.readlines()
|
||||
for i in range(len(lines)):
|
||||
if "autostart" in lines[i]:
|
||||
line = lines[i].split("=")[1].strip().capitalize()
|
||||
f.close()
|
||||
return line
|
||||
|
||||
def on_link_clicked(self, widget, link):
|
||||
t = threading.Thread(target=self.weblink, args=(link,))
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
def on_social_clicked(self, widget, event, link):
|
||||
t = threading.Thread(target=self.weblink, args=(link,))
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
def _on_info_clicked(self, widget, event):
|
||||
window_list = Wnck.Screen.get_default().get_windows()
|
||||
state = False
|
||||
for win in window_list:
|
||||
if "Information" in win.get_name():
|
||||
state = True
|
||||
if not state:
|
||||
w = conflicts.Conflicts()
|
||||
w.show_all()
|
||||
|
||||
def weblink(self, link):
|
||||
# webbrowser.open_new_tab(link)
|
||||
try:
|
||||
# use xdg-open to use the default browser to open the weblink
|
||||
subprocess.Popen(
|
||||
["xdg-open", link],
|
||||
shell=False,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
except Exception as e:
|
||||
print("Exception in opening weblink(): %s" % e)
|
||||
|
||||
def is_connected(self):
|
||||
try:
|
||||
host = socket.gethostbyname(REMOTE_SERVER)
|
||||
s = socket.create_connection((host, 80), 2)
|
||||
s.close()
|
||||
|
||||
return True
|
||||
except: # noqa
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
def tooltip_callback(self, widget, x, y, keyboard_mode, tooltip, text):
|
||||
tooltip.set_text(text)
|
||||
return True
|
||||
|
||||
def internet_notifier(self):
|
||||
bb = 0
|
||||
dis = 0
|
||||
while True:
|
||||
if not self.is_connected():
|
||||
dis = 1
|
||||
GLib.idle_add(self.button_mirrors.set_sensitive, False)
|
||||
self.label_notify.set_name("label_style")
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
f"<span foreground='yellow'><b>No internet!</b>\n"
|
||||
f"Snigdha OS will <b>not</b> install any additional packages!</span>",
|
||||
) # noqa
|
||||
else:
|
||||
self.label_notify.set_name("")
|
||||
if bb == 0 and dis == 1:
|
||||
GLib.idle_add(self.button_mirrors.set_sensitive, True)
|
||||
GLib.idle_add(self.label_notify.set_text, "")
|
||||
bb = 1
|
||||
sleep(3)
|
||||
|
||||
def check_package_installed(self, package):
|
||||
try:
|
||||
subprocess.check_output("pacman -Qi " + package, shell=True, stderr=subprocess.STDOUT)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
def mirror_update(self):
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
f"<span foreground='cyan'>Updating Arch Mirrorlist\n"
|
||||
f"This may take some time, please wait...</span>",
|
||||
) # noqa
|
||||
GLib.idle_add(self.button_mirrors.set_sensitive, False)
|
||||
subprocess.run(
|
||||
[
|
||||
"pkexec",
|
||||
"/usr/bin/reflector",
|
||||
"--age",
|
||||
"6",
|
||||
"--latest",
|
||||
"21",
|
||||
"--fastest",
|
||||
"21",
|
||||
"--threads",
|
||||
"21",
|
||||
"--sort",
|
||||
"rate",
|
||||
"--protocol",
|
||||
"https",
|
||||
"--save",
|
||||
"/etc/pacman.d/mirrorlist",
|
||||
],
|
||||
shell=False,
|
||||
)
|
||||
print("Update mirrors completed")
|
||||
GLib.idle_add(
|
||||
self.label_notify.set_markup,
|
||||
f"<span foreground='cyan'>Updating Chaotic Aur Mirrorlist\n"
|
||||
f"This may take some time, please wait...</span>",
|
||||
) # noqa
|
||||
GLib.idle_add(self.button_mirrors.set_sensitive, False)
|
||||
subprocess.run(
|
||||
[
|
||||
"pkexec",
|
||||
"/usr/bin/rate-mirrors",
|
||||
"--concurrency",
|
||||
"40",
|
||||
"--disable-comments",
|
||||
"--allow-root",
|
||||
"--save",
|
||||
"/etc/pacman.d/mirrorlist",
|
||||
"chaotic-aur",
|
||||
],
|
||||
shell=False,
|
||||
)
|
||||
print("Update mirrors completed")
|
||||
GLib.idle_add(self.label_notify.set_markup, "<b>Mirrorlist updated</b>")
|
||||
GLib.idle_add(self.button_mirrors.set_sensitive, True)
|
||||
|
||||
|
||||
def MessageBox(self, title, message):
|
||||
md = Gtk.MessageDialog(
|
||||
parent=self,
|
||||
flags=0,
|
||||
message_type=Gtk.MessageType.INFO,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
text=title,
|
||||
)
|
||||
md.format_secondary_markup(message)
|
||||
md.run()
|
||||
md.destroy()
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = Main()
|
||||
w.connect("delete-event", Gtk.main_quit)
|
||||
w.show_all()
|
||||
Gtk.main()
|
||||
83
usr/share/snigdhaos-welcome/tempCodeRunnerFile.py
Normal file
83
usr/share/snigdhaos-welcome/tempCodeRunnerFile.py
Normal file
@@ -0,0 +1,83 @@
|
||||
def on_buttonatt_clicked(self, widget):
|
||||
# app_cmd = [
|
||||
# "/usr/bin/archlinux-tweak-tool",
|
||||
# ]
|
||||
# pacman_cmd = [
|
||||
# "pkexec",
|
||||
# "pacman",
|
||||
# "-Sy",
|
||||
# "archlinux-tweak-tool-git",
|
||||
# "--noconfirm",
|
||||
# "--needed",
|
||||
# ]
|
||||
|
||||
# dev_package = "archlinux-tweak-tool-dev-git"
|
||||
|
||||
# if self.check_package_installed(dev_package):
|
||||
# print("[WARN]: %s package found ..removing it" % dev_package)
|
||||
# self.remove_dev_package(
|
||||
# ["pkexec", "pacman", "-Rs", dev_package, "--noconfirm"], dev_package
|
||||
# )
|
||||
|
||||
# if not self.check_package_installed("archlinux-tweak-tool-git"):
|
||||
# if not os.path.exists(self.pacman_lockfile):
|
||||
# md = MessageDialog(
|
||||
# title="Install Package",
|
||||
# message="<b>Arch Linux Tweak Tool</b> is missing, Let Snigdha OS - Welcome install it ?",
|
||||
# )
|
||||
|
||||
# md.show_all()
|
||||
# md.run()
|
||||
# md.destroy()
|
||||
|
||||
# if md.response is True:
|
||||
# threading.Thread(
|
||||
# target=self.check_package_queue, daemon=True
|
||||
# ).start()
|
||||
# threading.Thread(
|
||||
# target=self.install_package,
|
||||
# args=(
|
||||
# app_cmd,
|
||||
# pacman_cmd,
|
||||
# "archlinux-tweak-tool-git",
|
||||
# ),
|
||||
# daemon=True,
|
||||
# ).start()
|
||||
# else:
|
||||
# print(
|
||||
# "[ERROR]: Pacman lockfile found %s, is another pacman process running ?"
|
||||
# % self.pacman_lockfile
|
||||
# )
|
||||
# md = Gtk.MessageDialog(
|
||||
# parent=self,
|
||||
# flags=0,
|
||||
# message_type=Gtk.MessageType.WARNING,
|
||||
# buttons=Gtk.ButtonsType.OK,
|
||||
# text="Pacman lockfile found %s, is another pacman process running ?"
|
||||
# % self.pacman_lockfile,
|
||||
# title="Warning",
|
||||
# )
|
||||
# md.run()
|
||||
# md.destroy()
|
||||
# else:
|
||||
# threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
|
||||
# def check_package_installed(self, package):
|
||||
# pacman_cmd = ["pacman", "-Qi", package]
|
||||
# try:
|
||||
# process = subprocess.run(
|
||||
# pacman_cmd,
|
||||
# shell=False,
|
||||
# stdout=subprocess.PIPE,
|
||||
# stderr=subprocess.STDOUT,
|
||||
# universal_newlines=True,
|
||||
# )
|
||||
|
||||
# if process.returncode == 0:
|
||||
# # package is installed
|
||||
# return True
|
||||
# else:
|
||||
# return False
|
||||
# except subprocess.CalledProcessError as e:
|
||||
# # package is not installed
|
||||
# return False
|
||||
679
usr/share/snigdhaos-welcome/ui/GUI.py
Normal file
679
usr/share/snigdhaos-welcome/ui/GUI.py
Normal file
@@ -0,0 +1,679 @@
|
||||
# Author: Erik Dubois [Arcolinux]
|
||||
# Adopted for Snigdha OS
|
||||
|
||||
import os
|
||||
import getpass
|
||||
from os.path import expanduser
|
||||
from ui.Stack import Stack
|
||||
from ui.StackSwitcher import StackSwitcher
|
||||
|
||||
debug = False
|
||||
# debug = True
|
||||
|
||||
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
home = expanduser("~")
|
||||
username = getpass.getuser()
|
||||
|
||||
app_discord = "#"
|
||||
app_website = "https://snigdhaos.org/"
|
||||
app_forums = "https://forum.snigdhaos.org/"
|
||||
app_facebook = "https://facebook.com/snigdhalinux/"
|
||||
app_twitter = "https://twitter.com/snigdhaos/"
|
||||
|
||||
if debug:
|
||||
user = username
|
||||
else:
|
||||
user = "eshan"
|
||||
|
||||
Settings = home + "/.config/snigdhaos-welcome/settings.conf"
|
||||
Skel_Settings = "/etc/skel/.config/snigdhaos-welcome/settings.conf"
|
||||
dot_desktop = "/usr/share/applications/snigdhaos-welcome.desktop"
|
||||
autostart = home + "/.config/autostart/snigdhaos-welcome.desktop"
|
||||
|
||||
|
||||
def GUI(self, Gtk, GdkPixbuf):
|
||||
# initialize main vbox
|
||||
self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
|
||||
self.vbox.set_halign(Gtk.Align.CENTER)
|
||||
self.add(self.vbox)
|
||||
|
||||
headerbar = Gtk.HeaderBar()
|
||||
headerbar.set_title("Snigdha OS Welcome - Arctic")
|
||||
headerbar.set_show_close_button(True)
|
||||
|
||||
self.set_titlebar(headerbar)
|
||||
|
||||
# x11 shows icon inside headerbar twice, only set icon when on wayland
|
||||
if self.session is not None:
|
||||
if self.session == "wayland":
|
||||
headerbar.pack_start(
|
||||
Gtk.Image().new_from_pixbuf(
|
||||
GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
os.path.join(base_dir, "images/snigdhaos-icon.png"), 16, 16
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
# initialize the stack
|
||||
stack = Stack(transition_type="CROSSFADE")
|
||||
|
||||
# initialize the stack-switcher
|
||||
stack_switcher = StackSwitcher(stack)
|
||||
|
||||
vbox_stack_sidebar = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=25)
|
||||
vbox_stack_sidebar.set_name("stack_box")
|
||||
|
||||
vbox_stack_sidebar.add(stack_switcher)
|
||||
vbox_stack_sidebar.add(stack)
|
||||
|
||||
self.vbox.add(vbox_stack_sidebar)
|
||||
|
||||
# vbox to contain all the installation controls
|
||||
vbox_install_stack = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||
vbox_install_stack.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
hbox_install_buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
|
||||
hbox_install_buttons.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
vbox_quit = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||
vbox_quit.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
hbox_util_buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
|
||||
hbox_util_buttons.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
vbox_welcome_title = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20)
|
||||
vbox_welcome_title.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
vbox_welcome_message = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
|
||||
vbox_welcome_message.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
vbox_install_stack.pack_start(vbox_welcome_title, False, False, 0)
|
||||
vbox_install_stack.pack_start(vbox_welcome_message, False, False, 0)
|
||||
vbox_install_stack.pack_start(hbox_install_buttons, False, False, 0)
|
||||
# vbox_install_stack.pack_start(hbox_second_row_buttons, False, False, 0)
|
||||
vbox_install_stack.pack_start(hbox_util_buttons, False, False, 0)
|
||||
vbox_install_stack.pack_start(vbox_quit, False, False, 0)
|
||||
|
||||
# vbox to contain all the information text
|
||||
vbox_info_stack = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
|
||||
vbox_info_stack.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
vbox_info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
|
||||
vbox_info_stack.pack_start(vbox_info, False, False, 0)
|
||||
|
||||
# vbox to contain credits text
|
||||
vbox_credits_stack = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
|
||||
vbox_credits_stack.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
vbox_credits = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
|
||||
vbox_credits_stack.pack_start(vbox_credits, False, False, 0)
|
||||
|
||||
hbox_social_links = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
|
||||
hbox_social_links.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
# social links with images
|
||||
hbox_social_img = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=25)
|
||||
hbox_social_img.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
label_discord = Gtk.Label(xalign=0, yalign=0)
|
||||
label_discord.set_markup(
|
||||
"<a href='%s' title='%s'>%s</a>" % (app_discord, app_discord, "Discord")
|
||||
)
|
||||
|
||||
label_telegram = Gtk.Label(xalign=0, yalign=0)
|
||||
label_telegram.set_markup(
|
||||
"<a href='%s' title='%s'>%s</a>" % (app_facebook, app_facebook, "Facebook")
|
||||
)
|
||||
|
||||
label_youtube = Gtk.Label(xalign=0, yalign=0)
|
||||
label_youtube.set_markup(
|
||||
"<a href='%s' title='%s'>%s</a>" % (app_twitter, app_twitter, "Twitter")
|
||||
)
|
||||
|
||||
label_forums = Gtk.Label(xalign=0, yalign=0)
|
||||
label_forums.set_markup(
|
||||
"<a href='%s' title='%s'>%s</a>" % (app_forums, app_forums, "Forums")
|
||||
)
|
||||
|
||||
# ======================================================================
|
||||
# SOCIAL LINKS
|
||||
# ======================================================================
|
||||
|
||||
# facebook
|
||||
|
||||
fb_event = Gtk.EventBox()
|
||||
pbfb = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
os.path.join(base_dir, "images/facebook.png"), 64, 64
|
||||
)
|
||||
fbimage = Gtk.Image().new_from_pixbuf(pbfb)
|
||||
fb_event.add(fbimage)
|
||||
fb_event.connect(
|
||||
"button_press_event",
|
||||
self.on_social_clicked,
|
||||
"https://www.facebook.com/snigdhalinux/",
|
||||
)
|
||||
|
||||
# telegram
|
||||
# tg_event = Gtk.EventBox()
|
||||
# pbtg = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
# os.path.join(base_dir, "images/tg.png"), 28, 28
|
||||
# )
|
||||
# tgimage = Gtk.Image().new_from_pixbuf(pbtg)
|
||||
# tg_event.add(tgimage)
|
||||
# tg_event.connect(
|
||||
# "button_press_event",
|
||||
# self.on_social_clicked,
|
||||
# app_facebook,
|
||||
# )
|
||||
|
||||
# twitter
|
||||
tw_event = Gtk.EventBox()
|
||||
pbtw = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
os.path.join(base_dir, "images/twitter.png"), 64, 64
|
||||
)
|
||||
twimage = Gtk.Image().new_from_pixbuf(pbtw)
|
||||
tw_event.add(twimage)
|
||||
tw_event.connect(
|
||||
"button_press_event",
|
||||
self.on_social_clicked,
|
||||
"https://twitter.com/snigdhaos",
|
||||
)
|
||||
|
||||
# mewe
|
||||
mew_event = Gtk.EventBox()
|
||||
pbmew = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
os.path.join(base_dir, "images/github.png"), 64, 64
|
||||
)
|
||||
mewimage = Gtk.Image().new_from_pixbuf(pbmew)
|
||||
mew_event.add(mewimage)
|
||||
mew_event.connect(
|
||||
"button_press_event",
|
||||
self.on_social_clicked,
|
||||
"https://github.com/snigdhalinux",
|
||||
)
|
||||
|
||||
# discord
|
||||
# ds_event = Gtk.EventBox()
|
||||
# pbds = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
# os.path.join(base_dir, "images/discord.png"), 28, 28
|
||||
# )
|
||||
# dsimage = Gtk.Image().new_from_pixbuf(pbds)
|
||||
# ds_event.add(dsimage)
|
||||
# ds_event.connect(
|
||||
# "button_press_event",
|
||||
# self.on_social_clicked,
|
||||
# app_discord,
|
||||
# )
|
||||
|
||||
# youtube
|
||||
# yt_event = Gtk.EventBox()
|
||||
# pbyt = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
# os.path.join(base_dir, "images/youtube.png"), 28, 28
|
||||
# )
|
||||
# ytimage = Gtk.Image().new_from_pixbuf(pbyt)
|
||||
# yt_event.add(ytimage)
|
||||
# yt_event.connect(
|
||||
# "button_press_event",
|
||||
# self.on_social_clicked,
|
||||
# "https://youtube.com/c/erikdubois",
|
||||
# )
|
||||
|
||||
# instagram
|
||||
# insta_event = Gtk.EventBox()
|
||||
# pbinsta = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
# os.path.join(base_dir, "images/insta.png"), 28, 28
|
||||
# )
|
||||
# instaimage = Gtk.Image().new_from_pixbuf(pbinsta)
|
||||
# insta_event.add(instaimage)
|
||||
# insta_event.connect(
|
||||
# "button_press_event",
|
||||
# self.on_social_clicked,
|
||||
# "https://www.instagram.com/arcolinux/",
|
||||
# )
|
||||
|
||||
# linkedin
|
||||
# lin_event = Gtk.EventBox()
|
||||
# pblin = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
# os.path.join(base_dir, "images/linkedin.png"), 28, 28
|
||||
# )
|
||||
# linimage = Gtk.Image().new_from_pixbuf(pblin)
|
||||
# lin_event.add(linimage)
|
||||
# lin_event.connect(
|
||||
# "button_press_event",
|
||||
# self.on_social_clicked,
|
||||
# "https://www.linkedin.com/in/arcolinux/",
|
||||
# )
|
||||
|
||||
# patreon
|
||||
# pat_event = Gtk.EventBox()
|
||||
# pbpat = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
# os.path.join(base_dir, "images/patreon.png"), 28, 28
|
||||
# )
|
||||
# patimage = Gtk.Image().new_from_pixbuf(pbpat)
|
||||
# pat_event.add(patimage)
|
||||
# pat_event.connect(
|
||||
# "button_press_event",
|
||||
# self.on_social_clicked,
|
||||
# "https://www.patreon.com/arcolinux",
|
||||
# )
|
||||
|
||||
# element
|
||||
# el_event = Gtk.EventBox()
|
||||
# pbel = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
# os.path.join(base_dir, "images/element.png"), 28, 28
|
||||
# )
|
||||
# elimage = Gtk.Image().new_from_pixbuf(pbel)
|
||||
# el_event.add(elimage)
|
||||
# el_event.connect(
|
||||
# "button_press_event",
|
||||
# self.on_social_clicked,
|
||||
# "https://app.element.io/#/room/!jUDkosOsuDbGWNzKYl:matrix.org",
|
||||
# )
|
||||
|
||||
# att
|
||||
# att_event = Gtk.EventBox()
|
||||
# pbatt = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
# os.path.join(base_dir, "images/archlinux-tweak-tool.svg"), 28, 28
|
||||
# )
|
||||
# attimage = Gtk.Image().new_from_pixbuf(pbatt)
|
||||
# att_event.add(attimage)
|
||||
# att_event.connect("button_press_event", self.on_launch_clicked, "")
|
||||
|
||||
label_social_padding = Gtk.Label(xalign=0, yalign=0)
|
||||
label_social_padding.set_text(" ")
|
||||
|
||||
# tooltips
|
||||
fb_event.set_property("has-tooltip", True)
|
||||
tw_event.set_property("has-tooltip", True)
|
||||
mew_event.set_property("has-tooltip", True)
|
||||
# insta_event.set_property("has-tooltip", True)
|
||||
# lin_event.set_property("has-tooltip", True)
|
||||
# el_event.set_property("has-tooltip", True)
|
||||
# pat_event.set_property("has-tooltip", True)
|
||||
# yt_event.set_property("has-tooltip", True)
|
||||
# ds_event.set_property("has-tooltip", True)
|
||||
# tg_event.set_property("has-tooltip", True)
|
||||
# att_event.set_property("has-tooltip", True)
|
||||
|
||||
fb_event.connect("query-tooltip", self.tooltip_callback, "Facebook")
|
||||
tw_event.connect("query-tooltip", self.tooltip_callback, "Twitter")
|
||||
mew_event.connect("query-tooltip", self.tooltip_callback, "Github")
|
||||
# insta_event.connect("query-tooltip", self.tooltip_callback, "Instagram")
|
||||
# lin_event.connect("query-tooltip", self.tooltip_callback, "LinkedIn")
|
||||
# el_event.connect("query-tooltip", self.tooltip_callback, "Element")
|
||||
# el_event.connect("query-tooltip", self.tooltip_callback, "Element-Matrix")
|
||||
# pat_event.connect("query-tooltip", self.tooltip_callback, "Patreon")
|
||||
# yt_event.connect("query-tooltip", self.tooltip_callback, "YouTube")
|
||||
# ds_event.connect("query-tooltip", self.tooltip_callback, "Discord")
|
||||
# tg_event.connect("query-tooltip", self.tooltip_callback, "Telegram")
|
||||
# att_event.connect("query-tooltip", self.tooltip_callback, "Arch Linux Tweak Tool")
|
||||
|
||||
hbox_social_img.add(fb_event)
|
||||
hbox_social_img.add(tw_event)
|
||||
hbox_social_img.add(mew_event)
|
||||
# hbox_social_img.add(insta_event)
|
||||
# hbox_social_img.add(lin_event)
|
||||
# hbox_social_img.add(el_event)
|
||||
# hbox_social_img.add(pat_event)
|
||||
# hbox_social_img.add(label_social_padding)
|
||||
# hbox_social_img.add(yt_event)
|
||||
# hbox_social_img.add(ds_event)
|
||||
# hbox_social_img.add(tg_event)
|
||||
# hbox_social_img.add(att_event)
|
||||
|
||||
label_info_header1 = Gtk.Label(xalign=0, yalign=0)
|
||||
label_info_header1.set_name("label_style")
|
||||
label_info_header1.set_justify(Gtk.Justification.CENTER)
|
||||
label_info_header1.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
label_info_header2 = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
label_info_header2.set_name("label_style")
|
||||
label_info_header2.set_justify(Gtk.Justification.CENTER)
|
||||
label_info_header2.set_halign(Gtk.Align.CENTER)
|
||||
label_info_header2.set_markup("<b>You have the freedom of choice</b>")
|
||||
|
||||
label_info2 = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
label_info2.set_justify(Gtk.Justification.CENTER)
|
||||
|
||||
if debug is True:
|
||||
label_info_header1.set_markup("<b>Snigdha OS - Arctic Installer</b>")
|
||||
|
||||
desc = (
|
||||
f"Clean You Computer With GParted before installing Snigdha OS.\n"
|
||||
f"During the <b>Online Installation</b> many options will be open to you.\n\n"
|
||||
f"<b>Offline Installation</b> does not require internet connection.\n"
|
||||
f"<b>Online installation</b> (Recommended) requires a working internet connection"
|
||||
)
|
||||
|
||||
desc2 = (
|
||||
f"Welcome to A Blazing Fast and Optimized Operating System.\n"
|
||||
f"Snigdha OS\n"
|
||||
f"Follow our facebook Page to get update about latest news and upcoming features.\n"
|
||||
f"Also you can follow us on github and suggest more features.\n"
|
||||
f"Get Registered for beta testing[Beta Image may be unstable.]\n\n"
|
||||
)
|
||||
|
||||
label_info2.set_markup(desc2)
|
||||
|
||||
else:
|
||||
label_info_header1.set_markup("<b>Welcome to Snigdha OS - Arctic</b>")
|
||||
desc = (
|
||||
f"Welcome to A Blazing Fast and Optimized Operating System.\n"
|
||||
f"Snigdha OS\n"
|
||||
f"Follow our facebook Page to get update about latest news and upcoming features.\n"
|
||||
f"Also you can follow us on github and suggest more features.\n"
|
||||
f"Get Registered for beta testing[Beta Image may be unstable.]\n\n"
|
||||
)
|
||||
|
||||
label_info = Gtk.Label(xalign=0, yalign=0)
|
||||
label_info.set_markup(desc)
|
||||
label_info.set_justify(Gtk.Justification.CENTER)
|
||||
|
||||
# ======================================================================
|
||||
# PACK THE INFO BOX
|
||||
# ======================================================================
|
||||
|
||||
vbox_info.pack_start(label_info_header1, False, False, 0)
|
||||
vbox_info.pack_start(label_info, False, False, 0)
|
||||
if len(label_info2.get_text()) > 0:
|
||||
vbox_info.pack_start(label_info_header2, False, False, 0)
|
||||
vbox_info.pack_start(label_info2, False, False, 0)
|
||||
|
||||
vbox_info.pack_start(hbox_social_links, False, False, 0)
|
||||
vbox_info.pack_start(hbox_social_img, False, False, 0)
|
||||
|
||||
# ======================================================================
|
||||
# ADD PAGES TO STACK
|
||||
# ======================================================================
|
||||
|
||||
if debug is True:
|
||||
stack.add_titled(vbox_install_stack, "Installation", "Installation")
|
||||
else:
|
||||
stack.add_titled(vbox_install_stack, "Welcome", "Welcome")
|
||||
|
||||
stack.add_titled(vbox_info_stack, "Information", "Information")
|
||||
stack.add_titled(vbox_credits_stack, "Developers", "Developers")
|
||||
|
||||
autostart = eval(self.load_settings())
|
||||
|
||||
hbox_notify = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
|
||||
hbox_notify.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
hbox_footer_buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
|
||||
|
||||
# ======================================================================
|
||||
# NOTIFY LABEL
|
||||
# ======================================================================
|
||||
|
||||
self.label_notify = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
self.label_notify.set_justify(Gtk.Justification.CENTER)
|
||||
hbox_notify.pack_end(self.label_notify, False, False, 0)
|
||||
|
||||
# ======================================================================
|
||||
# WELCOME LABEL
|
||||
# ======================================================================
|
||||
|
||||
# label_welcome = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
# label_welcome.set_markup("<big>Welcome to <b>ArcoLinux</b></big>")
|
||||
|
||||
# ======================================================================
|
||||
# ARCO IMAGE
|
||||
# ======================================================================
|
||||
|
||||
pixbuf = GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
os.path.join(base_dir, "images/snigdhaos-icon.png"), 164, 164
|
||||
)
|
||||
image = Gtk.Image().new_from_pixbuf(pixbuf)
|
||||
|
||||
# ======================================================================
|
||||
# WELCOME LABEL
|
||||
# ======================================================================
|
||||
|
||||
label_welcome_message = Gtk.Label(xalign=0, yalign=0)
|
||||
label_welcome_message.set_name("label_style_eshan")
|
||||
|
||||
if username == user:
|
||||
label_welcome_message.set_text(
|
||||
"Use Offline Installation in case Online Installation fails!"
|
||||
)
|
||||
else:
|
||||
label_welcome_message.set_text(
|
||||
"The options below will help you get started on Snigdha OS\nIf You are having any problem, just raise your issue in our forum!"
|
||||
)
|
||||
|
||||
vbox_welcome_title.pack_start(image, True, False, 0)
|
||||
vbox_welcome_message.pack_start(label_welcome_message, True, False, 0)
|
||||
|
||||
# ======================================================================
|
||||
# MAIN BUTTONS
|
||||
# ======================================================================
|
||||
|
||||
# ======================================================================
|
||||
# BUTTON - GPARTED
|
||||
# ======================================================================
|
||||
|
||||
button_gparted = Gtk.Button(label="")
|
||||
button_gparted_label = button_gparted.get_child()
|
||||
button_gparted_label.set_markup("Run GParted")
|
||||
button_gparted.connect("clicked", self.on_gp_clicked)
|
||||
button_gparted.set_size_request(100, 50)
|
||||
button_gparted.set_property("has-tooltip", True)
|
||||
button_gparted.connect("query-tooltip", self.tooltip_callback, "Launch GParted")
|
||||
|
||||
# ======================================================================
|
||||
# BUTTON - EASY INSTALL
|
||||
# ======================================================================
|
||||
|
||||
self.button_easy_install = Gtk.Button(label="")
|
||||
button_easy_install_label = self.button_easy_install.get_child()
|
||||
button_easy_install_label.set_markup(
|
||||
"<span size='large'>Offline Installation</span>"
|
||||
)
|
||||
self.button_easy_install.connect("clicked", self.on_easy_install_clicked)
|
||||
self.button_easy_install.set_size_request(300, 60)
|
||||
self.button_easy_install.set_property("has-tooltip", True)
|
||||
self.button_easy_install.connect(
|
||||
"query-tooltip", self.tooltip_callback, "No internet connection required"
|
||||
)
|
||||
# ======================================================================
|
||||
# BUTTON - ADV INSTALL
|
||||
# ======================================================================
|
||||
|
||||
self.button_adv_install = Gtk.Button(label="")
|
||||
button_adv_label = self.button_adv_install.get_child()
|
||||
|
||||
button_adv_label.set_markup(
|
||||
"<span size='large'>Online Installation</span>"
|
||||
)
|
||||
self.button_adv_install.connect("clicked", self.on_adv_install_clicked)
|
||||
self.button_adv_install.set_size_request(300, 60)
|
||||
self.button_adv_install.set_property("has-tooltip", True)
|
||||
self.button_adv_install.connect(
|
||||
"query-tooltip", self.tooltip_callback, "Internet connection required!"
|
||||
)
|
||||
|
||||
# ======================================================================
|
||||
# BUTTON - MIRRORS
|
||||
# ======================================================================
|
||||
|
||||
self.button_mirrors = Gtk.Button(label="")
|
||||
button_mirrors_label = self.button_mirrors.get_child()
|
||||
|
||||
button_mirrors_label.set_markup("Update Mirrors")
|
||||
|
||||
self.button_mirrors.connect("clicked", self.on_mirror_clicked)
|
||||
self.button_mirrors.set_size_request(100, 50)
|
||||
self.button_mirrors.set_property("has-tooltip", True)
|
||||
self.button_mirrors.connect(
|
||||
"query-tooltip", self.tooltip_callback, "Update Mirrorlist"
|
||||
)
|
||||
|
||||
# ======================================================================
|
||||
# BUTTON - ATT
|
||||
# ======================================================================
|
||||
|
||||
# self.button_att = Gtk.Button(label="")
|
||||
# button_att_label = self.button_att.get_child()
|
||||
# button_att_label.set_markup(
|
||||
# "<span size='large'><b>Launch Arch Linux Tweak Tool</b></span>"
|
||||
# )
|
||||
# self.button_att.connect("clicked", self.on_buttonatt_clicked)
|
||||
# self.button_att.set_property("has-tooltip", True)
|
||||
# self.button_att.connect(
|
||||
# "query-tooltip", self.tooltip_callback, "Launch Arch Linux Tweak Tool"
|
||||
# )
|
||||
|
||||
# ======================================================================
|
||||
# BUTTON - SOFI
|
||||
# ======================================================================
|
||||
|
||||
# self.button_sofi = Gtk.Button(label="")
|
||||
# button_sofi_label = self.button_sofi.get_child()
|
||||
# button_sofi_label.set_markup("<span size='large'><b>Install Software</b></span>")
|
||||
# self.button_sofi.connect("clicked", self.on_button_sofi_clicked)
|
||||
# self.button_sofi.set_property("has-tooltip", True)
|
||||
# self.button_sofi.connect("query-tooltip", self.tooltip_callback, "Launch Sofirem")
|
||||
|
||||
# ======================================================================
|
||||
# BUTTON - ARANDR
|
||||
# ======================================================================
|
||||
|
||||
button_resolution = Gtk.Button(label="Fix Screen Resolution")
|
||||
button_resolution.set_size_request(100, 50)
|
||||
button_resolution.set_property("has-tooltip", True)
|
||||
button_resolution.connect("query-tooltip", self.tooltip_callback, "Launch Arandr")
|
||||
button_resolution.connect("clicked", self.on_buttonarandr_clicked)
|
||||
|
||||
if username == user:
|
||||
hbox_util_buttons.pack_start(self.button_mirrors, False, True, 0)
|
||||
hbox_util_buttons.pack_start(button_gparted, False, True, 0)
|
||||
|
||||
if self.session == "x11":
|
||||
hbox_util_buttons.pack_start(button_resolution, False, True, 0)
|
||||
|
||||
hbox_install_buttons.pack_start(self.button_easy_install, True, True, 0)
|
||||
hbox_install_buttons.pack_end(self.button_adv_install, True, True, 0)
|
||||
|
||||
else:
|
||||
# self.button_att.set_size_request(100, 30)
|
||||
# self.button_sofi.set_size_request(100, 30)
|
||||
|
||||
self.button_mirrors.get_child().set_markup("Update Mirrors")
|
||||
|
||||
# self.button_att.get_child().set_markup("<b>Launch Arch Linux Tweak Tool</b>")
|
||||
|
||||
# self.button_sofi.get_child().set_markup("<b>Install Software</b>")
|
||||
|
||||
button_resolution.get_child().set_markup("<b>Screen Resolution</b>")
|
||||
|
||||
# hbox_install_buttons.pack_start(self.button_sofi, False, True, 0)
|
||||
# hbox_install_buttons.pack_start(self.button_att, False, True, 0)
|
||||
hbox_install_buttons.pack_start(self.button_mirrors, False, True, 0)
|
||||
|
||||
# self.button_arco_website = Gtk.Button(label="")
|
||||
# self.button_arco_website.get_child().set_markup("<b>ArcoLinux Website</b>")
|
||||
# self.button_arco_website.set_size_request(100, 30)
|
||||
#
|
||||
# self.button_probe = Gtk.Button(label="")
|
||||
# self.button_probe.get_child().set_markup("<b>Run Probe</b>")
|
||||
# self.button_probe.set_size_request(100, 30)
|
||||
|
||||
# hbox_second_row_buttons.pack_start(self.button_arco_website,False,True,0)
|
||||
# hbox_second_row_buttons.pack_start(self.button_probe,False,True,0)
|
||||
|
||||
if self.session == "x11":
|
||||
hbox_install_buttons.pack_start(button_resolution, False, True, 0)
|
||||
|
||||
# ======================================================================
|
||||
# USER INFO
|
||||
# ======================================================================
|
||||
|
||||
label_creds = Gtk.Label(xalign=0)
|
||||
label_creds.set_markup("User: liveuser | Pass: No Password")
|
||||
label_creds.set_name("label_style")
|
||||
|
||||
hbox_user = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
|
||||
|
||||
hbox_user.pack_start(label_creds, False, False, 0)
|
||||
|
||||
# ======================================================================
|
||||
# CREDITS
|
||||
# ======================================================================
|
||||
|
||||
label_credits_title = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
label_credits_title.set_name("label_style")
|
||||
label_credits_title.set_markup("<b>Meet The Developers</b>")
|
||||
label_credits_title.set_halign(Gtk.Align.CENTER)
|
||||
label_credits_title.set_justify(Gtk.Justification.CENTER)
|
||||
|
||||
label_credits_support = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
label_credits_support.set_name("label_style")
|
||||
label_credits_support.set_markup(
|
||||
f"For support or to report any issues use <b><a href='{app_forums}' title='{app_forums}'>Snigdha OS Forum</a></b>"
|
||||
)
|
||||
label_credits_support.set_halign(Gtk.Align.CENTER)
|
||||
label_credits_support.set_justify(Gtk.Justification.CENTER)
|
||||
|
||||
label_credits = Gtk.Label(xalign=0, yalign=0)
|
||||
label_credits.set_markup(
|
||||
f"Eshanized\n"
|
||||
f"Iconized\n"
|
||||
f"Snigdha\n"
|
||||
# f"Eshanized\n"
|
||||
# f"For support, or to report any issues use <b><a href='{app_discord}' title='{app_discord}'>Discord</a></b>"
|
||||
)
|
||||
# label_credits.set_markup(
|
||||
# f"Eshanized\n"
|
||||
# )
|
||||
label_credits.set_justify(Gtk.Justification.CENTER)
|
||||
label_credits.set_line_wrap(True)
|
||||
label_credits.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
vbox_credits.pack_start(label_credits_title, False, False, 0)
|
||||
vbox_credits.pack_start(label_credits, False, False, 0)
|
||||
vbox_credits.pack_start(label_credits_support, False, False, 0)
|
||||
|
||||
# ======================================================================
|
||||
# QUIT BUTTON
|
||||
# ======================================================================
|
||||
|
||||
button_quit = Gtk.Button(label="")
|
||||
button_quit.get_child().set_markup("EXIT")
|
||||
button_quit.set_size_request(100, 40)
|
||||
button_quit.connect("clicked", Gtk.main_quit)
|
||||
|
||||
vbox_quit.pack_start(button_quit, False, False, 0)
|
||||
|
||||
# ======================================================================
|
||||
# Add to startup
|
||||
# ======================================================================
|
||||
|
||||
check = Gtk.CheckButton(label="Autostart")
|
||||
check.set_property("has-tooltip", True)
|
||||
check.connect(
|
||||
"query-tooltip",
|
||||
self.tooltip_callback,
|
||||
"Untick if you do not want Snigdha OS Welcome to run @startup!",
|
||||
)
|
||||
check.connect("toggled", self.startup_toggle)
|
||||
check.set_active(autostart)
|
||||
|
||||
hbox_footer_buttons.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
if username == user:
|
||||
hbox_footer_buttons.pack_start(hbox_user, True, False, 0)
|
||||
|
||||
vbox_auto_start = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
|
||||
vbox_auto_start.set_halign(Gtk.Align.CENTER)
|
||||
vbox_auto_start.pack_end(check, True, False, 0)
|
||||
self.vbox.pack_end(vbox_auto_start, True, False, 0)
|
||||
else:
|
||||
hbox_footer_buttons.pack_end(check, False, False, 0)
|
||||
|
||||
# ======================================================================
|
||||
# PACK TO WINDOW
|
||||
# ======================================================================
|
||||
|
||||
self.vbox.pack_start(hbox_notify, False, False, 5) # notify label
|
||||
|
||||
self.vbox.pack_end(hbox_footer_buttons, False, False, 0) # Footer
|
||||
266
usr/share/snigdhaos-welcome/ui/MessageDialog.py
Normal file
266
usr/share/snigdhaos-welcome/ui/MessageDialog.py
Normal file
@@ -0,0 +1,266 @@
|
||||
# This class is only for constructing a Message Dialog
|
||||
|
||||
import os
|
||||
import gi
|
||||
import subprocess
|
||||
import threading
|
||||
from threading import Thread
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GdkPixbuf
|
||||
|
||||
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
|
||||
# generic Message Dialog with yes/no buttons
|
||||
class MessageDialog(Gtk.Dialog):
|
||||
def __init__(self, title, message):
|
||||
Gtk.Dialog.__init__(self)
|
||||
|
||||
self.set_border_width(10)
|
||||
self.set_title(title)
|
||||
self.set_modal(True)
|
||||
|
||||
self.set_resizable(False)
|
||||
|
||||
self.response = False
|
||||
|
||||
headerbar = Gtk.HeaderBar()
|
||||
headerbar.set_title(title)
|
||||
headerbar.set_show_close_button(True)
|
||||
|
||||
headerbar.pack_start(
|
||||
Gtk.Image().new_from_pixbuf(
|
||||
GdkPixbuf.Pixbuf().new_from_file_at_size(os.path.join(base_dir, "images/snigdhaos-icon.png"), 24, 24)
|
||||
)
|
||||
)
|
||||
|
||||
self.set_titlebar(headerbar)
|
||||
|
||||
btn_yes = Gtk.Button(label="Yes")
|
||||
btn_yes.set_size_request(100, 30)
|
||||
btn_yes.connect("clicked", self.on_md_yes_clicked)
|
||||
btn_yes.set_halign(Gtk.Align.END)
|
||||
|
||||
btn_no = Gtk.Button(label="No")
|
||||
btn_no.set_size_request(100, 30)
|
||||
btn_no.connect("clicked", self.on_md_no_clicked)
|
||||
btn_no.set_halign(Gtk.Align.END)
|
||||
|
||||
label_message = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
label_message.set_markup(message)
|
||||
|
||||
hbox_buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||
hbox_buttons.pack_start(btn_yes, False, False, 0)
|
||||
hbox_buttons.pack_start(btn_no, False, False, 0)
|
||||
|
||||
hbox_buttons.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
self.vbox.set_spacing(5)
|
||||
|
||||
self.vbox.add(label_message)
|
||||
|
||||
self.vbox.add(hbox_buttons)
|
||||
|
||||
def on_md_yes_clicked(self, widget):
|
||||
self.response = True
|
||||
self.destroy()
|
||||
|
||||
def on_md_no_clicked(self, widget):
|
||||
self.response = False
|
||||
self.destroy()
|
||||
|
||||
|
||||
class MessageDialogBootloader(Gtk.Dialog):
|
||||
def __init__(
|
||||
self,
|
||||
title,
|
||||
install_method,
|
||||
pacman_lockfile,
|
||||
run_app,
|
||||
calamares_polkit,
|
||||
):
|
||||
Gtk.Dialog.__init__(self)
|
||||
|
||||
self.set_border_width(20)
|
||||
self.set_title(title)
|
||||
self.set_modal(True)
|
||||
# self.set_default_size(600, 100)
|
||||
self.set_resizable(False)
|
||||
|
||||
self.pacman_lockfile = pacman_lockfile
|
||||
self.run_app = run_app
|
||||
self.calamares_polkit = calamares_polkit
|
||||
|
||||
self.label_message = Gtk.Label(xalign=0, yalign=0)
|
||||
self.label_message.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
headerbar = Gtk.HeaderBar()
|
||||
headerbar.set_title(title)
|
||||
headerbar.set_show_close_button(True)
|
||||
|
||||
headerbar.pack_start(
|
||||
Gtk.Image().new_from_pixbuf(
|
||||
GdkPixbuf.Pixbuf().new_from_file_at_size(
|
||||
os.path.join(base_dir, "images/snigdhaos-icon.png"), 24, 24
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self.set_titlebar(headerbar)
|
||||
|
||||
btn_cancel = Gtk.Button(label="Cancel")
|
||||
btn_cancel.set_size_request(100, 50)
|
||||
btn_cancel.connect("clicked", self.on_md_cancel_clicked)
|
||||
btn_cancel.set_halign(Gtk.Align.END)
|
||||
|
||||
title_message = "You have chosen the %s option" % install_method
|
||||
|
||||
title_second_message = (
|
||||
"Would you like to install <b>Grub (Recommended)</b> or <b>Systemd-boot</b> ?"
|
||||
)
|
||||
|
||||
btn_bootloader_grub = Gtk.Button(label="Install Grub")
|
||||
btn_bootloader_grub.set_size_request(100, 50)
|
||||
btn_bootloader_grub.connect("clicked", self.on_bootloader_grub_clicked)
|
||||
|
||||
btn_bootloader_systemd_boot = Gtk.Button(label="Install Systemd-boot")
|
||||
btn_bootloader_systemd_boot.set_size_request(100, 50)
|
||||
btn_bootloader_systemd_boot.connect(
|
||||
"clicked", self.on_bootloader_systemd_boot_clicked
|
||||
)
|
||||
|
||||
label_title_message = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
label_title_message.set_markup("<b>%s</b>" % title_message)
|
||||
|
||||
label_title_message.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
label_title_second_message = Gtk.Label(xalign=0.5, yalign=0.5)
|
||||
label_title_second_message.set_markup("%s" % title_second_message)
|
||||
|
||||
label_title_second_message.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
lbl_padding1 = Gtk.Label(xalign=0, yalign=0)
|
||||
lbl_padding1.set_text(" ")
|
||||
|
||||
lbl_padding2 = Gtk.Label(xalign=0, yalign=0)
|
||||
lbl_padding2.set_text(" ")
|
||||
|
||||
hbox_buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||
hbox_buttons.pack_start(btn_bootloader_grub, False, False, 1)
|
||||
hbox_buttons.pack_start(btn_bootloader_systemd_boot, False, False, 1)
|
||||
|
||||
hbox_buttons.set_halign(Gtk.Align.CENTER)
|
||||
|
||||
vbox_cancel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
|
||||
vbox_cancel.pack_end(btn_cancel, False, False, 0)
|
||||
|
||||
self.vbox.set_spacing(20)
|
||||
|
||||
self.vbox.add(label_title_message)
|
||||
self.vbox.add(label_title_second_message)
|
||||
self.vbox.add(hbox_buttons)
|
||||
|
||||
def on_md_cancel_clicked(self, widget):
|
||||
self.destroy()
|
||||
|
||||
# select GRUB
|
||||
def on_bootloader_grub_clicked(self, widget):
|
||||
if not os.path.exists(self.pacman_lockfile):
|
||||
bootloader_file = "/etc/calamares/modules/bootloader-grub.conf"
|
||||
|
||||
if os.path.exists(bootloader_file):
|
||||
app_cmd = [
|
||||
"sudo",
|
||||
"cp",
|
||||
bootloader_file,
|
||||
"/etc/calamares/modules/bootloader.conf",
|
||||
]
|
||||
|
||||
Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
|
||||
subprocess.Popen([self.calamares_polkit, "-d"], shell=False)
|
||||
else:
|
||||
print(
|
||||
"[ERROR]: %s not found, Make sure you are on a Live ISO?"
|
||||
% bootloader_file
|
||||
)
|
||||
|
||||
if self.label_message is not None:
|
||||
self.label_message.destroy()
|
||||
|
||||
self.label_message.set_markup(
|
||||
"<span foreground='red'><b>%s not found\nMake sure you are on a Live ISO?</b></span>"
|
||||
% bootloader_file
|
||||
)
|
||||
|
||||
self.vbox.add(self.label_message)
|
||||
self.show_all()
|
||||
|
||||
else:
|
||||
print(
|
||||
"[ERROR]: Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile
|
||||
)
|
||||
|
||||
if self.label_message is not None:
|
||||
self.label_message.destroy()
|
||||
|
||||
self.label_message.set_markup(
|
||||
"<span foreground='red'><b Pacman lockfile found %s, is another pacman process running ?</b></span>"
|
||||
% self.pacman_lockfile
|
||||
)
|
||||
|
||||
self.vbox.add(self.label_message)
|
||||
self.show_all()
|
||||
|
||||
self.destroy()
|
||||
|
||||
# select systemd-boot
|
||||
def on_bootloader_systemd_boot_clicked(self, widget):
|
||||
if not os.path.exists(self.pacman_lockfile):
|
||||
bootloader_file = "/etc/calamares/modules/bootloader-systemd.conf"
|
||||
|
||||
if os.path.exists(bootloader_file):
|
||||
app_cmd = [
|
||||
"sudo",
|
||||
"cp",
|
||||
bootloader_file,
|
||||
"/etc/calamares/modules/bootloader.conf",
|
||||
]
|
||||
|
||||
Thread(target=self.run_app, args=(app_cmd,), daemon=True).start()
|
||||
subprocess.Popen([self.calamares_polkit, "-d"], shell=False)
|
||||
|
||||
else:
|
||||
print("[ERROR]: %s not found, Make sure you are on a Live ISO?" % bootloader_file)
|
||||
|
||||
if self.label_message is not None:
|
||||
self.label_message.destroy()
|
||||
|
||||
self.label_message.set_markup(
|
||||
"<span foreground='red'><b>%s not found\nMake sure you are on a Live ISO?</b></span>"
|
||||
% bootloader_file
|
||||
)
|
||||
|
||||
self.vbox.add(self.label_message)
|
||||
self.show_all()
|
||||
|
||||
else:
|
||||
print(
|
||||
"[ERROR]: Pacman lockfile found %s, is another pacman process running ?"
|
||||
% self.pacman_lockfile
|
||||
)
|
||||
|
||||
if self.label_message is not None:
|
||||
self.label_message.destroy()
|
||||
|
||||
self.label_message.set_markup(
|
||||
"<span foreground='red'><b Pacman lockfile found %s, is another pacman process running ?</b></span>"
|
||||
% self.pacman_lockfile
|
||||
)
|
||||
|
||||
self.vbox.add(self.label_message)
|
||||
self.show_all()
|
||||
|
||||
self.destroy()
|
||||
22
usr/share/snigdhaos-welcome/ui/Stack.py
Normal file
22
usr/share/snigdhaos-welcome/ui/Stack.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class Stack(Gtk.Stack):
|
||||
def __init__(self, transition_type):
|
||||
super(Stack, self).__init__()
|
||||
|
||||
# self.set_transition_type(Gtk.StackTransitionType.ROTATE_LEFT)
|
||||
if transition_type == "ROTATE_LEFT":
|
||||
transition_type = Gtk.StackTransitionType.ROTATE_LEFT
|
||||
if transition_type == "CROSSFADE":
|
||||
transition_type = Gtk.StackTransitionType.CROSSFADE
|
||||
|
||||
self.set_transition_type(transition_type)
|
||||
self.set_hexpand(True)
|
||||
self.set_vexpand(True)
|
||||
self.set_transition_duration(500)
|
||||
self.set_hhomogeneous(False)
|
||||
self.set_vhomogeneous(False)
|
||||
12
usr/share/snigdhaos-welcome/ui/StackSwitcher.py
Normal file
12
usr/share/snigdhaos-welcome/ui/StackSwitcher.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class StackSwitcher(Gtk.StackSwitcher):
|
||||
def __init__(self, stack):
|
||||
super(StackSwitcher, self).__init__()
|
||||
self.set_orientation(Gtk.Orientation.HORIZONTAL)
|
||||
self.set_stack(stack)
|
||||
self.set_halign(Gtk.Align.CENTER)
|
||||
BIN
usr/share/snigdhaos-welcome/ui/__pycache__/GUI.cpython-311.pyc
Normal file
BIN
usr/share/snigdhaos-welcome/ui/__pycache__/GUI.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
usr/share/snigdhaos-welcome/ui/__pycache__/Stack.cpython-311.pyc
Normal file
BIN
usr/share/snigdhaos-welcome/ui/__pycache__/Stack.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user