Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SettingsPopover: use provider_for_screen for theme buttons #785

Merged
merged 5 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions data/Application.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ vte-terminal {
padding: 0 9px;
}

.color-custom radio {
.color-button radio {
padding: 10px;
-gtk-icon-shadow: none;
}

.color-button.custom radio {
-gtk-icon-source: -gtk-icontheme("list-add-symbolic");
}

.color-custom radio:checked {
.color-button.custom radio:checked {
-gtk-icon-source: -gtk-icontheme("check-active-symbolic");
}

Expand Down
15 changes: 7 additions & 8 deletions src/Widgets/SettingsPopover.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ public sealed class Terminal.SettingsPopover : Gtk.Popover {
}

private const string STYLE_CSS = """
.color-button radio {
.color-button.%s radio {
background-color: %s;
color: %s;
padding: 10px;
jeremypw marked this conversation as resolved.
Show resolved Hide resolved
-gtk-icon-shadow: none;
}
""";

Expand Down Expand Up @@ -107,7 +105,6 @@ public sealed class Terminal.SettingsPopover : Gtk.Popover {
var custom_button = add_theme_button (Themes.CUSTOM, out custom_button_provider);
custom_button.tooltip_text = _("Custom");
custom_button.group = hc_button;
custom_button.get_style_context ().add_class ("color-custom");

update_active_colorbutton (dark_button, Application.settings.get_string ("theme"));

Expand Down Expand Up @@ -167,11 +164,13 @@ public sealed class Terminal.SettingsPopover : Gtk.Popover {
halign = Gtk.Align.CENTER
};

button.get_style_context ().add_class (Granite.STYLE_CLASS_COLOR_BUTTON);
button.get_style_context ().add_class (theme);

css_provider = new Gtk.CssProvider ();

unowned var style_context = button.get_style_context ();
style_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON);
style_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

update_theme_provider (css_provider, theme);

button.toggled.connect ((b) => {
Expand Down Expand Up @@ -201,7 +200,7 @@ public sealed class Terminal.SettingsPopover : Gtk.Popover {
var foreground = theme_palette[Themes.PALETTE_SIZE - 2].to_string ();

try {
css_provider.load_from_data (STYLE_CSS.printf (background, foreground));
css_provider.load_from_data (STYLE_CSS.printf (theme, background, foreground));
} catch (Error e) {
critical ("Unable to style color button: %s", e.message);
}
Expand Down