ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: Re: [ethereal-dev] Re: Ethereal patches

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Jerry Talkington <jerryt@xxxxxxxxxx>
Date: Tue, 7 Dec 1999 17:13:24 -0800
* Guy Harris (guy@xxxxxxxxxx) done spit this rhetoric:
> 
> In fact, are filters really preferences?  The other stuff in Preferences
> controls the default behavior of various bits of Ethereal, but the
> filters is really a collection of filters you *can* apply, not filters
> that are in effect by default.  Filters are also kept in a separate file
> from preferences.
> 
> Perhaps there should be a separate dialog box popped up by the "Filter:"
> buttons, and perhaps an "Edit:Filters" menu item to pop it up as well?

Ok, here is a new patch that does just that.

> 
> > I think that just having another button that says "Apply", and acts as an
> > Ok and apply is probably a better idea.  I'll look into it.
> 
> "Apply" probably shouldn't act as OK-and-apply; "Apply" generally seems
> to mean "do what this dialog box says to do, but don't dismiss the
> dialog box, so I can see what it does, and tweak it if it doesn't do
> what I really wanted".

It's now a button like "New", "Change", etc..

> The button should probably be omitted if it wouldn't actually do
> anything (i.e., if E_FILT_TE_PTR_KEY isn't attached to the button that
> "filter_prefs_ok()" would be handed).

E_FILT_TE_PTR_KEY is attached to all of the widgets passed it, so if the
text widget doesn't do anything when activated, it'll just fill the box
with text, without closing the window.  I attached the Filters... menu item
to the main window's dialog box, also.

-- 
Jerry Talkington
NetCache Escalation Engineer
Network Appliance, Inc.

