r15752 - gnucash/trunk/src/gnome-utils - Add preferences support for a GtkFontButton widget.
David Hampton
hampton at cvs.gnucash.org
Sat Mar 24 14:14:09 EDT 2007
Author: hampton
Date: 2007-03-24 14:14:08 -0400 (Sat, 24 Mar 2007)
New Revision: 15752
Trac: http://svn.gnucash.org/trac/changeset/15752
Modified:
gnucash/trunk/src/gnome-utils/dialog-preferences.c
Log:
Add preferences support for a GtkFontButton widget.
Modified: gnucash/trunk/src/gnome-utils/dialog-preferences.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-preferences.c 2007-03-24 15:30:27 UTC (rev 15751)
+++ gnucash/trunk/src/gnome-utils/dialog-preferences.c 2007-03-24 18:14:08 UTC (rev 15752)
@@ -555,6 +555,92 @@
/*******************************/
+/** The user changed a GtkFontButton. Update gconf. Font selection
+ * choices are stored as a string.
+ *
+ * @internal
+ *
+ * @param gde A pointer to the GtkFontButton that was changed.
+ *
+ * @param user_data Unused.
+ */
+static void
+gnc_prefs_font_button_user_cb (GtkFontButton *fb,
+ gpointer user_data)
+{
+ const gchar *key, *font;
+ time_t time;
+
+ g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
+ key = gtk_widget_get_name(GTK_WIDGET(fb)) + PREFIX_LEN;
+ font = gtk_font_button_get_font_name(fb);
+
+ DEBUG("font_button %s set", key);
+ gnc_gconf_set_string(key, NULL, font, NULL);
+}
+
+
+/** A GtkFontButton choice was updated in gconf. Update the user
+ * visible dialog.
+ *
+ * @internal
+ *
+ * @param gde A pointer to the GtkFontButton that changed.
+ *
+ * @param value The new value of the GtkFontButton.
+ */
+static void
+gnc_prefs_font_button_gconf_cb (GtkFontButton *fb,
+ GConfEntry *entry)
+{
+ const gchar *font;
+
+ g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
+ ENTER("fb %p, entry %p", fb, entry);
+
+ font = gconf_value_get_string(entry->value);
+
+ g_signal_handlers_block_by_func(G_OBJECT(fb),
+ G_CALLBACK(gnc_prefs_font_button_user_cb),
+ NULL);
+ gtk_font_button_set_font_name(fb, font);
+ g_signal_handlers_unblock_by_func(G_OBJECT(fb),
+ G_CALLBACK(gnc_prefs_font_button_user_cb), NULL);
+ LEAVE(" ");
+}
+
+
+/** Connect a GtkFontButton widget to the user callback function. Set
+ * the font from its value in gconf.
+ *
+ * @internal
+ *
+ * @param gde A pointer to the date_edit that should be connected.
+ */
+static void
+gnc_prefs_connect_font_button (GtkFontButton *fb)
+{
+ const gchar *name, *font;
+
+ g_return_if_fail(GTK_IS_FONT_BUTTON(fb));
+
+ /* Lookup font name based upon gconf setting */
+ name = gtk_widget_get_name(GTK_WIDGET(fb)) + PREFIX_LEN;
+ font = gnc_gconf_get_string(name, NULL, NULL);
+
+ gtk_font_button_set_font_name(fb, font);
+ DEBUG(" font_button %s set", name);
+
+ g_signal_connect(G_OBJECT(fb), "font_set",
+ G_CALLBACK(gnc_prefs_font_button_user_cb), NULL);
+
+ gtk_widget_show_all(GTK_WIDGET(fb));
+}
+
+
+/**********/
+
+
/** The user clicked on a radio button. Update gconf. Radio button
* group choices are stored as a string. The last component of the
* widget name is the string that will be stored. I.E. The widget name
@@ -1305,6 +1391,9 @@
} else if (GNC_IS_DATE_EDIT(widget)) {
DEBUG(" %s - date_edit", name);
gnc_prefs_connect_date_edit(GNC_DATE_EDIT(widget));
+ } else if (GTK_IS_FONT_BUTTON(widget)) {
+ DEBUG(" %s - entry", name);
+ gnc_prefs_connect_font_button(GTK_FONT_BUTTON(widget));
} else if (GTK_IS_RADIO_BUTTON(widget)) {
DEBUG(" %s - radio button", name);
gnc_prefs_connect_radio_button(GTK_RADIO_BUTTON(widget));
@@ -1518,6 +1607,9 @@
} else if (GNC_IS_DATE_EDIT(widget)) {
DEBUG("widget %p - date_edit", widget);
gnc_prefs_date_edit_gconf_cb(GNC_DATE_EDIT(widget), entry);
+ } else if (GTK_IS_FONT_BUTTON(widget)) {
+ DEBUG("widget %p - font button", widget);
+ gnc_prefs_font_button_gconf_cb(GTK_FONT_BUTTON(widget), entry);
} else if (GTK_IS_RADIO_BUTTON(widget)) {
DEBUG("widget %p - radio button", widget);
gnc_prefs_radio_button_gconf_cb(GTK_RADIO_BUTTON(widget));
More information about the gnucash-changes
mailing list