Skip to content

Commit 4a5a721

Browse files
authored
Update main.py
1 parent 2ea3948 commit 4a5a721

File tree

1 file changed

+48
-151
lines changed

1 file changed

+48
-151
lines changed

main.py

Lines changed: 48 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,190 +1,87 @@
11
import sys
2-
import os
3-
import webbrowser
4-
import subprocess
52
import gi
63
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
88

9-
class HackerOSWelcome(Gtk.ApplicationWindow):
9+
class HackerOSWelcome(Adw.ApplicationWindow):
1010
def __init__(self, *args, **kwargs):
1111
super().__init__(*args, **kwargs)
12+
self.actions = Actions(self)
1213
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
1519
self.style_provider = Gtk.CssProvider()
1620
css = """
1721
window {
1822
background-color: #121212;
1923
color: white;
24+
border-radius: 12px;
25+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
2026
}
2127
label {
2228
color: white;
29+
text-shadow: 1px 1px 2px black;
2330
}
2431
button {
2532
background-color: #1E1E1E;
2633
color: white;
2734
border: 2px solid #555;
2835
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;
3140
}
3241
button:hover {
3342
background-color: #333;
3443
border-color: #777;
44+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
3545
}
3646
button:active {
3747
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;
3874
}
3975
"""
4076
self.style_provider.load_from_data(css.encode())
4177
Gtk.StyleContext.add_provider_for_display(
42-
Gdk.Display.get_default(),
78+
self.get_display(),
4379
self.style_provider,
4480
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
4581
)
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)
18683

187-
class Application(Gtk.Application):
84+
class Application(Adw.Application):
18885
def __init__(self):
18986
super().__init__(application_id="org.hackeros.welcome",
19087
flags=Gio.ApplicationFlags.FLAGS_NONE)

0 commit comments

Comments
 (0)