mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add preferences support for a GtkFontButton widget.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15752 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
191e977fd1
commit
2c8690b5d8
@ -555,6 +555,92 @@ gnc_prefs_sort_pages (GtkNotebook *notebook)
|
||||
/*******************************/
|
||||
|
||||
|
||||
/** 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 @@ gnc_prefs_connect_one (const gchar *name,
|
||||
} 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 @@ gnc_preferences_gconf_changed (GConfClient *client,
|
||||
} 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));
|
||||
|
Loading…
Reference in New Issue
Block a user