added some menuitems "View->Show" including show/hide of all main widgets,

saving the states in the recent file

svn path=/trunk/; revision=9726
This commit is contained in:
Ulf Lamping 2004-01-19 00:42:12 +00:00
parent d2a8b3d2cc
commit 453309c0c6
17 changed files with 616 additions and 223 deletions

View File

@ -1,7 +1,7 @@
# Makefile.am
# Automake file for the GTK interface routines for Ethereal
#
# $Id: Makefile.am,v 1.85 2004/01/09 08:36:22 guy Exp $
# $Id: Makefile.am,v 1.86 2004/01/19 00:42:09 ulfl Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@ -132,6 +132,8 @@ libui_a_SOURCES = \
proto_draw.h \
proto_hier_stats_dlg.h \
proto_hier_stats_dlg.c \
recent.c \
recent.h \
rtp_analysis.h \
rtp_stream.c \
rtp_stream.h \
@ -227,6 +229,8 @@ libui_a_SOURCES = \
proto_draw.h \
proto_hier_stats_dlg.h \
proto_hier_stats_dlg.c \
recent.c \
recent.h \
rtp_analysis.h \
rtp_stream.c \
rtp_stream.h \

View File

@ -1,7 +1,7 @@
## Makefile for building ethereal.exe with Microsoft C and nmake
## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
#
# $Id: Makefile.nmake,v 1.69 2004/01/09 08:36:22 guy Exp $
# $Id: Makefile.nmake,v 1.70 2004/01/19 00:42:10 ulfl Exp $
include ..\config.nmake
@ -91,6 +91,7 @@ OBJECTS = \
proto_dlg.obj \
proto_draw.obj \
proto_hier_stats_dlg.obj \
recent.obj \
rtp_stream.obj \
service_response_time_table.obj \
simple_dialog.obj \

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.357 2004/01/18 02:19:07 jmayer Exp $
* $Id: main.c,v 1.358 2004/01/19 00:42:09 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -123,6 +123,7 @@
#include "compat_macros.h"
#include "find_dlg.h"
#include "packet_list.h"
#include "recent.h"
#ifdef WIN32
#include "capture-wpcap.h"
@ -137,6 +138,8 @@ typedef struct column_arrows {
capture_file cfile;
GtkWidget *main_display_filter_widget=NULL;
GtkWidget *top_level = NULL, *tree_view, *byte_nb_ptr, *tv_scrollw;
GtkWidget *upper_pane, *lower_pane;
GtkWidget *menubar, *main_vbox, *main_tb, *pkt_scrollw, *stat_hbox, *filter_tb;
static GtkWidget *info_bar;
#if GTK_MAJOR_VERSION < 2
GdkFont *m_r_font, *m_b_font;
@ -611,104 +614,6 @@ prepare_selected_cb_or_plist_not(GtkWidget *w _U_, gpointer data)
}
#define RECENT_FILE_NAME "recent"
/* Write out "recent" to the user's recent file, and return 0.
If we got an error, stuff a pointer to the path of the recent file
into "*pf_path_return", and return the errno. */
int
write_recent(char **rf_path_return)
{
char *rf_path;
FILE *rf;
/* To do:
* - Split output lines longer than MAX_VAL_LEN
* - Create a function for the preference directory check/creation
* so that duplication can be avoided with filter.c
*/
rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE);
if ((rf = fopen(rf_path, "w")) == NULL) {
*rf_path_return = rf_path;
return errno;
}
fputs("# Recent settings file for Ethereal " VERSION ".\n"
"#\n"
"# This file is regenerated each time Ethereal is quit.\n"
"# So be careful, if you want to make manual changes here.\n"
"\n"
"######## Recent capture files (latest first) ########\n"
"\n", rf);
menu_recent_file_write_all(rf);
fputs("\n"
"######## Recent display filters (latest last) ########\n"
"\n", rf);
dfilter_combo_write_all(rf);
fclose(rf);
/* XXX - catch I/O errors (e.g. "ran out of disk space") and return
an error indication, or maybe write to a new preferences file and
rename that file on top of the old one only if there are not I/O
errors. */
return 0;
}
/* set one user's recent file key/value pair */
static int
set_recent_pair(gchar *key, gchar *value)
{
if (strcmp(key, RECENT_KEY_CAPTURE_FILE) == 0) {
add_menu_recent_capture_file(value);
} else if (strcmp(key, RECENT_KEY_DISPLAY_FILTER) == 0) {
dfilter_combo_add_recent(value);
}
return PREFS_SET_OK;
}
/* opens the user's recent file and read it out */
void
read_recent(char **rf_path_return, int *rf_errno_return)
{
char *rf_path;
FILE *rf;
/* Construct the pathname of the user's recent file. */
rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE);
/* Read the user's recent file, if it exists. */
*rf_path_return = NULL;
if ((rf = fopen(rf_path, "r")) != NULL) {
/* We succeeded in opening it; read it. */
read_prefs_file(rf_path, rf, set_recent_pair);
/* set dfilter combobox to have one empty line at the current position */
dfilter_combo_add_recent("");
fclose(rf);
g_free(rf_path);
rf_path = NULL;
} else {
/* We failed to open it. If we failed for some reason other than
"it doesn't exist", return the errno and the pathname, so our
caller can report the error. */
if (errno != ENOENT) {
*rf_errno_return = errno;
*rf_path_return = rf_path;
}
}
}
static guint dfilter_combo_max_recent = 10;
@ -747,7 +652,7 @@ dfilter_combo_add(GtkWidget *filter_cm, char *s) {
/* write all non empty display filters (until maximum count)
* of the combo box GList to the user's recent file */
void
dfilter_combo_write_all(FILE *rf) {
dfilter_recent_combo_write_all(FILE *rf) {
GtkWidget *filter_cm = OBJECT_GET_DATA(top_level, E_DFILTER_CM_KEY);
GList *filter_list = OBJECT_GET_DATA(filter_cm, E_DFILTER_FL_KEY);
GList *li;
@ -2784,11 +2689,101 @@ not_xlfd:
}
#endif
/*
* Helper for main_widgets_rearrange()
*/
void foreach_remove_a_child(GtkWidget *widget, gpointer data) {
gtk_container_remove(GTK_CONTAINER(data), widget);
}
/*
* Rearrange the main window widgets
*/
void main_widgets_rearrange(void) {
gint widgets = 0;
GtkWidget *w[10];
/* be a bit faster */
gtk_widget_hide(main_vbox);
/* be sure, we don't loose a widget while rearranging */
gtk_widget_ref(menubar);
gtk_widget_ref(main_tb);
gtk_widget_ref(filter_tb);
gtk_widget_ref(pkt_scrollw);
gtk_widget_ref(tv_scrollw);
gtk_widget_ref(byte_nb_ptr);
gtk_widget_ref(upper_pane);
gtk_widget_ref(lower_pane);
gtk_widget_ref(stat_hbox);
gtk_widget_ref(info_bar);
/* empty all containers participating */
gtk_container_foreach(GTK_CONTAINER(main_vbox), foreach_remove_a_child, main_vbox);
gtk_container_foreach(GTK_CONTAINER(upper_pane), foreach_remove_a_child, upper_pane);
gtk_container_foreach(GTK_CONTAINER(lower_pane), foreach_remove_a_child, lower_pane);
gtk_container_foreach(GTK_CONTAINER(stat_hbox), foreach_remove_a_child, stat_hbox);
gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);
if (recent.main_toolbar_show) {
gtk_box_pack_start(GTK_BOX(main_vbox), main_tb, FALSE, TRUE, 0);
}
if (recent.packet_list_show) {
w[widgets++] = pkt_scrollw;
}
if (recent.tree_view_show) {
w[widgets++] = tv_scrollw;
}
if (recent.byte_view_show) {
w[widgets++] = byte_nb_ptr;
}
switch(widgets) {
case(0):
break;
case(1):
gtk_container_add(GTK_CONTAINER(main_vbox), w[0]);
break;
case(2):
gtk_container_add(GTK_CONTAINER(main_vbox), upper_pane);
gtk_paned_pack1(GTK_PANED(upper_pane), w[0], TRUE, TRUE);
gtk_paned_pack2(GTK_PANED(upper_pane), w[1], FALSE, FALSE);
break;
case(3):
gtk_container_add(GTK_CONTAINER(main_vbox), upper_pane);
gtk_paned_add1(GTK_PANED(upper_pane), w[0]);
gtk_paned_add2(GTK_PANED(upper_pane), lower_pane);
gtk_paned_pack1(GTK_PANED(lower_pane), w[1], TRUE, TRUE);
gtk_paned_pack2(GTK_PANED(lower_pane), w[2], FALSE, FALSE);
break;
}
if (recent.statusbar_show || recent.filter_toolbar_show) {
gtk_box_pack_start(GTK_BOX(main_vbox), stat_hbox, FALSE, TRUE, 0);
}
if (recent.filter_toolbar_show) {
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_tb, FALSE, TRUE, 1);
}
if (recent.statusbar_show) {
gtk_box_pack_start(GTK_BOX(stat_hbox), info_bar, TRUE, TRUE, 0);
}
gtk_widget_show(main_vbox);
}
static void
create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
{
GtkWidget *main_vbox, *menubar, *u_pane, *l_pane,
*stat_hbox,
GtkWidget
*filter_bt, *filter_cm, *filter_te,
*filter_apply,
*filter_reset;
@ -2832,26 +2827,19 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gtk_widget_show(main_vbox);
/* Menu bar */
get_main_menu(&menubar, &accel);
menubar = main_menu_new(&accel);
gtk_window_add_accel_group(GTK_WINDOW(top_level), accel);
gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);
gtk_widget_show(menubar);
/* Main Toolbar */
create_toolbar(main_vbox);
/* Panes for the packet list, tree, and byte view */
u_pane = gtk_vpaned_new();
gtk_paned_gutter_size(GTK_PANED(u_pane), (GTK_PANED(u_pane))->handle_size);
l_pane = gtk_vpaned_new();
gtk_paned_gutter_size(GTK_PANED(l_pane), (GTK_PANED(l_pane))->handle_size);
gtk_container_add(GTK_CONTAINER(main_vbox), u_pane);
gtk_widget_show(l_pane);
gtk_paned_add2(GTK_PANED(u_pane), l_pane);
gtk_widget_show(u_pane);
main_tb = toolbar_new();
//gtk_box_pack_start(GTK_BOX(main_vbox), main_tb, FALSE, TRUE, 0);
gtk_widget_show (main_tb);
/* Packet list */
packet_list_new(u_pane, prefs, pl_size);
pkt_scrollw = packet_list_new(prefs);
WIDGET_SET_SIZE(packet_list, -1, pl_size);
gtk_widget_show(pkt_scrollw);
/* Tree view */
#if GTK_MAJOR_VERSION < 2
@ -2859,7 +2847,10 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gdk_font_unref(item_style->font);
item_style->font = m_r_font;
#endif
create_tree_view(tv_size, prefs, l_pane, &tv_scrollw, &tree_view);
tv_scrollw = main_tree_view_new(prefs, &tree_view);
WIDGET_SET_SIZE(tv_scrollw, -1, tv_size);
gtk_widget_show(tv_scrollw);
#if GTK_MAJOR_VERSION < 2
SIGNAL_CONNECT(tree_view, "tree-select-row", tree_view_select_row_cb, NULL);
SIGNAL_CONNECT(tree_view, "tree-unselect-row", tree_view_unselect_row_cb,
@ -2873,23 +2864,42 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gtk_widget_show(tree_view);
/* Byte view. */
byte_nb_ptr = create_byte_view(bv_size, l_pane);
byte_nb_ptr = byte_view_new();
WIDGET_SET_SIZE(byte_nb_ptr, -1, bv_size);
gtk_widget_show(byte_nb_ptr);
SIGNAL_CONNECT(byte_nb_ptr, "button_press_event", popup_menu_handler,
OBJECT_GET_DATA(popup_menu_object, PM_HEXDUMP_KEY));
/* Filter/info box */
stat_hbox = gtk_hbox_new(FALSE, 1);
gtk_container_border_width(GTK_CONTAINER(stat_hbox), 0);
gtk_box_pack_start(GTK_BOX(main_vbox), stat_hbox, FALSE, TRUE, 0);
gtk_widget_show(stat_hbox);
/* Panes for the packet list, tree, and byte view */
lower_pane = gtk_vpaned_new();
gtk_paned_gutter_size(GTK_PANED(lower_pane), (GTK_PANED(lower_pane))->handle_size);
gtk_widget_show(lower_pane);
upper_pane = gtk_vpaned_new();
gtk_paned_gutter_size(GTK_PANED(upper_pane), (GTK_PANED(upper_pane))->handle_size);
gtk_widget_show(upper_pane);
/* filter toolbar */
#if GTK_MAJOR_VERSION < 2
filter_tb = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
GTK_TOOLBAR_BOTH);
#else
filter_tb = gtk_toolbar_new();
gtk_toolbar_set_orientation(GTK_TOOLBAR(filter_tb),
GTK_ORIENTATION_HORIZONTAL);
#endif /* GTK_MAJOR_VERSION */
gtk_widget_show(filter_tb);
filter_bt = gtk_button_new_with_label("Filter:");
SIGNAL_CONNECT(filter_bt, "clicked", display_filter_construct_cb, &args);
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_bt, FALSE, TRUE, 0);
gtk_widget_show(filter_bt);
OBJECT_SET_DATA(top_level, E_FILT_BT_PTR_KEY, filter_bt);
gtk_toolbar_append_widget(GTK_TOOLBAR(filter_tb), filter_bt,
"Open display filter dialog", "Private");
filter_cm = gtk_combo_new();
filter_list = g_list_append (filter_list, "");
gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), filter_list);
@ -2901,21 +2911,25 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);
OBJECT_SET_DATA(filter_te, E_DFILTER_CM_KEY, filter_cm);
OBJECT_SET_DATA(top_level, E_DFILTER_CM_KEY, filter_cm);
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_cm, TRUE, TRUE, 3);
SIGNAL_CONNECT(filter_te, "activate", filter_activate_cb, filter_te);
WIDGET_SET_SIZE(filter_cm, 400, -1);
gtk_widget_show(filter_cm);
gtk_toolbar_append_widget(GTK_TOOLBAR(filter_tb), filter_cm,
"Enter a display filter", "Private");
filter_reset = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLEAR);
OBJECT_SET_DATA(filter_reset, E_DFILTER_TE_KEY, filter_te);
SIGNAL_CONNECT(filter_reset, "clicked", filter_reset_cb, NULL);
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_reset, FALSE, TRUE, 1);
gtk_widget_show(filter_reset);
gtk_toolbar_append_widget(GTK_TOOLBAR(filter_tb), filter_reset,
"Clear the display filter", "Private");
filter_apply = BUTTON_NEW_FROM_STOCK(GTK_STOCK_APPLY);
OBJECT_SET_DATA(filter_apply, E_DFILTER_CM_KEY, filter_cm);
SIGNAL_CONNECT(filter_apply, "clicked", filter_activate_cb, filter_te);
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_apply, FALSE, TRUE, 1);
gtk_widget_show(filter_apply);
gtk_toolbar_append_widget(GTK_TOOLBAR(filter_tb), filter_apply,
"Apply the display filter", "Private");
/* Sets the text entry widget pointer as the E_DILTER_TE_KEY data
* of any widget that ends up calling a callback which needs
@ -2953,14 +2967,22 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
OBJECT_SET_DATA(popup_menu_object, E_DFILTER_TE_KEY, filter_te);
OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_KEY, packet_list);
/* statusbar */
info_bar = gtk_statusbar_new();
main_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "main");
file_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "file");
help_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "help");
gtk_statusbar_push(GTK_STATUSBAR(info_bar), main_ctx, DEF_READY_MESSAGE);
gtk_box_pack_start(GTK_BOX(stat_hbox), info_bar, TRUE, TRUE, 0);
gtk_widget_show(info_bar);
/* Filter/info hbox */
stat_hbox = gtk_hbox_new(FALSE, 1);
gtk_container_border_width(GTK_CONTAINER(stat_hbox), 0);
gtk_widget_show(stat_hbox);
/* rearrange all the widgets */
main_widgets_rearrange();
gtk_widget_show(top_level);
/* Fill in column titles. This must be done after the top level window

View File

@ -1,7 +1,7 @@
/* main.h
* Global defines, etc.
*
* $Id: main.h,v 1.35 2004/01/09 08:36:23 guy Exp $
* $Id: main.h,v 1.36 2004/01/19 00:42:09 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -96,11 +96,10 @@ void collapse_all_cb(GtkWidget *, gpointer);
void resolve_name_cb(GtkWidget *, gpointer);
void reftime_frame_cb(GtkWidget *, gpointer, guint);
#define RECENT_KEY_CAPTURE_FILE "recent.capture_file"
#define RECENT_KEY_DISPLAY_FILTER "recent.display_filter"
extern gboolean dfilter_combo_add_recent(gchar *s);
extern void dfilter_recent_combo_write_all(FILE *rf);
gboolean dfilter_combo_add_recent(gchar *s);
void dfilter_combo_write_all(FILE *rf);
extern void main_widgets_rearrange(void);
char *boldify(const char *);
#if GTK_MAJOR_VERSION < 2

View File

@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
* $Id: menu.c,v 1.136 2004/01/09 08:36:23 guy Exp $
* $Id: menu.c,v 1.137 2004/01/19 00:42:10 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -66,6 +66,7 @@
#include "../ipproto.h"
#include "packet_list.h"
#include "ethclist.h"
#include "recent.h"
GtkWidget *popup_menu_object;
@ -78,6 +79,12 @@ clear_menu_recent_capture_file_cmd_cb(GtkWidget *w, gpointer unused _U_);
static void menus_init(void);
static void set_menu_sensitivity (GtkItemFactory *, gchar *, gint);
static void main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
static void statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
/* This is the GtkItemFactoryEntry structure used to generate new menus.
Item 1: The menu path. The letter after the underscore indicates an
@ -167,27 +174,28 @@ static GtkItemFactoryEntry menu_items[] =
ITEM_FACTORY_STOCK_ENTRY("/Edit/_Preferences...", "<shift><control>P", prefs_cb,
0, GTK_STOCK_PREFERENCES),
ITEM_FACTORY_ENTRY("/_View", NULL, NULL, 0, "<Branch>", NULL),
#if 0
/* XXX: the show/hide functionality of the GUI elements is currently not implemented */
ITEM_FACTORY_ENTRY("/View/_Show", NULL, NULL, 0, "<Branch>", NULL),
ITEM_FACTORY_ENTRY("/View/_Show/Main Toolbar", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Show/Filter Toolbar", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Show/Status Bar", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Show/Packet List", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Show/Packet Dissection", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Show/Packet Data", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Show/Main Toolbar", NULL, main_toolbar_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Show/Filter Toolbar", NULL, filter_toolbar_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Show/<separator>", NULL, NULL, 0, "<Separator>", NULL),
ITEM_FACTORY_ENTRY("/View/Show/Packet List", NULL, packet_list_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Show/Packet Dissection", NULL, tree_view_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Show/Packet Data", NULL, byte_view_show_cb, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Show/<separator>", NULL, NULL, 0, "<Separator>", NULL),
ITEM_FACTORY_ENTRY("/View/Show/Status Bar", NULL, statusbar_show_cb, 0, "<CheckItem>", NULL),
#if 0
/* XXX: the settings in the "Options" dialog could be seperated into the following menu items. */
/* before this, some effort must be taken to transfer the functionality of this dialog to the menu items */
/* (getting the current values, handling the radioitems, ...) */
ITEM_FACTORY_ENTRY("/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL),
ITEM_FACTORY_ENTRY("/View/_Time Display Format/Time of day", NULL, NULL, 0, "<RadioItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Time Display Format/Date and time of day", NULL, NULL, 0, "<RadioItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Time Display Format/Seconds since beginning of capture", NULL, NULL, 0, "<RadioItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Time Display Format/Seconds since previous capture", NULL, NULL, 0, "<RadioItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Time Display Format/Time of day", NULL, NULL, 0, "<RadioItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Time Display Format/Date and time of day", NULL, NULL, 0, "<RadioItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds since beginning of capture", NULL, NULL, 0, "<RadioItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds since previous capture", NULL, NULL, 0, "<RadioItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Name Resolution", NULL, NULL, 0, "<Branch>", NULL),
ITEM_FACTORY_ENTRY("/View/_Name Resolution/Enable MAC", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Name Resolution/Enable Network", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/_Name Resolution/Enable Transport", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable MAC", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable Network", NULL, NULL, 0, "<CheckItem>", NULL),
ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable Transport", NULL, NULL, 0, "<CheckItem>", NULL),
#else
ITEM_FACTORY_ENTRY("/View/_Options...", NULL, display_opt_cb,
0, NULL, NULL),
@ -400,19 +408,21 @@ static GSList *popup_menu_list = NULL;
static GtkAccelGroup *grp;
void
get_main_menu(GtkWidget ** menubar, GtkAccelGroup ** table) {
GtkWidget *
main_menu_new(GtkAccelGroup ** table) {
GtkWidget *menubar;
grp = gtk_accel_group_new();
if (initialize)
menus_init();
if (menubar)
*menubar = main_menu_factory->widget;
menubar = main_menu_factory->widget;
if (table)
*table = grp;
return menubar;
}
static void
@ -461,6 +471,7 @@ menus_init(void) {
set_menus_for_selected_packet(&cfile);
set_menus_for_selected_tree_row(&cfile);
/* init with an empty recent files list */
clear_menu_recent_capture_file_cmd_cb(NULL, NULL);
}
}
@ -885,6 +896,99 @@ menu_recent_file_write_all(FILE *rf) {
}
static void
main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
{
/* save current setting in recent */
recent.main_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
main_widgets_rearrange();
}
static void
filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
{
/* save current setting in recent */
recent.filter_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
main_widgets_rearrange();
}
static void
packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_)
{
/* save current setting in recent */
recent.packet_list_show = GTK_CHECK_MENU_ITEM(w)->active;
main_widgets_rearrange();
}
static void
tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_)
{
/* save current setting in recent */
recent.tree_view_show = GTK_CHECK_MENU_ITEM(w)->active;
main_widgets_rearrange();
}
static void
byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_)
{
/* save current setting in recent */
recent.byte_view_show = GTK_CHECK_MENU_ITEM(w)->active;
main_widgets_rearrange();
}
static void
statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
{
/* save current setting in recent */
recent.statusbar_show = GTK_CHECK_MENU_ITEM(w)->active;
main_widgets_rearrange();
}
/* the recent file read has finished, update the menu corresponding */
void
menu_recent_read_finished(void) {
GtkWidget *menu = NULL;
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Main Toolbar");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Filter Toolbar");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Packet List");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Packet Dissection");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Packet Data");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Status Bar");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
main_widgets_rearrange();
}
gint
popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
{

View File

@ -1,7 +1,7 @@
/* menu.h
* Menu definitions
*
* $Id: menu.h,v 1.13 2003/12/17 22:13:07 guy Exp $
* $Id: menu.h,v 1.14 2004/01/19 00:42:10 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -32,7 +32,7 @@ extern "C" {
/* Write all recent capture filenames to the user's recent file */
void menu_recent_file_write_all(FILE *rf);
void get_main_menu (GtkWidget **, GtkAccelGroup **);
GtkWidget *main_menu_new(GtkAccelGroup **);
void set_menu_object_data (gchar *path, gchar *key, gpointer data);
gint popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data);

