code cleanup: use common prefix for all functions in color_filters.h
svn path=/trunk/; revision=13910
This commit is contained in:
parent
5ef0665d34
commit
ccff84dbdf
|
@ -55,7 +55,7 @@ GSList *removed_filter_list = NULL;
|
|||
* This way, unmarking and marking a packet which matches a now removed
|
||||
* color filter will still be colored correctly as the color filter is
|
||||
* still reachable. */
|
||||
void remove_color_filter(color_filter_t *colorf)
|
||||
void color_filter_remove(color_filter_t *colorf)
|
||||
{
|
||||
/* Remove colorf from the list of color filters */
|
||||
color_filter_list = g_slist_remove(color_filter_list, colorf);
|
||||
|
@ -98,7 +98,7 @@ delete_all_color_filters (void)
|
|||
|
||||
/* Initialize the filter structures (reading from file) for general running, including app startup */
|
||||
void
|
||||
colfilter_init(void)
|
||||
color_filters_init(void)
|
||||
{
|
||||
delete_all_color_filters();
|
||||
if (!read_filters())
|
||||
|
@ -107,7 +107,7 @@ colfilter_init(void)
|
|||
|
||||
/* Create a new filter */
|
||||
color_filter_t *
|
||||
new_color_filter(gchar *name, /* The name of the filter to create */
|
||||
color_filter_new(gchar *name, /* The name of the filter to create */
|
||||
gchar *filter_string, /* The string representing the filter */
|
||||
color_t *bg_color, /* The background color */
|
||||
color_t *fg_color) /* The foreground color */
|
||||
|
@ -139,7 +139,7 @@ prime_edt(gpointer data, gpointer user_data)
|
|||
/* Prime the epan_dissect_t with all the compiler
|
||||
* color filters in 'color_filter_list'. */
|
||||
void
|
||||
filter_list_prime_edt(epan_dissect_t *edt)
|
||||
color_filters_prime_edt(epan_dissect_t *edt)
|
||||
{
|
||||
g_slist_foreach(color_filter_list, prime_edt, edt);
|
||||
}
|
||||
|
@ -276,12 +276,12 @@ read_filters_file(FILE *f, gpointer arg)
|
|||
continue;
|
||||
}
|
||||
|
||||
colorf = new_color_filter(name, filter_exp, &bg_color,
|
||||
colorf = color_filter_new(name, filter_exp, &bg_color,
|
||||
&fg_color);
|
||||
colorf->c_colorfilter = temp_dfilter;
|
||||
|
||||
if (arg != NULL)
|
||||
color_add_filter_cb (colorf, arg);
|
||||
color_filter_add_cb (colorf, arg);
|
||||
} /* if sscanf */
|
||||
|
||||
skip_end_of_line = TRUE;
|
||||
|
@ -348,7 +348,7 @@ read_global_filters(void)
|
|||
|
||||
/* read filters from some other filter file (import) */
|
||||
gboolean
|
||||
read_other_filters(gchar *path, gpointer arg)
|
||||
color_filters_import(gchar *path, gpointer arg)
|
||||
{
|
||||
FILE *f;
|
||||
gboolean ret;
|
||||
|
@ -408,7 +408,7 @@ write_filters_file(FILE *f, gboolean only_marked)
|
|||
|
||||
/* save filters in users filter file */
|
||||
gboolean
|
||||
write_filters(void)
|
||||
color_filters_write(void)
|
||||
{
|
||||
gchar *pf_dir_path;
|
||||
const gchar *path;
|
||||
|
@ -438,7 +438,7 @@ write_filters(void)
|
|||
|
||||
/* delete users filter file and reload global filters */
|
||||
gboolean
|
||||
revert_filters(void)
|
||||
color_filters_revert(void)
|
||||
{
|
||||
gchar *pf_dir_path;
|
||||
gchar *path;
|
||||
|
@ -462,14 +462,14 @@ revert_filters(void)
|
|||
g_free(path);
|
||||
|
||||
/* Reload the (global) filters - Note: this does not update the dialog. */
|
||||
colfilter_init();
|
||||
color_filters_init();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* save filters in some other filter file (export) */
|
||||
gboolean
|
||||
write_other_filters(gchar *path, gboolean only_marked)
|
||||
color_filters_export(gchar *path, gboolean only_marked)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
|
|
|
@ -42,22 +42,41 @@ typedef struct _color_filter {
|
|||
|
||||
/* List of all color filters. */
|
||||
extern GSList *color_filter_list;
|
||||
extern GSList *removed_filter_list;
|
||||
|
||||
/** Init the color filters. */
|
||||
void colfilter_init(void);
|
||||
void color_filters_init(void);
|
||||
|
||||
/** Save filters in users filter file.
|
||||
*
|
||||
* @return TRUE if write succeeded
|
||||
*/
|
||||
gboolean write_filters(void);
|
||||
gboolean color_filters_write(void);
|
||||
|
||||
/** Delete users filter file and reload global filters.
|
||||
*
|
||||
* @return TRUE if write succeeded
|
||||
*/
|
||||
gboolean revert_filters(void);
|
||||
gboolean color_filters_revert(void);
|
||||
|
||||
/** Load filters (import) from some other filter file.
|
||||
*
|
||||
* @param path the path to the filter file
|
||||
* @param arg the color filter widget
|
||||
* @return TRUE, if read succeeded
|
||||
*/
|
||||
gboolean color_filters_import(gchar *path, gpointer arg);
|
||||
|
||||
/** Save filters (export) to some other filter file.
|
||||
*
|
||||
* @param path the path to the filter file
|
||||
* @param only_marked TRUE if only the marked filters should be saved
|
||||
* @return TRUE, if write succeeded
|
||||
*/
|
||||
gboolean color_filters_export(gchar *path, gboolean only_marked);
|
||||
|
||||
/** @todo don't what this function is for, please add explanation
|
||||
*/
|
||||
void color_filters_prime_edt(epan_dissect_t *edt);
|
||||
|
||||
/** Create a new color filter.
|
||||
*
|
||||
|
@ -67,38 +86,20 @@ gboolean revert_filters(void);
|
|||
* @param fg_color foreground color
|
||||
* @return the new color filter
|
||||
*/
|
||||
color_filter_t *new_color_filter(gchar *name, gchar *filter_string,
|
||||
color_filter_t *color_filter_new(gchar *name, gchar *filter_string,
|
||||
color_t *bg_color, color_t *fg_color);
|
||||
|
||||
/** Remove the color filter.
|
||||
*
|
||||
* @param colorf the color filter to be removed
|
||||
*/
|
||||
void remove_color_filter(color_filter_t *colorf);
|
||||
|
||||
/** Load filters from some other filter file.
|
||||
*
|
||||
* @param path the path to the filter file
|
||||
* @param arg the color filter widget
|
||||
* @return TRUE, if read succeeded
|
||||
*/
|
||||
gboolean read_other_filters(gchar *path, gpointer arg);
|
||||
|
||||
/** Save filters to some other filter file.
|
||||
*
|
||||
* @param path the path to the filter file
|
||||
* @param only_marked TRUE if only the marked filters should be saved
|
||||
* @return TRUE, if write succeeded
|
||||
*/
|
||||
gboolean write_other_filters(gchar *path, gboolean only_marked);
|
||||
void color_filter_remove(color_filter_t *colorf);
|
||||
|
||||
/** Add a color filter.
|
||||
*
|
||||
* @param colorf the new color filter
|
||||
* @param arg the color filter widget
|
||||
*/
|
||||
void color_add_filter_cb (color_filter_t *colorf, gpointer arg);
|
||||
|
||||
void filter_list_prime_edt(epan_dissect_t *edt);
|
||||
void color_filter_add_cb (color_filter_t *colorf, gpointer arg);
|
||||
|
||||
#endif
|
||||
|
|
2
file.c
2
file.c
|
@ -789,7 +789,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
|||
epan_dissect_prime_dfilter(edt, cf->dfcode);
|
||||
}
|
||||
if (color_filter_list) {
|
||||
filter_list_prime_edt(edt);
|
||||
color_filters_prime_edt(edt);
|
||||
}
|
||||
tap_queue_init(edt);
|
||||
epan_dissect_run(edt, pseudo_header, buf, fdata, &cf->cinfo);
|
||||
|
|
|
@ -869,7 +869,7 @@ color_add_colorf(GtkWidget *color_filters, color_filter_t *colorf)
|
|||
}
|
||||
|
||||
void
|
||||
color_add_filter_cb (color_filter_t *colorf, gpointer arg)
|
||||
color_filter_add_cb(color_filter_t *colorf, gpointer arg)
|
||||
{
|
||||
GtkWidget *color_filters = arg;
|
||||
|
||||
|
@ -926,7 +926,7 @@ create_new_color_filter(GtkButton *button, char *filter)
|
|||
style = gtk_widget_get_style(packet_list);
|
||||
gdkcolor_to_color_t(&bg_color, &style->base[GTK_STATE_NORMAL]);
|
||||
gdkcolor_to_color_t(&fg_color, &style->text[GTK_STATE_NORMAL]);
|
||||
colorf = new_color_filter("name", filter, &bg_color, &fg_color); /* Adds at end! */
|
||||
colorf = color_filter_new("name", filter, &bg_color, &fg_color); /* Adds at end! */
|
||||
|
||||
color_add_colorf(color_filters, colorf);
|
||||
|
||||
|
@ -986,7 +986,7 @@ color_delete(gint row, GtkWidget *color_filters)
|
|||
window_destroy(colorf->edit_dialog);
|
||||
|
||||
/* Remove the color filter from the list of color filters. */
|
||||
remove_color_filter(colorf);
|
||||
color_filter_remove(colorf);
|
||||
|
||||
/* If we grab the focus after updating the selection, the first
|
||||
* row is always selected, so we do it before */
|
||||
|
@ -1004,7 +1004,7 @@ color_delete(gint row, GtkWidget *color_filters)
|
|||
window_destroy(colorf->edit_dialog);
|
||||
|
||||
/* Remove the color filter from the list of color filters. */
|
||||
remove_color_filter(colorf);
|
||||
color_filter_remove(colorf);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -1050,7 +1050,7 @@ color_delete_cb(GtkWidget *widget, gpointer user_data _U_)
|
|||
static void
|
||||
color_save_cb(GtkButton *button _U_, gpointer user_data _U_)
|
||||
{
|
||||
if (!write_filters())
|
||||
if (!color_filters_write())
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open filter file: %s", strerror(errno));
|
||||
}
|
||||
|
@ -1068,7 +1068,7 @@ color_clear_cmd(GtkWidget *widget)
|
|||
color_delete (num_of_filters-1, color_filters);
|
||||
}
|
||||
|
||||
if (!revert_filters())
|
||||
if (!color_filters_revert())
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not delete filter file: %s", strerror(errno));
|
||||
|
||||
|
|
|
@ -1624,7 +1624,7 @@ file_color_import_ok_cb(GtkWidget *w, gpointer fs) {
|
|||
gchar *cf_name, *s;
|
||||
gpointer argument;
|
||||
|
||||
argument = OBJECT_GET_DATA(w, ARGUMENT_CL); /* to be passed back into read_other_filters */
|
||||
argument = OBJECT_GET_DATA(w, ARGUMENT_CL); /* to be passed back into color_filters_import */
|
||||
|
||||
#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
|
||||
cf_name = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)));
|
||||
|
@ -1635,16 +1635,16 @@ file_color_import_ok_cb(GtkWidget *w, gpointer fs) {
|
|||
Check whether they did. */
|
||||
if (test_for_directory(cf_name) == EISDIR) {
|
||||
/* It's a directory - set the file selection box to display that
|
||||
directory, don't try to open the directory as a capture file. */
|
||||
directory, don't try to open the directory as a color filter file. */
|
||||
set_last_open_dir(cf_name);
|
||||
g_free(cf_name);
|
||||
file_selection_set_current_folder(fs, get_last_open_dir());
|
||||
return;
|
||||
}
|
||||
|
||||
/* Try to open the capture file. */
|
||||
/* Try to open the color filter file. */
|
||||
|
||||
if (!read_other_filters(cf_name, argument)) {
|
||||
if (!color_filters_import(cf_name, argument)) {
|
||||
/* We couldn't open it; don't dismiss the open dialog box,
|
||||
just leave it around so that the user can, after they
|
||||
dismiss the alert box popped up for the open error,
|
||||
|
@ -1796,7 +1796,7 @@ file_color_export_ok_cb(GtkWidget *w _U_, gpointer fs) {
|
|||
/* Write out the filters (all, or only the ones that are currently
|
||||
displayed or marked) to the file with the specified name. */
|
||||
|
||||
if (!write_other_filters(cf_name, color_marked))
|
||||
if (!color_filters_export(cf_name, color_marked))
|
||||
{
|
||||
/* The write failed; don't dismiss the open dialog box,
|
||||
just leave it around so that the user can, after they
|
||||
|
|
|
@ -2284,7 +2284,7 @@ main(int argc, char *argv[])
|
|||
dnd_init(top_level);
|
||||
|
||||
colors_init();
|
||||
colfilter_init();
|
||||
color_filters_init();
|
||||
decode_as_init();
|
||||
|
||||
/* the window can be sized only, if it's not already shown, so do it now! */
|
||||
|
|
Loading…
Reference in New Issue