/* colors.c
* Definitions for color structures and routines
*
- * $Id: colors.c,v 1.15 1999/11/10 19:58:32 gram Exp $
+ * $Id: colors.c,v 1.16 1999/11/30 04:23:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
extern capture_file cf;
+static void new_color_filter(colfilter *filters, gchar *name,
+ gchar *filter_string);
static gboolean read_filters(capture_file *cf);
+static GtkWidget* create_color_win (cap_file *cf);
+static GtkWidget* create_colorize_win (cap_file *cf,
+ GtkWidget **colorize_filter_name,
+ GtkWidget **colorize_filter_text);
static GtkWidget* create_color_sel_win(cap_file *cf, GdkColor *);
+static gboolean get_color(GdkColor *new_color);
-GdkColor proto_colors[MAXCOLORS];
-GdkColormap* sys_cmap;
-GdkColormap* our_cmap = NULL;
+static GdkColormap* sys_cmap;
+static GdkColormap* our_cmap = NULL;
static gchar *titles[2] = { "Name", "Filter String" };
GdkColor WHITE = { 0, 65535, 65535, 65535 };
GdkColor BLACK = { 0, 0, 0, 0 };
+#define COLOR_CHANGE_COLORS_LB "color_change_colors_lb"
+
/* This structure is used to allow you to compile in default colors if
* you wish. They can be later changed by a user.
*/
read_filters(cf);
}
-void
+static void
set_color_filter_name(capture_file *cf, gint n, gchar *str)
{
gtk_clist_set_text(GTK_CLIST(cf->colors->color_filters),n,0,str);
}
-
-gchar *
+static gchar *
get_color_filter_name(capture_file *cf, gint n)
{
gchar *filter_name;
return filter_name;
}
-void
+static void
set_color_filter_string(capture_file *cf, gint n, gchar *str)
{
gtk_clist_set_text(GTK_CLIST(cf->colors->color_filters),n,1,str);
}
-
-gchar *
+static gchar *
get_color_filter_string(capture_file *cf, gint n)
{
gchar *filter_string;
return gtk_clist_get_row_data(GTK_CLIST(cf->colors->color_filters),n);
}
-void
+static void
new_color_filter(colfilter *filters, gchar *name, gchar *filter_string)
{
color_filter_t *colorf;
/* cf already exists as a global */
/* create the color dialog */
create_color_win(&cf);
-
}
-void
+static void
color_cancel_cb (GtkWidget *widget,
gpointer user_data)
{
gtk_widget_destroy(win);
}
-void
+static void
color_delete_cb(GtkWidget *widget, gpointer user_data)
{
- if(cf.colors->row_selected != -1){
- gtk_clist_remove(GTK_CLIST(cf.colors->color_filters),
- cf.colors->row_selected);
- cf.colors->num_of_filters--;
- if(!cf.colors->num_of_filters){
- cf.colors->row_selected = -1;
+ colfilter *filter;
+ GtkWidget *color_change_colors;
+
+ filter = (colfilter *)user_data;
+ if(filter->row_selected != -1){
+ gtk_clist_remove(GTK_CLIST(filter->color_filters),
+ filter->row_selected);
+ filter->num_of_filters--;
+ if(!filter->num_of_filters){
+ /* No filters any more, so none can be selected... */
+ filter->row_selected = -1;
+ color_change_colors =
+ (GtkWidget *) gtk_object_get_data(GTK_OBJECT(widget),
+ COLOR_CHANGE_COLORS_LB);
+
+ /* ...and none can be edited. */
+ gtk_widget_set_sensitive (color_change_colors, FALSE);
} else {
- cf.colors->row_selected--;
- if(cf.colors->row_selected < 0)
- cf.colors->row_selected = 0;
- gtk_clist_select_row(GTK_CLIST(cf.colors->color_filters),
- cf.colors->row_selected,0);
+ filter->row_selected--;
+ if(filter->row_selected < 0)
+ filter->row_selected = 0;
+ gtk_clist_select_row(GTK_CLIST(filter->color_filters),
+ filter->row_selected,0);
}
}
}
/* Move the selected filter up in the list */
-void
+static void
color_filt_up_cb (GtkButton *button,
gpointer user_data)
{
}
/* Move the selected filter down in the list */
-void
+static void
color_filter_down_cb (GtkButton *button,
gpointer user_data)
{
}
/* Set selected row in cf */
-void
-rembember_selected_row (GtkCList *clist,
+static void
+remember_selected_row (GtkCList *clist,
gint row,
gint column,
GdkEvent *event,
gpointer user_data)
{
- capture_file *cf;
- cf = (capture_file *) user_data;
+ colfilter *colors = (colfilter *)user_data;
- cf->colors->row_selected = row;
+ colors->row_selected = row;
}
-/* change name to color_new_cb */
static GtkWidget *filt_name_entry;
static GtkWidget *filt_text_entry;
/* Create a new filter in the list */
-void
-create_new_cb (GtkButton *button,
+static void
+color_new_cb (GtkButton *button,
gpointer user_data)
{
colfilter *filter;
+ GtkWidget *color_change_colors;
filter = (colfilter *)user_data;
new_color_filter(filter, "name", "filter"); /* Adds at end! */
- /* select the last row */
- cf.colors->row_selected = cf.colors->num_of_filters;
- cf.colors->num_of_filters++;
- gtk_clist_select_row(GTK_CLIST(cf.colors->color_filters),cf.colors->row_selected,0);
+ /* A row has been added, so we can edit it. */
+ color_change_colors = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(button),
+ COLOR_CHANGE_COLORS_LB);
+ gtk_widget_set_sensitive (color_change_colors, TRUE);
+
+ /* select the new (last) row */
+ filter->row_selected = filter->num_of_filters;
+ filter->num_of_filters++;
+ gtk_clist_select_row(GTK_CLIST(filter->color_filters),
+ filter->row_selected,-1);
/* this is the global cf! */
create_colorize_win(&cf, &filt_name_entry, &filt_text_entry);
}
/* Change a filter */
-/* probably should change name to color_edit_cb */
-void
-color_change_cb (GtkButton *button,
- gpointer user_data)
+static void
+color_edit_cb (GtkButton *button,
+ gpointer user_data)
{
colfilter *filter;
filter = (colfilter *)user_data;
- if(cf.colors->row_selected == -1){
+ if(filter->row_selected == -1){
/* select the first row */
- cf.colors->row_selected = 0;
- gtk_clist_select_row(GTK_CLIST(cf.colors->color_filters),cf.colors->row_selected,0);
+ filter->row_selected = 0;
+ gtk_clist_select_row(GTK_CLIST(filter->color_filters),
+ filter->row_selected,-1);
}
/* this is the global cf! */
/*Default colors are in cf in the e entry itself.*/
/* save filters in file */
-void
+static void
color_save_cb (GtkButton *button,
gpointer user_data)
{
}
/* Exit dialog and process list */
-void
+static void
color_ok_cb (GtkButton *button,
gpointer user_data)
{
}
/* Process all data by applying filters in list */
-void
+static void
color_apply_cb (GtkButton *button,
gpointer user_data)
{
}
/* Exit dialog and do not process list */
-void
+static void
colorize_cancel_cb (GtkObject *object,
gpointer user_data)
{
static gint bg_set_flag; /* 0 -> setting foreground, 1-> setting background */
/* Change the foreground color */
-void
+static void
colorize_fg_cb (GtkButton *button,
gpointer user_data)
{
}
/* Change the background color */
-void
+static void
colorize_bg_cb (GtkButton *button,
gpointer user_data)
{
}
/* accept color (and potential content) change */
-void
+static void
colorize_ok_cb (GtkButton *button,
gpointer user_data)
{
}
/* Revert to existing colors */
-void
-color_cel_cancel_cb (GtkObject *object,
+static void
+color_sel_cancel_cb (GtkObject *object,
gpointer user_data)
{
GtkWidget *color_dialog;
}
/* Retrieve selected color */
-void
+static void
color_sel_ok_cb (GtkButton *button,
gpointer user_data)
{
}
}
-
-
-
-
-GtkWidget*
+static GtkWidget*
create_color_win (capture_file *cf)
{
GtkWidget *color_win;
gtk_widget_set_usize(color_change_colors, 50, 30);
gtk_box_pack_start (GTK_BOX (hbox2), color_change_colors, TRUE, FALSE, 5);
gtk_tooltips_set_tip (tooltips, color_change_colors, ("Change color of selected filter"), NULL);
+ gtk_widget_set_sensitive (color_change_colors,
+ (cf->colors->num_of_filters != 0));
color_delete = gtk_button_new_with_label (("Delete"));
gtk_widget_ref (color_delete);
GTK_SIGNAL_FUNC (color_filter_down_cb),
cf->colors);
gtk_signal_connect (GTK_OBJECT (clist1), "select_row",
- GTK_SIGNAL_FUNC (rembember_selected_row),
- cf);
+ GTK_SIGNAL_FUNC (remember_selected_row),
+ cf->colors);
+ gtk_object_set_data(GTK_OBJECT (color_new), COLOR_CHANGE_COLORS_LB,
+ color_change_colors);
gtk_signal_connect (GTK_OBJECT (color_new), "clicked",
- GTK_SIGNAL_FUNC (create_new_cb),
+ GTK_SIGNAL_FUNC (color_new_cb),
cf->colors);
gtk_signal_connect (GTK_OBJECT (color_change_colors), "clicked",
- GTK_SIGNAL_FUNC (color_change_cb),
+ GTK_SIGNAL_FUNC (color_edit_cb),
cf->colors);
+ gtk_object_set_data(GTK_OBJECT (color_delete), COLOR_CHANGE_COLORS_LB,
+ color_change_colors);
gtk_signal_connect (GTK_OBJECT (color_delete), "clicked",
GTK_SIGNAL_FUNC (color_delete_cb),
- color_delete);
+ cf->colors);
gtk_signal_connect (GTK_OBJECT (color_save), "clicked",
GTK_SIGNAL_FUNC (color_save_cb),
cf);
return color_win;
}
-GtkWidget*
+static GtkWidget*
create_colorize_win (capture_file *cf,
GtkWidget **colorize_filter_name,
GtkWidget **colorize_filter_text)
{
GtkWidget *color_sel_win;
GtkWidget *color_sel_ok;
- GtkWidget *color_cel_cancel;
+ GtkWidget *color_sel_cancel;
GtkWidget *color_sel_help;
color_sel_win = gtk_color_selection_dialog_new (("Choose color"));
gtk_widget_show (color_sel_ok);
GTK_WIDGET_SET_FLAGS (color_sel_ok, GTK_CAN_DEFAULT);
- color_cel_cancel = GTK_COLOR_SELECTION_DIALOG (color_sel_win)->cancel_button;
- gtk_object_set_data (GTK_OBJECT (color_sel_win), "color_cel_cancel", color_cel_cancel);
- gtk_widget_show (color_cel_cancel);
- GTK_WIDGET_SET_FLAGS (color_cel_cancel, GTK_CAN_DEFAULT);
+ color_sel_cancel = GTK_COLOR_SELECTION_DIALOG (color_sel_win)->cancel_button;
+ gtk_object_set_data (GTK_OBJECT (color_sel_win), "color_sel_cancel", color_sel_cancel);
+ gtk_widget_show (color_sel_cancel);
+ GTK_WIDGET_SET_FLAGS (color_sel_cancel, GTK_CAN_DEFAULT);
color_sel_help = GTK_COLOR_SELECTION_DIALOG (color_sel_win)->help_button;
GTK_WIDGET_SET_FLAGS (color_sel_help, GTK_CAN_DEFAULT);
#if 0
gtk_signal_connect (GTK_OBJECT (color_sel_win), "destroy",
- GTK_SIGNAL_FUNC (color_cel_cancel_cb),
+ GTK_SIGNAL_FUNC (color_sel_cancel_cb),
color_sel_win);
#endif
gtk_signal_connect (GTK_OBJECT (color_sel_ok), "clicked",
GTK_SIGNAL_FUNC (color_sel_ok_cb),
color_sel_win);
- gtk_signal_connect (GTK_OBJECT (color_cel_cancel), "clicked",
- GTK_SIGNAL_FUNC (color_cel_cancel_cb),
+ gtk_signal_connect (GTK_OBJECT (color_sel_cancel), "clicked",
+ GTK_SIGNAL_FUNC (color_sel_cancel_cb),
color_sel_win);
gtk_widget_show(color_sel_win);
return color_sel_win;
}
-gboolean
-get_color ( GdkColor *new_color) {
-
+static gboolean
+get_color (GdkColor *new_color)
+{
GdkVisual *pv;
if (!our_cmap) {
/* colors.h
* Definitions for color structures and routines
*
- * $Id: colors.h,v 1.5 1999/10/07 22:50:45 guy Exp $
+ * $Id: colors.h,v 1.6 1999/11/30 04:23:06 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#define CFILTERS_CONTAINS_FILTER(cf) \
((cf)->colors->num_of_filters != 0)
-extern GdkColor proto_colors[MAXCOLORS];
-extern GdkColormap* sys_cmap;
-extern GdkColor color_light_gray;
extern GdkColor WHITE;
extern GdkColor BLACK;
} colfilter;
-
typedef struct _capture_file cap_file;
-
void colors_init(cap_file *cf);
-void set_color_filter_name(cap_file *cf, gint n, gchar *str);
-gchar* get_color_filter_name(cap_file *cf, gint n);
-
-void set_color_filter_string(cap_file *cf, gint n, gchar *str);
-gchar* get_color_filter_string(cap_file *cf, gint n);
color_filter_t *color_filter(cap_file *cf, gint n);
-void new_color_filter(colfilter *filters, gchar *name, gchar *filter_string);
-
/* ===================== USER INTERFACE ====================== */
void
color_display_cb(GtkWidget *w, gpointer d);
-void
-color_delete_cb (GtkWidget *widget,
- gpointer user_data);
-void
-color_cancel_cb (GtkWidget *widget,
- gpointer user_data);
-void
-color_filt_up_cb (GtkButton *button,
- gpointer user_data);
-
-void
-color_filter_down_cb (GtkButton *button,
- gpointer user_data);
-
-void
-rembember_selected_row (GtkCList *clist,
- gint row,
- gint column,
- GdkEvent *event,
- gpointer user_data);
-
-void
-create_new_cb (GtkButton *button,
- gpointer user_data);
-
-void
-color_change_cb (GtkButton *button,
- gpointer user_data);
-
-void
-color_save_cb (GtkButton *button,
- gpointer user_data);
-
-void
-color_ok_cb (GtkButton *button,
- gpointer user_data);
-
-void
-color_apply_cb (GtkButton *button,
- gpointer user_data);
-
-void
-colorize_cancel_cb (GtkObject *object,
- gpointer user_data);
-
-void
-colorize_fg_cb (GtkButton *button,
- gpointer user_data);
-
-void
-colorize_bg_cb (GtkButton *button,
- gpointer user_data);
-
-void
-colorize_ok_cb (GtkButton *button,
- gpointer user_data);
-
-void
-color_cel_cancel_cb (GtkObject *object,
- gpointer user_data);
-
-void
-color_sel_ok_cb (GtkButton *button,
- gpointer user_data);
-
-gboolean
-get_color (GdkColor *new_color);
-
-GtkWidget* create_color_win (cap_file *cf);
-GtkWidget* create_colorize_win (cap_file *cf,
- GtkWidget **colorize_filter_name,
- GtkWidget **colorize_filter_text);
#endif