View File

@ -1,7 +1,7 @@
/* packet_list.c
* packet list related functions 2002 Olivier Abad
*
* $Id: packet_list.c,v 1.9 2004/01/09 20:36:47 guy Exp $
* $Id: packet_list.c,v 1.10 2004/01/19 00:42:10 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -393,8 +393,8 @@ set_plist_font(PangoFontDescription *font)
}
}
void
packet_list_new(GtkWidget *u_pane, e_prefs *prefs, gint pl_size)
GtkWidget *
packet_list_new(e_prefs *prefs)
{
GtkWidget *pkt_scrollw;
int i;
@ -403,8 +403,6 @@ packet_list_new(GtkWidget *u_pane, e_prefs *prefs, gint pl_size)
pkt_scrollw = scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(pkt_scrollw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show(pkt_scrollw);
gtk_paned_add1(GTK_PANED(u_pane), pkt_scrollw);
packet_list = eth_clist_new(cfile.cinfo.num_cols);
/* Column titles are filled in below */
@ -426,13 +424,14 @@ packet_list_new(GtkWidget *u_pane, e_prefs *prefs, gint pl_size)
eth_clist_set_column_justification(ETH_CLIST(packet_list), i,
GTK_JUSTIFY_RIGHT);
}
WIDGET_SET_SIZE(packet_list, -1, pl_size);
SIGNAL_CONNECT(packet_list, "button_press_event", popup_menu_handler,
OBJECT_GET_DATA(popup_menu_object, PM_PACKET_LIST_KEY));
SIGNAL_CONNECT(packet_list, "button_press_event",
packet_list_button_pressed_cb, NULL);
eth_clist_set_compare_func(ETH_CLIST(packet_list), packet_list_compare);
gtk_widget_show(packet_list);
return pkt_scrollw;
}
void

