diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2008-06-17 19:50:22 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2008-06-17 19:50:22 +0000 |
commit | 4cd366783231a8c98f5947c39d377855b3797b81 (patch) | |
tree | 769064e2b7156203df41b983de9c677bf03754d3 /gtk | |
parent | d630c26a291f62ee8123eb977e1babc5277d2400 (diff) | |
download | wireshark-4cd366783231a8c98f5947c39d377855b3797b81.tar.gz wireshark-4cd366783231a8c98f5947c39d377855b3797b81.tar.bz2 wireshark-4cd366783231a8c98f5947c39d377855b3797b81.zip |
Popup a menu with configuration profiles instead of the profile dlg
when clicking the profile in the statusbar. Much easier to use.
svn path=/trunk/; revision=25468
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main_statusbar.c | 4 | ||||
-rw-r--r-- | gtk/profile_dlg.c | 58 | ||||
-rw-r--r-- | gtk/profile_dlg.h | 6 |
3 files changed, 66 insertions, 2 deletions
diff --git a/gtk/main_statusbar.c b/gtk/main_statusbar.c index 661cc0289e..669ab93e1c 100644 --- a/gtk/main_statusbar.c +++ b/gtk/main_statusbar.c @@ -346,10 +346,10 @@ profile_bar_new(void) profile_bar_event = gtk_event_box_new(); profile_bar = gtk_statusbar_new(); gtk_container_add(GTK_CONTAINER(profile_bar_event), profile_bar); - g_signal_connect(profile_bar_event, "button_press_event", G_CALLBACK(profile_dialog_cb), NULL); + g_signal_connect(profile_bar_event, "button_press_event", G_CALLBACK(profile_show_popup_cb), NULL); profile_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(profile_bar), "profile"); gtk_tooltips_set_tip (tooltips, profile_bar_event, - "Click to change configuration profile.", NULL); + "Click to change configuration profile", NULL); profile_bar_update(); gtk_widget_show(profile_bar); diff --git a/gtk/profile_dlg.c b/gtk/profile_dlg.c index 06f35da873..c0f8909d54 100644 --- a/gtk/profile_dlg.c +++ b/gtk/profile_dlg.c @@ -841,6 +841,64 @@ profile_dialog_new(void) } +static void +select_profile_cb (GtkWidget *w _U_, gpointer data) +{ + const gchar *current_profile = get_profile_name (); + gchar *selected_profile = (gchar *) data; + + if (strcmp (selected_profile, current_profile) != 0) { + change_configuration_profile (selected_profile); + } +} + +gboolean +profile_show_popup_cb (GtkWidget *w _U_, GdkEvent *event) +{ + GdkEventButton *bevent = (GdkEventButton *)event; + const gchar *profile_name = get_profile_name (); + const gchar *profiles_dir, *name; + ETH_DIR *dir; /* scanned directory */ + ETH_DIRENT *file; /* current file */ + GtkWidget *menu; + GtkWidget *menu_item; + + menu = gtk_menu_new (); + + /* Add a menu item for the Default profile */ + menu_item = gtk_check_menu_item_new_with_label (DEFAULT_PROFILE); + if (strcmp (profile_name, DEFAULT_PROFILE)==0) { + /* Check current profile */ + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), TRUE); + } + g_signal_connect (menu_item, "activate", G_CALLBACK(select_profile_cb), g_strdup (DEFAULT_PROFILE)); + gtk_menu_append (menu, menu_item); + gtk_widget_show (menu_item); + + profiles_dir = get_profiles_dir(); + if ((dir = ws_dir_open(profiles_dir, 0, NULL)) != NULL) { + while ((file = ws_dir_read_name(dir)) != NULL) { + name = ws_dir_get_name(file); + + if (profile_exists(name)) { + menu_item = gtk_check_menu_item_new_with_label (name); + if (strcmp (name, profile_name)==0) { + /* Check current profile */ + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), TRUE); + } + g_signal_connect (menu_item, "activate", G_CALLBACK(select_profile_cb), g_strdup (name)); + gtk_menu_append (menu, menu_item); + gtk_widget_show (menu_item); + } + } + } + + gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, + bevent->button, bevent->time); + + return TRUE; +} + /* Create a profile dialog for editing display profiles; this is to be used as a callback for menu items, toolbars, etc.. */ void diff --git a/gtk/profile_dlg.h b/gtk/profile_dlg.h index df6fcb391b..abec96f260 100644 --- a/gtk/profile_dlg.h +++ b/gtk/profile_dlg.h @@ -31,6 +31,12 @@ * @ingroup dialog_group */ +/** User requested the "Configuration Profiles" popup menu. + * + * @param widget parent widget + * @param event button event + */ +gboolean profile_show_popup_cb(GtkWidget *w _U_, GdkEvent *event); /** User requested the "Configuration Profiles" dialog box by menu or toolbar. * |