aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2010-10-12 16:42:02 +0000
committerBill Meier <wmeier@newsguy.com>2010-10-12 16:42:02 +0000
commit2d3abb5cec7bce8618304c2d57b768e95324a8e1 (patch)
tree85603bc3d2e067e3a4bc2750899b3dab185cf2be
parentc004d573612b85732ee27241ec7bb54cb60bf1db (diff)
Minor cleanup of the global name space:
- Define some vars as static; - Rename some externs to be less generic; Also: cleanup some whitespace. svn path=/trunk/; revision=34489
-rw-r--r--gtk/color_dlg.c251
-rw-r--r--gtk/color_dlg.h3
-rw-r--r--gtk/color_edit_dlg.c505
-rw-r--r--gtk/color_edit_dlg.h3
4 files changed, 382 insertions, 380 deletions
diff --git a/gtk/color_dlg.c b/gtk/color_dlg.c
index 13f5ea0281..868ee492df 100644
--- a/gtk/color_dlg.c
+++ b/gtk/color_dlg.c
@@ -51,9 +51,9 @@
#include "gtk/gtkglobals.h"
#include "gtk/help_dlg.h"
#include "gtk/color_edit_dlg.h"
-#ifdef NEW_PACKET_LIST
-#include "gtk/new_packet_list.h"
-#endif /* NEW_PACKET_LIST */
+#ifdef NEW_PACKET_LIST
+#include "gtk/new_packet_list.h"
+#endif /* NEW_PACKET_LIST */
#define BUTTON_SIZE_X -1
@@ -83,9 +83,10 @@ static void color_export_cb(GtkButton *button, gpointer user_data );
static GtkWidget *colorize_win;
-gint num_of_filters; /* number of filters being displayed */
-gint row_selected; /* row in color_filters that is selected */
-gboolean row_is_moving = FALSE;
+gint color_dlg_num_of_filters; /* number of filters being displayed */
+gint color_dlg_row_selected; /* row in color_filters that is selected */
+
+static gboolean row_is_moving = FALSE;
/* This is a list of all current color filters in the dialog
* (copied from color_filters.c and edited with the dialog).
@@ -211,8 +212,8 @@ colorize_dialog_new (char *filter)
- num_of_filters = 0;
- row_selected = -1; /* no row selected */
+ color_dlg_num_of_filters = 0;
+ color_dlg_row_selected = -1; /* no row selected */
tooltips = gtk_tooltips_new ();
/* Resizing of the dialog window is now reasonably done.
@@ -307,12 +308,12 @@ colorize_dialog_new (char *filter)
/* the list store contains : filter name, filter string, foreground
* color, background color, pointer to color filter */
- store = gtk_list_store_new(6,
- G_TYPE_STRING,
+ store = gtk_list_store_new(6,
+ G_TYPE_STRING,
G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
G_TYPE_POINTER);
color_filters = tree_view_new(GTK_TREE_MODEL(store));
g_object_unref(store);
@@ -461,7 +462,7 @@ static void move_this_row (GtkWidget *color_filters,
g_assert(amount == +1 || amount == -1);
g_assert(amount == +1 || filter_number > 0);
- g_assert(amount == -1 || filter_number < num_of_filters - 1);
+ g_assert(amount == -1 || filter_number < color_dlg_num_of_filters - 1);
row_is_moving = TRUE;
model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
@@ -476,12 +477,12 @@ static void move_this_row (GtkWidget *color_filters,
else
gtk_list_store_insert_after(GTK_LIST_STORE(model), &iter1, &iter2);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter1,
- 0, name,
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter1,
+ 0, name,
1, string,
- 2, fg_str,
- 3, bg_str,
- 4, disabled,
+ 2, fg_str,
+ 3, bg_str,
+ 4, disabled,
5, colorf, -1);
g_free(name);
@@ -515,7 +516,7 @@ color_filter_up_cb(GtkButton *button, gpointer user_data _U_)
amount = -1;
color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(button), COLOR_FILTERS_CL);
- for (filter_number = 0; filter_number < num_of_filters; filter_number++)
+ for (filter_number = 0; filter_number < color_dlg_num_of_filters; filter_number++)
{
model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
gtk_tree_model_iter_nth_child(model, &iter, NULL, filter_number);
@@ -540,7 +541,7 @@ color_filter_down_cb(GtkButton *button, gpointer user_data _U_)
amount = +1;
color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(button), COLOR_FILTERS_CL);
- for (filter_number = num_of_filters - 1; filter_number >= 0; filter_number--)
+ for (filter_number = color_dlg_num_of_filters - 1; filter_number >= 0; filter_number--)
{
model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
gtk_tree_model_iter_nth_child(model, &iter, NULL, filter_number);
@@ -553,42 +554,42 @@ color_filter_down_cb(GtkButton *button, gpointer user_data _U_)
struct remember_data
{
- gint count; /* count of selected filters */
- gboolean first_selected; /* true if the first filter in the list is selected */
- gboolean last_selected; /* true if the last filter in the list is selected */
- gboolean all_enabled; /* true if all selected coloring rules are enabled */
- gboolean all_disabled; /* true if all selected coloring rules are disabled */
- gpointer color_filters;
+ gint count; /* count of selected filters */
+ gboolean first_selected; /* true if the first filter in the list is selected */
+ gboolean last_selected; /* true if the last filter in the list is selected */
+ gboolean all_enabled; /* true if all selected coloring rules are enabled */
+ gboolean all_disabled; /* true if all selected coloring rules are disabled */
+ gpointer color_filters;
};
/* called for each selected row in the tree.
-*/
+ */
static void remember_this_row (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer arg)
{
- gint *path_index;
- color_filter_t *colorf;
- struct remember_data *data = arg;
+ gint *path_index;
+ color_filter_t *colorf;
+ struct remember_data *data = arg;
- gtk_tree_model_get(model, iter, 5, &colorf, -1);
- colorf->selected = TRUE;
+ gtk_tree_model_get(model, iter, 5, &colorf, -1);
+ colorf->selected = TRUE;
- data->all_enabled &= (!colorf->disabled);
- data->all_disabled &= colorf->disabled;
+ data->all_enabled &= (!colorf->disabled);
+ data->all_disabled &= colorf->disabled;
- 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];
+ path_index = gtk_tree_path_get_indices(path); /* not to be freed */
+ if (path_index == NULL) /* can return NULL according to API doc.*/
+ {
+ return;
+ }
+ color_dlg_row_selected = path_index[0];
- if (row_selected == 0)
- data->first_selected = TRUE;
- if (row_selected == num_of_filters - 1)
- data->last_selected = TRUE;
+ if (color_dlg_row_selected == 0)
+ data->first_selected = TRUE;
+ if (color_dlg_row_selected == color_dlg_num_of_filters - 1)
+ data->last_selected = TRUE;
- data->count++;
+ data->count++;
- gtk_tree_view_scroll_to_cell(data->color_filters, path, NULL, FALSE, 0.0f, 0.0f);
+ gtk_tree_view_scroll_to_cell(data->color_filters, path, NULL, FALSE, 0.0f, 0.0f);
}
/* clear the selection flag of this filter */
@@ -604,71 +605,71 @@ clear_select_flag(gpointer filter_arg, gpointer arg _U_)
static void
remember_selected_row(GtkTreeSelection *sel, gpointer color_filters)
{
- GtkWidget *button;
- struct remember_data data;
-
- data.first_selected = data.last_selected = FALSE;
- data.all_enabled = data.all_disabled = TRUE;
- data.count = 0;
- data.color_filters = color_filters;
-
- g_slist_foreach(color_filter_edit_list, clear_select_flag, NULL);
- gtk_tree_selection_selected_foreach(sel,remember_this_row, &data);
-
- if (data.count > 0)
- {
- /*
- * One or more rows are selected, so we can operate on them.
- */
-
- /* We can only edit if there is exactly one filter selected */
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_EDIT_LB);
- gtk_widget_set_sensitive (button, data.count == 1);
-
- /* We can enable any number of filters */
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_ENABLE_LB);
- gtk_widget_set_sensitive (button, !data.all_enabled);
-
- /* We can disable any number of filters */
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DISABLE_LB);
- gtk_widget_set_sensitive (button, !data.all_disabled);
-
- /* We can delete any number of filters */
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DELETE_LB);
- gtk_widget_set_sensitive (button, TRUE);
-
- /*
- * We can move them up *if* one of them isn't the top row,
- * and move them down *if* one of them isn't the bottom row.
- */
+ GtkWidget *button;
+ struct remember_data data;
+
+ data.first_selected = data.last_selected = FALSE;
+ data.all_enabled = data.all_disabled = TRUE;
+ data.count = 0;
+ data.color_filters = color_filters;
+
+ g_slist_foreach(color_filter_edit_list, clear_select_flag, NULL);
+ gtk_tree_selection_selected_foreach(sel,remember_this_row, &data);
+
+ if (data.count > 0)
+ {
+ /*
+ * One or more rows are selected, so we can operate on them.
+ */
+
+ /* We can only edit if there is exactly one filter selected */
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_EDIT_LB);
+ gtk_widget_set_sensitive (button, data.count == 1);
+
+ /* We can enable any number of filters */
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_ENABLE_LB);
+ gtk_widget_set_sensitive (button, !data.all_enabled);
+
+ /* We can disable any number of filters */
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DISABLE_LB);
+ gtk_widget_set_sensitive (button, !data.all_disabled);
+
+ /* We can delete any number of filters */
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DELETE_LB);
+ gtk_widget_set_sensitive (button, TRUE);
+
+ /*
+ * We can move them up *if* one of them isn't the top row,
+ * and move them down *if* one of them isn't the bottom row.
+ */
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_UP_LB);
+ gtk_widget_set_sensitive(button, !data.first_selected);
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DOWN_LB);
+ gtk_widget_set_sensitive(button, !data.last_selected);
+ }
+ else
+ {
+ color_dlg_row_selected = -1;
+
+ /*
+ * No row is selected, so we can't do operations that affect the
+ * selected row.
+ */
+ if (!row_is_moving) {
button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_UP_LB);
- gtk_widget_set_sensitive(button, !data.first_selected);
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DOWN_LB);
- gtk_widget_set_sensitive(button, !data.last_selected);
- }
- else
- {
- row_selected = -1;
-
- /*
- * No row is selected, so we can't do operations that affect the
- * selected row.
- */
- if (!row_is_moving) {
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_UP_LB);
- gtk_widget_set_sensitive (button, FALSE);
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DOWN_LB);
- gtk_widget_set_sensitive (button, FALSE);
- }
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_EDIT_LB);
gtk_widget_set_sensitive (button, FALSE);
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_ENABLE_LB);
- gtk_widget_set_sensitive (button, FALSE);
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DISABLE_LB);
- gtk_widget_set_sensitive (button, FALSE);
- button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DELETE_LB);
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DOWN_LB);
gtk_widget_set_sensitive (button, FALSE);
}
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_EDIT_LB);
+ gtk_widget_set_sensitive (button, FALSE);
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_ENABLE_LB);
+ gtk_widget_set_sensitive (button, FALSE);
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DISABLE_LB);
+ gtk_widget_set_sensitive (button, FALSE);
+ button = (GtkWidget *)g_object_get_data(G_OBJECT(color_filters), COLOR_DELETE_LB);
+ gtk_widget_set_sensitive (button, FALSE);
+ }
}
@@ -732,15 +733,15 @@ add_filter_to_list(gpointer filter_arg, gpointer list_arg)
colorf->fg_color.red, colorf->fg_color.green, colorf->fg_color.blue);
g_snprintf(bg_str, sizeof(bg_str), "#%04X%04X%04X",
colorf->bg_color.red, colorf->bg_color.green, colorf->bg_color.blue);
- gtk_list_store_set(store, &iter,
+ gtk_list_store_set(store, &iter,
0, colorf->filter_name,
- 1, colorf->filter_text,
- 2, fg_str,
+ 1, colorf->filter_text,
+ 2, fg_str,
3, bg_str,
- 4, colorf->disabled,
+ 4, colorf->disabled,
5, colorf, -1);
color_filter_edit_list = g_slist_append(color_filter_edit_list, colorf);
- num_of_filters++;
+ color_dlg_num_of_filters++;
} else {
/* But keep the temporary ones too, so they can be added again
* when the user is done editing */
@@ -778,17 +779,17 @@ create_new_color_filter(GtkButton *button, const char *filter)
gtk_tree_selection_unselect_all (sel);
/* Use the default background and foreground colors as the colors. */
-#ifdef NEW_PACKET_LIST
- style = gtk_widget_get_style(new_packet_list_get_widget());
-#else
- style = gtk_widget_get_style(packet_list);
-#endif /* NEW_PACKET_LIST */
+#ifdef NEW_PACKET_LIST
+ style = gtk_widget_get_style(new_packet_list_get_widget());
+#else
+ style = gtk_widget_get_style(packet_list);
+#endif /* NEW_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 = color_filter_new("name", filter, &bg_color, &fg_color, FALSE);
add_filter_to_list(colorf, color_filters);
- select_row(color_filters, num_of_filters-1);
+ select_row(color_filters, color_dlg_num_of_filters-1);
/* open the edit dialog */
edit_color_filter_dialog(color_filters, TRUE /* is a new filter */);
@@ -812,7 +813,7 @@ color_edit_cb(GtkButton *button, gpointer user_data _U_)
GtkWidget *color_filters;
color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(button), COLOR_FILTERS_CL);
- g_assert(row_selected != -1);
+ g_assert(color_dlg_row_selected != -1);
edit_color_filter_dialog(color_filters, FALSE /* is not a new filter */);
}
@@ -846,7 +847,7 @@ color_disable_cb(GtkWidget *widget, gboolean action_disable)
color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(widget), COLOR_FILTERS_CL);
- for (filter_number = 0; filter_number < num_of_filters; filter_number++)
+ for (filter_number = 0; filter_number < color_dlg_num_of_filters; filter_number++)
{
model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
gtk_tree_model_iter_nth_child(model, &iter, NULL, filter_number);
@@ -854,7 +855,7 @@ color_disable_cb(GtkWidget *widget, gboolean action_disable)
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(color_filters));
if (gtk_tree_selection_iter_is_selected(sel, &iter)) {
colorf->disabled = action_disable;
- gtk_list_store_set(GTK_LIST_STORE(model), &iter,
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter,
4, action_disable, -1);
}
}
@@ -881,7 +882,7 @@ color_delete_single(gint row, GtkWidget *color_filters)
/* Remove this color filter from the CList displaying the
color filters. */
gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- num_of_filters--;
+ color_dlg_num_of_filters--;
/* Destroy any "Edit color filter" dialog boxes editing it. */
if (colorf->edit_dialog != NULL)
@@ -957,9 +958,9 @@ color_clear_cmd(GtkWidget *widget)
color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(widget), COLOR_FILTERS_CL);
- while (num_of_filters > 0)
+ while (color_dlg_num_of_filters > 0)
{
- color_delete_single (num_of_filters-1, color_filters);
+ color_delete_single (color_dlg_num_of_filters-1, color_filters);
}
/* try to read the global filters */
diff --git a/gtk/color_dlg.h b/gtk/color_dlg.h
index caaf158806..4d98157ff0 100644
--- a/gtk/color_dlg.h
+++ b/gtk/color_dlg.h
@@ -30,6 +30,9 @@
* @ingroup dialog_group
*/
+extern gint color_dlg_num_of_filters; /* number of filters being displayed */
+extern gint color_dlg_row_selected; /* row in color_filters that is selected */
+
/** User requested the "Colorize Display" dialog box by menu or toolbar.
*
* @param widget parent widget (unused)
diff --git a/gtk/color_edit_dlg.c b/gtk/color_edit_dlg.c
index c534403d71..38b94b93c0 100644
--- a/gtk/color_edit_dlg.c
+++ b/gtk/color_edit_dlg.c
@@ -36,6 +36,7 @@
#include "../color_filters.h"
#include "../simple_dialog.h"
+#include "gtk/color_dlg.h"
#include "gtk/color_utils.h"
#include "gtk/dlg_utils.h"
#include "gtk/gui_utils.h"
@@ -54,7 +55,7 @@ static void edit_color_filter_destroy_cb(GObject *object, gpointer user_data);
static void edit_color_filter_fg_cb(GtkButton *button, gpointer user_data);
static void edit_color_filter_bg_cb(GtkButton *button, gpointer user_data);
/*
-static void edit_disabled_cb_cb(GtkButton *button, gpointer user_data);
+ static void edit_disabled_cb_cb(GtkButton *button, gpointer user_data);
*/
static void edit_color_filter_ok_cb(GtkButton *button, gpointer user_data);
static void edit_new_color_filter_cancel_cb(GtkButton *button, gpointer user_data);
@@ -64,13 +65,13 @@ static void color_sel_ok_cb(GtkButton *button, gpointer user_data);
static void color_sel_cancel_cb(GtkObject *object, gpointer user_data);
-#define COLOR_FILTERS_CL "color_filters_cl"
-#define COLOR_FILTER "color_filter"
-#define COLOR_FILTER_NAME_TE "color_filter_name_te"
-#define COLOR_FILTER_TEXT_TE "color_filter_text_te"
-#define COLOR_SELECTION_FG "color_selection_fg"
-#define COLOR_SELECTION_BG "color_selection_bg"
-#define COLOR_SELECTION_PARENT "color_selection_parent"
+#define COLOR_FILTERS_CL "color_filters_cl"
+#define COLOR_FILTER "color_filter"
+#define COLOR_FILTER_NAME_TE "color_filter_name_te"
+#define COLOR_FILTER_TEXT_TE "color_filter_text_te"
+#define COLOR_SELECTION_FG "color_selection_fg"
+#define COLOR_SELECTION_BG "color_selection_bg"
+#define COLOR_SELECTION_PARENT "color_selection_parent"
/* XXX - we don't forbid having more than one "Edit color filter" dialog
open, so these shouldn't be global. */
@@ -83,7 +84,7 @@ static void
filter_expr_cb(GtkWidget *w _U_, gpointer filter_te)
{
- dfilter_expr_dlg_new(GTK_WIDGET(filter_te));
+ dfilter_expr_dlg_new(GTK_WIDGET(filter_te));
}
@@ -93,188 +94,188 @@ void
edit_color_filter_dialog(GtkWidget *color_filters,
gboolean is_new_filter)
{
- color_filter_t *colorf;
- GtkWidget *edit_dialog;
- GtkWidget *dialog_vbox;
- GtkTooltips *tooltips;
- GdkColor bg_color, fg_color;
+ color_filter_t *colorf;
+ GtkWidget *edit_dialog;
+ GtkWidget *dialog_vbox;
+ GtkTooltips *tooltips;
+ GdkColor bg_color, fg_color;
- GtkWidget *filter_fr;
- GtkWidget *filter_fr_vbox;
- GtkWidget *filter_name_hbox;
- GtkWidget *color_filter_name;
- GtkWidget *filter_string_hbox;
- GtkWidget *add_expression_bt;
- GtkWidget *color_filter_text;
+ GtkWidget *filter_fr;
+ GtkWidget *filter_fr_vbox;
+ GtkWidget *filter_name_hbox;
+ GtkWidget *color_filter_name;
+ GtkWidget *filter_string_hbox;
+ GtkWidget *add_expression_bt;
+ GtkWidget *color_filter_text;
- GtkWidget *settings_hbox;
+ GtkWidget *settings_hbox;
- GtkWidget *colorize_fr;
- GtkWidget *colorize_hbox;
- GtkWidget *colorize_filter_fg;
- GtkWidget *colorize_filter_bg;
+ GtkWidget *colorize_fr;
+ GtkWidget *colorize_hbox;
+ GtkWidget *colorize_filter_fg;
+ GtkWidget *colorize_filter_bg;
- GtkWidget *status_fr;
- GtkWidget *status_vbox;
+ GtkWidget *status_fr;
+ GtkWidget *status_vbox;
- GtkWidget *bbox;
- GtkWidget *edit_color_filter_ok;
- GtkWidget *edit_color_filter_cancel;
+ GtkWidget *bbox;
+ GtkWidget *edit_color_filter_ok;
+ GtkWidget *edit_color_filter_cancel;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- 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, color_dlg_row_selected);
+ gtk_tree_model_get(model, &iter, 5, &colorf, -1);
+
+ if (colorf->edit_dialog != NULL) {
+ /* There's already an edit box open for this filter; reactivate it. */
+ reactivate_window(colorf->edit_dialog);
+ return;
+ }
- gtk_tree_model_iter_nth_child(model, &iter, NULL, row_selected);
- gtk_tree_model_get(model, &iter, 5, &colorf, -1);
+ tooltips = gtk_tooltips_new ();
- if (colorf->edit_dialog != NULL) {
- /* There's already an edit box open for this filter; reactivate it. */
- reactivate_window(colorf->edit_dialog);
- return;
- }
+ /* dialog window */
+ edit_dialog = dlg_conf_window_new ("Wireshark: Edit Color Filter");
+ gtk_window_set_default_size(GTK_WINDOW(edit_dialog), 500, -1);
+ g_object_set_data(G_OBJECT(edit_dialog), "edit_dialog", edit_dialog);
+ colorf->edit_dialog = edit_dialog;
- tooltips = gtk_tooltips_new ();
+ dialog_vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+ gtk_container_add (GTK_CONTAINER (edit_dialog), dialog_vbox);
- /* dialog window */
- edit_dialog = dlg_conf_window_new ("Wireshark: Edit Color Filter");
- gtk_window_set_default_size(GTK_WINDOW(edit_dialog), 500, -1);
- g_object_set_data(G_OBJECT(edit_dialog), "edit_dialog", edit_dialog);
- colorf->edit_dialog = edit_dialog;
+ /* Filter frame */
+ filter_fr = gtk_frame_new("Filter");
+ gtk_box_pack_start (GTK_BOX (dialog_vbox), filter_fr, FALSE, FALSE, 0);
- dialog_vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
- gtk_container_add (GTK_CONTAINER (edit_dialog), dialog_vbox);
+ filter_fr_vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (filter_fr_vbox), 5);
+ gtk_container_add(GTK_CONTAINER(filter_fr), filter_fr_vbox);
- /* Filter frame */
- filter_fr = gtk_frame_new("Filter");
- gtk_box_pack_start (GTK_BOX (dialog_vbox), filter_fr, FALSE, FALSE, 0);
+ /* filter name hbox */
+ filter_name_hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (filter_fr_vbox), filter_name_hbox, TRUE, FALSE, 3);
- filter_fr_vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (filter_fr_vbox), 5);
- gtk_container_add(GTK_CONTAINER(filter_fr), filter_fr_vbox);
+ color_filter_name = gtk_label_new (("Name: "));
+ gtk_box_pack_start (GTK_BOX (filter_name_hbox), color_filter_name, FALSE, FALSE, 0);
- /* filter name hbox */
- filter_name_hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (filter_fr_vbox), filter_name_hbox, TRUE, FALSE, 3);
+ filt_name_entry = gtk_entry_new ();
+ gtk_entry_set_text(GTK_ENTRY(filt_name_entry), colorf->filter_name);
- color_filter_name = gtk_label_new (("Name: "));
- gtk_box_pack_start (GTK_BOX (filter_name_hbox), color_filter_name, FALSE, FALSE, 0);
+ color_t_to_gdkcolor(&bg_color, &colorf->bg_color);
+ color_t_to_gdkcolor(&fg_color, &colorf->fg_color);
- filt_name_entry = gtk_entry_new ();
- gtk_entry_set_text(GTK_ENTRY(filt_name_entry), colorf->filter_name);
+ gtk_widget_modify_base(filt_name_entry, GTK_STATE_NORMAL, &bg_color);
+ gtk_widget_modify_text(filt_name_entry, GTK_STATE_NORMAL, &fg_color);
- color_t_to_gdkcolor(&bg_color, &colorf->bg_color);
- color_t_to_gdkcolor(&fg_color, &colorf->fg_color);
+ gtk_box_pack_start (GTK_BOX (filter_name_hbox), filt_name_entry, TRUE, TRUE, 0);
+ gtk_tooltips_set_tip (tooltips, filt_name_entry, ("This is the editable name of the filter. (No @ characters allowed.)"), NULL);
- gtk_widget_modify_base(filt_name_entry, GTK_STATE_NORMAL, &bg_color);
- gtk_widget_modify_text(filt_name_entry, GTK_STATE_NORMAL, &fg_color);
- gtk_box_pack_start (GTK_BOX (filter_name_hbox), filt_name_entry, TRUE, TRUE, 0);
- gtk_tooltips_set_tip (tooltips, filt_name_entry, ("This is the editable name of the filter. (No @ characters allowed.)"), NULL);
+ /* filter string hbox */
+ filter_string_hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (filter_fr_vbox), filter_string_hbox, TRUE, FALSE, 3);
+ color_filter_text = gtk_label_new (("String: "));
+ gtk_box_pack_start (GTK_BOX (filter_string_hbox), color_filter_text, FALSE, FALSE, 0);
- /* filter string hbox */
- filter_string_hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (filter_fr_vbox), filter_string_hbox, TRUE, FALSE, 3);
+ filt_text_entry = gtk_entry_new ();
+ g_signal_connect(filt_text_entry, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
+ g_object_set_data(G_OBJECT(filter_string_hbox), E_FILT_AUTOCOMP_PTR_KEY, NULL);
+ g_signal_connect(filt_text_entry, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
+ g_signal_connect(edit_dialog, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
+ gtk_entry_set_text(GTK_ENTRY(filt_text_entry), colorf->filter_text);
- color_filter_text = gtk_label_new (("String: "));
- gtk_box_pack_start (GTK_BOX (filter_string_hbox), color_filter_text, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (filter_string_hbox), filt_text_entry, TRUE, TRUE, 0);
+ gtk_tooltips_set_tip (tooltips, filt_text_entry, ("This is the editable text of the filter"), NULL);
- filt_text_entry = gtk_entry_new ();
- g_signal_connect(filt_text_entry, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
- g_object_set_data(G_OBJECT(filter_string_hbox), E_FILT_AUTOCOMP_PTR_KEY, NULL);
- g_signal_connect(filt_text_entry, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
- g_signal_connect(edit_dialog, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
- gtk_entry_set_text(GTK_ENTRY(filt_text_entry), colorf->filter_text);
+ /* Create the "Add Expression..." button, to pop up a dialog
+ for constructing filter comparison expressions. */
+ add_expression_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_ADD_EXPRESSION);
+ g_signal_connect(add_expression_bt, "clicked", G_CALLBACK(filter_expr_cb), filt_text_entry);
+ gtk_box_pack_start (GTK_BOX(filter_string_hbox), add_expression_bt, FALSE, FALSE, 3);
+ gtk_tooltips_set_tip (tooltips, add_expression_bt, ("Add an expression to the filter string"), NULL);
- gtk_box_pack_start (GTK_BOX (filter_string_hbox), filt_text_entry, TRUE, TRUE, 0);
- gtk_tooltips_set_tip (tooltips, filt_text_entry, ("This is the editable text of the filter"), NULL);
+ /* Show the (in)validity of the default filter string */
+ filter_te_syntax_check_cb(filt_text_entry, NULL);
- /* Create the "Add Expression..." button, to pop up a dialog
- for constructing filter comparison expressions. */
- add_expression_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_ADD_EXPRESSION);
- g_signal_connect(add_expression_bt, "clicked", G_CALLBACK(filter_expr_cb), filt_text_entry);
- gtk_box_pack_start (GTK_BOX(filter_string_hbox), add_expression_bt, FALSE, FALSE, 3);
- gtk_tooltips_set_tip (tooltips, add_expression_bt, ("Add an expression to the filter string"), NULL);
+ /* settings-hbox for "choose color frame" and "status frame" */
+ settings_hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox), settings_hbox, FALSE, FALSE, 0);
- /* Show the (in)validity of the default filter string */
- filter_te_syntax_check_cb(filt_text_entry, NULL);
+ /* choose color frame */
+ colorize_fr = gtk_frame_new("Display Colors");
+ gtk_box_pack_start (GTK_BOX (settings_hbox), colorize_fr, TRUE, TRUE, 0);
- /* settings-hbox for "choose color frame" and "status frame" */
- settings_hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (dialog_vbox), settings_hbox, FALSE, FALSE, 0);
+ colorize_hbox = gtk_hbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (colorize_hbox), 5);
+ gtk_container_add(GTK_CONTAINER(colorize_fr), colorize_hbox);
- /* choose color frame */
- colorize_fr = gtk_frame_new("Display Colors");
- gtk_box_pack_start (GTK_BOX (settings_hbox), colorize_fr, TRUE, TRUE, 0);
+ colorize_filter_fg = gtk_button_new_with_label (("Foreground Color..."));
+ gtk_box_pack_start (GTK_BOX (colorize_hbox), colorize_filter_fg, TRUE, FALSE, 0);
+ gtk_tooltips_set_tip (tooltips, colorize_filter_fg, ("Select foreground color for data display"), NULL);
- colorize_hbox = gtk_hbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (colorize_hbox), 5);
- gtk_container_add(GTK_CONTAINER(colorize_fr), colorize_hbox);
+ colorize_filter_bg = gtk_button_new_with_label (("Background Color..."));
+ gtk_box_pack_start (GTK_BOX (colorize_hbox), colorize_filter_bg, TRUE, FALSE, 0);
+ gtk_tooltips_set_tip (tooltips, colorize_filter_bg, ("Select background color for data display"), NULL);
- colorize_filter_fg = gtk_button_new_with_label (("Foreground Color..."));
- gtk_box_pack_start (GTK_BOX (colorize_hbox), colorize_filter_fg, TRUE, FALSE, 0);
- gtk_tooltips_set_tip (tooltips, colorize_filter_fg, ("Select foreground color for data display"), NULL);
+ /* status frame */
+ status_fr = gtk_frame_new("Status");
+ gtk_box_pack_start (GTK_BOX (settings_hbox), status_fr, TRUE, TRUE, 0);
- colorize_filter_bg = gtk_button_new_with_label (("Background Color..."));
- gtk_box_pack_start (GTK_BOX (colorize_hbox), colorize_filter_bg, TRUE, FALSE, 0);
- gtk_tooltips_set_tip (tooltips, colorize_filter_bg, ("Select background color for data display"), NULL);
+ status_vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (status_vbox), 5);
+ gtk_container_add(GTK_CONTAINER(status_fr), status_vbox);
- /* status frame */
- status_fr = gtk_frame_new("Status");
- gtk_box_pack_start (GTK_BOX (settings_hbox), status_fr, TRUE, TRUE, 0);
+ disabled_cb = gtk_check_button_new_with_label("Disabled");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disabled_cb), colorf->disabled);
+ gtk_box_pack_start (GTK_BOX (status_vbox), disabled_cb, TRUE, FALSE, 0);
+ gtk_tooltips_set_tip (tooltips, disabled_cb, ("Color rule won't be checked if this box is selected"), NULL);
- status_vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (status_vbox), 5);
- gtk_container_add(GTK_CONTAINER(status_fr), status_vbox);
-
- disabled_cb = gtk_check_button_new_with_label("Disabled");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disabled_cb), colorf->disabled);
- gtk_box_pack_start (GTK_BOX (status_vbox), disabled_cb, TRUE, FALSE, 0);
- gtk_tooltips_set_tip (tooltips, disabled_cb, ("Color rule won't be checked if this box is selected"), NULL);
-
- /* button box */
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
- gtk_box_pack_start(GTK_BOX(dialog_vbox), bbox, FALSE, FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (bbox), 0);
-
- edit_color_filter_ok = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
- gtk_tooltips_set_tip (tooltips, edit_color_filter_ok, ("Accept filter color change"), NULL);
+ /* button box */
+ bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
+ gtk_box_pack_start(GTK_BOX(dialog_vbox), bbox, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (bbox), 0);
- edit_color_filter_cancel = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
- gtk_tooltips_set_tip (tooltips, edit_color_filter_cancel, ("Reject filter color change"), NULL);
+ edit_color_filter_ok = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
+ gtk_tooltips_set_tip (tooltips, edit_color_filter_ok, ("Accept filter color change"), NULL);
- gtk_widget_grab_default(edit_color_filter_ok);
-
- /* signals and such */
- g_object_set_data(G_OBJECT(edit_dialog), COLOR_FILTER, colorf);
- g_signal_connect(edit_dialog, "destroy", G_CALLBACK(edit_color_filter_destroy_cb), NULL);
- g_object_set_data(G_OBJECT(colorize_filter_fg), COLOR_FILTER, colorf);
- g_signal_connect(colorize_filter_fg, "clicked", G_CALLBACK(edit_color_filter_fg_cb), NULL);
- g_object_set_data(G_OBJECT(colorize_filter_bg), COLOR_FILTER, colorf);
- g_signal_connect(colorize_filter_bg, "clicked", G_CALLBACK(edit_color_filter_bg_cb), NULL);
- g_object_set_data(G_OBJECT(disabled_cb), COLOR_FILTER, colorf);
+ edit_color_filter_cancel = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
+ gtk_tooltips_set_tip (tooltips, edit_color_filter_cancel, ("Reject filter color change"), NULL);
+
+ gtk_widget_grab_default(edit_color_filter_ok);
+
+ /* signals and such */
+ g_object_set_data(G_OBJECT(edit_dialog), COLOR_FILTER, colorf);
+ g_signal_connect(edit_dialog, "destroy", G_CALLBACK(edit_color_filter_destroy_cb), NULL);
+ g_object_set_data(G_OBJECT(colorize_filter_fg), COLOR_FILTER, colorf);
+ g_signal_connect(colorize_filter_fg, "clicked", G_CALLBACK(edit_color_filter_fg_cb), NULL);
+ g_object_set_data(G_OBJECT(colorize_filter_bg), COLOR_FILTER, colorf);
+ g_signal_connect(colorize_filter_bg, "clicked", G_CALLBACK(edit_color_filter_bg_cb), NULL);
+ g_object_set_data(G_OBJECT(disabled_cb), COLOR_FILTER, colorf);
/* g_signal_connect(disabled_cb, "clicked", G_CALLBACK(edit_disabled_cb_cb), NULL);*/
- g_object_set_data(G_OBJECT(edit_color_filter_ok), COLOR_FILTERS_CL, color_filters);
- g_object_set_data(G_OBJECT(edit_color_filter_ok), COLOR_FILTER, colorf);
- g_signal_connect(edit_color_filter_ok, "clicked", G_CALLBACK(edit_color_filter_ok_cb), edit_dialog);
-
- /* set callback to delete new filters if cancel chosen */
- if (is_new_filter)
- {
- g_object_set_data(G_OBJECT(edit_color_filter_cancel), COLOR_FILTERS_CL, color_filters);
- g_signal_connect(edit_color_filter_cancel, "clicked",
- G_CALLBACK(edit_new_color_filter_cancel_cb), edit_dialog);
- }
- /* escape will select cancel */
- window_set_cancel_button(edit_dialog, edit_color_filter_cancel, window_cancel_button_cb);
-
- g_signal_connect(edit_dialog, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
-
- gtk_widget_show_all(edit_dialog);
- window_present(edit_dialog);
+ g_object_set_data(G_OBJECT(edit_color_filter_ok), COLOR_FILTERS_CL, color_filters);
+ g_object_set_data(G_OBJECT(edit_color_filter_ok), COLOR_FILTER, colorf);
+ g_signal_connect(edit_color_filter_ok, "clicked", G_CALLBACK(edit_color_filter_ok_cb), edit_dialog);
+
+ /* set callback to delete new filters if cancel chosen */
+ if (is_new_filter)
+ {
+ g_object_set_data(G_OBJECT(edit_color_filter_cancel), COLOR_FILTERS_CL, color_filters);
+ g_signal_connect(edit_color_filter_cancel, "clicked",
+ G_CALLBACK(edit_new_color_filter_cancel_cb), edit_dialog);
+ }
+ /* escape will select cancel */
+ window_set_cancel_button(edit_dialog, edit_color_filter_cancel, window_cancel_button_cb);
+
+ g_signal_connect(edit_dialog, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
+
+ gtk_widget_show_all(edit_dialog);
+ window_present(edit_dialog);
}
/* Called when the dialog box is being destroyed; destroy any color
@@ -344,9 +345,9 @@ edit_color_filter_bg_cb (GtkButton *button,
}
/* Toggle the disabled flag */
-/*
+#if 0
static void
-edit_disabled_cb_cb (GtkButton *button,
+edit_disabled_cb_cb (GtkButton *button,
gpointer user_data _U_)
{
color_filter_t *colorf;
@@ -356,88 +357,88 @@ edit_disabled_cb_cb (GtkButton *button,
printf("Colorfilter %s is now %s\n",colorf->filter_name,colorf->disabled?"disabled":"enabled");
}
-*/
+#endif
/* accept color (and potential content) change */
static void
edit_color_filter_ok_cb (GtkButton *button,
gpointer user_data)
{
- GtkWidget *dialog;
- GtkStyle *style;
- GdkColor new_fg_color;
- GdkColor new_bg_color;
- gchar *filter_name;
- gchar *filter_text;
- gboolean filter_disabled;
- color_filter_t *colorf;
- dfilter_t *compiled_filter;
- GtkWidget *color_filters;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar fg_str[14], bg_str[14];
-
- dialog = (GtkWidget *)user_data;
-
- style = gtk_widget_get_style(filt_name_entry);
- new_bg_color = style->base[GTK_STATE_NORMAL];
- new_fg_color = style->text[GTK_STATE_NORMAL];
-
- filter_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(filt_name_entry)));
- filter_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(filt_text_entry)));
- filter_disabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(disabled_cb));
-
- if(strchr(filter_name,'@') || strchr(filter_text,'@')){
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Filter names and strings must not"
- " use the '@' character. Filter unchanged.");
- g_free(filter_name);
- g_free(filter_text);
- return;
- }
-
- if(!dfilter_compile(filter_text, &compiled_filter)) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Filter \"%s\" didn't compile correctly.\n"
- " Please try again. Filter unchanged.\n%s\n", filter_name,
- dfilter_error_msg);
- } else {
- color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(button), COLOR_FILTERS_CL);
- colorf = (color_filter_t *)g_object_get_data(G_OBJECT(button), COLOR_FILTER);
-
- g_free(colorf->filter_name);
- colorf->filter_name = filter_name;
-
- g_free(colorf->filter_text);
- colorf->filter_text = filter_text;
-
- colorf->disabled = filter_disabled;
- gdkcolor_to_color_t(&colorf->fg_color, &new_fg_color);
- gdkcolor_to_color_t(&colorf->bg_color, &new_bg_color);
- g_snprintf(fg_str, sizeof(fg_str), "#%04X%04X%04X",
- new_fg_color.red, new_fg_color.green, new_fg_color.blue);
- g_snprintf(bg_str, sizeof(bg_str), "#%04X%04X%04X",
- new_bg_color.red, new_bg_color.green, new_bg_color.blue);
- model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
- gtk_tree_model_iter_nth_child(model, &iter, NULL, row_selected);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, filter_name,
- 1, filter_text, 2, fg_str, 3, bg_str,
- 4, filter_disabled, -1);
- if(colorf->c_colorfilter != NULL)
- dfilter_free(colorf->c_colorfilter);
- colorf->c_colorfilter = compiled_filter;
-
- /* Destroy the dialog box. */
- window_destroy(dialog);
- }
+ GtkWidget *dialog;
+ GtkStyle *style;
+ GdkColor new_fg_color;
+ GdkColor new_bg_color;
+ gchar *filter_name;
+ gchar *filter_text;
+ gboolean filter_disabled;
+ color_filter_t *colorf;
+ dfilter_t *compiled_filter;
+ GtkWidget *color_filters;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar fg_str[14], bg_str[14];
+
+ dialog = (GtkWidget *)user_data;
+
+ style = gtk_widget_get_style(filt_name_entry);
+ new_bg_color = style->base[GTK_STATE_NORMAL];
+ new_fg_color = style->text[GTK_STATE_NORMAL];
+
+ filter_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(filt_name_entry)));
+ filter_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(filt_text_entry)));
+ filter_disabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(disabled_cb));
+
+ if(strchr(filter_name,'@') || strchr(filter_text,'@')){
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Filter names and strings must not"
+ " use the '@' character. Filter unchanged.");
+ g_free(filter_name);
+ g_free(filter_text);
+ return;
+ }
+
+ if(!dfilter_compile(filter_text, &compiled_filter)) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Filter \"%s\" didn't compile correctly.\n"
+ " Please try again. Filter unchanged.\n%s\n", filter_name,
+ dfilter_error_msg);
+ } else {
+ color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(button), COLOR_FILTERS_CL);
+ colorf = (color_filter_t *)g_object_get_data(G_OBJECT(button), COLOR_FILTER);
+
+ g_free(colorf->filter_name);
+ colorf->filter_name = filter_name;
+
+ g_free(colorf->filter_text);
+ colorf->filter_text = filter_text;
+
+ colorf->disabled = filter_disabled;
+ gdkcolor_to_color_t(&colorf->fg_color, &new_fg_color);
+ gdkcolor_to_color_t(&colorf->bg_color, &new_bg_color);
+ g_snprintf(fg_str, sizeof(fg_str), "#%04X%04X%04X",
+ new_fg_color.red, new_fg_color.green, new_fg_color.blue);
+ g_snprintf(bg_str, sizeof(bg_str), "#%04X%04X%04X",
+ new_bg_color.red, new_bg_color.green, new_bg_color.blue);
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
+ gtk_tree_model_iter_nth_child(model, &iter, NULL, color_dlg_row_selected);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, filter_name,
+ 1, filter_text, 2, fg_str, 3, bg_str,
+ 4, filter_disabled, -1);
+ if(colorf->c_colorfilter != NULL)
+ dfilter_free(colorf->c_colorfilter);
+ colorf->c_colorfilter = compiled_filter;
+
+ /* Destroy the dialog box. */
+ window_destroy(dialog);
+ }
}
/* reject new color filter addition */
static void
edit_new_color_filter_cancel_cb(GtkButton *button, gpointer user_data _U_)
{
- /* Delete the entry. As a side effect this destroys the edit_dialog window. */
- color_delete_single(num_of_filters-1, (GtkWidget*)g_object_get_data(G_OBJECT(button), COLOR_FILTERS_CL));
+ /* Delete the entry. As a side effect this destroys the edit_dialog window. */
+ color_delete_single(color_dlg_num_of_filters-1, (GtkWidget*)g_object_get_data(G_OBJECT(button), COLOR_FILTERS_CL));
}
static GtkWidget*
@@ -454,11 +455,11 @@ color_sel_win_new(color_filter_t *colorf, gboolean is_bg)
if (is_bg) {
color = &colorf->bg_color;
title = g_strdup_printf("Wireshark: Choose background color for \"%s\"",
- colorf->filter_name);
+ colorf->filter_name);
} else {
color = &colorf->fg_color;
title = g_strdup_printf("Wireshark: Choose foreground color for \"%s\"",
- colorf->filter_name);
+ colorf->filter_name);
}
color_sel_win = gtk_color_selection_dialog_new(title);
g_free(title);
@@ -468,8 +469,8 @@ color_sel_win_new(color_filter_t *colorf, gboolean is_bg)
if (color != NULL) {
color_t_to_gdkcolor(&gcolor, color);
gtk_color_selection_set_current_color(
- GTK_COLOR_SELECTION(
- GTK_COLOR_SELECTION_DIALOG(color_sel_win)->colorsel), &gcolor);
+ GTK_COLOR_SELECTION(
+ GTK_COLOR_SELECTION_DIALOG(color_sel_win)->colorsel), &gcolor);
}
color_sel_ok = GTK_COLOR_SELECTION_DIALOG (color_sel_win)->ok_button;
@@ -480,9 +481,9 @@ color_sel_win_new(color_filter_t *colorf, gboolean is_bg)
g_object_set_data(G_OBJECT(color_sel_win), "color_sel_cancel", color_sel_cancel);
GTK_WIDGET_SET_FLAGS (color_sel_cancel, GTK_CAN_DEFAULT);
window_set_cancel_button(color_sel_win, color_sel_cancel, NULL); /* ensure esc does req'd local cxl action. */
- /* esc as handled by the */
- /* gtk_color_selection_dialog widget */
- /* doesn't result in this happening. */
+ /* esc as handled by the */
+ /* gtk_color_selection_dialog widget */
+ /* doesn't result in this happening. */
color_sel_help = GTK_COLOR_SELECTION_DIALOG (color_sel_win)->help_button;
g_object_set_data(G_OBJECT(color_sel_win), "color_sel_help", color_sel_help);
@@ -538,28 +539,28 @@ color_sel_ok_cb (GtkButton *button _U_,
color_dialog = (GtkWidget *)user_data;
gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(
- GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &new_color);
+ GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel), &new_color);
if ( ! get_color(&new_color) ){
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Could not allocate color. Try again.");
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Could not allocate color. Try again.");
} else {
- /* Find the "Edit color filter" dialog box with which this is
- associated. */
- parent = (GtkWidget *)g_object_get_data(G_OBJECT(color_dialog), COLOR_SELECTION_PARENT);
-
- /* Find that dialog box's foreground and background color selection
- boxes, if any. */
- color_selection_bg = g_object_get_data(G_OBJECT(parent), COLOR_SELECTION_BG);
- is_bg = (color_dialog == color_selection_bg);
-
- color_sel_win_destroy(color_dialog);
-
- /* now apply the change to the fore/background */
- if (is_bg)
- gtk_widget_modify_base(filt_name_entry, GTK_STATE_NORMAL, &new_color);
- else
- gtk_widget_modify_text(filt_name_entry, GTK_STATE_NORMAL, &new_color);
+ /* Find the "Edit color filter" dialog box with which this is
+ associated. */
+ parent = (GtkWidget *)g_object_get_data(G_OBJECT(color_dialog), COLOR_SELECTION_PARENT);
+
+ /* Find that dialog box's foreground and background color selection
+ boxes, if any. */
+ color_selection_bg = g_object_get_data(G_OBJECT(parent), COLOR_SELECTION_BG);
+ is_bg = (color_dialog == color_selection_bg);
+
+ color_sel_win_destroy(color_dialog);
+
+ /* now apply the change to the fore/background */
+ if (is_bg)
+ gtk_widget_modify_base(filt_name_entry, GTK_STATE_NORMAL, &new_color);
+ else
+ gtk_widget_modify_text(filt_name_entry, GTK_STATE_NORMAL, &new_color);
}
}
diff --git a/gtk/color_edit_dlg.h b/gtk/color_edit_dlg.h
index d2e85c8bfd..e54fc3eff5 100644
--- a/gtk/color_edit_dlg.h
+++ b/gtk/color_edit_dlg.h
@@ -30,9 +30,6 @@
* @ingroup dialog_group
*/
-extern gint num_of_filters; /* number of filters being displayed */
-extern gint row_selected; /* row in color_filters that is selected */
-
/* new color filter edit dialog */
extern void
edit_color_filter_dialog(GtkWidget *color_filters,