# HG changeset patch # User Tim Ringenbach # Date 1088496626 0 # Node ID d4e3356e7bbca182e5222b28e8b466bd60ccb562 # Parent da603f6c5482e2d86343a2d46d960ef85e5d0029 [gaim-migrate @ 10240] [03:07] commit message? [03:07] 'Thought others mind find this useful' i guess.. committer: Tailor Script diff -r da603f6c5482 -r d4e3356e7bbc src/gtkprefs.c --- a/src/gtkprefs.c Mon Jun 28 21:20:36 2004 +0000 +++ b/src/gtkprefs.c Tue Jun 29 08:10:26 2004 +0000 @@ -153,6 +153,50 @@ } static void +entry_set(GtkEntry *entry, gpointer data) { + char *key = (char*)data; + + gaim_prefs_set_string(key, gtk_entry_get_text(entry)); +} + +GtkWidget * +gaim_gtk_prefs_labeled_entry(GtkWidget *page, const gchar *title, char *key, + GtkSizeGroup *sg) +{ + GtkWidget *hbox, *label, *entry; + const gchar *value; + + value = gaim_prefs_get_string(key); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(page), hbox, FALSE, FALSE, 5); + gtk_widget_show(hbox); + + label = gtk_label_new_with_mnemonic(title); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + entry = gtk_entry_new(); + gtk_entry_set_text(GTK_ENTRY(entry), value); + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(entry), "changed", + G_CALLBACK(entry_set), (char*)key); + gtk_widget_show(entry); + + gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); + + if(sg) { + gtk_size_group_add_widget(sg, label); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + } + + gaim_set_accessible_label(entry, label); + + return hbox; +} + +static void dropdown_set(GObject *w, const char *key) { const char *str_value; diff -r da603f6c5482 -r d4e3356e7bbc src/gtkprefs.h --- a/src/gtkprefs.h Mon Jun 28 21:20:36 2004 +0000 +++ b/src/gtkprefs.h Tue Jun 29 08:10:26 2004 +0000 @@ -81,6 +81,21 @@ const gchar *title, char *key, int min, int max, GtkSizeGroup *sg); /** + * Add a new entry representing a string preference + * + * @param page The page to which the entry will be added + * @param title The text to be displayed as the entry label + * @param key The key of the string pref that will be represented by the entry + * @param sg If not NULL, the size group to which the entry will be added + * + * @return An hbox containing both the label and the entry. Can be used to set + * the widgets to sensitive or insensitive based on the value of a + * checkbox. + */ +GtkWidget *gaim_gtk_prefs_labeled_entry(GtkWidget *page, const gchar *title, + char *key, GtkSizeGroup *sg); + +/** * Add a new dropdown representing a preference of the specified type * * @param page The page to which the dropdown will be added