diff options
author | gram <gram@f5534014-38df-0310-8fa8-9805f1628bb7> | 1998-12-17 05:42:33 +0000 |
---|---|---|
committer | gram <gram@f5534014-38df-0310-8fa8-9805f1628bb7> | 1998-12-17 05:42:33 +0000 |
commit | ac9fe64a3b04ee9333446ed2de17754ae9638065 (patch) | |
tree | c7a1862fa9f17082e0a5b4adc6b86abe34808761 | |
parent | 634c12c34c6a7f0700c8af26be3afe62801739b2 (diff) |
A patch spread across many files to let Ethereal compile under GTK+-1.1.x.
Tests for GTK versions are done during compilation, not during "./configure".
The big problems have been taken care of in this patch (functional change
in the packet clist and conversion of menu_factory to item_factory), but
plenty of smaller problems with dialogue boxes abound. I have fixed
a small problem with file_open*(), but have left 2 comments in just in case
I'm not going about this the right way. Can someone verify?
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@127 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | capture.c | 3 | ||||
-rw-r--r-- | column.c | 3 | ||||
-rw-r--r-- | ethereal.c | 49 | ||||
-rw-r--r-- | ethereal.h | 16 | ||||
-rw-r--r-- | file.c | 14 | ||||
-rw-r--r-- | filter.c | 3 | ||||
-rw-r--r-- | follow.c | 4 | ||||
-rw-r--r-- | menu.c | 123 | ||||
-rw-r--r-- | menu.h | 10 | ||||
-rw-r--r-- | packet-lpd.c | 3 | ||||
-rw-r--r-- | prefs.c | 3 | ||||
-rw-r--r-- | resolv.c | 3 | ||||
-rw-r--r-- | wiretap/ChangeLog | 3 |
13 files changed, 203 insertions, 34 deletions
@@ -1,7 +1,7 @@ /* capture.c * Routines for packet capture windows * - * $Id: capture.c,v 1.12 1998/11/18 03:17:17 gerald Exp $ + * $Id: capture.c,v 1.13 1998/12/17 05:42:19 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -35,6 +35,7 @@ #include <gtk/gtk.h> #include <pcap.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> @@ -1,7 +1,7 @@ /* column.c * Routines for handling column preferences * - * $Id: column.c,v 1.4 1998/12/16 09:05:51 guy Exp $ + * $Id: column.c,v 1.5 1998/12/17 05:42:20 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -33,6 +33,7 @@ #include <gtk/gtk.h> +#include <stdio.h> #include <ctype.h> #include <errno.h> #include <unistd.h> diff --git a/ethereal.c b/ethereal.c index 30f76133cd..906a6a3b8e 100644 --- a/ethereal.c +++ b/ethereal.c @@ -1,6 +1,6 @@ /* ethereal.c * - * $Id: ethereal.c,v 1.14 1998/11/18 03:17:16 gerald Exp $ + * $Id: ethereal.c,v 1.15 1998/12/17 05:42:21 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -46,6 +46,7 @@ #include <gtk/gtk.h> #include <pcap.h> /* needed for capture.h */ +#include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> @@ -104,14 +105,20 @@ void file_sel_ok_cb(GtkWidget *w, GtkFileSelection *fs) { gchar *cf_name; int err; - GtkWidget *filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY); + GtkWidget *filter_te = NULL; + + /* Gilbert --- I added this if statement. Is this right? */ + if (w) + filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY); cf_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION (fs))); gtk_widget_hide(GTK_WIDGET (fs)); gtk_widget_destroy(GTK_WIDGET (fs)); - if (cf.dfilter) g_free(cf.dfilter); - cf.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te))); + if (w && cf.dfilter) { + g_free(cf.dfilter); + cf.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te))); + } if ((err = load_cap_file(cf_name, &cf)) == 0) chdir(cf_name); g_free(cf_name); @@ -227,6 +234,9 @@ file_open_cmd_cb(GtkWidget *w, gpointer data) { pointer to the filter entry */ gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_sel)->ok_button), "clicked", (GtkSignalFunc) file_sel_ok_cb, file_sel ); + + /* Gilbert --- I added this if statement. Is this right? */ + if (w) gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(file_sel)->ok_button), E_DFILTER_TE_KEY, gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY)); @@ -244,8 +254,13 @@ file_open_cmd_cb(GtkWidget *w, gpointer data) { void file_close_cmd_cb(GtkWidget *widget, gpointer data) { close_cap_file(&cf, info_bar, file_ctx); +#ifdef USE_ITEM + set_menu_sensitivity("/File/Close", FALSE); + set_menu_sensitivity("/File/Reload", FALSE); +#else set_menu_sensitivity("<Main>/File/Close", FALSE); set_menu_sensitivity("<Main>/File/Reload", FALSE); +#endif } /* Reload a file using the current display filter */ @@ -373,7 +388,15 @@ main(int argc, char *argv[]) *bv_table, *bv_hscroll, *bv_vscroll, *stat_hbox, *tv_scrollw, *filter_bt, *filter_te; GtkStyle *pl_style; +#ifdef GTK_HAVE_FEATURES_1_1_0 + GtkAccelGroup *accel; +#else GtkAcceleratorTable *accel; +#endif + +#ifdef GTK_HAVE_FEATURES_1_1_4 + GtkWidget *packet_sw; +#endif gint pl_size = 280, tv_size = 95, bv_size = 75; gchar *rc_file, *cf_name = NULL; gchar *medium_font = MONO_MEDIUM_FONT; @@ -523,7 +546,11 @@ main(int argc, char *argv[]) /* Menu bar */ get_main_menu(&menubar, &accel); +#ifdef GTK_HAVE_FEATURES_1_1_0 + gtk_window_add_accel_group(GTK_WINDOW(window), accel); +#else gtk_window_add_accelerator_table(GTK_WINDOW(window), accel); +#endif gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show(menubar); @@ -540,6 +567,11 @@ main(int argc, char *argv[]) /* Packet list */ packet_list = gtk_clist_new_with_titles(cf.cinfo.num_cols, col_title); gtk_clist_column_titles_passive(GTK_CLIST(packet_list)); +#ifdef GTK_HAVE_FEATURES_1_1_4 + packet_sw = gtk_scrolled_window_new(NULL, NULL); + gtk_widget_show(packet_sw); + gtk_container_add(GTK_CONTAINER(packet_sw), packet_list); +#endif pl_style = gtk_style_new(); gdk_font_unref(pl_style->font); pl_style->font = m_r_font; @@ -557,7 +589,11 @@ main(int argc, char *argv[]) GTK_JUSTIFY_RIGHT); } gtk_widget_set_usize(packet_list, -1, pl_size); +#ifdef GTK_HAVE_FEATURES_1_1_4 + gtk_paned_add1(GTK_PANED(u_pane), packet_sw); +#else gtk_paned_add1(GTK_PANED(u_pane), packet_list); +#endif gtk_widget_show(packet_list); /* Tree view */ @@ -569,7 +605,12 @@ main(int argc, char *argv[]) gtk_widget_show(tv_scrollw); tree_view = gtk_tree_new(); +#ifdef GTK_HAVE_FEATURES_1_1_0 + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tv_scrollw), + tree_view); +#else gtk_container_add(GTK_CONTAINER(tv_scrollw), tree_view); +#endif gtk_tree_set_selection_mode(GTK_TREE(tree_view), GTK_SELECTION_SINGLE); gtk_tree_set_view_lines(GTK_TREE(tree_view), FALSE); gtk_tree_set_view_mode(GTK_TREE(tree_view), TRUE); diff --git a/ethereal.h b/ethereal.h index fd7e0eb64e..009b5dff50 100644 --- a/ethereal.h +++ b/ethereal.h @@ -1,7 +1,7 @@ /* ethereal.h * Global defines, etc. * - * $Id: ethereal.h,v 1.8 1998/11/17 04:28:45 gerald Exp $ + * $Id: ethereal.h,v 1.9 1998/12/17 05:42:22 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -66,6 +66,20 @@ #ifndef MIN #define MIN(x, y) ((x) < (y) ? (x) : (y)) #endif + +/* Determine whether we use menu factories or item factories. This + * code snippet is taken from cheops.h of cheops-0.57, a GPL'ed + * network utility program Copyright (C) 1998, Mark Spencer + */ +#if (GTK_MINOR_VERSION > 1) || ((GTK_MICRO_VERSION > 1) && (GTK_MINOR_VERSION > 0)) + #define USE_ITEM + #define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a)) +#else + #undef USE_ITEM + typedef void (*_GTK_MENU_FUNC_T)(GtkWidget *, void *); + #define GTK_MENU_FUNC(a) ((_GTK_MENU_FUNC_T)(a)) +#endif + typedef struct _selection_info { GtkWidget *tree; @@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.13 1998/11/17 04:28:46 gerald Exp $ + * $Id: file.c,v 1.14 1998/12/17 05:42:23 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -56,8 +56,8 @@ # include <netinet/in.h> #endif -#include "menu.h" #include "ethereal.h" +#include "menu.h" #include "packet.h" #include "file.h" #include "util.h" @@ -294,16 +294,26 @@ load_cap_file(char *fname, capture_file *cf) { g_free(load_msg); name_ptr[-1] = '\0'; +#ifdef USE_ITEM + set_menu_sensitivity("/File/Close", TRUE); + set_menu_sensitivity("/File/Reload", TRUE); +#else set_menu_sensitivity("<Main>/File/Close", TRUE); set_menu_sensitivity("<Main>/File/Reload", TRUE); +#endif } else { msg_len = strlen(name_ptr) + strlen(err_fmt) + 2; load_msg = g_realloc(load_msg, msg_len); snprintf(load_msg, msg_len, err_fmt, name_ptr); gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, load_msg); g_free(load_msg); +#ifdef USE_ITEM set_menu_sensitivity("<Main>/File/Close", FALSE); set_menu_sensitivity("<Main>/File/Reload", FALSE); +#else + set_menu_sensitivity("<Main>/File/Close", FALSE); + set_menu_sensitivity("<Main>/File/Reload", FALSE); +#endif } return err; @@ -1,7 +1,7 @@ /* filter.c * Routines for managing filter sets * - * $Id: filter.c,v 1.9 1998/11/17 04:28:48 gerald Exp $ + * $Id: filter.c,v 1.10 1998/12/17 05:42:24 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -29,6 +29,7 @@ #include <gtk/gtk.h> +#include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> @@ -1,6 +1,6 @@ /* follow.c * - * $Id: follow.c,v 1.4 1998/10/28 01:29:16 guy Exp $ + * $Id: follow.c,v 1.5 1998/12/17 05:42:25 gram Exp $ * * Copyright 1998 Mike Hall <mlh@io.com> * @@ -30,6 +30,8 @@ #endif #include <gtk/gtk.h> +#include <stdlib.h> +#include <stdio.h> #include <string.h> #include <unistd.h> @@ -1,7 +1,7 @@ /* menu.c * Menu routines * - * $Id: menu.c,v 1.10 1998/11/12 00:06:22 gram Exp $ + * $Id: menu.c,v 1.11 1998/12/17 05:42:26 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -34,8 +34,8 @@ #include <strings.h> -#include "menu.h" #include "ethereal.h" +#include "menu.h" #include "capture.h" #include "packet.h" #include "prefs.h" @@ -43,9 +43,10 @@ #include "follow.h" /* Much of this was take from the GTK+ tuturial at http://www.gtk.org */ - +#ifndef USE_ITEM static void menus_remove_accel (GtkWidget *, gchar *, gchar *); static gint menus_install_accel (GtkWidget *, gchar *, gchar, gchar, gchar *); +#endif /* this is the GtkMenuEntry structure used to create new menus. The * first member is the menu definition string. The second, the @@ -54,7 +55,36 @@ static gint menus_install_accel (GtkWidget *, gchar *, gchar, gchar, gchar *); * this menu item is selected (by the accelerator key, or with the * mouse.) The last member is the data to pass to your callback function. */ - +#ifdef USE_ITEM +GtkAccelGroup *grp; +static GtkItemFactoryEntry menu_items[] = +{ + {"/_File", NULL, NULL, 0, "<Branch>" }, + {"/File/_Open", "<control>O", GTK_MENU_FUNC(file_open_cmd_cb), 0, NULL}, + {"/File/_Close", "<control>W", GTK_MENU_FUNC(file_close_cmd_cb), 0, NULL}, + {"/File/_Save", "<control>S", NULL, 0, NULL}, + {"/File/Save _as", NULL, NULL, 0, NULL}, + {"/File/_Reload", "<control>R", GTK_MENU_FUNC(file_reload_cmd_cb), 0, NULL}, + {"/File/<separator>", NULL, NULL, 0, "<Separator>"}, + {"/File/_Print Packet", "<control>P", GTK_MENU_FUNC(file_print_cmd_cb), 0, NULL}, + {"/File/<separator>", NULL, NULL, 0, "<Separator>"}, + {"/File/_Quit", "<control>Q", GTK_MENU_FUNC(file_quit_cmd_cb), 0, NULL}, + {"/_Edit", NULL, NULL, 0, "<Branch>" }, + {"/Edit/Cut", "<control>X", NULL, 0, NULL}, + {"/Edit/Copy", "<control>C", NULL, 0, NULL}, + {"/Edit/Paste", "<control>V", NULL, 0, NULL}, + {"/Edit/<separator>", NULL, NULL, 0, "<Separator>"}, + {"/Edit/Find", "<control>F", NULL, 0, NULL}, + {"/Edit/<separator>", NULL, NULL, 0, "<Separator>"}, + {"/Edit/_Preferences", NULL, GTK_MENU_FUNC(prefs_cb), E_PR_PG_NONE, NULL}, + {"/_Tools", NULL, NULL, 0, "<Branch>" }, + {"/Tools/_Capture", "<control>K", GTK_MENU_FUNC(capture_prep_cb), 0, NULL}, + {"/Tools/_Follow TCP Stream", NULL, GTK_MENU_FUNC(follow_stream_cb), 0, NULL}, + {"/Tools/Graph", NULL, NULL, 0, NULL}, + {"/_Help", NULL, NULL, 0, "<Branch>" }, + {"/Help/_About Ethereal", NULL, GTK_MENU_FUNC(about_ethereal), 0, NULL} +}; +#else static GtkMenuEntry menu_items[] = { {"<Main>/File/Open", "<control>O", file_open_cmd_cb, NULL}, @@ -78,33 +108,77 @@ static GtkMenuEntry menu_items[] = {"<Main>/Tools/Graph", NULL, NULL, NULL}, {"<Main>/Help/About Ethereal", NULL, about_ethereal, NULL} }; +#endif /* calculate the number of menu_items */ static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]); static int initialize = TRUE; +#ifdef USE_ITEM +static GtkItemFactory *factory = NULL; +#else static GtkMenuFactory *factory = NULL; static GtkMenuFactory *subfactory[1]; static GHashTable *entry_ht = NULL; +#endif void +#ifdef GTK_HAVE_FEATURES_1_1_0 +get_main_menu(GtkWidget ** menubar, GtkAccelGroup ** table) { +#else get_main_menu(GtkWidget ** menubar, GtkAcceleratorTable ** table) { +#endif + +#ifdef USE_ITEM + grp = gtk_accel_group_new(); +#endif + if (initialize) menus_init(); +#ifdef USE_ITEM + if (menubar) + *menubar = factory->widget; +#else if (menubar) *menubar = subfactory[0]->widget; +#endif + if (table) +#ifdef USE_ITEM + *table = grp; +#else +#ifdef GTK_HAVE_FEATURES_1_1_0 + *table = subfactory[0]->accel_group; +#else *table = subfactory[0]->table; +#endif /* GTK 1.1.0 */ +#endif /* USE_ITEM */ } void menus_init(void) { +#ifndef USE_ITEM GtkMenuPath *mp; +#endif if (initialize) { initialize = FALSE; +#ifdef USE_ITEM + factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp); + gtk_item_factory_create_items(factory, nmenu_items, menu_items, NULL); + set_menu_sensitivity("/File/Close", FALSE); + set_menu_sensitivity("/File/Save", FALSE); + set_menu_sensitivity("/File/Save as", FALSE); + set_menu_sensitivity("/File/Reload", FALSE); + set_menu_sensitivity("/Edit/Cut", FALSE); + set_menu_sensitivity("/Edit/Copy", FALSE); + set_menu_sensitivity("/Edit/Paste", FALSE); + set_menu_sensitivity("/Edit/Find", FALSE); + set_menu_sensitivity("/Tools/Graph", FALSE); + +#else factory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR); subfactory[0] = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR); @@ -123,25 +197,45 @@ menus_init(void) { if ((mp = gtk_menu_factory_find(factory, "<Main>/Help")) != NULL) { gtk_menu_item_right_justify((GtkMenuItem *) mp->widget); } +#endif } } void set_menu_sensitivity (gchar *path, gint val) { +#ifdef USE_ITEM + GtkWidget *menu; +#else GtkMenuPath *mp; - +#endif + +#ifdef USE_ITEM + if ((menu = gtk_item_factory_get_widget(factory, path)) != NULL) + gtk_widget_set_sensitive(menu, val); +#else if ((mp = gtk_menu_factory_find(factory, path)) != NULL) gtk_widget_set_sensitive(mp->widget, val); +#endif } void set_menu_object_data (gchar *path, gchar *key, gpointer data) { +#ifdef USE_ITEM + GtkWidget *menu; +#else GtkMenuPath *mp; +#endif +#ifdef USE_ITEM + if ((menu = gtk_item_factory_get_widget(factory, path)) != NULL) + gtk_object_set_data(GTK_OBJECT(menu), key, data); +#else if ((mp = gtk_menu_factory_find(factory, path)) != NULL) gtk_object_set_data(GTK_OBJECT(mp->widget), key, data); +#endif } +#ifndef USE_ITEM void menus_create(GtkMenuEntry * entries, int nmenu_entries) { char *accelerator; @@ -164,8 +258,13 @@ menus_create(GtkMenuEntry * entries, int nmenu_entries) { for (i = 0; i < nmenu_entries; i++) if (entries[i].widget) { +#ifdef GTK_HAVE_FEATURES_1_1_0 + gtk_signal_connect(GTK_OBJECT(entries[i].widget), "add_accelerator", + (GtkSignalFunc) menus_install_accel, entries[i].path); +#else gtk_signal_connect(GTK_OBJECT(entries[i].widget), "install_accelerator", (GtkSignalFunc) menus_install_accel, entries[i].path); +#endif gtk_signal_connect(GTK_OBJECT(entries[i].widget), "remove_accelerator", (GtkSignalFunc) menus_remove_accel, entries[i].path); } @@ -210,17 +309,5 @@ menus_remove_accel(GtkWidget * widget, gchar * signal_name, gchar * path) { g_hash_table_insert(entry_ht, path, g_strdup("")); } } +#endif -void -menus_set_sensitive(char *path, int sensitive) { - GtkMenuPath *menu_path; - - if (initialize) - menus_init(); - - menu_path = gtk_menu_factory_find(factory, path); - if (menu_path) - gtk_widget_set_sensitive(menu_path->widget, sensitive); - else - g_warning("Unable to set sensitivity for menu which doesn't exist: %s", path); -} @@ -1,7 +1,7 @@ /* menu.h * Menu definitions * - * $Id: menu.h,v 1.3 1998/10/12 01:40:51 gerald Exp $ + * $Id: menu.h,v 1.4 1998/12/17 05:42:27 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -30,8 +30,14 @@ extern "C" { #endif /* __cplusplus */ -void menus_init (void); + +void menus_init(void); + +#ifdef GTK_HAVE_FEATURES_1_1_0 +void get_main_menu (GtkWidget **, GtkAccelGroup **); +#else void get_main_menu (GtkWidget **, GtkAcceleratorTable **); +#endif void set_menu_sensitivity (gchar *, gint); void set_menu_object_data (gchar *path, gchar *key, gpointer data); void menus_create (GtkMenuEntry *, int); diff --git a/packet-lpd.c b/packet-lpd.c index 49a2f4439a..afd4a9c354 100644 --- a/packet-lpd.c +++ b/packet-lpd.c @@ -2,7 +2,7 @@ * Routines for LPR and LPRng packet disassembly * Gilbert Ramirez <gram@verdict.uthscsa.edu> * - * $Id: packet-lpd.c,v 1.5 1998/11/17 04:28:57 gerald Exp $ + * $Id: packet-lpd.c,v 1.6 1998/12/17 05:42:28 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@unicom.net> @@ -30,6 +30,7 @@ #include <gtk/gtk.h> +#include <stdlib.h> #include <stdio.h> #include <string.h> @@ -1,7 +1,7 @@ /* prefs.c * Routines for handling preferences * - * $Id: prefs.c,v 1.12 1998/11/18 03:17:18 gerald Exp $ + * $Id: prefs.c,v 1.13 1998/12/17 05:42:29 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -33,6 +33,7 @@ #include <gtk/gtk.h> +#include <stdlib.h> #include <ctype.h> #include <errno.h> #include <unistd.h> @@ -1,7 +1,7 @@ /* resolv.c * Routines for network object lookup * - * $Id: resolv.c,v 1.4 1998/09/27 22:12:45 gerald Exp $ + * $Id: resolv.c,v 1.5 1998/12/17 05:42:32 gram Exp $ * * Laurent Deniel <deniel@worldnet.fr> * @@ -35,6 +35,7 @@ #include <gtk/gtk.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> diff --git a/wiretap/ChangeLog b/wiretap/ChangeLog index e69de29bb2..12ac9307c6 100644 --- a/wiretap/ChangeLog +++ b/wiretap/ChangeLog @@ -0,0 +1,3 @@ + +December 10, 1998 + Proper timestamp calculations added to ngsniffer.c and lanalyzer.c |