Ethereal-dev: Re: [Ethereal-dev] Phase two of color filters update
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Richard Urwin <richard@xxxxxxxxxxxxxxx>
Date: Wed, 27 Aug 2003 23:17:09 +0100
On Tuesday 26 Aug 2003 4:34 am, Guy Harris wrote: > On Mon, Aug 25, 2003 at 10:56:24PM +0100, Richard Urwin wrote: > > OK. Here's the modified patch, with textual buttons for Import and > > Export. > > > > Please check it in. Thanks. > > Ronnie Sahlberg already checked in the original patch - could you > redo that patch as a delta relative to the current CVS version? OK, here it is. I haven't built it against the CVS, but since all the changes in the two files concerned are mine, I can be fairly sure it will build. <ducks and runs> I also fixed a tiny segmentation fault due to a duplicate fclose, and tidied up a bit while I was looking for it. So this isn't the two line fix it should be. But it is still straight-forward. Please check it in. Thanks. -- Richard Urwin
diff -Bur --ignore-matching-lines=: --exclude='*.o' --exclude='*.dtd' --exclude='*.xml' --exclude=configure --exclude='ascend-grammar.[ch]' --exclude='ascend-scanner.[ch]' --exclude=Makefile --exclude='*.1' --exclude='*.log' --exclude='*.log' --exclude='*.Po' --exclude='*.status' ethereal-2003-08-27/gtk/color_dlg.c ethereal/gtk/color_dlg.c --- ethereal-2003-08-27/gtk/color_dlg.c 2003-08-18 22:27:09.000000000 +0100 +++ ethereal/gtk/color_dlg.c 2003-08-25 23:54:44.000000000 +0100 @@ -446,25 +445,17 @@ gtk_widget_show (importexport_vbox); gtk_box_pack_start (GTK_BOX (button_ok_hbox), importexport_vbox, TRUE, TRUE, 0); -#if GTK_MAJOR_VERSION < 2 - color_export = gtk_button_new_with_label (("Export")); -#else - color_export = gtk_button_new_from_stock(GTK_STOCK_SAVE_AS); -#endif + color_export = gtk_button_new_with_label (("Export...")); gtk_widget_ref(color_export); gtk_widget_show(color_export); gtk_box_pack_start(GTK_BOX (importexport_vbox), color_export, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, color_export, ("Save filters to specified file"), NULL); + gtk_tooltips_set_tip(tooltips, color_export, ("Save all/marked filters to specified file"), NULL); -#if GTK_MAJOR_VERSION < 2 - color_import = gtk_button_new_with_label (("Import")); -#else - color_import = gtk_button_new_from_stock(GTK_STOCK_OPEN); -#endif + color_import = gtk_button_new_with_label (("Import...")); gtk_widget_ref(color_import); gtk_widget_show(color_import); gtk_box_pack_start(GTK_BOX (importexport_vbox), color_import, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips, color_import, ("Load filters from specified file"), NULL); + gtk_tooltips_set_tip(tooltips, color_import, ("Include filters from specified file"), NULL); #if GTK_MAJOR_VERSION < 2 color_cancel = gtk_button_new_with_label (("Cancel")); @@ -742,30 +733,24 @@ gboolean last_marked; /* true if the last filter in the list is marked */ gpointer color_filters; }; -/* called for each selected row in the tree. The first call is detected and does -the stuff that only needs to be done once. If we are never called the visited -variable stays false and means that no rows are selected. +/* called for each selected row in the tree. */ void remember_this_row (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer arg) { - GtkWidget *button; - gchar *path_str; + gint *path_index; color_filter_t *colorf; struct remember_data *data = arg; gtk_tree_model_get(model, iter, 4, &colorf, -1); colorf->marked = TRUE; - path_str = gtk_tree_path_to_string(path); - row_selected = atoi(path_str); - g_free(path_str); + path_index = gtk_tree_path_get_indices(path); /* not to be freed */ + if (path_index == NULL) /* can return NULL according to API doc.*/ + { + return; + } + row_selected = path_index[0]; - /* - * A row is selected, so we can move it up *if* it's not at the top - * and move it down *if* it's not at the bottom. - */ - button = (GtkWidget *)OBJECT_GET_DATA(data->color_filters, COLOR_UP_LB); - gtk_widget_set_sensitive(button, row_selected > 0); if (row_selected == 0) data->first_marked = TRUE; if (row_selected == num_of_filters - 1) @@ -789,11 +774,10 @@ { GtkWidget *button; struct remember_data data; - + data.first_marked = data.last_marked = FALSE; data.count = 0; data.color_filters = color_filters; - g_slist_foreach(filter_list, clear_mark, NULL); gtk_tree_selection_selected_foreach(sel,remember_this_row, &data); @@ -1017,9 +1002,7 @@ GtkTreeIter iter; - /* The "selection changed" callback is called when the row is - * removed, so we must remember the selected row. */ - model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters)); + model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters)); gtk_tree_model_iter_nth_child(model, &iter, NULL, row); gtk_tree_model_get(model, &iter, 4, &colorf, -1); @@ -1038,9 +1021,8 @@ /* If we grab the focus after updating the selection, the first * row is always selected, so we do it before */ gtk_widget_grab_focus(color_filters); - /* Update the selection */ #else - colorf = gtk_clist_get_row_data(GTK_CLIST(color_filters), row); + colorf = gtk_clist_get_row_data(GTK_CLIST(color_filters), row); /* Remove this color filter from the CList displaying the color filters. */ diff -Bur --ignore-matching-lines=: --exclude='*.o' --exclude='*.dtd' --exclude='*.xml' --exclude=configure --exclude='ascend-grammar.[ch]' --exclude='ascend-scanner.[ch]' --exclude=Makefile --exclude='*.1' --exclude='*.log' --exclude='*.log' --exclude='*.Po' --exclude='*.status' ethereal-2003-08-27/gtk/color_filters.c ethereal/gtk/color_filters.c --- ethereal-2003-08-27/gtk/color_filters.c 2003-08-18 22:27:10.000000000 +0100 +++ ethereal/gtk/color_filters.c 2003-08-25 22:18:14.000000000 +0100 @@ -204,7 +202,6 @@ } /* if sscanf */ } while(!feof(f)); - fclose(f); return TRUE; } /* read filters from the user's filter file */ @@ -218,6 +215,7 @@ * reading only */ gchar *path; FILE *f; + gboolean ret; /* decide what file to open (from dfilter code) */ path = get_persconffile_path("colorfilters", FALSE); @@ -233,7 +231,9 @@ g_free((gchar *)path); path = NULL; - return read_filters_file(f, NULL); + ret = read_filters_file(f, NULL); + fclose(f); + return ret; } /* read filters from the filter file */ @@ -242,6 +242,7 @@ { gchar *path; FILE *f; + gboolean ret; /* decide what file to open (from dfilter code) */ path = get_datafile_path("colorfilters"); @@ -257,7 +258,9 @@ g_free((gchar *)path); path = NULL; - return read_filters_file(f, NULL); + ret = read_filters_file(f, NULL); + fclose(f); + return ret; } /* save filters in some other filter file */ @@ -266,6 +269,7 @@ read_other_filters(gchar *path, gpointer arg) { FILE *f; + gboolean ret; if ((f = fopen(path, "r")) == NULL) { simple_dialog(ESD_TYPE_CRIT, NULL, @@ -274,9 +278,9 @@ return FALSE; } - read_filters_file(f, arg); + ret = read_filters_file(f, arg); fclose(f); - return TRUE; + return ret; } struct write_filter_data
Wed Aug 27 22:52:53 BST 2003 Comparison between ethereal-2003-08-27 and ethereal Changes to: ethereal/gtk/color_dlg.c ethereal/gtk/color_filters.c New Files: See 'colorfilters2b.patch' for details
How Colorization Works ---------------------- Packets are colored according to a list of color filters. Each filter consists of a name, a filter expression and a coloration. A packet is colored according to the first filter that it matches, Color filter expressions use exactly the same syntax as display filter expressions. When Ethereal starts the color filters are loaded from: 1. The user's personal colorfilters file or, if that does not exist, 2. The global colorfilters file. If neither of these exist then the packets will not be colored. The Color Filters Dialog ------------------------ This dialog displays a list of color filters and allows it to be modified. THE FILTER LIST Single rows may be selected by clicking. Multiple rows may be selected by using the ctrl and shift keys in combination with the mouse button. UP Moves the selected filter(s) up the list, making it more likely that they will be used to color packets. DOWN Moves the selected filter(s) down the list, making it less likely that they will be used to color packets. NEW Adds a new filter at the bottom of the list and opens the Edit Color Filter dialog box. You will have to alter the filter expression at least before the filter will be accepted. The format of color filter expressions is identical to that of display filters. The new filter is selected, so it may immediately be moved up and down, deleted or edited. To avoid confusion all filters are unselected before the new filter is created. EDIT Opens the Edit Color Filter dialog box for the selected filter. (If this button is disabled you may have more than one filter selected, making it ambiguous which is to be edited.) DELETE Deletes the selected color filter(s). OK Closes the dialog and uses the color filters as they stand. APPLY Colors the packets according to the current list of color filters, but does not close the dialog. SAVE Saves the current list of color filters in your personal colorfilters file. Unless you do this they will not be used the next time you start Ethereal. REVERT Deletes your personal colorfilters file, reloads the global colorfilters file, if any, and closes the dialog. EXPORT Allows you to choose a file in which to save the current list of color filters. You may also choose to save only the selected filters. A button is provided to save the filters in the global colorfilter file, (you must have sufficient permissions to write this file, of course.) IMPORT Allows you to choose a file containing color filters which are then added to the bottom of the current list. All the added filters are selected, so they may be moved to the correct position in the list as a group. To avoid confusion all filters are unselected before the new filters are imported. A button is provided to load the filters from the global colorfilter file. CANCEL Closes the dialog without changing the coloration of the packets. Note that changes you have made to the current list of color filters are not undone.
- Follow-Ups:
- Re: [Ethereal-dev] Phase two of color filters update
- From: Guy Harris
- Re: [Ethereal-dev] Phase two of color filters update
- References:
- [Ethereal-dev] Phase two of color filters update
- From: Richard Urwin
- Re: [Ethereal-dev] Phase two of color filters update
- From: Richard Urwin
- Re: [Ethereal-dev] Phase two of color filters update
- From: Guy Harris
- [Ethereal-dev] Phase two of color filters update
- Prev by Date: Re: [Ethereal-dev] Typo in packet-eth.c
- Next by Date: [Ethereal-dev] Multiple highlight bug
- Previous by thread: Re: [Ethereal-dev] Phase two of color filters update
- Next by thread: Re: [Ethereal-dev] Phase two of color filters update
- Index(es):