diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/about_dlg.c | 10 | ||||
-rw-r--r-- | gtk/dlg_utils.c | 35 | ||||
-rw-r--r-- | gtk/dlg_utils.h | 13 | ||||
-rw-r--r-- | gtk/simple_dialog.c | 18 |
4 files changed, 60 insertions, 16 deletions
diff --git a/gtk/about_dlg.c b/gtk/about_dlg.c index 49a1796aed..c9cdf738b1 100644 --- a/gtk/about_dlg.c +++ b/gtk/about_dlg.c @@ -105,7 +105,7 @@ splash_new(char *message) main_lb = gtk_label_new(message); gtk_container_add(GTK_CONTAINER(main_vb), main_lb); OBJECT_SET_DATA(win, "splash_label", main_lb); - + gtk_widget_show_all(win); splash_update(win, message); @@ -209,7 +209,7 @@ about_folders_page_new(void) scrolledwindow = scrolled_window_new(NULL, NULL); #if GTK_MAJOR_VERSION >= 2 - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_SHADOW_IN); #endif @@ -228,7 +228,7 @@ about_folders_page_new(void) /* pers conf */ path = get_persconffile_path("", FALSE); - about_folders_row(table, "Personal configuration", path, + about_folders_row(table, "Personal configuration", path, "\"dfilters\", \"preferences\", \"ethers\", ..."); g_free((void *) path); @@ -310,7 +310,7 @@ about_wireshark_cb( GtkWidget *w _U_, gpointer data _U_ ) #else gtk_window_set_position(GTK_WINDOW(about_wireshark_w), GTK_WIN_POS_CENTER); #endif - /* setting the size is dangerous here, as making it too short will + /* setting the size is dangerous here, as making it too short will * clip content on GTK1, so simply use the natural size */ /*gtk_window_set_default_size(GTK_WINDOW(about_wireshark_w), 600, 400);*/ gtk_container_border_width(GTK_CONTAINER(about_wireshark_w), 6); @@ -355,6 +355,8 @@ about_wireshark_cb( GtkWidget *w _U_, gpointer data _U_ ) gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0); ok_btn = OBJECT_GET_DATA(bbox, GTK_STOCK_OK); + gtk_widget_grab_focus(ok_btn); + gtk_widget_grab_default(ok_btn); window_set_cancel_button(about_wireshark_w, ok_btn, window_cancel_button_cb); SIGNAL_CONNECT(about_wireshark_w, "delete_event", window_delete_event_cb, NULL); 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(); diff --git a/gtk/dlg_utils.h b/gtk/dlg_utils.h index 71f515a0c9..7c51c2b2ae 100644 --- a/gtk/dlg_utils.h +++ b/gtk/dlg_utils.h @@ -24,7 +24,7 @@ /** @defgroup dialog_group Dialogs * - * Dialogs are specially created windows and are related to their parent windows (usually the main window). + * Dialogs are specially created windows and are related to their parent windows (usually the main window). * See: @ref howto_window_page for details. * * Normal dialogs are created using dlg_window_new(). @@ -61,7 +61,7 @@ */ /** @file - * Utilities for dialog boxes. Depending on the window functions in + * Utilities for dialog boxes. Depending on the window functions in * gui_utils.h, see: @ref howto_window_page for details. * @ingroup dialog_group */ @@ -71,7 +71,7 @@ /** Create a dialog box window that belongs to Wireshark's main window. - * If you want to create a window, use window_new() instead. + * If you want to create a window, use window_new() instead. * See window_new() for general window usage. * * @param title the title for the new dialog @@ -98,6 +98,13 @@ extern GtkWidget *dlg_button_row_new(const gchar *stock_id_first, ...); */ extern void dlg_set_activate(GtkWidget *widget, GtkWidget *ok_button); +/** Set the focus and default for the nth item in a button row. + * + * @param hbox A button row returned by dlg_button_row_new(). + * @param focus_item The button to focus (0 is the first). + * @see dlg_button_row_new() + */ +void dlg_button_focus_nth(GtkWidget *hbox, gint focus_item); /** used by compat_macros.h only, don't use directly */ extern GtkWidget *dlg_radio_button_new_with_label_with_mnemonic(GSList *group, diff --git a/gtk/simple_dialog.c b/gtk/simple_dialog.c index fe288dd7b4..e97170f1cd 100644 --- a/gtk/simple_dialog.c +++ b/gtk/simple_dialog.c @@ -58,7 +58,7 @@ typedef struct { gint btn_mask; char *message; } queued_message_t; - + static GSList *message_queue; static GtkWidget * @@ -172,6 +172,8 @@ display_simple_dialog(gint type, gint btn_mask, char *message) #if GTK_MAJOR_VERSION >= 2 gtk_label_set_markup(GTK_LABEL(msg_label), message); gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE); + g_object_set(gtk_widget_get_settings(msg_label), + "gtk-label-select-on-focus", FALSE, NULL); #endif gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL); @@ -228,12 +230,12 @@ display_simple_dialog(gint type, gint btn_mask, char *message) OBJECT_SET_DATA(save_bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_SAVE)); SIGNAL_CONNECT(save_bt, "clicked", simple_dialog_cancel_cb, win); } - + dont_save_bt = OBJECT_GET_DATA(bbox, WIRESHARK_STOCK_DONT_SAVE); if (dont_save_bt) { OBJECT_SET_DATA(dont_save_bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_DONT_SAVE)); - SIGNAL_CONNECT(dont_save_bt, "clicked", simple_dialog_cancel_cb, win); - } + SIGNAL_CONNECT(dont_save_bt, "clicked", simple_dialog_cancel_cb, win); + } bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLEAR); if(bt) { OBJECT_SET_DATA(bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CLEAR)); @@ -266,6 +268,8 @@ display_simple_dialog(gint type, gint btn_mask, char *message) } } + dlg_button_focus_nth(bbox, 0); + gtk_widget_show(win); return win; @@ -325,9 +329,9 @@ vsimple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, va_list state = gdk_window_get_state(top_level->window); } - /* If we don't yet have a main window or it's iconified, don't show the - dialog. If showing up a dialog, while main window is iconified, program - will become unresponsive! */ + /* If we don't yet have a main window or it's iconified, don't show the + dialog. If showing up a dialog, while main window is iconified, program + will become unresponsive! */ if (top_level == NULL || state & GDK_WINDOW_STATE_ICONIFIED) { #else |