View File

@ -1,7 +1,7 @@
/* packet_list.h
* Declarations of GTK+-specific routines for managing the packet list.
*
* $Id: packet_list.h,v 1.1 2004/01/09 08:36:23 guy Exp $
* $Id: packet_list.h,v 1.2 2004/01/19 00:42:10 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -25,7 +25,7 @@
#ifndef __PACKET_LIST_H__
#define __PACKET_LIST_H__
extern void packet_list_new(GtkWidget *u_pane, e_prefs *prefs, gint pl_size);
extern GtkWidget *packet_list_new(e_prefs *prefs);
extern void packet_list_set_column_titles(void);
extern void mark_frame_cb(GtkWidget *, gpointer);

View File

@ -3,7 +3,7 @@
*
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
* $Id: packet_win.c,v 1.42 2002/11/11 15:39:05 oabad Exp $
* $Id: packet_win.c,v 1.43 2004/01/19 00:42:10 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -144,11 +144,17 @@ void new_window_cb(GtkWidget *w _U_)
gtk_widget_show(pane);
/* Tree view */
create_tree_view(tv_size, &prefs, pane, &tv_scrollw, &tree_view);
tv_scrollw = main_tree_view_new(&prefs, &tree_view);
gtk_paned_pack1(GTK_PANED(pane), tv_scrollw, TRUE, TRUE);
WIDGET_SET_SIZE(tv_scrollw, -1, tv_size);
gtk_widget_show(tv_scrollw);
gtk_widget_show(tree_view);
/* Byte view */
bv_nb_ptr = create_byte_view(bv_size, pane);
bv_nb_ptr = byte_view_new();
gtk_paned_pack2(GTK_PANED(pane), bv_nb_ptr, FALSE, FALSE);
WIDGET_SET_SIZE(bv_nb_ptr, -1, bv_size);
gtk_widget_show(bv_nb_ptr);
DataPtr->main = main_w;
DataPtr->tv_scrollw = tv_scrollw;

