aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/gui_prefs.c31
-rw-r--r--gtk/toolbar.c60
-rw-r--r--gtk/toolbar.h4
-rw-r--r--prefs.c28
-rw-r--r--prefs.h10
5 files changed, 93 insertions, 40 deletions
diff --git a/gtk/gui_prefs.c b/gtk/gui_prefs.c
index 57ccbcb1d1..8b151825ac 100644
--- a/gtk/gui_prefs.c
+++ b/gtk/gui_prefs.c
@@ -1,7 +1,7 @@
/* gui_prefs.c
* Dialog box for GUI preferences
*
- * $Id: gui_prefs.c,v 1.41 2003/10/14 23:20:17 guy Exp $
+ * $Id: gui_prefs.c,v 1.42 2003/10/16 21:19:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -45,6 +45,7 @@
#include "proto_draw.h"
#include "main.h"
#include "compat_macros.h"
+#include "toolbar.h"
static void font_browse_cb(GtkWidget *w, gpointer data);
static void font_browse_ok_cb(GtkWidget *w, GtkFontSelectionDialog *fs);
@@ -84,6 +85,8 @@ static void fileopen_selected_cb(GtkWidget *mybutton_rb _U_, gpointer parent_w);
#define GUI_FILEOPEN_KEY "fileopen_behavior"
#define GUI_FILEOPEN_DIR_KEY "fileopen_directory"
+#define GUI_TOOLBAR_STYLE_KEY "toolbar_style"
+
static const enum_val_t scrollbar_placement_vals[] = {
{ "Left", FALSE },
{ "Right", TRUE },
@@ -121,11 +124,18 @@ static const enum_val_t altern_colors_vals[] = {
#endif
static const enum_val_t highlight_style_vals[] = {
- { "Bold", 0 },
- { "Inverse", 1 },
+ { "Bold", FALSE },
+ { "Inverse", TRUE },
{ NULL, 0 }
};
+static const enum_val_t toolbar_style_vals[] = {
+ { "Icons only", TB_STYLE_ICONS },
+ { "Text only", TB_STYLE_TEXT },
+ { "Icons & Text", TB_STYLE_BOTH },
+ { NULL, 0 }
+};
+
static const enum_val_t gui_fileopen_vals[] = {
{ "Remember last directory", FO_STYLE_LAST_OPENED },
{ "Always start in directory:", FO_STYLE_SPECIFIED },
@@ -156,7 +166,7 @@ gui_prefs_show(void)
GtkWidget *main_tb, *main_vb, *hbox, *font_bt, *color_bt;
GtkWidget *scrollbar_om, *plist_browse_om;
GtkWidget *ptree_browse_om, *highlight_style_om;
- GtkWidget *fileopen_rb, *fileopen_dir_te;
+ GtkWidget *fileopen_rb, *fileopen_dir_te, *toolbar_style_om;
GtkWidget *save_position_cb, *save_size_cb;
#if GTK_MAJOR_VERSION < 2
GtkWidget *expander_style_om, *line_style_om;
@@ -230,6 +240,13 @@ gui_prefs_show(void)
OBJECT_SET_DATA(main_vb, HEX_DUMP_HIGHLIGHT_STYLE_KEY,
highlight_style_om);
+ /* Toolbar prefs */
+ toolbar_style_om = create_preference_option_menu(main_tb, pos++,
+ "Toolbar style:", NULL, toolbar_style_vals,
+ prefs.gui_toolbar_main_style);
+ OBJECT_SET_DATA(main_vb, GUI_TOOLBAR_STYLE_KEY,
+ toolbar_style_om);
+
/* Geometry prefs */
save_position_cb = create_preference_check_button(main_tb, pos++,
"Save window position:", NULL, prefs.gui_geometry_save_position);
@@ -479,6 +496,9 @@ gui_prefs_fetch(GtkWidget *w)
prefs.gui_hex_dump_highlight_style = fetch_enum_value(
OBJECT_GET_DATA(w, HEX_DUMP_HIGHLIGHT_STYLE_KEY),
highlight_style_vals);
+ prefs.gui_toolbar_main_style = fetch_enum_value(
+ OBJECT_GET_DATA(w, GUI_TOOLBAR_STYLE_KEY),
+ toolbar_style_vals);
prefs.gui_geometry_save_position =
gtk_toggle_button_get_active(OBJECT_GET_DATA(w,
GEOMETRY_POSITION_KEY));
@@ -549,6 +569,9 @@ gui_prefs_apply(GtkWidget *w _U_)
or the colors to use changed. */
follow_redraw_all();
+ /* XXX: redraw the toolbar only, if style changed */
+ toolbar_redraw_all();
+
set_scrollbar_placement_all();
set_plist_sel_browse(prefs.gui_plist_sel_browse);
set_ptree_sel_browse_all(prefs.gui_ptree_sel_browse);
diff --git a/gtk/toolbar.c b/gtk/toolbar.c
index 7d07590358..20284a2a8c 100644
--- a/gtk/toolbar.c
+++ b/gtk/toolbar.c
@@ -2,7 +2,7 @@
* The main toolbar
* Copyright 2003, Ulf Lamping <ulf.lamping@web.de>
*
- * $Id: toolbar.c,v 1.5 2003/10/16 21:04:20 oabad Exp $
+ * $Id: toolbar.c,v 1.6 2003/10/16 21:19:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -33,7 +33,8 @@
*
* Hint: gtk2 in comparison to gtk1 has a better way to handle with "common"
* icons; gtk2 calls this kind of icons "stock-icons"
- * (stock-icons including: icons for "open", "save", "print", ...)
+ * (stock-icons including: icons for "open", "save", "print", ...).
+ * The gtk2 version of this code uses them.
*/
#ifdef HAVE_CONFIG_H
@@ -87,16 +88,15 @@
#define E_TB_MAIN_HB_KEY "toolbar_main_handlebox"
-gboolean toolbar_init = FALSE;
+static gboolean toolbar_init = FALSE;
-GtkWidget *new_button, *stop_button;
-GtkWidget *open_button, *save_button, *close_button, *reload_button;
-GtkWidget *print_button, *find_button, *find_next_button, *go_to_button;
-GtkWidget *capture_filter_button, *display_filter_button;
-GtkWidget *color_display_button, *prefs_button, *help_button;
+static GtkWidget *new_button, *stop_button;
+static GtkWidget *open_button, *save_button, *close_button, *reload_button;
+static GtkWidget *print_button, *find_button, *find_next_button, *go_to_button;
+static GtkWidget *capture_filter_button, *display_filter_button;
+static GtkWidget *color_display_button, *prefs_button, *help_button;
-void toolbar_redraw_all(void);
-void get_main_toolbar(GtkWidget *window, GtkWidget **toolbar);
+static void get_main_toolbar(GtkWidget *window, GtkWidget **toolbar);
/*
@@ -137,40 +137,42 @@ toolbar_redraw_all(void)
{
GtkWidget *main_tb, *main_tb_hb;
gboolean gui_toolbar_main_show;
- gint gui_toolbar_main_style;
-
- /* Possible toolbar styles (from GTK):
- typedef enum
- {
- GTK_TOOLBAR_ICONS,
- GTK_TOOLBAR_TEXT,
- GTK_TOOLBAR_BOTH,
- GTK_TOOLBAR_BOTH_HORIZ
- } GtkToolbarStyle;
- */
+ static const GtkToolbarStyle styles[] = {
+ GTK_TOOLBAR_ICONS,
+ GTK_TOOLBAR_TEXT,
+ GTK_TOOLBAR_BOTH
+ };
/* default: show toolbar */
/* XXX: get this info from a preference setting */
gui_toolbar_main_show = TRUE;
/* gui_toolbar_main_style = prefs.gui_toolbar_main_show; */
- /* default style: icons only */
- gui_toolbar_main_style = GTK_TOOLBAR_ICONS;
- /* XXX: get this style from a preference setting */
- /* gui_toolbar_main_style = prefs.gui_toolbar_main_style; */
-
main_tb_hb = OBJECT_GET_DATA(top_level, E_TB_MAIN_HB_KEY);
/* does the user want the toolbar? */
if (gui_toolbar_main_show) {
/* yes, set the style he/she prefers (texts, icons, both) */
main_tb = OBJECT_GET_DATA(top_level, E_TB_MAIN_KEY);
- gtk_toolbar_set_style(GTK_TOOLBAR(main_tb), gui_toolbar_main_style);
+ gtk_toolbar_set_style(GTK_TOOLBAR(main_tb),
+ styles[prefs.gui_toolbar_main_style]);
gtk_widget_show(main_tb_hb);
} else {
/* no */
gtk_widget_hide(main_tb_hb);
}
+
+ /* resize ALL elements in the top_level container */
+#if GTK_MAJOR_VERSION >= 2
+ /* XXX - do this on GTK+ 2.x as well? If we don't do it in 1.2[.x],
+ the toolbar takes the maximum vertical size it ever had, even
+ if you change the style in such a way as to reduce its height. */
+#if 0
+ gtk_container_resize_children(GTK_CONTAINER(top_level));
+#endif
+#else
+ gtk_container_queue_resize(GTK_CONTAINER(top_level));
+#endif
}
@@ -224,7 +226,7 @@ void set_toolbar_for_captured_packets(gboolean have_captured_packets) {
/* helper function: add a separator to the toolbar */
-void toolbar_append_separator(GtkWidget *toolbar) {
+static void toolbar_append_separator(GtkWidget *toolbar) {
/* XXX - the usage of a gtk_separator doesn't seem to work for a toolbar.
* (at least in the win32 port of gtk 1.3)
* So simply add a few spaces */
@@ -235,7 +237,7 @@ void toolbar_append_separator(GtkWidget *toolbar) {
/* get the main toolbar (remember: call this only once!) */
-void get_main_toolbar(GtkWidget *window, GtkWidget **toolbar)
+static void get_main_toolbar(GtkWidget *window, GtkWidget **toolbar)
{
GdkPixmap *icon;
GtkWidget *iconw;
diff --git a/gtk/toolbar.h b/gtk/toolbar.h
index f5a96b5f13..d9af92174b 100644
--- a/gtk/toolbar.h
+++ b/gtk/toolbar.h
@@ -2,7 +2,7 @@
* Definitions for toolbar utility routines
* Copyright 2003, Ulf Lamping <ulf.lamping@web.de>
*
- * $Id: toolbar.h,v 1.2 2003/10/16 20:56:07 oabad Exp $
+ * $Id: toolbar.h,v 1.3 2003/10/16 21:19:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -31,6 +31,8 @@ void set_toolbar_for_capture_in_progress(gboolean have_capture_file);
void set_toolbar_for_captured_packets(gboolean have_captured_packets);
void create_toolbar(GtkWidget *main_vbox);
+void toolbar_redraw_all(void);
+
void set_toolbar_object_data(gchar *key, gpointer data);
#endif /* __TOOLBAR_H__ */
diff --git a/prefs.c b/prefs.c
index 1fa71f86ca..eabf9c248c 100644
--- a/prefs.c
+++ b/prefs.c
@@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
- * $Id: prefs.c,v 1.109 2003/10/14 23:20:15 guy Exp $
+ * $Id: prefs.c,v 1.110 2003/10/16 21:19:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -78,18 +78,23 @@ static int mgcp_udp_port_count;
e_prefs prefs;
-gchar *gui_ptree_line_style_text[] =
+static gchar *gui_ptree_line_style_text[] =
{ "NONE", "SOLID", "DOTTED", "TABBED", NULL };
-gchar *gui_ptree_expander_style_text[] =
+static gchar *gui_ptree_expander_style_text[] =
{ "NONE", "SQUARE", "TRIANGLE", "CIRCULAR", NULL };
-gchar *gui_hex_dump_highlight_style_text[] =
+static gchar *gui_hex_dump_highlight_style_text[] =
{ "BOLD", "INVERSE", NULL };
-gchar *gui_fileopen_style_text[] =
+static gchar *gui_fileopen_style_text[] =
{ "LAST_OPENED", "SPECIFIED", NULL };
+/* GTK knows of two ways representing "both", vertical and horizontal aligned.
+ * as this may not work on other guis, we use only "both" in general here */
+static gchar *gui_toolbar_style_text[] =
+ { "ICONS", "TEXT", "BOTH", NULL };
+
/*
* List of all modules with preference settings.
*/
@@ -912,6 +917,7 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
prefs.gui_ptree_line_style = 0;
prefs.gui_ptree_expander_style = 1;
prefs.gui_hex_dump_highlight_style = 1;
+ prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
#ifdef WIN32
prefs.gui_font_name = g_strdup("-*-lucida console-medium-r-*-*-*-100-*-*-*-*-*-*");
#else
@@ -1266,6 +1272,7 @@ prefs_set_pref(char *prefarg)
#define PRS_GUI_GEOMETRY_MAIN_Y "gui.geometry.main.y"
#define PRS_GUI_GEOMETRY_MAIN_WIDTH "gui.geometry.main.width"
#define PRS_GUI_GEOMETRY_MAIN_HEIGHT "gui.geometry.main.height"
+#define PRS_GUI_TOOLBAR_MAIN_STYLE "gui.toolbar_main_style"
/*
* This applies to more than just captures, so it's not "capture.name_resolve";
@@ -1499,6 +1506,11 @@ set_pref(gchar *pref_name, gchar *value)
} else if (strcmp(pref_name, PRS_GUI_HEX_DUMP_HIGHLIGHT_STYLE) == 0) {
prefs.gui_hex_dump_highlight_style =
find_index_from_string_array(value, gui_hex_dump_highlight_style_text, 1);
+ } else if (strcmp(pref_name, PRS_GUI_TOOLBAR_MAIN_STYLE) == 0) {
+ /* see toolbar.c for details, "icons only" is default */
+ prefs.gui_toolbar_main_style =
+ find_index_from_string_array(value, gui_toolbar_style_text,
+ TB_STYLE_ICONS);
} else if (strcmp(pref_name, PRS_GUI_FONT_NAME) == 0) {
if (prefs.gui_font_name != NULL)
g_free(prefs.gui_font_name);
@@ -2065,6 +2077,11 @@ write_prefs(char **pf_path_return)
fprintf(pf, PRS_GUI_HEX_DUMP_HIGHLIGHT_STYLE ": %s\n",
gui_hex_dump_highlight_style_text[prefs.gui_hex_dump_highlight_style]);
+ fprintf(pf, "\n# Main Toolbar style.\n");
+ fprintf(pf, "# One of: ICONS, TEXT, BOTH\n");
+ fprintf(pf, PRS_GUI_TOOLBAR_MAIN_STYLE ": %s\n",
+ gui_toolbar_style_text[prefs.gui_toolbar_main_style]);
+
fprintf(pf, "\n# Font name for packet list, protocol tree, and hex dump panes.\n");
fprintf(pf, PRS_GUI_FONT_NAME ": %s\n", prefs.gui_font_name);
@@ -2204,6 +2221,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
dest->gui_ptree_line_style = src->gui_ptree_line_style;
dest->gui_ptree_expander_style = src->gui_ptree_expander_style;
dest->gui_hex_dump_highlight_style = src->gui_hex_dump_highlight_style;
+ dest->gui_toolbar_main_style = src->gui_toolbar_main_style;
dest->gui_font_name = g_strdup(src->gui_font_name);
dest->gui_marked_fg = src->gui_marked_fg;
dest->gui_marked_bg = src->gui_marked_bg;
diff --git a/prefs.h b/prefs.h
index d82bea9c49..f27d14c544 100644
--- a/prefs.h
+++ b/prefs.h
@@ -1,7 +1,7 @@
/* prefs.h
* Definitions for preference handling routines
*
- * $Id: prefs.h,v 1.48 2003/10/14 23:20:16 guy Exp $
+ * $Id: prefs.h,v 1.49 2003/10/16 21:19:11 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -52,6 +52,13 @@ char string_to_name_resolve(char *string, guint32 *name_resolve);
#define FO_STYLE_LAST_OPENED 0 /* start in last directory we looked at */
#define FO_STYLE_SPECIFIED 1 /* start in specified directory */
+/*
+ * Toolbar styles.
+ */
+#define TB_STYLE_ICONS 0
+#define TB_STYLE_TEXT 1
+#define TB_STYLE_BOTH 2
+
typedef struct _e_prefs {
gint pr_format;
gint pr_dest;
@@ -67,6 +74,7 @@ typedef struct _e_prefs {
gint gui_ptree_line_style;
gint gui_ptree_expander_style;
gboolean gui_hex_dump_highlight_style;
+ gint gui_toolbar_main_style;
gchar *gui_font_name;
color_t gui_marked_fg;
color_t gui_marked_bg;