fix window resize, freeze and first page fixes

This commit is contained in:
Roma 2023-08-11 00:11:08 +02:00
parent b18596457f
commit 92cdce9884
7 changed files with 73 additions and 40 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
donation-thumb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 253 KiB

113
welcome.py Executable file → Normal file
View File

@ -4,7 +4,7 @@ import sys
import os import os
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk from gi.repository import Gtk, Gdk, Gio
class WelcomeScreen(Gtk.Window): class WelcomeScreen(Gtk.Window):
def __init__(self): def __init__(self):
@ -17,21 +17,25 @@ class WelcomeScreen(Gtk.Window):
print("Error: Icon not found:", icon_path) print("Error: Icon not found:", icon_path)
self.set_border_width(10) self.set_border_width(10)
self.set_resizable(False)
self.set_size_request(800, 600)
self.set_default_size(800, 600) self.set_default_size(800, 600)
self.pages = [ self.pages = [
{"title": "Welcome to TROMjaro", {"title": "Welcome to TROMjaro",
"description": "TROMjaro is free and open source operating system which fights against the influences of trade!", "description": "This operating system is trade-free.\nThis means that you do not have to trade anything to us in order to use it.\nNot your data, not your attention, currency or anything else.\nThere are no free trials here, no ads, and no trackers.",
"image_path": "tromjaro-welcome-thumb.png", "image_path": "",
"with_button": False}, "with_button": True,
"button_text": "Take a minute to customize your desktop experience",
"button_handler": self.on_next_button_clicked},
{"title": "Choose a Layout", {"title": "Choose a Layout",
"description": "Make it morph into any shape you love!", "description": "Make it morph into any configuration you like!",
"image_path": "tromjaro-layout-switcher-thumb.png", "image_path": "tromjaro-layout-switcher-thumb.png",
"with_button": True, "with_button": True,
"button_text": "Open the Layout Switcher", "button_text": "Open the Layout Switcher",
"button_handler": self.on_layout_switcher_button_clicked}, "button_handler": self.on_layout_switcher_button_clicked},
{"title": "Choose a Theme", {"title": "Choose a Theme",
"description": "Choose between the many variations of themes!", "description": "Choose between the many variations of themes that sync across different types of applications.",
"image_path": "tromjaro-theme-switcher-thumb.png", "image_path": "tromjaro-theme-switcher-thumb.png",
"with_button": True, "with_button": True,
"button_text": "Open the Theme Switcher", "button_text": "Open the Theme Switcher",
@ -49,13 +53,13 @@ class WelcomeScreen(Gtk.Window):
"button_text": "Setup Internet Content Blocker", "button_text": "Setup Internet Content Blocker",
"button_handler": self.on_content_blocker_button_clicked}, "button_handler": self.on_content_blocker_button_clicked},
{"title": "Settings Manager", {"title": "Settings Manager",
"description": "You will find all of the settings into one single place.", "description": "If you want to do more tweaks, you will find all of the settings into one single place.",
"image_path": "settings-thumbnail.png", "image_path": "settings-thumbnail.png",
"with_button": True, "with_button": True,
"button_text": "Open Settings Manager", "button_text": "Open Settings Manager",
"button_handler": self.on_settings_button_clicked}, "button_handler": self.on_settings_button_clicked},
{"title": "Donation", {"title": "Support Us",
"description": "If you want to help for the cause of fighting the force of trade, please, consider a donation. Thank you!", "description": "TROMjaro is one of the many trade-free projects that we are doing. Please support us if you can. Thank you!",
"image_path": "donation-thumb.png", "image_path": "donation-thumb.png",
"with_button": True, "with_button": True,
"button_text": "Donate", "button_text": "Donate",
@ -75,68 +79,94 @@ class WelcomeScreen(Gtk.Window):
header_label = Gtk.Label(label=self.pages[self.current_page]["title"].upper()) header_label = Gtk.Label(label=self.pages[self.current_page]["title"].upper())
header_label.set_markup("<big><b>{}</b></big>".format(self.pages[self.current_page]["title"].upper())) header_label.set_markup("<big><b>{}</b></big>".format(self.pages[self.current_page]["title"].upper()))
description_label = Gtk.Label(label=self.pages[self.current_page]["description"])
header_label.set_hexpand(True) header_label.set_hexpand(True)
description_label.set_hexpand(True) if self.current_page == 0:
header_label.set_margin_top(180)
header_label.set_margin_bottom(20)
grid.attach(header_label, 0, 0, 2, 1) grid.attach(header_label, 0, 0, 2, 1)
grid.attach(description_label, 0, 1, 2, 1)
grid_row = 1
if self.current_page == 0:
description = self.pages[self.current_page]["description"]
description_lines = description.split("\n")
for line in description_lines:
description_label = Gtk.Label(label=line)
description_label.set_markup('<span size="large">{}</span>'.format(line))
description_label.set_size_request(600, 30)
description_label.set_justify(Gtk.Justification.CENTER)
description_label.set_hexpand(True)
description_label.set_line_wrap(True)
grid.attach(description_label, 0, grid_row, 2, 1)
grid_row += 1
else:
description_label = Gtk.Label(label=self.pages[self.current_page]["description"])
description_label.set_hexpand(True)
description_label.set_justify(Gtk.Justification.CENTER)
description_label.set_line_wrap(True)
grid.attach(description_label, 0, grid_row, 2, 1)
grid_row += 1
image_path = self.pages[self.current_page]["image_path"] image_path = self.pages[self.current_page]["image_path"]
if image_path and os.path.exists(image_path): if image_path and os.path.exists(image_path):
image = Gtk.Image.new_from_file(image_path) image = Gtk.Image.new_from_file(image_path)
image.set_size_request(600, 400)
grid.attach(image, 0, grid_row, 2, 1)
grid_row += 1
else: else:
print("Error: Image not found:", image_path) print("Error: Image not found:", image_path)
image = Gtk.Image.new_from_icon_name("image-missing", Gtk.IconSize.DIALOG)
image.set_size_request(600, 400)
grid.attach(image, 0, 2, 2, 1)
if self.pages[self.current_page]["with_button"]: if self.pages[self.current_page]["with_button"]:
button_text = self.pages[self.current_page]["button_text"] button_text = self.pages[self.current_page]["button_text"]
button_handler = self.pages[self.current_page]["button_handler"] button_handler = self.pages[self.current_page]["button_handler"]
button = Gtk.Button(label=button_text.upper()) button = Gtk.Button(label=button_text.upper())
button.set_size_request(60, -1) # Set fixed button width to 60px button.set_size_request(100, -1)
button.set_name("accent_button") # Set the name of the button to "accent_button" button.set_halign(Gtk.Align.CENTER)
button.set_name("accent_button")
button.set_margin_top(20) button.set_margin_top(20)
button.set_margin_bottom(20) if self.current_page == 0:
button.set_margin_bottom(200)
else:
button.set_margin_bottom(20)
button.connect("clicked", button_handler) button.connect("clicked", button_handler)
grid.attach(button, 0, 3, 2, 1) grid.attach(button, 0, grid_row, 2, 1)
grid_row += 1
if self.current_page > 0: if self.current_page > 0:
left_button = Gtk.Button(label="Previous") left_button = Gtk.Button(label="Previous")
left_button.set_size_request(60, -1) # Set fixed button width to 60px left_button.set_size_request(60, -1)
left_button.set_halign(Gtk.Align.START) # Align the button to the left left_button.set_halign(Gtk.Align.START)
left_button.set_margin_top(20) left_button.set_margin_top(20)
left_button.set_margin_bottom(20) left_button.set_margin_bottom(20)
left_button.connect("clicked", self.on_previous_button_clicked) left_button.connect("clicked", self.on_previous_button_clicked)
grid.attach(left_button, 0, 4, 1, 1) grid.attach(left_button, 0, grid_row, 1, 1)
if self.current_page < len(self.pages) - 1: if self.current_page > 0 and self.current_page < len(self.pages) - 1:
right_button = Gtk.Button(label="Next") right_button = Gtk.Button(label="Next")
right_button.set_size_request(60, -1) # Set fixed button width to 60px right_button.set_size_request(60, -1)
right_button.set_halign(Gtk.Align.END) # Align the button to the right right_button.set_halign(Gtk.Align.END)
right_button.set_margin_top(20) right_button.set_margin_top(20)
right_button.set_margin_bottom(20) right_button.set_margin_bottom(20)
right_button.connect("clicked", self.on_next_button_clicked) right_button.connect("clicked", self.on_next_button_clicked)
grid.attach(right_button, 1, 4, 1, 1) grid.attach(right_button, 1, grid_row, 1, 1)
grid_row += 1
if self.current_page == len(self.pages) - 1: if self.current_page == len(self.pages) - 1:
right_button = Gtk.Button(label="Finish") right_button = Gtk.Button(label="Finish")
right_button.connect("clicked", self.on_finish_button_clicked) right_button.connect("clicked", self.on_finish_button_clicked)
right_button.set_size_request(60, -1) # Set fixed button width to 60px right_button.set_size_request(60, -1)
right_button.set_halign(Gtk.Align.END) # Align the button to the right right_button.set_halign(Gtk.Align.END)
right_button.set_margin_top(20) right_button.set_margin_top(20)
right_button.set_margin_bottom(20) right_button.set_margin_bottom(20)
grid.attach(right_button, 1, 4, 1, 1) grid.attach(right_button, 1, grid_row, 1, 1)
grid_row += 1
checkbox = Gtk.CheckButton(label="Open the Welcome Screen on every boot") checkbox = Gtk.CheckButton(label="Open the Welcome Screen on every boot")
checkbox.set_active(True) checkbox.set_active(True)
checkbox.connect("toggled", self.on_checkbox_toggled) checkbox.connect("toggled", self.on_checkbox_toggled)
checkbox.set_halign(Gtk.Align.CENTER) checkbox.set_halign(Gtk.Align.CENTER)
grid.attach(checkbox, 0, 5, 2, 1) grid.attach(checkbox, 0, grid_row, 2, 1)
grid_row += 1
# Set up CSS style provider for the accent button
css_provider = Gtk.CssProvider() css_provider = Gtk.CssProvider()
css_provider.load_from_data(b""" css_provider.load_from_data(b"""
button#accent_button { button#accent_button {
@ -163,22 +193,22 @@ class WelcomeScreen(Gtk.Window):
self.create_ui() self.create_ui()
def on_layout_switcher_button_clicked(self, button): def on_layout_switcher_button_clicked(self, button):
subprocess.run(["tromjaro-layout-switcher"]) self.run_command("tromjaro-layout-switcher")
def on_theme_switcher_button_clicked(self, button): def on_theme_switcher_button_clicked(self, button):
subprocess.run(["tromjaro-theme-switcher"]) self.run_command("tromjaro-theme-switcher")
def on_background_button_clicked(self, button): def on_background_button_clicked(self, button):
subprocess.run(["xfdesktop-settings"]) self.run_command("xfdesktop-settings")
def on_content_blocker_button_clicked(self, button): def on_content_blocker_button_clicked(self, button):
subprocess.run(["tblockg"]) self.run_command("tblockg")
def on_settings_button_clicked(self, button): def on_settings_button_clicked(self, button):
subprocess.run(["xfce4-settings-manager"]) self.run_command("xfce4-settings-manager")
def on_donate_button_clicked(self, button): def on_donate_button_clicked(self, button):
subprocess.run(["xdg-open", "https://www.tromsite.com/donate/"]) self.run_command("xdg-open https://www.tromsite.com/donate/")
def on_checkbox_toggled(self, checkbox): def on_checkbox_toggled(self, checkbox):
if checkbox.get_active(): if checkbox.get_active():
@ -194,6 +224,9 @@ class WelcomeScreen(Gtk.Window):
def on_finish_button_clicked(self, button): def on_finish_button_clicked(self, button):
sys.exit(0) sys.exit(0)
def run_command(self, command):
subprocess.Popen(command.split(' '), start_new_session=True)
win = WelcomeScreen() win = WelcomeScreen()
win.connect("destroy", Gtk.main_quit) win.connect("destroy", Gtk.main_quit)
win.show_all() win.show_all()