View File

@ -1,7 +1,7 @@
/* proto_draw.c
* Routines for GTK+ packet display
*
* $Id: proto_draw.c,v 1.78 2004/01/10 16:35:10 ulfl Exp $
* $Id: proto_draw.c,v 1.79 2004/01/19 00:42:10 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -593,21 +593,13 @@ byte_view_button_press_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
}
GtkWidget *
create_byte_view(gint bv_size, GtkWidget *pane)
byte_view_new(void)
{
GtkWidget *byte_nb;
byte_nb = gtk_notebook_new();
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(byte_nb), GTK_POS_BOTTOM);
gtk_paned_pack2(GTK_PANED(pane), byte_nb, FALSE, FALSE);
#if GTK_MAJOR_VERSION < 2
WIDGET_SET_SIZE(byte_nb, -1, bv_size);
#else
gtk_widget_set_size_request(byte_nb, -1, bv_size);
#endif
gtk_widget_show(byte_nb);
/* Add a placeholder byte view so that there's at least something
displayed in the byte view notebook. */
add_byte_tab(byte_nb, "", NULL, NULL, NULL);
@ -1461,9 +1453,8 @@ set_ptree_font_all(PangoFontDescription *font)
#endif
}
void
create_tree_view(gint tv_size, e_prefs *prefs, GtkWidget *pane,
GtkWidget **tv_scrollw_p, GtkWidget **tree_view_p)
GtkWidget *
main_tree_view_new(e_prefs *prefs, GtkWidget **tree_view_p)
{
GtkWidget *tv_scrollw, *tree_view;
#if GTK_MAJOR_VERSION >= 2
@ -1482,9 +1473,6 @@ create_tree_view(gint tv_size, e_prefs *prefs, GtkWidget *pane,
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(tv_scrollw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
#endif
gtk_paned_pack1(GTK_PANED(pane), tv_scrollw, TRUE, TRUE);
WIDGET_SET_SIZE(tv_scrollw, -1, tv_size);
gtk_widget_show(tv_scrollw);
#if GTK_MAJOR_VERSION < 2
tree_view = ctree_new(1, 0);
@ -1520,7 +1508,8 @@ create_tree_view(gint tv_size, e_prefs *prefs, GtkWidget *pane,
remember_ptree_widget(tree_view);
*tree_view_p = tree_view;
*tv_scrollw_p = tv_scrollw;
return tv_scrollw;
}
#if GTK_MAJOR_VERSION < 2

View File

@ -1,7 +1,7 @@
/* proto_draw.h
* Definitions for GTK+ packet display structures and routines
*
* $Id: proto_draw.h,v 1.21 2002/11/03 17:38:34 oabad Exp $
* $Id: proto_draw.h,v 1.22 2004/01/19 00:42:11 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -47,7 +47,7 @@ extern void redraw_hex_dump(GtkWidget *nb, frame_data *fd, field_info *finfo);
/* Redraw all byte view windows. */
extern void redraw_hex_dump_all(void);
extern GtkWidget *create_byte_view(gint bv_size, GtkWidget *pane);
extern GtkWidget *byte_view_new(void);
extern void add_byte_views(epan_dissect_t *edt, GtkWidget *tree_view,
GtkWidget *byte_nb_ptr);
@ -64,8 +64,7 @@ void packet_hex_reprint(GtkTextView *);
void set_ptree_font_all(PangoFontDescription *font);
#endif
void create_tree_view(gint tv_size, e_prefs *prefs, GtkWidget *pane,
GtkWidget **tv_scrollw_p, GtkWidget **tree_view_p);
extern GtkWidget * main_tree_view_new(e_prefs *prefs, GtkWidget **tree_view_p);
void proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view);
void expand_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view);
void collapse_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view);

