diff --git a/vanilla_first_setup/assets/theme-dark.svg b/vanilla_first_setup/assets/theme-dark.svg new file mode 100644 index 00000000..d290633f --- /dev/null +++ b/vanilla_first_setup/assets/theme-dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/vanilla_first_setup/assets/theme-default.svg b/vanilla_first_setup/assets/theme-default.svg new file mode 100644 index 00000000..320dadd0 --- /dev/null +++ b/vanilla_first_setup/assets/theme-default.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/vanilla_first_setup/defaults/theme.py b/vanilla_first_setup/defaults/theme.py index 404c6103..4ade0cb1 100644 --- a/vanilla_first_setup/defaults/theme.py +++ b/vanilla_first_setup/defaults/theme.py @@ -14,11 +14,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from gi.repository import Gtk, Gio +from gi.repository import Gtk, Gio, Adw @Gtk.Template(resource_path="/org/vanillaos/FirstSetup/gtk/default-theme.ui") -class VanillaDefaultTheme(Gtk.Box): +class VanillaDefaultTheme(Adw.Bin): __gtype_name__ = "VanillaDefaultTheme" btn_next = Gtk.Template.Child() @@ -32,8 +32,10 @@ def __init__(self, window, distro_info, key, step, **kwargs): self.__key = key self.__step = step self.__theme = "light" + self.__style_manager = self.__window.style_manager - self.__build_ui() + self.btn_default.set_active(not self.__style_manager.get_dark()) + self.btn_dark.set_active(self.__style_manager.get_dark()) self.btn_next.connect("clicked", self.__window.next) self.btn_default.connect("toggled", self.__set_theme, "light") @@ -43,9 +45,6 @@ def __init__(self, window, distro_info, key, step, **kwargs): def step_id(self): return self.__key - def __build_ui(self): - self.btn_dark.set_group(self.btn_default) - def __set_theme(self, widget, theme: str): pref = "prefer-dark" if theme == "dark" else "default" gtk = "Adwaita-dark" if theme == "dark" else "Adwaita" diff --git a/vanilla_first_setup/gtk/default-hostname.ui b/vanilla_first_setup/gtk/default-hostname.ui index 2a2ceab0..62582915 100644 --- a/vanilla_first_setup/gtk/default-hostname.ui +++ b/vanilla_first_setup/gtk/default-hostname.ui @@ -2,12 +2,25 @@ - + \ No newline at end of file diff --git a/vanilla_first_setup/gtk/default-theme.ui b/vanilla_first_setup/gtk/default-theme.ui index e64cf36e..7ff43287 100644 --- a/vanilla_first_setup/gtk/default-theme.ui +++ b/vanilla_first_setup/gtk/default-theme.ui @@ -1,60 +1,131 @@ - - - diff --git a/vanilla_first_setup/gtk/default-user.ui b/vanilla_first_setup/gtk/default-user.ui index 040b0c88..27ca3bcd 100644 --- a/vanilla_first_setup/gtk/default-user.ui +++ b/vanilla_first_setup/gtk/default-user.ui @@ -2,50 +2,68 @@ diff --git a/vanilla_first_setup/gtk/layout-applications.ui b/vanilla_first_setup/gtk/layout-applications.ui index d383d679..7d70f564 100644 --- a/vanilla_first_setup/gtk/layout-applications.ui +++ b/vanilla_first_setup/gtk/layout-applications.ui @@ -2,37 +2,45 @@ diff --git a/vanilla_first_setup/style.css b/vanilla_first_setup/style.css index 4c80e84d..ae30800e 100644 --- a/vanilla_first_setup/style.css +++ b/vanilla_first_setup/style.css @@ -1,41 +1,25 @@ -/* CSS inspired by: Sonny Piers */ +/* CSS inspired from: Settings Appearance Panel */ -.theme-selector { - border-radius: 100px; - margin: 8px; - border: 1px solid rgba(145, 145, 145, 0.1); - padding: 30px; -} -.theme-selector radio { - -gtk-icon-source: none; - border: none; +.background-preview-button { background: none; + border-radius: 9px; + padding: 3px; box-shadow: none; - min-width: 12px; - min-height: 12px; - transform: translate(34px, 20px); - padding: 2px; - border-radius: 100px; -} -.theme-selector radio:checked { - -gtk-icon-source: -gtk-icontheme("object-select-symbolic"); - background-color: @theme_selected_bg_color; - color: @theme_selected_fg_color; -} -.theme-selector:checked { - border-color: @theme_selected_bg_color; - border-width: 2px; - background-color: @theme_selected_bg_color; -} -.theme-selector.light { - background-color: #ffffff; -} -.theme-selector.dark { - background-color: #202020; -} -.theme-selector.light:checked { - background-color: #eeeeee; -} -.theme-selector.dark:checked { - background-color: #303030; -} + outline: none; + } + + .background-preview-button:checked { + box-shadow: 0 0 0 3px @accent_color; + } + + .background-preview-button:focus:focus-visible { + box-shadow: 0 0 0 3px alpha(@accent_color, .3); + } + + .background-preview-button:checked:focus:focus-visible { + box-shadow: 0 0 0 3px @accent_color, 0 0 0 6px alpha(@accent_color, .3); + } + + .appearance-thumbnail { + border-radius: 6px; + } diff --git a/vanilla_first_setup/vanilla-first-setup.gresource.xml b/vanilla_first_setup/vanilla-first-setup.gresource.xml index 59ab67f7..38c4f050 100644 --- a/vanilla_first_setup/vanilla-first-setup.gresource.xml +++ b/vanilla_first_setup/vanilla-first-setup.gresource.xml @@ -29,6 +29,9 @@ ../data/icons/hicolor/symbolic/actions/vanilla-history-undo-symbolic.svg + assets/theme-default.svg + assets/theme-dark.svg + assets/bundle-app-icons/com.github.flxzt.rnote.png assets/bundle-app-icons/com.github.tchx84.Flatseal.png assets/bundle-app-icons/com.usebottles.bottles.png diff --git a/vanilla_first_setup/vanilla-first-setup.in b/vanilla_first_setup/vanilla-first-setup.in old mode 100644 new mode 100755 diff --git a/vanilla_first_setup/views/post_script.py b/vanilla_first_setup/views/post_script.py index d8d351c5..8147bd0e 100644 --- a/vanilla_first_setup/views/post_script.py +++ b/vanilla_first_setup/views/post_script.py @@ -33,10 +33,13 @@ def __init__(self, window, post_script: str, **kwargs): self.__font.set_size(13 * Pango.SCALE) self.__font.set_weight(Pango.Weight.NORMAL) self.__font.set_stretch(Pango.Stretch.NORMAL) + self.__style_manager = self.__window.style_manager self.__build_ui() - def __build_ui(self): + self.__style_manager.connect("notify::dark", self.__build_ui) + + def __build_ui(self, *args): self.__terminal.set_cursor_blink_mode(Vte.CursorBlinkMode.ON) self.__terminal.set_font(self.__font) self.__terminal.set_mouse_autohide(True) @@ -44,8 +47,10 @@ def __build_ui(self): self.console_output.append(self.__terminal) self.__terminal.connect("child-exited", self.on_vte_child_exited) + is_dark: bool = self.__style_manager.get_dark() + palette = [ - "#353535", + "#363636", "#c01c28", "#26a269", "#a2734c", @@ -73,13 +78,14 @@ def __build_ui(self): self.colors = [Gdk.RGBA() for c in palette] [color.parse(s) for (color, s) in zip(self.colors, palette)] - desktop_schema = Gio.Settings.new("org.gnome.desktop.interface") - if desktop_schema.get_enum("color-scheme") == 0: - self.fg.parse(FOREGROUND) - self.bg.parse(BACKGROUND) - elif desktop_schema.get_enum("color-scheme") == 1: + + if is_dark: self.fg.parse(FOREGROUND_DARK) self.bg.parse(BACKGROUND_DARK) + else: + self.fg.parse(FOREGROUND) + self.bg.parse(BACKGROUND) + self.__terminal.set_colors(self.fg, self.bg, self.colors) self.__terminal.spawn_async( diff --git a/vanilla_first_setup/views/progress.py b/vanilla_first_setup/views/progress.py index 7583279e..c66783ec 100644 --- a/vanilla_first_setup/views/progress.py +++ b/vanilla_first_setup/views/progress.py @@ -45,33 +45,21 @@ def __init__(self, window, tour: dict, **kwargs): self.__font.set_size(13 * Pango.SCALE) self.__font.set_weight(Pango.Weight.NORMAL) self.__font.set_stretch(Pango.Stretch.NORMAL) + self.__style_manager = self.__window.style_manager self.__build_ui() + self.__on_setup_terminal_colors() + self.__style_manager.connect("notify::dark", self.__on_setup_terminal_colors) self.tour_button.connect("clicked", self.__on_tour_button) self.console_button.connect("clicked", self.__on_console_button) - def __on_tour_button(self, *args): - self.tour_box.set_visible(True) - self.console_box.set_visible(False) - self.tour_button.set_visible(False) - self.console_button.set_visible(True) - - def __on_console_button(self, *args): - self.tour_box.set_visible(False) - self.console_box.set_visible(True) - self.tour_button.set_visible(True) - self.console_button.set_visible(False) - - def __build_ui(self): - self.__terminal.set_cursor_blink_mode(Vte.CursorBlinkMode.ON) - self.__terminal.set_font(self.__font) - self.__terminal.set_mouse_autohide(True) - self.console_output.append(self.__terminal) - self.__terminal.connect("child-exited", self.on_vte_child_exited) + def __on_setup_terminal_colors(self, *args): + + is_dark: bool = self.__style_manager.get_dark() palette = [ - "#353535", + "#363636", "#c01c28", "#26a269", "#a2734c", @@ -88,6 +76,7 @@ def __build_ui(self): "#33c7de", "#ffffff", ] + FOREGROUND = palette[0] BACKGROUND = palette[15] FOREGROUND_DARK = palette[15] @@ -98,15 +87,36 @@ def __build_ui(self): self.colors = [Gdk.RGBA() for c in palette] [color.parse(s) for (color, s) in zip(self.colors, palette)] - desktop_schema = Gio.Settings.new("org.gnome.desktop.interface") - if desktop_schema.get_enum("color-scheme") == 0: - self.fg.parse(FOREGROUND) - self.bg.parse(BACKGROUND) - elif desktop_schema.get_enum("color-scheme") == 1: + + if is_dark: self.fg.parse(FOREGROUND_DARK) self.bg.parse(BACKGROUND_DARK) + else: + self.fg.parse(FOREGROUND) + self.bg.parse(BACKGROUND) + self.__terminal.set_colors(self.fg, self.bg, self.colors) + def __on_tour_button(self, *args): + self.tour_box.set_visible(True) + self.console_box.set_visible(False) + self.tour_button.set_visible(False) + self.console_button.set_visible(True) + + def __on_console_button(self, *args): + self.tour_box.set_visible(False) + self.console_box.set_visible(True) + self.tour_button.set_visible(True) + self.console_button.set_visible(False) + + def __build_ui(self): + self.__terminal.set_cursor_blink_mode(Vte.CursorBlinkMode.ON) + self.__terminal.set_font(self.__font) + self.__terminal.set_mouse_autohide(True) + self.__terminal.set_input_enabled(False) + self.console_output.append(self.__terminal) + self.__terminal.connect("child-exited", self.on_vte_child_exited) + for _, tour in self.__tour.items(): self.carousel_tour.append(VanillaTour(self.__window, tour)) diff --git a/vanilla_first_setup/window.py b/vanilla_first_setup/window.py index 21db7367..0fcdf454 100644 --- a/vanilla_first_setup/window.py +++ b/vanilla_first_setup/window.py @@ -40,6 +40,7 @@ class VanillaWindow(Adw.ApplicationWindow): headerbar = Gtk.Template.Child() btn_back = Gtk.Template.Child() toasts = Gtk.Template.Child() + style_manager = Adw.StyleManager().get_default() def __init__(self, post_script: str, user: str, new_user: bool = False, **kwargs): super().__init__(**kwargs)