Skip to content

Commit 62768c8

Browse files
committed
Fix menu coloring
1 parent 6834e2d commit 62768c8

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

background/Application.vala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ public class Gala.Background.Application : Gtk.Application {
1717

1818
hold ();
1919

20+
/*
21+
* We can't use Granite for the color scheme since it connects to the portal which only becomes available
22+
* some time after we are already showing.
23+
*/
24+
Utils.init_color_scheme_watcher ((scheme) => {
25+
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = scheme == DARK;
26+
});
27+
2028
/*
2129
* We have to be careful not to init Granite because Granite gets Settings sync but it takes a while
2230
* until the portal launches so it blocks.

background/BackgroundManager.vala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@ public class Gala.Background.BackgroundManager : Object {
1818
private uint idle_id = 0;
1919

2020
construct {
21-
/*
22-
* We can't use Granite for the color scheme since it connects to the portal which only becomes available
23-
* some time after we are already showing.
24-
*/
25-
Utils.init_color_scheme_watcher (queue_set_background);
26-
2721
setup_background ();
2822
Gdk.Display.get_default ().get_monitors ().items_changed.connect (setup_background);
2923

3024
set_background ();
3125
gnome_settings.changed.connect (queue_set_background);
3226
elementary_settings.changed.connect (queue_set_background);
27+
28+
Gtk.Settings.get_default ().notify["gtk-application-prefer-dark-theme"].connect (queue_set_background);
3329
}
3430

3531
private void setup_background () {
@@ -75,7 +71,7 @@ public class Gala.Background.BackgroundManager : Object {
7571
}
7672

7773
if (elementary_settings.get_boolean ("dim-wallpaper-in-dark-style")
78-
&& Utils.get_color_scheme () == DARK
74+
&& Gtk.Settings.get_default ().gtk_application_prefer_dark_theme
7975
) {
8076
current_background = Background.get_dimmed (current_background);
8177
}

background/Utils.vala

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace Gala.Background.Utils {
2020
[DBus (name = "io.elementary.pantheon.AccountsService")]
2121
private interface AccountsService : DBusProxy {
2222
public abstract int prefers_color_scheme { get; set; }
23-
public abstract int prefers_accent_color { get; set; }
2423
}
2524

2625
private const string FDO_ACCOUNTS_NAME = "org.freedesktop.Accounts";
@@ -40,6 +39,8 @@ namespace Gala.Background.Utils {
4039
return;
4140
}
4241

42+
style_change_callback (accounts_service_proxy.prefers_color_scheme);
43+
4344
accounts_service_proxy.g_properties_changed.connect ((changed, invalid) => {
4445
var value = changed.lookup_value ("PrefersColorScheme", new VariantType ("i"));
4546
if (value != null) {
@@ -48,14 +49,6 @@ namespace Gala.Background.Utils {
4849
});
4950
}
5051

51-
public static ColorScheme get_color_scheme () {
52-
if (accounts_service_proxy != null) {
53-
return accounts_service_proxy.prefers_color_scheme;
54-
}
55-
56-
return LIGHT;
57-
}
58-
5952
private const double SATURATION_WEIGHT = 1.5;
6053
private const double WEIGHT_THRESHOLD = 1.0;
6154

0 commit comments

Comments
 (0)