231
gtk/recent.c Normal file
View File

@ -0,0 +1,231 @@
/* recent.c
* Recent "preference" handling routines
* Copyright 2004, Ulf Lamping <ulf.lamping@web.de>
*
* $Id: recent.c,v 1.1 2004/01/19 00:42:11 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
*
*
* 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.
*
* 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.
*
* 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
#include <gtk/gtk.h>
#include <stdio.h>
#include "recent.h"
#include <epan/epan.h>
#include <epan/filesystem.h>
#include "menu.h"
#include "main.h"
#include "prefs.h"
#include "prefs-int.h"
#define RECENT_FILE_NAME "recent"
/* #include "../menu.h" */
extern void add_menu_recent_capture_file(gchar *file);
extern void menu_recent_read_finished(void);
recent_settings_t recent;
/* Write out "recent" to the user's recent file, and return 0.
If we got an error, stuff a pointer to the path of the recent file
into "*pf_path_return", and return the errno. */
int
write_recent(char **rf_path_return)
{
char *rf_path;
FILE *rf;
/* To do:
* - Split output lines longer than MAX_VAL_LEN
* - Create a function for the preference directory check/creation
* so that duplication can be avoided with filter.c
*/
rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE);
if ((rf = fopen(rf_path, "w")) == NULL) {
*rf_path_return = rf_path;
return errno;
}
fputs("# Recent settings file for Ethereal " VERSION ".\n"
"#\n"
"# This file is regenerated each time Ethereal is quit.\n"
"# So be careful, if you want to make manual changes here.\n"
"\n"
"######## Recent capture files (latest first) ########\n"
"\n", rf);
menu_recent_file_write_all(rf);
fputs("\n"
"######## Recent display filters (latest last) ########\n"
"\n", rf);
dfilter_recent_combo_write_all(rf);
fprintf(rf, "\n# Main Toolbar show (hide).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_KEY_MAIN_TOOLBAR_SHOW ": %s\n",
recent.main_toolbar_show == TRUE ? "TRUE" : "FALSE");
fprintf(rf, "\n# Filter Toolbar show (hide).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_KEY_FILTER_TOOLBAR_SHOW ": %s\n",
recent.filter_toolbar_show == TRUE ? "TRUE" : "FALSE");
fprintf(rf, "\n# Packet list show (hide).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_KEY_PACKET_LIST_SHOW ": %s\n",
recent.packet_list_show == TRUE ? "TRUE" : "FALSE");
fprintf(rf, "\n# Tree view show (hide).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_KEY_TREE_VIEW_SHOW ": %s\n",
recent.tree_view_show == TRUE ? "TRUE" : "FALSE");
fprintf(rf, "\n# Byte view show (hide).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_KEY_BYTE_VIEW_SHOW ": %s\n",
recent.byte_view_show == TRUE ? "TRUE" : "FALSE");
fprintf(rf, "\n# Statusbar show (hide).\n");
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_KEY_STATUSBAR_SHOW ": %s\n",
recent.statusbar_show == TRUE ? "TRUE" : "FALSE");
fclose(rf);
/* XXX - catch I/O errors (e.g. "ran out of disk space") and return
an error indication, or maybe write to a new preferences file and
rename that file on top of the old one only if there are not I/O
errors. */
return 0;
}
/* set one user's recent file key/value pair */
static int
read_set_recent_pair(gchar *key, gchar *value)
{
if (strcmp(key, RECENT_KEY_CAPTURE_FILE) == 0) {
add_menu_recent_capture_file(value);
} else if (strcmp(key, RECENT_KEY_DISPLAY_FILTER) == 0) {
dfilter_combo_add_recent(value);
} else if (strcmp(key, RECENT_KEY_MAIN_TOOLBAR_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.main_toolbar_show = TRUE;
}
else {
recent.main_toolbar_show = FALSE;
}
} else if (strcmp(key, RECENT_KEY_FILTER_TOOLBAR_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.filter_toolbar_show = TRUE;
}
else {
recent.filter_toolbar_show = FALSE;
}
} else if (strcmp(key, RECENT_KEY_PACKET_LIST_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.packet_list_show = TRUE;
}
else {
recent.packet_list_show = FALSE;
}
} else if (strcmp(key, RECENT_KEY_TREE_VIEW_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.tree_view_show = TRUE;
}
else {
recent.tree_view_show = FALSE;
}
} else if (strcmp(key, RECENT_KEY_BYTE_VIEW_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.byte_view_show = TRUE;
}
else {
recent.byte_view_show = FALSE;
}
} else if (strcmp(key, RECENT_KEY_STATUSBAR_SHOW) == 0) {
if (strcasecmp(value, "true") == 0) {
recent.statusbar_show = TRUE;
}
else {
recent.statusbar_show = FALSE;
}
}
return PREFS_SET_OK;
}
/* opens the user's recent file and read it out */
void
read_recent(char **rf_path_return, int *rf_errno_return)
{
char *rf_path;
FILE *rf;
/* set defaults */
recent.main_toolbar_show = TRUE;
recent.filter_toolbar_show= TRUE;
recent.packet_list_show = TRUE;
recent.tree_view_show = TRUE;
recent.byte_view_show = TRUE;
recent.statusbar_show = TRUE;
/* Construct the pathname of the user's recent file. */
rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE);
/* Read the user's recent file, if it exists. */
*rf_path_return = NULL;
if ((rf = fopen(rf_path, "r")) != NULL) {
/* We succeeded in opening it; read it. */
read_prefs_file(rf_path, rf, read_set_recent_pair);
/* set dfilter combobox to have one empty line at the current position */
dfilter_combo_add_recent("");
fclose(rf);
g_free(rf_path);
rf_path = NULL;
} else {
/* We failed to open it. If we failed for some reason other than
"it doesn't exist", return the errno and the pathname, so our
caller can report the error. */
if (errno != ENOENT) {
*rf_errno_return = errno;
*rf_path_return = rf_path;
}
}
menu_recent_read_finished();
}