"I believe the children are our future: nasty, brutish and short."
Index: gtk/capture_dlg.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/capture_dlg.c,v
retrieving revision 1.10
diff -r1.10 capture_dlg.c
193c193
<     GTK_SIGNAL_FUNC(prefs_cb), (gpointer) E_PR_PG_FILTER);
---
>     GTK_SIGNAL_FUNC(filter_dialog_cb), NULL);
Index: gtk/file_dlg.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/file_dlg.c,v
retrieving revision 1.13
diff -r1.13 file_dlg.c
97c97
<     GTK_SIGNAL_FUNC(prefs_cb), (gpointer) E_PR_PG_FILTER);
---
>     GTK_SIGNAL_FUNC(filter_dialog_cb), NULL);
Index: gtk/filter_prefs.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/filter_prefs.c,v
retrieving revision 1.5
diff -r1.5 filter_prefs.c
51a52
> #define E_FILTER_WIDGET_KEY "filter_widget"
64c65
< static GtkWidget   *filter_l, *chg_bt, *copy_bt, *del_bt, *name_te, *filter_te;
---
> static GtkWidget   *filter_l, *chg_bt, *copy_bt, *del_bt, *name_te, *filter_te, *apply_bt;
67a69,72
> static void filter_dlg_ok(GtkWidget *ok_bt, gpointer parent_w);
> static void filter_dlg_save(GtkWidget *save_bt, gpointer parent_w);
> static void filter_dlg_cancel(GtkWidget *cancel_bt, gpointer parent_w);
> static void filter_sel_apply_cb(GtkWidget *cancel_bt, gpointer parent_w);
121a127,202
> /* the window that pops up for filter editing/applying */
> void
> filter_dialog_cb(GtkWidget *w)
> {
> 	GtkWidget	*main_w,	/* main window */
> 			*main_vb,	/* main container */
> 			*bbox, 		/* button container */
> 			*ok_bt, 	/* ok button */
> 			*save_bt, 	/* save button */
> 			*cancel_bt;	/* cancel button */ 
> 	GtkWidget *filter_te = NULL;	/* filter text entry */
> 	GtkWidget *filter_pg = NULL;	/* filter settings box */
> 
> 	/* get the text entry widget from the caller */
> 	if(w != NULL) {
> 		filter_te = gtk_object_get_data(GTK_OBJECT(w), E_FILT_TE_PTR_KEY);
> 	}
> 
> 	main_w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> 	gtk_window_set_title(GTK_WINDOW(main_w), "Ethereal: Filters");
> 
> 	main_vb = gtk_vbox_new(FALSE, 5);
> 	gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
> 	gtk_container_add(GTK_CONTAINER(main_w), main_vb);
> 	gtk_widget_show(main_vb);
> 
> 	filter_pg = filter_prefs_show(filter_te);
> 	gtk_box_pack_start(GTK_BOX(main_vb), filter_pg, TRUE, TRUE, 0);
> 	gtk_object_set_data(GTK_OBJECT(filter_pg), E_FILT_TE_PTR_KEY, filter_te);
> 	gtk_object_set_data(GTK_OBJECT(main_w), E_FILTER_WIDGET_KEY, filter_pg);
> 	gtk_widget_show(filter_te);
> 
> 	bbox = gtk_hbutton_box_new();
> 	gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
> 	gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
> 	gtk_container_add(GTK_CONTAINER(main_vb), bbox);
> 	gtk_widget_show(bbox);
> 
> 	ok_bt = gtk_button_new_with_label ("OK");
> 	gtk_signal_connect(GTK_OBJECT(ok_bt), "clicked",
> 		GTK_SIGNAL_FUNC(filter_dlg_ok), GTK_OBJECT(main_w));
> 	GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT);
> 	gtk_box_pack_start(GTK_BOX(bbox), ok_bt, TRUE, TRUE, 0);
> 	gtk_widget_grab_default(ok_bt);
> 	gtk_widget_show(ok_bt);
> 
> 	save_bt = gtk_button_new_with_label ("Save");
> 	gtk_signal_connect(GTK_OBJECT(save_bt), "clicked",
> 		GTK_SIGNAL_FUNC(filter_dlg_save), GTK_OBJECT(main_w));
> 	GTK_WIDGET_SET_FLAGS(save_bt, GTK_CAN_DEFAULT);
> 	gtk_box_pack_start(GTK_BOX(bbox), save_bt, TRUE, TRUE, 0);
> 	gtk_widget_show(save_bt);
> 
> 	cancel_bt = gtk_button_new_with_label ("Cancel");
> 	gtk_signal_connect(GTK_OBJECT(cancel_bt), "clicked",
> 		GTK_SIGNAL_FUNC(filter_dlg_cancel), GTK_OBJECT(main_w));
> 	GTK_WIDGET_SET_FLAGS(cancel_bt, GTK_CAN_DEFAULT);
> 	gtk_box_pack_start(GTK_BOX(bbox), cancel_bt, TRUE, TRUE, 0);
> 	gtk_widget_show(cancel_bt);
> 
> 
> 	gtk_widget_show(main_w);
> }
> 
> static void
> filter_dlg_ok(GtkWidget *ok_bt, gpointer parent_w)
> {
> 	filter_prefs_ok(gtk_object_get_data(GTK_OBJECT(parent_w), E_FILTER_WIDGET_KEY));
> 	gtk_widget_destroy(GTK_WIDGET(parent_w));
> }
> 
> static void
> filter_dlg_save(GtkWidget *save_bt, gpointer parent_w)
> {
> 	filter_prefs_save(gtk_object_get_data(GTK_OBJECT(parent_w), E_FILTER_WIDGET_KEY));
> }
122a204,210
> static void
> filter_dlg_cancel(GtkWidget *cancel_bt, gpointer parent_w)
> {
> 	filter_prefs_cancel(gtk_object_get_data(GTK_OBJECT(parent_w),  E_FILTER_WIDGET_KEY));
> 	gtk_widget_destroy(GTK_WIDGET(parent_w));
> }
> 	
182c270,277
<   
---
> 
>   apply_bt = gtk_button_new_with_label("Apply");
>   gtk_widget_set_sensitive(apply_bt, FALSE);
>   gtk_signal_connect(GTK_OBJECT(apply_bt), "clicked",
>     GTK_SIGNAL_FUNC(filter_sel_apply_cb), w);
>   gtk_container_add(GTK_CONTAINER(list_bb), apply_bt);
>   gtk_widget_show(apply_bt);
> 
286a382
>     gtk_widget_set_sensitive(apply_bt, sensitivity);
403a500,519
> }
> 
> void
> filter_sel_apply_cb(GtkWidget *w, gpointer data)
> {
> 	GList      *flp, *sl;
> 	GtkObject  *l_item;
> 	filter_def *filt;
> 	GtkWidget  *mw_filt = data;
> 	
> 	sl = GTK_LIST(filter_l)->selection;
> 	if (sl != NULL && mw_filt != NULL) {  /* Place something in the filter box. */
> 		l_item = GTK_OBJECT(sl->data);
> 		flp    = (GList *) gtk_object_get_data(l_item, E_FILT_NAME_KEY);
> 		if (flp) {
> 			filt = (filter_def *) flp->data;
> 			gtk_entry_set_text(GTK_ENTRY(mw_filt), filt->strval);
> 			gtk_signal_emit_by_name(GTK_OBJECT(mw_filt), "activate");
> 		}
> 	}
Index: gtk/main.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/main.c,v
retrieving revision 1.65
diff -r1.65 main.c
1311c1311
<     GTK_SIGNAL_FUNC(prefs_cb), (gpointer) E_PR_PG_FILTER);
---
>     GTK_SIGNAL_FUNC(filter_dialog_cb), NULL);
1339a1340
>   set_menu_object_data("/Edit/Filters...", E_FILT_TE_PTR_KEY, filter_te);
Index: gtk/main.h
===================================================================
RCS file: /cvsroot/ethereal/gtk/main.h,v
retrieving revision 1.6
diff -r1.6 main.h
68a69
> void filter_dialog_cb(GtkWidget *);
Index: gtk/menu.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/menu.c,v
retrieving revision 1.8
diff -r1.8 menu.c
97a98
>   {"/Edit/_Filters...", NULL, GTK_MENU_FUNC(filter_dialog_cb), (gpointer *)NULL, NULL},
Index: gtk/prefs_dlg.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/prefs_dlg.c,v
retrieving revision 1.3
diff -r1.3 prefs_dlg.c
54d53
< #include "filter_prefs.h"
67d65
< #define E_FILTER_PAGE_KEY "filter_options_page"
75c73
<   GtkWidget *print_pg, *filter_pg, *column_pg, *stream_pg, *filter_te, *label;
---
>   GtkWidget *print_pg, *column_pg, *stream_pg, *label;
80,81d77
<   filter_pg = NULL;
<   filter_te = NULL;
109,119d104
<   /* Filter prefs */
<   if (w)
<     filter_te = gtk_object_get_data(GTK_OBJECT(w), E_FILT_TE_PTR_KEY);
<   filter_pg = filter_prefs_show(filter_te);
< 
<   /* Pass along the entry widget pointer from the calling widget */
<   gtk_object_set_data(GTK_OBJECT(filter_pg), E_FILT_TE_PTR_KEY, filter_te);
<   gtk_object_set_data(GTK_OBJECT(prefs_w), E_FILTER_PAGE_KEY, filter_pg);
<   label = gtk_label_new ("Filters");
<   gtk_notebook_append_page (GTK_NOTEBOOK(prefs_nb), filter_pg, label);
< 
172d156
<   filter_prefs_ok(gtk_object_get_data(GTK_OBJECT(parent_w), E_FILTER_PAGE_KEY));
182d165
<   filter_prefs_save(gtk_object_get_data(GTK_OBJECT(parent_w), E_FILTER_PAGE_KEY));
192d174
<   filter_prefs_cancel(gtk_object_get_data(GTK_OBJECT(parent_w), E_FILTER_PAGE_KEY));
202d183
<   filter_prefs_delete(gtk_object_get_data(GTK_OBJECT(prefs_w), E_FILTER_PAGE_KEY));