[gnome-builder] app: keep gsettings around for future use
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] app: keep gsettings around for future use
- Date: Mon, 13 Nov 2017 08:15:24 +0000 (UTC)
commit cfa6fbff1bdafa429429dd19c00ee0572ae02ae7
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 13 00:14:28 2017 -0800
app: keep gsettings around for future use
I noticed that unrefing the first one goes through a bunch of side-effects
to unsubscribe. We need it for the lifetime of the app, so just keep it
around instead of immediately discarding it.
src/libide/application/ide-application-private.h | 2 ++
src/libide/application/ide-application.c | 21 +++++++++------------
2 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/src/libide/application/ide-application-private.h
b/src/libide/application/ide-application-private.h
index 1ad2411..07f69b2 100644
--- a/src/libide/application/ide-application-private.h
+++ b/src/libide/application/ide-application-private.h
@@ -61,6 +61,8 @@ struct _IdeApplication
GHashTable *plugin_settings;
GPtrArray *reapers;
+
+ GSettings *settings;
};
void ide_application_discover_plugins (IdeApplication *self) G_GNUC_INTERNAL;
diff --git a/src/libide/application/ide-application.c b/src/libide/application/ide-application.c
index 20b07ea..c8b5e2a 100644
--- a/src/libide/application/ide-application.c
+++ b/src/libide/application/ide-application.c
@@ -79,7 +79,6 @@ _ide_application_set_mode (IdeApplication *self,
static void
ide_application_make_skeleton_dirs (IdeApplication *self)
{
- g_autoptr(GSettings) settings = NULL;
g_autofree gchar *projects_dir = NULL;
gchar *path;
@@ -99,8 +98,7 @@ ide_application_make_skeleton_dirs (IdeApplication *self)
g_mkdir_with_parents (path, 0750);
g_free (path);
- settings = g_settings_new ("org.gnome.builder");
- projects_dir = g_settings_get_string (settings, "projects-directory");
+ projects_dir = g_settings_get_string (self->settings, "projects-directory");
if (!g_path_is_absolute (projects_dir))
{
@@ -127,7 +125,7 @@ ide_application_register_keybindings (IdeApplication *self)
settings = g_settings_new ("org.gnome.builder.editor");
name = g_settings_get_string (settings, "keybindings");
- self->keybindings = ide_keybindings_new (GTK_APPLICATION (self), name);
+ self->keybindings = ide_keybindings_new (name);
g_settings_bind (settings, "keybindings", self->keybindings, "mode", G_SETTINGS_BIND_GET);
IDE_EXIT;
@@ -380,15 +378,11 @@ ide_application_register_settings (IdeApplication *self)
if (g_getenv ("GTK_THEME") == NULL)
{
- g_autoptr(GSettings) settings = NULL;
- GtkSettings *gtk_settings;
-
- settings = g_settings_new ("org.gnome.builder");
- gtk_settings = gtk_settings_get_default ();
+ GtkSettings *gtk_settings = gtk_settings_get_default ();
- g_settings_bind (settings, "night-mode",
- gtk_settings, "gtk-application-prefer-dark-theme",
- G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (self->settings, "night-mode",
+ gtk_settings, "gtk-application-prefer-dark-theme",
+ G_SETTINGS_BIND_DEFAULT);
}
IDE_EXIT;
@@ -402,6 +396,8 @@ ide_application_startup (GApplication *application)
g_assert (IDE_IS_APPLICATION (self));
+ self->settings = g_settings_new ("org.gnome.builder");
+
g_resources_register (ide_get_resource ());
g_resources_register (ide_icons_get_resource ());
@@ -523,6 +519,7 @@ ide_application_finalize (GObject *object)
g_clear_object (&self->worker_manager);
g_clear_object (&self->keybindings);
g_clear_object (&self->recent_projects);
+ g_clear_object (&self->settings);
G_OBJECT_CLASS (ide_application_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]