r23251 - gnucash/trunk/src - Gnc-Prefs: migrate GncDateEdit widgets (and associated preferences)
Geert Janssens
gjanssens at code.gnucash.org
Mon Oct 7 10:19:29 EDT 2013
Author: gjanssens
Date: 2013-10-07 10:19:29 -0400 (Mon, 07 Oct 2013)
New Revision: 23251
Trac: http://svn.gnucash.org/trac/changeset/23251
Modified:
gnucash/trunk/src/app-utils/gnc-accounting-period.c
gnucash/trunk/src/gnome-utils/dialog-preferences.c
gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade
gnucash/trunk/src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in
Log:
Gnc-Prefs: migrate GncDateEdit widgets (and associated preferences)
All GncDateEdits now use the new preferences backend
so drop the GncDateEdit-Gconf wiring as well.
Modified: gnucash/trunk/src/app-utils/gnc-accounting-period.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-accounting-period.c 2013-10-07 14:18:49 UTC (rev 23250)
+++ gnucash/trunk/src/app-utils/gnc-accounting-period.c 2013-10-07 14:19:29 UTC (rev 23251)
@@ -78,7 +78,9 @@
if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_START_CHOICE_ABS))
{
- time = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_START_DATE);
+ GVariant *var = gnc_prefs_get_value(GNC_PREFS_GROUP, GNC_PREF_START_DATE);
+ time = g_variant_get_int64 (var);
+ g_variant_unref (var);
}
else
{
@@ -100,8 +102,10 @@
if (gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_END_CHOICE_ABS))
{
- time = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_END_DATE);
+ GVariant *var = gnc_prefs_get_value(GNC_PREFS_GROUP, GNC_PREF_END_DATE);
+ time = g_variant_get_int64 (var);
time = gnc_time64_get_day_end(time);
+ g_variant_unref (var);
}
else
{
Modified: gnucash/trunk/src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in
===================================================================
--- gnucash/trunk/src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in 2013-10-07 14:18:49 UTC (rev 23250)
+++ gnucash/trunk/src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in 2013-10-07 14:19:29 UTC (rev 23251)
@@ -20,7 +20,7 @@
<summary>Use absolute profit/loss starting date</summary>
<description>This setting controls the type of starting date used in profit/loss calculations. If set to "absolute" then GnuCash will retrieve the starting date specified by the start_date key. If set to anything else, GnuCash will retrieve the starting date specified by the start_period key.</description>
</key>
- <key name="start_date" type="i">
+ <key name="start_date" type="x">
<default>0</default>
<summary>Starting date (in seconds from Jan 1, 1970)</summary>
<description>This setting controls the starting date set in profit/loss calculations if the start_choice setting is set to "absolute". This field should contain a date as represented in seconds from January 1st, 1970.</description>
@@ -40,7 +40,7 @@
<summary>Use absolute profit/loss ending date</summary>
<description>This setting controls the type of ending date used in profit/loss calculations. If set to "absolute" then GnuCash will retrieve the ending date specified by the end_date key. If set to anything else, GnuCash will retrieve the ending date specified by the end_period key.</description>
</key>
- <key name="end_date" type="i">
+ <key name="end_date" type="x">
<default>0</default>
<summary>Ending date (in seconds from Jan 1, 1970)</summary>
<description>This setting controls the ending date set in profit/loss calculations if the end_choice setting is set to "absolute". This field should contain a date as represented in seconds from January 1st, 1970.</description>
Modified: gnucash/trunk/src/gnome-utils/dialog-preferences.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-preferences.c 2013-10-07 14:18:49 UTC (rev 23250)
+++ gnucash/trunk/src/gnome-utils/dialog-preferences.c 2013-10-07 14:19:29 UTC (rev 23251)
@@ -676,97 +676,8 @@
g_strfreev (splits);
}
-/* FIXME to remove when gconf conversion of preferences is complete */
/****************************************************************************/
-/** The user changed a date_edit. Update gconf. Date_edit
- * choices are stored as an int.
- *
- * @internal
- *
- * @param gde A pointer to the date_edit that was changed.
- *
- * @param user_data Unused.
- */
-static void
-gnc_prefs_date_edit_user_cb_gconf (GNCDateEdit *gde,
- gpointer user_data)
-{
- const gchar *name;
- time64 time;
-
- g_return_if_fail(GNC_IS_DATE_EDIT(gde));
- name = g_object_get_data(G_OBJECT(gde), "name");
- time = gnc_date_edit_get_date(gde);
-
- DEBUG("date_edit %s set", name);
- gnc_gconf_set_int(name, NULL, time, NULL);
-}
-
-
-/** A date_edit choice was updated in gconf. Update the user
- * visible dialog.
- *
- * @internal
- *
- * @param gde A pointer to the date_edit that changed.
- *
- * @param value The new value of the date_edit.
- */
-static void
-gnc_prefs_date_edit_gconf_cb_gconf (GNCDateEdit *gde,
- GConfEntry *entry)
-{
- time64 time;
-
- g_return_if_fail(GNC_IS_DATE_EDIT(gde));
- ENTER("date_edit %p, entry %p", gde, entry);
-
- time = gconf_value_get_int(entry->value);
-
- g_signal_handlers_block_by_func(G_OBJECT(gde),
- G_CALLBACK(gnc_prefs_date_edit_user_cb_gconf), NULL);
- gnc_date_edit_set_time(GNC_DATE_EDIT(gde), time);
- g_signal_handlers_unblock_by_func(G_OBJECT(gde),
- G_CALLBACK(gnc_prefs_date_edit_user_cb_gconf), NULL);
- LEAVE(" ");
-}
-
-
-/** Connect a date_edit widget to the user callback function. Set
- * the starting state of the gde from its value in gconf.
- *
- * @internal
- *
- * @param gde A pointer to the date_edit that should be connected.
- */
-static void
-gnc_prefs_connect_date_edit_gconf (GNCDateEdit *gde , const gchar *boxname )
-{
- const gchar *name;
- time64 time;
-
- g_return_if_fail(GNC_IS_DATE_EDIT(gde));
-
- /* Lookup the date based upon gconf setting */
- name = boxname + PREFIX_LEN;
-
- g_object_set_data(G_OBJECT(gde), "name", g_strdup(name) );
-
- time = gnc_gconf_get_int(name, NULL, NULL);
-
- gnc_date_edit_set_time(GNC_DATE_EDIT(gde), time);
- DEBUG(" date_edit %s set", name);
-
- g_signal_connect(G_OBJECT(gde), "date_changed",
- G_CALLBACK(gnc_prefs_date_edit_user_cb_gconf), NULL);
-
- gtk_widget_show_all(GTK_WIDGET(gde));
-}
-/* FIXME end of section to remove */
-
-/****************************************************************************/
-
/** Connect a GtkFontButton widget to its stored value in the preferences database.
*
* @internal
@@ -985,8 +896,31 @@
g_free (pref);
}
+/****************************************************************************/
+/** Connect a GncDateEdit widget to its stored value in the preferences database.
+ *
+ * @internal
+ *
+ * @param gde A pointer to the date_edit that should be connected.
+ */
+static void
+gnc_prefs_connect_date_edit (GNCDateEdit *gde , const gchar *boxname )
+{
+ gchar *group, *pref;
+ gchar *mnemonic;
+ g_return_if_fail(GNC_IS_DATE_EDIT(gde));
+
+ gnc_prefs_split_widget_name (boxname, &group, &pref);
+
+ gnc_prefs_bind (group, pref, G_OBJECT (gde), "time");
+
+ g_free (group);
+ g_free (pref);
+}
+
+
/****************************************************************************/
/********************/
@@ -1050,28 +984,6 @@
{
/* These tests must be ordered from more specific widget to less
* specific widget. */
-
- if (GTK_IS_HBOX(widget))
- {
- /* Test custom widgets are all children of a hbox */
- GtkWidget *widget_child;
- GList* child = gtk_container_get_children(GTK_CONTAINER(widget));
- widget_child = child->data;
- g_list_free(child);
- DEBUG(" %s - hbox", name);
- DEBUG("Hbox widget type is %s and name is %s", gtk_widget_get_name(GTK_WIDGET(widget_child)), name);
-
- if (GNC_IS_DATE_EDIT(widget_child))
- {
- DEBUG(" %s - date_edit", name);
- gnc_prefs_connect_date_edit_gconf(GNC_DATE_EDIT(widget_child), name );
- }
- }
- else
- {
- DEBUG(" %s - unsupported %s", name,
- G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
- }
}
/* FIXME end of section to be removed */
@@ -1144,6 +1056,11 @@
DEBUG(" %s - period_Select", name);
gnc_prefs_connect_period_select(GNC_PERIOD_SELECT(widget_child), name );
}
+ else if (GNC_IS_DATE_EDIT(widget_child))
+ {
+ DEBUG(" %s - date_edit", name);
+ gnc_prefs_connect_date_edit(GNC_DATE_EDIT(widget_child), name );
+ }
}
else
{
@@ -1247,12 +1164,12 @@
if (date_is_valid)
gnc_period_select_set_fy_end(GNC_PERIOD_SELECT (period), &fy_end);
- box = GTK_WIDGET(gtk_builder_get_object (builder, "gconf/window/pages/account_tree/summary/start_date"));
+ box = GTK_WIDGET(gtk_builder_get_object (builder, "pref/window.pages.account_tree.summary/start_date"));
date = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
gtk_widget_show (date);
gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);
- box = GTK_WIDGET(gtk_builder_get_object (builder, "gconf/window/pages/account_tree/summary/end_date"));
+ box = GTK_WIDGET(gtk_builder_get_object (builder, "pref/window.pages.account_tree.summary/end_date"));
date = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
gtk_widget_show (date);
gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);
@@ -1417,29 +1334,6 @@
{
/* These tests must be ordered from more specific widget to less
* specific widget. */
-
- if (GTK_IS_HBOX(widget))
- {
- /* Test custom widgets are all children of a hbox */
- GtkWidget *widget_child;
- GList* child = gtk_container_get_children(GTK_CONTAINER(widget));
- widget_child = child->data;
- g_list_free(child);
-
- DEBUG(" %s - hbox", name);
- DEBUG("Hbox gconf name is %s and widget get name is %s", name, gtk_widget_get_name(GTK_WIDGET(widget_child)));
-
- if (GNC_IS_DATE_EDIT(widget_child))
- {
- DEBUG("widget %p - date_edit", widget_child);
- gnc_prefs_date_edit_gconf_cb_gconf(GNC_DATE_EDIT(widget_child), entry);
- }
- }
- else
- {
- DEBUG("widget %p - unsupported %s", widget,
- G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
- }
}
g_free(name);
LEAVE(" ");
Modified: gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade
===================================================================
--- gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade 2013-10-07 14:18:49 UTC (rev 23250)
+++ gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade 2013-10-07 14:19:29 UTC (rev 23251)
@@ -352,7 +352,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="gconf/window/pages/account_tree/summary/start_date">
+ <object class="GtkHBox" id="pref/window.pages.account_tree.summary/start_date">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@@ -386,7 +386,7 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="gconf/window/pages/account_tree/summary/end_date">
+ <object class="GtkHBox" id="pref/window.pages.account_tree.summary/end_date">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
More information about the gnucash-changes
mailing list