From 4151a40503dbffc9b44aad461bc333f79bb25d48 Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Sat, 12 Apr 2008 16:38:13 +0000 Subject: rename toolbar to main_toolbar svn path=/trunk/; revision=24940 --- gtk/Makefile.am | 2 +- gtk/Makefile.common | 2 +- gtk/capture_if_dlg.c | 2 +- gtk/gui_prefs.c | 2 +- gtk/libui.vcproj | 16 +- gtk/main.c | 4 +- gtk/main_toolbar.c | 520 +++++++++++++++++++++++++++++++++++++++++++++++++++ gtk/main_toolbar.h | 94 ++++++++++ gtk/menu.c | 2 +- gtk/toolbar.c | 519 -------------------------------------------------- gtk/toolbar.h | 94 ---------- 11 files changed, 628 insertions(+), 629 deletions(-) create mode 100644 gtk/main_toolbar.c create mode 100644 gtk/main_toolbar.h delete mode 100644 gtk/toolbar.c delete mode 100644 gtk/toolbar.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 8b5b02595e..89a821d4f4 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -90,6 +90,7 @@ noinst_HEADERS = \ macros_dlg.h \ main.h \ main_statusbar.h \ + main_toolbar.h \ main_welcome.h \ menu.h \ mtp3_stat.h \ @@ -123,7 +124,6 @@ noinst_HEADERS = \ summary_dlg.h \ supported_protos_dlg.h \ text_page.h \ - toolbar.h \ u3.h \ uat_gui.h \ voip_calls.h \ diff --git a/gtk/Makefile.common b/gtk/Makefile.common index 4f676af8dd..24bcf76d5b 100644 --- a/gtk/Makefile.common +++ b/gtk/Makefile.common @@ -83,6 +83,7 @@ WIRESHARK_GTK_SRC = \ macros_dlg.c \ main.c \ main_statusbar.c \ + main_toolbar.c \ main_welcome.c \ menu.c \ nameres_prefs.c \ @@ -117,7 +118,6 @@ WIRESHARK_GTK_SRC = \ supported_protos_dlg.c \ tap_dfilter_dlg.c \ text_page.c \ - toolbar.c \ u3.c \ uat_gui.c \ voip_calls.c \ diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c index b7190cf871..46951ef8ec 100644 --- a/gtk/capture_if_dlg.c +++ b/gtk/capture_if_dlg.c @@ -56,9 +56,9 @@ #include "dlg_utils.h" #include "main.h" +#include "main_toolbar.h" #include "wtap.h" #include "help_dlg.h" -#include "toolbar.h" #include "keys.h" #include "webbrowser.h" diff --git a/gtk/gui_prefs.c b/gtk/gui_prefs.c index 7396583502..68d5ff53ec 100644 --- a/gtk/gui_prefs.c +++ b/gtk/gui_prefs.c @@ -42,9 +42,9 @@ #include "dlg_utils.h" #include "proto_draw.h" #include "main.h" +#include "main_toolbar.h" #include "font_utils.h" #include "packet_list.h" -#include "toolbar.h" #include "recent.h" #include "webbrowser.h" diff --git a/gtk/libui.vcproj b/gtk/libui.vcproj index 0b76b4656c..65718e38d2 100644 --- a/gtk/libui.vcproj +++ b/gtk/libui.vcproj @@ -439,6 +439,10 @@ RelativePath=".\main_statusbar.c" > + + @@ -663,10 +667,6 @@ RelativePath=".\text_page.c" > - - @@ -909,6 +909,10 @@ RelativePath=".\main_statusbar.h" > + + @@ -1045,10 +1049,6 @@ RelativePath=".\text_page.h" > - - diff --git a/gtk/main.c b/gtk/main.c index cd499e1a33..0d2de4341c 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -127,6 +127,7 @@ #include "main.h" #include "main_statusbar.h" +#include "main_toolbar.h" #include "main_welcome.h" #include "menu.h" #include "../main_window.h" @@ -138,7 +139,6 @@ #include "keys.h" #include "packet_win.h" #include "stock_icons.h" -#include "toolbar.h" #include "find_dlg.h" #include "packet_list.h" #include "recent.h" @@ -169,8 +169,6 @@ #include "airpcap_dlg.h" #include "airpcap_gui_utils.h" -#include "./gtk/toolbar.h" - #include "./image/toolbar/wep_closed_24.xpm" #endif diff --git a/gtk/main_toolbar.c b/gtk/main_toolbar.c new file mode 100644 index 0000000000..3298dd0d40 --- /dev/null +++ b/gtk/main_toolbar.c @@ -0,0 +1,520 @@ +/* toolbar.c + * The main toolbar + * Copyright 2003, Ulf Lamping + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * 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. + */ + +/* + * This file implements the "main" toolbar for Wireshark. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#ifdef HAVE_LIBPCAP +#include "capture_dlg.h" +#endif /* HAVE_LIBPCAP */ +#include "filter_dlg.h" +#include "capture_file_dlg.h" +#include "find_dlg.h" +#include "goto_dlg.h" +#include "color.h" +#include "color_dlg.h" +#include +#include "prefs_dlg.h" +#include "main.h" +#include "main_toolbar.h" +#include "help_dlg.h" +#include "gtkglobals.h" +#include "stock_icons.h" +#include "keys.h" +#include "recent.h" +#include "packet_history.h" +#include "packet_list.h" +#include "color_filters.h" +#include "menu.h" + + + +/* XXX: add this key to some .h file, as it adds a key to the top level Widget? */ +#define E_TB_MAIN_KEY "toolbar_main" + + +static gboolean toolbar_init = FALSE; + +#if GTK_CHECK_VERSION(2,4,0) +#define BUTTON_TYPE GtkToolItem +#else /* GTK_CHECK_VERSION(2,4,0) */ +#define BUTTON_TYPE GtkWidget +#endif /* GTK_CHECK_VERSION(2,4,0) */ + +#ifdef HAVE_LIBPCAP +static BUTTON_TYPE *capture_options_button, *new_button, *stop_button, *clear_button, *if_button; +static BUTTON_TYPE *capture_filter_button, *autoscroll_button; +#endif /* HAVE_LIBPCAP */ +static BUTTON_TYPE *open_button, *save_button, *close_button, *reload_button; +static BUTTON_TYPE *print_button, *find_button, *history_forward_button, *history_back_button; +static BUTTON_TYPE *go_to_button, *go_to_top_button, *go_to_bottom_button; +static BUTTON_TYPE *display_filter_button; +static BUTTON_TYPE *zoom_in_button, *zoom_out_button, *zoom_100_button, *colorize_button, *resize_columns_button; +static BUTTON_TYPE *color_display_button, *prefs_button, *help_button; +#if !GTK_CHECK_VERSION(2,4,0) +static BUTTON_TYPE *save_as_button; +#endif + +#define SAVE_BUTTON_TOOLTIP_TEXT "Save this capture file..." +#define SAVE_AS_BUTTON_TOOLTIP_TEXT "Save this capture file as..." + + +/* + * Redraw all toolbars (currently only the main toolbar) + */ +void +toolbar_redraw_all(void) +{ + GtkWidget *main_tb; + + main_tb = g_object_get_data(G_OBJECT(top_level), E_TB_MAIN_KEY); + + gtk_toolbar_set_style(GTK_TOOLBAR(main_tb), + prefs.gui_toolbar_main_style); +} + +/* Enable or disable toolbar items based on whether you have a capture file + you've finished reading. */ +void set_toolbar_for_capture_file(gboolean have_capture_file) { + if (toolbar_init) { + gtk_widget_set_sensitive(GTK_WIDGET(save_button), have_capture_file); +#if !GTK_CHECK_VERSION(2,4,0) + gtk_widget_set_sensitive(GTK_WIDGET(save_as_button), have_capture_file); +#endif + gtk_widget_set_sensitive(GTK_WIDGET(close_button), have_capture_file); + gtk_widget_set_sensitive(GTK_WIDGET(reload_button), have_capture_file); + } +} + +/* Enable or disable menu items based on whether you have an unsaved + capture file you've finished reading. */ +void set_toolbar_for_unsaved_capture_file(gboolean have_unsaved_capture_file) { + GtkTooltips *tooltips; + + tooltips = gtk_tooltips_new(); + + if (toolbar_init) { + if(have_unsaved_capture_file) { +#if GTK_CHECK_VERSION(2,4,0) + gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(save_button), + GTK_STOCK_SAVE); + gtk_tool_item_set_tooltip(save_button, tooltips, + SAVE_BUTTON_TOOLTIP_TEXT, NULL); + g_object_set_data(G_OBJECT(save_button), "save", GINT_TO_POINTER(1)); +#else /* GTK_CHECK_VERSION(2,4,0) */ + gtk_widget_hide(GTK_WIDGET(save_as_button)); + gtk_widget_show(GTK_WIDGET(save_button)); +#endif /* GTK_CHECK_VERSION(2,4,0) */ + } else { +#if GTK_CHECK_VERSION(2,4,0) + gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(save_button), + GTK_STOCK_SAVE_AS); + gtk_tool_item_set_tooltip(save_button, tooltips, + SAVE_AS_BUTTON_TOOLTIP_TEXT, NULL); + g_object_set_data(G_OBJECT(save_button), "save", GINT_TO_POINTER(0)); +#else /* GTK_CHECK_VERSION(2,4,0) */ + gtk_widget_show(GTK_WIDGET(save_as_button)); + gtk_widget_hide(GTK_WIDGET(save_button)); +#endif /* GTK_CHECK_VERSION(2,4,0) */ + } + /*gtk_widget_set_sensitive((GTK_WIDGET(save_button), have_unsaved_capture_file); + gtk_widget_set_sensitive(GTK_WIDGET(save_as_button), !have_unsaved_capture_file);*/ + } +} + +/* fudge to call correct file_save or file_save_as fcn based upon the + value of the "save" key associated with the save button +*/ + +#if GTK_CHECK_VERSION(2,4,0) +static void file_save_or_save_as_cmd_cb(GtkWidget *w, gpointer data) { + if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(save_button),"save")) == 1) { + file_save_cmd_cb(w, data); + } + else { + file_save_as_cmd_cb(w, data); + } +} +#endif + +/** The packet history has changed, we need to update the menu. + * + * @param back_history some back history entries available + * @param forward_history some forward history entries available + */ +void set_toolbar_for_packet_history(gboolean back_history, gboolean forward_history) { + gtk_widget_set_sensitive(GTK_WIDGET(history_back_button), back_history); + gtk_widget_set_sensitive(GTK_WIDGET(history_forward_button), forward_history); +} + + +/* XXX - this is a quick and dirty hack to get the current state of capturing. + * this has to be improved, and should be reside somewhere in the capture engine. */ +gboolean g_is_capture_in_progress = FALSE; + +gboolean +is_capture_in_progress(void) +{ + return g_is_capture_in_progress; +} + +/* set toolbar state "have a capture in progress" */ +void set_toolbar_for_capture_in_progress(gboolean capture_in_progress) { + + g_is_capture_in_progress = capture_in_progress; + + if (toolbar_init) { +#ifdef HAVE_LIBPCAP + gtk_widget_set_sensitive(GTK_WIDGET(capture_options_button), !capture_in_progress); + gtk_widget_set_sensitive(GTK_WIDGET(new_button), !capture_in_progress); + gtk_widget_set_sensitive(GTK_WIDGET(stop_button), capture_in_progress); + gtk_widget_set_sensitive(GTK_WIDGET(clear_button), capture_in_progress); + /*if (capture_in_progress) { + gtk_widget_hide(GTK_WIDGET(new_button)); + gtk_widget_show(GTK_WIDGET(stop_button)); + } else { + gtk_widget_show(GTK_WIDGET(new_button)); + gtk_widget_hide(GTK_WIDGET(stop_button)); + }*/ +#endif /* HAVE_LIBPCAP */ + gtk_widget_set_sensitive(GTK_WIDGET(open_button), !capture_in_progress); + } +} + +/* set toolbar state "have packets captured" */ +void set_toolbar_for_captured_packets(gboolean have_captured_packets) { + + if (toolbar_init) { + gtk_widget_set_sensitive(GTK_WIDGET(print_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(find_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(history_back_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(history_forward_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(go_to_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(go_to_top_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(go_to_bottom_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(zoom_in_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(zoom_out_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(zoom_100_button), + have_captured_packets); + gtk_widget_set_sensitive(GTK_WIDGET(resize_columns_button), + have_captured_packets); + /* XXX - I don't see a reason why this should be done (as it is in the + * menus) */ + /* gtk_widget_set_sensitive(GTK_WIDGET(color_display_button), + have_captured_packets);*/ + } +} + + +/* helper function: add a separator to the toolbar */ +static void toolbar_append_separator(GtkWidget *toolbar) { +#if GTK_CHECK_VERSION(2,4,0) + GtkToolItem *tool_item = gtk_separator_tool_item_new(); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, -1); + gtk_widget_show(GTK_WIDGET(tool_item)); +#else /* GTK_CHECK_VERSION(2,4,0) */ + /* GTK 2 uses (as it should be) a seperator when adding this space */ + gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); +#endif /* GTK_CHECK_VERSION(2,4,0) */ +} + + + +#if GTK_CHECK_VERSION(2,4,0) +#define toolbar_item(new_item, window, toolbar, stock, tooltips, tooltip_text, xpm, callback, user_data) { \ + new_item = gtk_tool_button_new_from_stock(stock); \ + gtk_tool_item_set_tooltip(new_item, tooltips, tooltip_text, NULL); \ + g_signal_connect(new_item, "clicked", G_CALLBACK(callback), user_data); \ + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), new_item, -1); \ + gtk_widget_show(GTK_WIDGET(new_item)); \ + } + +#else /* GTK_CHECK_VERSION(2,4,0) */ + +#define toolbar_item(new_item, window, toolbar, stock, tooltips, tooltip_text, xpm, callback, user_data) { \ + new_item = gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), \ + stock, tooltip_text, "Private", G_CALLBACK(callback), user_data, -1);\ + } +#endif /* GTK_CHECK_VERSION(2,4,0) */ + +#define toolbar_icon(new_icon, window, xpm) { \ + icon = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->white, (gchar **) xpm); \ + new_icon = gtk_image_new_from_pixmap(icon, mask); \ + } + + +#if GTK_CHECK_VERSION(2,4,0) +#define toolbar_toggle_button(new_item, window, toolbar, stock, tooltips, tooltip_text, xpm, callback, user_data) { \ + new_item = gtk_toggle_tool_button_new_from_stock(stock); \ + gtk_tool_item_set_tooltip(new_item, tooltips, tooltip_text, NULL); \ + g_signal_connect(new_item, "toggled", G_CALLBACK(callback), user_data); \ + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), new_item, -1); \ + gtk_widget_show_all(GTK_WIDGET(new_item)); \ + } +#else /* GTK_CHECK_VERSION(2,4,0) */ +#define toolbar_toggle_button(new_item, window, toolbar, stock, tooltips, tooltip_text, xpm, callback, user_data) { \ + toolbar_icon(iconw, window, xpm); \ + new_item = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), \ + GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, \ + stock, tooltip_text, "Private", iconw, GTK_SIGNAL_FUNC(callback), user_data);\ + } +#endif /* GTK_CHECK_VERSION(2,4,0) */ + + +static void +colorize_toggle_cb(GtkWidget *toggle_button, gpointer user_data _U_) { +#if GTK_CHECK_VERSION(2,4,0) + menu_colorize_changed(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(toggle_button))); +#else /* GTK_CHECK_VERSION(2,4,0) */ + menu_colorize_changed(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button))); +#endif /* GTK_CHECK_VERSION(2,4,0) */ +} + +void +toolbar_colorize_changed(gboolean packet_list_colorize) { +#if GTK_CHECK_VERSION(2,4,0) + if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(colorize_button)) != packet_list_colorize) { + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(colorize_button), packet_list_colorize); + } +#else /* GTK_CHECK_VERSION(2,4,0) */ + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(colorize_button)) != packet_list_colorize) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(colorize_button), packet_list_colorize); + } +#endif /* GTK_CHECK_VERSION(2,4,0) */ +} + + +#ifdef HAVE_LIBPCAP +static void +auto_scroll_live_toggle_cb(GtkWidget *autoscroll_button, gpointer user_data _U_) { +#if GTK_CHECK_VERSION(2,4,0) + menu_auto_scroll_live_changed(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(autoscroll_button))); +#else /* GTK_CHECK_VERSION(2,4,0) */ + menu_auto_scroll_live_changed(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autoscroll_button))); + +#endif /* GTK_CHECK_VERSION(2,4,0) */ +} + +void +toolbar_auto_scroll_live_changed(gboolean auto_scroll_live) { +#if GTK_CHECK_VERSION(2,4,0) + if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(autoscroll_button)) != auto_scroll_live) { + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(autoscroll_button), auto_scroll_live); + } +#else /* GTK_CHECK_VERSION(2,4,0) */ + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autoscroll_button)) != auto_scroll_live) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoscroll_button), auto_scroll_live); + } +#endif /* GTK_CHECK_VERSION(2,4,0) */ +} +#endif + +/* + * Create all toolbars (currently only the main toolbar) + */ +GtkWidget * +toolbar_new(void) +{ + GtkWidget *main_tb; + GtkWidget *window = top_level; +#if !GTK_CHECK_VERSION(2,4,0) + GdkPixmap *icon; + GdkBitmap * mask; + GtkWidget *iconw; +#endif + GtkTooltips *tooltips; + + tooltips = gtk_tooltips_new(); + + /* this function should be only called once! */ + g_assert(!toolbar_init); + + /* we need to realize the window because we use pixmaps for + * items on the toolbar in the context of it */ + /* (coming from the gtk example, please don't ask me why ;-) */ + gtk_widget_realize(window); + + /* toolbar will be horizontal, with both icons and text (as default here) */ + /* (this will usually be overwritten by the preferences setting) */ + main_tb = gtk_toolbar_new(); + gtk_toolbar_set_orientation(GTK_TOOLBAR(main_tb), + GTK_ORIENTATION_HORIZONTAL); + + g_object_set_data(G_OBJECT(top_level), E_TB_MAIN_KEY, main_tb); + + +#ifdef HAVE_LIBPCAP + toolbar_item(if_button, window, main_tb, + WIRESHARK_STOCK_CAPTURE_INTERFACES, tooltips, "List the available capture interfaces...", capture_interfaces_24_xpm, capture_if_cb, NULL); + + toolbar_item(capture_options_button, window, main_tb, + WIRESHARK_STOCK_CAPTURE_OPTIONS, tooltips, "Show the capture options...", capture_options_24_xpm, capture_prep_cb, NULL); + + toolbar_item(new_button, window, main_tb, + WIRESHARK_STOCK_CAPTURE_START, tooltips, "Start a new live capture", capture_start_24_xpm, capture_start_cb, NULL); + + toolbar_item(stop_button, window, main_tb, + WIRESHARK_STOCK_CAPTURE_STOP, tooltips, "Stop the running live capture", capture_stop_24_xpm, capture_stop_cb, NULL); + + toolbar_item(clear_button, window, main_tb, + WIRESHARK_STOCK_CAPTURE_RESTART, tooltips, "Restart the running live capture", capture_restart_24_xpm, capture_restart_cb, NULL); + + toolbar_append_separator(main_tb); +#endif /* HAVE_LIBPCAP */ + + toolbar_item(open_button, window, main_tb, + GTK_STOCK_OPEN, tooltips, "Open a capture file...", stock_open_24_xpm, file_open_cmd_cb, NULL); + + /* Only create a separate button in GTK < 2.4. With GTK 2.4+, we will + * just modify the save_button to read/show save or save as as needed. + * We'll also fudge in an object key ("save") for the save button with data which specifies + * whether the button is currently "save" (1)or "save as" (0). + * The fcn file_save_or_save_as_cmd_cb + * will then call the appropriate file_save_cmd_cb or file_save_as_cmd_cb + */ + +#if !GTK_CHECK_VERSION(2,4,0) + toolbar_item(save_button, window, main_tb, + GTK_STOCK_SAVE, tooltips, SAVE_BUTTON_TOOLTIP_TEXT, stock_save_24_xpm, file_save_cmd_cb, NULL); + toolbar_item(save_as_button, window, main_tb, + GTK_STOCK_SAVE_AS, tooltips, SAVE_AS_BUTTON_TOOLTIP_TEXT, stock_save_as_24_xpm, file_save_as_cmd_cb, NULL); +#else + toolbar_item(save_button, window, main_tb, + GTK_STOCK_SAVE, tooltips, SAVE_BUTTON_TOOLTIP_TEXT, stock_save_24_xpm, file_save_or_save_as_cmd_cb, NULL); + g_object_set_data(G_OBJECT(save_button), "save", GINT_TO_POINTER(1)); +#endif + + toolbar_item(close_button, window, main_tb, + GTK_STOCK_CLOSE, tooltips, "Close this capture file", stock_close_24_xpm, file_close_cmd_cb, NULL); + + toolbar_item(reload_button, window, main_tb, + GTK_STOCK_REFRESH, tooltips, "Reload this capture file", stock_refresh_24_xpm, file_reload_cmd_cb, NULL); + + toolbar_item(print_button, window, main_tb, + GTK_STOCK_PRINT, tooltips, "Print packet(s)...", stock_print_24_xpm, file_print_cmd_cb, NULL); + + toolbar_append_separator(main_tb); + + toolbar_item(find_button, window, main_tb, + GTK_STOCK_FIND, tooltips, "Find a packet...", stock_search_24_xpm, find_frame_cb, NULL); + + toolbar_item(history_back_button, window, main_tb, + GTK_STOCK_GO_BACK, tooltips, "Go back in packet history", stock_left_arrow_24_xpm, history_back_cb, NULL); + + toolbar_item(history_forward_button, window, main_tb, + GTK_STOCK_GO_FORWARD, tooltips, "Go forward in packet history", stock_right_arrow_24_xpm, history_forward_cb, NULL); + + toolbar_item(go_to_button, window, main_tb, + GTK_STOCK_JUMP_TO, tooltips, "Go to the packet with number...", stock_jump_to_24_xpm, goto_frame_cb, NULL); + + toolbar_item(go_to_top_button, window, main_tb, + GTK_STOCK_GOTO_TOP, tooltips, "Go to the first packet", stock_top_24_xpm, goto_top_frame_cb, NULL); + + toolbar_item(go_to_bottom_button, window, main_tb, + GTK_STOCK_GOTO_BOTTOM, tooltips, "Go to the last packet", stock_bottom_24_xpm, goto_bottom_frame_cb, NULL); + + toolbar_append_separator(main_tb); + + toolbar_toggle_button(colorize_button, window, main_tb, + WIRESHARK_STOCK_COLORIZE, tooltips, "Colorize Packet List", colorize_24_xpm, colorize_toggle_cb, NULL); + +#ifdef HAVE_LIBPCAP + toolbar_toggle_button(autoscroll_button, window, main_tb, + WIRESHARK_STOCK_AUTOSCROLL, tooltips, "Auto Scroll Packet List in Live Capture", autoscroll_24_xpm, auto_scroll_live_toggle_cb, NULL); +#endif + + toolbar_append_separator(main_tb); + + toolbar_item(zoom_in_button, window, main_tb, + GTK_STOCK_ZOOM_IN, tooltips, "Zoom in", stock_zoom_in_24_xpm, view_zoom_in_cb, NULL); + + toolbar_item(zoom_out_button, window, main_tb, + GTK_STOCK_ZOOM_OUT, tooltips, "Zoom out", stock_zoom_out_24_xpm, view_zoom_out_cb, NULL); + + toolbar_item(zoom_100_button, window, main_tb, + GTK_STOCK_ZOOM_100, tooltips, "Zoom 100%", stock_zoom_1_24_xpm, view_zoom_100_cb, NULL); + + toolbar_item(resize_columns_button, window, main_tb, + WIRESHARK_STOCK_RESIZE_COLUMNS, tooltips, "Resize All Columns", resize_columns_24_xpm, packet_list_resize_columns_cb, NULL); + + toolbar_append_separator(main_tb); + +#ifdef HAVE_LIBPCAP + toolbar_item(capture_filter_button, window, main_tb, + WIRESHARK_STOCK_CAPTURE_FILTER, tooltips, "Edit capture filter...", capture_filter_24_xpm, cfilter_dialog_cb, NULL); +#endif /* HAVE_LIBPCAP */ + + toolbar_item(display_filter_button, window, main_tb, + WIRESHARK_STOCK_DISPLAY_FILTER, tooltips, "Edit/apply display filter...", display_filter_24_xpm, dfilter_dialog_cb, NULL); + + toolbar_item(color_display_button, window, main_tb, + GTK_STOCK_SELECT_COLOR, tooltips, "Edit coloring rules...", stock_colorselector_24_xpm, color_display_cb, NULL); + + /* the preference button uses it's own Stock icon label "Prefs", as "Preferences" is too long */ + toolbar_item(prefs_button, window, main_tb, + GTK_STOCK_PREFERENCES, tooltips, "Edit preferences...", stock_preferences_24_xpm, prefs_cb, NULL); + + toolbar_append_separator(main_tb); + + toolbar_item(help_button, window, main_tb, + GTK_STOCK_HELP, tooltips, "Show some help...", stock_help_24_xpm, topic_cb, GINT_TO_POINTER(HELP_CONTENT)); + + /* disable all "sensitive" items by default */ + toolbar_init = TRUE; + set_toolbar_for_unsaved_capture_file(FALSE); + set_toolbar_for_captured_packets(FALSE); + set_toolbar_for_capture_file(FALSE); +#ifdef HAVE_LIBPCAP + set_toolbar_for_capture_in_progress(FALSE); +#endif /* HAVE_LIBPCAP */ + + /* make current preferences effective */ + toolbar_redraw_all(); + + return main_tb; +} + +void +set_toolbar_object_data(gchar *key, gpointer data) +{ + g_object_set_data(G_OBJECT(open_button), key, data); + g_object_set_data(G_OBJECT(reload_button), key, data); +} diff --git a/gtk/main_toolbar.h b/gtk/main_toolbar.h new file mode 100644 index 0000000000..39c8c6798f --- /dev/null +++ b/gtk/main_toolbar.h @@ -0,0 +1,94 @@ +/* toolbar.h + * Definitions for toolbar utility routines + * Copyright 2003, Ulf Lamping + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * 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 __TOOLBAR_H__ +#define __TOOLBAR_H__ + +gboolean is_capture_in_progress(void); + +/** @file + * The main toolbar. + * @ingroup main_window_group + */ + +/** Create the main toolbar. + * @return the new (still hidden) toolbar + */ +GtkWidget *toolbar_new(void); + +/** Redraw the main toolbar. Used, when user changes preferences. */ +void toolbar_redraw_all(void); + +/** The "Colorize Packet List" option has changed. + */ +void toolbar_colorize_changed(gboolean packet_list_colorize); + +#ifdef HAVE_LIBPCAP +/** The "Auto Scroll in Live Capture" option has changed. + */ +void toolbar_auto_scroll_live_changed(gboolean auto_scroll_live); +#endif + +/** We have (or don't have) a capture file now. + * + * @param have_capture_file TRUE, if we have a capture file + */ +void set_toolbar_for_capture_file(gboolean have_capture_file); + +/** We have (or don't have) an unsaved capture file now. + * + * @param have_unsaved_capture_file TRUE, if we have an unsaved capture file + */ +void set_toolbar_for_unsaved_capture_file(gboolean have_unsaved_capture_file); + +/** We have (or don't have) a capture in progress now. + * + * @param have_capture_file TRUE, if we have a capture in progress file + */ +void set_toolbar_for_capture_in_progress(gboolean have_capture_file); + +/** We have (or don't have) captured packets now. + * + * @param have_captured_packets TRUE, if we have captured packets + */ +void set_toolbar_for_captured_packets(gboolean have_captured_packets); + +/** The packet history has changed, we need to update the menu. + * + * @param back_history some back history entries available + * @param forward_history some forward history entries available + */ +void set_toolbar_for_packet_history(gboolean back_history, gboolean forward_history); + +/** Set object data of some buttons (where needed). It's needed so callback + * functions can read back their required data. Acts like g_object_set_data() + * on multiple buttons. + * + * @param key the key + * @param data the data to set + */ +void set_toolbar_object_data(gchar *key, gpointer data); + +#endif /* __TOOLBAR_H__ */ diff --git a/gtk/menu.c b/gtk/menu.c index bfd87ac8dd..3bb01730d9 100644 --- a/gtk/menu.c +++ b/gtk/menu.c @@ -31,6 +31,7 @@ #include #include "main.h" +#include "main_toolbar.h" #include "menu.h" #include "../stat_menu.h" #include "gui_stat_menu.h" @@ -69,7 +70,6 @@ #include #include #include "stock_icons.h" -#include "toolbar.h" #include "gtkglobals.h" #include "register.h" #include "../menu.h" diff --git a/gtk/toolbar.c b/gtk/toolbar.c deleted file mode 100644 index a818330ac1..0000000000 --- a/gtk/toolbar.c +++ /dev/null @@ -1,519 +0,0 @@ -/* toolbar.c - * The main toolbar - * Copyright 2003, Ulf Lamping - * - * $Id$ - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * 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. - */ - -/* - * This file implements the "main" toolbar for Wireshark. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#ifdef HAVE_LIBPCAP -#include "capture_dlg.h" -#endif /* HAVE_LIBPCAP */ -#include "filter_dlg.h" -#include "capture_file_dlg.h" -#include "find_dlg.h" -#include "goto_dlg.h" -#include "color.h" -#include "color_dlg.h" -#include -#include "prefs_dlg.h" -#include "main.h" -#include "help_dlg.h" -#include "gtkglobals.h" -#include "stock_icons.h" -#include "keys.h" -#include "recent.h" -#include "packet_history.h" -#include "packet_list.h" -#include "color_filters.h" -#include "menu.h" - - - -/* XXX: add this key to some .h file, as it adds a key to the top level Widget? */ -#define E_TB_MAIN_KEY "toolbar_main" - - -static gboolean toolbar_init = FALSE; - -#if GTK_CHECK_VERSION(2,4,0) -#define BUTTON_TYPE GtkToolItem -#else /* GTK_CHECK_VERSION(2,4,0) */ -#define BUTTON_TYPE GtkWidget -#endif /* GTK_CHECK_VERSION(2,4,0) */ - -#ifdef HAVE_LIBPCAP -static BUTTON_TYPE *capture_options_button, *new_button, *stop_button, *clear_button, *if_button; -static BUTTON_TYPE *capture_filter_button, *autoscroll_button; -#endif /* HAVE_LIBPCAP */ -static BUTTON_TYPE *open_button, *save_button, *close_button, *reload_button; -static BUTTON_TYPE *print_button, *find_button, *history_forward_button, *history_back_button; -static BUTTON_TYPE *go_to_button, *go_to_top_button, *go_to_bottom_button; -static BUTTON_TYPE *display_filter_button; -static BUTTON_TYPE *zoom_in_button, *zoom_out_button, *zoom_100_button, *colorize_button, *resize_columns_button; -static BUTTON_TYPE *color_display_button, *prefs_button, *help_button; -#if !GTK_CHECK_VERSION(2,4,0) -static BUTTON_TYPE *save_as_button; -#endif - -#define SAVE_BUTTON_TOOLTIP_TEXT "Save this capture file..." -#define SAVE_AS_BUTTON_TOOLTIP_TEXT "Save this capture file as..." - - -/* - * Redraw all toolbars (currently only the main toolbar) - */ -void -toolbar_redraw_all(void) -{ - GtkWidget *main_tb; - - main_tb = g_object_get_data(G_OBJECT(top_level), E_TB_MAIN_KEY); - - gtk_toolbar_set_style(GTK_TOOLBAR(main_tb), - prefs.gui_toolbar_main_style); -} - -/* Enable or disable toolbar items based on whether you have a capture file - you've finished reading. */ -void set_toolbar_for_capture_file(gboolean have_capture_file) { - if (toolbar_init) { - gtk_widget_set_sensitive(GTK_WIDGET(save_button), have_capture_file); -#if !GTK_CHECK_VERSION(2,4,0) - gtk_widget_set_sensitive(GTK_WIDGET(save_as_button), have_capture_file); -#endif - gtk_widget_set_sensitive(GTK_WIDGET(close_button), have_capture_file); - gtk_widget_set_sensitive(GTK_WIDGET(reload_button), have_capture_file); - } -} - -/* Enable or disable menu items based on whether you have an unsaved - capture file you've finished reading. */ -void set_toolbar_for_unsaved_capture_file(gboolean have_unsaved_capture_file) { - GtkTooltips *tooltips; - - tooltips = gtk_tooltips_new(); - - if (toolbar_init) { - if(have_unsaved_capture_file) { -#if GTK_CHECK_VERSION(2,4,0) - gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(save_button), - GTK_STOCK_SAVE); - gtk_tool_item_set_tooltip(save_button, tooltips, - SAVE_BUTTON_TOOLTIP_TEXT, NULL); - g_object_set_data(G_OBJECT(save_button), "save", GINT_TO_POINTER(1)); -#else /* GTK_CHECK_VERSION(2,4,0) */ - gtk_widget_hide(GTK_WIDGET(save_as_button)); - gtk_widget_show(GTK_WIDGET(save_button)); -#endif /* GTK_CHECK_VERSION(2,4,0) */ - } else { -#if GTK_CHECK_VERSION(2,4,0) - gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(save_button), - GTK_STOCK_SAVE_AS); - gtk_tool_item_set_tooltip(save_button, tooltips, - SAVE_AS_BUTTON_TOOLTIP_TEXT, NULL); - g_object_set_data(G_OBJECT(save_button), "save", GINT_TO_POINTER(0)); -#else /* GTK_CHECK_VERSION(2,4,0) */ - gtk_widget_show(GTK_WIDGET(save_as_button)); - gtk_widget_hide(GTK_WIDGET(save_button)); -#endif /* GTK_CHECK_VERSION(2,4,0) */ - } - /*gtk_widget_set_sensitive((GTK_WIDGET(save_button), have_unsaved_capture_file); - gtk_widget_set_sensitive(GTK_WIDGET(save_as_button), !have_unsaved_capture_file);*/ - } -} - -/* fudge to call correct file_save or file_save_as fcn based upon the - value of the "save" key associated with the save button -*/ - -#if GTK_CHECK_VERSION(2,4,0) -static void file_save_or_save_as_cmd_cb(GtkWidget *w, gpointer data) { - if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(save_button),"save")) == 1) { - file_save_cmd_cb(w, data); - } - else { - file_save_as_cmd_cb(w, data); - } -} -#endif - -/** The packet history has changed, we need to update the menu. - * - * @param back_history some back history entries available - * @param forward_history some forward history entries available - */ -void set_toolbar_for_packet_history(gboolean back_history, gboolean forward_history) { - gtk_widget_set_sensitive(GTK_WIDGET(history_back_button), back_history); - gtk_widget_set_sensitive(GTK_WIDGET(history_forward_button), forward_history); -} - - -/* XXX - this is a quick and dirty hack to get the current state of capturing. - * this has to be improved, and should be reside somewhere in the capture engine. */ -gboolean g_is_capture_in_progress = FALSE; - -gboolean -is_capture_in_progress(void) -{ - return g_is_capture_in_progress; -} - -/* set toolbar state "have a capture in progress" */ -void set_toolbar_for_capture_in_progress(gboolean capture_in_progress) { - - g_is_capture_in_progress = capture_in_progress; - - if (toolbar_init) { -#ifdef HAVE_LIBPCAP - gtk_widget_set_sensitive(GTK_WIDGET(capture_options_button), !capture_in_progress); - gtk_widget_set_sensitive(GTK_WIDGET(new_button), !capture_in_progress); - gtk_widget_set_sensitive(GTK_WIDGET(stop_button), capture_in_progress); - gtk_widget_set_sensitive(GTK_WIDGET(clear_button), capture_in_progress); - /*if (capture_in_progress) { - gtk_widget_hide(GTK_WIDGET(new_button)); - gtk_widget_show(GTK_WIDGET(stop_button)); - } else { - gtk_widget_show(GTK_WIDGET(new_button)); - gtk_widget_hide(GTK_WIDGET(stop_button)); - }*/ -#endif /* HAVE_LIBPCAP */ - gtk_widget_set_sensitive(GTK_WIDGET(open_button), !capture_in_progress); - } -} - -/* set toolbar state "have packets captured" */ -void set_toolbar_for_captured_packets(gboolean have_captured_packets) { - - if (toolbar_init) { - gtk_widget_set_sensitive(GTK_WIDGET(print_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(find_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(history_back_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(history_forward_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(go_to_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(go_to_top_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(go_to_bottom_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(zoom_in_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(zoom_out_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(zoom_100_button), - have_captured_packets); - gtk_widget_set_sensitive(GTK_WIDGET(resize_columns_button), - have_captured_packets); - /* XXX - I don't see a reason why this should be done (as it is in the - * menus) */ - /* gtk_widget_set_sensitive(GTK_WIDGET(color_display_button), - have_captured_packets);*/ - } -} - - -/* helper function: add a separator to the toolbar */ -static void toolbar_append_separator(GtkWidget *toolbar) { -#if GTK_CHECK_VERSION(2,4,0) - GtkToolItem *tool_item = gtk_separator_tool_item_new(); - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, -1); - gtk_widget_show(GTK_WIDGET(tool_item)); -#else /* GTK_CHECK_VERSION(2,4,0) */ - /* GTK 2 uses (as it should be) a seperator when adding this space */ - gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); -#endif /* GTK_CHECK_VERSION(2,4,0) */ -} - - - -#if GTK_CHECK_VERSION(2,4,0) -#define toolbar_item(new_item, window, toolbar, stock, tooltips, tooltip_text, xpm, callback, user_data) { \ - new_item = gtk_tool_button_new_from_stock(stock); \ - gtk_tool_item_set_tooltip(new_item, tooltips, tooltip_text, NULL); \ - g_signal_connect(new_item, "clicked", G_CALLBACK(callback), user_data); \ - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), new_item, -1); \ - gtk_widget_show(GTK_WIDGET(new_item)); \ - } - -#else /* GTK_CHECK_VERSION(2,4,0) */ - -#define toolbar_item(new_item, window, toolbar, stock, tooltips, tooltip_text, xpm, callback, user_data) { \ - new_item = gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), \ - stock, tooltip_text, "Private", G_CALLBACK(callback), user_data, -1);\ - } -#endif /* GTK_CHECK_VERSION(2,4,0) */ - -#define toolbar_icon(new_icon, window, xpm) { \ - icon = gdk_pixmap_create_from_xpm_d(window->window, &mask, &window->style->white, (gchar **) xpm); \ - new_icon = gtk_image_new_from_pixmap(icon, mask); \ - } - - -#if GTK_CHECK_VERSION(2,4,0) -#define toolbar_toggle_button(new_item, window, toolbar, stock, tooltips, tooltip_text, xpm, callback, user_data) { \ - new_item = gtk_toggle_tool_button_new_from_stock(stock); \ - gtk_tool_item_set_tooltip(new_item, tooltips, tooltip_text, NULL); \ - g_signal_connect(new_item, "toggled", G_CALLBACK(callback), user_data); \ - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), new_item, -1); \ - gtk_widget_show_all(GTK_WIDGET(new_item)); \ - } -#else /* GTK_CHECK_VERSION(2,4,0) */ -#define toolbar_toggle_button(new_item, window, toolbar, stock, tooltips, tooltip_text, xpm, callback, user_data) { \ - toolbar_icon(iconw, window, xpm); \ - new_item = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), \ - GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, \ - stock, tooltip_text, "Private", iconw, GTK_SIGNAL_FUNC(callback), user_data);\ - } -#endif /* GTK_CHECK_VERSION(2,4,0) */ - - -static void -colorize_toggle_cb(GtkWidget *toggle_button, gpointer user_data _U_) { -#if GTK_CHECK_VERSION(2,4,0) - menu_colorize_changed(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(toggle_button))); -#else /* GTK_CHECK_VERSION(2,4,0) */ - menu_colorize_changed(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button))); -#endif /* GTK_CHECK_VERSION(2,4,0) */ -} - -void -toolbar_colorize_changed(gboolean packet_list_colorize) { -#if GTK_CHECK_VERSION(2,4,0) - if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(colorize_button)) != packet_list_colorize) { - gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(colorize_button), packet_list_colorize); - } -#else /* GTK_CHECK_VERSION(2,4,0) */ - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(colorize_button)) != packet_list_colorize) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(colorize_button), packet_list_colorize); - } -#endif /* GTK_CHECK_VERSION(2,4,0) */ -} - - -#ifdef HAVE_LIBPCAP -static void -auto_scroll_live_toggle_cb(GtkWidget *autoscroll_button, gpointer user_data _U_) { -#if GTK_CHECK_VERSION(2,4,0) - menu_auto_scroll_live_changed(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(autoscroll_button))); -#else /* GTK_CHECK_VERSION(2,4,0) */ - menu_auto_scroll_live_changed(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autoscroll_button))); - -#endif /* GTK_CHECK_VERSION(2,4,0) */ -} - -void -toolbar_auto_scroll_live_changed(gboolean auto_scroll_live) { -#if GTK_CHECK_VERSION(2,4,0) - if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(autoscroll_button)) != auto_scroll_live) { - gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(autoscroll_button), auto_scroll_live); - } -#else /* GTK_CHECK_VERSION(2,4,0) */ - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autoscroll_button)) != auto_scroll_live) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autoscroll_button), auto_scroll_live); - } -#endif /* GTK_CHECK_VERSION(2,4,0) */ -} -#endif - -/* - * Create all toolbars (currently only the main toolbar) - */ -GtkWidget * -toolbar_new(void) -{ - GtkWidget *main_tb; - GtkWidget *window = top_level; -#if !GTK_CHECK_VERSION(2,4,0) - GdkPixmap *icon; - GdkBitmap * mask; - GtkWidget *iconw; -#endif - GtkTooltips *tooltips; - - tooltips = gtk_tooltips_new(); - - /* this function should be only called once! */ - g_assert(!toolbar_init); - - /* we need to realize the window because we use pixmaps for - * items on the toolbar in the context of it */ - /* (coming from the gtk example, please don't ask me why ;-) */ - gtk_widget_realize(window); - - /* toolbar will be horizontal, with both icons and text (as default here) */ - /* (this will usually be overwritten by the preferences setting) */ - main_tb = gtk_toolbar_new(); - gtk_toolbar_set_orientation(GTK_TOOLBAR(main_tb), - GTK_ORIENTATION_HORIZONTAL); - - g_object_set_data(G_OBJECT(top_level), E_TB_MAIN_KEY, main_tb); - - -#ifdef HAVE_LIBPCAP - toolbar_item(if_button, window, main_tb, - WIRESHARK_STOCK_CAPTURE_INTERFACES, tooltips, "List the available capture interfaces...", capture_interfaces_24_xpm, capture_if_cb, NULL); - - toolbar_item(capture_options_button, window, main_tb, - WIRESHARK_STOCK_CAPTURE_OPTIONS, tooltips, "Show the capture options...", capture_options_24_xpm, capture_prep_cb, NULL); - - toolbar_item(new_button, window, main_tb, - WIRESHARK_STOCK_CAPTURE_START, tooltips, "Start a new live capture", capture_start_24_xpm, capture_start_cb, NULL); - - toolbar_item(stop_button, window, main_tb, - WIRESHARK_STOCK_CAPTURE_STOP, tooltips, "Stop the running live capture", capture_stop_24_xpm, capture_stop_cb, NULL); - - toolbar_item(clear_button, window, main_tb, - WIRESHARK_STOCK_CAPTURE_RESTART, tooltips, "Restart the running live capture", capture_restart_24_xpm, capture_restart_cb, NULL); - - toolbar_append_separator(main_tb); -#endif /* HAVE_LIBPCAP */ - - toolbar_item(open_button, window, main_tb, - GTK_STOCK_OPEN, tooltips, "Open a capture file...", stock_open_24_xpm, file_open_cmd_cb, NULL); - - /* Only create a separate button in GTK < 2.4. With GTK 2.4+, we will - * just modify the save_button to read/show save or save as as needed. - * We'll also fudge in an object key ("save") for the save button with data which specifies - * whether the button is currently "save" (1)or "save as" (0). - * The fcn file_save_or_save_as_cmd_cb - * will then call the appropriate file_save_cmd_cb or file_save_as_cmd_cb - */ - -#if !GTK_CHECK_VERSION(2,4,0) - toolbar_item(save_button, window, main_tb, - GTK_STOCK_SAVE, tooltips, SAVE_BUTTON_TOOLTIP_TEXT, stock_save_24_xpm, file_save_cmd_cb, NULL); - toolbar_item(save_as_button, window, main_tb, - GTK_STOCK_SAVE_AS, tooltips, SAVE_AS_BUTTON_TOOLTIP_TEXT, stock_save_as_24_xpm, file_save_as_cmd_cb, NULL); -#else - toolbar_item(save_button, window, main_tb, - GTK_STOCK_SAVE, tooltips, SAVE_BUTTON_TOOLTIP_TEXT, stock_save_24_xpm, file_save_or_save_as_cmd_cb, NULL); - g_object_set_data(G_OBJECT(save_button), "save", GINT_TO_POINTER(1)); -#endif - - toolbar_item(close_button, window, main_tb, - GTK_STOCK_CLOSE, tooltips, "Close this capture file", stock_close_24_xpm, file_close_cmd_cb, NULL); - - toolbar_item(reload_button, window, main_tb, - GTK_STOCK_REFRESH, tooltips, "Reload this capture file", stock_refresh_24_xpm, file_reload_cmd_cb, NULL); - - toolbar_item(print_button, window, main_tb, - GTK_STOCK_PRINT, tooltips, "Print packet(s)...", stock_print_24_xpm, file_print_cmd_cb, NULL); - - toolbar_append_separator(main_tb); - - toolbar_item(find_button, window, main_tb, - GTK_STOCK_FIND, tooltips, "Find a packet...", stock_search_24_xpm, find_frame_cb, NULL); - - toolbar_item(history_back_button, window, main_tb, - GTK_STOCK_GO_BACK, tooltips, "Go back in packet history", stock_left_arrow_24_xpm, history_back_cb, NULL); - - toolbar_item(history_forward_button, window, main_tb, - GTK_STOCK_GO_FORWARD, tooltips, "Go forward in packet history", stock_right_arrow_24_xpm, history_forward_cb, NULL); - - toolbar_item(go_to_button, window, main_tb, - GTK_STOCK_JUMP_TO, tooltips, "Go to the packet with number...", stock_jump_to_24_xpm, goto_frame_cb, NULL); - - toolbar_item(go_to_top_button, window, main_tb, - GTK_STOCK_GOTO_TOP, tooltips, "Go to the first packet", stock_top_24_xpm, goto_top_frame_cb, NULL); - - toolbar_item(go_to_bottom_button, window, main_tb, - GTK_STOCK_GOTO_BOTTOM, tooltips, "Go to the last packet", stock_bottom_24_xpm, goto_bottom_frame_cb, NULL); - - toolbar_append_separator(main_tb); - - toolbar_toggle_button(colorize_button, window, main_tb, - WIRESHARK_STOCK_COLORIZE, tooltips, "Colorize Packet List", colorize_24_xpm, colorize_toggle_cb, NULL); - -#ifdef HAVE_LIBPCAP - toolbar_toggle_button(autoscroll_button, window, main_tb, - WIRESHARK_STOCK_AUTOSCROLL, tooltips, "Auto Scroll Packet List in Live Capture", autoscroll_24_xpm, auto_scroll_live_toggle_cb, NULL); -#endif - - toolbar_append_separator(main_tb); - - toolbar_item(zoom_in_button, window, main_tb, - GTK_STOCK_ZOOM_IN, tooltips, "Zoom in", stock_zoom_in_24_xpm, view_zoom_in_cb, NULL); - - toolbar_item(zoom_out_button, window, main_tb, - GTK_STOCK_ZOOM_OUT, tooltips, "Zoom out", stock_zoom_out_24_xpm, view_zoom_out_cb, NULL); - - toolbar_item(zoom_100_button, window, main_tb, - GTK_STOCK_ZOOM_100, tooltips, "Zoom 100%", stock_zoom_1_24_xpm, view_zoom_100_cb, NULL); - - toolbar_item(resize_columns_button, window, main_tb, - WIRESHARK_STOCK_RESIZE_COLUMNS, tooltips, "Resize All Columns", resize_columns_24_xpm, packet_list_resize_columns_cb, NULL); - - toolbar_append_separator(main_tb); - -#ifdef HAVE_LIBPCAP - toolbar_item(capture_filter_button, window, main_tb, - WIRESHARK_STOCK_CAPTURE_FILTER, tooltips, "Edit capture filter...", capture_filter_24_xpm, cfilter_dialog_cb, NULL); -#endif /* HAVE_LIBPCAP */ - - toolbar_item(display_filter_button, window, main_tb, - WIRESHARK_STOCK_DISPLAY_FILTER, tooltips, "Edit/apply display filter...", display_filter_24_xpm, dfilter_dialog_cb, NULL); - - toolbar_item(color_display_button, window, main_tb, - GTK_STOCK_SELECT_COLOR, tooltips, "Edit coloring rules...", stock_colorselector_24_xpm, color_display_cb, NULL); - - /* the preference button uses it's own Stock icon label "Prefs", as "Preferences" is too long */ - toolbar_item(prefs_button, window, main_tb, - GTK_STOCK_PREFERENCES, tooltips, "Edit preferences...", stock_preferences_24_xpm, prefs_cb, NULL); - - toolbar_append_separator(main_tb); - - toolbar_item(help_button, window, main_tb, - GTK_STOCK_HELP, tooltips, "Show some help...", stock_help_24_xpm, topic_cb, GINT_TO_POINTER(HELP_CONTENT)); - - /* disable all "sensitive" items by default */ - toolbar_init = TRUE; - set_toolbar_for_unsaved_capture_file(FALSE); - set_toolbar_for_captured_packets(FALSE); - set_toolbar_for_capture_file(FALSE); -#ifdef HAVE_LIBPCAP - set_toolbar_for_capture_in_progress(FALSE); -#endif /* HAVE_LIBPCAP */ - - /* make current preferences effective */ - toolbar_redraw_all(); - - return main_tb; -} - -void -set_toolbar_object_data(gchar *key, gpointer data) -{ - g_object_set_data(G_OBJECT(open_button), key, data); - g_object_set_data(G_OBJECT(reload_button), key, data); -} diff --git a/gtk/toolbar.h b/gtk/toolbar.h deleted file mode 100644 index 39c8c6798f..0000000000 --- a/gtk/toolbar.h +++ /dev/null @@ -1,94 +0,0 @@ -/* toolbar.h - * Definitions for toolbar utility routines - * Copyright 2003, Ulf Lamping - * - * $Id$ - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * 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 __TOOLBAR_H__ -#define __TOOLBAR_H__ - -gboolean is_capture_in_progress(void); - -/** @file - * The main toolbar. - * @ingroup main_window_group - */ - -/** Create the main toolbar. - * @return the new (still hidden) toolbar - */ -GtkWidget *toolbar_new(void); - -/** Redraw the main toolbar. Used, when user changes preferences. */ -void toolbar_redraw_all(void); - -/** The "Colorize Packet List" option has changed. - */ -void toolbar_colorize_changed(gboolean packet_list_colorize); - -#ifdef HAVE_LIBPCAP -/** The "Auto Scroll in Live Capture" option has changed. - */ -void toolbar_auto_scroll_live_changed(gboolean auto_scroll_live); -#endif - -/** We have (or don't have) a capture file now. - * - * @param have_capture_file TRUE, if we have a capture file - */ -void set_toolbar_for_capture_file(gboolean have_capture_file); - -/** We have (or don't have) an unsaved capture file now. - * - * @param have_unsaved_capture_file TRUE, if we have an unsaved capture file - */ -void set_toolbar_for_unsaved_capture_file(gboolean have_unsaved_capture_file); - -/** We have (or don't have) a capture in progress now. - * - * @param have_capture_file TRUE, if we have a capture in progress file - */ -void set_toolbar_for_capture_in_progress(gboolean have_capture_file); - -/** We have (or don't have) captured packets now. - * - * @param have_captured_packets TRUE, if we have captured packets - */ -void set_toolbar_for_captured_packets(gboolean have_captured_packets); - -/** The packet history has changed, we need to update the menu. - * - * @param back_history some back history entries available - * @param forward_history some forward history entries available - */ -void set_toolbar_for_packet_history(gboolean back_history, gboolean forward_history); - -/** Set object data of some buttons (where needed). It's needed so callback - * functions can read back their required data. Acts like g_object_set_data() - * on multiple buttons. - * - * @param key the key - * @param data the data to set - */ -void set_toolbar_object_data(gchar *key, gpointer data); - -#endif /* __TOOLBAR_H__ */ -- cgit v1.2.1