1999-12-02 04:30:15 +00:00
|
|
|
/* stream_prefs.c
|
|
|
|
* Dialog boxes for preferences for the stream window
|
|
|
|
*
|
2003-02-17 07:50:49 +00:00
|
|
|
* $Id: stream_prefs.c,v 1.16 2003/02/17 07:50:49 oabad Exp $
|
1999-12-02 04:30:15 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
On Windows, use the directory in which the binary resides as the
directory in which global data files are stored. If an installed binary
is being run, that's the correct directory for them; if a build-tree
binary is being run, the "manuf" file will be there, and you can put
other data files there as well, if necessary.
Do the same with plugins, except that, if there's no
"plugins\\{version}" subdirectory of that directory, fall back on the
default installation directory, so you at least have a place where you
can put plugins for use by build-tree binaries. (Should we, instead,
have the Windows build procedure create a subdirectory of the "plugins"
source directory, with the plugin version number as its name, and copy
the plugins there, so you'd use the build-tree plugin binaries?)
Move "test_for_directory()" out of "util.c" and into
"epan/filesystem.c", with the other file system access portability
wrappers and convenience routines. Fix "util.h" not to declare it - or
other routines moved to "epan/filesystem.c" a while ago.
svn path=/trunk/; revision=3858
2001-08-21 06:39:18 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-12-02 04:30:15 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-02 04:30:15 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-02 04:30:15 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-02 04:30:15 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2000-10-20 04:26:40 +00:00
|
|
|
#include <gtk/gtk.h>
|
1999-12-02 04:30:15 +00:00
|
|
|
|
2000-11-21 23:54:10 +00:00
|
|
|
#include "color.h"
|
|
|
|
#include "color_utils.h"
|
1999-12-02 04:30:15 +00:00
|
|
|
#include "globals.h"
|
|
|
|
#include "stream_prefs.h"
|
|
|
|
#include "keys.h"
|
|
|
|
#include "print.h"
|
2002-01-11 07:40:32 +00:00
|
|
|
#include "prefs.h"
|
2002-11-11 15:39:06 +00:00
|
|
|
#include "compat_macros.h"
|
1999-12-02 04:30:15 +00:00
|
|
|
|
|
|
|
static void update_text_color(GtkWidget *, gpointer);
|
|
|
|
static void update_current_color(GtkWidget *, gpointer);
|
|
|
|
|
|
|
|
static GdkColor tcolors[4], *curcolor = NULL;
|
|
|
|
|
|
|
|
#define SAMPLE_CLIENT_TEXT "Sample client text\n"
|
|
|
|
#define SAMPLE_SERVER_TEXT "Sample server text\n"
|
|
|
|
#define CFG_IDX 0
|
|
|
|
#define CBG_IDX 1
|
|
|
|
#define SFG_IDX 2
|
|
|
|
#define SBG_IDX 3
|
|
|
|
#define STREAM_SAMPLE_KEY "stream_entry"
|
|
|
|
#define STREAM_CS_KEY "stream_colorselection"
|
|
|
|
#define CS_RED 0
|
|
|
|
#define CS_GREEN 1
|
|
|
|
#define CS_BLUE 2
|
|
|
|
#define CS_OPACITY 3
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
stream_prefs_show()
|
|
|
|
{
|
|
|
|
GtkWidget *main_vb, *main_tb, *label, *optmenu, *menu, *menuitem;
|
|
|
|
GtkWidget *sample, *colorsel;
|
|
|
|
int width, height, i;
|
|
|
|
gchar *mt[] = { "Client foreground", "Client background",
|
|
|
|
"Server foreground", "Server background" };
|
|
|
|
int mcount = sizeof(mt) / sizeof (gchar *);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-02 04:30:15 +00:00
|
|
|
gdouble scolor[4];
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
GtkTextBuffer *buf;
|
|
|
|
GtkTextIter iter;
|
2003-02-17 07:50:49 +00:00
|
|
|
PangoLayout *layout;
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
1999-12-02 04:30:15 +00:00
|
|
|
|
2000-11-21 23:54:10 +00:00
|
|
|
color_t_to_gdkcolor(&tcolors[CFG_IDX], &prefs.st_client_fg);
|
|
|
|
color_t_to_gdkcolor(&tcolors[CBG_IDX], &prefs.st_client_bg);
|
|
|
|
color_t_to_gdkcolor(&tcolors[SFG_IDX], &prefs.st_server_fg);
|
|
|
|
color_t_to_gdkcolor(&tcolors[SBG_IDX], &prefs.st_server_bg);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-12-02 04:30:15 +00:00
|
|
|
curcolor = &tcolors[CFG_IDX];
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-02 04:30:15 +00:00
|
|
|
scolor[CS_RED] = (gdouble) (curcolor->red) / 65535.0;
|
|
|
|
scolor[CS_GREEN] = (gdouble) (curcolor->green) / 65535.0;
|
|
|
|
scolor[CS_BLUE] = (gdouble) (curcolor->blue) / 65535.0;
|
|
|
|
scolor[CS_OPACITY] = 1.0;
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-12-02 04:30:15 +00:00
|
|
|
/* Enclosing containers for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 5);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
|
|
|
|
main_tb = gtk_table_new(3, 3, FALSE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
|
|
|
|
gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
|
|
|
|
gtk_widget_show(main_tb);
|
|
|
|
|
|
|
|
label = gtk_label_new("Set:");
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, 0, 1);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
|
|
|
|
/* We have to create this now, and configure it below. */
|
|
|
|
colorsel = gtk_color_selection_new();
|
|
|
|
|
|
|
|
optmenu = gtk_option_menu_new ();
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
for (i = 0; i < mcount; i++){
|
|
|
|
menuitem = gtk_menu_item_new_with_label (mt[i]);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(menuitem, STREAM_CS_KEY, colorsel);
|
|
|
|
SIGNAL_CONNECT(menuitem, "activate", update_current_color, &tcolors[i]);
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
}
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), menu);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), optmenu, 1, 2, 0, 1);
|
|
|
|
gtk_widget_show(optmenu);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-02 04:30:15 +00:00
|
|
|
sample = gtk_text_new(FALSE, FALSE);
|
|
|
|
height = 2 * (sample->style->font->ascent + sample->style->font->descent);
|
|
|
|
width = gdk_string_width(sample->style->font, "Sample server text");
|
2002-11-11 15:39:06 +00:00
|
|
|
WIDGET_SET_SIZE(sample, width, height);
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_text_set_editable(GTK_TEXT(sample), FALSE);
|
|
|
|
gtk_text_insert(GTK_TEXT(sample), NULL, &tcolors[CFG_IDX], &tcolors[CBG_IDX],
|
2002-11-03 17:38:45 +00:00
|
|
|
SAMPLE_CLIENT_TEXT, -1);
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_text_insert(GTK_TEXT(sample), NULL, &tcolors[SFG_IDX], &tcolors[SBG_IDX],
|
2002-11-03 17:38:45 +00:00
|
|
|
SAMPLE_SERVER_TEXT, -1);
|
|
|
|
#else
|
|
|
|
sample = gtk_text_view_new();
|
2003-02-17 07:50:49 +00:00
|
|
|
layout = gtk_widget_create_pango_layout(sample, "Sample server text");
|
|
|
|
pango_layout_get_pixel_size(layout, &width, &height);
|
|
|
|
g_object_unref(G_OBJECT(layout));
|
2002-11-11 15:39:06 +00:00
|
|
|
WIDGET_SET_SIZE(sample, width, height);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_text_view_set_editable(GTK_TEXT_VIEW(sample), FALSE);
|
|
|
|
buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sample));
|
|
|
|
gtk_text_buffer_get_start_iter(buf, &iter);
|
|
|
|
gtk_text_buffer_create_tag(buf, "client",
|
|
|
|
"foreground-gdk", &tcolors[CFG_IDX],
|
|
|
|
"background-gdk", &tcolors[CBG_IDX], NULL);
|
|
|
|
gtk_text_buffer_create_tag(buf, "server",
|
|
|
|
"foreground-gdk", &tcolors[SFG_IDX],
|
|
|
|
"background-gdk", &tcolors[SBG_IDX], NULL);
|
|
|
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_CLIENT_TEXT, -1,
|
|
|
|
"client", NULL);
|
|
|
|
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_SERVER_TEXT, -1,
|
|
|
|
"server", NULL);
|
|
|
|
#endif
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), sample, 2, 3, 0, 2);
|
|
|
|
gtk_widget_show(sample);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_color_selection_set_color(GTK_COLOR_SELECTION(colorsel), &scolor[CS_RED]);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel),
|
|
|
|
curcolor);
|
|
|
|
#endif
|
2001-03-01 20:49:50 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(main_tb), colorsel, 0, 3, 2, 3,
|
|
|
|
GTK_SHRINK, GTK_SHRINK, 0, 0);
|
|
|
|
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(colorsel, STREAM_SAMPLE_KEY, sample);
|
|
|
|
SIGNAL_CONNECT(colorsel, "color-changed", update_text_color, NULL);
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_widget_show(colorsel);
|
|
|
|
|
|
|
|
gtk_widget_show(main_vb);
|
|
|
|
return(main_vb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
update_text_color(GtkWidget *w, gpointer data _U_) {
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2002-11-11 15:39:06 +00:00
|
|
|
GtkText *sample = OBJECT_GET_DATA(w, STREAM_SAMPLE_KEY);
|
1999-12-02 04:30:15 +00:00
|
|
|
gdouble scolor[4];
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
2002-11-11 15:39:06 +00:00
|
|
|
GtkTextView *sample = OBJECT_GET_DATA(w, STREAM_SAMPLE_KEY);
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkTextBuffer *buf;
|
|
|
|
GtkTextTag *tag;
|
|
|
|
#endif
|
1999-12-02 04:30:15 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_color_selection_get_color(GTK_COLOR_SELECTION(w), &scolor[CS_RED]);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-12-02 04:30:15 +00:00
|
|
|
curcolor->red = (gushort) (scolor[CS_RED] * 65535.0);
|
|
|
|
curcolor->green = (gushort) (scolor[CS_GREEN] * 65535.0);
|
|
|
|
curcolor->blue = (gushort) (scolor[CS_BLUE] * 65535.0);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_text_freeze(sample);
|
|
|
|
gtk_text_set_point(sample, 0);
|
|
|
|
gtk_text_forward_delete(sample, gtk_text_get_length(sample));
|
|
|
|
gtk_text_insert(sample, NULL, &tcolors[CFG_IDX], &tcolors[CBG_IDX],
|
|
|
|
SAMPLE_CLIENT_TEXT, -1);
|
|
|
|
gtk_text_insert(sample, NULL, &tcolors[SFG_IDX], &tcolors[SBG_IDX],
|
|
|
|
SAMPLE_SERVER_TEXT, -1);
|
|
|
|
gtk_text_thaw(sample);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(w), curcolor);
|
|
|
|
|
|
|
|
buf = gtk_text_view_get_buffer(sample);
|
|
|
|
tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buf), "client");
|
|
|
|
g_object_set(tag, "foreground-gdk", &tcolors[CFG_IDX], "background-gdk",
|
|
|
|
&tcolors[CBG_IDX], NULL);
|
|
|
|
tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buf), "server");
|
|
|
|
g_object_set(tag, "foreground-gdk", &tcolors[SFG_IDX], "background-gdk",
|
|
|
|
&tcolors[SBG_IDX], NULL);
|
|
|
|
#endif
|
1999-12-02 04:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_current_color(GtkWidget *w, gpointer data)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkColorSelection *colorsel;
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-02 04:30:15 +00:00
|
|
|
gdouble scolor[4];
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
1999-12-02 04:30:15 +00:00
|
|
|
|
2002-11-11 15:39:06 +00:00
|
|
|
colorsel = GTK_COLOR_SELECTION(OBJECT_GET_DATA(w, STREAM_CS_KEY));
|
1999-12-02 04:30:15 +00:00
|
|
|
curcolor = (GdkColor *) data;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1999-12-02 04:30:15 +00:00
|
|
|
scolor[CS_RED] = (gdouble) (curcolor->red) / 65535.0;
|
|
|
|
scolor[CS_GREEN] = (gdouble) (curcolor->green) / 65535.0;
|
|
|
|
scolor[CS_BLUE] = (gdouble) (curcolor->blue) / 65535.0;
|
|
|
|
scolor[CS_OPACITY] = 1.0;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-12-02 04:30:15 +00:00
|
|
|
gtk_color_selection_set_color(colorsel, &scolor[CS_RED]);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
gtk_color_selection_set_current_color(colorsel, curcolor);
|
|
|
|
#endif
|
1999-12-02 04:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
stream_prefs_fetch(GtkWidget *w _U_)
|
1999-12-02 04:30:15 +00:00
|
|
|
{
|
2000-11-21 23:54:10 +00:00
|
|
|
gdkcolor_to_color_t(&prefs.st_client_fg, &tcolors[CFG_IDX]);
|
|
|
|
gdkcolor_to_color_t(&prefs.st_client_bg, &tcolors[CBG_IDX]);
|
|
|
|
gdkcolor_to_color_t(&prefs.st_server_fg, &tcolors[SFG_IDX]);
|
|
|
|
gdkcolor_to_color_t(&prefs.st_server_bg, &tcolors[SBG_IDX]);
|
1999-12-02 04:30:15 +00:00
|
|
|
}
|
|
|
|
|
2000-09-09 10:04:53 +00:00
|
|
|
/* XXX - "gui_prefs_apply()" handles this, as the "Follow TCP Stream"
|
|
|
|
windows may have to be redrawn due to a font change; this means
|
|
|
|
that calling "stream_prefs_apply()" without calling "gui_prefs_apply()"
|
|
|
|
won't work. */
|
1999-12-02 04:30:15 +00:00
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
stream_prefs_apply(GtkWidget *w _U_)
|
1999-12-02 04:30:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
stream_prefs_destroy(GtkWidget *w _U_)
|
1999-12-02 04:30:15 +00:00
|
|
|
{
|
|
|
|
}
|