[gnome-builder/wip/chergert/perspective] prefs: push schema-id and path into container for expansion



commit 270e3ffb746aa443e0883903f94dd7ea27b83818
Author: Christian Hergert <chergert redhat com>
Date:   Mon Nov 9 23:38:39 2015 -0800

    prefs: push schema-id and path into container for expansion
    
    We intend to have sub-pages which can be pushed onto the preferences stack.
    This requires that we be able to expand some simple key/value pairs so that
    the transient page can be based on user input (such as a source language
    id). Pushing the expansion code into container seems like the natural
    choice.
    
    We still need to add transient pages and API for setting that key/value
    map.

 libide/Makefile.am                                 |    1 +
 libide/preferences/ide-preferences-builtin.c       |   28 +++-
 .../ide-preferences-container-private.h            |   31 ++++
 libide/preferences/ide-preferences-container.c     |  186 +++++++++++++++++++-
 libide/preferences/ide-preferences-container.h     |    2 +
 libide/preferences/ide-preferences-font-button.c   |   28 +---
 libide/preferences/ide-preferences-spin-button.c   |   51 +-----
 libide/preferences/ide-preferences-switch.c        |   51 +-----
 8 files changed, 250 insertions(+), 128 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index e6a9797..f6feac4 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -274,6 +274,7 @@ libide_1_0_la_SOURCES = \
        preferences/ide-preferences-builtin.h \
        preferences/ide-preferences-container.c \
        preferences/ide-preferences-container.h \
+       preferences/ide-preferences-container-private.h \
        preferences/ide-preferences-entry.c \
        preferences/ide-preferences-entry.h \
        preferences/ide-preferences-font-button.c \
diff --git a/libide/preferences/ide-preferences-builtin.c b/libide/preferences/ide-preferences-builtin.c
index 698d63d..cd68f5b 100644
--- a/libide/preferences/ide-preferences-builtin.c
+++ b/libide/preferences/ide-preferences-builtin.c
@@ -289,18 +289,32 @@ ide_preferences_builtin_register_languages (IdePreferences *preferences)
   for (i = 0; language_ids [i]; i++)
     {
       GtkSourceLanguage *language;
+      GtkBox *box;
+      GtkImage *arrow;
+      GtkLabel *title;
       const gchar *name;
 
       language = gtk_source_language_manager_get_language (manager, language_ids [i]);
       name = gtk_source_language_get_name (language);
 
-      ide_preferences_add_custom (preferences, "languages", "list",
-                                  g_object_new (GTK_TYPE_LABEL,
-                                                "xalign", 0.0f,
-                                                "visible", TRUE,
-                                                "label", name,
-                                                NULL),
-                                  NULL, 0);
+      box = g_object_new (GTK_TYPE_BOX,
+                          "visible", TRUE,
+                          "orientation", GTK_ORIENTATION_HORIZONTAL,
+                          NULL);
+      title = g_object_new (GTK_TYPE_LABEL,
+                            "hexpand", TRUE,
+                            "label", name,
+                            "visible", TRUE,
+                            "xalign", 0.0f,
+                            NULL);
+      arrow = g_object_new (GTK_TYPE_IMAGE,
+                            "icon-name", "pan-end-symbolic",
+                            "visible", TRUE,
+                            NULL);
+      gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (title));
+      gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (arrow));
+
+      ide_preferences_add_custom (preferences, "languages", "list", GTK_WIDGET (box), NULL, 0);
     }
 }
 
diff --git a/libide/preferences/ide-preferences-container-private.h 
b/libide/preferences/ide-preferences-container-private.h
new file mode 100644
index 0000000..ef60b31
--- /dev/null
+++ b/libide/preferences/ide-preferences-container-private.h
@@ -0,0 +1,31 @@
+/* ide-preferences-container-private.h
+ *
+ * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_PREFERENCES_CONTAINER_PRIVATE_H
+#define IDE_PREFERENCES_CONTAINER_PRIVATE_H
+
+#include "ide-preferences-container.h"
+
+G_BEGIN_DECLS
+
+void _ide_preferences_container_set_map (IdePreferencesContainer *self,
+                                         GHashTable              *map);
+
+G_END_DECLS
+
+#endif /* IDE_PREFERENCES_CONTAINER_PRIVATE_H */
diff --git a/libide/preferences/ide-preferences-container.c b/libide/preferences/ide-preferences-container.c
index b2259f7..67d5a88 100644
--- a/libide/preferences/ide-preferences-container.c
+++ b/libide/preferences/ide-preferences-container.c
@@ -20,9 +20,15 @@
 
 typedef struct
 {
-  GtkBin parent_instance;
-  gint   priority;
-  gchar *keywords;
+  GtkBin      parent_instance;
+
+  gint        priority;
+
+  gchar      *keywords;
+  gchar      *schema_id;
+  gchar      *path;
+  GSettings  *settings;
+  GHashTable *map;
 } IdePreferencesContainerPrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (IdePreferencesContainer, ide_preferences_container, GTK_TYPE_BIN)