61
gtk/recent.h Normal file
View File

@ -0,0 +1,61 @@
/* recent.h
* Definitions for recent "preference" handling routines
* Copyright 2004, Ulf Lamping <ulf.lamping@web.de>
*
* $Id: recent.h,v 1.1 2004/01/19 00:42:11 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* 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.
*
* 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.
*
* 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.
*/
#ifndef __RECENT_H__
#define __RECENT_H__
#include <glib.h>
#define RECENT_KEY_CAPTURE_FILE "recent.capture_file"
#define RECENT_KEY_DISPLAY_FILTER "recent.display_filter"
#define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show"
#define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show"
#define RECENT_KEY_PACKET_LIST_SHOW "gui.packet_list_show"
#define RECENT_KEY_TREE_VIEW_SHOW "gui.tree_view_show"
#define RECENT_KEY_BYTE_VIEW_SHOW "gui.byte_view_show"
#define RECENT_KEY_STATUSBAR_SHOW "gui.statusbar_show"
typedef struct recent_settings_tag {
gboolean main_toolbar_show;
gboolean filter_toolbar_show;
gboolean packet_list_show;
/*gboolean packet_list_height;*/
gboolean tree_view_show;
/*gboolean tree_view_height;*/
gboolean byte_view_show;
gboolean statusbar_show;
} recent_settings_t;
extern recent_settings_t recent;
extern int write_recent(char **rf_path_return);
extern void read_recent(char **rf_path_return, int *rf_errno_return);
#endif /* recent.h */

