aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorJörg Mayer <jmayer@loplof.de>2005-08-20 14:02:00 +0000
committerJörg Mayer <jmayer@loplof.de>2005-08-20 14:02:00 +0000
commit0edcc8920eb4e0483f1c7886f07cce465bae2260 (patch)
tree17d7a1bddeab8630608cf30bc38356ff5ad4495a /gtk
parent4fd9fcc63956b732bfde38cc8ec6622b51ba7e06 (diff)
- Declare some functions static
- Add plugins_dlg.h - Include .h files in their respective .c files - Include .h and remove extern declarations in .c files - set eol-style and keywords on gui_utils.[hc] svn path=/trunk/; revision=15471
Diffstat (limited to 'gtk')
-rw-r--r--gtk/about_dlg.c8
-rw-r--r--gtk/capture_if_dlg.c4
-rw-r--r--gtk/fileset_dlg.c2
-rw-r--r--gtk/flow_graph.c12
-rw-r--r--gtk/gsm_map_summary.c2
-rw-r--r--gtk/gui_utils.c2078
-rw-r--r--gtk/gui_utils.h616
-rw-r--r--gtk/main.h2
-rw-r--r--gtk/menu.h2
-rw-r--r--gtk/mgcp_stat.c2
-rw-r--r--gtk/mtp3_summary.c2
-rw-r--r--gtk/plugins_dlg.c3
-rw-r--r--gtk/plugins_dlg.h38
-rw-r--r--gtk/prefs_dlg.c4
-rw-r--r--gtk/print_dlg.c2
-rw-r--r--gtk/proto_dlg.c2
-rw-r--r--gtk/proto_draw.c6
-rw-r--r--gtk/proto_hier_stats_dlg.c2
-rw-r--r--gtk/range_utils.c1
-rw-r--r--gtk/recent.c4
-rw-r--r--gtk/rpc_progs.c2
-rw-r--r--gtk/rtp_analysis.c4
-rw-r--r--gtk/rtp_stream.c4
-rw-r--r--gtk/rtp_stream_dlg.c4
-rw-r--r--gtk/sctp_assoc_analyse.c4
-rw-r--r--gtk/sctp_byte_graph_dlg.c8
-rw-r--r--gtk/sctp_chunk_stat.c2
-rw-r--r--gtk/sctp_chunk_stat_dlg.c5
-rw-r--r--gtk/sctp_error_dlg.c4
-rw-r--r--gtk/sctp_stat.c12
-rw-r--r--gtk/sctp_stat_dlg.c6
-rw-r--r--gtk/tcp_graph.c4
-rw-r--r--gtk/toolbar.h2
-rw-r--r--gtk/voip_calls.c24
-rw-r--r--gtk/voip_calls_dlg.c4
35 files changed, 1457 insertions, 1424 deletions
diff --git a/gtk/about_dlg.c b/gtk/about_dlg.c
index e6bdd77123..68d464f900 100644
--- a/gtk/about_dlg.c
+++ b/gtk/about_dlg.c
@@ -43,12 +43,8 @@
#include "../image/eicon3d64.xpm"
#include "gtkglobals.h"
#include "version_info.h"
-
-extern GString *comp_info_str, *runtime_info_str;
-
-#ifdef HAVE_PLUGINS
-extern GtkWidget *about_plugins_page_new(void);
-#endif
+#include "main.h"
+#include "plugins_dlg.h"
static void about_ethereal_destroy_cb(GtkWidget *, gpointer);
diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c
index 2bbe1d7a86..544faa637a 100644
--- a/gtk/capture_if_dlg.c
+++ b/gtk/capture_if_dlg.c
@@ -60,9 +60,7 @@
#include "wtap.h"
#include "main.h"
#include "help_dlg.h"
-
-
-extern gboolean is_capture_in_progress(void);
+#include "toolbar.h"
/*
* Keep a static pointer to the current "Capture Interfaces" window, if
diff --git a/gtk/fileset_dlg.c b/gtk/fileset_dlg.c
index abd81d7b16..ce0cb77261 100644
--- a/gtk/fileset_dlg.c
+++ b/gtk/fileset_dlg.c
@@ -125,7 +125,7 @@ fs_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
/* get creation date (converted from filename) */
/* */
-char *
+static char *
fileset_dlg_name2date_dup(const char * name) {
char *pfx;
char *filename;
diff --git a/gtk/flow_graph.c b/gtk/flow_graph.c
index 1fc5ce5d16..5acdb8cfa2 100644
--- a/gtk/flow_graph.c
+++ b/gtk/flow_graph.c
@@ -75,7 +75,7 @@ void flow_graph_data_init(void);
/****************************************************************************/
/* free up memory and initialize the pointers */
-void flow_graph_reset(void *ptr _U_)
+static void flow_graph_reset(void *ptr _U_)
{
graph_analysis_item_t *graph_item;
@@ -114,7 +114,7 @@ void protect_thread_critical_region(void);
void unprotect_thread_critical_region(void);
/****************************************************************************/
-void
+static void
remove_tap_listener_flow_graph(void)
{
protect_thread_critical_region();
@@ -186,7 +186,7 @@ toggle_select_tcp(GtkWidget *widget _U_, gpointer user_data _U_)
/****************************************************************************/
/* Add a new frame into the graph */
-int flow_graph_frame_add_to_graph(packet_info *pinfo)
+static int flow_graph_frame_add_to_graph(packet_info *pinfo)
{
graph_analysis_item_t *gai;
int i;
@@ -238,7 +238,7 @@ int flow_graph_frame_add_to_graph(packet_info *pinfo)
/****************************************************************************/
/* Add a new tcp frame into the graph */
-int flow_graph_tcp_add_to_graph(packet_info *pinfo, const struct tcpheader *tcph)
+static int flow_graph_tcp_add_to_graph(packet_info *pinfo, const struct tcpheader *tcph)
{
graph_analysis_item_t *gai;
/* copied from packet-tcp */
@@ -316,7 +316,7 @@ flow_graph_tcp_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U
}
-void flow_graph_packet_draw(void *prs _U_)
+static void flow_graph_packet_draw(void *prs _U_)
{
return;
}
@@ -548,7 +548,7 @@ flow_graph_init_tap(const char *dummy _U_)
/****************************************************************************/
/* entry point when called via the GTK menu */
-void flow_graph_launch(GtkWidget *w _U_, gpointer data _U_)
+static void flow_graph_launch(GtkWidget *w _U_, gpointer data _U_)
{
flow_graph_init_tap("");
}
diff --git a/gtk/gsm_map_summary.c b/gtk/gsm_map_summary.c
index abd563e75b..6cc8fa69e6 100644
--- a/gtk/gsm_map_summary.c
+++ b/gtk/gsm_map_summary.c
@@ -64,7 +64,7 @@ add_string_to_box(gchar *str, GtkWidget *box)
}
-void
+static void
gsm_map_stat_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_)
{
summary_tally summary;
diff --git a/gtk/gui_utils.c b/gtk/gui_utils.c
index ac715ec06e..c6ee544775 100644
--- a/gtk/gui_utils.c
+++ b/gtk/gui_utils.c
@@ -1,1039 +1,1039 @@
-/* ui_util.c
- * UI utility routines
- *
- * $Id: ui_util.c 15286 2005-08-10 19:49:45Z ulfl $
- *
- * 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 <string.h>
-
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
-#ifdef HAVE_IO_H
-# include <io.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-
-#include "gtkglobals.h"
-#include "gui_utils.h"
-#include <epan/prefs.h>
-#include "epan/epan.h"
-#include "../ui_util.h"
-#include "compat_macros.h"
-#include "recent.h"
-
-
-#include "image/eicon3d16.xpm"
-
-/* XXX - remove this later again, when dlg_xx function cleanup done */
-#include "dlg_utils.h"
-
-
-#define WINDOW_GEOM_KEY "window_geom"
-
-
-/* load the geometry values for a window from previously saved values */
-static gboolean window_geom_load(const gchar *name, window_geometry_t *geom);
-
-
-
-/* Set our window icon. The GDK documentation doesn't provide any
- actual documentation for gdk_window_set_icon(), so we'll steal
- libgimp/gimpdialog.c:gimp_dialog_realize_callback() from the Gimp
- sources and assume it's safe.
-
- XXX - The current icon size is fixed at 16x16 pixels, which looks fine
- with kwm (KDE 1.x's window manager), Sawfish (the "default" window
- manager for GNOME?), and under Windows with Exceed putting X windows
- on the Windows desktop, using Exceed as the window manager, as those
- window managers put a 16x16 icon on the title bar.
-
- The window managers in some windowing environments (e.g. dtwm in CDE)
- and some stand-alone window managers have larger icon sizes (many window
- managers put the window icon on the desktop, in the Windows 3.x style,
- rather than in the titlebar, in the Windows 4.x style), so we need to
- find a way to size our icon appropriately.
-
- The X11 Inter-Client Communications Conventions Manual, Version 1.1,
- in X11R5, specifies that "a window manager that wishes to place
- constraints on the sizes of icon pixmaps and/or windows should
- place a property called WM_ICON_SIZE on the root"; that property
- contains minimum width and height, maximum width and height, and
- width and height increment values. "XGetIconSizes()" retrieves
- that property; unfortunately, I've yet to find a window manager
- that sets it on the root window (kwm, AfterStep, and Exceed don't
- appear to set it).
-
- The X Desktop Group's Window Manager Standard specifies, in the section
- on Application Window Properties, an _NET_WM_ICON property, presumably
- set by the window manager, which is an array of possible icon sizes
- for the client. There's no API in GTK+ 1.2[.x] for this; there may
- eventually be one either in GTK+ 2.0 or GNOME 2.0.
-
- Some window managers can be configured to take the window name
- specified by the WM_NAME property of a window or the resource
- or class name specified by the WM_CLASS property and base the
- choice of icon for the window on one of those; WM_CLASS for
- Ethereal's windows has a resource name of "ethereal" and a class
- name of "Ethereal". However, the way that's done is window-manager-
- specific, and there's no way to determine what size a particular
- window manager would want, so there's no way to automate this as
- part of the installation of Ethereal.
- */
-static void
-window_icon_realize_cb (GtkWidget *win, gpointer data _U_)
-{
-#ifndef _WIN32
- static GdkPixmap *icon_pmap = NULL;
- static GdkBitmap *icon_mask = NULL;
- GtkStyle *style;
-
- style = gtk_widget_get_style (win);
-
- if (icon_pmap == NULL) {
- icon_pmap = gdk_pixmap_create_from_xpm_d (win->window,
- &icon_mask, &style->bg[GTK_STATE_NORMAL], eicon3d16_xpm);
- }
-
- gdk_window_set_icon (win->window, NULL, icon_pmap, icon_mask);
-#endif
-}
-
-
-/* Create a new window, of the specified type, with the specified title
- (if any) and the Ethereal icon. */
-GtkWidget *
-window_new(GtkWindowType type, const gchar *title)
-{
- GtkWidget *win;
-
- win = gtk_window_new(type);
- if (title != NULL)
- gtk_window_set_title(GTK_WINDOW(win), title);
- SIGNAL_CONNECT(win, "realize", window_icon_realize_cb, NULL);
-
- /* XXX - which one is the correct default policy? or use a preference for this? */
- /* GTK_WIN_POS_NONE, GTK_WIN_POS_CENTER or GTK_WIN_POS_MOUSE */
- /* a lot of people dislike GTK_WIN_POS_MOUSE */
-
- /* set the initial position (must be done, before show is called!) */
-#if GTK_MAJOR_VERSION >= 2
-/* gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ON_PARENT);*/
-#else
-/* gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);*/
-#endif
- gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_NONE);
-
-#if GTK_MAJOR_VERSION < 2
- /* allow window to be shrinked by user, as gtk_widget_set_usize() will set minimum size and */
- /* the user never could shrink the window again */
- gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, FALSE);
-#endif
-
- return win;
-}
-
-
-/* Same as window_new(), but will keep it's geometry values (size, position, ...).
- * Be sure to use window_present() and window_destroy() appropriately! */
-GtkWidget *
-window_new_with_geom(GtkWindowType type, const gchar *title, const gchar *geom_name)
-{
- window_geometry_t geom;
- GtkWidget *win = window_new(type, title);
-
- OBJECT_SET_DATA(win, WINDOW_GEOM_KEY, (gpointer)g_strdup(geom_name));
-
- /* do we have a previously saved size and position of this window? */
- if(geom_name) {
- /* It's a good idea to set the position and size of the window already here,
- * as it's still invisible and won't "flicker the screen" while initially resizing. */
- if(window_geom_load(geom_name, &geom)) {
- /* XXX - use prefs to select which values to set? */
- geom.set_pos = TRUE;
- geom.set_size = TRUE;
- geom.set_maximized = FALSE; /* don't maximize until window is shown */
- window_set_geometry(win, &geom);
- }
- }
-
- return win;
-}
-
-
-#if GTK_MAJOR_VERSION < 2
-/* We can't set the decorations until the window is realized. */
-static void
-window_notitle_realize_cb (GtkWidget *win, gpointer data _U_)
-{
- gdk_window_set_decorations(win->window, 0);
-}
-#endif
-
-
-/* Create a new window for a splash screen; it's a main window, with no title,
- positioned in the center of the screen. */
-GtkWidget *
-splash_window_new(void)
-{
- GtkWidget *win;
-
- win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-#if GTK_MAJOR_VERSION >= 2
- gtk_window_set_decorated(GTK_WINDOW(win), FALSE);
-#else
- SIGNAL_CONNECT(win, "realize", window_notitle_realize_cb, NULL);
-#endif
-
- /* set the initial position (must be done, before show is called!) */
- gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
-
- return win;
-}
-
-
-/* Present the created window on the screen. */
-void
-window_present(GtkWidget *win)
-{
- window_geometry_t geom;
- const gchar *name;
-
-#if GTK_MAJOR_VERSION >= 2
- /* present this window */
- gtk_window_present(GTK_WINDOW(win));
-#endif
-
- /* do we have a previously saved size and position of this window? */
- name = OBJECT_GET_DATA(win, WINDOW_GEOM_KEY);
- if(name) {
- if(window_geom_load(name, &geom)) {
- /* XXX - use prefs to select which values to set? */
- geom.set_pos = TRUE;
- geom.set_size = TRUE;
- geom.set_maximized = TRUE;
- window_set_geometry(win, &geom);
- }
- }
-}
-
-
-static gint
-window_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer cancel_button)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (event->keyval == GDK_Escape) {
- gtk_widget_activate(GTK_WIDGET(cancel_button));
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-/* Set the "key_press_event" signal for a top-level dialog window to
- call a routine to activate the "Cancel" button for a dialog box if
- the key being pressed is the <Esc> key.
-
- XXX - there should be a GTK+ widget that'll do that for you, and
- let you specify a "Cancel" button. It should also not impose
- a requirement that there be a separator in the dialog box, as
- the GtkDialog widget does; the visual convention that there's
- such a separator between the rest of the dialog boxes and buttons
- such as "OK" and "Cancel" is, for better or worse, not universal
- (not even in GTK+ - look at the GtkFileSelection dialog!). */
-static void
-window_set_cancel(GtkWidget *widget, GtkWidget *cancel_button)
-{
- SIGNAL_CONNECT(widget, "key_press_event", window_key_press_cb, cancel_button);
-}
-
-
-/* set the actions needed for the cancel "Close"/"Ok"/"Cancel" button that closes the window */
-void window_set_cancel_button(GtkWidget *win, GtkWidget *bt, window_cancel_button_fct cb)
-{
- if(cb)
- SIGNAL_CONNECT(bt, "clicked", cb, win);
-
- gtk_widget_grab_default(bt);
-
- window_set_cancel(win, bt);
-}
-
-
-/* default callback handler for cancel button "clicked" signal */
-void window_cancel_button_cb(GtkWidget *w _U_, gpointer data)
-{
- window_destroy(GTK_WIDGET(data));
-}
-
-
-/* default callback handler: the window managers X of the window was clicked (delete_event) */
-gboolean
-window_delete_event_cb(GtkWidget *win, GdkEvent *event _U_, gpointer user_data _U_)
-{
- window_destroy(win);
-
- /* event handled, don't do anything else */
- return TRUE;
-}
-
-
-/* get the geometry of a window from window_new() */
-void
-window_get_geometry(GtkWidget *widget, window_geometry_t *geom)
-{
- gint desk_x, desk_y;
-#if GTK_MAJOR_VERSION >= 2
- GdkWindowState state;
-#endif
-
- /* Try to grab our geometry.
-
- GTK+ provides two routines to get a window's position relative
- to the X root window. If I understand the documentation correctly,
- gdk_window_get_deskrelative_origin applies mainly to Enlightenment
- and gdk_window_get_root_origin applies for all other WMs.
-
- The code below tries both routines, and picks the one that returns
- the upper-left-most coordinates.
-
- More info at:
-
- http://mail.gnome.org/archives/gtk-devel-list/2001-March/msg00289.html
- http://www.gtk.org/faq/#AEN606
- */
-
- gdk_window_get_root_origin(widget->window,
- &geom->x,
- &geom->y);
- if (gdk_window_get_deskrelative_origin(widget->window,
- &desk_x, &desk_y)) {
- if (desk_x <= geom->x &&
- desk_y <= geom->y)
- {
- geom->x = desk_x;
- geom->y = desk_y;
- }
- }
-
- /* XXX - Is this the "approved" method? */
- gdk_window_get_size(widget->window,
- &geom->width,
- &geom->height);
-
-#if GTK_MAJOR_VERSION >= 2
- state = gdk_window_get_state(widget->window);
- geom->maximized = (state == GDK_WINDOW_STATE_MAXIMIZED);
-#endif
-}
-
-
-/* set the geometry of a window from window_new() */
-void
-window_set_geometry(GtkWidget *widget, window_geometry_t *geom)
-{
- /* as we now have the geometry from the recent file, set it */
- if (geom->set_pos) {
- gtk_widget_set_uposition(widget,
- geom->x,
- geom->y);
- }
-
- if (geom->set_size) {
-#if GTK_MAJOR_VERSION >= 2
- gtk_window_resize(GTK_WINDOW(widget),
-#else
- gtk_window_set_default_size(GTK_WINDOW(widget),
- geom->width,
- geom->height);
- gtk_widget_set_usize(widget,
-#endif
- /*WIDGET_SET_SIZE(widget,*/
- geom->width,
- geom->height);
- }
-
-#if GTK_MAJOR_VERSION >= 2
- if(geom->set_maximized) {
- if (geom->maximized) {
- gdk_window_maximize(widget->window);
- } else {
- gdk_window_unmaximize(widget->window);
- }
- }
-#endif
-}
-
-
-/* the geometry hashtable for all known window classes,
- * the window name is the key, and the geometry struct is the value */
-GHashTable *window_geom_hash = NULL;
-
-
-/* save the window and it's current geometry into the geometry hashtable */
-static void
-window_geom_save(const gchar *name, window_geometry_t *geom)
-{
- gchar *key;
- window_geometry_t *work;
-
- /* init hashtable, if not already done */
- if(!window_geom_hash) {
- window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal);
- }
- /* if we have an old one, remove and free it first */
- work = g_hash_table_lookup(window_geom_hash, name);
- if(work) {
- g_hash_table_remove(window_geom_hash, name);
- g_free(work->key);
- g_free(work);
- }
-
- /* g_malloc and insert the new one */
- work = g_malloc(sizeof(*geom));
- *work = *geom;
- key = g_strdup(name);
- work->key = key;
- g_hash_table_insert(window_geom_hash, key, work);
-}
-
-
-/* load the desired geometry for this window from the geometry hashtable */
-static gboolean
-window_geom_load(const gchar *name, window_geometry_t *geom)
-{
- window_geometry_t *p;
-
- /* init hashtable, if not already done */
- if(!window_geom_hash) {
- window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- p = g_hash_table_lookup(window_geom_hash, name);
- if(p) {
- *geom = *p;
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-
-/* read in a single key value pair from the recent file into the geometry hashtable */
-void
-window_geom_recent_read_pair(const char *name, const char *key, const char *value)
-{
- window_geometry_t geom;
-
-
- /* find window geometry maybe already in hashtable */
- if(!window_geom_load(name, &geom)) {
- /* not in table, init geom with "basic" values */
- geom.key = g_strdup(name);
- geom.set_pos = FALSE;
- geom.x = -1;
- geom.y = -1;
- geom.set_size = FALSE;
- geom.width = -1;
- geom.height = -1;
-
- geom.set_maximized = FALSE;/* this is valid in GTK2 only */
- geom.maximized = FALSE; /* this is valid in GTK2 only */
- }
-
- if (strcmp(key, "x") == 0) {
- geom.x = strtol(value, NULL, 10);
- geom.set_pos = TRUE;
- } else if (strcmp(key, "y") == 0) {
- geom.y = strtol(value, NULL, 10);
- geom.set_pos = TRUE;
- } else if (strcmp(key, "width") == 0) {
- geom.width = strtol(value, NULL, 10);
- geom.set_size = TRUE;
- } else if (strcmp(key, "height") == 0) {
- geom.height = strtol(value, NULL, 10);
- geom.set_size = TRUE;
- } else if (strcmp(key, "maximized") == 0) {
- if (strcasecmp(value, "true") == 0) {
- geom.maximized = TRUE;
- }
- else {
- geom.maximized = FALSE;
- }
- geom.set_maximized = TRUE;
- } else {
- g_assert_not_reached();
- }
-
- /* save / replace geometry in hashtable */
- window_geom_save(name, &geom);
-}
-
-
-/* write all geometry values of all windows from the hashtable to the recent file */
-void
-window_geom_recent_write_all(gpointer rf)
-{
- /* init hashtable, if not already done */
- if(!window_geom_hash) {
- window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- g_hash_table_foreach(window_geom_hash, write_recent_geom, rf);
-}
-
-
-void
-window_destroy(GtkWidget *win)
-{
- window_geometry_t geom;
- const gchar *name;
-
- /* get_geometry must be done *before* destroy is running, as the window geometry
- * cannot be retrieved at destroy time (so don't use event "destroy" for this) */
- /* ...and don't do this at all, if we currently have no GdkWindow (e.g. if the
- * GtkWidget is hidden) */
- if(!GTK_WIDGET_NO_WINDOW(win) && GTK_WIDGET_VISIBLE(win)) {
- window_get_geometry(win, &geom);
-
- name = OBJECT_GET_DATA(win, WINDOW_GEOM_KEY);
- if(name) {
- window_geom_save(name, &geom);
- g_free((gpointer)name);
- }
- }
-
- gtk_widget_destroy(win);
-}
-
-
-/* convert an xpm to a GtkWidget, using the window settings from it's parent */
-/* (be sure that the parent window is already being displayed) */
-GtkWidget *xpm_to_widget_from_parent(GtkWidget *parent, const char ** xpm) {
-#if GTK_MAJOR_VERSION < 2
- GdkPixmap *icon;
- GdkBitmap * mask;
-
-
- icon = gdk_pixmap_create_from_xpm_d(parent->window, &mask, &parent->style->white, (char **) xpm);
- return gtk_pixmap_new(icon, mask);
-#else
- GdkPixbuf * pixbuf;
- GdkPixmap * pixmap;
- GdkBitmap * bitmap;
-
-
- pixbuf = gdk_pixbuf_new_from_xpm_data(xpm);
- gdk_pixbuf_render_pixmap_and_mask_for_colormap (pixbuf, gtk_widget_get_colormap(parent), &pixmap, &bitmap, 128);
-
- return gtk_image_new_from_pixmap (pixmap, bitmap);
-#endif
-}
-
-
-/* convert an xpm to a GtkWidget, using the top_level window settings */
-/* (be sure that the top_level window is already being displayed) */
-GtkWidget *xpm_to_widget(const char ** xpm) {
- return xpm_to_widget_from_parent(top_level, xpm);
-}
-
-
-/* Set the name of the top-level window and its icon to the specified
- string. */
-void
-set_main_window_name(gchar *window_name)
-{
- gchar *title;
-
- /* use user-defined window title if preference is set */
- title = create_user_window_title(window_name);
- gtk_window_set_title(GTK_WINDOW(top_level), title);
- gdk_window_set_icon_name(top_level->window, title);
- g_free(title);
-}
-
-
-/* update the main window */
-void main_window_update(void)
-{
- while (gtk_events_pending()) gtk_main_iteration();
-}
-
-#ifdef HAVE_LIBPCAP
-
-/* exit the main window */
-void main_window_exit(void)
-{
- gtk_exit(0);
-}
-
-/* quit a nested main window */
-void main_window_nested_quit(void)
-{
- if (gtk_main_level() > 0)
- gtk_main_quit();
-}
-
-/* quit the main window */
-void main_window_quit(void)
-{
- gtk_main_quit();
-}
-
-
-
-typedef struct pipe_input_tag {
- gint source;
- gpointer user_data;
- int *child_process;
- pipe_input_cb_t input_cb;
- guint pipe_input_id;
-} pipe_input_t;
-
-
-#ifdef _WIN32
-/* The timer has expired, see if there's stuff to read from the pipe,
- if so, do the callback */
-static gint
-pipe_timer_cb(gpointer data)
-{
- HANDLE handle;
- DWORD avail = 0;
- gboolean result, result1;
- DWORD childstatus;
- pipe_input_t *pipe_input = data;
-
-
- /* Oddly enough although Named pipes don't work on win9x,
- PeekNamedPipe does !!! */
- handle = (HANDLE) _get_osfhandle (pipe_input->source);
- result = PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL);
-
- /* Get the child process exit status */
- result1 = GetExitCodeProcess((HANDLE)*(pipe_input->child_process),
- &childstatus);
-
- /* If the Peek returned an error, or there are bytes to be read
- or the childwatcher thread has terminated then call the normal
- callback */
- if (!result || avail > 0 || childstatus != STILL_ACTIVE) {
-
- /* avoid reentrancy problems and stack overflow */
- gtk_timeout_remove(pipe_input->pipe_input_id);
-
- /* And call the real handler */
- if (pipe_input->input_cb(pipe_input->source, pipe_input->user_data)) {
- /* restore pipe handler */
- pipe_input->pipe_input_id = gtk_timeout_add(200, pipe_timer_cb, data);
- }
-
- /* Return false so that this timer is not run again */
- return FALSE;
- }
- else {
- /* No data so let timer run again */
- return TRUE;
- }
-}
-
-#else /* _WIN32 */
-
-/* There's stuff to read from the sync pipe, meaning the child has sent
- us a message, or the sync pipe has closed, meaning the child has
- closed it (perhaps because it exited). */
-static void
-pipe_input_cb(gpointer data, gint source _U_,
- GdkInputCondition condition _U_)
-{
- pipe_input_t *pipe_input = data;
-
-
- /* avoid reentrancy problems and stack overflow */
- gtk_input_remove(pipe_input->pipe_input_id);
-
- if (pipe_input->input_cb(source, pipe_input->user_data)) {
- /* restore pipe handler */
- pipe_input->pipe_input_id = gtk_input_add_full (source,
- GDK_INPUT_READ|GDK_INPUT_EXCEPTION,
- pipe_input_cb,
- NULL,
- data,
- NULL);
- }
-}
-#endif
-
-void pipe_input_set_handler(gint source, gpointer user_data, int *child_process, pipe_input_cb_t input_cb)
-{
- static pipe_input_t pipe_input;
-
- pipe_input.source = source;
- pipe_input.child_process = child_process;
- pipe_input.user_data = user_data;
- pipe_input.input_cb = input_cb;
-
-#ifdef _WIN32
- /* Tricky to use pipes in win9x, as no concept of wait. NT can
- do this but that doesn't cover all win32 platforms. GTK can do
- this but doesn't seem to work over processes. Attempt to do
- something similar here, start a timer and check for data on every
- timeout. */
- pipe_input.pipe_input_id = gtk_timeout_add(200, pipe_timer_cb, &pipe_input);
-#else
- pipe_input.pipe_input_id = gtk_input_add_full(source,
- GDK_INPUT_READ|GDK_INPUT_EXCEPTION,
- pipe_input_cb,
- NULL,
- &pipe_input,
- NULL);
-#endif
-}
-
-
-#endif /* HAVE_LIBPCAP */
-
-/* Given a pointer to a GtkWidget for a top-level window, raise it and
- de-iconify it. This routine is used if the user has done something to
- ask that a window of a certain type be popped up when there can be only
- one such window and such a window has already been popped up - we
- pop up the existing one rather than creating a new one.
-
- XXX - we should request that it be given the input focus, too. Alas,
- GDK has nothing to do that, e.g. by calling "XSetInputFocus()" in a
- window in X. Besides, using "XSetInputFocus()" doesn't work anyway,
- apparently due to the way GTK+/GDK manages the input focus.
-
- The X Desktop Group's Window Manager Standard specifies, in the section
- on Root Window Properties, an _NET_ACTIVE_WINDOW client message that
- can be sent to the root window, containing the window ID of the
- window to activate; I infer that this might be the way to give the
- window the input focus - I assume that means it's also de-iconified,
- but I wouldn't assume it'd raise it.
-
- XXX - will this do the right thing on window systems other than X? */
-void
-reactivate_window(GtkWidget *win)
-{
- gdk_window_show(win->window);
- gdk_window_raise(win->window);
-}
-
-/* List of all GtkScrolledWindows, so we can globally set the scrollbar
- placement of all of them. */
-static GList *scrolled_windows;
-
-static void setup_scrolled_window(GtkWidget *scrollw);
-static void forget_scrolled_window(GtkWidget *scrollw, gpointer data);
-static void set_scrollbar_placement_scrollw(GtkWidget *scrollw);
-
-/* Create a GtkScrolledWindow, set its scrollbar placement appropriately,
- and remember it. */
-GtkWidget *
-scrolled_window_new(GtkAdjustment *hadjustment, GtkAdjustment *vadjustment)
-{
- GtkWidget *scrollw;
-
- scrollw = gtk_scrolled_window_new(hadjustment, vadjustment);
- setup_scrolled_window(scrollw);
- return scrollw;
-}
-
-/* Set a GtkScrolledWindow's scrollbar placement and add it to the list
- of GtkScrolledWindows. */
-static void
-setup_scrolled_window(GtkWidget *scrollw)
-{
- set_scrollbar_placement_scrollw(scrollw);
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- scrolled_windows = g_list_append(scrolled_windows, scrollw);
-
- /* Catch the "destroy" event on the widget, so that we remove it from
- the list when it's destroyed. */
- SIGNAL_CONNECT(scrollw, "destroy", forget_scrolled_window, NULL);
-}
-
-/* Remove a GtkScrolledWindow from the list of GtkScrolledWindows. */
-static void
-forget_scrolled_window(GtkWidget *scrollw, gpointer data _U_)
-{
- scrolled_windows = g_list_remove(scrolled_windows, scrollw);
-}
-
-/* Set the scrollbar placement of a GtkScrolledWindow based upon user
- preference. */
-static void
-set_scrollbar_placement_scrollw(GtkWidget *scrollw)
-{
- if (prefs.gui_scrollbar_on_right) {
- gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scrollw),
- GTK_CORNER_TOP_LEFT);
- } else {
- gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scrollw),
- GTK_CORNER_TOP_RIGHT);
- }
-}
-
-static void
-set_scrollbar_placement_cb(gpointer data, gpointer user_data _U_)
-{
- set_scrollbar_placement_scrollw((GtkWidget *)data);
-}
-
-/* Set the scrollbar placement of all GtkScrolledWindows based on
- user preference. */
-void
-set_scrollbar_placement_all(void)
-{
- g_list_foreach(scrolled_windows, set_scrollbar_placement_cb, NULL);
-}
-
-/* List of all CTrees/TreeViews, so we can globally set the line and
- * expander style of all of them. */
-static GList *trees;
-
-static void setup_tree(GtkWidget *tree);
-static void forget_tree(GtkWidget *tree, gpointer data);
-static void set_tree_styles(GtkWidget *tree);
-
-/* Create a Tree, give it the right styles, and remember it. */
-#if GTK_MAJOR_VERSION < 2
-GtkWidget *
-ctree_new(gint columns, gint tree_column)
-#else
-GtkWidget *
-tree_view_new(GtkTreeModel *model)
-#endif
-{
- GtkWidget *tree;
-
-#if GTK_MAJOR_VERSION < 2
- tree = gtk_ctree_new(columns, tree_column);
-#else
- tree = gtk_tree_view_new_with_model(model);
-#endif
- setup_tree(tree);
- return tree;
-}
-
-#if GTK_MAJOR_VERSION < 2
-GtkWidget *
-ctree_new_with_titles(gint columns, gint tree_column, const gchar *titles[])
-{
- GtkWidget *tree;
-
- tree = gtk_ctree_new_with_titles(columns, tree_column, (gchar **) titles);
- setup_tree(tree);
- return tree;
-}
-#endif
-
-/* Set a Tree's styles and add it to the list of Trees. */
-static void
-setup_tree(GtkWidget *tree)
-{
- set_tree_styles(tree);
-
- trees = g_list_append(trees, tree);
-
- /* Catch the "destroy" event on the widget, so that we remove it from
- the list when it's destroyed. */
- SIGNAL_CONNECT(tree, "destroy", forget_tree, NULL);
-}
-
-/* Remove a Tree from the list of Trees. */
-static void
-forget_tree(GtkWidget *tree, gpointer data _U_)
-{
- trees = g_list_remove(trees, tree);
-}
-
-/* Set the styles of a Tree based upon user preferences. */
-static void
-set_tree_styles(GtkWidget *tree)
-{
-#if GTK_MAJOR_VERSION < 2
- g_assert(prefs.gui_ptree_line_style >= GTK_CTREE_LINES_NONE &&
- prefs.gui_ptree_line_style <= GTK_CTREE_LINES_TABBED);
- gtk_ctree_set_line_style(GTK_CTREE(tree), prefs.gui_ptree_line_style);
- g_assert(prefs.gui_ptree_expander_style >= GTK_CTREE_EXPANDER_NONE &&
- prefs.gui_ptree_expander_style <= GTK_CTREE_EXPANDER_CIRCULAR);
- gtk_ctree_set_expander_style(GTK_CTREE(tree),
- prefs.gui_ptree_expander_style);
-#else
- g_assert(prefs.gui_altern_colors >= 0 && prefs.gui_altern_colors <= 1);
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree),
- prefs.gui_altern_colors);
-#endif
-}
-
-static void
-set_tree_styles_cb(gpointer data, gpointer user_data _U_)
-{
- set_tree_styles((GtkWidget *)data);
-}
-
-/* Set the styles of all Trees based upon style values. */
-void
-set_tree_styles_all(void)
-{
- g_list_foreach(trees, set_tree_styles_cb, NULL);
-}
-
-
-
-
-#if GTK_MAJOR_VERSION < 2
-/* convert variable argument list of values to array of strings (GTK2 -> GTK1) */
-static void
-simple_list_convert(gchar **ent, va_list ap)
-{
- int i;
- char *s;
-
- while( (i = va_arg(ap, int)) != -1 ) {
- s = va_arg(ap, char *);
- ent[i] = s;
- }
-}
-#endif
-
-
-/* append a row to the simple list */
-/* use it like: simple_list_append(list, 0, "first", 1, "second", -1) */
-void
-simple_list_append(GtkWidget *list, ...)
-{
- va_list ap;
-
-#if GTK_MAJOR_VERSION < 2
- gchar *ent[10]; /* new entry added in clist */
-#else
- GtkTreeIter iter;
- GtkListStore *store;
-#endif
-
- va_start(ap, list);
-#if GTK_MAJOR_VERSION < 2
- simple_list_convert(ent, ap);
- gtk_clist_append(GTK_CLIST(list), ent);
-#else
- store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
- gtk_list_store_append(store, &iter);
- gtk_list_store_set_valist(store, &iter, ap);
-#endif
- va_end(ap);
-}
-
-/* create a simple list widget */
-GtkWidget *
-simple_list_new(gint cols, const gchar **titles) {
- GtkWidget *plugins_list;
-#if GTK_MAJOR_VERSION >= 2
- int i;
- GtkListStore *store;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-#endif
-
-
-#if GTK_MAJOR_VERSION < 2
- plugins_list = gtk_clist_new_with_titles(cols, (gchar **) titles);
- gtk_clist_set_selection_mode(GTK_CLIST(plugins_list), GTK_SELECTION_SINGLE);
- gtk_clist_column_titles_passive(GTK_CLIST(plugins_list));
- if(titles) {
- gtk_clist_column_titles_show(GTK_CLIST(plugins_list));
- } else {
- gtk_clist_column_titles_hide(GTK_CLIST(plugins_list));
- }
- gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_list), 0, TRUE);
- gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_list), 1, TRUE);
-#else
- g_assert(cols <= 10);
- store = gtk_list_store_new(cols,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
- plugins_list = tree_view_new(GTK_TREE_MODEL(store));
- g_object_unref(G_OBJECT(store));
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(plugins_list), (titles != NULL));
- for(i=0; i<cols; i++) {
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(titles ? titles[i] : "", renderer,
- "text", i, NULL);
- gtk_tree_view_column_set_sort_column_id(column, i);
- gtk_tree_view_append_column(GTK_TREE_VIEW(plugins_list), column);
- }
-#endif
-
- return plugins_list;
-}
-
-extern void
-copy_to_clipboard(GString *str)
-{
-#if (GTK_MAJOR_VERSION >= 2)
- GtkClipboard *cb;
-
- cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* Get the default clipboard */
- gtk_clipboard_set_text(cb, str->str, -1); /* Copy the byte data into the clipboard */
-#else
- GtkWidget *window;
- GtkWidget *text;
-
- window = window_new (GTK_WINDOW_TOPLEVEL,"");
- text = gtk_text_new (NULL, NULL); /* Create the GtkText widget */
- gtk_container_add (GTK_CONTAINER (window), text); /* Avoid a GTK assertion */
- gtk_widget_realize (text); /* Realizing a widget creates a window for it, ready for us to insert some text */
- gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, str->str, -1);
- gtk_editable_select_region((GtkEditable *)text, 0, -1); /* Select ALL text */
- gtk_editable_copy_clipboard((GtkEditable *)text); /* Copy the byte data into the clipboard */
-#endif
-}
-
-/*
- * Create a new window title string with user-defined title preference.
- * (Or ignore it if unspecified).
- */
-gchar *
-create_user_window_title(const gchar *caption)
-{
- /* fail-safe */
- if (caption == NULL)
- return g_strdup("");
-
- /* no user-defined title specified */
- if ((prefs.gui_window_title == NULL) || (*prefs.gui_window_title == '\0'))
- return g_strdup(caption);
-
- return g_strdup_printf("%s %s", prefs.gui_window_title, caption);
-}
+/* ui_util.c
+ * UI utility routines
+ *
+ * $Id$
+ *
+ * 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 <string.h>
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+#ifdef HAVE_IO_H
+# include <io.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "gtkglobals.h"
+#include "gui_utils.h"
+#include <epan/prefs.h>
+#include "epan/epan.h"
+#include "../ui_util.h"
+#include "compat_macros.h"
+#include "recent.h"
+
+
+#include "image/eicon3d16.xpm"
+
+/* XXX - remove this later again, when dlg_xx function cleanup done */
+#include "dlg_utils.h"
+
+
+#define WINDOW_GEOM_KEY "window_geom"
+
+
+/* load the geometry values for a window from previously saved values */
+static gboolean window_geom_load(const gchar *name, window_geometry_t *geom);
+
+
+
+/* Set our window icon. The GDK documentation doesn't provide any
+ actual documentation for gdk_window_set_icon(), so we'll steal
+ libgimp/gimpdialog.c:gimp_dialog_realize_callback() from the Gimp
+ sources and assume it's safe.
+
+ XXX - The current icon size is fixed at 16x16 pixels, which looks fine
+ with kwm (KDE 1.x's window manager), Sawfish (the "default" window
+ manager for GNOME?), and under Windows with Exceed putting X windows
+ on the Windows desktop, using Exceed as the window manager, as those
+ window managers put a 16x16 icon on the title bar.
+
+ The window managers in some windowing environments (e.g. dtwm in CDE)
+ and some stand-alone window managers have larger icon sizes (many window
+ managers put the window icon on the desktop, in the Windows 3.x style,
+ rather than in the titlebar, in the Windows 4.x style), so we need to
+ find a way to size our icon appropriately.
+
+ The X11 Inter-Client Communications Conventions Manual, Version 1.1,
+ in X11R5, specifies that "a window manager that wishes to place
+ constraints on the sizes of icon pixmaps and/or windows should
+ place a property called WM_ICON_SIZE on the root"; that property
+ contains minimum width and height, maximum width and height, and
+ width and height increment values. "XGetIconSizes()" retrieves
+ that property; unfortunately, I've yet to find a window manager
+ that sets it on the root window (kwm, AfterStep, and Exceed don't
+ appear to set it).
+
+ The X Desktop Group's Window Manager Standard specifies, in the section
+ on Application Window Properties, an _NET_WM_ICON property, presumably
+ set by the window manager, which is an array of possible icon sizes
+ for the client. There's no API in GTK+ 1.2[.x] for this; there may
+ eventually be one either in GTK+ 2.0 or GNOME 2.0.
+
+ Some window managers can be configured to take the window name
+ specified by the WM_NAME property of a window or the resource
+ or class name specified by the WM_CLASS property and base the
+ choice of icon for the window on one of those; WM_CLASS for
+ Ethereal's windows has a resource name of "ethereal" and a class
+ name of "Ethereal". However, the way that's done is window-manager-
+ specific, and there's no way to determine what size a particular
+ window manager would want, so there's no way to automate this as
+ part of the installation of Ethereal.
+ */
+static void
+window_icon_realize_cb (GtkWidget *win, gpointer data _U_)
+{
+#ifndef _WIN32
+ static GdkPixmap *icon_pmap = NULL;
+ static GdkBitmap *icon_mask = NULL;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (win);
+
+ if (icon_pmap == NULL) {
+ icon_pmap = gdk_pixmap_create_from_xpm_d (win->window,
+ &icon_mask, &style->bg[GTK_STATE_NORMAL], eicon3d16_xpm);
+ }
+
+ gdk_window_set_icon (win->window, NULL, icon_pmap, icon_mask);
+#endif
+}
+
+
+/* Create a new window, of the specified type, with the specified title
+ (if any) and the Ethereal icon. */
+GtkWidget *
+window_new(GtkWindowType type, const gchar *title)
+{
+ GtkWidget *win;
+
+ win = gtk_window_new(type);
+ if (title != NULL)
+ gtk_window_set_title(GTK_WINDOW(win), title);
+ SIGNAL_CONNECT(win, "realize", window_icon_realize_cb, NULL);
+
+ /* XXX - which one is the correct default policy? or use a preference for this? */
+ /* GTK_WIN_POS_NONE, GTK_WIN_POS_CENTER or GTK_WIN_POS_MOUSE */
+ /* a lot of people dislike GTK_WIN_POS_MOUSE */
+
+ /* set the initial position (must be done, before show is called!) */
+#if GTK_MAJOR_VERSION >= 2
+/* gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ON_PARENT);*/
+#else
+/* gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);*/
+#endif
+ gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_NONE);
+
+#if GTK_MAJOR_VERSION < 2
+ /* allow window to be shrinked by user, as gtk_widget_set_usize() will set minimum size and */
+ /* the user never could shrink the window again */
+ gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, FALSE);
+#endif
+
+ return win;
+}
+
+
+/* Same as window_new(), but will keep it's geometry values (size, position, ...).
+ * Be sure to use window_present() and window_destroy() appropriately! */
+GtkWidget *
+window_new_with_geom(GtkWindowType type, const gchar *title, const gchar *geom_name)
+{
+ window_geometry_t geom;
+ GtkWidget *win = window_new(type, title);
+
+ OBJECT_SET_DATA(win, WINDOW_GEOM_KEY, (gpointer)g_strdup(geom_name));
+
+ /* do we have a previously saved size and position of this window? */
+ if(geom_name) {
+ /* It's a good idea to set the position and size of the window already here,
+ * as it's still invisible and won't "flicker the screen" while initially resizing. */
+ if(window_geom_load(geom_name, &geom)) {
+ /* XXX - use prefs to select which values to set? */
+ geom.set_pos = TRUE;
+ geom.set_size = TRUE;
+ geom.set_maximized = FALSE; /* don't maximize until window is shown */
+ window_set_geometry(win, &geom);
+ }
+ }
+
+ return win;
+}
+
+
+#if GTK_MAJOR_VERSION < 2
+/* We can't set the decorations until the window is realized. */
+static void
+window_notitle_realize_cb (GtkWidget *win, gpointer data _U_)
+{
+ gdk_window_set_decorations(win->window, 0);
+}
+#endif
+
+
+/* Create a new window for a splash screen; it's a main window, with no title,
+ positioned in the center of the screen. */
+GtkWidget *
+splash_window_new(void)
+{
+ GtkWidget *win;
+
+ win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#if GTK_MAJOR_VERSION >= 2
+ gtk_window_set_decorated(GTK_WINDOW(win), FALSE);
+#else
+ SIGNAL_CONNECT(win, "realize", window_notitle_realize_cb, NULL);
+#endif
+
+ /* set the initial position (must be done, before show is called!) */
+ gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
+
+ return win;
+}
+
+
+/* Present the created window on the screen. */
+void
+window_present(GtkWidget *win)
+{
+ window_geometry_t geom;
+ const gchar *name;
+
+#if GTK_MAJOR_VERSION >= 2
+ /* present this window */
+ gtk_window_present(GTK_WINDOW(win));
+#endif
+
+ /* do we have a previously saved size and position of this window? */
+ name = OBJECT_GET_DATA(win, WINDOW_GEOM_KEY);
+ if(name) {
+ if(window_geom_load(name, &geom)) {
+ /* XXX - use prefs to select which values to set? */
+ geom.set_pos = TRUE;
+ geom.set_size = TRUE;
+ geom.set_maximized = TRUE;
+ window_set_geometry(win, &geom);
+ }
+ }
+}
+
+
+static gint
+window_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer cancel_button)
+{
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ if (event->keyval == GDK_Escape) {
+ gtk_widget_activate(GTK_WIDGET(cancel_button));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/* Set the "key_press_event" signal for a top-level dialog window to
+ call a routine to activate the "Cancel" button for a dialog box if
+ the key being pressed is the <Esc> key.
+
+ XXX - there should be a GTK+ widget that'll do that for you, and
+ let you specify a "Cancel" button. It should also not impose
+ a requirement that there be a separator in the dialog box, as
+ the GtkDialog widget does; the visual convention that there's
+ such a separator between the rest of the dialog boxes and buttons
+ such as "OK" and "Cancel" is, for better or worse, not universal
+ (not even in GTK+ - look at the GtkFileSelection dialog!). */
+static void
+window_set_cancel(GtkWidget *widget, GtkWidget *cancel_button)
+{
+ SIGNAL_CONNECT(widget, "key_press_event", window_key_press_cb, cancel_button);
+}
+
+
+/* set the actions needed for the cancel "Close"/"Ok"/"Cancel" button that closes the window */
+void window_set_cancel_button(GtkWidget *win, GtkWidget *bt, window_cancel_button_fct cb)
+{
+ if(cb)
+ SIGNAL_CONNECT(bt, "clicked", cb, win);
+
+ gtk_widget_grab_default(bt);
+
+ window_set_cancel(win, bt);
+}
+
+
+/* default callback handler for cancel button "clicked" signal */
+void window_cancel_button_cb(GtkWidget *w _U_, gpointer data)
+{
+ window_destroy(GTK_WIDGET(data));
+}
+
+
+/* default callback handler: the window managers X of the window was clicked (delete_event) */
+gboolean
+window_delete_event_cb(GtkWidget *win, GdkEvent *event _U_, gpointer user_data _U_)
+{
+ window_destroy(win);
+
+ /* event handled, don't do anything else */
+ return TRUE;
+}
+
+
+/* get the geometry of a window from window_new() */
+void
+window_get_geometry(GtkWidget *widget, window_geometry_t *geom)
+{
+ gint desk_x, desk_y;
+#if GTK_MAJOR_VERSION >= 2
+ GdkWindowState state;
+#endif
+
+ /* Try to grab our geometry.
+
+ GTK+ provides two routines to get a window's position relative
+ to the X root window. If I understand the documentation correctly,
+ gdk_window_get_deskrelative_origin applies mainly to Enlightenment
+ and gdk_window_get_root_origin applies for all other WMs.
+
+ The code below tries both routines, and picks the one that returns
+ the upper-left-most coordinates.
+
+ More info at:
+
+ http://mail.gnome.org/archives/gtk-devel-list/2001-March/msg00289.html
+ http://www.gtk.org/faq/#AEN606
+ */
+
+ gdk_window_get_root_origin(widget->window,
+ &geom->x,
+ &geom->y);
+ if (gdk_window_get_deskrelative_origin(widget->window,
+ &desk_x, &desk_y)) {
+ if (desk_x <= geom->x &&
+ desk_y <= geom->y)
+ {
+ geom->x = desk_x;
+ geom->y = desk_y;
+ }
+ }
+
+ /* XXX - Is this the "approved" method? */
+ gdk_window_get_size(widget->window,
+ &geom->width,
+ &geom->height);
+
+#if GTK_MAJOR_VERSION >= 2
+ state = gdk_window_get_state(widget->window);
+ geom->maximized = (state == GDK_WINDOW_STATE_MAXIMIZED);
+#endif
+}
+
+
+/* set the geometry of a window from window_new() */
+void
+window_set_geometry(GtkWidget *widget, window_geometry_t *geom)
+{
+ /* as we now have the geometry from the recent file, set it */
+ if (geom->set_pos) {
+ gtk_widget_set_uposition(widget,
+ geom->x,
+ geom->y);
+ }
+
+ if (geom->set_size) {
+#if GTK_MAJOR_VERSION >= 2
+ gtk_window_resize(GTK_WINDOW(widget),
+#else
+ gtk_window_set_default_size(GTK_WINDOW(widget),
+ geom->width,
+ geom->height);
+ gtk_widget_set_usize(widget,
+#endif
+ /*WIDGET_SET_SIZE(widget,*/
+ geom->width,
+ geom->height);
+ }
+
+#if GTK_MAJOR_VERSION >= 2
+ if(geom->set_maximized) {
+ if (geom->maximized) {
+ gdk_window_maximize(widget->window);
+ } else {
+ gdk_window_unmaximize(widget->window);
+ }
+ }
+#endif
+}
+
+
+/* the geometry hashtable for all known window classes,
+ * the window name is the key, and the geometry struct is the value */
+GHashTable *window_geom_hash = NULL;
+
+
+/* save the window and it's current geometry into the geometry hashtable */
+static void
+window_geom_save(const gchar *name, window_geometry_t *geom)
+{
+ gchar *key;
+ window_geometry_t *work;
+
+ /* init hashtable, if not already done */
+ if(!window_geom_hash) {
+ window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+ /* if we have an old one, remove and free it first */
+ work = g_hash_table_lookup(window_geom_hash, name);
+ if(work) {
+ g_hash_table_remove(window_geom_hash, name);
+ g_free(work->key);
+ g_free(work);
+ }
+
+ /* g_malloc and insert the new one */
+ work = g_malloc(sizeof(*geom));
+ *work = *geom;
+ key = g_strdup(name);
+ work->key = key;
+ g_hash_table_insert(window_geom_hash, key, work);
+}
+
+
+/* load the desired geometry for this window from the geometry hashtable */
+static gboolean
+window_geom_load(const gchar *name, window_geometry_t *geom)
+{
+ window_geometry_t *p;
+
+ /* init hashtable, if not already done */
+ if(!window_geom_hash) {
+ window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+
+ p = g_hash_table_lookup(window_geom_hash, name);
+ if(p) {
+ *geom = *p;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+
+/* read in a single key value pair from the recent file into the geometry hashtable */
+void
+window_geom_recent_read_pair(const char *name, const char *key, const char *value)
+{
+ window_geometry_t geom;
+
+
+ /* find window geometry maybe already in hashtable */
+ if(!window_geom_load(name, &geom)) {
+ /* not in table, init geom with "basic" values */
+ geom.key = g_strdup(name);
+ geom.set_pos = FALSE;
+ geom.x = -1;
+ geom.y = -1;
+ geom.set_size = FALSE;
+ geom.width = -1;
+ geom.height = -1;
+
+ geom.set_maximized = FALSE;/* this is valid in GTK2 only */
+ geom.maximized = FALSE; /* this is valid in GTK2 only */
+ }
+
+ if (strcmp(key, "x") == 0) {
+ geom.x = strtol(value, NULL, 10);
+ geom.set_pos = TRUE;
+ } else if (strcmp(key, "y") == 0) {
+ geom.y = strtol(value, NULL, 10);
+ geom.set_pos = TRUE;
+ } else if (strcmp(key, "width") == 0) {
+ geom.width = strtol(value, NULL, 10);
+ geom.set_size = TRUE;
+ } else if (strcmp(key, "height") == 0) {
+ geom.height = strtol(value, NULL, 10);
+ geom.set_size = TRUE;
+ } else if (strcmp(key, "maximized") == 0) {
+ if (strcasecmp(value, "true") == 0) {
+ geom.maximized = TRUE;
+ }
+ else {
+ geom.maximized = FALSE;
+ }
+ geom.set_maximized = TRUE;
+ } else {
+ g_assert_not_reached();
+ }
+
+ /* save / replace geometry in hashtable */
+ window_geom_save(name, &geom);
+}
+
+
+/* write all geometry values of all windows from the hashtable to the recent file */
+void
+window_geom_recent_write_all(gpointer rf)
+{
+ /* init hashtable, if not already done */
+ if(!window_geom_hash) {
+ window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+
+ g_hash_table_foreach(window_geom_hash, write_recent_geom, rf);
+}
+
+
+void
+window_destroy(GtkWidget *win)
+{
+ window_geometry_t geom;
+ const gchar *name;
+
+ /* get_geometry must be done *before* destroy is running, as the window geometry
+ * cannot be retrieved at destroy time (so don't use event "destroy" for this) */
+ /* ...and don't do this at all, if we currently have no GdkWindow (e.g. if the
+ * GtkWidget is hidden) */
+ if(!GTK_WIDGET_NO_WINDOW(win) && GTK_WIDGET_VISIBLE(win)) {
+ window_get_geometry(win, &geom);
+
+ name = OBJECT_GET_DATA(win, WINDOW_GEOM_KEY);
+ if(name) {
+ window_geom_save(name, &geom);
+ g_free((gpointer)name);
+ }
+ }
+
+ gtk_widget_destroy(win);
+}
+
+
+/* convert an xpm to a GtkWidget, using the window settings from it's parent */
+/* (be sure that the parent window is already being displayed) */
+GtkWidget *xpm_to_widget_from_parent(GtkWidget *parent, const char ** xpm) {
+#if GTK_MAJOR_VERSION < 2
+ GdkPixmap *icon;
+ GdkBitmap * mask;
+
+
+ icon = gdk_pixmap_create_from_xpm_d(parent->window, &mask, &parent->style->white, (char **) xpm);
+ return gtk_pixmap_new(icon, mask);
+#else
+ GdkPixbuf * pixbuf;
+ GdkPixmap * pixmap;
+ GdkBitmap * bitmap;
+
+
+ pixbuf = gdk_pixbuf_new_from_xpm_data(xpm);
+ gdk_pixbuf_render_pixmap_and_mask_for_colormap (pixbuf, gtk_widget_get_colormap(parent), &pixmap, &bitmap, 128);
+
+ return gtk_image_new_from_pixmap (pixmap, bitmap);
+#endif
+}
+
+
+/* convert an xpm to a GtkWidget, using the top_level window settings */
+/* (be sure that the top_level window is already being displayed) */
+GtkWidget *xpm_to_widget(const char ** xpm) {
+ return xpm_to_widget_from_parent(top_level, xpm);
+}
+
+
+/* Set the name of the top-level window and its icon to the specified
+ string. */
+void
+set_main_window_name(gchar *window_name)
+{
+ gchar *title;
+
+ /* use user-defined window title if preference is set */
+ title = create_user_window_title(window_name);
+ gtk_window_set_title(GTK_WINDOW(top_level), title);
+ gdk_window_set_icon_name(top_level->window, title);
+ g_free(title);
+}
+
+
+/* update the main window */
+void main_window_update(void)
+{
+ while (gtk_events_pending()) gtk_main_iteration();
+}
+
+#ifdef HAVE_LIBPCAP
+
+/* exit the main window */
+void main_window_exit(void)
+{
+ gtk_exit(0);
+}
+
+/* quit a nested main window */
+void main_window_nested_quit(void)
+{
+ if (gtk_main_level() > 0)
+ gtk_main_quit();
+}
+
+/* quit the main window */
+void main_window_quit(void)
+{
+ gtk_main_quit();
+}
+
+
+
+typedef struct pipe_input_tag {
+ gint source;
+ gpointer user_data;
+ int *child_process;
+ pipe_input_cb_t input_cb;
+ guint pipe_input_id;
+} pipe_input_t;
+
+
+#ifdef _WIN32
+/* The timer has expired, see if there's stuff to read from the pipe,
+ if so, do the callback */
+static gint
+pipe_timer_cb(gpointer data)
+{
+ HANDLE handle;
+ DWORD avail = 0;
+ gboolean result, result1;
+ DWORD childstatus;
+ pipe_input_t *pipe_input = data;
+
+
+ /* Oddly enough although Named pipes don't work on win9x,
+ PeekNamedPipe does !!! */
+ handle = (HANDLE) _get_osfhandle (pipe_input->source);
+ result = PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL);
+
+ /* Get the child process exit status */
+ result1 = GetExitCodeProcess((HANDLE)*(pipe_input->child_process),
+ &childstatus);
+
+ /* If the Peek returned an error, or there are bytes to be read
+ or the childwatcher thread has terminated then call the normal
+ callback */
+ if (!result || avail > 0 || childstatus != STILL_ACTIVE) {
+
+ /* avoid reentrancy problems and stack overflow */
+ gtk_timeout_remove(pipe_input->pipe_input_id);
+
+ /* And call the real handler */
+ if (pipe_input->input_cb(pipe_input->source, pipe_input->user_data)) {
+ /* restore pipe handler */
+ pipe_input->pipe_input_id = gtk_timeout_add(200, pipe_timer_cb, data);
+ }
+
+ /* Return false so that this timer is not run again */
+ return FALSE;
+ }
+ else {
+ /* No data so let timer run again */
+ return TRUE;
+ }
+}
+
+#else /* _WIN32 */
+
+/* There's stuff to read from the sync pipe, meaning the child has sent
+ us a message, or the sync pipe has closed, meaning the child has
+ closed it (perhaps because it exited). */
+static void
+pipe_input_cb(gpointer data, gint source _U_,
+ GdkInputCondition condition _U_)
+{
+ pipe_input_t *pipe_input = data;
+
+
+ /* avoid reentrancy problems and stack overflow */
+ gtk_input_remove(pipe_input->pipe_input_id);
+
+ if (pipe_input->input_cb(source, pipe_input->user_data)) {
+ /* restore pipe handler */
+ pipe_input->pipe_input_id = gtk_input_add_full (source,
+ GDK_INPUT_READ|GDK_INPUT_EXCEPTION,
+ pipe_input_cb,
+ NULL,
+ data,
+ NULL);
+ }
+}
+#endif
+
+void pipe_input_set_handler(gint source, gpointer user_data, int *child_process, pipe_input_cb_t input_cb)
+{
+ static pipe_input_t pipe_input;
+
+ pipe_input.source = source;
+ pipe_input.child_process = child_process;
+ pipe_input.user_data = user_data;
+ pipe_input.input_cb = input_cb;
+
+#ifdef _WIN32
+ /* Tricky to use pipes in win9x, as no concept of wait. NT can
+ do this but that doesn't cover all win32 platforms. GTK can do
+ this but doesn't seem to work over processes. Attempt to do
+ something similar here, start a timer and check for data on every
+ timeout. */
+ pipe_input.pipe_input_id = gtk_timeout_add(200, pipe_timer_cb, &pipe_input);
+#else
+ pipe_input.pipe_input_id = gtk_input_add_full(source,
+ GDK_INPUT_READ|GDK_INPUT_EXCEPTION,
+ pipe_input_cb,
+ NULL,
+ &pipe_input,
+ NULL);
+#endif
+}
+
+
+#endif /* HAVE_LIBPCAP */
+
+/* Given a pointer to a GtkWidget for a top-level window, raise it and
+ de-iconify it. This routine is used if the user has done something to
+ ask that a window of a certain type be popped up when there can be only
+ one such window and such a window has already been popped up - we
+ pop up the existing one rather than creating a new one.
+
+ XXX - we should request that it be given the input focus, too. Alas,
+ GDK has nothing to do that, e.g. by calling "XSetInputFocus()" in a
+ window in X. Besides, using "XSetInputFocus()" doesn't work anyway,
+ apparently due to the way GTK+/GDK manages the input focus.
+
+ The X Desktop Group's Window Manager Standard specifies, in the section
+ on Root Window Properties, an _NET_ACTIVE_WINDOW client message that
+ can be sent to the root window, containing the window ID of the
+ window to activate; I infer that this might be the way to give the
+ window the input focus - I assume that means it's also de-iconified,
+ but I wouldn't assume it'd raise it.
+
+ XXX - will this do the right thing on window systems other than X? */
+void
+reactivate_window(GtkWidget *win)
+{
+ gdk_window_show(win->window);
+ gdk_window_raise(win->window);
+}
+
+/* List of all GtkScrolledWindows, so we can globally set the scrollbar
+ placement of all of them. */
+static GList *scrolled_windows;
+
+static void setup_scrolled_window(GtkWidget *scrollw);
+static void forget_scrolled_window(GtkWidget *scrollw, gpointer data);
+static void set_scrollbar_placement_scrollw(GtkWidget *scrollw);
+
+/* Create a GtkScrolledWindow, set its scrollbar placement appropriately,
+ and remember it. */
+GtkWidget *
+scrolled_window_new(GtkAdjustment *hadjustment, GtkAdjustment *vadjustment)
+{
+ GtkWidget *scrollw;
+
+ scrollw = gtk_scrolled_window_new(hadjustment, vadjustment);
+ setup_scrolled_window(scrollw);
+ return scrollw;
+}
+
+/* Set a GtkScrolledWindow's scrollbar placement and add it to the list
+ of GtkScrolledWindows. */
+static void
+setup_scrolled_window(GtkWidget *scrollw)
+{
+ set_scrollbar_placement_scrollw(scrollw);
+
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ scrolled_windows = g_list_append(scrolled_windows, scrollw);
+
+ /* Catch the "destroy" event on the widget, so that we remove it from
+ the list when it's destroyed. */
+ SIGNAL_CONNECT(scrollw, "destroy", forget_scrolled_window, NULL);
+}
+
+/* Remove a GtkScrolledWindow from the list of GtkScrolledWindows. */
+static void
+forget_scrolled_window(GtkWidget *scrollw, gpointer data _U_)
+{
+ scrolled_windows = g_list_remove(scrolled_windows, scrollw);
+}
+
+/* Set the scrollbar placement of a GtkScrolledWindow based upon user
+ preference. */
+static void
+set_scrollbar_placement_scrollw(GtkWidget *scrollw)
+{
+ if (prefs.gui_scrollbar_on_right) {
+ gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scrollw),
+ GTK_CORNER_TOP_LEFT);
+ } else {
+ gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scrollw),
+ GTK_CORNER_TOP_RIGHT);
+ }
+}
+
+static void
+set_scrollbar_placement_cb(gpointer data, gpointer user_data _U_)
+{
+ set_scrollbar_placement_scrollw((GtkWidget *)data);
+}
+
+/* Set the scrollbar placement of all GtkScrolledWindows based on
+ user preference. */
+void
+set_scrollbar_placement_all(void)
+{
+ g_list_foreach(scrolled_windows, set_scrollbar_placement_cb, NULL);
+}
+
+/* List of all CTrees/TreeViews, so we can globally set the line and
+ * expander style of all of them. */
+static GList *trees;
+
+static void setup_tree(GtkWidget *tree);
+static void forget_tree(GtkWidget *tree, gpointer data);
+static void set_tree_styles(GtkWidget *tree);
+
+/* Create a Tree, give it the right styles, and remember it. */
+#if GTK_MAJOR_VERSION < 2
+GtkWidget *
+ctree_new(gint columns, gint tree_column)
+#else
+GtkWidget *
+tree_view_new(GtkTreeModel *model)
+#endif
+{
+ GtkWidget *tree;
+
+#if GTK_MAJOR_VERSION < 2
+ tree = gtk_ctree_new(columns, tree_column);
+#else
+ tree = gtk_tree_view_new_with_model(model);
+#endif
+ setup_tree(tree);
+ return tree;
+}
+
+#if GTK_MAJOR_VERSION < 2
+GtkWidget *
+ctree_new_with_titles(gint columns, gint tree_column, const gchar *titles[])
+{
+ GtkWidget *tree;
+
+ tree = gtk_ctree_new_with_titles(columns, tree_column, (gchar **) titles);
+ setup_tree(tree);
+ return tree;
+}
+#endif
+
+/* Set a Tree's styles and add it to the list of Trees. */
+static void
+setup_tree(GtkWidget *tree)
+{
+ set_tree_styles(tree);
+
+ trees = g_list_append(trees, tree);
+
+ /* Catch the "destroy" event on the widget, so that we remove it from
+ the list when it's destroyed. */
+ SIGNAL_CONNECT(tree, "destroy", forget_tree, NULL);
+}
+
+/* Remove a Tree from the list of Trees. */
+static void
+forget_tree(GtkWidget *tree, gpointer data _U_)
+{
+ trees = g_list_remove(trees, tree);
+}
+
+/* Set the styles of a Tree based upon user preferences. */
+static void
+set_tree_styles(GtkWidget *tree)
+{
+#if GTK_MAJOR_VERSION < 2
+ g_assert(prefs.gui_ptree_line_style >= GTK_CTREE_LINES_NONE &&
+ prefs.gui_ptree_line_style <= GTK_CTREE_LINES_TABBED);
+ gtk_ctree_set_line_style(GTK_CTREE(tree), prefs.gui_ptree_line_style);
+ g_assert(prefs.gui_ptree_expander_style >= GTK_CTREE_EXPANDER_NONE &&
+ prefs.gui_ptree_expander_style <= GTK_CTREE_EXPANDER_CIRCULAR);
+ gtk_ctree_set_expander_style(GTK_CTREE(tree),
+ prefs.gui_ptree_expander_style);
+#else
+ g_assert(prefs.gui_altern_colors >= 0 && prefs.gui_altern_colors <= 1);
+ gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree),
+ prefs.gui_altern_colors);
+#endif
+}
+
+static void
+set_tree_styles_cb(gpointer data, gpointer user_data _U_)
+{
+ set_tree_styles((GtkWidget *)data);
+}
+
+/* Set the styles of all Trees based upon style values. */
+void
+set_tree_styles_all(void)
+{
+ g_list_foreach(trees, set_tree_styles_cb, NULL);
+}
+
+
+
+
+#if GTK_MAJOR_VERSION < 2
+/* convert variable argument list of values to array of strings (GTK2 -> GTK1) */
+static void
+simple_list_convert(gchar **ent, va_list ap)
+{
+ int i;
+ char *s;
+
+ while( (i = va_arg(ap, int)) != -1 ) {
+ s = va_arg(ap, char *);
+ ent[i] = s;
+ }
+}
+#endif
+
+
+/* append a row to the simple list */
+/* use it like: simple_list_append(list, 0, "first", 1, "second", -1) */
+void
+simple_list_append(GtkWidget *list, ...)
+{
+ va_list ap;
+
+#if GTK_MAJOR_VERSION < 2
+ gchar *ent[10]; /* new entry added in clist */
+#else
+ GtkTreeIter iter;
+ GtkListStore *store;
+#endif
+
+ va_start(ap, list);
+#if GTK_MAJOR_VERSION < 2
+ simple_list_convert(ent, ap);
+ gtk_clist_append(GTK_CLIST(list), ent);
+#else
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set_valist(store, &iter, ap);
+#endif
+ va_end(ap);
+}
+
+/* create a simple list widget */
+GtkWidget *
+simple_list_new(gint cols, const gchar **titles) {
+ GtkWidget *plugins_list;
+#if GTK_MAJOR_VERSION >= 2
+ int i;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+#endif
+
+
+#if GTK_MAJOR_VERSION < 2
+ plugins_list = gtk_clist_new_with_titles(cols, (gchar **) titles);
+ gtk_clist_set_selection_mode(GTK_CLIST(plugins_list), GTK_SELECTION_SINGLE);
+ gtk_clist_column_titles_passive(GTK_CLIST(plugins_list));
+ if(titles) {
+ gtk_clist_column_titles_show(GTK_CLIST(plugins_list));
+ } else {
+ gtk_clist_column_titles_hide(GTK_CLIST(plugins_list));
+ }
+ gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_list), 0, TRUE);
+ gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_list), 1, TRUE);
+#else
+ g_assert(cols <= 10);
+ store = gtk_list_store_new(cols,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ plugins_list = tree_view_new(GTK_TREE_MODEL(store));
+ g_object_unref(G_OBJECT(store));
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(plugins_list), (titles != NULL));
+ for(i=0; i<cols; i++) {
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(titles ? titles[i] : "", renderer,
+ "text", i, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, i);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(plugins_list), column);
+ }
+#endif
+
+ return plugins_list;
+}
+
+void
+copy_to_clipboard(GString *str)
+{
+#if (GTK_MAJOR_VERSION >= 2)
+ GtkClipboard *cb;
+
+ cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* Get the default clipboard */
+ gtk_clipboard_set_text(cb, str->str, -1); /* Copy the byte data into the clipboard */
+#else
+ GtkWidget *window;
+ GtkWidget *text;
+
+ window = window_new (GTK_WINDOW_TOPLEVEL,"");
+ text = gtk_text_new (NULL, NULL); /* Create the GtkText widget */
+ gtk_container_add (GTK_CONTAINER (window), text); /* Avoid a GTK assertion */
+ gtk_widget_realize (text); /* Realizing a widget creates a window for it, ready for us to insert some text */
+ gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, str->str, -1);
+ gtk_editable_select_region((GtkEditable *)text, 0, -1); /* Select ALL text */
+ gtk_editable_copy_clipboard((GtkEditable *)text); /* Copy the byte data into the clipboard */
+#endif
+}
+
+/*
+ * Create a new window title string with user-defined title preference.
+ * (Or ignore it if unspecified).
+ */
+gchar *
+create_user_window_title(const gchar *caption)
+{
+ /* fail-safe */
+ if (caption == NULL)
+ return g_strdup("");
+
+ /* no user-defined title specified */
+ if ((prefs.gui_window_title == NULL) || (*prefs.gui_window_title == '\0'))
+ return g_strdup(caption);
+
+ return g_strdup_printf("%s %s", prefs.gui_window_title, caption);
+}
diff --git a/gtk/gui_utils.h b/gtk/gui_utils.h
index 898b32f9f0..3a004b6b00 100644
--- a/gtk/gui_utils.h
+++ b/gtk/gui_utils.h
@@ -1,308 +1,308 @@
-/* gui_utils.h
- * Definitions for UI utility routines
- *
- * $Id: ui_util.h 15263 2005-08-08 17:22:55Z ulfl $
- *
- * 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 __GTKGUIUI_UTIL_H__
-#define __GTKGUIUI_UTIL_H__
-
-/** @defgroup windows_group Windows
- *
- * There are the following toplevel windows:
- *
- * - @ref main_window_group
- * - Statistic Windows (several different statistic windows)
- *
- * See: @ref howto_window_page for details.
- *
- */
-
-/** @page howto_window_page How to develop a window / dialog
- *
- * Windows and dialogs are related to each other. Dialogs are special kind of windows, but they behave
- * slightly different. Dialogs stick on it's parent window, normal windows will be much more independant
- * from it's parent window. Dialogs should be used to ask or note the user something, while windows should
- * show data independantly from the main window.
- * Dialogs are created by calling dlg_window_new() which in turn will call window_new().
- * After that, dialogs can be developed the same way as windows, all window related functions in gui_utils.h
- * can be used for both.
- *
- * @section window_create Create a window
- *
- * A typical window / dialog will be created by the following calls:
- *
- * - window_new() will create a new window with default position and size,
- * use dlg_window_new() if you need a dialog (transient to the main window)
- * - gtk_window_set_default_size() to set the default size of the window. Only
- * needed, if the initial size is not appropriate, e.g. when a scrolled_window_new() is used.
- * Be sure that the given size is larger than the initial size, otherwise the window might
- * clip the content (at least on GTK1)
- * - SIGNAL_CONNECT(my_win, "destroy", my_destroy_cb, NULL) callback, if some cleanup needs to be
- * done after the window is destroyed, e.g. free up memory, or set the window pointer
- * of a singleton window (only one instance allowed, e.g. about dialog) back to zero
- * - create and fill in the content and button widgets
- * - gtk_widget_show_all() shows all the widgets in the window
- * - window_present() present the window on screen and
- * (if available) set previously saved position and size
- *
- * @section window_events Events
- *
- * The following events are usually interesting:
- *
- * - "delete_event": the window managers "X" (e.g. upper right edge) of the window
- * was clicked, default handler will call gtk_widget_destroy()
- * - "destroy": everything is already gone, only cleanup of left over ressources
- * can/should be done now
- *
- * @section window_hints Hints
- *
- * If you want to save size and position, be sure to call window_destroy() instead of only
- * gtk_widget_destroy(), so you will probably have to SIGNAL_CONNECT to the "delete_event"!
- *
- * Don't use WIDGET_SET_SIZE() to set the size of a window,
- * use gtk_window_set_default_size() for that purpose!
- *
- * Be sure to call window_present() / window_destroy() appropriately, if you
- * want to have size and position of the window handled by ui_util.
- *
- */
-
-/** @file
- * Utilities for Windows and other user interface functions. See: @ref howto_window_page for details.
- * @ingroup dialog_group
- * @ingroup windows_group
- */
-
-/** @name Window Functions
- * @todo Move these window functions to a new file win_utils.h?
- * @{ */
-
-/** Create a new window with the Ethereal icon.
- * If you want to create a dialog, use dlg_window_new() instead.
- *
- * @param type window type, typical GTK_WINDOW_TOPLEVEL
- * @param title the title for the new window
- * @return the newly created window
- */
-extern GtkWidget *window_new(GtkWindowType type, const gchar *title);
-
-/** Same as window_new(), but will keep its geometry values (size, position, ...).
- * Be sure to use window_present() and window_destroy() appropriately!
- *
- * @param type window type, typical GTK_WINDOW_TOPLEVEL
- * @param title the title for the new window
- * @param geom_name the name to distinguish this window, will also be used for the recent file (don't use special chars)
- * @return the newly created window
- */
-extern GtkWidget *window_new_with_geom(GtkWindowType type, const gchar *title, const gchar *geom_name);
-
-/** Create a new splash window, with no icon or title bar.
- *
- * @return the newly created window
- */
-extern GtkWidget *splash_window_new(void);
-
-/** Present the created window on the top of the screen. This will put the window on top and
- * (if available) set previously saved position and size.
- *
- * @param win the window from window_new()
- */
-extern void window_present(GtkWidget *win);
-
-/** callback function for window_set_cancel_button() */
-typedef void (*window_cancel_button_fct) (GtkWidget *w, gpointer data);
-
-/** Register the default cancel button "Cancel"/"Close"/"Ok" of this window.
- * This will set the callback function for this button, grab this button as the default one and
- * set the "ESC" key handler to call the callback function if key is pressed.
- *
- * @param win the window from window_new()
- * @param bt the default button of this window
- * @param cb callback function to be called, when this button is pressed
- */
-extern void window_set_cancel_button(GtkWidget *win, GtkWidget *bt, window_cancel_button_fct cb);
-
-/** Remember the current window position / size and then destroy the window.
- * It's important to call this instead of gtk_widget_destroy() when using window_new_with_geom().
- *
- * @param win the window from window_new()
- */
-extern void window_destroy(GtkWidget *win);
-
-/** Default callback handler for cancel button "clicked" signal.
- * Use this for window_set_cancel_button(), if no user specific functionality required,
- * will simply call window_destroy()
- */
-extern void window_cancel_button_cb(GtkWidget *w _U_, gpointer data);
-
-/** Default callback handler if the window managers X of the window was clicked (delete_event).
- * Use this for SIGNAL_CONNECT(), if no user specific functionality required,
- * will simply call window_destroy()
- */
-extern gboolean window_delete_event_cb(GtkWidget *win, GdkEvent *event _U_, gpointer user_data _U_);
-
-/** geometry values for use in window_get_geometry() and window_set_geometry() */
-typedef struct window_geometry_s {
- gchar *key; /**< current key in hashtable (internally used only) */
- gboolean set_pos; /**< set the x and y position values */
- gint x; /**< the windows x position */
- gint y; /**< the windows y position */
- gboolean set_size; /**< set the width and height values */
- gint width; /**< the windows width */
- gint height; /**< the windows height */
-
- gboolean set_maximized; /**< set the maximized state (GTK2 only) */
- gboolean maximized; /**< the windows maximized state (GTK2 only) */
-} window_geometry_t;
-
-/** Get the geometry of a window.
- *
- * @param win the window from window_new()
- * @param geom the current geometry values of the window, the set_xy values will not be used
- * @todo if main uses the window_new_with_geom() to save size and such, make this function static
- */
-extern void window_get_geometry(GtkWidget *win, window_geometry_t *geom);
-/** Set the geometry of a window.
- *
- * @param win the window from window_new()
- * @param geom the new geometry values of the window
- * @todo if main uses the window_new_with_geom() to save size and such, make this function static
- */
-extern void window_set_geometry(GtkWidget *win, window_geometry_t *geom);
-
-/** Write all geometry values of all windows to the recent file.
- * Will call write_recent_geom() for every existing window type.
- *
- * @param rf recent file handle from caller
- */
-extern void window_geom_recent_write_all(gpointer rf);
-
-/** Read in a single geometry key value pair from the recent file.
- *
- * @param name the geom_name of the window
- * @param key the subkey of this pair (e.g. "x")
- * @param value the new value (e.g. "123")
- */
-extern void window_geom_recent_read_pair(const char *name, const char *key, const char *value);
-
-/** Raise a top-level window and de-iconify it.
- * This routine is used if the user has done something to
- * ask that a window of a certain type be popped up when there can be only
- * one such window and such a window has already been popped up - we
- * pop up the existing one rather than creating a new one.
- *
- * @param win the window from window_new() to be reactivated
- */
-extern void reactivate_window(GtkWidget *win);
-
-/** @} */
-
-/** Create a GtkScrolledWindow, set its scrollbar placement appropriately,
- * and remember it.
- *
- * @param hadjustment horizontal adjustment
- * @param vadjustment vertical adjustment
- * @return the new scrolled window
- */
-extern GtkWidget *scrolled_window_new(GtkAdjustment *hadjustment,
- GtkAdjustment *vadjustment);
-
-/** Set the scrollbar placement of all scrolled windows based on user
- preference. */
-extern void set_scrollbar_placement_all(void);
-
-#if GTK_MAJOR_VERSION < 2
-/** Create a GtkCTree, give it the right styles, and remember it.
- *
- * @param columns the number of columns
- * @param tree_column which column has the tree graphic
- * @return the newly created GtkCTree
- */
-extern GtkWidget *ctree_new(gint columns, gint tree_column);
-/** Create a GtkCTree, give it the right styles, and remember it.
- *
- * @param columns the number of columns
- * @param tree_column which column has the tree graphic
- * @param titles the titles of all columns
- * @return the newly created GtkCTree
- */
-extern GtkWidget *ctree_new_with_titles(gint columns, gint tree_column,
- const gchar *titles[]);
-#else
-/** Create a GtkTreeView, give it the right styles, and remember it.
- *
- * @param model the model (the data) of this tree view
- */
-extern GtkWidget *tree_view_new(GtkTreeModel *model);
-#endif
-
-/** Create a simple list widget.
- *
- * @param cols number of columns
- * @param titles the titles of all columns
- * @return the new simple list widget
- */
-extern GtkWidget *simple_list_new(gint cols, const gchar **titles);
-/** Append a row to the simple list.
- *
- * @param list the list from simple_list_new()
- * @param ... row and title, finished by -1 (e.g.: 0, "first", 1, "second", -1).
- */
-extern void simple_list_append(GtkWidget *list, ...);
-
-
-
-/** Set the styles of all Trees based upon user preferences. */
-extern void set_tree_styles_all(void);
-
-/** Convert an xpm picture into a GtkWidget showing it.
- * Beware: Ethereal's main window must already be visible!
- *
- * @param xpm the character array containing the picture
- * @return a newly created GtkWidget showing the picture
- */
-extern GtkWidget *xpm_to_widget(const char ** xpm);
-
-/** Convert an xpm picture into a GtkWidget showing it.
- * Beware: the given parent window must already be visible!
- *
- * @param parent the parent window of to widget to be generated
- * @param xpm the character array containing the picture
- * @return a newly created GtkWidget showing the picture
- */
-extern GtkWidget *xpm_to_widget_from_parent(GtkWidget *parent, const char ** xpm);
-
-/** Copy a GString to the clipboard.
- *
- * @param str GString that is to be copied to the clipboard.
- */
-extern void copy_to_clipboard(GString *str);
-
-/** Create a new window title that includes user-defined preference string.
- *
- * @param caption string you want included in title (appended to user-defined string)
- * @return a newly created title string including user-defined preference (if specified)
- */
-extern gchar *create_user_window_title(const gchar *caption);
-
-
-#endif /* __GTKGUIUI_UTIL_H__ */
+/* gui_utils.h
+ * Definitions for UI utility routines
+ *
+ * $Id$
+ *
+ * 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 __GTKGUIUI_UTIL_H__
+#define __GTKGUIUI_UTIL_H__
+
+/** @defgroup windows_group Windows
+ *
+ * There are the following toplevel windows:
+ *
+ * - @ref main_window_group
+ * - Statistic Windows (several different statistic windows)
+ *
+ * See: @ref howto_window_page for details.
+ *
+ */
+
+/** @page howto_window_page How to develop a window / dialog
+ *
+ * Windows and dialogs are related to each other. Dialogs are special kind of windows, but they behave
+ * slightly different. Dialogs stick on it's parent window, normal windows will be much more independant
+ * from it's parent window. Dialogs should be used to ask or note the user something, while windows should
+ * show data independantly from the main window.
+ * Dialogs are created by calling dlg_window_new() which in turn will call window_new().
+ * After that, dialogs can be developed the same way as windows, all window related functions in gui_utils.h
+ * can be used for both.
+ *
+ * @section window_create Create a window
+ *
+ * A typical window / dialog will be created by the following calls:
+ *
+ * - window_new() will create a new window with default position and size,
+ * use dlg_window_new() if you need a dialog (transient to the main window)
+ * - gtk_window_set_default_size() to set the default size of the window. Only
+ * needed, if the initial size is not appropriate, e.g. when a scrolled_window_new() is used.
+ * Be sure that the given size is larger than the initial size, otherwise the window might
+ * clip the content (at least on GTK1)
+ * - SIGNAL_CONNECT(my_win, "destroy", my_destroy_cb, NULL) callback, if some cleanup needs to be
+ * done after the window is destroyed, e.g. free up memory, or set the window pointer
+ * of a singleton window (only one instance allowed, e.g. about dialog) back to zero
+ * - create and fill in the content and button widgets
+ * - gtk_widget_show_all() shows all the widgets in the window
+ * - window_present() present the window on screen and
+ * (if available) set previously saved position and size
+ *
+ * @section window_events Events
+ *
+ * The following events are usually interesting:
+ *
+ * - "delete_event": the window managers "X" (e.g. upper right edge) of the window
+ * was clicked, default handler will call gtk_widget_destroy()
+ * - "destroy": everything is already gone, only cleanup of left over ressources
+ * can/should be done now
+ *
+ * @section window_hints Hints
+ *
+ * If you want to save size and position, be sure to call window_destroy() instead of only
+ * gtk_widget_destroy(), so you will probably have to SIGNAL_CONNECT to the "delete_event"!
+ *
+ * Don't use WIDGET_SET_SIZE() to set the size of a window,
+ * use gtk_window_set_default_size() for that purpose!
+ *
+ * Be sure to call window_present() / window_destroy() appropriately, if you
+ * want to have size and position of the window handled by ui_util.
+ *
+ */
+
+/** @file
+ * Utilities for Windows and other user interface functions. See: @ref howto_window_page for details.
+ * @ingroup dialog_group
+ * @ingroup windows_group
+ */
+
+/** @name Window Functions
+ * @todo Move these window functions to a new file win_utils.h?
+ * @{ */
+
+/** Create a new window with the Ethereal icon.
+ * If you want to create a dialog, use dlg_window_new() instead.
+ *
+ * @param type window type, typical GTK_WINDOW_TOPLEVEL
+ * @param title the title for the new window
+ * @return the newly created window
+ */
+extern GtkWidget *window_new(GtkWindowType type, const gchar *title);
+
+/** Same as window_new(), but will keep its geometry values (size, position, ...).
+ * Be sure to use window_present() and window_destroy() appropriately!
+ *
+ * @param type window type, typical GTK_WINDOW_TOPLEVEL
+ * @param title the title for the new window
+ * @param geom_name the name to distinguish this window, will also be used for the recent file (don't use special chars)
+ * @return the newly created window
+ */
+extern GtkWidget *window_new_with_geom(GtkWindowType type, const gchar *title, const gchar *geom_name);
+
+/** Create a new splash window, with no icon or title bar.
+ *
+ * @return the newly created window
+ */
+extern GtkWidget *splash_window_new(void);
+
+/** Present the created window on the top of the screen. This will put the window on top and
+ * (if available) set previously saved position and size.
+ *
+ * @param win the window from window_new()
+ */
+extern void window_present(GtkWidget *win);
+
+/** callback function for window_set_cancel_button() */
+typedef void (*window_cancel_button_fct) (GtkWidget *w, gpointer data);
+
+/** Register the default cancel button "Cancel"/"Close"/"Ok" of this window.
+ * This will set the callback function for this button, grab this button as the default one and
+ * set the "ESC" key handler to call the callback function if key is pressed.
+ *
+ * @param win the window from window_new()
+ * @param bt the default button of this window
+ * @param cb callback function to be called, when this button is pressed
+ */
+extern void window_set_cancel_button(GtkWidget *win, GtkWidget *bt, window_cancel_button_fct cb);
+
+/** Remember the current window position / size and then destroy the window.
+ * It's important to call this instead of gtk_widget_destroy() when using window_new_with_geom().
+ *
+ * @param win the window from window_new()
+ */
+extern void window_destroy(GtkWidget *win);
+
+/** Default callback handler for cancel button "clicked" signal.
+ * Use this for window_set_cancel_button(), if no user specific functionality required,
+ * will simply call window_destroy()
+ */
+extern void window_cancel_button_cb(GtkWidget *w _U_, gpointer data);
+
+/** Default callback handler if the window managers X of the window was clicked (delete_event).
+ * Use this for SIGNAL_CONNECT(), if no user specific functionality required,
+ * will simply call window_destroy()
+ */
+extern gboolean window_delete_event_cb(GtkWidget *win, GdkEvent *event _U_, gpointer user_data _U_);
+
+/** geometry values for use in window_get_geometry() and window_set_geometry() */
+typedef struct window_geometry_s {
+ gchar *key; /**< current key in hashtable (internally used only) */
+ gboolean set_pos; /**< set the x and y position values */
+ gint x; /**< the windows x position */
+ gint y; /**< the windows y position */
+ gboolean set_size; /**< set the width and height values */
+ gint width; /**< the windows width */
+ gint height; /**< the windows height */
+
+ gboolean set_maximized; /**< set the maximized state (GTK2 only) */
+ gboolean maximized; /**< the windows maximized state (GTK2 only) */
+} window_geometry_t;
+
+/** Get the geometry of a window.
+ *
+ * @param win the window from window_new()
+ * @param geom the current geometry values of the window, the set_xy values will not be used
+ * @todo if main uses the window_new_with_geom() to save size and such, make this function static
+ */
+extern void window_get_geometry(GtkWidget *win, window_geometry_t *geom);
+/** Set the geometry of a window.
+ *
+ * @param win the window from window_new()
+ * @param geom the new geometry values of the window
+ * @todo if main uses the window_new_with_geom() to save size and such, make this function static
+ */
+extern void window_set_geometry(GtkWidget *win, window_geometry_t *geom);
+
+/** Write all geometry values of all windows to the recent file.
+ * Will call write_recent_geom() for every existing window type.
+ *
+ * @param rf recent file handle from caller
+ */
+extern void window_geom_recent_write_all(gpointer rf);
+
+/** Read in a single geometry key value pair from the recent file.
+ *
+ * @param name the geom_name of the window
+ * @param key the subkey of this pair (e.g. "x")
+ * @param value the new value (e.g. "123")
+ */
+extern void window_geom_recent_read_pair(const char *name, const char *key, const char *value);
+
+/** Raise a top-level window and de-iconify it.
+ * This routine is used if the user has done something to
+ * ask that a window of a certain type be popped up when there can be only
+ * one such window and such a window has already been popped up - we
+ * pop up the existing one rather than creating a new one.
+ *
+ * @param win the window from window_new() to be reactivated
+ */
+extern void reactivate_window(GtkWidget *win);
+
+/** @} */
+
+/** Create a GtkScrolledWindow, set its scrollbar placement appropriately,
+ * and remember it.
+ *
+ * @param hadjustment horizontal adjustment
+ * @param vadjustment vertical adjustment
+ * @return the new scrolled window
+ */
+extern GtkWidget *scrolled_window_new(GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment);
+
+/** Set the scrollbar placement of all scrolled windows based on user
+ preference. */
+extern void set_scrollbar_placement_all(void);
+
+#if GTK_MAJOR_VERSION < 2
+/** Create a GtkCTree, give it the right styles, and remember it.
+ *
+ * @param columns the number of columns
+ * @param tree_column which column has the tree graphic
+ * @return the newly created GtkCTree
+ */
+extern GtkWidget *ctree_new(gint columns, gint tree_column);
+/** Create a GtkCTree, give it the right styles, and remember it.
+ *
+ * @param columns the number of columns
+ * @param tree_column which column has the tree graphic
+ * @param titles the titles of all columns
+ * @return the newly created GtkCTree
+ */
+extern GtkWidget *ctree_new_with_titles(gint columns, gint tree_column,
+ const gchar *titles[]);
+#else
+/** Create a GtkTreeView, give it the right styles, and remember it.
+ *
+ * @param model the model (the data) of this tree view
+ */
+extern GtkWidget *tree_view_new(GtkTreeModel *model);
+#endif
+
+/** Create a simple list widget.
+ *
+ * @param cols number of columns
+ * @param titles the titles of all columns
+ * @return the new simple list widget
+ */
+extern GtkWidget *simple_list_new(gint cols, const gchar **titles);
+/** Append a row to the simple list.
+ *
+ * @param list the list from simple_list_new()
+ * @param ... row and title, finished by -1 (e.g.: 0, "first", 1, "second", -1).
+ */
+extern void simple_list_append(GtkWidget *list, ...);
+
+
+
+/** Set the styles of all Trees based upon user preferences. */
+extern void set_tree_styles_all(void);
+
+/** Convert an xpm picture into a GtkWidget showing it.
+ * Beware: Ethereal's main window must already be visible!
+ *
+ * @param xpm the character array containing the picture
+ * @return a newly created GtkWidget showing the picture
+ */
+extern GtkWidget *xpm_to_widget(const char ** xpm);
+
+/** Convert an xpm picture into a GtkWidget showing it.
+ * Beware: the given parent window must already be visible!
+ *
+ * @param parent the parent window of to widget to be generated
+ * @param xpm the character array containing the picture
+ * @return a newly created GtkWidget showing the picture
+ */
+extern GtkWidget *xpm_to_widget_from_parent(GtkWidget *parent, const char ** xpm);
+
+/** Copy a GString to the clipboard.
+ *
+ * @param str GString that is to be copied to the clipboard.
+ */
+extern void copy_to_clipboard(GString *str);
+
+/** Create a new window title that includes user-defined preference string.
+ *
+ * @param caption string you want included in title (appended to user-defined string)
+ * @return a newly created title string including user-defined preference (if specified)
+ */
+extern gchar *create_user_window_title(const gchar *caption);
+
+
+#endif /* __GTKGUIUI_UTIL_H__ */
diff --git a/gtk/main.h b/gtk/main.h
index b0056adc6d..68e9c8d599 100644
--- a/gtk/main.h
+++ b/gtk/main.h
@@ -51,6 +51,8 @@
@enddot
*/
+extern GString *comp_info_str, *runtime_info_str;
+
/** @file
* The main window, filter toolbar, program start/stop and a lot of other things
* @ingroup main_window_group
diff --git a/gtk/menu.h b/gtk/menu.h
index b4c0cc3c28..06e51a3a61 100644
--- a/gtk/menu.h
+++ b/gtk/menu.h
@@ -29,6 +29,8 @@
extern "C" {
#endif /* __cplusplus */
+extern void add_menu_recent_capture_file(gchar *cf_name);
+
/** @file
* Menubar and context menus.
* @ingroup main_window_group
diff --git a/gtk/mgcp_stat.c b/gtk/mgcp_stat.c
index 9b24356f9a..634a5a5ce9 100644
--- a/gtk/mgcp_stat.c
+++ b/gtk/mgcp_stat.c
@@ -257,7 +257,7 @@ static const gchar *titles[]={
"Min in Frame",
"Max in Frame" };
-void
+static void
gtk_mgcpstat_init(const char *optarg)
{
mgcpstat_t *ms;
diff --git a/gtk/mtp3_summary.c b/gtk/mtp3_summary.c
index 55e061cfc3..bde41d3003 100644
--- a/gtk/mtp3_summary.c
+++ b/gtk/mtp3_summary.c
@@ -229,7 +229,7 @@ mtp3_sum_draw(
}
-void
+static void
mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_)
{
summary_tally summary;
diff --git a/gtk/plugins_dlg.c b/gtk/plugins_dlg.c
index f7015f4e98..e3e21cc270 100644
--- a/gtk/plugins_dlg.c
+++ b/gtk/plugins_dlg.c
@@ -33,6 +33,7 @@
#include "dlg_utils.h"
#include "gui_utils.h"
#include "compat_macros.h"
+#include "plugins_dlg.h"
#ifdef HAVE_PLUGINS
@@ -105,7 +106,7 @@ about_plugins_page_new(void)
return scrolledwindow;
}
-void
+static void
tools_plugins_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
{
GtkWidget *main_vbox;
diff --git a/gtk/plugins_dlg.h b/gtk/plugins_dlg.h
new file mode 100644
index 0000000000..63851b014d
--- /dev/null
+++ b/gtk/plugins_dlg.h
@@ -0,0 +1,38 @@
+/* plugins_dlg.h
+ * Plugins definitions
+ *
+ * $Id$
+ *
+ * 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 __GTKGUIPLUGINS_H__
+#define __GTKGUIPLUGINS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+GtkWidget * about_plugins_page_new(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __GTKGUIPLUGINS_H__ */
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 69d5ee5539..09b659b2b3 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -361,7 +361,7 @@ module_prefs_show(module_t *module, gpointer user_data)
#endif
/* add a page to the tree */
-prefs_tree_iter
+static prefs_tree_iter
prefs_tree_page_add(const gchar *title, gint page_nr,
gpointer store, prefs_tree_iter *parent_iter,
gboolean has_child
@@ -388,7 +388,7 @@ prefs_tree_page_add(const gchar *title, gint page_nr,
}
/* add a page to the notebook */
-GtkWidget *
+static GtkWidget *
prefs_nb_page_add(GtkWidget *notebook, const gchar *title, GtkWidget *page, const char *page_key)
{
GtkWidget *frame;
diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c
index 1992dc3081..61caec2883 100644
--- a/gtk/print_dlg.c
+++ b/gtk/print_dlg.c
@@ -113,7 +113,7 @@ static print_args_t print_args;
static gboolean print_prefs_init = FALSE;
-void
+static void
file_print_cmd(gboolean print_selected)
{
print_args_t *args = &print_args;
diff --git a/gtk/proto_dlg.c b/gtk/proto_dlg.c
index 2772168a0e..b795dcbfbc 100644
--- a/gtk/proto_dlg.c
+++ b/gtk/proto_dlg.c
@@ -518,7 +518,7 @@ revert_proto_selection(void)
} /* revert_proto_selection */
-gint
+static gint
protocol_data_compare(gconstpointer a, gconstpointer b)
{
const protocol_data_t *ap = (const protocol_data_t *)a;
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index 7427b73674..bc5632da63 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -804,7 +804,7 @@ savehex_dlg_destroy_cb(void)
savehex_dlg = NULL;
}
-extern void
+void
copy_hex_cb(GtkWidget * w _U_, gpointer data _U_)
{
GtkWidget *bv;
@@ -1603,7 +1603,7 @@ set_ptree_font_all(FONT_TYPE *font)
#if GTK_MAJOR_VERSION >= 2
-void tree_cell_renderer(GtkTreeViewColumn *tree_column _U_,
+static void tree_cell_renderer(GtkTreeViewColumn *tree_column _U_,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
@@ -1826,7 +1826,7 @@ main_proto_tree_draw(proto_tree *protocol_tree)
}
-void
+static void
tree_view_follow_link(field_info *fi)
{
if(fi->hfinfo->type == FT_FRAMENUM) {
diff --git a/gtk/proto_hier_stats_dlg.c b/gtk/proto_hier_stats_dlg.c
index 3f9f3f4769..b0d157bf6c 100644
--- a/gtk/proto_hier_stats_dlg.c
+++ b/gtk/proto_hier_stats_dlg.c
@@ -309,7 +309,7 @@ create_tree(GtkWidget *container, ph_stats_t *ps)
gtk_container_add(GTK_CONTAINER(sw), tree);
}
-void
+static void
proto_hier_stats_cb(GtkWidget *w _U_, gpointer d _U_)
{
ph_stats_t *ps;
diff --git a/gtk/range_utils.c b/gtk/range_utils.c
index 19ea06cb97..d0e4110514 100644
--- a/gtk/range_utils.c
+++ b/gtk/range_utils.c
@@ -37,6 +37,7 @@
#include "dlg_utils.h"
#include "compat_macros.h"
#include "simple_dialog.h"
+#include "range_utils.h"
#define RANGE_VALUES_KEY "range_values"
diff --git a/gtk/recent.c b/gtk/recent.c
index c51ea5d118..c5a955dc55 100644
--- a/gtk/recent.c
+++ b/gtk/recent.c
@@ -66,10 +66,6 @@
#define RECENT_FILE_NAME "recent"
-
-/* #include "../menu.h" */
-extern void add_menu_recent_capture_file(gchar *file);
-
recent_settings_t recent;
static const char *ts_type_text[] =
diff --git a/gtk/rpc_progs.c b/gtk/rpc_progs.c
index a69fa8053f..f64c2c12e5 100644
--- a/gtk/rpc_progs.c
+++ b/gtk/rpc_progs.c
@@ -331,7 +331,7 @@ win_destroy_cb(void *dummy _U_, gpointer data _U_)
/* When called, this function will start rpcprogs
*/
-void
+static void
gtk_rpcprogs_init(const char *optarg _U_)
{
char *title_string;
diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c
index be4f2763e8..02321d0540 100644
--- a/gtk/rtp_analysis.c
+++ b/gtk/rtp_analysis.c
@@ -3146,7 +3146,7 @@ column_arrows* add_sort_by_column(GtkWidget* window, GtkWidget* clist,
/****************************************************************************/
/* Create the dialog box with all widgets */
-void create_rtp_dialog(user_data_t* user_data)
+static void create_rtp_dialog(user_data_t* user_data)
{
GtkWidget *window = NULL;
GtkWidget *clist_fwd;
@@ -3501,7 +3501,7 @@ void rtp_analysis(
/****************************************************************************/
/* entry point from main menu */
-void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
+static void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
{
address ip_src_fwd;
guint16 port_src_fwd;
diff --git a/gtk/rtp_stream.c b/gtk/rtp_stream.c
index d85cf9a2f1..a598adb2f4 100644
--- a/gtk/rtp_stream.c
+++ b/gtk/rtp_stream.c
@@ -63,7 +63,7 @@ static rtpstream_tapinfo_t the_tapinfo_struct =
/****************************************************************************/
/* GCompareFunc style comparison function for _rtp_stream_info */
-gint rtp_stream_info_cmp(gconstpointer aa, gconstpointer bb)
+static gint rtp_stream_info_cmp(gconstpointer aa, gconstpointer bb)
{
const struct _rtp_stream_info* a = aa;
const struct _rtp_stream_info* b = bb;
@@ -115,7 +115,7 @@ static void rtpstream_reset_cb(void *arg)
/****************************************************************************/
/* redraw the output */
-void rtpstream_draw(void *arg _U_)
+static void rtpstream_draw(void *arg _U_)
{
/* XXX: see rtpstream_on_update in rtp_streams_dlg.c for comments
gtk_signal_emit_by_name(top_level, "signal_rtpstream_update");
diff --git a/gtk/rtp_stream_dlg.c b/gtk/rtp_stream_dlg.c
index 7ba93641cc..adfc3f128d 100644
--- a/gtk/rtp_stream_dlg.c
+++ b/gtk/rtp_stream_dlg.c
@@ -213,7 +213,7 @@ rtpstream_on_unselect (GtkButton *button _U_,
/****************************************************************************/
-gint rtp_stream_info_cmp_reverse(gconstpointer aa, gconstpointer bb)
+static gint rtp_stream_info_cmp_reverse(gconstpointer aa, gconstpointer bb)
{
const struct _rtp_stream_info* a = aa;
const struct _rtp_stream_info* b = bb;
@@ -866,7 +866,7 @@ void rtpstream_dlg_show(GList *list)
/****************************************************************************/
/* entry point when called via the GTK menu */
-void rtpstream_launch(GtkWidget *w _U_, gpointer data _U_)
+static void rtpstream_launch(GtkWidget *w _U_, gpointer data _U_)
{
/* Register the tap listener */
register_tap_listener_rtp_stream();
diff --git a/gtk/sctp_assoc_analyse.c b/gtk/sctp_assoc_analyse.c
index 6354a14edb..40bba3d243 100644
--- a/gtk/sctp_assoc_analyse.c
+++ b/gtk/sctp_assoc_analyse.c
@@ -354,7 +354,7 @@ static void analyse_window_set_title(struct sctp_analyse *u_data)
g_free(title);
}
-void create_analyse_window(struct sctp_analyse* u_data)
+static void create_analyse_window(struct sctp_analyse* u_data)
{
GtkWidget *window = NULL;
GtkWidget *notebook;
@@ -698,7 +698,7 @@ void assoc_analyse(sctp_assoc_info_t* assoc)
}
-void sctp_analyse_cb(struct sctp_analyse* u_data)
+static void sctp_analyse_cb(struct sctp_analyse* u_data)
{
guint8* ip_src;
guint16 srcport;
diff --git a/gtk/sctp_byte_graph_dlg.c b/gtk/sctp_byte_graph_dlg.c
index 4802014b3b..52baa680cb 100644
--- a/gtk/sctp_byte_graph_dlg.c
+++ b/gtk/sctp_byte_graph_dlg.c
@@ -113,7 +113,7 @@ static void sctp_graph_set_title(struct sctp_udata *u_data);
static void create_draw_area(GtkWidget *box, struct sctp_udata *u_data);
-gint tsn_cmp(gconstpointer aa, gconstpointer bb)
+static gint tsn_cmp(gconstpointer aa, gconstpointer bb)
{
const struct tsn_sort* a = aa;
const struct tsn_sort* b = bb;
@@ -1082,7 +1082,7 @@ static void create_draw_area(GtkWidget *box, struct sctp_udata *u_data)
gtk_box_pack_start(GTK_BOX(box), u_data->io->draw_area, TRUE, TRUE, 0);
}
-void insertion(GPtrArray *array, guint32 N)
+static void insertion(GPtrArray *array, guint32 N)
{
guint32 i, j;
guint32 v;
@@ -1103,7 +1103,7 @@ void insertion(GPtrArray *array, guint32 N)
}
}
-void set_arw_offsets(struct sctp_udata *u_data)
+static void set_arw_offsets(struct sctp_udata *u_data)
{
GPtrArray *s_array=NULL, *t_array=NULL;
guint32 i, j=0;
@@ -1146,7 +1146,7 @@ void set_arw_offsets(struct sctp_udata *u_data)
}
}
-void compute_offsets(struct sctp_udata *u_data)
+static void compute_offsets(struct sctp_udata *u_data)
{
struct tsn_sort t_sort;
GPtrArray *array=NULL;
diff --git a/gtk/sctp_chunk_stat.c b/gtk/sctp_chunk_stat.c
index e81871446c..0006515097 100644
--- a/gtk/sctp_chunk_stat.c
+++ b/gtk/sctp_chunk_stat.c
@@ -130,7 +130,7 @@ sctpstat_reset(void *phs)
sctp_stat->number_of_packets = 0;
}
-sctp_ep_t* alloc_sctp_ep(struct _sctp_info *si)
+static sctp_ep_t* alloc_sctp_ep(struct _sctp_info *si)
{
sctp_ep_t* ep;
guint16 chunk_type;
diff --git a/gtk/sctp_chunk_stat_dlg.c b/gtk/sctp_chunk_stat_dlg.c
index e5e330fca6..80c47494f4 100644
--- a/gtk/sctp_chunk_stat_dlg.c
+++ b/gtk/sctp_chunk_stat_dlg.c
@@ -48,7 +48,6 @@ static GtkWidget *sctp_chunk_stat_dlg=NULL;
static GtkWidget *clist = NULL;
static GList *last_list = NULL;
static sctp_assoc_info_t* selected_stream = NULL; /* current selection */
-extern GtkWidget *main_display_filter_widget;
#define NUM_COLS 14
#define FRAME_LIMIT 8
@@ -68,7 +67,7 @@ enum chunk_types {
COOKIE_ACK = 11
};
-const char *chunk_name(int type)
+static const char *chunk_name(int type)
{
#define CASE(x) case x: s=#x; break
const char *s = "unknown";
@@ -343,7 +342,7 @@ static void chunk_window_set_title(struct sctp_udata *u_data)
g_free(title);
}
-void sctp_chunk_dlg(struct sctp_udata *u_data)
+static void sctp_chunk_dlg(struct sctp_udata *u_data)
{
GtkWidget *main_vb, *table;
GtkWidget *label, *h_button_box;
diff --git a/gtk/sctp_error_dlg.c b/gtk/sctp_error_dlg.c
index 91211cd1c2..6f72eab3da 100644
--- a/gtk/sctp_error_dlg.c
+++ b/gtk/sctp_error_dlg.c
@@ -46,8 +46,6 @@ static GtkWidget *clist = NULL;
static GList *last_list = NULL;
static sctp_error_info_t* selected_packet = NULL;/* current selection */
/*static sctp_assoc_info_t* selected_assoc = NULL; */
-extern GtkWidget *main_display_filter_widget;
-
#define NUM_COLS 3
@@ -91,7 +89,7 @@ sctp_error_on_unselect(GtkButton *button _U_, gpointer user_data _U_)
gtk_clist_unselect_all(GTK_CLIST(clist));
}
-void sctp_error_dlg_update(GList *list)
+static void sctp_error_dlg_update(GList *list)
{
GList *ilist=NULL;
diff --git a/gtk/sctp_stat.c b/gtk/sctp_stat.c
index 1203c7536d..048c5b70ac 100644
--- a/gtk/sctp_stat.c
+++ b/gtk/sctp_stat.c
@@ -139,7 +139,7 @@ void free_first(gpointer data, gpointer user_data _U_)
g_free(data);
}
-void tsn_free(gpointer data, gpointer user_data _U_)
+static void tsn_free(gpointer data, gpointer user_data _U_)
{
tsn_t *tsn;
@@ -293,7 +293,7 @@ static sctp_assoc_info_t *calc_checksum(struct _sctp_info *check_data, sctp_asso
}
-gint sctp_assoc_vtag_cmp(gconstpointer aa, gconstpointer bb)
+static gint sctp_assoc_vtag_cmp(gconstpointer aa, gconstpointer bb)
{
const struct _sctp_assoc_info* a = aa;
@@ -349,7 +349,7 @@ gint sctp_assoc_vtag_cmp(gconstpointer aa, gconstpointer bb)
}
-gint sctp_assoc_address_cmp(gconstpointer aa, gconstpointer bb)
+static gint sctp_assoc_address_cmp(gconstpointer aa, gconstpointer bb)
{
GList *srclist, *dstlist;
const struct _sctp_tmp_info* a = aa;
@@ -578,7 +578,7 @@ gint sctp_assoc_address_cmp(gconstpointer aa, gconstpointer bb)
-sctp_assoc_info_t * find_assoc(sctp_tmp_info_t * needle)
+static sctp_assoc_info_t * find_assoc(sctp_tmp_info_t * needle)
{
sctp_allassocs_info_t *assoc_info;
sctp_assoc_info_t *info = NULL;
@@ -656,7 +656,7 @@ sctp_assoc_info_t * find_assoc(sctp_tmp_info_t * needle)
return NULL;
}
-sctp_assoc_info_t * add_chunk_count(address * vadd, sctp_assoc_info_t * info, guint32 direction, guint32 type)
+static sctp_assoc_info_t * add_chunk_count(address * vadd, sctp_assoc_info_t * info, guint32 direction, guint32 type)
{
GList *list;
address *v=NULL;
@@ -701,7 +701,7 @@ sctp_assoc_info_t * add_chunk_count(address * vadd, sctp_assoc_info_t * info, gu
return info;
}
-sctp_assoc_info_t * add_address(address * vadd, sctp_assoc_info_t *info, guint8 direction)
+static sctp_assoc_info_t * add_address(address * vadd, sctp_assoc_info_t *info, guint8 direction)
{
GList *list;
address *v=NULL;
diff --git a/gtk/sctp_stat_dlg.c b/gtk/sctp_stat_dlg.c
index e497855569..1591a88d13 100644
--- a/gtk/sctp_stat_dlg.c
+++ b/gtk/sctp_stat_dlg.c
@@ -42,6 +42,7 @@
#include "compat_macros.h"
#include "sctp_stat.h"
+#include "gtkglobals.h"
static GtkWidget *sctp_stat_dlg=NULL;
@@ -49,7 +50,6 @@ static GtkWidget *clist = NULL;
static GList *last_list = NULL;
static gchar *filter_string = NULL;
static sctp_assoc_info_t* selected_stream = NULL; /* current selection */
-extern GtkWidget *main_display_filter_widget;
static sctp_allassocs_info_t *sctp_assocs=NULL;
static guint16 n_children=0;
static GtkWidget *bt_afilter = NULL, *bt_unselect=NULL, *bt_analyse=NULL, *bt_filter=NULL;
@@ -568,7 +568,7 @@ gtk_sctpstat_dlg(void)
}
-void sctp_stat_dlg_show(void)
+static void sctp_stat_dlg_show(void)
{
if (sctp_stat_dlg != NULL)
{
@@ -587,7 +587,7 @@ void sctp_stat_dlg_show(void)
}
-void sctp_stat_start(GtkWidget *w _U_, gpointer data _U_)
+static void sctp_stat_start(GtkWidget *w _U_, gpointer data _U_)
{
sctp_assocs = g_malloc(sizeof(sctp_allassocs_info_t));
diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c
index 11c5f98bad..a414c51135 100644
--- a/gtk/tcp_graph.c
+++ b/gtk/tcp_graph.c
@@ -494,7 +494,7 @@ static char helptext[] =
";
#endif
-void tcp_graph_cb (GtkWidget *w _U_, gpointer data, guint callback_action /*graph_type*/ _U_)
+static void tcp_graph_cb (GtkWidget *w _U_, gpointer data, guint callback_action /*graph_type*/ _U_)
{
struct segment current;
struct graph *g;
@@ -4041,7 +4041,7 @@ static int rint (double x)
#endif
-gboolean tcp_graph_selected_packet_enabled(frame_data *current_frame, epan_dissect_t *edt)
+static gboolean tcp_graph_selected_packet_enabled(frame_data *current_frame, epan_dissect_t *edt)
{
return current_frame != NULL ? (edt->pi.ipproto == IP_PROTO_TCP) : FALSE;
}
diff --git a/gtk/toolbar.h b/gtk/toolbar.h
index 5efac3e634..ba51487b51 100644
--- a/gtk/toolbar.h
+++ b/gtk/toolbar.h
@@ -26,6 +26,8 @@
#ifndef __TOOLBAR_H__
#define __TOOLBAR_H__
+gboolean is_capture_in_progress(void);
+
/** @file
* The main toolbar.
* @ingroup main_window_group
diff --git a/gtk/voip_calls.c b/gtk/voip_calls.c
index ebb32e67af..5b255b5318 100644
--- a/gtk/voip_calls.c
+++ b/gtk/voip_calls.c
@@ -190,7 +190,7 @@ void graph_analysis_data_init(void){
/****************************************************************************/
/* Add a new item into the graph */
-int add_to_graph(voip_calls_tapinfo_t *tapinfo _U_, packet_info *pinfo, const gchar *frame_label, gchar *comment, guint16 call_num, address *src_addr, address *dst_addr)
+static int add_to_graph(voip_calls_tapinfo_t *tapinfo _U_, packet_info *pinfo, const gchar *frame_label, gchar *comment, guint16 call_num, address *src_addr, address *dst_addr)
{
graph_analysis_item_t *gai;
@@ -224,7 +224,7 @@ int add_to_graph(voip_calls_tapinfo_t *tapinfo _U_, packet_info *pinfo, const gc
/****************************************************************************/
/* Append str to frame_label and comment in a graph item */
/* return 0 if the frame_num is not in the graph list */
-int append_to_frame_graph(voip_calls_tapinfo_t *tapinfo _U_, guint32 frame_num, const gchar *new_frame_label, const gchar *new_comment)
+static int append_to_frame_graph(voip_calls_tapinfo_t *tapinfo _U_, guint32 frame_num, const gchar *new_frame_label, const gchar *new_comment)
{
graph_analysis_item_t *gai;
GList* list;
@@ -261,7 +261,7 @@ int append_to_frame_graph(voip_calls_tapinfo_t *tapinfo _U_, guint32 frame_num,
/****************************************************************************/
/* Change the frame_label and comment in a graph item if not NULL*/
/* return 0 if the frame_num is not in the graph list */
-int change_frame_graph(voip_calls_tapinfo_t *tapinfo _U_, guint32 frame_num, const gchar *new_frame_label, const gchar *new_comment)
+static int change_frame_graph(voip_calls_tapinfo_t *tapinfo _U_, guint32 frame_num, const gchar *new_frame_label, const gchar *new_comment)
{
graph_analysis_item_t *gai;
GList* list;
@@ -296,7 +296,7 @@ int change_frame_graph(voip_calls_tapinfo_t *tapinfo _U_, guint32 frame_num, con
/****************************************************************************/
/* Change all the graph items with call_num to new_call_num */
-guint change_call_num_graph(voip_calls_tapinfo_t *tapinfo _U_, guint16 call_num, guint16 new_call_num)
+static guint change_call_num_graph(voip_calls_tapinfo_t *tapinfo _U_, guint16 call_num, guint16 new_call_num)
{
graph_analysis_item_t *gai;
GList* list;
@@ -404,7 +404,7 @@ remove_tap_listener_rtp_event(void)
/****************************************************************************/
/* when there is a [re]reading of RTP packet's */
-void voip_rtp_reset(void *ptr _U_)
+static void voip_rtp_reset(void *ptr _U_)
{
voip_rtp_tapinfo_t *tapinfo = &the_tapinfo_rtp_struct;
GList* list;
@@ -500,7 +500,7 @@ RTP_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const vo
/****************************************************************************/
/* whenever a redraw in the RTP tap listener */
-void RTP_packet_draw(void *prs _U_)
+static void RTP_packet_draw(void *prs _U_)
{
voip_rtp_tapinfo_t *rtp_tapinfo = &the_tapinfo_rtp_struct;
GList* rtp_streams_list;
@@ -1429,7 +1429,7 @@ remove_tap_listener_q931_calls(void)
/****************************TAP for H323 ***********************************/
/****************************************************************************/
-void add_h245_Address(h323_calls_info_t *h323info, h245_address_t *h245_address)
+static void add_h245_Address(h323_calls_info_t *h323info, h245_address_t *h245_address)
{
h323info->h245_list = g_list_append(h323info->h245_list, h245_address);
}
@@ -1725,7 +1725,7 @@ void h245_add_to_graph(guint32 new_frame_num)
}
/* free the h245_labels if the frame number is different */
-void h245_free_labels(guint32 new_frame_num)
+static void h245_free_labels(guint32 new_frame_num)
{
gint8 n;
@@ -1742,7 +1742,7 @@ void h245_free_labels(guint32 new_frame_num)
}
/* add the frame_label and comment to h245_labels and free the actual one if it is different frame num */
-void h245_add_label(guint32 new_frame_num, gchar *frame_label, gchar *comment)
+static void h245_add_label(guint32 new_frame_num, gchar *frame_label, gchar *comment)
{
h245_free_labels(new_frame_num);
@@ -1960,7 +1960,7 @@ remove_tap_listener_sdp_calls(void)
This function will look for a signal/event in the SignalReq/ObsEvent string
and return true if it is found
*/
-gboolean isSignal(const gchar *signal, const gchar *signalStr)
+static gboolean isSignal(const gchar *signal, const gchar *signalStr)
{
gint i;
gchar **resultArray;
@@ -1988,7 +1988,7 @@ gboolean isSignal(const gchar *signal, const gchar *signalStr)
This function will get the Caller ID info and replace the current string
This is how it looks the caller Id: rg, ci(02/16/08/29, "3035550002","Ale Sipura 2")
*/
-void mgcpCallerID(gchar *signalStr, gchar **callerId)
+static void mgcpCallerID(gchar *signalStr, gchar **callerId)
{
gchar **arrayStr;
@@ -2015,7 +2015,7 @@ void mgcpCallerID(gchar *signalStr, gchar **callerId)
This function will get the Dialed Digits and replace the current string
This is how it looks the dialed digits 5,5,5,0,0,0,2,#,*
*/
-void mgcpDialedDigits(gchar *signalStr, gchar **dialedDigits)
+static void mgcpDialedDigits(gchar *signalStr, gchar **dialedDigits)
{
gchar *tmpStr;
gchar resultStr[50];
diff --git a/gtk/voip_calls_dlg.c b/gtk/voip_calls_dlg.c
index f05496bb67..4e1a970a3e 100644
--- a/gtk/voip_calls_dlg.c
+++ b/gtk/voip_calls_dlg.c
@@ -179,7 +179,7 @@ static void add_to_clist(voip_calls_info_t* strinfo)
}
-void voip_calls_remove_tap_listener(void)
+static void voip_calls_remove_tap_listener(void)
{
/* Remove the calls tap listener */
remove_tap_listener_sip_calls();
@@ -801,7 +801,7 @@ voip_calls_init_tap(const char *dummy _U_)
/****************************************************************************/
/* entry point when called via the GTK menu */
-void voip_calls_launch(GtkWidget *w _U_, gpointer data _U_)
+static void voip_calls_launch(GtkWidget *w _U_, gpointer data _U_)
{
voip_calls_init_tap("");
}