From 9e6c7b11ae8eac1bcf50fc904e2e426f7c9d28f3 Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Tue, 3 Oct 2006 18:39:36 +0000 Subject: Implement a real "Cancel" button for the coloring rules dialog - this was a hard one! It seems to be working without bugs and as designed now. As this was a huge internal change, new bugs are very probable - please report. The implementation isn't still perfect, a new dialog internal list could possibly be removed again. However, I want to check in at this condition, just in case I make things worse - again. svn path=/trunk/; revision=19413 --- color_filters.h | 126 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 43 deletions(-) (limited to 'color_filters.h') diff --git a/color_filters.h b/color_filters.h index 50e32e3a42..b9b7d788b8 100644 --- a/color_filters.h +++ b/color_filters.h @@ -34,76 +34,111 @@ typedef struct _color_filter { gchar *filter_text; /* text of the filter expression */ color_t bg_color; /* background color for packets that match */ color_t fg_color; /* foreground color for packets that match */ + gboolean selected; /* set if the filter is selected in the color dialog box */ + + /* only used inside of color_filters.c */ dfilter_t *c_colorfilter; /* compiled filter expression */ + + /* only used outside of color_filters.c (beside init) */ void *edit_dialog; /* if filter is being edited, dialog * box for it */ - gboolean selected; /* set if the filter is selected in the color dialog box */ } color_filter_t; -/* List of all color filters. */ -extern GSList *color_filter_list; -/** Init the color filters. */ +/** Init the color filters (incl. initial read from file). */ void color_filters_init(void); -/** Save filters in users filter file. + + +/** Color filters currently used? * - * @return TRUE if write succeeded + * @return TRUE, if filters are used */ -gboolean color_filters_write(void); +gboolean color_filters_used(void); -/** Delete users filter file and reload global filters. +/** En-/disable color filters * - * @return TRUE if write succeeded + * @param enable TRUE to enable (default) */ -gboolean color_filters_revert(void); +void +color_filters_enable(gboolean enable); + + + +/* Prime the epan_dissect_t with all the compiler + * color filters of the current filter list. + * + * @param the epan dissector details + */ +void color_filters_prime_edt(epan_dissect_t *edt); + +/** Colorize a specific packet. + * + * @param row the row in the packet list + * @param edt the dissected packet + * @return the matching color filter or NULL + */ +color_filter_t * +color_filters_colorize_packet(gint row, epan_dissect_t *edt); + + + +/** Clone the currently active filter list. + * + * @param user_data will be returned by each call to to color_filter_add_cb() + */ +void color_filters_clone(gpointer user_data); /** Load filters (import) from some other filter file. * - * @param path the path to the filter file - * @param arg the color filter widget + * @param path the path to the import file + * @param user_data will be returned by each call to to color_filter_add_cb() * @return TRUE, if read succeeded */ -gboolean color_filters_import(gchar *path, gpointer arg); +gboolean color_filters_import(gchar *path, gpointer user_data); -/** Save filters (export) to some other filter file. +/** Read filters from the global filter file (not the users file). * - * @param path the path to the filter file - * @param only_selected TRUE if only the selected filters should be saved - * @return TRUE, if write succeeded + * @param user_data will be returned by each call to to color_filter_add_cb() + * @return TRUE, if read succeeded */ -gboolean color_filters_export(gchar *path, gboolean only_selected); +gboolean color_filters_read_globals(gpointer user_data); -/* Prime the epan_dissect_t with all the compiler - * color filters in 'color_filter_list'. +/** A color filter was added (while importing). + * (color_filters.c calls this for every filter coming in) * - * @param the epan dissector details + * @param colorf the new color filter + * @param user_data from caller */ -void color_filters_prime_edt(epan_dissect_t *edt); +void color_filter_add_cb (color_filter_t *colorf, gpointer user_data); -/** Color filters currently used? + + +/** Apply a changed filter list. * - * @return TRUE, if filters are used + * @param cfl the filter list to apply */ -gboolean color_filters_used(void); +void color_filters_apply(GSList *cfl); -/** En-/disable color filters +/** Save filters in users filter file. * - * @param enable TRUE to enable (default) + * @param cfl the filter list to write + * @return TRUE if write succeeded */ -void -color_filters_enable(gboolean enable); +gboolean color_filters_write(GSList *cfl); -/** Colorize a specific packet. +/** Save filters (export) to some other filter file. * - * @param row the row in the packet list - * @param edt the dissected packet - * @return the matching color filter or NULL + * @param path the path to the filter file + * @param cfl the filter list to write + * @param only_selected TRUE if only the selected filters should be saved + * @return TRUE, if write succeeded */ -color_filter_t * -color_filters_colorize_packet(gint row, epan_dissect_t *edt); +gboolean color_filters_export(gchar *path, GSList *cfl, gboolean only_selected); + + -/** Create a new color filter. +/** Create a new color filter (g_malloc'ed). * * @param name the name of the filter * @param filter_string the filter string @@ -111,20 +146,25 @@ color_filters_colorize_packet(gint row, epan_dissect_t *edt); * @param fg_color foreground color * @return the new color filter */ -color_filter_t *color_filter_new(const gchar *name, const gchar *filter_string, +color_filter_t *color_filter_new( + const gchar *name, const gchar *filter_string, color_t *bg_color, color_t *fg_color); -/** Remove the color filter. +/** Delete a single color filter (g_free'ed). * * @param colorf the color filter to be removed */ -void color_filter_remove(color_filter_t *colorf); +void color_filter_delete(color_filter_t *colorf); + + -/** A color filter was added (from import). + +/** Delete a filter list including all entries. * - * @param colorf the new color filter - * @param arg the color filter widget + * @param cfl the filter list to delete */ -void color_filter_add_cb (color_filter_t *colorf, gpointer arg); +void color_filter_list_delete(GSList **cfl); + + #endif -- cgit v1.2.3