forked from elementary/fileroller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fr-application-prefers-color-scheme.patch
102 lines (92 loc) · 3.28 KB
/
fr-application-prefers-color-scheme.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
--- a/meson.build 2021-10-20 21:13:40.609148697 -0300
+++ b/meson.build 2021-10-20 21:14:39.100481137 -0300
@@ -5,6 +5,7 @@
)
glib_version = '>=2.38'
+granite_version = '>=5.4.0'
gtk_version = '>=3.22.0'
nautilus_version = '>=3.28.0'
json_glib_version = '>=0.14.0'
@@ -26,6 +27,7 @@
libm_dep = c_comp.find_library('m')
thread_dep = dependency('threads')
glib_dep = dependency('glib-2.0', version : glib_version)
+granite_dep = dependency('granite', version : granite_version)
gthread_dep = dependency('gthread-2.0')
gtk_dep = dependency('gtk+-3.0', version : gtk_version)
--- a/src/meson.build 2021-10-20 21:13:45.597451531 -0300
+++ b/src/meson.build 2021-10-20 21:13:33.592716613 -0300
@@ -88,6 +88,7 @@
libm_dep,
thread_dep,
glib_dep,
+ granite_dep,
gthread_dep,
gtk_dep,
use_json_glib ? libjson_glib_dep : [],
--- a/src/fr-application.c 2021-10-20 21:20:35.812767699 -0300
+++ b/src/fr-application.c 2021-10-20 21:20:12.212284465 -0300
@@ -28,6 +28,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glib/gprintf.h>
+#include <granite.h>
#ifdef ENABLE_NOTIFICATION
# include <libnotify/notify.h>
#endif
@@ -348,6 +349,7 @@
guint owner_id;
GSettings *listing_settings;
GSettings *ui_settings;
+ GBinding *color_scheme;
};
@@ -365,7 +367,7 @@
g_bus_unown_name (self->owner_id);
_g_object_unref (self->listing_settings);
_g_object_unref (self->ui_settings);
-
+ _g_object_unref (self->color_scheme);
release_data ();
G_OBJECT_CLASS (fr_application_parent_class)->finalize (object);
@@ -443,12 +445,24 @@
g_free (buffer);
}
+static gboolean
+update_prefers_color_scheme (GBinding *binding,
+ const GValue *source,
+ GValue *target,
+ gpointer user_data)
+{
+ GraniteSettingsColorScheme color_scheme = g_value_get_enum (source);
+
+ g_value_set_boolean (target, color_scheme == GRANITE_SETTINGS_COLOR_SCHEME_DARK);
+ return TRUE;
+}
static void
fr_application_startup (GApplication *application)
{
- GtkSettings *gtk_settings;
- gboolean shell_shows_menubar;
+ GraniteSettings *granite_settings;
+ GtkSettings *gtk_settings;
+ gboolean shell_shows_menubar;
g_application_set_resource_base_path (application, "/org/gnome/FileRoller");
G_APPLICATION_CLASS (fr_application_parent_class)->startup (application);
@@ -464,9 +477,18 @@
fr_application_register_archive_manager_service (FR_APPLICATION (application));
initialize_data ();
+ granite_settings = granite_settings_get_default ();
+ gtk_settings = gtk_settings_get_default ();
+
+ FR_APPLICATION (application)->color_scheme =
+ g_object_bind_property_full (granite_settings,"prefers-color-scheme",
+ gtk_settings, "gtk-application-prefer-dark-theme",
+ G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
+ update_prefers_color_scheme,
+ NULL, NULL, NULL);
+
/* use the menubar only when the shell shows the menu bar */
- gtk_settings = gtk_settings_get_default ();
g_object_get (G_OBJECT (gtk_settings),
"gtk-shell-shows-menubar", &shell_shows_menubar,
NULL);