aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorLaurent Deniel <laurent.deniel@free.fr>2000-08-21 15:45:33 +0000
committerLaurent Deniel <laurent.deniel@free.fr>2000-08-21 15:45:33 +0000
commit8fbd65cc7fa830d497c14ee29d9912e618a09e8f (patch)
treec0887a4f01bc643e51d4b028a23f4e8e290b2925 /gtk
parentff42c86f9a39f23e89bad0581b126c9f96e48268 (diff)
Frames in the packet list can now be marked by the user using
the middle mouse button. The marked packets are displayed in reverse video but this should change in the future (the color should be configurable via the GUI). Then, the marked packets can be saved (via the "Save as" window dialog). Other features will be added in the future (I am waiting for your comments and wishes). svn path=/trunk/; revision=2322
Diffstat (limited to 'gtk')
-rw-r--r--gtk/file_dlg.c43
-rw-r--r--gtk/main.c29
2 files changed, 64 insertions, 8 deletions
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 6155513817..8cd7fcebd4 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -1,7 +1,7 @@
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.30 2000/08/11 13:33:04 deniel Exp $
+ * $Id: file_dlg.c,v 1.31 2000/08/21 15:45:32 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -267,8 +267,10 @@ file_save_cmd_cb(GtkWidget *w, gpointer data) {
/* XXX - can we make these not be static? */
static gboolean filtered;
+static gboolean marked;
static int filetype;
static GtkWidget *filter_cb;
+static GtkWidget *mark_cb;
static GtkWidget *ft_om;
static gboolean
@@ -290,7 +292,11 @@ can_save_with_wiretap(int ft)
"filtered" is TRUE if we're to save only the packets that passed
the display filter (in which case we have to save it using Wiretap)
and FALSE if we're to save the entire file (in which case, if we're
- saving it in the type it has already, we can just copy it). */
+ saving it in the type it has already, we can just copy it).
+
+ "marked" is TRUE if we have to save only the marked packets,
+ the same remark as "filtered" applies.
+*/
static void
set_file_type_list(GtkWidget *option_menu)
{
@@ -308,8 +314,8 @@ set_file_type_list(GtkWidget *option_menu)
/* Check all file types. */
index = 0;
for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) {
- if (filtered || ft != cfile.cd_t) {
- /* Filtered, or a different file type. We have to use Wiretap. */
+ if (filtered || marked || ft != cfile.cd_t) {
+ /* Filtered, marked or a different file type. We have to use Wiretap. */
if (!can_save_with_wiretap(ft))
continue; /* We can't. */
}
@@ -337,7 +343,7 @@ select_file_type_cb(GtkWidget *w, gpointer data)
int new_filetype = (int)data;
if (filetype != new_filetype) {
- /* We can select only the filtered packets to be saved iff we can
+ /* We can select only the filtered or marked packets to be saved if we can
use Wiretap to save the file. */
gtk_widget_set_sensitive(filter_cb, can_save_with_wiretap(new_filetype));
filetype = new_filetype;
@@ -358,6 +364,20 @@ toggle_filtered_cb(GtkWidget *widget, gpointer data)
}
}
+static void
+toggle_marked_cb(GtkWidget *widget, gpointer data)
+{
+ gboolean new_marked;
+
+ new_marked = GTK_TOGGLE_BUTTON (widget)->active;
+
+ if (marked != new_marked) {
+ /* They changed the state of the "marked" button. */
+ marked = new_marked;
+ set_file_type_list(ft_om);
+ }
+}
+
/*
* Keep a static pointer to the current "Save Capture File As" window, if
* any, so that if somebody tries to do "File:Save" or "File:Save As"
@@ -379,6 +399,7 @@ file_save_as_cmd_cb(GtkWidget *w, gpointer data)
/* Default to saving all packets, in the file's current format. */
filtered = FALSE;
+ marked = FALSE;
filetype = cfile.cd_t;
file_save_as_w = gtk_file_selection_new ("Ethereal: Save Capture File As");
@@ -411,6 +432,14 @@ file_save_as_cmd_cb(GtkWidget *w, gpointer data)
gtk_widget_set_sensitive(filter_cb, can_save_with_wiretap(filetype));
gtk_widget_show(filter_cb);
+ mark_cb = gtk_check_button_new_with_label("Save only marked packets");
+ gtk_container_add(GTK_CONTAINER(main_vb), mark_cb);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(mark_cb), FALSE);
+ gtk_signal_connect(GTK_OBJECT(mark_cb), "toggled",
+ GTK_SIGNAL_FUNC(toggle_marked_cb), NULL);
+ gtk_widget_set_sensitive(mark_cb, can_save_with_wiretap(filetype));
+ gtk_widget_show(mark_cb);
+
/* File type row */
ft_hb = gtk_hbox_new(FALSE, 3);
gtk_container_add(GTK_CONTAINER(main_vb), ft_hb);
@@ -450,8 +479,8 @@ file_save_as_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
gtk_widget_destroy(GTK_WIDGET (fs));
/* Write out the packets (all, or only the ones that are currently
- displayed) to the file with the specified name. */
- save_cap_file(cf_name, &cfile, filtered, filetype);
+ displayed or marked) to the file with the specified name. */
+ save_cap_file(cf_name, &cfile, filtered, marked, filetype);
/* If "save_cap_file()" saved the file name we handed it, it saved
a copy, so we should free up our copy. */
diff --git a/gtk/main.c b/gtk/main.c
index da462c66b2..6d55de6b5c 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.144 2000/08/21 12:33:22 deniel Exp $
+ * $Id: main.c,v 1.145 2000/08/21 15:45:33 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -458,6 +458,31 @@ packet_list_click_column_cb(GtkCList *clist, gint column, gpointer data)
gtk_clist_sort(clist);
}
+static void
+packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data) {
+
+ GdkEventButton *event_button = (GdkEventButton *)event;
+ gint row, column;
+
+ if (w == NULL || event == NULL)
+ return;
+
+ if (event->type == GDK_BUTTON_PRESS && event_button->button == 2 &&
+ gtk_clist_get_selection_info(GTK_CLIST(w), event_button->x, event_button->y,
+ &row, &column)) {
+ frame_data *fdata;
+ fdata = (frame_data *) gtk_clist_get_row_data(GTK_CLIST(w), row);
+ if (fdata != NULL) {
+ fdata->flags.marked = !fdata->flags.marked;
+ /* XXX need user-configurable colors here */
+ gtk_clist_set_background(GTK_CLIST(packet_list), row,
+ (fdata->flags.marked) ?&BLACK : &WHITE);
+ gtk_clist_set_foreground(GTK_CLIST(packet_list), row,
+ (fdata->flags.marked) ?&WHITE : &BLACK);
+ }
+ }
+}
+
/* What to do when a list item is selected/unselected */
static void
packet_list_select_cb(GtkWidget *w, gint row, gint col, gpointer evt) {
@@ -1420,6 +1445,8 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gtk_signal_connect(GTK_OBJECT(packet_list), "button_press_event",
GTK_SIGNAL_FUNC(popup_menu_handler),
gtk_object_get_data(GTK_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY));
+ gtk_signal_connect(GTK_OBJECT(packet_list), "button_press_event",
+ GTK_SIGNAL_FUNC(packet_list_button_pressed_cb), NULL);
gtk_clist_set_compare_func(GTK_CLIST(packet_list), packet_list_compare);
gtk_widget_show(packet_list);