1
|
|
-From 277418cea7b011520df9759301d416cd51709564 Mon Sep 17 00:00:00 2001
|
2
|
|
-From: Denis Gorodnichev <denis.gorodnichev@gmail.com>
|
3
|
|
-Date: Wed, 17 May 2023 06:56:21 +0300
|
4
|
|
-Subject: [PATCH 4/6] tell dconf-edit about relocatable schemas (#1355)
|
5
|
|
-
|
6
|
|
-* tell dconf-edit about relocatable schemas
|
7
|
|
-
|
8
|
|
-* self fix for incorrect and duplicated records
|
9
|
|
-
|
10
|
|
-remove duplicated schemas for currect path
|
11
|
|
-remove incorrect schemas for current path
|
12
|
|
-
|
13
|
|
-* remove clock applet hack
|
14
|
|
-
|
15
|
|
-* expose mate_panel_applet_settings_new to introspection
|
16
|
|
-
|
17
|
|
-add "transfer full" annotation to make this method available through
|
18
|
|
-introspection
|
19
|
|
-
|
20
|
|
-Signed-off-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
|
21
|
|
----
|
22
|
|
- applets/clock/clock.c | 10 ---
|
23
|
|
- .../mate-panel-applet-gsettings.c | 82 +++++++++++++++++++
|
24
|
|
- .../mate-panel-applet-gsettings.h | 8 ++
|
25
|
|
- mate-panel/panel-profile.c | 47 +++++++++++
|
26
|
|
- 4 files changed, 137 insertions(+), 10 deletions(-)
|
27
|
|
-
|
28
|
|
-diff --git a/applets/clock/clock.c b/applets/clock/clock.c
|
29
|
|
-index 0ee49628..7a11f0e9 100644
|
30
|
|
---- a/applets/clock/clock.c
|
31
|
|
-+++ b/applets/clock/clock.c
|
32
|
|
-@@ -2411,18 +2411,8 @@ show_week_changed (GSettings *settings,
|
33
|
|
- static void
|
34
|
|
- setup_gsettings (ClockData *cd)
|
35
|
|
- {
|
36
|
|
-- gint format;
|
37
|
|
-- gchar *custom_format;
|
38
|
|
--
|
39
|
|
- cd->settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (cd->applet), CLOCK_SCHEMA);
|
40
|
|
-
|
41
|
|
-- /* hack to allow users to set custom format in dconf-editor */
|
42
|
|
-- format = g_settings_get_enum (cd->settings, KEY_FORMAT);
|
43
|
|
-- custom_format = g_settings_get_string (cd->settings, KEY_CUSTOM_FORMAT);
|
44
|
|
-- g_settings_set_enum (cd->settings, KEY_FORMAT, format);
|
45
|
|
-- g_settings_set_string (cd->settings, KEY_CUSTOM_FORMAT, custom_format);
|
46
|
|
-- g_free (custom_format);
|
47
|
|
--
|
48
|
|
- g_signal_connect (cd->settings, "changed::" KEY_FORMAT, G_CALLBACK (format_changed), cd);
|
49
|
|
- g_signal_connect (cd->settings, "changed::" KEY_SHOW_SECONDS, G_CALLBACK (show_seconds_changed), cd);
|
50
|
|
- g_signal_connect (cd->settings, "changed::" KEY_SHOW_DATE, G_CALLBACK (show_date_changed), cd);
|
51
|
|
-diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.c b/libmate-panel-applet/mate-panel-applet-gsettings.c
|
52
|
|
-index 1c0ac744..4679dc6d 100644
|
53
|
|
---- a/libmate-panel-applet/mate-panel-applet-gsettings.c
|
54
|
|
-+++ b/libmate-panel-applet/mate-panel-applet-gsettings.c
|
55
|
|
-@@ -29,6 +29,87 @@
|
56
|
|
- #include "mate-panel-applet.h"
|
57
|
|
- #include "mate-panel-applet-gsettings.h"
|
58
|
|
-
|
59
|
|
-+static GVariant *
|
60
|
|
-+add_to_dict (GVariant *dict, const gchar *schema, const gchar *path)
|
61
|
|
-+{
|
62
|
|
-+ GVariantIter iter;
|
63
|
|
-+ GVariantBuilder builder;
|
64
|
|
-+ gboolean is_schema_found;
|
65
|
|
-+ gboolean is_incorrect_schema;
|
66
|
|
-+ gint path_counter;
|
67
|
|
-+
|
68
|
|
-+ gchar *key;
|
69
|
|
-+ gchar *value;
|
70
|
|
-+
|
71
|
|
-+ g_variant_builder_init (&builder, (const GVariantType *) "a{ss}");
|
72
|
|
-+ g_variant_iter_init (&iter, dict);
|
73
|
|
-+
|
74
|
|
-+ is_schema_found = FALSE;
|
75
|
|
-+ is_incorrect_schema = FALSE;
|
76
|
|
-+ path_counter = 0;
|
77
|
|
-+
|
78
|
|
-+ while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
|
79
|
|
-+ gboolean path_is_found = FALSE;
|
80
|
|
-+ if (g_strcmp0 (value, path) == 0) {
|
81
|
|
-+ path_is_found = TRUE;
|
82
|
|
-+ path_counter++;
|
83
|
|
-+ if (g_strcmp0 (key, schema) == 0) {
|
84
|
|
-+ is_schema_found = TRUE;
|
85
|
|
-+ } else {
|
86
|
|
-+ // skip incoorect schema for path
|
87
|
|
-+ is_incorrect_schema = TRUE;
|
88
|
|
-+ g_free (key);
|
89
|
|
-+ g_free (value);
|
90
|
|
-+ continue;
|
91
|
|
-+ }
|
92
|
|
-+ }
|
93
|
|
-+
|
94
|
|
-+ gboolean need_add_to_dict = !path_is_found || path_counter < 2;
|
95
|
|
-+
|
96
|
|
-+ if (need_add_to_dict) {
|
97
|
|
-+ g_variant_builder_add (&builder, "{ss}", key, value);
|
98
|
|
-+ }
|
99
|
|
-+
|
100
|
|
-+ g_free (key);
|
101
|
|
-+ g_free (value);
|
102
|
|
-+ }
|
103
|
|
-+
|
104
|
|
-+ if (!is_schema_found) {
|
105
|
|
-+ g_variant_builder_add (&builder, "{ss}", schema, path);
|
106
|
|
-+ }
|
107
|
|
-+
|
108
|
|
-+ if (!is_schema_found || is_incorrect_schema || (path_counter > 1)) {
|
109
|
|
-+ return g_variant_ref_sink (g_variant_builder_end (&builder));
|
110
|
|
-+ } else {
|
111
|
|
-+ g_variant_builder_clear (&builder);
|
112
|
|
-+ // no changes
|
113
|
|
-+ return NULL;
|
114
|
|
-+ }
|
115
|
|
-+}
|
116
|
|
-+
|
117
|
|
-+static void
|
118
|
|
-+register_dconf_editor_relocatable_schema (const gchar *schema, const gchar *path)
|
119
|
|
-+{
|
120
|
|
-+ GSettings *dconf_editor_settings;
|
121
|
|
-+ dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
|
122
|
|
-+
|
123
|
|
-+ if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
|
124
|
|
-+ GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
|
125
|
|
-+
|
126
|
|
-+ if (g_variant_is_of_type (relocatable_schemas, G_VARIANT_TYPE_DICTIONARY)) {
|
127
|
|
-+ GVariant * new_relocatable_schemas = add_to_dict (relocatable_schemas, schema, path);
|
128
|
|
-+ if (new_relocatable_schemas) {
|
129
|
|
-+ g_settings_set_value (dconf_editor_settings, "relocatable-schemas-user-paths", new_relocatable_schemas);
|
130
|
|
-+ g_variant_unref (new_relocatable_schemas);
|
131
|
|
-+ }
|
132
|
|
-+ }
|
133
|
|
-+
|
134
|
|
-+ g_variant_unref (relocatable_schemas);
|
135
|
|
-+ }
|
136
|
|
-+
|
137
|
|
-+ g_object_unref (dconf_editor_settings);
|
138
|
|
-+}
|
139
|
|
-+
|
140
|
|
- GSettings *
|
141
|
|
- mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema)
|
142
|
|
- {
|
143
|
|
-@@ -41,6 +122,7 @@ mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema)
|
144
|
|
-
|
145
|
|
- if (path) {
|
146
|
|
- settings = g_settings_new_with_path (schema, path);
|
147
|
|
-+ register_dconf_editor_relocatable_schema (schema, path);
|
148
|
|
- g_free (path);
|
149
|
|
- }
|
150
|
|
-
|
151
|
|
-diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.h b/libmate-panel-applet/mate-panel-applet-gsettings.h
|
152
|
|
-index 0dbbdb01..152a73d2 100644
|
153
|
|
---- a/libmate-panel-applet/mate-panel-applet-gsettings.h
|
154
|
|
-+++ b/libmate-panel-applet/mate-panel-applet-gsettings.h
|
155
|
|
-@@ -35,7 +35,15 @@
|
156
|
|
-
|
157
|
|
- G_BEGIN_DECLS
|
158
|
|
-
|
159
|
|
-+/**
|
160
|
|
-+ * mate_panel_applet_settings_new:
|
161
|
|
-+ * @applet A #MatePanelApplet
|
162
|
|
-+ * @schema applet's schema id
|
163
|
|
-+ *
|
164
|
|
-+ * Returns: (transfer full): a #GSettings. free when you used it
|
165
|
|
-+ */
|
166
|
|
- GSettings* mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema);
|
167
|
|
-+
|
168
|
|
- GList* mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key);
|
169
|
|
- void mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list);
|
170
|
|
- GSList* mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key);
|
171
|
|
-diff --git a/mate-panel/panel-profile.c b/mate-panel/panel-profile.c
|
172
|
|
-index 05da882e..47d6d95b 100644
|
173
|
|
---- a/mate-panel/panel-profile.c
|
174
|
|
-+++ b/mate-panel/panel-profile.c
|
175
|
|
-@@ -835,6 +835,52 @@ key_from_type (PanelGSettingsKeyType type) {
|
176
|
|
- return NULL;
|
177
|
|
- }
|
178
|
|
-
|
179
|
|
-+static GVariant *
|
180
|
|
-+remove_from_dict (GVariant *dict, const gchar *path)
|
181
|
|
-+{
|
182
|
|
-+ GVariantIter iter;
|
183
|
|
-+ GVariantBuilder builder;
|
184
|
|
-+
|
185
|
|
-+ gchar *key;
|
186
|
|
-+ gchar *value;
|
187
|
|
-+
|
188
|
|
-+ g_variant_builder_init (&builder, (const GVariantType *) "a{ss}");
|
189
|
|
-+ g_variant_iter_init (&iter, dict);
|
190
|
|
-+
|
191
|
|
-+ while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
|
192
|
|
-+ if ( g_strcmp0 (value, path) != 0) {
|
193
|
|
-+ g_variant_builder_add (&builder, "{ss}", key, value);
|
194
|
|
-+ }
|
195
|
|
-+
|
196
|
|
-+ g_free (key);
|
197
|
|
-+ g_free (value);
|
198
|
|
-+ }
|
199
|
|
-+
|
200
|
|
-+ return g_variant_ref_sink (g_variant_builder_end (&builder));
|
201
|
|
-+}
|
202
|
|
-+
|
203
|
|
-+static void
|
204
|
|
-+unregister_dconf_editor_relocatable_schema (const gchar *path)
|
205
|
|
-+{
|
206
|
|
-+ GSettings *dconf_editor_settings;
|
207
|
|
-+ dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
|
208
|
|
-+
|
209
|
|
-+ if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
|
210
|
|
-+ GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
|
211
|
|
-+
|
212
|
|
-+ if (g_variant_is_of_type (relocatable_schemas, G_VARIANT_TYPE_DICTIONARY)) {
|
213
|
|
-+ GVariant * new_relocatable_schemas = remove_from_dict (relocatable_schemas, path);
|
214
|
|
-+ g_settings_set_value (dconf_editor_settings, "relocatable-schemas-user-paths", new_relocatable_schemas);
|
215
|
|
-+ g_variant_unref (new_relocatable_schemas);
|
216
|
|
-+ }
|
217
|
|
-+
|
218
|
|
-+ g_variant_unref (relocatable_schemas);
|
219
|
|
-+ }
|
220
|
|
-+
|
221
|
|
-+ g_object_unref (dconf_editor_settings);
|
222
|
|
-+}
|
223
|
|
-+
|
224
|
|
-+
|
225
|
|
- void
|
226
|
|
- panel_profile_add_to_list (PanelGSettingsKeyType type,
|
227
|
|
- const char *id)
|
228
|
|
-@@ -1345,6 +1391,7 @@ panel_profile_delete_dir (PanelGSettingsKeyType type,
|
229
|
|
- gchar *subdir;
|
230
|
|
- subdir = g_strdup_printf (PANEL_TOPLEVEL_PATH "%s/prefs/", id);
|
231
|
|
- mate_dconf_recursive_reset (subdir, NULL);
|
232
|
|
-+ unregister_dconf_editor_relocatable_schema (subdir);
|
233
|
|
- g_free (subdir);
|
234
|
|
- }
|
235
|
|
-
|
236
|
|
---
|
237
|
|
-2.39.2
|
238
|
|
- |