@@ -31,10 +37,13 @@ enum {
   PROP_0,
   PROP_KEYWORDS,
   PROP_PRIORITY,
+  PROP_SCHEMA_ID,
+  PROP_PATH,
   LAST_PROP
 };
 
 static GParamSpec *properties [LAST_PROP];
+static GHashTable *settings_cache;
 
 static void
 ide_preferences_container_finalize (GObject *object)
@@ -42,7 +51,11 @@ ide_preferences_container_finalize (GObject *object)
   IdePreferencesContainer *self = (IdePreferencesContainer *)object;
   IdePreferencesContainerPrivate *priv = ide_preferences_container_get_instance_private (self);
 
+  g_clear_pointer (&priv->schema_id, g_free);
+  g_clear_pointer (&priv->path, g_free);
   g_clear_pointer (&priv->keywords, g_free);
+  g_clear_pointer (&priv->map, g_hash_table_unref);
+  g_clear_object (&priv->settings);
 
   G_OBJECT_CLASS (ide_preferences_container_parent_class)->finalize (object);
 }
@@ -58,6 +71,14 @@ ide_preferences_container_get_property (GObject    *object,
 
   switch (prop_id)
     {
+    case PROP_SCHEMA_ID:
+      g_value_set_string (value, priv->schema_id);
+      break;
+
+    case PROP_PATH:
+      g_value_set_string (value, priv->path);
+      break;
+
     case PROP_KEYWORDS:
       g_value_set_string (value, priv->keywords);
       break;
@@ -82,6 +103,14 @@ ide_preferences_container_set_property (GObject      *object,
 
   switch (prop_id)
     {
+    case PROP_SCHEMA_ID:
+      priv->schema_id = g_value_dup_string (value);
+      break;
+
+    case PROP_PATH:
+      priv->path = g_value_dup_string (value);
+      break;
+
     case PROP_KEYWORDS:
       priv->keywords = g_value_dup_string (value);
       break;
@@ -111,6 +140,13 @@ ide_preferences_container_class_init (IdePreferencesContainerClass *klass)
                          NULL,
                          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
+  properties [PROP_PATH] =
+    g_param_spec_string ("path",
+                         "Path",
+                         "Path",
+                         NULL,
+                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
   properties [PROP_PRIORITY] =
     g_param_spec_int ("priority",
                       "Priority",
@@ -120,10 +156,154 @@ ide_preferences_container_class_init (IdePreferencesContainerClass *klass)
                       0,
                       (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
+  properties [PROP_SCHEMA_ID] =
+    g_param_spec_string ("schema-id",
+                         "Schema Id",
+                         "Schema Id",
+                         NULL,
+                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
   g_object_class_install_properties (object_class, LAST_PROP, properties);
+
+  settings_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 }
 
 static void
 ide_preferences_container_init (IdePreferencesContainer *self)
 {
 }
+
+static gchar *
+ide_preferences_container_expand (IdePreferencesContainer *self,
+                                  const gchar             *spec)
+{
+  IdePreferencesContainerPrivate *priv = ide_preferences_container_get_instance_private (self);
+  GHashTableIter iter;
+  const gchar *key;
+  const gchar *value;
+  gchar *expanded;
+
+  g_assert (IDE_IS_PREFERENCES_CONTAINER (self));
+
+  if (spec == NULL)
+    return NULL;
+
+  expanded = g_strdup (spec);
+
+  if (priv->map == NULL)
+    return expanded;
+
+  g_hash_table_iter_init (&iter, priv->map);
+
+  while (g_hash_table_iter_next (&iter, (gpointer *)&key, (gpointer *)&value))
+    {
+      gchar *tmp = expanded;
+      gchar **split;
+
+      split = g_strsplit (tmp, key, 0);
+      expanded = g_strjoinv (value, split);
+
+      g_strfreev (split);
+      g_free (tmp);
+    }
+
+  return expanded;
+}
+
+static void
+ide_preferences_container_evict_settings (gpointer  data,
+                                          GObject  *where_object_was)
+{
+  g_assert (data != NULL);
+  g_assert (where_object_was != NULL);
+
+  g_hash_table_remove (settings_cache, (gchar *)data);
+}
+
+static void
+ide_preferences_container_cache_settings (const gchar *hash_key,
+                                          GSettings   *settings)
+{
+  gchar *key;
+
+  g_assert (hash_key != NULL);
+  g_assert (G_IS_SETTINGS (settings));
+
+  key = g_strdup (hash_key);
+  g_hash_table_insert (settings_cache, key, settings);
+  g_object_weak_ref (G_OBJECT (settings), ide_preferences_container_evict_settings, key);
+}
+
+/**
+ * ide_preferences_container_get_settings:
+ *
+ * Returns: (nullable) (transfer full): A #GSettings
+ */
+GSettings *
+ide_preferences_container_get_settings (IdePreferencesContainer *self)
+{
+  IdePreferencesContainerPrivate *priv = ide_preferences_container_get_instance_private (self);
+
+  g_return_val_if_fail (IDE_IS_PREFERENCES_CONTAINER (self), NULL);
+
+  if (priv->settings == NULL)
+    {
+      gchar *resolved_schema_id;
+      gchar *resolved_path;
+      gchar *hash_key;
+
+      if (priv->schema_id == NULL)
+        return NULL;
+
+      resolved_schema_id = ide_preferences_container_expand (self, priv->schema_id);
+      resolved_path = ide_preferences_container_expand (self, priv->path);
+      hash_key = g_strdup_printf ("%s|%s",
+                                  resolved_schema_id ?: "",
+                                  resolved_path ?: "");
+
+      if (!g_hash_table_contains (settings_cache, hash_key))
+        {
+          GSettingsSchemaSource *source;
+          GSettingsSchema *schema;
+
+          source = g_settings_schema_source_get_default ();
+          schema = g_settings_schema_source_lookup (source, resolved_schema_id, TRUE);
+
+          if (schema != NULL)
+            {
+              if (resolved_path)
+                priv->settings = g_settings_new_with_path (resolved_schema_id, resolved_path);
+              else
+                priv->settings = g_settings_new (resolved_schema_id);
+              ide_preferences_container_cache_settings (hash_key, priv->settings);
+            }
+
+          g_clear_pointer (&schema, g_settings_schema_unref);
+        }
+      else
+        {
+          priv->settings = g_object_ref (g_hash_table_lookup (settings_cache, hash_key));
+        }
+
+      g_clear_pointer (&hash_key, g_free);
+      g_clear_pointer (&resolved_schema_id, g_free);
+      g_clear_pointer (&resolved_path, g_free);
+    }
+
+  return (priv->settings != NULL) ? g_object_ref (priv->settings) : NULL;
+}
+
+void
+_ide_preferences_container_set_map (IdePreferencesContainer *self,
+                                    GHashTable              *map)
+{
+  IdePreferencesContainerPrivate *priv = ide_preferences_container_get_instance_private (self);
+
+  g_return_if_fail (IDE_IS_PREFERENCES_CONTAINER (self));
+
+  if (map != priv->map)
+    {
+      g_clear_pointer (&priv->map, g_hash_table_unref);
+      priv->map = map ? g_hash_table_ref (map) : NULL;
+    }
+}
diff --git a/libide/preferences/ide-preferences-container.h b/libide/preferences/ide-preferences-container.h
index c5b2cad..818d1f7 100644
--- a/libide/preferences/ide-preferences-container.h
+++ b/libide/preferences/ide-preferences-container.h
@@ -32,6 +32,8 @@ struct _IdePreferencesContainerClass
   GtkBinClass parent_class;
 };
 
+GSettings *ide_preferences_container_get_settings (IdePreferencesContainer *self);
+
 G_END_DECLS
 
 #endif /* IDE_PREFERENCES_CONTAINER_H */
diff --git a/libide/preferences/ide-preferences-font-button.c 
b/libide/preferences/ide-preferences-font-button.c
index dbf90d3..7e9470d 100644
--- a/libide/preferences/ide-preferences-font-button.c
+++ b/libide/preferences/ide-preferences-font-button.c
@@ -23,7 +23,6 @@ struct _IdePreferencesFontButton
   GtkBin                parent_instance;
 
   GSettings            *settings;
-  gchar                *schema_id;
   gchar                *key;
 
   GtkLabel             *title;
@@ -39,7 +38,6 @@ G_DEFINE_TYPE (IdePreferencesFontButton, ide_preferences_font_button, IDE_TYPE_P
 enum {
   PROP_0,
   PROP_KEY,
-  PROP_SCHEMA_ID,
   PROP_TITLE,
   LAST_PROP
 };
@@ -108,22 +106,18 @@ static void
 ide_preferences_font_button_constructed (GObject *object)
 {
   IdePreferencesFontButton *self = (IdePreferencesFontButton *)object;
-  GSettingsSchemaSource *source;
-  g_autoptr(GSettingsSchema) schema = NULL;
   g_autofree gchar *signal_detail = NULL;
 
   g_assert (IDE_IS_PREFERENCES_FONT_BUTTON (self));
 
-  source = g_settings_schema_source_get_default ();
-  schema = g_settings_schema_source_lookup (source, self->schema_id, TRUE);
+  self->settings = ide_preferences_container_get_settings (IDE_PREFERENCES_CONTAINER (self));
 
-  if (schema == NULL || !g_settings_schema_has_key (schema, self->key))
+  if (self->settings == NULL)
     {
-      gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
+      g_warning ("Failed to load settings for font button.");
       goto chainup;
     }
 
-  self->settings = g_settings_new (self->schema_id);
   signal_detail = g_strdup_printf ("changed::%s", self->key);
 
   g_signal_connect_object (self->settings,
@@ -144,7 +138,6 @@ ide_preferences_font_button_finalize (GObject *object)
   IdePreferencesFontButton *self = (IdePreferencesFontButton *)object;
 
   g_clear_object (&self->settings);
-  g_clear_pointer (&self->schema_id, g_free);
   g_clear_pointer (&self->key, g_free);
 
   G_OBJECT_CLASS (ide_preferences_font_button_parent_class)->finalize (object);
@@ -164,10 +157,6 @@ ide_preferences_font_button_get_property (GObject    *object,
       g_value_set_string (value, self->key);
       break;
 
-    case PROP_SCHEMA_ID:
-      g_value_set_string (value, self->schema_id);
-      break;
-
     case PROP_TITLE:
       g_value_set_string (value, gtk_label_get_label (self->title));
       break;
@@ -191,10 +180,6 @@ ide_preferences_font_button_set_property (GObject      *object,
       self->key = g_value_dup_string (value);
       break;
 
-    case PROP_SCHEMA_ID:
-      self->schema_id = g_value_dup_string (value);
-      break;
-
     case PROP_TITLE:
       gtk_label_set_label (self->title, g_value_get_string (value));
       break;
@@ -231,13 +216,6 @@ ide_preferences_font_button_class_init (IdePreferencesFontButtonClass *klass)
                          NULL,
                          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
-  properties [PROP_SCHEMA_ID] =
-    g_param_spec_string ("schema-id",
-                         "Schema Id",
-                         "Schema Id",
-                         NULL,
-                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
-
   properties [PROP_TITLE] =
     g_param_spec_string ("title",
                          "Title",
diff --git a/libide/preferences/ide-preferences-spin-button.c 
b/libide/preferences/ide-preferences-spin-button.c
index 02267de..e67af50 100644
--- a/libide/preferences/ide-preferences-spin-button.c
+++ b/libide/preferences/ide-preferences-spin-button.c
@@ -26,8 +26,6 @@ struct _IdePreferencesSpinButton
   guint                    updating : 1;
 
   gchar                   *key;
-  gchar                   *path;
-  gchar                   *schema_id;
   GSettings               *settings;
 
   const GVariantType      *type;
@@ -42,8 +40,6 @@ G_DEFINE_TYPE (IdePreferencesSpinButton, ide_preferences_spin_button, IDE_TYPE_P
 enum {
   PROP_0,
   PROP_KEY,
-  PROP_PATH,
-  PROP_SCHEMA_ID,
   PROP_SUBTITLE,
   PROP_TITLE,
   LAST_PROP
@@ -170,7 +166,6 @@ static void
 ide_preferences_spin_button_constructed (GObject *object)
 {
   IdePreferencesSpinButton *self = (IdePreferencesSpinButton *)object;
-  GSettingsSchemaSource *source;
   GSettingsSchema *schema = NULL;
   GSettingsSchemaKey *key = NULL;
   GVariant *range = NULL;
@@ -184,15 +179,16 @@ ide_preferences_spin_button_constructed (GObject *object)
 
   g_assert (IDE_IS_PREFERENCES_SPIN_BUTTON (self));
 
-  source = g_settings_schema_source_get_default ();
-  schema = g_settings_schema_source_lookup (source, self->schema_id, TRUE);
+  self->settings = ide_preferences_container_get_settings (IDE_PREFERENCES_CONTAINER (self));
 
-  if (schema == NULL || !g_settings_schema_has_key (schema, self->key))
+  if (self->settings == NULL)
     {
-      gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
+      g_warning ("Failed to load settings for spin button");
       goto chainup;
     }
 
+  g_object_get (self->settings, "settings-schema", &schema, NULL);
+
   adj = gtk_spin_button_get_adjustment (self->spin_button);
   key = g_settings_schema_get_key (schema, self->key);
   range = g_settings_schema_key_get_range (key);
@@ -213,11 +209,6 @@ ide_preferences_spin_button_constructed (GObject *object)
   apply_value (adj, lower, "lower");
   apply_value (adj, upper, "upper");
 
-  if (self->path != NULL)
-    self->settings = g_settings_new_with_path (self->schema_id, self->path);
-  else
-    self->settings = g_settings_new (self->schema_id);
-
   signal_detail = g_strdup_printf ("changed::%s", self->key);
 
   g_signal_connect_object (self->settings,
@@ -253,8 +244,6 @@ ide_preferences_spin_button_finalize (GObject *object)
   IdePreferencesSpinButton *self = (IdePreferencesSpinButton *)object;
 
   g_clear_pointer (&self->key, g_free);
-  g_clear_pointer (&self->path, g_free);
-  g_clear_pointer (&self->schema_id, g_free);
   g_clear_object (&self->settings);
 
   G_OBJECT_CLASS (ide_preferences_spin_button_parent_class)->finalize (object);
@@ -274,14 +263,6 @@ ide_preferences_spin_button_get_property (GObject    *object,
       g_value_set_string (value, self->key);
       break;
 
-    case PROP_PATH:
-      g_value_set_string (value, self->path);
-      break;
-
-    case PROP_SCHEMA_ID:
-      g_value_set_string (value, self->schema_id);
-      break;
-
     case PROP_SUBTITLE:
       g_value_set_string (value, gtk_label_get_label (self->subtitle));
       break;
@@ -309,14 +290,6 @@ ide_preferences_spin_button_set_property (GObject      *object,
       self->key = g_value_dup_string (value);
       break;
 
-    case PROP_PATH:
-      self->path = g_value_dup_string (value);
-      break;
-
-    case PROP_SCHEMA_ID:
-      self->schema_id = g_value_dup_string (value);
-      break;
-
     case PROP_SUBTITLE:
       gtk_label_set_label (self->subtitle, g_value_get_string (value));
       break;
@@ -362,20 +335,6 @@ ide_preferences_spin_button_class_init (IdePreferencesSpinButtonClass *klass)
                          NULL,
                          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
-  properties [PROP_SCHEMA_ID] =
-    g_param_spec_string ("schema-id",
-                         "schema-id",
-                         "schema-id",
-                         NULL,
-                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
-
-  properties [PROP_PATH] =
-    g_param_spec_string ("path",
-                         "path",
-                         "path",
-                         NULL,
-                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
-
   properties [PROP_SUBTITLE] =
     g_param_spec_string ("subtitle",
                          "subtitle",
diff --git a/libide/preferences/ide-preferences-switch.c b/libide/preferences/ide-preferences-switch.c
index 8ed248a..7ddeaa6 100644
--- a/libide/preferences/ide-preferences-switch.c
+++ b/libide/preferences/ide-preferences-switch.c
@@ -27,10 +27,8 @@ struct _IdePreferencesSwitch
   guint     updating : 1;
 
   gchar     *key;
-  gchar     *schema_id;
-  gchar     *path;
-  GSettings *settings;
   GVariant  *target;
+  GSettings *settings;
 
   GtkLabel  *subtitle;
   GtkLabel  *title;
@@ -44,8 +42,6 @@ enum {
   PROP_0,
   PROP_IS_RADIO,
   PROP_KEY,
-  PROP_PATH,
-  PROP_SCHEMA_ID,
   PROP_SUBTITLE,
   PROP_TARGET,
   PROP_TITLE,
@@ -112,26 +108,18 @@ static void
 ide_preferences_switch_constructed (GObject *object)
 {
   IdePreferencesSwitch *self = (IdePreferencesSwitch *)object;
-  GSettingsSchemaSource *source;
-  g_autoptr(GSettingsSchema) schema = NULL;
   g_autofree gchar *signal_detail = NULL;
 
   g_assert (IDE_IS_PREFERENCES_SWITCH (self));
 
-  source = g_settings_schema_source_get_default ();
-  schema = g_settings_schema_source_lookup (source, self->schema_id, TRUE);
+  self->settings = ide_preferences_container_get_settings (IDE_PREFERENCES_CONTAINER (self));
 
-  if (schema == NULL || !g_settings_schema_has_key (schema, self->key))
+  if (self->settings == NULL)
     {
-      gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
+      g_warning ("Failed to load settings for switch");
       goto chainup;
     }
 
-  if (self->path != NULL)
-    self->settings = g_settings_new_with_path (self->schema_id, self->path);
-  else
-    self->settings = g_settings_new (self->schema_id);
-
   signal_detail = g_strdup_printf ("changed::%s", self->key);
 
   g_signal_connect_object (self->settings,
@@ -253,8 +241,6 @@ ide_preferences_switch_finalize (GObject *object)
   IdePreferencesSwitch *self = (IdePreferencesSwitch *)object;
 
   g_clear_pointer (&self->key, g_free);
-  g_clear_pointer (&self->schema_id, g_free);
-  g_clear_pointer (&self->path, g_free);
   g_clear_pointer (&self->target, g_variant_unref);
   g_clear_object (&self->settings);
 
@@ -275,18 +261,10 @@ ide_preferences_switch_get_property (GObject    *object,
       g_value_set_boolean (value, self->is_radio);
       break;
 
-    case PROP_SCHEMA_ID:
-      g_value_set_string (value, self->schema_id);
-      break;
-
     case PROP_KEY:
       g_value_set_string (value, self->key);
       break;
 
-    case PROP_PATH:
-      g_value_set_string (value, self->path);
-      break;
-
     case PROP_TARGET:
       g_value_set_variant (value, self->target);
       break;
@@ -320,18 +298,10 @@ ide_preferences_switch_set_property (GObject      *object,
       gtk_widget_set_visible (GTK_WIDGET (self->image), self->is_radio);
       break;
 
-    case PROP_SCHEMA_ID:
-      self->schema_id = g_value_dup_string (value);
-      break;
-
     case PROP_KEY:
       self->key = g_value_dup_string (value);
       break;
 
-    case PROP_PATH:
-      self->path = g_value_dup_string (value);
-      break;
-
     case PROP_TARGET:
       self->target = g_value_dup_variant (value);
       break;
@@ -379,12 +349,6 @@ ide_preferences_switch_class_init (IdePreferencesSwitchClass *klass)
                          FALSE,
                          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
-  properties [PROP_SCHEMA_ID] =
-    g_param_spec_string ("schema-id",
-                         "Schema Id",
-                         "Schema Id",
-                         NULL,
-                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
   properties [PROP_TARGET] =
     g_param_spec_variant ("target",
@@ -401,13 +365,6 @@ ide_preferences_switch_class_init (IdePreferencesSwitchClass *klass)
                          NULL,
                          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
-  properties [PROP_PATH] =
-    g_param_spec_string ("path",
-                         "Path",
-                         "Path",
-                         NULL,
-                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
-
   properties [PROP_TITLE] =
     g_param_spec_string ("title",
                          "Title",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]