diff options
author | oabad <oabad@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-09-23 19:09:52 +0000 |
---|---|---|
committer | oabad <oabad@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-09-23 19:09:52 +0000 |
commit | 7eb03ae98351bac834896f6653d6d782f9cc5f6f (patch) | |
tree | 6ec4a83fd50769bea03ddb77d3d3765a736e7699 /gtk2 | |
parent | d1279130303141eda4d3cc148ba974326b53db8a (diff) |
Change to color filters :
- moved color_filter_t in color.h
- change color_filter_t to use color_t instead of GdkColor
This changed allowed to remove the last gtk includes in file.c. It is
now completely free of any gtk related code.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@6324 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk2')
-rw-r--r-- | gtk2/color_dlg.c | 28 | ||||
-rw-r--r-- | gtk2/color_utils.c | 4 | ||||
-rw-r--r-- | gtk2/colors.c | 11 | ||||
-rw-r--r-- | gtk2/colors.h | 20 | ||||
-rw-r--r-- | gtk2/main.c | 10 | ||||
-rw-r--r-- | gtk2/packet_list.c | 20 |
6 files changed, 48 insertions, 45 deletions
diff --git a/gtk2/color_dlg.c b/gtk2/color_dlg.c index aeff7be802..168bab1930 100644 --- a/gtk2/color_dlg.c +++ b/gtk2/color_dlg.c @@ -1,7 +1,7 @@ /* color_dlg.c * Definitions for dialog boxes for color filters * - * $Id: color_dlg.c,v 1.2 2002/09/05 18:48:51 jmayer Exp $ + * $Id: color_dlg.c,v 1.3 2002/09/23 19:09:52 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -34,6 +34,7 @@ #include <epan/packet.h> #include "colors.h" #include "color_dlg.h" +#include "color_utils.h" #include "file.h" #include <epan/dfilter/dfilter.h> #include "simple_dialog.h" @@ -367,16 +368,19 @@ static void add_filter_to_clist(gpointer filter_arg, gpointer clist_arg) { color_filter_t *colorf = filter_arg; - GtkWidget *color_filters = clist_arg; - gchar *data[2]; - gint row; + GtkWidget *color_filters = clist_arg; + gchar *data[2]; + gint row; + GdkColor bg, fg; data[0] = colorf->filter_name; data[1] = colorf->filter_text; row = gtk_clist_append(GTK_CLIST(color_filters), data); + color_t_to_gdkcolor(&fg, &colorf->fg_color); + color_t_to_gdkcolor(&bg, &colorf->bg_color); gtk_clist_set_row_data(GTK_CLIST(color_filters), row, colorf); - gtk_clist_set_foreground(GTK_CLIST(color_filters), row, &colorf->fg_color); - gtk_clist_set_background(GTK_CLIST(color_filters), row, &colorf->bg_color); + gtk_clist_set_foreground(GTK_CLIST(color_filters), row, &fg); + gtk_clist_set_background(GTK_CLIST(color_filters), row, &bg); num_of_filters++; } @@ -705,8 +709,8 @@ edit_color_filter_dialog_new (GtkWidget *color_filters, gtk_entry_set_text(GTK_ENTRY(*colorize_filter_name), colorf->filter_name); style = gtk_style_copy(gtk_widget_get_style(*colorize_filter_name)); - style->base[GTK_STATE_NORMAL] = colorf->bg_color; - style->fg[GTK_STATE_NORMAL] = colorf->fg_color; + color_t_to_gdkcolor(&style->base[GTK_STATE_NORMAL], &colorf->bg_color); + color_t_to_gdkcolor(&style->fg[GTK_STATE_NORMAL], &colorf->fg_color); gtk_widget_set_style(*colorize_filter_name, style); gtk_widget_show (*colorize_filter_name); @@ -961,8 +965,8 @@ edit_color_filter_ok_cb (GtkButton *button, if (colorf->filter_text != NULL) g_free(colorf->filter_text); colorf->filter_text = filter_text; - colorf->fg_color = new_fg_color; - colorf->bg_color = new_bg_color; + gdkcolor_to_color_t(&colorf->fg_color, &new_fg_color); + gdkcolor_to_color_t(&colorf->bg_color, &new_bg_color); gtk_clist_set_foreground(GTK_CLIST(color_filters), row_selected, &new_fg_color); gtk_clist_set_background(GTK_CLIST(color_filters), row_selected, @@ -1002,13 +1006,13 @@ color_sel_win_new(color_filter_t *colorf, gboolean is_bg) static const gchar fg_title_format[] = "Choose foreground color for \"%s\""; static const gchar bg_title_format[] = "Choose background color for \"%s\""; GtkWidget *color_sel_win; - GdkColor *color; + color_t *color; GtkWidget *color_sel_ok; GtkWidget *color_sel_cancel; GtkWidget *color_sel_help; if (is_bg) { - color = &colorf->bg_color; + color = &colorf->bg_color; title_len = strlen(bg_title_format) + strlen(colorf->filter_name); title = g_malloc(title_len + 1); sprintf(title, bg_title_format, colorf->filter_name); diff --git a/gtk2/color_utils.c b/gtk2/color_utils.c index 94aaf2dbe2..9d37d6efeb 100644 --- a/gtk2/color_utils.c +++ b/gtk2/color_utils.c @@ -2,7 +2,7 @@ * Utilities for converting between "toolkit-independent" and GDK * notions of color * - * $Id: color_utils.c,v 1.2 2002/09/05 18:48:51 jmayer Exp $ + * $Id: color_utils.c,v 1.3 2002/09/23 19:09:52 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -30,7 +30,7 @@ #include <gtk/gtk.h> -#include "prefs.h" /* to declare "color_t" */ +#include "color.h" /* to declare "color_t" */ void color_t_to_gdkcolor(GdkColor *target, color_t *source) diff --git a/gtk2/colors.c b/gtk2/colors.c index 0aad705459..5092cd7064 100644 --- a/gtk2/colors.c +++ b/gtk2/colors.c @@ -1,7 +1,7 @@ /* colors.c * Definitions for color structures and routines * - * $Id: colors.c,v 1.2 2002/09/05 18:48:51 jmayer Exp $ + * $Id: colors.c,v 1.3 2002/09/23 19:09:52 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -36,6 +36,7 @@ #include <epan/packet.h> #include "colors.h" +#include "color_utils.h" #include "file.h" #include <epan/dfilter/dfilter.h> #include "simple_dialog.h" @@ -91,8 +92,8 @@ new_color_filter(gchar *name, /* The name of the filter to create */ colorf = (color_filter_t *)g_malloc(sizeof (color_filter_t)); colorf->filter_name = g_strdup(name); colorf->filter_text = g_strdup(filter_string); - colorf->bg_color = WHITE; - colorf->fg_color = BLACK; + gdkcolor_to_color_t(&colorf->bg_color, &WHITE); + gdkcolor_to_color_t(&colorf->fg_color, &BLACK); colorf->c_colorfilter = NULL; colorf->edit_dialog = NULL; filter_list = g_slist_append(filter_list, colorf); @@ -213,8 +214,8 @@ read_filters(void) bg_color.green = bg_g; bg_color.blue = bg_b; - colorf->bg_color = bg_color; - colorf->fg_color = fg_color; + gdkcolor_to_color_t(&colorf->bg_color, &bg_color); + gdkcolor_to_color_t(&colorf->fg_color, &fg_color); } /* if sscanf */ } while(!feof(f)); return TRUE; diff --git a/gtk2/colors.h b/gtk2/colors.h index 35508dbea6..1840f64cb6 100644 --- a/gtk2/colors.h +++ b/gtk2/colors.h @@ -1,7 +1,7 @@ /* colors.h * Definitions for color structures and routines * - * $Id: colors.h,v 1.2 2002/09/05 18:48:51 jmayer Exp $ + * $Id: colors.h,v 1.3 2002/09/23 19:09:52 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -24,6 +24,8 @@ #ifndef __COLORS_H__ #define __COLORS_H__ +#include "../color.h" + #define MAXCOLORS 255 #define MAX_COLOR_FILTER_NAME_LEN 33 #define MAX_COLOR_FILTER_STRING_LEN 256 @@ -34,19 +36,6 @@ extern GdkColor WHITE; extern GdkColor BLACK; -/* Data for a color filter. */ -typedef struct _color_filter { - gchar *filter_name; /* name of the filter */ - gchar *filter_text; /* text of the filter expression */ - GdkColor bg_color; /* background color for packets that match */ - GdkColor fg_color; /* foreground color for packets that match */ - dfilter_t *c_colorfilter; /* compiled filter expression */ - GtkWidget *edit_dialog; /* if filter is being edited, dialog box for it */ -} color_filter_t; - -/* List of all color filters. */ -extern GSList *filter_list; - void colfilter_init(void); gboolean write_filters(void); @@ -56,7 +45,4 @@ void delete_color_filter(color_filter_t *colorf); gboolean get_color (GdkColor *new_color); -void -filter_list_prime_edt(epan_dissect_t *edt); - #endif diff --git a/gtk2/main.c b/gtk2/main.c index acd8ebaa25..8d36805fa2 100644 --- a/gtk2/main.c +++ b/gtk2/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.11 2002/09/09 20:39:01 guy Exp $ + * $Id: main.c,v 1.12 2002/09/23 19:09:52 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -661,14 +661,14 @@ set_frame_mark(gboolean set, frame_data *frame, gint row) { mark_frame(&cfile, frame); color_t_to_gdkcolor(&fg, &prefs.gui_marked_fg); color_t_to_gdkcolor(&bg, &prefs.gui_marked_bg); + gtk_clist_set_background(GTK_CLIST(packet_list), row, &bg); + gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &fg); } else { unmark_frame(&cfile, frame); - fg = BLACK; - bg = WHITE; + gtk_clist_set_background(GTK_CLIST(packet_list), row, NULL); + gtk_clist_set_foreground(GTK_CLIST(packet_list), row, NULL); } file_set_save_marked_sensitive(); - gtk_clist_set_background(GTK_CLIST(packet_list), row, &bg); - gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &fg); } static gint diff --git a/gtk2/packet_list.c b/gtk2/packet_list.c index 7e3d7aeeb0..fabb7d6960 100644 --- a/gtk2/packet_list.c +++ b/gtk2/packet_list.c @@ -1,7 +1,7 @@ /* packet_list.c * packet list related functions 2002 Olivier Abad * - * $Id: packet_list.c,v 1.1 2002/09/21 11:36:30 oabad Exp $ + * $Id: packet_list.c,v 1.2 2002/09/23 19:09:52 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -30,7 +30,9 @@ #include "gtkglobals.h" #include "epan/epan.h" +#include "color.h" #include "../ui_util.h" +#include "color_utils.h" #include "column.h" #include "epan/column_info.h" @@ -95,10 +97,20 @@ packet_list_append(gchar *text[], gpointer data) } void -packet_list_set_colors(gint row, GdkColor *fg, GdkColor *bg) +packet_list_set_colors(gint row, color_t *fg, color_t *bg) { - if (fg) gtk_clist_set_foreground(GTK_CLIST(packet_list), row, fg); - if (bg) gtk_clist_set_background(GTK_CLIST(packet_list), row, bg); + GdkColor gdkfg, gdkbg; + + if (fg) + { + color_t_to_gdkcolor(&gdkfg, fg); + gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &gdkfg); + } + if (bg) + { + color_t_to_gdkcolor(&gdkbg, bg); + gtk_clist_set_background(GTK_CLIST(packet_list), row, &gdkbg); + } } gint |