View File

@ -2,7 +2,7 @@
* The main toolbar
* Copyright 2003, Ulf Lamping <ulf.lamping@web.de>
*
* $Id: toolbar.c,v 1.19 2004/01/10 17:10:06 ulfl Exp $
* $Id: toolbar.c,v 1.20 2004/01/19 00:42:11 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -60,6 +60,7 @@
#include "toolbar.h"
#include "keys.h"
#include "compat_macros.h"
#include "recent.h"
/* All of the icons used here are coming (or are derived) from GTK2 stock icons.
* They were converted using "The Gimp" with standard conversion from png to xpm.
@ -170,8 +171,8 @@ void ethereal_stock_icons(void) {
/*
* Create all toolbars (currently only the main toolbar)
*/
void
create_toolbar(GtkWidget *main_vbox)
GtkWidget *
toolbar_new(void)
{
GtkWidget *main_tb;
@ -187,11 +188,12 @@ create_toolbar(GtkWidget *main_vbox)
gtk_toolbar_set_space_size(GTK_TOOLBAR(main_tb), 3);
#endif
gtk_box_pack_start(GTK_BOX(main_vbox), main_tb, FALSE, TRUE, 0);
OBJECT_SET_DATA(top_level, E_TB_MAIN_KEY, main_tb);
/* make current preferences effective */
toolbar_redraw_all();
return main_tb;
}
/*
@ -204,16 +206,8 @@ toolbar_redraw_all(void)
main_tb = OBJECT_GET_DATA(top_level, E_TB_MAIN_KEY);
/* does the user want the toolbar? */
if (prefs.gui_toolbar_main_show) {
/* yes, set the style he/she prefers (texts, icons, both) */
gtk_toolbar_set_style(GTK_TOOLBAR(main_tb),
gtk_toolbar_set_style(GTK_TOOLBAR(main_tb),
prefs.gui_toolbar_main_style);
gtk_widget_show(main_tb);
} else {
/* no */
gtk_widget_hide(main_tb);
}
#if GTK_MAJOR_VERSION < 2
/* In GTK+ 1.2[.x], the toolbar takes the maximum vertical size it ever
@ -674,8 +668,6 @@ static void get_main_toolbar(GtkWidget *window, GtkWidget **toolbar)
#ifdef HAVE_LIBPCAP
set_toolbar_for_capture_in_progress(FALSE);
#endif /* HAVE_LIBPCAP */
/* everything is well done here :-) */
gtk_widget_show (*toolbar);
}
void

