|
1 | 1 | import sys |
2 | | -import os |
3 | | -import webbrowser |
4 | | -import subprocess |
5 | 2 | import gi |
6 | 3 | gi.require_version('Gtk', '4.0') |
7 | | -from gi.repository import Gtk, GdkPixbuf, Gdk, GLib, Gio |
| 4 | +gi.require_version('Adw', '1') |
| 5 | +from gi.repository import Gtk, Adw, Gio |
| 6 | +from ui import build_ui |
| 7 | +from actions import Actions |
8 | 8 |
|
9 | | -class HackerOSWelcome(Gtk.ApplicationWindow): |
| 9 | +class HackerOSWelcome(Adw.ApplicationWindow): |
10 | 10 | def __init__(self, *args, **kwargs): |
11 | 11 | super().__init__(*args, **kwargs) |
| 12 | + self.actions = Actions(self) |
12 | 13 | self.set_title("HackerOS Welcome") |
13 | | - self.set_default_size(900, 650) |
14 | | - # Stylizacja |
| 14 | + self.set_default_size(1000, 750) |
| 15 | + # Set dark theme using Adw.StyleManager |
| 16 | + style_manager = Adw.StyleManager.get_default() |
| 17 | + style_manager.set_color_scheme(Adw.ColorScheme.FORCE_DARK) |
| 18 | + # Stylizacja - rozbudowany CSS dla ładniejszego wyglądu |
15 | 19 | self.style_provider = Gtk.CssProvider() |
16 | 20 | css = """ |
17 | 21 | window { |
18 | 22 | background-color: #121212; |
19 | 23 | color: white; |
| 24 | + border-radius: 12px; |
| 25 | + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5); |
20 | 26 | } |
21 | 27 | label { |
22 | 28 | color: white; |
| 29 | + text-shadow: 1px 1px 2px black; |
23 | 30 | } |
24 | 31 | button { |
25 | 32 | background-color: #1E1E1E; |
26 | 33 | color: white; |
27 | 34 | border: 2px solid #555; |
28 | 35 | border-radius: 8px; |
29 | | - padding: 10px; |
30 | | - font-size: 14px; |
| 36 | + padding: 12px 20px; |
| 37 | + font-size: 16px; |
| 38 | + font-weight: bold; |
| 39 | + transition: all 0.3s ease; |
31 | 40 | } |
32 | 41 | button:hover { |
33 | 42 | background-color: #333; |
34 | 43 | border-color: #777; |
| 44 | + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); |
35 | 45 | } |
36 | 46 | button:active { |
37 | 47 | background-color: #444; |
| 48 | + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3); |
| 49 | + } |
| 50 | + .title { |
| 51 | + font-size: 32px; |
| 52 | + font-weight: bold; |
| 53 | + color: #FFFFFF; |
| 54 | + } |
| 55 | + .subtitle { |
| 56 | + font-size: 20px; |
| 57 | + color: #CCCCCC; |
| 58 | + } |
| 59 | + separator { |
| 60 | + background-color: #555; |
| 61 | + margin: 10px 0; |
| 62 | + } |
| 63 | + scrolledwindow { |
| 64 | + background-color: #181818; |
| 65 | + border-radius: 8px; |
| 66 | + padding: 10px; |
| 67 | + } |
| 68 | + .footer { |
| 69 | + font-size: 14px; |
| 70 | + color: #888888; |
| 71 | + padding: 10px; |
| 72 | + background-color: #0A0A0A; |
| 73 | + border-top: 1px solid #333; |
38 | 74 | } |
39 | 75 | """ |
40 | 76 | self.style_provider.load_from_data(css.encode()) |
41 | 77 | Gtk.StyleContext.add_provider_for_display( |
42 | | - Gdk.Display.get_default(), |
| 78 | + self.get_display(), |
43 | 79 | self.style_provider, |
44 | 80 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION |
45 | 81 | ) |
46 | | - self.init_ui() |
47 | | - |
48 | | - def init_ui(self): |
49 | | - main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) |
50 | | - self.set_child(main_box) |
51 | | - # Górny layout z logo i tytułem |
52 | | - top_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) |
53 | | - top_box.set_margin_top(20) |
54 | | - top_box.set_margin_start(20) |
55 | | - top_box.set_margin_end(20) |
56 | | - # Logo |
57 | | - logo_path = "/usr/share/HackerOS/ICONS/Plymouth-Icons/watermark.png" |
58 | | - if os.path.exists(logo_path): |
59 | | - pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(logo_path, 120, 120) |
60 | | - self.logo_image = Gtk.Image.new_from_pixbuf(pixbuf) |
61 | | - else: |
62 | | - self.logo_image = Gtk.Image() # Puste jeśli nie znaleziono |
63 | | - top_box.append(self.logo_image) |
64 | | - # Tytuł |
65 | | - title_label = Gtk.Label(label="Witaj w HackerOS!") |
66 | | - title_label.set_markup("<span font='Arial bold 28'>Witaj w HackerOS!</span>") |
67 | | - title_label.set_hexpand(True) |
68 | | - title_label.set_halign(Gtk.Align.CENTER) |
69 | | - top_box.append(title_label) |
70 | | - main_box.append(top_box) |
71 | | - # Podtytuł (używany też do feedbacku) |
72 | | - self.subtitle_label = Gtk.Label(label="Twój system do Gier i Etycznego Hakowania") |
73 | | - self.subtitle_label.set_markup("<span font='Arial 18'>Twój system do Gier i Etycznego Hakowania</span>") |
74 | | - self.subtitle_label.set_halign(Gtk.Align.CENTER) |
75 | | - main_box.append(self.subtitle_label) |
76 | | - # Separator |
77 | | - separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL) |
78 | | - separator.set_margin_start(20) |
79 | | - separator.set_margin_end(20) |
80 | | - main_box.append(separator) |
81 | | - # Layout przycisków - dwie kolumny |
82 | | - buttons_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=20) |
83 | | - buttons_box.set_margin_start(20) |
84 | | - buttons_box.set_margin_end(20) |
85 | | - buttons_box.set_margin_bottom(20) |
86 | | - left_buttons_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) |
87 | | - right_buttons_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) |
88 | | - # Przyciski lewej kolumny |
89 | | - left_buttons = [ |
90 | | - ("Sprawdź aktualizacje", self.check_updates), |
91 | | - ("Uruchom narzędzia HackerOS", self.launch_tools), |
92 | | - ("Otwórz stronę HackerOS", lambda: webbrowser.open("https://hackeros-linux-system.github.io/HackerOS-Website/Home-page.html")), |
93 | | - ("Otwórz X", lambda: webbrowser.open("https://x.com/hackeros_linux")), |
94 | | - ("Otwórz dokumentację", self.open_documentation), |
95 | | - ("Uruchom Steam", self.launch_steam), |
96 | | - ("Otwórz sklep z aplikacjami", self.open_software), |
97 | | - ("Changelog", lambda: webbrowser.open("https://hackeros-linux-system.github.io/HackerOS-Website/releases.html")), |
98 | | - ("Informacje o systemie", lambda: webbrowser.open("https://hackeros-linux-system.github.io/HackerOS-Website/about-hackeros.html")), |
99 | | - ("Zgłoś błąd", lambda: webbrowser.open("https://github.com/HackerOS-Linux-System/HackerOS-Website/issues")), |
100 | | - ("Forum dyskusyjne", lambda: webbrowser.open("https://github.com/HackerOS-Linux-System/HackerOS-Website/discussions")), |
101 | | - ("Zaktualizuj system", self.update_system) |
102 | | - ] |
103 | | - for text, action in left_buttons: |
104 | | - btn = Gtk.Button(label=text) |
105 | | - btn.connect("clicked", lambda widget, act=action: act()) |
106 | | - left_buttons_box.append(btn) |
107 | | - # Przyciski prawej kolumny |
108 | | - right_buttons = [ |
109 | | - ("Proton Updater", "/usr/share/HackerOS/Scripts/Bin/Proton-Updater.sh"), |
110 | | - ("Switch to Hacker Mode", "/usr/share/HackerOS/Scripts/Bin/Switch_To_Hacker-Mode.sh"), |
111 | | - ("HackerOS Cockpit", "/usr/share/HackerOS/Scripts/Bin/HackerOS-Cockpit.sh"), |
112 | | - ("Update System", "/usr/share/HackerOS/Scripts/Bin/update_system.sh"), |
113 | | - ("Check updates", "/usr/share/HackerOS/Scripts/Bin/check_updates_notify.sh"), |
114 | | - ("Hacker Game", "love /usr/share/HackerOS/Scripts/Hacker-Games/hacker-game.love"), |
115 | | - ("Starblaster", "/usr/share/HackerOS/Scripts/Hacker-Games/starblaster"), |
116 | | - ("The Racer", "/usr/share/HackerOS/Scripts/Hacker-Games/The-Racer"), |
117 | | - ("Hacker Launcher", "/usr/share/HackerOS/Scripts/HackerOS-Apps/Hacker_Launcher") |
118 | | - ] |
119 | | - for text, cmd in right_buttons: |
120 | | - btn = Gtk.Button(label=text) |
121 | | - btn.connect("clicked", lambda widget, c=cmd: self.run_command_with_feedback(c)) |
122 | | - right_buttons_box.append(btn) |
123 | | - buttons_box.append(left_buttons_box) |
124 | | - buttons_box.append(right_buttons_box) |
125 | | - main_box.append(buttons_box) |
126 | | - |
127 | | - def run_command_with_feedback(self, cmd): |
128 | | - """Uruchamianie komend z feedbackiem.""" |
129 | | - full_cmd = f"bash -c '{cmd}'" |
130 | | - result = os.system(f"pkexec {full_cmd}") |
131 | | - cmd_name = cmd.split('/')[-1] if '/' in cmd else cmd |
132 | | - if result == 0: |
133 | | - self.subtitle_label.set_label(f"Uruchomiono: {cmd_name}.") |
134 | | - else: |
135 | | - self.subtitle_label.set_label(f"Błąd podczas uruchamiania: {cmd_name}.") |
136 | | - |
137 | | - def check_updates(self): |
138 | | - result = os.system("pkexec bash -c 'apt update && apt upgrade -y && flatpak update -y'") |
139 | | - if result == 0: |
140 | | - self.subtitle_label.set_label("Sprawdzenie aktualizacji zakończone pomyślnie.") |
141 | | - else: |
142 | | - self.subtitle_label.set_label("Błąd podczas sprawdzania aktualizacji.") |
143 | | - |
144 | | - def launch_tools(self): |
145 | | - result = os.system("pkexec bash /usr/share/HackerOS/Scripts/Bin/install-tools.sh") |
146 | | - if result == 0: |
147 | | - self.subtitle_label.set_label("Uruchomiono narzędzia HackerOS pomyślnie.") |
148 | | - else: |
149 | | - self.subtitle_label.set_label("Błąd podczas uruchamiania narzędzi HackerOS.") |
150 | | - |
151 | | - def open_documentation(self): |
152 | | - result = os.system("pkexec bash /usr/share/HackerOS/Scripts/Bin/HackerOS-Documentation.sh") |
153 | | - if result == 0: |
154 | | - self.subtitle_label.set_label("Otworzono dokumentację HackerOS.") |
155 | | - else: |
156 | | - self.subtitle_label.set_label("Błąd podczas otwierania dokumentacji.") |
157 | | - |
158 | | - def launch_steam(self): |
159 | | - try: |
160 | | - subprocess.run(["flatpak", "run", "com.valvesoftware.Steam", "-gamepadui"], check=True) |
161 | | - self.subtitle_label.set_label("Steam został uruchomiony w trybie gamepad UI.") |
162 | | - except (FileNotFoundError, subprocess.CalledProcessError): |
163 | | - self.subtitle_label.set_label("Instalowanie Steam...") |
164 | | - install_result = os.system("flatpak install -y com.valvesoftware.Steam") |
165 | | - if install_result == 0: |
166 | | - try: |
167 | | - subprocess.run(["flatpak", "run", "com.valvesoftware.Steam", "-gamepadui"], check=True) |
168 | | - self.subtitle_label.set_label("Steam zainstalowany i uruchomiony.") |
169 | | - except subprocess.CalledProcessError: |
170 | | - self.subtitle_label.set_label("Błąd podczas uruchamiania Steam po instalacji.") |
171 | | - else: |
172 | | - self.subtitle_label.set_label("Błąd podczas instalacji Steam.") |
173 | | - |
174 | | - def open_software(self): |
175 | | - result = os.system("gnome-software &") |
176 | | - self.subtitle_label.set_label("Uruchomiono Sklep z aplikacjami.") |
177 | | - |
178 | | - def update_system(self): |
179 | | - # Otwiera terminal z komendą hacker update, potem pyta o zamknięcie |
180 | | - terminal_cmd = 'gnome-terminal -- bash -c "hacker update; read -p \'Chcesz zamknąć terminal? (t/n) \' answer; if [ \"$answer\" = \'t\' ]; then exit; else echo \'Terminal pozostanie otwarty.\'; read; fi"' |
181 | | - result = os.system(terminal_cmd) |
182 | | - if result == 0: |
183 | | - self.subtitle_label.set_label("Rozpoczęto aktualizację systemu w terminalu.") |
184 | | - else: |
185 | | - self.subtitle_label.set_label("Błąd podczas uruchamiania aktualizacji systemu.") |
| 82 | + build_ui(self) |
186 | 83 |
|
187 | | -class Application(Gtk.Application): |
| 84 | +class Application(Adw.Application): |
188 | 85 | def __init__(self): |
189 | 86 | super().__init__(application_id="org.hackeros.welcome", |
190 | 87 | flags=Gio.ApplicationFlags.FLAGS_NONE) |
|
0 commit comments