|
| 1 | +import os |
| 2 | +import gi |
| 3 | +gi.require_version('Gtk', '4.0') |
| 4 | +gi.require_version('Adw', '1') |
| 5 | +from gi.repository import Gtk, Adw, GdkPixbuf |
| 6 | + |
| 7 | +def build_ui(window): |
| 8 | + # HeaderBar dla profesjonalnego wyglądu |
| 9 | + header_bar = Adw.HeaderBar() |
| 10 | + header_bar.set_show_end_title_buttons(True) |
| 11 | + |
| 12 | + # Box dla title widget z logo i tytułem |
| 13 | + title_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) |
| 14 | + |
| 15 | + # Logo (mniejsze dla headera) |
| 16 | + logo_path = "/usr/share/HackerOS/ICONS/Plymouth-Icons/watermark.png" |
| 17 | + if os.path.exists(logo_path): |
| 18 | + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(logo_path, 32, 32) |
| 19 | + logo_image = Gtk.Image.new_from_pixbuf(pixbuf) |
| 20 | + else: |
| 21 | + logo_image = Gtk.Image() # Puste jeśli nie znaleziono |
| 22 | + title_box.append(logo_image) |
| 23 | + |
| 24 | + # Tytuł (mniejszy font dla headera) |
| 25 | + title_label = Gtk.Label(label="Witaj w HackerOS!") |
| 26 | + title_label.set_markup("<span font='Arial bold 20'>Witaj w HackerOS!</span>") |
| 27 | + title_box.append(title_label) |
| 28 | + |
| 29 | + header_bar.set_title_widget(title_box) |
| 30 | + |
| 31 | + # Content box |
| 32 | + content_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15) |
| 33 | + content_box.set_margin_top(20) |
| 34 | + content_box.set_margin_start(20) |
| 35 | + content_box.set_margin_end(20) |
| 36 | + content_box.set_margin_bottom(20) |
| 37 | + |
| 38 | + # Podtytuł (używany też do feedbacku) |
| 39 | + window.subtitle_label = Gtk.Label(label="Twój system do Gier i Etycznego Hakowania") |
| 40 | + window.subtitle_label.set_markup("<span font='Arial 18'>Twój system do Gier i Etycznego Hakowania</span>") |
| 41 | + window.subtitle_label.set_halign(Gtk.Align.CENTER) |
| 42 | + window.subtitle_label.get_style_context().add_class("subtitle") |
| 43 | + content_box.append(window.subtitle_label) |
| 44 | + |
| 45 | + # Separator |
| 46 | + separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL) |
| 47 | + separator.set_margin_start(10) |
| 48 | + separator.set_margin_end(10) |
| 49 | + content_box.append(separator) |
| 50 | + |
| 51 | + # ScrolledWindow dla przycisków, aby było scrollowalne jeśli potrzeba |
| 52 | + scrolled_window = Gtk.ScrolledWindow() |
| 53 | + scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) |
| 54 | + scrolled_window.set_hexpand(True) |
| 55 | + scrolled_window.set_vexpand(True) |
| 56 | + content_box.append(scrolled_window) |
| 57 | + |
| 58 | + # Layout przycisków - FlowBox dla dynamicznego układu |
| 59 | + flow_box = Gtk.FlowBox() |
| 60 | + flow_box.set_column_spacing(15) |
| 61 | + flow_box.set_row_spacing(15) |
| 62 | + flow_box.set_margin_start(10) |
| 63 | + flow_box.set_margin_end(10) |
| 64 | + flow_box.set_margin_bottom(20) |
| 65 | + flow_box.set_homogeneous(True) |
| 66 | + flow_box.set_min_children_per_line(2) |
| 67 | + flow_box.set_max_children_per_line(3) |
| 68 | + scrolled_window.set_child(flow_box) |
| 69 | + |
| 70 | + # Pozostałe przyciski (usunięto wskazane) |
| 71 | + buttons = [ |
| 72 | + ("Otwórz stronę HackerOS", window.actions.open_website), |
| 73 | + ("Otwórz X", window.actions.open_x), |
| 74 | + ("Otwórz sklep z aplikacjami", window.actions.open_software), |
| 75 | + ("Changelog", window.actions.open_changelog), |
| 76 | + ("Informacje o systemie", window.actions.open_system_info), |
| 77 | + ("Zgłoś błąd", window.actions.report_bug), |
| 78 | + ("Forum dyskusyjne", window.actions.open_forum), |
| 79 | + ("Zaktualizuj system", window.actions.update_system), |
| 80 | + ("Uruchom HackerOS Games", lambda: window.actions.run_command_with_feedback("/usr/share/HackerOS/Scripts/Bin/HackerOS-Games.sh")), |
| 81 | + ("Hacker Launcher", lambda: window.actions.run_command_with_feedback("/usr/share/HackerOS/Scripts/HackerOS-Apps/Hacker_Launcher")) |
| 82 | + ] |
| 83 | + for text, action in buttons: |
| 84 | + btn = Gtk.Button(label=text) |
| 85 | + btn.connect("clicked", lambda widget, act=action: act()) |
| 86 | + flow_box.append(btn) |
| 87 | + |
| 88 | + # Footer |
| 89 | + footer_label = Gtk.Label(label="© 2025 HackerOS Team | All rights reserved") |
| 90 | + footer_label.set_halign(Gtk.Align.CENTER) |
| 91 | + footer_label.get_style_context().add_class("footer") |
| 92 | + content_box.append(footer_label) |
| 93 | + |
| 94 | + # ToolbarView do integracji headera i contentu |
| 95 | + toolbar_view = Adw.ToolbarView() |
| 96 | + toolbar_view.add_top_bar(header_bar) |
| 97 | + toolbar_view.set_content(content_box) |
| 98 | + |
| 99 | + # Ustaw content okna |
| 100 | + window.set_content(toolbar_view) |
0 commit comments