diff options
-rw-r--r-- | meta-xfce/recipes-apps/mousepad/files/0001-Plugin-support-Properly-handle-plugin-settings.patch | 279 | ||||
-rw-r--r-- | meta-xfce/recipes-apps/mousepad/mousepad_0.5.7.bb (renamed from meta-xfce/recipes-apps/mousepad/mousepad_0.5.5.bb) | 4 |
2 files changed, 1 insertions, 282 deletions
diff --git a/meta-xfce/recipes-apps/mousepad/files/0001-Plugin-support-Properly-handle-plugin-settings.patch b/meta-xfce/recipes-apps/mousepad/files/0001-Plugin-support-Properly-handle-plugin-settings.patch deleted file mode 100644 index 0ace907c41..0000000000 --- a/meta-xfce/recipes-apps/mousepad/files/0001-Plugin-support-Properly-handle-plugin-settings.patch +++ /dev/null | |||
@@ -1,279 +0,0 @@ | |||
1 | From 6d1800a305698f801236a2d73ebe178fa2d1139d Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Ga=C3=ABl=20Bonithon?= <gael@xfce.org> | ||
3 | Date: Sat, 12 Jun 2021 16:45:56 +0200 | ||
4 | Subject: [PATCH] Plugin support: Properly handle plugin settings | ||
5 | |||
6 | What was done in !92 was strictly speaking only suitable for one plugin. | ||
7 | This could be extended to several plugins by adding a `.gschema.xml` | ||
8 | file in `plugins/`, intermediate between the one of the application and | ||
9 | those of the plugins, or by refactoring the Makefiles with inclusions | ||
10 | and a single call to `@GSETTINGS_RULES@`. | ||
11 | |||
12 | But in any case, due to the relative rigidity of the `.gschema.xml` file | ||
13 | format and the internal workings of `glib-compile-schemas`, this would | ||
14 | only be suitable for plugins that are present at compile time, i.e. | ||
15 | "fake plugins". | ||
16 | |||
17 | Instead, this commit adds the plugin settings at load time, as is | ||
18 | natural and as the `GSettingsSchema` documentation states. To do this, | ||
19 | the setting store is extended to contain several roots: the application | ||
20 | root and the plugin roots. | ||
21 | |||
22 | For the latter, a unified naming convention is preserved, with the | ||
23 | prefix `org.xfce.mousepad.plugins.`, but they are in fact completely | ||
24 | independent of each other and independent of the application root. | ||
25 | |||
26 | Fixes #136, related to !92. | ||
27 | |||
28 | Upstream-Status: Backport [https://gitlab.xfce.org/apps/mousepad/-/commit/0d9d4f05aace800118d0a390e4e5dc5ebb940ca5] | ||
29 | |||
30 | Signed-off-by: Changqing Li <changqing.li@windriver.com> | ||
31 | --- | ||
32 | mousepad/mousepad-application.c | 12 +++- | ||
33 | mousepad/mousepad-settings-store.c | 70 ++++++++++++------- | ||
34 | mousepad/mousepad-settings-store.h | 3 + | ||
35 | mousepad/mousepad-settings.c | 14 +++- | ||
36 | mousepad/mousepad-settings.h | 1 + | ||
37 | mousepad/org.xfce.mousepad.gschema.xml | 1 - | ||
38 | ...g.xfce.mousepad.plugins.gspell.gschema.xml | 4 -- | ||
39 | 7 files changed, 71 insertions(+), 34 deletions(-) | ||
40 | |||
41 | diff --git a/mousepad/mousepad-application.c b/mousepad/mousepad-application.c | ||
42 | index d9a64ff..378d78e 100644 | ||
43 | --- a/mousepad/mousepad-application.c | ||
44 | +++ b/mousepad/mousepad-application.c | ||
45 | @@ -721,7 +721,7 @@ mousepad_application_load_plugins (MousepadApplication *application) | ||
46 | GError *error = NULL; | ||
47 | GDir *dir; | ||
48 | const gchar *basename; | ||
49 | - gchar *provider_name; | ||
50 | + gchar *provider_name, *schema_id; | ||
51 | gchar **strs; | ||
52 | gsize n_strs; | ||
53 | |||
54 | @@ -775,6 +775,16 @@ mousepad_application_load_plugins (MousepadApplication *application) | ||
55 | application, G_CONNECT_SWAPPED); | ||
56 | g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action)); | ||
57 | |||
58 | + /* add its settings to the setting store */ | ||
59 | + if (g_str_has_prefix (provider_name, "mousepad-plugin-")) | ||
60 | + schema_id = provider_name + 16; | ||
61 | + else | ||
62 | + schema_id = provider_name; | ||
63 | + | ||
64 | + schema_id = g_strconcat (MOUSEPAD_ID, ".plugins.", schema_id, NULL); | ||
65 | + mousepad_settings_add_root (schema_id); | ||
66 | + g_free (schema_id); | ||
67 | + | ||
68 | /* instantiate this provider types and initialize its action state */ | ||
69 | if (g_strv_contains ((const gchar *const *) strs, provider_name)) | ||
70 | { | ||
71 | diff --git a/mousepad/mousepad-settings-store.c b/mousepad/mousepad-settings-store.c | ||
72 | index de989bd..d117c53 100644 | ||
73 | --- a/mousepad/mousepad-settings-store.c | ||
74 | +++ b/mousepad/mousepad-settings-store.c | ||
75 | @@ -29,9 +29,11 @@ | ||
76 | |||
77 | struct MousepadSettingsStore_ | ||
78 | { | ||
79 | - GObject parent; | ||
80 | - GSettings *root; | ||
81 | - GHashTable *keys; | ||
82 | + GObject parent; | ||
83 | + | ||
84 | + GSettingsBackend *backend; | ||
85 | + GList *roots; | ||
86 | + GHashTable *keys; | ||
87 | }; | ||
88 | |||
89 | |||
90 | @@ -76,8 +78,10 @@ mousepad_setting_key_new (const gchar *key_name, | ||
91 | |||
92 | |||
93 | static void | ||
94 | -mousepad_setting_key_free (MousepadSettingKey *key) | ||
95 | +mousepad_setting_key_free (gpointer data) | ||
96 | { | ||
97 | + MousepadSettingKey *key = data; | ||
98 | + | ||
99 | if (G_LIKELY (key != NULL)) | ||
100 | { | ||
101 | g_object_unref (key->settings); | ||
102 | @@ -138,16 +142,16 @@ mousepad_settings_store_class_init (MousepadSettingsStoreClass *klass) | ||
103 | static void | ||
104 | mousepad_settings_store_finalize (GObject *object) | ||
105 | { | ||
106 | - MousepadSettingsStore *self; | ||
107 | + MousepadSettingsStore *self = MOUSEPAD_SETTINGS_STORE (object); | ||
108 | |||
109 | g_return_if_fail (MOUSEPAD_IS_SETTINGS_STORE (object)); | ||
110 | |||
111 | - self = MOUSEPAD_SETTINGS_STORE (object); | ||
112 | + if (self->backend != NULL) | ||
113 | + g_object_unref (self->backend); | ||
114 | |||
115 | + g_list_free_full (self->roots, g_object_unref); | ||
116 | g_hash_table_destroy (self->keys); | ||
117 | |||
118 | - g_object_unref (self->root); | ||
119 | - | ||
120 | G_OBJECT_CLASS (mousepad_settings_store_parent_class)->finalize (object); | ||
121 | } | ||
122 | |||
123 | @@ -212,28 +216,19 @@ static void | ||
124 | mousepad_settings_store_init (MousepadSettingsStore *self) | ||
125 | { | ||
126 | #ifdef MOUSEPAD_SETTINGS_KEYFILE_BACKEND | ||
127 | - GSettingsBackend *backend; | ||
128 | - gchar *conf_file; | ||
129 | - conf_file = g_build_filename (g_get_user_config_dir (), | ||
130 | - "Mousepad", | ||
131 | - "settings.conf", | ||
132 | - NULL); | ||
133 | - backend = g_keyfile_settings_backend_new (conf_file, "/", NULL); | ||
134 | + gchar *conf_file; | ||
135 | + | ||
136 | + conf_file = g_build_filename (g_get_user_config_dir (), "Mousepad", "settings.conf", NULL); | ||
137 | + self->backend = g_keyfile_settings_backend_new (conf_file, "/", NULL); | ||
138 | g_free (conf_file); | ||
139 | - self->root = g_settings_new_with_backend (MOUSEPAD_ID, backend); | ||
140 | - g_object_unref (backend); | ||
141 | #else | ||
142 | - self->root = g_settings_new (MOUSEPAD_ID); | ||
143 | + self->backend = NULL; | ||
144 | #endif | ||
145 | |||
146 | - self->keys = g_hash_table_new_full (g_str_hash, | ||
147 | - g_str_equal, | ||
148 | - NULL, | ||
149 | - (GDestroyNotify) mousepad_setting_key_free); | ||
150 | + self->roots = NULL; | ||
151 | + self->keys = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, mousepad_setting_key_free); | ||
152 | |||
153 | - mousepad_settings_store_add_settings (self, MOUSEPAD_ID, | ||
154 | - g_settings_schema_source_get_default (), | ||
155 | - self->root); | ||
156 | + mousepad_settings_store_add_root (self, MOUSEPAD_ID); | ||
157 | } | ||
158 | |||
159 | |||
160 | @@ -246,6 +241,31 @@ mousepad_settings_store_new (void) | ||
161 | |||
162 | |||
163 | |||
164 | +void | ||
165 | +mousepad_settings_store_add_root (MousepadSettingsStore *self, | ||
166 | + const gchar *schema_id) | ||
167 | +{ | ||
168 | + GSettingsSchemaSource *source; | ||
169 | + GSettingsSchema *schema; | ||
170 | + GSettings *root; | ||
171 | + | ||
172 | + source = g_settings_schema_source_get_default (); | ||
173 | + schema = g_settings_schema_source_lookup (source, schema_id, TRUE); | ||
174 | + | ||
175 | + /* exit silently if no schema is found: plugins may have settings or not */ | ||
176 | + if (schema == NULL) | ||
177 | + return; | ||
178 | + | ||
179 | + root = g_settings_new_full (schema, self->backend, NULL); | ||
180 | + g_settings_schema_unref (schema); | ||
181 | + | ||
182 | + self->roots = g_list_prepend (self->roots, root); | ||
183 | + | ||
184 | + mousepad_settings_store_add_settings (self, schema_id, source, root); | ||
185 | +} | ||
186 | + | ||
187 | + | ||
188 | + | ||
189 | const gchar * | ||
190 | mousepad_settings_store_lookup_key_name (MousepadSettingsStore *self, | ||
191 | const gchar *setting) | ||
192 | diff --git a/mousepad/mousepad-settings-store.h b/mousepad/mousepad-settings-store.h | ||
193 | index 3f5cae1..4842036 100644 | ||
194 | --- a/mousepad/mousepad-settings-store.h | ||
195 | +++ b/mousepad/mousepad-settings-store.h | ||
196 | @@ -38,6 +38,9 @@ GType mousepad_settings_store_get_type (void); | ||
197 | |||
198 | MousepadSettingsStore *mousepad_settings_store_new (void); | ||
199 | |||
200 | +void mousepad_settings_store_add_root (MousepadSettingsStore *store, | ||
201 | + const gchar *schema_id); | ||
202 | + | ||
203 | const gchar *mousepad_settings_store_lookup_key_name (MousepadSettingsStore *store, | ||
204 | const gchar *setting); | ||
205 | |||
206 | diff --git a/mousepad/mousepad-settings.c b/mousepad/mousepad-settings.c | ||
207 | index d071de6..66b338d 100644 | ||
208 | --- a/mousepad/mousepad-settings.c | ||
209 | +++ b/mousepad/mousepad-settings.c | ||
210 | @@ -24,6 +24,15 @@ static MousepadSettingsStore *settings_store = NULL; | ||
211 | |||
212 | |||
213 | |||
214 | +void | ||
215 | +mousepad_settings_init (void) | ||
216 | +{ | ||
217 | + if (settings_store == NULL) | ||
218 | + settings_store = mousepad_settings_store_new (); | ||
219 | +} | ||
220 | + | ||
221 | + | ||
222 | + | ||
223 | void | ||
224 | mousepad_settings_finalize (void) | ||
225 | { | ||
226 | @@ -39,10 +48,9 @@ mousepad_settings_finalize (void) | ||
227 | |||
228 | |||
229 | void | ||
230 | -mousepad_settings_init (void) | ||
231 | +mousepad_settings_add_root (const gchar *schema_id) | ||
232 | { | ||
233 | - if (settings_store == NULL) | ||
234 | - settings_store = mousepad_settings_store_new (); | ||
235 | + mousepad_settings_store_add_root (settings_store, schema_id); | ||
236 | } | ||
237 | |||
238 | |||
239 | diff --git a/mousepad/mousepad-settings.h b/mousepad/mousepad-settings.h | ||
240 | index bc63d11..615be51 100644 | ||
241 | --- a/mousepad/mousepad-settings.h | ||
242 | +++ b/mousepad/mousepad-settings.h | ||
243 | @@ -87,6 +87,7 @@ G_BEGIN_DECLS | ||
244 | |||
245 | void mousepad_settings_init (void); | ||
246 | void mousepad_settings_finalize (void); | ||
247 | +void mousepad_settings_add_root (const gchar *schema_id); | ||
248 | |||
249 | void mousepad_setting_bind (const gchar *setting, | ||
250 | gpointer object, | ||
251 | diff --git a/mousepad/org.xfce.mousepad.gschema.xml b/mousepad/org.xfce.mousepad.gschema.xml | ||
252 | index e802719..8509ee3 100644 | ||
253 | --- a/mousepad/org.xfce.mousepad.gschema.xml | ||
254 | +++ b/mousepad/org.xfce.mousepad.gschema.xml | ||
255 | @@ -39,7 +39,6 @@ | ||
256 | |||
257 | <!-- generic schemas --> | ||
258 | <schema id="org.xfce.mousepad" path="/org/xfce/mousepad/" gettext-domain="mousepad"> | ||
259 | - <child name="plugins" schema="org.xfce.mousepad.plugins"/> | ||
260 | <child name="preferences" schema="org.xfce.mousepad.preferences"/> | ||
261 | <child name="state" schema="org.xfce.mousepad.state"/> | ||
262 | </schema> | ||
263 | diff --git a/plugins/gspell-plugin/org.xfce.mousepad.plugins.gspell.gschema.xml b/plugins/gspell-plugin/org.xfce.mousepad.plugins.gspell.gschema.xml | ||
264 | index 6db65b6..95295ba 100644 | ||
265 | --- a/plugins/gspell-plugin/org.xfce.mousepad.plugins.gspell.gschema.xml | ||
266 | +++ b/plugins/gspell-plugin/org.xfce.mousepad.plugins.gspell.gschema.xml | ||
267 | @@ -1,9 +1,5 @@ | ||
268 | <schemalist> | ||
269 | |||
270 | - <schema id="org.xfce.mousepad.plugins" path="/org/xfce/mousepad/plugins/" gettext-domain="mousepad"> | ||
271 | - <child name="gspell" schema="org.xfce.mousepad.plugins.gspell"/> | ||
272 | - </schema> | ||
273 | - | ||
274 | <schema id="org.xfce.mousepad.plugins.gspell" path="/org/xfce/mousepad/plugins/gspell/" gettext-domain="mousepad"> | ||
275 | <child name="preferences" schema="org.xfce.mousepad.plugins.gspell.preferences"/> | ||
276 | </schema> | ||
277 | -- | ||
278 | 2.17.1 | ||
279 | |||
diff --git a/meta-xfce/recipes-apps/mousepad/mousepad_0.5.5.bb b/meta-xfce/recipes-apps/mousepad/mousepad_0.5.7.bb index bab564288e..4897a7eca7 100644 --- a/meta-xfce/recipes-apps/mousepad/mousepad_0.5.5.bb +++ b/meta-xfce/recipes-apps/mousepad/mousepad_0.5.7.bb | |||
@@ -7,9 +7,7 @@ DEPENDS = "gtk+3 gtksourceview4 xfconf xfce4-dev-tools-native" | |||
7 | 7 | ||
8 | inherit xfce-app gsettings mime-xdg | 8 | inherit xfce-app gsettings mime-xdg |
9 | 9 | ||
10 | SRC_URI += "file://0001-Plugin-support-Properly-handle-plugin-settings.patch" | 10 | SRC_URI[sha256sum] = "105315743042e09e794037ab0594a1c47cbbf0b6b834dffed157192f4f03bde8" |
11 | |||
12 | SRC_URI[sha256sum] = "40c35f00e0e10df50a59bd0dbba9007d2fb5574ed8a2aa73b0fc5ef40e64abe1" | ||
13 | 11 | ||
14 | PACKAGECONFIG ??= "" | 12 | PACKAGECONFIG ??= "" |
15 | PACKAGECONFIG[spell] = "--enable-plugin-gspell,--disable-plugin-gspell,gspell" | 13 | PACKAGECONFIG[spell] = "--enable-plugin-gspell,--disable-plugin-gspell,gspell" |