[gedit/wip/misc] filebrowser: more robust check if Nautilus GSettings can be used
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/misc] filebrowser: more robust check if Nautilus GSettings can be used
- Date: Sat, 16 Jul 2022 16:14:15 +0000 (UTC)
commit e85f70706551a85950d9d868a7ece24955de58a6
Author: Sébastien Wilmet <swilmet informatique-libre be>
Date: Sat Jul 16 17:47:21 2022 +0200
filebrowser: more robust check if Nautilus GSettings can be used
plugins/filebrowser/gedit-file-browser-plugin.c | 34 ++++++++++++++++---------
1 file changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/plugins/filebrowser/gedit-file-browser-plugin.c b/plugins/filebrowser/gedit-file-browser-plugin.c
index 73d702fa4..cc81ab3f2 100644
--- a/plugins/filebrowser/gedit-file-browser-plugin.c
+++ b/plugins/filebrowser/gedit-file-browser-plugin.c
@@ -47,7 +47,8 @@
#define FILEBROWSER_FILTER_PATTERN "filter-pattern"
#define FILEBROWSER_BINARY_PATTERNS "binary-patterns"
-#define NAUTILUS_BASE_SETTINGS "org.gnome.nautilus.preferences"
+//#define NAUTILUS_BASE_SETTINGS "org.gnome.nautilus.preferences"
+#define NAUTILUS_BASE_SETTINGS "org.gnome.nautilus.nausietnusetsuiet"
#define NAUTILUS_FALLBACK_SETTINGS "org.gnome.gedit.plugins.filebrowser.nautilus"
#define NAUTILUS_CLICK_POLICY_KEY "click-policy"
@@ -120,24 +121,28 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (GeditFileBrowserPlugin,
_gedit_file_browser_widget_register_type (type_module); \
)
-static GSettings *
-settings_try_new (const gchar *schema_id)
+static gboolean
+can_use_nautilus_gsettings (void)
{
- GSettings *settings = NULL;
GSettingsSchemaSource *source;
GSettingsSchema *schema;
+ gboolean can_use;
source = g_settings_schema_source_get_default ();
+ g_assert (source != NULL);
+ schema = g_settings_schema_source_lookup (source, NAUTILUS_BASE_SETTINGS, TRUE);
- schema = g_settings_schema_source_lookup (source, schema_id, TRUE);
-
- if (schema != NULL)
+ if (schema == NULL)
{
- settings = g_settings_new_full (schema, NULL, NULL);
- g_settings_schema_unref (schema);
+ g_print ("null schema\n");
+ return FALSE;
}
- return settings;
+ can_use = g_settings_schema_has_key (schema, NAUTILUS_CLICK_POLICY_KEY);
+ g_print ("has key: %d\n", can_use);
+
+ g_settings_schema_unref (schema);
+ return can_use;
}
static void
@@ -147,10 +152,15 @@ gedit_file_browser_plugin_init (GeditFileBrowserPlugin *plugin)
plugin->priv->settings = g_settings_new (FILEBROWSER_BASE_SETTINGS);
plugin->priv->terminal_settings = g_settings_new (TERMINAL_BASE_SETTINGS);
- plugin->priv->nautilus_settings = settings_try_new (NAUTILUS_BASE_SETTINGS);
- if (plugin->priv->nautilus_settings == NULL)
+ if (can_use_nautilus_gsettings ())
+ {
+ g_print ("Can use nautilus gsettings\n");
+ plugin->priv->nautilus_settings = g_settings_new (NAUTILUS_BASE_SETTINGS);
+ }
+ else
{
+ g_print ("Cannot use nautilus gsettings\n");
plugin->priv->nautilus_settings = g_settings_new (NAUTILUS_FALLBACK_SETTINGS);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]