Skip to content

Commit

Permalink
Check the existence of dconf-editor's schema (#1447)
Browse files Browse the repository at this point in the history
We need to check the existence of dconf-editor's GSettings schema before
using it, because the program will abort if dconf-editor is not installed
on the system when it tries to access it.
  • Loading branch information
City-busz authored and lukefromdc committed Oct 15, 2024
1 parent 2c39f24 commit c0eaf88
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 16 additions & 2 deletions libmate-panel-applet/mate-panel-applet-gsettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,21 @@ add_to_dict (GVariant *dict, const gchar *schema, const gchar *path)
static void
register_dconf_editor_relocatable_schema (const gchar *schema, const gchar *path)
{
GSettings *dconf_editor_settings;
dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
GSettingsSchemaSource *source;
GSettingsSchema *dconf_editor_schema;
GSettings *dconf_editor_settings;

source = g_settings_schema_source_get_default ();

if (! source)
return;

dconf_editor_schema = g_settings_schema_source_lookup (source, "ca.desrt.dconf-editor.Settings", FALSE);

if (! dconf_editor_schema)
return;

dconf_editor_settings = g_settings_new_full (dconf_editor_schema, NULL, NULL);

if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
Expand All @@ -108,6 +121,7 @@ register_dconf_editor_relocatable_schema (const gchar *schema, const gchar *path
}

g_object_unref (dconf_editor_settings);
g_settings_schema_unref (dconf_editor_schema);
}

GSettings *
Expand Down
18 changes: 16 additions & 2 deletions mate-panel/panel-profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,21 @@ remove_from_dict (GVariant *dict, const gchar *path)
static void
unregister_dconf_editor_relocatable_schema (const gchar *path)
{
GSettings *dconf_editor_settings;
dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
GSettingsSchemaSource *source;
GSettingsSchema *dconf_editor_schema;
GSettings *dconf_editor_settings;

source = g_settings_schema_source_get_default ();

if (! source)
return;

dconf_editor_schema = g_settings_schema_source_lookup (source, "ca.desrt.dconf-editor.Settings", FALSE);

if (! dconf_editor_schema)
return;

dconf_editor_settings = g_settings_new_full (dconf_editor_schema, NULL, NULL);

if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
Expand All @@ -878,6 +891,7 @@ unregister_dconf_editor_relocatable_schema (const gchar *path)
}

g_object_unref (dconf_editor_settings);
g_settings_schema_unref (dconf_editor_schema);
}


Expand Down

0 comments on commit c0eaf88

Please sign in to comment.