Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
UX: make enabling Shell theming and customizing themes more intuitive
Browse files Browse the repository at this point in the history
Full commit changelog:
    * refactored `main_window` module
    * removed 'GNOME Shell' option from `AppTypeDialog` widget
    * changed Shell theming section design, now it's a single `ExpandRow` widget in `PreferencesGroup` parent with an `ActionRow` with a button to 'Custom Shell Colors' window as a child
    * splitted most widget groups in `main_window` module into an external modules
    * disabled `get_default_wallpaper` function in `main_window` module
    * updated POTFILES
  • Loading branch information
tfuxu committed Jan 11, 2023
1 parent dc7e91e commit b48add9
Show file tree
Hide file tree
Showing 21 changed files with 426 additions and 204 deletions.
3 changes: 3 additions & 0 deletions data/com.github.GradienceTeam.Gradience.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<key name="enabled-plugins" type="as">
<default>[]</default>
</key>
<key name="shell-theming-enabled" type="b">
<default>true</default>
</key>
<key name="user-flatpak-theming-gtk4" type="b">
<default>false</default>
</key>
Expand Down
3 changes: 3 additions & 0 deletions data/gradience.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<file preprocess="xml-stripblanks">ui/error_list_row.ui</file>
<file preprocess="xml-stripblanks">ui/explore_preset_row.ui</file>
<file preprocess="xml-stripblanks">ui/log_out_dialog.ui</file>
<file preprocess="xml-stripblanks">ui/monet_theming_group.ui</file>
<file preprocess="xml-stripblanks">ui/no_plugin_window.ui</file>
<file preprocess="xml-stripblanks">ui/option_row.ui</file>
<file preprocess="xml-stripblanks">ui/palette_shades.ui</file>
Expand All @@ -20,6 +21,8 @@
<file preprocess="xml-stripblanks">ui/repo_row.ui</file>
<file preprocess="xml-stripblanks">ui/save_dialog.ui</file>
<file preprocess="xml-stripblanks">ui/share_window.ui</file>
<file preprocess="xml-stripblanks">ui/shell_prefs_window.ui</file>
<file preprocess="xml-stripblanks">ui/shell_theming_group.ui</file>
<file preprocess="xml-stripblanks">ui/welcome_window.ui</file>
<file preprocess="xml-stripblanks">ui/window.ui</file>
<file>images/welcome-dark.svg</file>
Expand Down
3 changes: 0 additions & 3 deletions data/ui/app_type_dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ template GradienceAppTypeDialog : Adw.MessageDialog {
CheckButton gtk3-app-type {
label: _("GTK 3 Applications (adw-gtk3 theme is required)");
}
CheckButton gnome-app-type {
label: _("GNOME Shell");
}
}
// Box {
// orientation: vertical;
Expand Down
3 changes: 3 additions & 0 deletions data/ui/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ blueprints = custom_target('blueprints',
'option_row.blp',
'window.blp',
'log_out_dialog.blp',
'monet_theming_group.blp',
'app_type_dialog.blp',
'custom_css_group.blp',
'presets_manager_window.blp',
Expand All @@ -15,6 +16,8 @@ blueprints = custom_target('blueprints',
'builtin_preset_row.blp',
'explore_preset_row.blp',
'save_dialog.blp',
'shell_prefs_window.blp',
'shell_theming_group.blp',
'repo_row.blp',
'no_plugin_window.blp',
'share_window.blp',
Expand Down
42 changes: 42 additions & 0 deletions data/ui/monet_theming_group.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Gtk 4.0;
using Adw 1;

template GradienceMonetThemingGroup : Adw.PreferencesGroup {
title: _("Monet Engine");
description: _("Monet is an engine that generates a Material Design 3 palette from extracting image's colors.");

[header-suffix]
Button apply-button {
valign: center;
label: _("Apply");
clicked => on_apply_button_clicked();
}

Adw.ActionRow file-chooser-row {
title: _("Background Image");

[suffix]
Button file-chooser-button {
valign: center;
clicked => on_file_chooser_button_clicked();

Box button-content {
spacing: 10;

Label {
label: _("Choose a File");
}

Image {
icon-name: "folder-pictures-symbolic";
}
}
}
}
}

Gtk.FileChooserNative monet-file-chooser {
title: _("Choose a Image File");
modal: true;
//response => on_monet_file_chooser_response();
}
1 change: 1 addition & 0 deletions data/ui/preferences_window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ template GradiencePreferencesWindow : Adw.PreferencesWindow {
}
}

// This group is disabled as there isn't yet any implementation of custom repositories in Gradience
Adw.PreferencesGroup custom_repository_group {
visible: false;
title: _("Custom Preset Repositories");
Expand Down
17 changes: 17 additions & 0 deletions data/ui/shell_prefs_window.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Gtk 4.0;
using Adw 1;

template GradienceShellPrefsWindow : Adw.PreferencesWindow {
title: _("Custom Shell Theme Colors");
search-enabled: false;
default-height: 600;
default-width: 500;
modal: true;

Adw.PreferencesPage {
Adw.PreferencesGroup custom-colors-group {
title: _("Custom Shell Colors");
description: _("This section allows you to customize colors that will be used in Shell theme.");
}
}
}
24 changes: 24 additions & 0 deletions data/ui/shell_theming_group.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Gtk 4.0;
using Adw 1;

template GradienceShellThemingGroup : Adw.PreferencesGroup {
title: _("GNOME Shell Theming");
description: _("This section allows you to enable and customize Shell theme look.\nWARNING: Extensions that modify Shell stylesheet can cause issues with themes.");

Adw.ExpanderRow shell-theming-expander {
title: _("Enable Shell Theming");
subtitle: _("Enable GNOME Shell theme generator and get access to theme customization options");
show-enable-switch: true;

Adw.ActionRow {
title: _("Customize Shell Colors");

[suffix]
Button shell-pref-button {
valign: center;
label: _("Open Custom Shell Colors");
clicked => on_shell_pref_button_clicked();
}
}
}
}
6 changes: 3 additions & 3 deletions data/ui/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,23 @@ template GradienceMainWindow : Adw.ApplicationWindow {
title: _("Colors");
icon-name: "larger-brush-symbolic";

child: Adw.PreferencesPage content { };
child: Adw.PreferencesPage content-colors { };
}

Adw.ViewStackPage {
name: "theming";
title: _("Theming");
icon-name: "color-picker-symbolic";

child: Adw.PreferencesPage content_monet { };
child: Adw.PreferencesPage content-theming { };
}

Adw.ViewStackPage {
name: "plugins";
title: _("Advanced");
icon-name: "settings-symbolic";

child: Adw.PreferencesPage content_plugins { };
child: Adw.PreferencesPage content-plugins { };
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradience/backend/theming/preset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,12 @@ def apply_preset(self, app_type: str, preset: Preset) -> None:
) as file:
file.write(gtk3_css)
elif app_type == "shell":
shell_theme = ShellTheme(shell_version=43)
shell_theme = ShellTheme(shell_version=43) # TODO: Check which version of GNOME Shell user has installed

try:
shell_theme.create_theme(preset=preset)
except GLib.GError as e:
logging.error(f"Failed to apply a theme for GNOME Shell. Exc: {e}")
logging.error(f"Failed to apply a theme for GNOME Shell.", exc=e)
raise

def restore_gtk4_preset(self) -> None:
Expand Down
17 changes: 3 additions & 14 deletions gradience/frontend/dialogs/app_type_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,8 @@ class GradienceAppTypeDialog(Adw.MessageDialog):

gtk4_app_type = Gtk.Template.Child("gtk4-app-type")
gtk3_app_type = Gtk.Template.Child("gtk3-app-type")
gnome_app_type = Gtk.Template.Child("gnome-app-type")

def __init__(
self,
parent,
heading,
body,
ok_res_name,
ok_res_label,
ok_res_appearance,
**kwargs
):

def __init__(self, parent, heading, body, ok_res_name, ok_res_label, ok_res_appearance, **kwargs):
super().__init__(**kwargs)

self.parent = parent
Expand All @@ -58,6 +48,5 @@ def __init__(
def get_app_types(self):
return {
"gtk4": self.gtk4_app_type.get_active(),
"gtk3": self.gtk3_app_type.get_active(),
"shell": self.gnome_app_type.get_active()
"gtk3": self.gtk3_app_type.get_active()
}
2 changes: 1 addition & 1 deletion gradience/frontend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def apply_color_scheme(self, widget, response):
if widget.get_app_types()["gtk3"]:
PresetUtils().apply_preset("gtk3", self.preset)

if widget.get_app_types()["shell"]:
if self.settings.get_boolean("shell-theming-enabled"):
PresetUtils().apply_preset("shell", self.preset)

self.reload_plugins()
Expand Down
6 changes: 3 additions & 3 deletions gradience/frontend/schemas/shell_schema.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# shell_schema.py
#
# Change the look of Adwaita, with ease
# Copyright (C) 2022 Gradience Team
# Copyright (C) 2023, Gradience Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -19,8 +19,8 @@
shell_schema = {
"variables": [
{
"name": "_dark_base_color",
"title": _("Base color")
"name": "dark_base_color",
"title": _("Base Color")
},
{
"name": "fg_color",
Expand Down
Loading

0 comments on commit b48add9

Please sign in to comment.