r23221 - gnucash/trunk/src/app-utils - GSettings: add function to bind a gsettings key to a gobject property

Geert Janssens gjanssens at code.gnucash.org
Mon Oct 7 10:06:03 EDT 2013


Author: gjanssens
Date: 2013-10-07 10:06:02 -0400 (Mon, 07 Oct 2013)
New Revision: 23221
Trac: http://svn.gnucash.org/trac/changeset/23221

Modified:
   gnucash/trunk/src/app-utils/gnc-gsettings.c
   gnucash/trunk/src/app-utils/gnc-gsettings.h
Log:
GSettings: add function to bind a gsettings key to a gobject property

Modified: gnucash/trunk/src/app-utils/gnc-gsettings.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gsettings.c	2013-10-07 14:05:14 UTC (rev 23220)
+++ gnucash/trunk/src/app-utils/gnc-gsettings.c	2013-10-07 14:06:02 UTC (rev 23221)
@@ -222,6 +222,22 @@
 }
 
 
+void gnc_gsettings_bind (const gchar *schema,
+                         /*@ null @*/ const gchar *key,
+                         gpointer object,
+                         const gchar *property)
+{
+    GSettings *schema_ptr = gnc_gsettings_get_schema_ptr (schema);
+    g_return_if_fail (G_IS_SETTINGS (schema_ptr));
+
+    if (gnc_gsettings_is_valid_key (schema_ptr, key))
+        g_settings_bind (schema_ptr, key, object, property, 0);
+    else
+    {
+        PERR ("Invalid key %s for schema %s", key, schema);
+    }
+}
+
 /************************************************************/
 /*                      Getters/Setters                     */
 /************************************************************/

Modified: gnucash/trunk/src/app-utils/gnc-gsettings.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-gsettings.h	2013-10-07 14:05:14 UTC (rev 23220)
+++ gnucash/trunk/src/app-utils/gnc-gsettings.h	2013-10-07 14:06:02 UTC (rev 23221)
@@ -221,6 +221,30 @@
                                           gpointer user_data);
 
 
+/** Bind a setting to a g_object property. When this succeeds a change
+ *  of the setting will automatically update the bound object property
+ *  and vice versa.
+ *
+ *  @param schema This string provides a grouping of keys within the
+ *  GnuCash schema of the gsettings database.  It can be a simple string
+ *  as in "history" for settings that are common to many areas of
+ *  gnucash, or it can be a partial path name as in
+ *  "dialogs.business.invoice" for setting that only apply to one
+ *  specific area of the program.
+ *
+ *  @param key This string is the name of the particular key within
+ *  the named schema of gsettings.
+ *
+ *  @param object The object to be bound.
+ *
+ *  @param property The property of the object to bind to.
+ */
+void gnc_gsettings_bind (const gchar *schema,
+                         /*@ null @*/ const gchar *key,
+                         gpointer object,
+                         const gchar *property);
+
+
 /** @name GSettings Get Functions
  @{
 */



More information about the gnucash-changes mailing list