diff options
author | Olivier Abad <oabad@noos.fr> | 2002-09-21 11:36:30 +0000 |
---|---|---|
committer | Olivier Abad <oabad@noos.fr> | 2002-09-21 11:36:30 +0000 |
commit | d72aca0b7ec946e137da3d04418ea6f4a4dc77d8 (patch) | |
tree | 0662da2707b2b10450d3dd11b484e2887c32ab10 | |
parent | 820af9e2f22e0a84417fde57b7ef1d4c537a8a19 (diff) |
Removed all gtk calls in file.c :
- created a few packet_list_xxx functions (ui_util.h gtk/packet_list.c
gtk2/packet_list.c) ;
- removed almost all "gtk/xxx" and "gtk2/xxx" includes in file.c
The only remaining includes are related to color filters. We have to
make color_filter_t GUI independent by replacing GdkColor with color_t.
I'll work on this later.
svn path=/trunk/; revision=6311
-rw-r--r-- | file.c | 148 | ||||
-rw-r--r-- | gtk/Makefile.am | 3 | ||||
-rw-r--r-- | gtk/packet_list.c | 153 | ||||
-rw-r--r-- | gtk/packet_win.h | 5 | ||||
-rw-r--r-- | gtk/proto_draw.c | 14 | ||||
-rw-r--r-- | gtk/proto_draw.h | 4 | ||||
-rw-r--r-- | gtk/ui_util.c | 3 | ||||
-rw-r--r-- | gtk2/Makefile.am | 3 | ||||
-rw-r--r-- | gtk2/packet_list.c | 153 | ||||
-rw-r--r-- | gtk2/packet_win.h | 5 | ||||
-rw-r--r-- | gtk2/proto_draw.c | 18 | ||||
-rw-r--r-- | gtk2/proto_draw.h | 6 | ||||
-rw-r--r-- | gtk2/ui_util.c | 3 | ||||
-rw-r--r-- | ui_util.h | 29 |
14 files changed, 422 insertions, 125 deletions
@@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.289 2002/09/04 22:15:39 sahlberg Exp $ + * $Id: file.c,v 1.290 2002/09/21 11:36:25 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -63,11 +63,6 @@ #include <epan/epan.h> #include <epan/filesystem.h> -#if GTK_MAJOR_VERSION == 1 -#include "gtk/main.h" -#else -#include "gtk2/main.h" -#endif #include "color.h" #if GTK_MAJOR_VERSION == 1 #include "gtk/color_utils.h" @@ -85,13 +80,6 @@ #include "ui_util.h" #include "statusbar.h" #include "prefs.h" -#if GTK_MAJOR_VERSION == 1 -#include "gtk/proto_draw.h" -#include "gtk/packet_win.h" -#else -#include "gtk2/proto_draw.h" -#include "gtk2/packet_win.h" -#endif #include <epan/dfilter/dfilter.h> #include <epan/conversation.h> #include "globals.h" @@ -103,8 +91,6 @@ #include <epan/epan_dissect.h> #include "tap.h" -extern GtkWidget *packet_list, *byte_nb_ptr, *tree_view; - #ifdef HAVE_LIBPCAP gboolean auto_scroll_live; #endif @@ -117,10 +103,8 @@ static void read_packet(capture_file *cf, long offset); static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean refilter, gboolean redissect); -static void set_selected_row(int row); - -static void freeze_clist(capture_file *cf); -static void thaw_clist(capture_file *cf); +static void freeze_plist(capture_file *cf); +static void thaw_plist(capture_file *cf); static char *file_rename_error_message(int err); static char *file_close_error_message(int err); @@ -252,9 +236,9 @@ close_cap_file(capture_file *cf) cf->last_displayed = NULL; /* Clear the packet list. */ - gtk_clist_freeze(GTK_CLIST(packet_list)); - gtk_clist_clear(GTK_CLIST(packet_list)); - gtk_clist_thaw(GTK_CLIST(packet_list)); + packet_list_freeze(); + packet_list_clear(); + packet_list_thaw(); /* Clear any file-related status bar messages. XXX - should be "clear *ALL* file-related status bar messages; @@ -359,7 +343,7 @@ read_cap_file(capture_file *cf, int *err) #define O_BINARY 0 #endif - freeze_clist(cf); + freeze_plist(cf); stop_flag = FALSE; g_get_current_time(&start_time); @@ -409,7 +393,7 @@ read_cap_file(capture_file *cf, int *err) can do whatever is appropriate when that happens. */ destroy_progress_dlg(progbar); cf->state = FILE_READ_ABORTED; /* so that we're allowed to close it */ - gtk_clist_thaw(GTK_CLIST(packet_list)); /* undo our freeze */ + packet_list_thaw(); /* undo our freeze */ close_cap_file(cf); return (READ_ABORTED); } @@ -439,7 +423,7 @@ read_cap_file(capture_file *cf, int *err) cf->lnk_t = wtap_file_encap(cf->wth); cf->current_frame = cf->first_displayed; - thaw_clist(cf); + thaw_plist(cf); statusbar_pop_file_msg(); set_display_filename(cf); @@ -455,7 +439,7 @@ read_cap_file(capture_file *cf, int *err) /* If we have any displayed packets to select, select the first of those packets by making the first row the selected row. */ if (cf->first_displayed != NULL) - gtk_signal_emit_by_name(GTK_OBJECT(packet_list), "select_row", 0); + packet_list_select_row(0); if (*err != 0) { /* Put up a message box noting that the read failed somewhere along @@ -514,12 +498,11 @@ start_tail_cap_file(char *fname, gboolean is_tempfile, capture_file *cf) for (i = 0; i < cf->cinfo.num_cols; i++) { if (get_column_resize_type(cf->cinfo.col_fmt[i]) == RESIZE_LIVE) - gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, TRUE); + packet_list_set_column_auto_resize(i, TRUE); else { - gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, FALSE); - gtk_clist_set_column_width(GTK_CLIST(packet_list), i, - cf->cinfo.col_width[i]); - gtk_clist_set_column_resizeable(GTK_CLIST(packet_list), i, TRUE); + packet_list_set_column_auto_resize(i, FALSE); + packet_list_set_column_width(i, cf->cinfo.col_width[i]); + packet_list_set_column_resizeable(i, TRUE); } } @@ -533,7 +516,7 @@ continue_tail_cap_file(capture_file *cf, int to_read, int *err) { long data_offset = 0; - gtk_clist_freeze(GTK_CLIST(packet_list)); + packet_list_freeze(); while (to_read != 0 && (wtap_read(cf->wth, err, &data_offset))) { if (cf->state == FILE_READ_ABORTED) { @@ -546,13 +529,12 @@ continue_tail_cap_file(capture_file *cf, int to_read, int *err) to_read--; } - gtk_clist_thaw(GTK_CLIST(packet_list)); + packet_list_thaw(); /* XXX - this cheats and looks inside the packet list to find the final row number. */ if (auto_scroll_live && cf->plist_end != NULL) - gtk_clist_moveto(GTK_CLIST(packet_list), - GTK_CLIST(packet_list)->rows - 1, -1, 1.0, 1.0); + packet_list_moveto_end(); if (cf->state == FILE_READ_ABORTED) { /* Well, the user decided to exit Ethereal. Return READ_ABORTED @@ -574,7 +556,7 @@ finish_tail_cap_file(capture_file *cf, int *err) { long data_offset; - gtk_clist_freeze(GTK_CLIST(packet_list)); + packet_list_freeze(); while ((wtap_read(cf->wth, err, &data_offset))) { if (cf->state == FILE_READ_ABORTED) { @@ -596,12 +578,11 @@ finish_tail_cap_file(capture_file *cf, int *err) return READ_ABORTED; } - thaw_clist(cf); + thaw_plist(cf); if (auto_scroll_live && cf->plist_end != NULL) /* XXX - this cheats and looks inside the packet list to find the final row number. */ - gtk_clist_moveto(GTK_CLIST(packet_list), - GTK_CLIST(packet_list)->rows - 1, -1, 1.0, 1.0); + packet_list_moveto_end(); /* We're done reading sequentially through the file. */ cf->state = FILE_READ_DONE; @@ -789,21 +770,17 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, /* This is the last frame we've seen so far. */ cf->last_displayed = fdata; - row = gtk_clist_append(GTK_CLIST(packet_list), cf->cinfo.col_data); - gtk_clist_set_row_data(GTK_CLIST(packet_list), row, fdata); + row = packet_list_append(cf->cinfo.col_data, fdata); if (fdata->flags.marked) { color_t_to_gdkcolor(&bg, &prefs.gui_marked_bg); color_t_to_gdkcolor(&fg, &prefs.gui_marked_fg); + packet_list_set_colors(row, &bg, &fg); } else if (filter_list != NULL && (args.colorf != NULL)) { bg = args.colorf->bg_color; fg = args.colorf->fg_color; - } else { - bg = WHITE; - fg = BLACK; + packet_list_set_colors(row, &bg, &fg); } - gtk_clist_set_background(GTK_CLIST(packet_list), row, &bg); - gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &fg); } else { /* This frame didn't pass the display filter, so it's not being added to the clist, and thus has no row. */ @@ -984,10 +961,10 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, /* Freeze the packet list while we redo it, so we don't get any screen updates while it happens. */ - gtk_clist_freeze(GTK_CLIST(packet_list)); + packet_list_freeze(); /* Clear it out. */ - gtk_clist_clear(GTK_CLIST(packet_list)); + packet_list_clear(); /* We don't yet know which will be the first and last frames displayed. */ cf->first_displayed = NULL; @@ -1104,12 +1081,12 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, destroy_progress_dlg(progbar); /* Unfreeze the packet list. */ - gtk_clist_thaw(GTK_CLIST(packet_list)); + packet_list_thaw(); if (selected_row != -1) { /* The frame that was selected passed the filter; select it, make it the focus row, and make it visible. */ - set_selected_row(selected_row); + packet_list_set_selected_row(selected_row); finfo_selected = NULL; } else { /* The selected frame didn't pass the filter; make the first frame @@ -1345,7 +1322,6 @@ change_time_formats(capture_file *cf) int count; int row; int i; - GtkStyle *pl_style; float prog_val; GTimeVal start_time; gchar status_str[100]; @@ -1364,7 +1340,7 @@ change_time_formats(capture_file *cf) /* Freeze the packet list while we redo it, so we don't get any screen updates while it happens. */ - freeze_clist(cf); + freeze_plist(cf); /* Update the progress bar when it gets to this value. */ cf->progbar_nextstep = 0; @@ -1421,7 +1397,7 @@ change_time_formats(capture_file *cf) count++; /* Find what row this packet is in. */ - row = gtk_clist_find_row_from_data(GTK_CLIST(packet_list), fdata); + row = packet_list_find_row_from_data(fdata); if (row != -1) { /* This packet is in the summary list, on row "row". */ @@ -1432,8 +1408,7 @@ change_time_formats(capture_file *cf) "command-line-specified" format; update it. */ cf->cinfo.col_buf[i][0] = '\0'; col_set_cls_time(fdata, &cf->cinfo, i); - gtk_clist_set_text(GTK_CLIST(packet_list), row, i, - cf->cinfo.col_data[i]); + packet_list_set_text(row, i, cf->cinfo.col_data[i]); } } } @@ -1446,21 +1421,14 @@ change_time_formats(capture_file *cf) /* Set the column widths of those columns that show the time in "command-line-specified" format. */ - pl_style = gtk_widget_get_style(packet_list); for (i = 0; i < cf->cinfo.num_cols; i++) { if (cf->cinfo.fmt_matx[i][COL_CLS_TIME]) { - gtk_clist_set_column_width(GTK_CLIST(packet_list), i, -#if GTK_MAJOR_VERSION == 1 - gdk_string_width(pl_style->font, get_column_longest_string(COL_CLS_TIME))); -#else - gdk_string_width(gdk_font_from_description(pl_style->font_desc), - get_column_longest_string(COL_CLS_TIME))); -#endif + packet_list_set_cls_time_width(i); } } /* Unfreeze the packet list. */ - thaw_clist(cf); + thaw_plist(cf); } gboolean @@ -1579,11 +1547,11 @@ find_packet(capture_file *cf, dfilter_t *sfcode) if (new_fd != NULL) { /* We found a frame. Find what row it's in. */ - row = gtk_clist_find_row_from_data(GTK_CLIST(packet_list), new_fd); + row = packet_list_find_row_from_data(new_fd); g_assert(row != -1); /* Select that row, make it the focus row, and make it visible. */ - set_selected_row(row); + packet_list_set_selected_row(row); return TRUE; /* success */ } else return FALSE; /* failure */ @@ -1605,11 +1573,11 @@ goto_frame(capture_file *cf, guint fnumber) /* We found that frame, and it's currently being displayed. Find what row it's in. */ - row = gtk_clist_find_row_from_data(GTK_CLIST(packet_list), fdata); + row = packet_list_find_row_from_data(fdata); g_assert(row != -1); /* Select that row, make it the focus row, and make it visible. */ - set_selected_row(row); + packet_list_set_selected_row(row); return FOUND_FRAME; } @@ -1621,7 +1589,7 @@ select_packet(capture_file *cf, int row) int err; /* Get the frame data struct pointer for this frame */ - fdata = (frame_data *) gtk_clist_get_row_data(GTK_CLIST(packet_list), row); + fdata = (frame_data *)packet_list_get_row_data(row); if (fdata == NULL) { /* XXX - if a GtkCList's selection mode is GTK_SELECTION_BROWSE, when @@ -1675,8 +1643,8 @@ select_packet(capture_file *cf, int row) /* Display the GUI protocol tree and hex dump. XXX - why do we dump core if we call "proto_tree_draw()" before calling "add_byte_views()"? */ - add_byte_views(cf->edt, tree_view, byte_nb_ptr); - proto_tree_draw(cf->edt->tree, tree_view); + add_main_byte_views(cf->edt); + main_proto_tree_draw(cf->edt->tree); /* A packet is selected. */ set_menus_for_selected_packet(TRUE); @@ -1702,27 +1670,6 @@ unselect_packet(capture_file *cf) unselect_field(); } -/* Set the selected row and the focus row of the packet list to the specified - row, and make it visible if it's not currently visible. */ -static void -set_selected_row(int row) -{ - if (gtk_clist_row_is_visible(GTK_CLIST(packet_list), row) != GTK_VISIBILITY_FULL) - gtk_clist_moveto(GTK_CLIST(packet_list), row, -1, 0.0, 0.0); - - /* XXX - why is there no "gtk_clist_set_focus_row()", so that we - can make the row for the frame we found the focus row? - - See - - http://www.gnome.org/mailing-lists/archives/gtk-list/2000-January/0038.shtml - - */ - GTK_CLIST(packet_list)->focus_row = row; - - gtk_clist_select_row(GTK_CLIST(packet_list), row, -1); -} - /* Unset the selected protocol tree field, if any. */ void unselect_field(void) @@ -1753,7 +1700,7 @@ unmark_frame(capture_file *cf, frame_data *frame) } static void -freeze_clist(capture_file *cf) +freeze_plist(capture_file *cf) { int i; @@ -1761,33 +1708,32 @@ freeze_clist(capture_file *cf) we're reading the capture file (freezing the clist doesn't seem to suffice). */ for (i = 0; i < cf->cinfo.num_cols; i++) - gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, FALSE); - gtk_clist_freeze(GTK_CLIST(packet_list)); + packet_list_set_column_auto_resize(i, FALSE); + packet_list_freeze(); } static void -thaw_clist(capture_file *cf) +thaw_plist(capture_file *cf) { int i; for (i = 0; i < cf->cinfo.num_cols; i++) { if (get_column_resize_type(cf->cinfo.col_fmt[i]) == RESIZE_MANUAL) { /* Set this column's width to the appropriate value. */ - gtk_clist_set_column_width(GTK_CLIST(packet_list), i, - cf->cinfo.col_width[i]); + packet_list_set_column_width(i, cf->cinfo.col_width[i]); } else { /* Make this column's size dynamic, so that it adjusts to the appropriate size. */ - gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, TRUE); + packet_list_set_column_auto_resize(i, TRUE); } } - gtk_clist_thaw(GTK_CLIST(packet_list)); + packet_list_thaw(); /* Hopefully, the columns have now gotten their appropriate sizes; make them resizeable - a column that auto-resizes cannot be resized by the user, and *vice versa*. */ for (i = 0; i < cf->cinfo.num_cols; i++) - gtk_clist_set_column_resizeable(GTK_CLIST(packet_list), i, TRUE); + packet_list_set_column_resizeable(i, TRUE); } /* diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 49e40a1dbe..023c9e67c2 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for the GTK interface routines for Ethereal # -# $Id: Makefile.am,v 1.41 2002/09/07 10:02:24 sahlberg Exp $ +# $Id: Makefile.am,v 1.42 2002/09/21 11:36:27 oabad Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -72,6 +72,7 @@ libui_a_SOURCES = \ menu.h \ nameres_prefs.c \ nameres_prefs.h \ + packet_list.c \ packet_win.c \ packet_win.h \ plugins_dlg.c \ diff --git a/gtk/packet_list.c b/gtk/packet_list.c new file mode 100644 index 0000000000..5231ac93a5 --- /dev/null +++ b/gtk/packet_list.c @@ -0,0 +1,153 @@ +/* packet_list.c + * packet list related functions 2002 Olivier Abad + * + * $Id: packet_list.c,v 1.1 2002/09/21 11:36:27 oabad Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <gtk/gtk.h> + +#include "gtkglobals.h" +#include "epan/epan.h" +#include "../ui_util.h" +#include "column.h" +#include "epan/column_info.h" + +void +packet_list_clear(void) +{ + gtk_clist_clear(GTK_CLIST(packet_list)); +} + +void +packet_list_freeze(void) +{ + gtk_clist_freeze(GTK_CLIST(packet_list)); +} + +void +packet_list_thaw(void) +{ + gtk_clist_thaw(GTK_CLIST(packet_list)); +} + +void +packet_list_select_row(gint row) +{ + gtk_signal_emit_by_name(GTK_OBJECT(packet_list), "select_row", row); +} + +void +packet_list_set_column_auto_resize(gint column, gboolean auto_resize) +{ + gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), column, + auto_resize); +} + +void +packet_list_set_column_resizeable(gint column, gboolean resizeable) +{ + gtk_clist_set_column_resizeable(GTK_CLIST(packet_list), column, resizeable); +} + +void +packet_list_set_column_width(gint column, gint width) +{ + gtk_clist_set_column_width(GTK_CLIST(packet_list), column, width); +} + +void +packet_list_moveto_end(void) +{ + gtk_clist_moveto(GTK_CLIST(packet_list), + GTK_CLIST(packet_list)->rows - 1, -1, 1.0, 1.0); +} + +gint +packet_list_append(gchar *text[], gpointer data) +{ + gint row; + + row = gtk_clist_append(GTK_CLIST(packet_list), text); + gtk_clist_set_row_data(GTK_CLIST(packet_list), row, data); + return row; +} + +void +packet_list_set_colors(gint row, GdkColor *fg, GdkColor *bg) +{ + if (fg) gtk_clist_set_foreground(GTK_CLIST(packet_list), row, fg); + if (bg) gtk_clist_set_background(GTK_CLIST(packet_list), row, bg); +} + +gint +packet_list_find_row_from_data(gpointer data) +{ + return gtk_clist_find_row_from_data(GTK_CLIST(packet_list), data); +} + +void +packet_list_set_text(gint row, gint column, const gchar *text) +{ + gtk_clist_set_text(GTK_CLIST(packet_list), row, column, text); +} + +/* Set the column widths of those columns that show the time in + * "command-line-specified" format. */ +void +packet_list_set_cls_time_width(gint column) +{ + GtkStyle *pl_style; + gint width; + + pl_style = gtk_widget_get_style(packet_list); + width = gdk_string_width(pl_style->font, + get_column_longest_string(COL_CLS_TIME)); + packet_list_set_column_width(column, width); +} + +gpointer +packet_list_get_row_data(gint row) +{ + return gtk_clist_get_row_data(GTK_CLIST(packet_list), row); +} + +/* Set the selected row and the focus row of the packet list to the specified + * row, and make it visible if it's not currently visible. */ +void +packet_list_set_selected_row(gint row) +{ + if (gtk_clist_row_is_visible(GTK_CLIST(packet_list), row) != + GTK_VISIBILITY_FULL) + gtk_clist_moveto(GTK_CLIST(packet_list), row, -1, 0.0, 0.0); + + /* XXX - why is there no "gtk_clist_set_focus_row()", so that we + * can make the row for the frame we found the focus row? + * + * See http://www.gnome.org/mailing-lists/archives/gtk-list/2000-January/0038.shtml + */ + GTK_CLIST(packet_list)->focus_row = row; + + gtk_clist_select_row(GTK_CLIST(packet_list), row, -1); +} diff --git a/gtk/packet_win.h b/gtk/packet_win.h index 331ba89845..86797e2765 100644 --- a/gtk/packet_win.h +++ b/gtk/packet_win.h @@ -3,7 +3,7 @@ * * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet_win.h,v 1.8 2002/08/28 21:03:48 jmayer Exp $ + * $Id: packet_win.h,v 1.9 2002/09/21 11:36:27 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -30,9 +30,6 @@ /* Create a new packet window. */ extern void new_window_cb(GtkWidget *w); -/* Destroy all popup packet windows. */ -void destroy_packet_wins(void); - /* Redraw the hex dump panes of all packet windows. */ void redraw_hex_dump_packet_wins(void); diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c index d7424bf94f..3264826c92 100644 --- a/gtk/proto_draw.c +++ b/gtk/proto_draw.c @@ -1,7 +1,7 @@ /* proto_draw.c * Routines for GTK+ packet display * - * $Id: proto_draw.c,v 1.58 2002/09/05 18:47:47 jmayer Exp $ + * $Id: proto_draw.c,v 1.59 2002/09/21 11:36:27 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -514,6 +514,12 @@ add_byte_tab(GtkWidget *byte_nb, const char *name, tvbuff_t *tvb, } void +add_main_byte_views(epan_dissect_t *edt) +{ + add_byte_views(edt, tree_view, byte_nb_ptr); +} + +void add_byte_views(epan_dissect_t *edt, GtkWidget *tree_view, GtkWidget *byte_nb_ptr) { @@ -973,6 +979,12 @@ struct proto_tree_draw_info { }; void +main_proto_tree_draw(proto_tree *protocol_tree) +{ + proto_tree_draw(protocol_tree, tree_view); +} + +void proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view) { struct proto_tree_draw_info info; diff --git a/gtk/proto_draw.h b/gtk/proto_draw.h index 28c8414110..f9a70c4d2e 100644 --- a/gtk/proto_draw.h +++ b/gtk/proto_draw.h @@ -1,7 +1,7 @@ /* proto_draw.h * Definitions for GTK+ packet display structures and routines * - * $Id: proto_draw.h,v 1.19 2002/08/28 21:03:49 jmayer Exp $ + * $Id: proto_draw.h,v 1.20 2002/09/21 11:36:27 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -65,6 +65,4 @@ void collapse_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view); void set_ptree_sel_browse_all(gboolean); void set_ptree_font_all(GdkFont *font); -void clear_tree_and_hex_views(void); - #endif diff --git a/gtk/ui_util.c b/gtk/ui_util.c index a568996e0a..4d46a171f4 100644 --- a/gtk/ui_util.c +++ b/gtk/ui_util.c @@ -1,7 +1,7 @@ /* ui_util.c * UI utility routines * - * $Id: ui_util.c,v 1.11 2002/09/05 18:47:48 jmayer Exp $ + * $Id: ui_util.c,v 1.12 2002/09/21 11:36:27 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -31,6 +31,7 @@ #include "gtkglobals.h" #include "ui_util.h" #include "prefs.h" +#include "epan/epan.h" #include "../ui_util.h" #include "image/eicon3d16.xpm" diff --git a/gtk2/Makefile.am b/gtk2/Makefile.am index 540a21e8c6..d553a2a798 100644 --- a/gtk2/Makefile.am +++ b/gtk2/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for the GTK2 interface routines for Ethereal # -# $Id: Makefile.am,v 1.4 2002/09/07 09:28:05 sahlberg Exp $ +# $Id: Makefile.am,v 1.5 2002/09/21 11:36:30 oabad Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -70,6 +70,7 @@ libui_a_SOURCES = \ menu.h \ nameres_prefs.c \ nameres_prefs.h \ + packet_list.c \ packet_win.c \ packet_win.h \ plugins_dlg.c \ diff --git a/gtk2/packet_list.c b/gtk2/packet_list.c new file mode 100644 index 0000000000..7e3d7aeeb0 --- /dev/null +++ b/gtk2/packet_list.c @@ -0,0 +1,153 @@ +/* packet_list.c + * packet list related functions 2002 Olivier Abad + * + * $Id: packet_list.c,v 1.1 2002/09/21 11:36:30 oabad Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <gtk/gtk.h> + +#include "gtkglobals.h" +#include "epan/epan.h" +#include "../ui_util.h" +#include "column.h" +#include "epan/column_info.h" + +void +packet_list_clear(void) +{ + gtk_clist_clear(GTK_CLIST(packet_list)); +} + +void +packet_list_freeze(void) +{ + gtk_clist_freeze(GTK_CLIST(packet_list)); +} + +void +packet_list_thaw(void) +{ + gtk_clist_thaw(GTK_CLIST(packet_list)); +} + +void +packet_list_select_row(gint row) +{ + gtk_signal_emit_by_name(GTK_OBJECT(packet_list), "select_row", row); +} + +void +packet_list_set_column_auto_resize(gint column, gboolean auto_resize) +{ + gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), column, + auto_resize); +} + +void +packet_list_set_column_resizeable(gint column, gboolean resizeable) +{ + gtk_clist_set_column_resizeable(GTK_CLIST(packet_list), column, resizeable); +} + +void +packet_list_set_column_width(gint column, gint width) +{ + gtk_clist_set_column_width(GTK_CLIST(packet_list), column, width); +} + +void +packet_list_moveto_end(void) +{ + gtk_clist_moveto(GTK_CLIST(packet_list), + GTK_CLIST(packet_list)->rows - 1, -1, 1.0, 1.0); +} + +gint +packet_list_append(gchar *text[], gpointer data) +{ + gint row; + + row = gtk_clist_append(GTK_CLIST(packet_list), text); + gtk_clist_set_row_data(GTK_CLIST(packet_list), row, data); + return row; +} + +void +packet_list_set_colors(gint row, GdkColor *fg, GdkColor *bg) +{ + if (fg) gtk_clist_set_foreground(GTK_CLIST(packet_list), row, fg); + if (bg) gtk_clist_set_background(GTK_CLIST(packet_list), row, bg); +} + +gint +packet_list_find_row_from_data(gpointer data) +{ + return gtk_clist_find_row_from_data(GTK_CLIST(packet_list), data); +} + +void +packet_list_set_text(gint row, gint column, const gchar *text) +{ + gtk_clist_set_text(GTK_CLIST(packet_list), row, column, text); +} + +/* Set the column widths of those columns that show the time in + * "command-line-specified" format. */ +void +packet_list_set_cls_time_width(gint column) +{ + GtkStyle *pl_style; + gint width; + + pl_style = gtk_widget_get_style(packet_list); + width = gdk_string_width(gdk_font_from_description(pl_style->font_desc), + get_column_longest_string(COL_CLS_TIME)); + packet_list_set_column_width(column, width); +} + +gpointer +packet_list_get_row_data(gint row) +{ + return gtk_clist_get_row_data(GTK_CLIST(packet_list), row); +} + +/* Set the selected row and the focus row of the packet list to the specified + * row, and make it visible if it's not currently visible. */ +void +packet_list_set_selected_row(gint row) +{ + if (gtk_clist_row_is_visible(GTK_CLIST(packet_list), row) != + GTK_VISIBILITY_FULL) + gtk_clist_moveto(GTK_CLIST(packet_list), row, -1, 0.0, 0.0); + + /* XXX - why is there no "gtk_clist_set_focus_row()", so that we + * can make the row for the frame we found the focus row? + * + * See http://www.gnome.org/mailing-lists/archives/gtk-list/2000-January/0038.shtml + */ + GTK_CLIST(packet_list)->focus_row = row; + + gtk_clist_select_row(GTK_CLIST(packet_list), row, -1); +} diff --git a/gtk2/packet_win.h b/gtk2/packet_win.h index b3b15be1f8..89649aad7f 100644 --- a/gtk2/packet_win.h +++ b/gtk2/packet_win.h @@ -3,7 +3,7 @@ * * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet_win.h,v 1.1 2002/08/31 09:55:22 oabad Exp $ + * $Id: packet_win.h,v 1.2 2002/09/21 11:36:30 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -30,9 +30,6 @@ /* Create a new packet window. */ extern void new_window_cb(GtkWidget *w); -/* Destroy all popup packet windows. */ -void destroy_packet_wins(void); - /* Redraw the hex dump panes of all packet windows. */ void redraw_hex_dump_packet_wins(void); diff --git a/gtk2/proto_draw.c b/gtk2/proto_draw.c index e22e219d16..177c023c41 100644 --- a/gtk2/proto_draw.c +++ b/gtk2/proto_draw.c @@ -1,7 +1,7 @@ /* proto_draw.c * Routines for GTK+ packet display * - * $Id: proto_draw.c,v 1.3 2002/09/14 10:07:39 oabad Exp $ + * $Id: proto_draw.c,v 1.4 2002/09/21 11:36:30 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -554,8 +554,14 @@ add_byte_tab(GtkWidget *byte_nb, const char *name, tvbuff_t *tvb, } void +add_main_byte_views(epan_dissect_t *edt) +{ + add_byte_views(edt, tree_view, byte_nb_ptr); +} + +void add_byte_views(epan_dissect_t *edt, GtkWidget *tree_view, - GtkWidget *byte_nb_ptr) + GtkWidget *byte_nb_ptr) { GSList *src_le; data_source *src; @@ -573,7 +579,7 @@ add_byte_views(epan_dissect_t *edt, GtkWidget *tree_view, for (src_le = edt->pi.data_src; src_le != NULL; src_le = src_le->next) { src = src_le->data; add_byte_tab(byte_nb_ptr, src->name, src->tvb, edt->tree, - tree_view); + tree_view); } /* @@ -948,6 +954,12 @@ struct proto_tree_draw_info { }; void +main_proto_tree_draw(proto_tree *protocol_tree) +{ + proto_tree_draw(protocol_tree, tree_view); +} + +void proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view) { GtkTreeStore *store; diff --git a/gtk2/proto_draw.h b/gtk2/proto_draw.h index 3bab41ebef..5b37269adc 100644 --- a/gtk2/proto_draw.h +++ b/gtk2/proto_draw.h @@ -1,7 +1,7 @@ /* proto_draw.h * Definitions for GTK+ packet display structures and routines * - * $Id: proto_draw.h,v 1.1 2002/08/31 09:55:22 oabad Exp $ + * $Id: proto_draw.h,v 1.2 2002/09/21 11:36:30 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -50,7 +50,7 @@ extern void redraw_hex_dump_all(void); extern GtkWidget *create_byte_view(gint bv_size, GtkWidget *pane); extern void add_byte_views(epan_dissect_t *edt, GtkWidget *tree_view, - GtkWidget *byte_nb_ptr); + GtkWidget *byte_nb_ptr); void packet_hex_print(GtkTextView *, const guint8 *, frame_data *, field_info *, guint); @@ -65,6 +65,4 @@ void collapse_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view); void set_ptree_sel_browse_all(gboolean); void set_ptree_font_all(PangoFontDescription *font); -void clear_tree_and_hex_views(void); - #endif diff --git a/gtk2/ui_util.c b/gtk2/ui_util.c index 8dc77b7ae3..6740dc57d6 100644 --- a/gtk2/ui_util.c +++ b/gtk2/ui_util.c @@ -1,7 +1,7 @@ /* ui_util.c * UI utility routines * - * $Id: ui_util.c,v 1.3 2002/09/14 10:07:40 oabad Exp $ + * $Id: ui_util.c,v 1.4 2002/09/21 11:36:30 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -31,6 +31,7 @@ #include "gtkglobals.h" #include "ui_util.h" #include "prefs.h" +#include "epan/epan.h" #include "../ui_util.h" #include "image/eicon3d16.xpm" @@ -1,7 +1,7 @@ /* ui_util.h * Definitions for UI utility routines * - * $Id: ui_util.h,v 1.10 2002/08/28 21:00:41 jmayer Exp $ + * $Id: ui_util.h,v 1.11 2002/09/21 11:36:25 oabad Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -33,6 +33,33 @@ extern "C" { /* Set the name of the top-level window and its icon. */ void set_main_window_name(gchar *); +/* packet list related functions */ +void packet_list_clear(void); +void packet_list_freeze(void); +void packet_list_thaw(void); +void packet_list_select_row(gint); +void packet_list_set_column_auto_resize(gint, gboolean); +void packet_list_set_column_resizeable(gint, gboolean); +void packet_list_set_column_width(gint, gint); +void packet_list_moveto_end(void); +gint packet_list_append(gchar *text[], gpointer data); +void packet_list_set_colors(gint, GdkColor *, GdkColor *); +gint packet_list_find_row_from_data(gpointer); +void packet_list_set_text(gint, gint, const gchar *); +void packet_list_set_cls_time_width(gint); +gpointer packet_list_get_row_data(gint); +void packet_list_set_selected_row(gint); + +/* create byte views in the main window */ +void add_main_byte_views(epan_dissect_t *edt); +/* display the protocol tree in the main window */ +void main_proto_tree_draw(proto_tree *protocol_tree); + +void clear_tree_and_hex_views(void); + +/* Destroy all popup packet windows. */ +void destroy_packet_wins(void); + #ifdef __cplusplus } #endif /* __cplusplus */ |