aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/dlg_utils.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2007-01-20 02:05:49 +0000
committerGerald Combs <gerald@wireshark.org>2007-01-20 02:05:49 +0000
commit1e6ce19f799b3c4e71f5fe365d282f0dc9e9c6eb (patch)
tree45d70fa3d62edff2f0cfc25635511c0acaae9186 /gtk/dlg_utils.c
parent15648712d9555b2bae51537b228331856b1406ea (diff)
downloadwireshark-1e6ce19f799b3c4e71f5fe365d282f0dc9e9c6eb.tar.gz
wireshark-1e6ce19f799b3c4e71f5fe365d282f0dc9e9c6eb.tar.bz2
wireshark-1e6ce19f799b3c4e71f5fe365d282f0dc9e9c6eb.zip
Recent versions of GTK+ have added a "gtk-label-select-on-focus"
property, which selects the entire contents of a label when it comes into focus. This property annoyingly defaults to TRUE, which meant that the labels in simple dialogs and the about box would unexpectedly show up selected. Work around this by setting the focus on the "OK" button in the about dialog and the first button specified in simple dialogs. svn path=/trunk/; revision=20507
Diffstat (limited to 'gtk/dlg_utils.c')
-rw-r--r--gtk/dlg_utils.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/gtk/dlg_utils.c b/gtk/dlg_utils.c
index d493bd0c9f..e79541caaf 100644
--- a/gtk/dlg_utils.c
+++ b/gtk/dlg_utils.c
@@ -68,10 +68,40 @@ dlg_button_new(GtkWidget *hbox, GtkWidget *button_hbox, const gchar *stock_id)
return button;
}
+/*
+ * Set the focus and default for the nth item in a button row, with
+ * 0 being the first item.
+ */
+#define BUTTON_HBOX_KEY "button_hbox"
+void
+dlg_button_focus_nth(GtkWidget *hbox, gint focus_item) {
+ GtkWidget *button_hbox, *button;
+ GList *children;
+ gint cur_item = 0;
+
+ if (!hbox)
+ return;
+
+ button_hbox = OBJECT_GET_DATA(hbox, BUTTON_HBOX_KEY);
+ children = gtk_container_get_children(GTK_CONTAINER(button_hbox));
+
+ while (children) {
+ if (cur_item == focus_item) {
+ button = children->data;
+ gtk_widget_grab_focus(button);
+ gtk_widget_grab_default(button);
+ break;
+ }
+ children = g_list_next(children);
+ cur_item++;
+ }
+
+ g_list_free(children);
+}
/* create a button row for a dialog */
-/* The purpose of this is, to have one place available, where all button rows
+/* The purpose of this is, to have one place available, where all button rows
* from all dialogs are laid out. This will:
*
* a.) keep the button layout more consistent over the different dialogs
@@ -123,7 +153,7 @@ dlg_button_row_new(const gchar *stock_id_first, ...)
} else if (strcmp(stock_id, GTK_STOCK_SAVE) == 0) {
save = stock_id;
} else if (strcmp(stock_id, WIRESHARK_STOCK_DONT_SAVE) == 0) {
- dont_save = stock_id;
+ dont_save = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_CANCEL) == 0) {
cancel = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_CLOSE) == 0) {
@@ -166,6 +196,7 @@ dlg_button_row_new(const gchar *stock_id_first, ...)
button_hbox = gtk_hbutton_box_new();
gtk_box_pack_end(GTK_BOX(hbox), button_hbox, TRUE, TRUE, 0);
+ OBJECT_SET_DATA(hbox, BUTTON_HBOX_KEY, button_hbox);
gtk_widget_show(button_hbox);
help_hbox = gtk_hbutton_box_new();