aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk
diff options
context:
space:
mode:
authorIrene RĂ¼ngeler <I.Ruengeler@fh-muenster.de>2013-04-12 11:56:00 +0000
committerIrene RĂ¼ngeler <I.Ruengeler@fh-muenster.de>2013-04-12 11:56:00 +0000
commita17ec349b41662d97bb3f70817d607bf24fb5962 (patch)
tree7191a20ff85d9cfa3449a1d9c26a6db5384af691 /ui/gtk
parent267a89b1f48ff391b37591ebcb95a34f6029d6a3 (diff)
Change the sensitivity of the start button depending on the number of interfaces selected.
svn path=/trunk/; revision=48827
Diffstat (limited to 'ui/gtk')
-rw-r--r--ui/gtk/capture_dlg.c2
-rw-r--r--ui/gtk/main_menubar.c8
-rw-r--r--ui/gtk/main_toolbar.c12
-rw-r--r--ui/gtk/main_toolbar.h3
-rw-r--r--ui/gtk/main_welcome.c11
-rw-r--r--ui/gtk/main_welcome.h2
6 files changed, 36 insertions, 2 deletions
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c
index 03aedc50c7..dea2b1781a 100644
--- a/ui/gtk/capture_dlg.c
+++ b/ui/gtk/capture_dlg.c
@@ -2449,6 +2449,7 @@ update_options_table(gint indx)
change_interface_selection(g_strdup(device.name), device.selected);
}
}
+ set_sensitivity_for_start_icon();
}
@@ -3190,6 +3191,7 @@ static void capture_all_cb(GtkToggleButton *button, gpointer d _U_)
gtk_widget_set_sensitive(all_compile_bt, FALSE);
#endif
}
+ set_sensitivity_for_start_icon();
}
diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c
index 7bcf4bf6d2..cc86ad8f27 100644
--- a/ui/gtk/main_menubar.c
+++ b/ui/gtk/main_menubar.c
@@ -4825,6 +4825,8 @@ set_menus_for_capture_in_progress(gboolean capture_in_progress)
!capture_in_progress);
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Start",
!capture_in_progress);
+ set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Start",
+ global_capture_opts.num_selected > 0);
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Stop",
capture_in_progress);
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Restart",
@@ -4832,6 +4834,12 @@ set_menus_for_capture_in_progress(gboolean capture_in_progress)
#endif /* HAVE_LIBPCAP */
}
+void
+set_menus_capture_start_sensitivity(gboolean enable)
+{
+ set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Start",
+ enable);
+}
/* Disable menu items while we're waiting for the capture child to
finish. We disallow quitting until it finishes, and also disallow
diff --git a/ui/gtk/main_toolbar.c b/ui/gtk/main_toolbar.c
index 5d11fe9d86..026b41abac 100644
--- a/ui/gtk/main_toolbar.c
+++ b/ui/gtk/main_toolbar.c
@@ -58,6 +58,7 @@
#include "ui/gtk/keys.h"
#include "ui/gtk/packet_history.h"
#include "ui/gtk/packet_list.h"
+#include "ui/capture_globals.h"
#include "ui/gtk/old-gtk-compat.h"
@@ -97,6 +98,10 @@ toolbar_redraw_all(void)
(GtkToolbarStyle)prefs.gui_toolbar_filter_style);
}
+void set_start_button_sensitive(gboolean enable) {
+ gtk_widget_set_sensitive(GTK_WIDGET(new_button), enable);
+}
+
/* Enable or disable toolbar items based on whether you have a capture file
and, if so, whether you've finished reading it and whether there's stuff
in it that hasn't yet been saved to a permanent file. */
@@ -136,10 +141,13 @@ void set_toolbar_for_capture_in_progress(gboolean capture_in_progress) {
if (toolbar_init) {
#ifdef HAVE_LIBPCAP
- gtk_widget_set_sensitive(GTK_WIDGET(capture_options_button), !capture_in_progress);
+ gtk_widget_set_sensitive(GTK_WIDGET(capture_options_button), !capture_in_progress);
gtk_widget_set_sensitive(GTK_WIDGET(new_button), !capture_in_progress);
gtk_widget_set_sensitive(GTK_WIDGET(stop_button), capture_in_progress);
- gtk_widget_set_sensitive(GTK_WIDGET(clear_button), capture_in_progress);
+ gtk_widget_set_sensitive(GTK_WIDGET(clear_button), capture_in_progress);
+ if (!capture_in_progress) {
+ gtk_widget_set_sensitive(GTK_WIDGET(new_button), (global_capture_opts.num_selected > 0));
+ }
/*if (capture_in_progress) {
gtk_widget_hide(GTK_WIDGET(new_button));
gtk_widget_show(GTK_WIDGET(stop_button));
diff --git a/ui/gtk/main_toolbar.h b/ui/gtk/main_toolbar.h
index 4a9725364b..df8b188262 100644
--- a/ui/gtk/main_toolbar.h
+++ b/ui/gtk/main_toolbar.h
@@ -44,4 +44,7 @@ void toolbar_redraw_all(void);
*/
void set_toolbar_object_data(const gchar *key, gpointer data);
+void set_start_button_sensitive(gboolean enable);
+void set_menus_capture_start_sensitivity(gboolean enable);
+
#endif /* __TOOLBAR_H__ */
diff --git a/ui/gtk/main_welcome.c b/ui/gtk/main_welcome.c
index ad82a26087..75eaee8dfe 100644
--- a/ui/gtk/main_welcome.c
+++ b/ui/gtk/main_welcome.c
@@ -54,6 +54,7 @@
#include "ui/gtk/main.h"
#include "ui/gtk/menus.h"
#include "ui/gtk/main_welcome.h"
+#include "ui/gtk/main_toolbar.h"
#include "ui/gtk/help_dlg.h"
#include "ui/gtk/capture_file_dlg.h"
#include "ui/gtk/stock_icons.h"
@@ -751,9 +752,19 @@ gboolean on_selection_changed(GtkTreeSelection *selection _U_,
break;
}
}
+ set_sensitivity_for_start_icon();
return TRUE;
}
+void
+set_sensitivity_for_start_icon()
+{
+ gboolean enable = (global_capture_opts.num_selected > 0);
+
+ set_start_button_sensitive(enable);
+ set_menus_capture_start_sensitivity(enable);
+}
+
static gboolean activate_ifaces(GtkTreeModel *model,
GtkTreePath *path _U_,
GtkTreeIter *iter,
diff --git a/ui/gtk/main_welcome.h b/ui/gtk/main_welcome.h
index 36c307c7e7..fb1d1f50d3 100644
--- a/ui/gtk/main_welcome.h
+++ b/ui/gtk/main_welcome.h
@@ -76,6 +76,8 @@ void change_selection_for_all(gboolean enable);
void update_welcome_list(void);
+void set_sensitivity_for_start_icon(void);
+
#ifdef HAVE_PCAP_REMOTE
void add_interface_to_list(guint index);
#endif