View File

@ -2,7 +2,7 @@
* Definitions for toolbar utility routines
* Copyright 2003, Ulf Lamping <ulf.lamping@web.de>
*
* $Id: toolbar.h,v 1.5 2003/11/15 11:44:10 ulfl Exp $
* $Id: toolbar.h,v 1.6 2004/01/19 00:42:12 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -39,7 +39,7 @@ void set_toolbar_for_unsaved_capture_file(gboolean have_unsaved_capture_file);
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);
GtkWidget *toolbar_new(void);
void toolbar_redraw_all(void);
void set_toolbar_object_data(gchar *key, gpointer data);

17
prefs.c
View File

@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
* $Id: prefs.c,v 1.120 2004/01/05 19:31:44 ulfl Exp $
* $Id: prefs.c,v 1.121 2004/01/19 00:42:08 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -921,7 +921,6 @@ 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_show = TRUE;
prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
#ifdef WIN32
prefs.gui_font_name = g_strdup("-*-lucida console-medium-r-*-*-*-100-*-*-*-*-*-*");
@ -1525,13 +1524,7 @@ set_pref(gchar *pref_name, gchar *value)
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_SHOW) == 0) {
/* see toolbar.c for details */
if (strcasecmp(value, "true") == 0) {
prefs.gui_toolbar_main_show = TRUE;
}
else {
prefs.gui_toolbar_main_show = FALSE;
}
/* obsoleted by recent setting */
} 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 =
@ -2118,11 +2111,6 @@ 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 show/hide.\n");
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(pf, PRS_GUI_TOOLBAR_MAIN_SHOW ": %s\n",
prefs.gui_toolbar_main_show == TRUE ? "TRUE" : "FALSE");
fprintf(pf, "\n# Main Toolbar style.\n");
fprintf(pf, "# One of: ICONS, TEXT, BOTH\n");
fprintf(pf, PRS_GUI_TOOLBAR_MAIN_STYLE ": %s\n",
@ -2270,7 +2258,6 @@ 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_show = src->gui_toolbar_main_show;
dest->gui_toolbar_main_style = src->gui_toolbar_main_style;
dest->gui_fileopen_dir = g_strdup(src->gui_fileopen_dir);
dest->gui_fileopen_remembered_dir = g_strdup(src->gui_fileopen_remembered_dir);

View File

@ -1,7 +1,7 @@
/* prefs.h
* Definitions for preference handling routines
*
* $Id: prefs.h,v 1.53 2003/12/29 19:56:24 guy Exp $
* $Id: prefs.h,v 1.54 2004/01/19 00:42:08 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -74,7 +74,6 @@ typedef struct _e_prefs {
gint gui_ptree_line_style;
gint gui_ptree_expander_style;
gboolean gui_hex_dump_highlight_style;
gboolean gui_toolbar_main_show;
gint gui_toolbar_main_style;
gchar *gui_font_name;
color_t gui_marked_fg;