Turn the GTK+ 1.2.10 clist code into our own widget; that lets us modify it

to add functionality or improve performance, although, until we make it
work on GTK+ 1.3[.x] and 2.x, we shouldn't count on the performance
improvements, or make its API different from that of the GtkClist API
(other than names).

Move all the code that knows about the packet list into
gtk/packet_list.c, so that the GtkClist vs. EthClist stuff is
encapsulated inside it.

svn path=/trunk/; revision=9608
This commit is contained in:
Guy Harris 2004-01-09 08:36:23 +00:00
parent f5f60f1ba3
commit 563f423d76
11 changed files with 1846 additions and 1730 deletions

View File

@ -1,7 +1,7 @@
# Makefile.am
# Automake file for the GTK interface routines for Ethereal
#
# $Id: Makefile.am,v 1.84 2003/12/29 22:43:33 guy Exp $
# $Id: Makefile.am,v 1.85 2004/01/09 08:36:22 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@ -116,6 +116,7 @@ libui_a_SOURCES = \
nameres_prefs.c \
nameres_prefs.h \
packet_list.c \
packet_list.h \
packet_win.c \
packet_win.h \
plugins_dlg.c \
@ -182,6 +183,8 @@ libui_a_SOURCES = \
dlg_utils.h \
endpoint_talkers_table.c \
endpoint_talkers_table.h \
ethclist.c \
ethclist.h \
ethereal-tap-register.c \
file_dlg.c \
file_dlg.h \
@ -193,8 +196,6 @@ libui_a_SOURCES = \
follow_dlg.h \
goto_dlg.c \
goto_dlg.h \
gtkclist_v12.c \
gtkclist_v12.h \
gtkglobals.h \
gtk_stat_util.c \
gtk_stat_util.h \
@ -210,6 +211,7 @@ libui_a_SOURCES = \
nameres_prefs.c \
nameres_prefs.h \
packet_list.c \
packet_list.h \
packet_win.c \
packet_win.h \
plugins_dlg.c \

View File

@ -1,7 +1,7 @@
## Makefile for building ethereal.exe with Microsoft C and nmake
## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
#
# $Id: Makefile.nmake,v 1.68 2003/12/29 22:43:33 guy Exp $
# $Id: Makefile.nmake,v 1.69 2004/01/09 08:36:22 guy Exp $
include ..\config.nmake
@ -49,14 +49,10 @@ ETHEREAL_TAP_SRC = \
ETHEREAL_TAP_OBJECTS = $(ETHEREAL_TAP_SRC:.c=.obj)
# gtkclist.obj is not in here because it is gtk+-1.2 code,
# while the DLL for GTK+ on windows is gtk+-1.3, and there's
# some functions that have disappeared in gtk+-1.3 - and
# the only purpose our gtkclist.c serves is to be faster
# than versions of the CList code in some older GTK+ 1.2[.x]
# releases, but as of 1.2.8 the standard GTK+ should have
# the performance fix that's in our gtkclist.c, so there's no
# reason to use our gtkclist.c.
#
# ethclist.obj is not in here because it is currently gtk+-1.2-only
# code, while the DLL for GTK+ on Windows is gtk+-1.3.
#
OBJECTS = \
capture_combo_utils.obj \
capture_dlg.obj \

File diff suppressed because it is too large Load Diff

View File

@ -25,8 +25,8 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GTK_CLIST_H__
#define __GTK_CLIST_H__
#ifndef __ETH_CLIST_H__
#define __ETH_CLIST_H__
#include <gdk/gdk.h>
#include <gtk/gtksignal.h>
@ -43,106 +43,106 @@ extern "C" {
/* clist flags */
enum {
GTK_CLIST_IN_DRAG = 1 << 0,
GTK_CLIST_ROW_HEIGHT_SET = 1 << 1,
GTK_CLIST_SHOW_TITLES = 1 << 2,
GTK_CLIST_CHILD_HAS_FOCUS = 1 << 3,
GTK_CLIST_ADD_MODE = 1 << 4,
GTK_CLIST_AUTO_SORT = 1 << 5,
GTK_CLIST_AUTO_RESIZE_BLOCKED = 1 << 6,
GTK_CLIST_REORDERABLE = 1 << 7,
GTK_CLIST_USE_DRAG_ICONS = 1 << 8,
GTK_CLIST_DRAW_DRAG_LINE = 1 << 9,
GTK_CLIST_DRAW_DRAG_RECT = 1 << 10
ETH_CLIST_IN_DRAG = 1 << 0,
ETH_CLIST_ROW_HEIGHT_SET = 1 << 1,
ETH_CLIST_SHOW_TITLES = 1 << 2,
ETH_CLIST_CHILD_HAS_FOCUS = 1 << 3,
ETH_CLIST_ADD_MODE = 1 << 4,
ETH_CLIST_AUTO_SORT = 1 << 5,
ETH_CLIST_AUTO_RESIZE_BLOCKED = 1 << 6,
ETH_CLIST_REORDERABLE = 1 << 7,
ETH_CLIST_USE_DRAG_ICONS = 1 << 8,
ETH_CLIST_DRAW_DRAG_LINE = 1 << 9,
ETH_CLIST_DRAW_DRAG_RECT = 1 << 10
};
/* cell types */
typedef enum
{
GTK_CELL_EMPTY,
GTK_CELL_TEXT,
GTK_CELL_PIXMAP,
GTK_CELL_PIXTEXT,
GTK_CELL_WIDGET
} GtkCellType;
ETH_CELL_EMPTY,
ETH_CELL_TEXT,
ETH_CELL_PIXMAP,
ETH_CELL_PIXTEXT,
ETH_CELL_WIDGET
} EthCellType;
typedef enum
{
GTK_CLIST_DRAG_NONE,
GTK_CLIST_DRAG_BEFORE,
GTK_CLIST_DRAG_INTO,
GTK_CLIST_DRAG_AFTER
} GtkCListDragPos;
ETH_CLIST_DRAG_NONE,
ETH_CLIST_DRAG_BEFORE,
ETH_CLIST_DRAG_INTO,
ETH_CLIST_DRAG_AFTER
} EthCListDragPos;
typedef enum
{
GTK_BUTTON_IGNORED = 0,
GTK_BUTTON_SELECTS = 1 << 0,
GTK_BUTTON_DRAGS = 1 << 1,
GTK_BUTTON_EXPANDS = 1 << 2
} GtkButtonAction;
ETH_BUTTON_IGNORED = 0,
ETH_BUTTON_SELECTS = 1 << 0,
ETH_BUTTON_DRAGS = 1 << 1,
ETH_BUTTON_EXPANDS = 1 << 2
} EthButtonAction;
#define GTK_TYPE_CLIST (gtk_clist_get_type ())
#define GTK_CLIST(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_CLIST, GtkCList))
#define GTK_CLIST_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_CLIST, GtkCListClass))
#define GTK_IS_CLIST(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_CLIST))
#define GTK_IS_CLIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CLIST))
#define ETH_TYPE_CLIST (eth_clist_get_type ())
#define ETH_CLIST(obj) (GTK_CHECK_CAST ((obj), ETH_TYPE_CLIST, EthCList))
#define ETH_CLIST_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), ETH_TYPE_CLIST, EthCListClass))
#define ETH_IS_CLIST(obj) (GTK_CHECK_TYPE ((obj), ETH_TYPE_CLIST))
#define ETH_IS_CLIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), ETH_TYPE_CLIST))
#define GTK_CLIST_FLAGS(clist) (GTK_CLIST (clist)->flags)
#define GTK_CLIST_SET_FLAG(clist,flag) (GTK_CLIST_FLAGS (clist) |= (GTK_ ## flag))
#define GTK_CLIST_UNSET_FLAG(clist,flag) (GTK_CLIST_FLAGS (clist) &= ~(GTK_ ## flag))
#define ETH_CLIST_FLAGS(clist) (ETH_CLIST (clist)->flags)
#define ETH_CLIST_SET_FLAG(clist,flag) (ETH_CLIST_FLAGS (clist) |= (ETH_ ## flag))
#define ETH_CLIST_UNSET_FLAG(clist,flag) (ETH_CLIST_FLAGS (clist) &= ~(ETH_ ## flag))
#define GTK_CLIST_IN_DRAG(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_IN_DRAG)
#define GTK_CLIST_ROW_HEIGHT_SET(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_ROW_HEIGHT_SET)
#define GTK_CLIST_SHOW_TITLES(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_SHOW_TITLES)
#define GTK_CLIST_CHILD_HAS_FOCUS(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_CHILD_HAS_FOCUS)
#define GTK_CLIST_ADD_MODE(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_ADD_MODE)
#define GTK_CLIST_AUTO_SORT(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_AUTO_SORT)
#define GTK_CLIST_AUTO_RESIZE_BLOCKED(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_AUTO_RESIZE_BLOCKED)
#define GTK_CLIST_REORDERABLE(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_REORDERABLE)
#define GTK_CLIST_USE_DRAG_ICONS(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_USE_DRAG_ICONS)
#define GTK_CLIST_DRAW_DRAG_LINE(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_DRAW_DRAG_LINE)
#define GTK_CLIST_DRAW_DRAG_RECT(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_DRAW_DRAG_RECT)
#define ETH_CLIST_IN_DRAG(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_IN_DRAG)
#define ETH_CLIST_ROW_HEIGHT_SET(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_ROW_HEIGHT_SET)
#define ETH_CLIST_SHOW_TITLES(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_SHOW_TITLES)
#define ETH_CLIST_CHILD_HAS_FOCUS(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_CHILD_HAS_FOCUS)
#define ETH_CLIST_ADD_MODE(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_ADD_MODE)
#define ETH_CLIST_AUTO_SORT(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_AUTO_SORT)
#define ETH_CLIST_AUTO_RESIZE_BLOCKED(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_AUTO_RESIZE_BLOCKED)
#define ETH_CLIST_REORDERABLE(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_REORDERABLE)
#define ETH_CLIST_USE_DRAG_ICONS(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_USE_DRAG_ICONS)
#define ETH_CLIST_DRAW_DRAG_LINE(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_DRAW_DRAG_LINE)
#define ETH_CLIST_DRAW_DRAG_RECT(clist) (ETH_CLIST_FLAGS (clist) & ETH_CLIST_DRAW_DRAG_RECT)
#define GTK_CLIST_ROW(_glist_) ((GtkCListRow *)((_glist_)->data))
#define ETH_CLIST_ROW(_glist_) ((EthCListRow *)((_glist_)->data))
/* pointer casting for cells */
#define GTK_CELL_TEXT(cell) (((GtkCellText *) &(cell)))
#define GTK_CELL_PIXMAP(cell) (((GtkCellPixmap *) &(cell)))
#define GTK_CELL_PIXTEXT(cell) (((GtkCellPixText *) &(cell)))
#define GTK_CELL_WIDGET(cell) (((GtkCellWidget *) &(cell)))
#define ETH_CELL_TEXT(cell) (((EthCellText *) &(cell)))
#define ETH_CELL_PIXMAP(cell) (((EthCellPixmap *) &(cell)))
#define ETH_CELL_PIXTEXT(cell) (((EthCellPixText *) &(cell)))
#define ETH_CELL_WIDGET(cell) (((EthCellWidget *) &(cell)))
typedef struct _GtkCList GtkCList;
typedef struct _GtkCListClass GtkCListClass;
typedef struct _GtkCListColumn GtkCListColumn;
typedef struct _GtkCListRow GtkCListRow;
typedef struct _EthCList EthCList;
typedef struct _EthCListClass EthCListClass;
typedef struct _EthCListColumn EthCListColumn;
typedef struct _EthCListRow EthCListRow;
typedef struct _GtkCell GtkCell;
typedef struct _GtkCellText GtkCellText;
typedef struct _GtkCellPixmap GtkCellPixmap;
typedef struct _GtkCellPixText GtkCellPixText;
typedef struct _GtkCellWidget GtkCellWidget;
typedef struct _EthCell EthCell;
typedef struct _EthCellText EthCellText;
typedef struct _EthCellPixmap EthCellPixmap;
typedef struct _EthCellPixText EthCellPixText;
typedef struct _EthCellWidget EthCellWidget;
typedef gint (*GtkCListCompareFunc) (GtkCList *clist,
typedef gint (*EthCListCompareFunc) (EthCList *clist,
gconstpointer ptr1,
gconstpointer ptr2);
typedef struct _GtkCListCellInfo GtkCListCellInfo;
typedef struct _GtkCListDestInfo GtkCListDestInfo;
typedef struct _EthCListCellInfo EthCListCellInfo;
typedef struct _EthCListDestInfo EthCListDestInfo;
struct _GtkCListCellInfo
struct _EthCListCellInfo
{
gint row;
gint column;
};
struct _GtkCListDestInfo
struct _EthCListDestInfo
{
GtkCListCellInfo cell;
GtkCListDragPos insert_pos;
EthCListCellInfo cell;
EthCListDragPos insert_pos;
};
struct _GtkCList
struct _EthCList
{
GtkContainer container;
@ -171,7 +171,7 @@ struct _GtkCList
GdkWindow *title_window;
/* dynamicly allocated array of column structures */
GtkCListColumn *column;
EthCListColumn *column;
/* the scrolling window and its height and width to
* make things a little speedier */
@ -203,7 +203,7 @@ struct _GtkCList
guint8 drag_button;
/* dnd */
GtkCListCellInfo click_cell;
EthCListCellInfo click_cell;
/* scroll adjustments */
GtkAdjustment *hadjustment;
@ -233,90 +233,90 @@ struct _GtkCList
gint vtimer;
GtkSortType sort_type;
GtkCListCompareFunc compare;
EthCListCompareFunc compare;
gint sort_column;
};
struct _GtkCListClass
struct _EthCListClass
{
GtkContainerClass parent_class;
void (*set_scroll_adjustments) (GtkCList *clist,
void (*set_scroll_adjustments) (EthCList *clist,
GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
void (*refresh) (GtkCList *clist);
void (*select_row) (GtkCList *clist,
void (*refresh) (EthCList *clist);
void (*select_row) (EthCList *clist,
gint row,
gint column,
GdkEvent *event);
void (*unselect_row) (GtkCList *clist,
void (*unselect_row) (EthCList *clist,
gint row,
gint column,
GdkEvent *event);
void (*row_move) (GtkCList *clist,
void (*row_move) (EthCList *clist,
gint source_row,
gint dest_row);
void (*click_column) (GtkCList *clist,
void (*click_column) (EthCList *clist,
gint column);
void (*resize_column) (GtkCList *clist,
void (*resize_column) (EthCList *clist,
gint column,
gint width);
void (*toggle_focus_row) (GtkCList *clist);
void (*select_all) (GtkCList *clist);
void (*unselect_all) (GtkCList *clist);
void (*undo_selection) (GtkCList *clist);
void (*start_selection) (GtkCList *clist);
void (*end_selection) (GtkCList *clist);
void (*extend_selection) (GtkCList *clist,
void (*toggle_focus_row) (EthCList *clist);
void (*select_all) (EthCList *clist);
void (*unselect_all) (EthCList *clist);
void (*undo_selection) (EthCList *clist);
void (*start_selection) (EthCList *clist);
void (*end_selection) (EthCList *clist);
void (*extend_selection) (EthCList *clist,
GtkScrollType scroll_type,
gfloat position,
gboolean auto_start_selection);
void (*scroll_horizontal) (GtkCList *clist,
void (*scroll_horizontal) (EthCList *clist,
GtkScrollType scroll_type,
gfloat position);
void (*scroll_vertical) (GtkCList *clist,
void (*scroll_vertical) (EthCList *clist,
GtkScrollType scroll_type,
gfloat position);
void (*toggle_add_mode) (GtkCList *clist);
void (*abort_column_resize) (GtkCList *clist);
void (*resync_selection) (GtkCList *clist,
void (*toggle_add_mode) (EthCList *clist);
void (*abort_column_resize) (EthCList *clist);
void (*resync_selection) (EthCList *clist,
GdkEvent *event);
GList* (*selection_find) (GtkCList *clist,
GList* (*selection_find) (EthCList *clist,
gint row_number,
GList *row_list_element);
void (*draw_row) (GtkCList *clist,
void (*draw_row) (EthCList *clist,
GdkRectangle *area,
gint row,
GtkCListRow *clist_row);
void (*draw_drag_highlight) (GtkCList *clist,
GtkCListRow *target_row,
EthCListRow *clist_row);
void (*draw_drag_highlight) (EthCList *clist,
EthCListRow *target_row,
gint target_row_number,
GtkCListDragPos drag_pos);
void (*clear) (GtkCList *clist);
void (*fake_unselect_all) (GtkCList *clist,
EthCListDragPos drag_pos);
void (*clear) (EthCList *clist);
void (*fake_unselect_all) (EthCList *clist,
gint row);
void (*sort_list) (GtkCList *clist);
gint (*insert_row) (GtkCList *clist,
void (*sort_list) (EthCList *clist);
gint (*insert_row) (EthCList *clist,
gint row,
gchar *text[]);
void (*remove_row) (GtkCList *clist,
void (*remove_row) (EthCList *clist,
gint row);
void (*set_cell_contents) (GtkCList *clist,
GtkCListRow *clist_row,
void (*set_cell_contents) (EthCList *clist,
EthCListRow *clist_row,
gint column,
GtkCellType type,
EthCellType type,
const gchar *text,
guint8 spacing,
GdkPixmap *pixmap,
GdkBitmap *mask);
void (*cell_size_request) (GtkCList *clist,
GtkCListRow *clist_row,
void (*cell_size_request) (EthCList *clist,
EthCListRow *clist_row,
gint column,
GtkRequisition *requisition);
};
struct _GtkCListColumn
struct _EthCListColumn
{
gchar *title;
GdkRectangle area;
@ -336,9 +336,9 @@ struct _GtkCListColumn
guint button_passive : 1;
};
struct _GtkCListRow
struct _EthCListRow
{
GtkCell *cell;
EthCell *cell;
GtkStateType state;
GdkColor foreground;
@ -355,9 +355,9 @@ struct _GtkCListRow
};
/* Cell Structures */
struct _GtkCellText
struct _EthCellText
{
GtkCellType type;
EthCellType type;
gint16 vertical;
gint16 horizontal;
@ -367,9 +367,9 @@ struct _GtkCellText
gchar *text;
};
struct _GtkCellPixmap
struct _EthCellPixmap
{
GtkCellType type;
EthCellType type;
gint16 vertical;
gint16 horizontal;
@ -380,9 +380,9 @@ struct _GtkCellPixmap
GdkBitmap *mask;
};
struct _GtkCellPixText
struct _EthCellPixText
{
GtkCellType type;
EthCellType type;
gint16 vertical;
gint16 horizontal;
@ -395,9 +395,9 @@ struct _GtkCellPixText
GdkBitmap *mask;
};
struct _GtkCellWidget
struct _EthCellWidget
{
GtkCellType type;
EthCellType type;
gint16 vertical;
gint16 horizontal;
@ -407,9 +407,9 @@ struct _GtkCellWidget
GtkWidget *widget;
};
struct _GtkCell
struct _EthCell
{
GtkCellType type;
EthCellType type;
gint16 vertical;
gint16 horizontal;
@ -435,42 +435,42 @@ struct _GtkCell
} u;
};
GtkType gtk_clist_get_type (void);
GtkType eth_clist_get_type (void);
/* constructors useful for gtk-- wrappers */
void gtk_clist_construct (GtkCList *clist,
void eth_clist_construct (EthCList *clist,
gint columns,
gchar *titles[]);
/* create a new GtkCList */
GtkWidget* gtk_clist_new (gint columns);
GtkWidget* gtk_clist_new_with_titles (gint columns,
/* create a new EthCList */
GtkWidget* eth_clist_new (gint columns);
GtkWidget* eth_clist_new_with_titles (gint columns,
gchar *titles[]);
/* set adjustments of clist */
void gtk_clist_set_hadjustment (GtkCList *clist,
void eth_clist_set_hadjustment (EthCList *clist,
GtkAdjustment *adjustment);
void gtk_clist_set_vadjustment (GtkCList *clist,
void eth_clist_set_vadjustment (EthCList *clist,
GtkAdjustment *adjustment);
/* get adjustments of clist */
GtkAdjustment* gtk_clist_get_hadjustment (GtkCList *clist);
GtkAdjustment* gtk_clist_get_vadjustment (GtkCList *clist);
GtkAdjustment* eth_clist_get_hadjustment (EthCList *clist);
GtkAdjustment* eth_clist_get_vadjustment (EthCList *clist);
/* set the border style of the clist */
void gtk_clist_set_shadow_type (GtkCList *clist,
void eth_clist_set_shadow_type (EthCList *clist,
GtkShadowType type);
/* set the clist's selection mode */
void gtk_clist_set_selection_mode (GtkCList *clist,
void eth_clist_set_selection_mode (EthCList *clist,
GtkSelectionMode mode);
/* enable clists reorder ability */
void gtk_clist_set_reorderable (GtkCList *clist,
void eth_clist_set_reorderable (EthCList *clist,
gboolean reorderable);
void gtk_clist_set_use_drag_icons (GtkCList *clist,
void eth_clist_set_use_drag_icons (EthCList *clist,
gboolean use_icons);
void gtk_clist_set_button_actions (GtkCList *clist,
void eth_clist_set_button_actions (EthCList *clist,
guint button,
guint8 button_actions);
@ -478,88 +478,88 @@ void gtk_clist_set_button_actions (GtkCList *clist,
* you have made a number of changes and the updates wil occure in a
* more efficent mannor than if you made them on a unfrozen list
*/
void gtk_clist_freeze (GtkCList *clist);
void gtk_clist_thaw (GtkCList *clist);
void eth_clist_freeze (EthCList *clist);
void eth_clist_thaw (EthCList *clist);
/* show and hide the column title buttons */
void gtk_clist_column_titles_show (GtkCList *clist);
void gtk_clist_column_titles_hide (GtkCList *clist);
void eth_clist_column_titles_show (EthCList *clist);
void eth_clist_column_titles_hide (EthCList *clist);
/* set the column title to be a active title (responds to button presses,
* prelights, and grabs keyboard focus), or passive where it acts as just
* a title
*/
void gtk_clist_column_title_active (GtkCList *clist,
void eth_clist_column_title_active (EthCList *clist,
gint column);
void gtk_clist_column_title_passive (GtkCList *clist,
void eth_clist_column_title_passive (EthCList *clist,
gint column);
void gtk_clist_column_titles_active (GtkCList *clist);
void gtk_clist_column_titles_passive (GtkCList *clist);
void eth_clist_column_titles_active (EthCList *clist);
void eth_clist_column_titles_passive (EthCList *clist);
/* set the title in the column title button */
void gtk_clist_set_column_title (GtkCList *clist,
void eth_clist_set_column_title (EthCList *clist,
gint column,
const gchar *title);
/* returns the title of column. Returns NULL if title is not set */
gchar * gtk_clist_get_column_title (GtkCList *clist,
gchar * eth_clist_get_column_title (EthCList *clist,
gint column);
/* set a widget instead of a title for the column title button */
void gtk_clist_set_column_widget (GtkCList *clist,
void eth_clist_set_column_widget (EthCList *clist,
gint column,
GtkWidget *widget);
/* returns the column widget */
GtkWidget * gtk_clist_get_column_widget (GtkCList *clist,
GtkWidget * eth_clist_get_column_widget (EthCList *clist,
gint column);
/* set the justification on a column */
void gtk_clist_set_column_justification (GtkCList *clist,
void eth_clist_set_column_justification (EthCList *clist,
gint column,
GtkJustification justification);
/* set visibility of a column */
void gtk_clist_set_column_visibility (GtkCList *clist,
void eth_clist_set_column_visibility (EthCList *clist,
gint column,
gboolean visible);
/* enable/disable column resize operations by mouse */
void gtk_clist_set_column_resizeable (GtkCList *clist,
void eth_clist_set_column_resizeable (EthCList *clist,
gint column,
gboolean resizeable);
/* resize column automatically to its optimal width */
void gtk_clist_set_column_auto_resize (GtkCList *clist,
void eth_clist_set_column_auto_resize (EthCList *clist,
gint column,
gboolean auto_resize);
gint gtk_clist_columns_autosize (GtkCList *clist);
gint eth_clist_columns_autosize (EthCList *clist);
/* return the optimal column width, i.e. maximum of all cell widths */
gint gtk_clist_optimal_column_width (GtkCList *clist,
gint eth_clist_optimal_column_width (EthCList *clist,
gint column);
/* set the pixel width of a column; this is a necessary step in
* creating a CList because otherwise the column width is chozen from
* the width of the column title, which will never be right
*/
void gtk_clist_set_column_width (GtkCList *clist,
void eth_clist_set_column_width (EthCList *clist,
gint column,
gint width);
/* set column minimum/maximum width. min/max_width < 0 => no restriction */
void gtk_clist_set_column_min_width (GtkCList *clist,
void eth_clist_set_column_min_width (EthCList *clist,
gint column,
gint min_width);
void gtk_clist_set_column_max_width (GtkCList *clist,
void eth_clist_set_column_max_width (EthCList *clist,
gint column,
gint max_width);
/* change the height of the rows, the default (height=0) is
* the hight of the current font.
*/
void gtk_clist_set_row_height (GtkCList *clist,
void eth_clist_set_row_height (EthCList *clist,
guint height);
/* scroll the viewing area of the list to the given column and row;
@ -567,23 +567,23 @@ void gtk_clist_set_row_height (GtkCList *clist,
* row should appear on the screnn, 0.0 being top or left, 1.0 being
* bottom or right; if row or column is -1 then then there is no change
*/
void gtk_clist_moveto (GtkCList *clist,
void eth_clist_moveto (EthCList *clist,
gint row,
gint column,
gfloat row_align,
gfloat col_align);
/* returns whether the row is visible */
GtkVisibility gtk_clist_row_is_visible (GtkCList *clist,
GtkVisibility eth_clist_row_is_visible (EthCList *clist,
gint row);
/* returns the cell type */
GtkCellType gtk_clist_get_cell_type (GtkCList *clist,
EthCellType eth_clist_get_cell_type (EthCList *clist,
gint row,
gint column);
/* sets a given cell's text, replacing its current contents */
void gtk_clist_set_text (GtkCList *clist,
void eth_clist_set_text (EthCList *clist,
gint row,
gint column,
const gchar *text);
@ -591,26 +591,26 @@ void gtk_clist_set_text (GtkCList *clist,
/* for the "get" functions, any of the return pointer can be
* NULL if you are not interested
*/
gint gtk_clist_get_text (GtkCList *clist,
gint eth_clist_get_text (EthCList *clist,
gint row,
gint column,
gchar **text);
/* sets a given cell's pixmap, replacing its current contents */
void gtk_clist_set_pixmap (GtkCList *clist,
void eth_clist_set_pixmap (EthCList *clist,
gint row,
gint column,
GdkPixmap *pixmap,
GdkBitmap *mask);
gint gtk_clist_get_pixmap (GtkCList *clist,
gint eth_clist_get_pixmap (EthCList *clist,
gint row,
gint column,
GdkPixmap **pixmap,
GdkBitmap **mask);
/* sets a given cell's pixmap and text, replacing its current contents */
void gtk_clist_set_pixtext (GtkCList *clist,
void eth_clist_set_pixtext (EthCList *clist,
gint row,
gint column,
const gchar *text,
@ -618,7 +618,7 @@ void gtk_clist_set_pixtext (GtkCList *clist,
GdkPixmap *pixmap,
GdkBitmap *mask);
gint gtk_clist_get_pixtext (GtkCList *clist,
gint eth_clist_get_pixtext (EthCList *clist,
gint row,
gint column,
gchar **text,
@ -629,152 +629,152 @@ gint gtk_clist_get_pixtext (GtkCList *clist,
/* sets the foreground color of a row, the color must already
* be allocated
*/
void gtk_clist_set_foreground (GtkCList *clist,
void eth_clist_set_foreground (EthCList *clist,
gint row,
GdkColor *color);
/* sets the background color of a row, the color must already
* be allocated
*/
void gtk_clist_set_background (GtkCList *clist,
void eth_clist_set_background (EthCList *clist,
gint row,
GdkColor *color);
/* set / get cell styles */
void gtk_clist_set_cell_style (GtkCList *clist,
void eth_clist_set_cell_style (EthCList *clist,
gint row,
gint column,
GtkStyle *style);
GtkStyle *gtk_clist_get_cell_style (GtkCList *clist,
GtkStyle *eth_clist_get_cell_style (EthCList *clist,
gint row,
gint column);
void gtk_clist_set_row_style (GtkCList *clist,
void eth_clist_set_row_style (EthCList *clist,
gint row,
GtkStyle *style);
GtkStyle *gtk_clist_get_row_style (GtkCList *clist,
GtkStyle *eth_clist_get_row_style (EthCList *clist,
gint row);
/* this sets a horizontal and vertical shift for drawing
* the contents of a cell; it can be positive or negitive;
* this is particulary useful for indenting items in a column
*/
void gtk_clist_set_shift (GtkCList *clist,
void eth_clist_set_shift (EthCList *clist,
gint row,
gint column,
gint vertical,
gint horizontal);
/* set/get selectable flag of a single row */
void gtk_clist_set_selectable (GtkCList *clist,
void eth_clist_set_selectable (EthCList *clist,
gint row,
gboolean selectable);
gboolean gtk_clist_get_selectable (GtkCList *clist,
gboolean eth_clist_get_selectable (EthCList *clist,
gint row);
/* prepend/append returns the index of the row you just added,
* making it easier to append and modify a row
*/
gint gtk_clist_prepend (GtkCList *clist,
gint eth_clist_prepend (EthCList *clist,
gchar *text[]);
gint gtk_clist_append (GtkCList *clist,
gint eth_clist_append (EthCList *clist,
gchar *text[]);
/* inserts a row at index row and returns the row where it was
* actually inserted (may be different from "row" in auto_sort mode)
*/
gint gtk_clist_insert (GtkCList *clist,
gint eth_clist_insert (EthCList *clist,
gint row,
gchar *text[]);
/* removes row at index row */
void gtk_clist_remove (GtkCList *clist,
void eth_clist_remove (EthCList *clist,
gint row);
/* sets a arbitrary data pointer for a given row */
void gtk_clist_set_row_data (GtkCList *clist,
void eth_clist_set_row_data (EthCList *clist,
gint row,
gpointer data);
/* sets a data pointer for a given row with destroy notification */
void gtk_clist_set_row_data_full (GtkCList *clist,
void eth_clist_set_row_data_full (EthCList *clist,
gint row,
gpointer data,
GtkDestroyNotify destroy);
/* returns the data set for a row */
gpointer gtk_clist_get_row_data (GtkCList *clist,
gpointer eth_clist_get_row_data (EthCList *clist,
gint row);
/* givin a data pointer, find the first (and hopefully only!)
* row that points to that data, or -1 if none do
*/
gint gtk_clist_find_row_from_data (GtkCList *clist,
gint eth_clist_find_row_from_data (EthCList *clist,
gpointer data);
/* force selection of a row */
void gtk_clist_select_row (GtkCList *clist,
void eth_clist_select_row (EthCList *clist,
gint row,
gint column);
/* force unselection of a row */
void gtk_clist_unselect_row (GtkCList *clist,
void eth_clist_unselect_row (EthCList *clist,
gint row,
gint column);
/* undo the last select/unselect operation */
void gtk_clist_undo_selection (GtkCList *clist);
void eth_clist_undo_selection (EthCList *clist);
/* clear the entire list -- this is much faster than removing
* each item with gtk_clist_remove
* each item with eth_clist_remove
*/
void gtk_clist_clear (GtkCList *clist);
void eth_clist_clear (EthCList *clist);
/* return the row column corresponding to the x and y coordinates,
* the returned values are only valid if the x and y coordinates
* are respectively to a window == clist->clist_window
*/
gint gtk_clist_get_selection_info (GtkCList *clist,
gint eth_clist_get_selection_info (EthCList *clist,
gint x,
gint y,
gint *row,
gint *column);
/* in multiple or extended mode, select all rows */
void gtk_clist_select_all (GtkCList *clist);
void eth_clist_select_all (EthCList *clist);
/* in all modes except browse mode, deselect all rows */
void gtk_clist_unselect_all (GtkCList *clist);
void eth_clist_unselect_all (EthCList *clist);
/* swap the position of two rows */
void gtk_clist_swap_rows (GtkCList *clist,
void eth_clist_swap_rows (EthCList *clist,
gint row1,
gint row2);
/* move row from source_row position to dest_row position */
void gtk_clist_row_move (GtkCList *clist,
void eth_clist_row_move (EthCList *clist,
gint source_row,
gint dest_row);
/* sets a compare function different to the default */
void gtk_clist_set_compare_func (GtkCList *clist,
GtkCListCompareFunc cmp_func);
void eth_clist_set_compare_func (EthCList *clist,
EthCListCompareFunc cmp_func);
/* the column to sort by */
void gtk_clist_set_sort_column (GtkCList *clist,
void eth_clist_set_sort_column (EthCList *clist,
gint column);
/* how to sort : ascending or descending */
void gtk_clist_set_sort_type (GtkCList *clist,
void eth_clist_set_sort_type (EthCList *clist,
GtkSortType sort_type);
/* sort the list with the current compare function */
void gtk_clist_sort (GtkCList *clist);
void eth_clist_sort (EthCList *clist);
/* Automatically sort upon insertion */
void gtk_clist_set_auto_sort (GtkCList *clist,
void eth_clist_set_auto_sort (EthCList *clist,
gboolean auto_sort);
@ -782,4 +782,4 @@ void gtk_clist_set_auto_sort (GtkCList *clist,
}
#endif /* __cplusplus */
#endif /* __GTK_CLIST_H__ */
#endif /* __ETH_CLIST_H__ */

View File

@ -1,7 +1,7 @@
/* gtkglobals.h
* GTK-related Global defines, etc.
*
* $Id: gtkglobals.h,v 1.23 2003/12/24 01:21:32 guy Exp $
* $Id: gtkglobals.h,v 1.24 2004/01/09 08:36:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -31,14 +31,9 @@ extern GdkFont *m_r_font, *m_b_font;
extern guint m_font_height, m_font_width;
extern GtkStyle *item_style;
void set_plist_font(GdkFont *font);
#else
extern PangoFontDescription *m_r_font, *m_b_font;
void set_plist_font(PangoFontDescription *font);
#endif
void set_plist_sel_browse(gboolean);
#if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
/*

View File

@ -1,7 +1,7 @@
/* gui_prefs.c
* Dialog box for GUI preferences
*
* $Id: gui_prefs.c,v 1.49 2004/01/01 13:16:40 ulfl Exp $
* $Id: gui_prefs.c,v 1.50 2004/01/09 08:36:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -45,6 +45,7 @@
#include "dlg_utils.h"
#include "proto_draw.h"
#include "main.h"
#include "packet_list.h"
#include "compat_macros.h"
#include "toolbar.h"

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.350 2004/01/09 02:57:54 obiot Exp $
* $Id: main.c,v 1.351 2004/01/09 08:36:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -113,14 +113,14 @@
#include "register.h"
#include <prefs-int.h>
#include "ringbuffer.h"
#include "../ui_util.h"
#include "ui_util.h"
#include "toolbar.h"
#include "image/clist_ascend.xpm"
#include "image/clist_descend.xpm"
#include "../tap.h"
#include "../util.h"
#include "compat_macros.h"
#include "find_dlg.h"
#include "packet_list.h"
#ifdef WIN32
#include "capture-wpcap.h"
@ -134,8 +134,7 @@ typedef struct column_arrows {
capture_file cfile;
GtkWidget *main_display_filter_widget=NULL;
GtkWidget *top_level = NULL, *packet_list, *tree_view, *byte_nb_ptr,
*tv_scrollw, *pkt_scrollw;
GtkWidget *top_level = NULL, *tree_view, *byte_nb_ptr, *tv_scrollw;
static GtkWidget *info_bar;
#if GTK_MAJOR_VERSION < 2
GdkFont *m_r_font, *m_b_font;
@ -479,7 +478,7 @@ get_text_from_packet_list(gpointer data)
{
gint row = (gint)OBJECT_GET_DATA(data, E_MPACKET_LIST_ROW_KEY);
gint column = (gint)OBJECT_GET_DATA(data, E_MPACKET_LIST_COL_KEY);
frame_data *fdata = (frame_data *)gtk_clist_get_row_data(GTK_CLIST(packet_list), row);
frame_data *fdata = (frame_data *)packet_list_get_row_data(row);
epan_dissect_t *edt;
gchar *buf=NULL;
int len;
@ -830,84 +829,6 @@ filter_reset_cb(GtkWidget *w, gpointer data _U_)
filter_packets(&cfile, NULL);
}
/* GTKClist compare routine, overrides default to allow numeric comparison */
static gint
packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
{
/* Get row text strings */
char *text1 = GTK_CELL_TEXT (((const GtkCListRow *)ptr1)->cell[clist->sort_column])->text;
char *text2 = GTK_CELL_TEXT (((const GtkCListRow *)ptr2)->cell[clist->sort_column])->text;
/* Attempt to convert to numbers */
double num1 = atof(text1);
double num2 = atof(text2);
gint col_fmt = cfile.cinfo.col_fmt[clist->sort_column];
if ((col_fmt == COL_NUMBER) || (col_fmt == COL_REL_TIME) || (col_fmt == COL_DELTA_TIME) ||
((col_fmt == COL_CLS_TIME) && (timestamp_type == RELATIVE)) ||
((col_fmt == COL_CLS_TIME) && (timestamp_type == DELTA)) ||
(col_fmt == COL_UNRES_SRC_PORT) || (col_fmt == COL_UNRES_DST_PORT) ||
((num1 != 0) && (num2 != 0) && ((col_fmt == COL_DEF_SRC_PORT) || (col_fmt == COL_RES_SRC_PORT) ||
(col_fmt == COL_DEF_DST_PORT) || (col_fmt == COL_RES_DST_PORT))) ||
(col_fmt == COL_PACKET_LENGTH) || (col_fmt == COL_CULMULATIVE_BYTES)) {
/* Compare numeric column */
if (num1 < num2)
return -1;
else if (num1 > num2)
return 1;
else
return 0;
}
else {
/* Compare text column */
if (!text2)
return (text1 != NULL);
if (!text1)
return -1;
return strcmp(text1, text2);
}
}
/* What to do when a column is clicked */
static void
packet_list_click_column_cb(GtkCList *clist, gint column, gpointer data)
{
column_arrows *col_arrows = (column_arrows *) data;
int i;
gtk_clist_freeze(clist);
for (i = 0; i < cfile.cinfo.num_cols; i++) {
gtk_widget_hide(col_arrows[i].ascend_pm);
gtk_widget_hide(col_arrows[i].descend_pm);
}
if (column == clist->sort_column) {
if (clist->sort_type == GTK_SORT_ASCENDING) {
clist->sort_type = GTK_SORT_DESCENDING;
gtk_widget_show(col_arrows[column].descend_pm);
} else {
clist->sort_type = GTK_SORT_ASCENDING;
gtk_widget_show(col_arrows[column].ascend_pm);
}
}
else {
clist->sort_type = GTK_SORT_ASCENDING;
gtk_widget_show(col_arrows[column].ascend_pm);
gtk_clist_set_sort_column(clist, column);
}
gtk_clist_thaw(clist);
gtk_clist_sort(clist);
}
/* mark as reference time frame */
static void
set_frame_reftime(gboolean set, frame_data *frame, gint row) {
@ -921,79 +842,6 @@ set_frame_reftime(gboolean set, frame_data *frame, gint row) {
reftime_packets(&cfile);
}
/* mark packets */
static void
set_frame_mark(gboolean set, frame_data *frame, gint row) {
GdkColor fg, bg;
if (row == -1)
return;
if (set) {
mark_frame(&cfile, frame);
color_t_to_gdkcolor(&fg, &prefs.gui_marked_fg);
color_t_to_gdkcolor(&bg, &prefs.gui_marked_bg);
gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &fg);
gtk_clist_set_background(GTK_CLIST(packet_list), row, &bg);
} else {
color_filter_t *cfilter = frame->color_filter;
unmark_frame(&cfile, frame);
/* Restore the color from the matching color filter if any */
if (cfilter) { /* The packet matches a color filter */
color_t_to_gdkcolor(&fg, &cfilter->fg_color);
color_t_to_gdkcolor(&bg, &cfilter->bg_color);
gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &fg);
gtk_clist_set_background(GTK_CLIST(packet_list), row, &bg);
} else { /* No color filter match */
gtk_clist_set_foreground(GTK_CLIST(packet_list), row, NULL);
gtk_clist_set_background(GTK_CLIST(packet_list), row, NULL);
}
}
file_set_save_marked_sensitive();
}
#if GTK_MAJOR_VERSION < 2
static void
packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
{
GdkEventButton *event_button = (GdkEventButton *)event;
gint row, column;
if (w == NULL || event == NULL)
return;
if (event->type == GDK_BUTTON_PRESS && event_button->button == 2 &&
event_button->window == GTK_CLIST(w)->clist_window &&
gtk_clist_get_selection_info(GTK_CLIST(w),
(gint) event_button->x, (gint) event_button->y,
&row, &column)) {
frame_data *fdata = (frame_data *) gtk_clist_get_row_data(GTK_CLIST(w),
row);
set_frame_mark(!fdata->flags.marked, fdata, row);
}
}
#else
static gint
packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
{
GdkEventButton *event_button = (GdkEventButton *)event;
gint row, column;
if (w == NULL || event == NULL)
return FALSE;
if (event->type == GDK_BUTTON_PRESS && event_button->button == 2 &&
event_button->window == GTK_CLIST(w)->clist_window &&
gtk_clist_get_selection_info(GTK_CLIST(w), (gint) event_button->x,
(gint) event_button->y, &row, &column)) {
frame_data *fdata = (frame_data *)gtk_clist_get_row_data(GTK_CLIST(w),
row);
set_frame_mark(!fdata->flags.marked, fdata, row);
return TRUE;
}
return FALSE;
}
#endif
/* 0: toggle ref time status for the selected frame
* 1: find next ref time frame
* 2: find previous reftime frame
@ -1008,8 +856,7 @@ reftime_frame_cb(GtkWidget *w _U_, gpointer data _U_, guint action)
/* XXX hum, should better have a "cfile->current_row" here ... */
set_frame_reftime(!cfile.current_frame->flags.ref_time,
cfile.current_frame,
gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
cfile.current_frame));
packet_list_find_row_from_data(cfile.current_frame));
}
break;
case 1: /* find next ref frame */
@ -1021,67 +868,6 @@ reftime_frame_cb(GtkWidget *w _U_, gpointer data _U_, guint action)
}
}
void mark_frame_cb(GtkWidget *w _U_, gpointer data _U_) {
if (cfile.current_frame) {
/* XXX hum, should better have a "cfile->current_row" here ... */
set_frame_mark(!cfile.current_frame->flags.marked,
cfile.current_frame,
gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
cfile.current_frame));
}
}
static void mark_all_frames(gboolean set) {
frame_data *fdata;
cfile.marked_count = 0;
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
set_frame_mark(set,
fdata,
gtk_clist_find_row_from_data(GTK_CLIST(packet_list), fdata));
}
}
void update_marked_frames(void) {
frame_data *fdata;
if (cfile.plist == NULL) return;
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
if (fdata->flags.marked)
set_frame_mark(TRUE,
fdata,
gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
fdata));
}
}
void mark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_) {
mark_all_frames(TRUE);
}
void unmark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_) {
mark_all_frames(FALSE);
}
/* What to do when a list item is selected/unselected */
static void
packet_list_select_cb(GtkWidget *w _U_, gint row, gint col _U_, gpointer evt _U_) {
/* Remove the hex display tabbed pages */
while( (gtk_notebook_get_nth_page( GTK_NOTEBOOK(byte_nb_ptr), 0)))
gtk_notebook_remove_page( GTK_NOTEBOOK(byte_nb_ptr), 0);
select_packet(&cfile, row);
gtk_widget_grab_focus(packet_list);
}
static void
packet_list_unselect_cb(GtkWidget *w _U_, gint row _U_, gint col _U_, gpointer evt _U_) {
unselect_packet(&cfile);
}
#if GTK_MAJOR_VERSION < 2
static void
tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column _U_,
@ -1244,86 +1030,6 @@ void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) {
}
}
/* Set the selection mode of the packet list window. */
void
set_plist_sel_browse(gboolean val)
{
GtkSelectionMode new_mode;
/* initialize with a mode we don't use, so that the mode == new_mode
* test will fail the first time */
static GtkSelectionMode mode = GTK_SELECTION_MULTIPLE;
/* Yeah, GTK uses "browse" in the case where we do not, but oh well. I
* think "browse" in Ethereal makes more sense than "SINGLE" in GTK+ */
new_mode = val ? GTK_SELECTION_SINGLE : GTK_SELECTION_BROWSE;
if (mode == new_mode) {
/*
* The mode isn't changing, so don't do anything.
* In particular, don't gratuitiously unselect the
* current packet.
*
* XXX - why do we have to unselect the current packet
* ourselves? The documentation for the GtkCList at
*
* http://developer.gnome.org/doc/API/gtk/gtkclist.html
*
* says "Note that setting the widget's selection mode to
* one of GTK_SELECTION_BROWSE or GTK_SELECTION_SINGLE will
* cause all the items in the GtkCList to become deselected."
*/
return;
}
if (cfile.finfo_selected)
unselect_packet(&cfile);
mode = new_mode;
gtk_clist_set_selection_mode(GTK_CLIST(packet_list), mode);
}
/* Set the font of the packet list window. */
#if GTK_MAJOR_VERSION < 2
void
set_plist_font(GdkFont *font)
#else
void
set_plist_font(PangoFontDescription *font)
#endif
{
int i;
gint col_width;
#if GTK_MAJOR_VERSION < 2
GtkStyle *style;
style = gtk_style_new();
gdk_font_unref(style->font);
style->font = font;
gdk_font_ref(font);
gtk_widget_set_style(packet_list, style);
#else
PangoLayout *layout;
gtk_widget_modify_font(packet_list, font);
#endif
/* Compute default column sizes. */
for (i = 0; i < cfile.cinfo.num_cols; i++) {
#if GTK_MAJOR_VERSION < 2
col_width = gdk_string_width(font,
get_column_longest_string(get_column_format(i)));
#else
layout = gtk_widget_create_pango_layout(packet_list,
get_column_longest_string(get_column_format(i)));
pango_layout_get_pixel_size(layout, &col_width, NULL);
g_object_unref(G_OBJECT(layout));
#endif
gtk_clist_set_column_width(GTK_CLIST(packet_list), i,
col_width);
}
}
/*
* Push a message referring to file access onto the statusbar.
*/
@ -3067,17 +2773,12 @@ static void
create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
{
GtkWidget *main_vbox, *menubar, *u_pane, *l_pane,
*stat_hbox, *column_lb,
*stat_hbox,
*filter_bt, *filter_cm, *filter_te,
*filter_apply,
*filter_reset;
GList *filter_list = NULL;
GtkAccelGroup *accel;
GtkStyle *win_style;
GdkBitmap *ascend_bm, *descend_bm;
GdkPixmap *ascend_pm, *descend_pm;
column_arrows *col_arrows;
int i;
/* Display filter construct dialog has an Apply button, and "OK" not
only sets our text widget, it activates it (i.e., it causes us to
filter the capture). */
@ -3135,44 +2836,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gtk_widget_show(u_pane);
/* Packet list */
pkt_scrollw = scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(pkt_scrollw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show(pkt_scrollw);
gtk_paned_add1(GTK_PANED(u_pane), pkt_scrollw);
packet_list = gtk_clist_new(cfile.cinfo.num_cols);
/* Column titles are filled in below */
gtk_container_add(GTK_CONTAINER(pkt_scrollw), packet_list);
col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) *
cfile.cinfo.num_cols);
set_plist_sel_browse(prefs->gui_plist_sel_browse);
set_plist_font(m_r_font);
gtk_widget_set_name(packet_list, "packet list");
SIGNAL_CONNECT(packet_list, "click-column", packet_list_click_column_cb,
col_arrows);
SIGNAL_CONNECT(packet_list, "select-row", packet_list_select_cb, NULL);
SIGNAL_CONNECT(packet_list, "unselect-row", packet_list_unselect_cb, NULL);
for (i = 0; i < cfile.cinfo.num_cols; i++) {
/* Columns do not automatically resize, but are resizeable by
the user. */
gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, FALSE);
gtk_clist_set_column_resizeable(GTK_CLIST(packet_list), i, TRUE);
/* Right-justify the packet number column. */
if (cfile.cinfo.col_fmt[i] == COL_NUMBER)
gtk_clist_set_column_justification(GTK_CLIST(packet_list), i,
GTK_JUSTIFY_RIGHT);
}
WIDGET_SET_SIZE(packet_list, -1, pl_size);
SIGNAL_CONNECT(packet_list, "button_press_event", popup_menu_handler,
OBJECT_GET_DATA(popup_menu_object, PM_PACKET_LIST_KEY));
SIGNAL_CONNECT(packet_list, "button_press_event",
packet_list_button_pressed_cb, NULL);
gtk_clist_set_compare_func(GTK_CLIST(packet_list), packet_list_compare);
gtk_widget_show(packet_list);
packet_list_new(u_pane, prefs, pl_size);
/* Tree view */
#if GTK_MAJOR_VERSION < 2
@ -3292,37 +2956,10 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
gtk_widget_show(top_level);
/* Fill in column titles. This must be done after the top level window
is displayed. */
win_style = gtk_widget_get_style(top_level);
ascend_pm = gdk_pixmap_create_from_xpm_d(top_level->window, &ascend_bm,
&win_style->bg[GTK_STATE_NORMAL],
(gchar **)clist_ascend_xpm);
descend_pm = gdk_pixmap_create_from_xpm_d(top_level->window, &descend_bm,
&win_style->bg[GTK_STATE_NORMAL],
(gchar **)clist_descend_xpm);
for (i = 0; i < cfile.cinfo.num_cols; i++) {
col_arrows[i].table = gtk_table_new(2, 2, FALSE);
gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
column_lb = gtk_label_new(cfile.cinfo.col_title[i]);
gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show(column_lb);
col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
gtk_table_attach(GTK_TABLE(col_arrows[i].table),
col_arrows[i].ascend_pm,
1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
if (i == 0) {
gtk_widget_show(col_arrows[i].ascend_pm);
}
col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
gtk_table_attach(GTK_TABLE(col_arrows[i].table),
col_arrows[i].descend_pm,
1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_clist_set_column_widget(GTK_CLIST(packet_list), i,
col_arrows[i].table);
gtk_widget_show(col_arrows[i].table);
}
gtk_clist_column_titles_show(GTK_CLIST(packet_list));
is displayed.
XXX - is that still true, with fixed-width columns? */
packet_list_set_column_titles();
}

View File

@ -1,7 +1,7 @@
/* main.h
* Global defines, etc.
*
* $Id: main.h,v 1.34 2003/12/13 18:01:30 ulfl Exp $
* $Id: main.h,v 1.35 2004/01/09 08:36:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -95,10 +95,6 @@ void expand_all_cb(GtkWidget *, gpointer);
void collapse_all_cb(GtkWidget *, gpointer);
void resolve_name_cb(GtkWidget *, gpointer);
void reftime_frame_cb(GtkWidget *, gpointer, guint);
void mark_frame_cb(GtkWidget *, gpointer);
void mark_all_frames_cb(GtkWidget *w, gpointer);
void unmark_all_frames_cb(GtkWidget *w, gpointer);
void update_marked_frames(void);
#define RECENT_KEY_CAPTURE_FILE "recent.capture_file"
#define RECENT_KEY_DISPLAY_FILTER "recent.display_filter"

View File

@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
* $Id: menu.c,v 1.135 2004/01/06 22:38:07 guy Exp $
* $Id: menu.c,v 1.136 2004/01/09 08:36:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -64,6 +64,8 @@
#include "../tap.h"
#include "../menu.h"
#include "../ipproto.h"
#include "packet_list.h"
#include "ethclist.h"
GtkWidget *popup_menu_object;
@ -888,7 +890,6 @@ popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
{
GtkWidget *menu = NULL;
GdkEventButton *event_button = NULL;
GtkCList *packet_list = NULL;
gint row, column;
if(widget == NULL || event == NULL || data == NULL) {
@ -897,18 +898,15 @@ popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
/*
* If we ever want to make the menu differ based on what row
* and/or column we're above, we'd use "gtk_clist_get_selection_info()"
* and/or column we're above, we'd use "eth_clist_get_selection_info()"
* to find the row and column number for the coordinates; a CTree is,
* I guess, like a CList with one column(?) and the expander widget
* as a pixmap.
*/
/* Check if we are on packet_list object */
if (widget == OBJECT_GET_DATA(popup_menu_object, E_MPACKET_LIST_KEY)) {
packet_list=GTK_CLIST(widget);
if (gtk_clist_get_selection_info(GTK_CLIST(packet_list),
(gint) (((GdkEventButton *)event)->x),
(gint) (((GdkEventButton *)event)->y),
&row,&column)) {
if (packet_list_get_event_row_column(widget, (GdkEventButton *)event,
&row, &column)) {
OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_ROW_KEY,
GINT_TO_POINTER(row));
OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_COL_KEY,

View File

@ -1,7 +1,7 @@
/* packet_list.c
* packet list related functions 2002 Olivier Abad
*
* $Id: packet_list.c,v 1.7 2003/12/09 06:48:40 guy Exp $
* $Id: packet_list.c,v 1.8 2004/01/09 08:36:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -28,31 +28,475 @@
#include <gtk/gtk.h>
#include "globals.h"
#include "gtkglobals.h"
#include "epan/epan.h"
#include "color.h"
#include "../ui_util.h"
#include "ui_util.h"
#include "menu.h"
#include "color_utils.h"
#include "column.h"
#include "epan/column_info.h"
#include "compat_macros.h"
#include "../prefs.h"
#include "file_dlg.h"
#include "packet_list.h"
#include "keys.h"
#include "image/clist_ascend.xpm"
#include "image/clist_descend.xpm"
/*
* XXX - gross hack.
* This lets us use GtkCList in GTK+ 1.3[.x] and later, and EthCList on
* GTK+ 1.2[.x], at least until we either use GTK+ 2.x's native widgets
* or make EthCList work on 1.3[.x] and 2.x.
*/
#if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
#define EthCList GtkCList
#define EthCListRow GtkCListRow
#define eth_clist_append gtk_clist_append
#define eth_clist_clear gtk_clist_clear
#define eth_clist_column_titles_show gtk_clist_column_titles_show
#define eth_clist_find_row_from_data gtk_clist_find_row_from_data
#define eth_clist_freeze gtk_clist_freeze
#define eth_clist_get_row_data gtk_clist_get_row_data
#define eth_clist_get_selection_info gtk_clist_get_selection_info
#define eth_clist_moveto gtk_clist_moveto
#define eth_clist_new gtk_clist_new
#define eth_clist_row_is_visible gtk_clist_row_is_visible
#define eth_clist_select_row gtk_clist_select_row
#define eth_clist_set_background gtk_clist_set_background
#define eth_clist_set_column_auto_resize gtk_clist_set_column_auto_resize
#define eth_clist_set_column_justification gtk_clist_set_column_justification
#define eth_clist_set_column_resizeable gtk_clist_set_column_resizeable
#define eth_clist_set_column_width gtk_clist_set_column_width
#define eth_clist_set_column_widget gtk_clist_set_column_widget
#define eth_clist_set_compare_func gtk_clist_set_compare_func
#define eth_clist_set_foreground gtk_clist_set_foreground
#define eth_clist_set_row_data gtk_clist_set_row_data
#define eth_clist_set_selection_mode gtk_clist_set_selection_mode
#define eth_clist_set_sort_column gtk_clist_set_sort_column
#define eth_clist_set_text gtk_clist_set_text
#define eth_clist_sort gtk_clist_sort
#define eth_clist_thaw gtk_clist_thaw
#define ETH_CLIST GTK_CLIST
#else
#include "ethclist.h"
#endif
typedef struct column_arrows {
GtkWidget *table;
GtkWidget *ascend_pm;
GtkWidget *descend_pm;
} column_arrows;
GtkWidget *packet_list;
/* GTKClist compare routine, overrides default to allow numeric comparison */
static gint
packet_list_compare(EthCList *clist, gconstpointer ptr1, gconstpointer ptr2)
{
/* Get row text strings */
char *text1 = GTK_CELL_TEXT (((const EthCListRow *)ptr1)->cell[clist->sort_column])->text;
char *text2 = GTK_CELL_TEXT (((const EthCListRow *)ptr2)->cell[clist->sort_column])->text;
/* Attempt to convert to numbers */
double num1 = atof(text1);
double num2 = atof(text2);
gint col_fmt = cfile.cinfo.col_fmt[clist->sort_column];
if ((col_fmt == COL_NUMBER) || (col_fmt == COL_REL_TIME) || (col_fmt == COL_DELTA_TIME) ||
((col_fmt == COL_CLS_TIME) && (timestamp_type == RELATIVE)) ||
((col_fmt == COL_CLS_TIME) && (timestamp_type == DELTA)) ||
(col_fmt == COL_UNRES_SRC_PORT) || (col_fmt == COL_UNRES_DST_PORT) ||
((num1 != 0) && (num2 != 0) && ((col_fmt == COL_DEF_SRC_PORT) || (col_fmt == COL_RES_SRC_PORT) ||
(col_fmt == COL_DEF_DST_PORT) || (col_fmt == COL_RES_DST_PORT))) ||
(col_fmt == COL_PACKET_LENGTH) || (col_fmt == COL_CULMULATIVE_BYTES)) {
/* Compare numeric column */
if (num1 < num2)
return -1;
else if (num1 > num2)
return 1;
else
return 0;
}
else {
/* Compare text column */
if (!text2)
return (text1 != NULL);
if (!text1)
return -1;
return strcmp(text1, text2);
}
}
/* What to do when a column is clicked */
static void
packet_list_click_column_cb(EthCList *clist, gint column, gpointer data)
{
column_arrows *col_arrows = (column_arrows *) data;
int i;
eth_clist_freeze(clist);
for (i = 0; i < cfile.cinfo.num_cols; i++) {
gtk_widget_hide(col_arrows[i].ascend_pm);
gtk_widget_hide(col_arrows[i].descend_pm);
}
if (column == clist->sort_column) {
if (clist->sort_type == GTK_SORT_ASCENDING) {
clist->sort_type = GTK_SORT_DESCENDING;
gtk_widget_show(col_arrows[column].descend_pm);
} else {
clist->sort_type = GTK_SORT_ASCENDING;
gtk_widget_show(col_arrows[column].ascend_pm);
}
}
else {
clist->sort_type = GTK_SORT_ASCENDING;
gtk_widget_show(col_arrows[column].ascend_pm);
eth_clist_set_sort_column(clist, column);
}
eth_clist_thaw(clist);
eth_clist_sort(clist);
}
/* What to do when a list item is selected/unselected */
static void
packet_list_select_cb(GtkWidget *w _U_, gint row, gint col _U_, gpointer evt _U_) {
/* Remove the hex display tabbed pages */
while( (gtk_notebook_get_nth_page( GTK_NOTEBOOK(byte_nb_ptr), 0)))
gtk_notebook_remove_page( GTK_NOTEBOOK(byte_nb_ptr), 0);
select_packet(&cfile, row);
gtk_widget_grab_focus(packet_list);
}
static void
packet_list_unselect_cb(GtkWidget *w _U_, gint row _U_, gint col _U_, gpointer evt _U_) {
unselect_packet(&cfile);
}
/* mark packets */
static void
set_frame_mark(gboolean set, frame_data *frame, gint row) {
GdkColor fg, bg;
if (row == -1)
return;
if (set) {
mark_frame(&cfile, frame);
color_t_to_gdkcolor(&fg, &prefs.gui_marked_fg);
color_t_to_gdkcolor(&bg, &prefs.gui_marked_bg);
eth_clist_set_foreground(ETH_CLIST(packet_list), row, &fg);
eth_clist_set_background(ETH_CLIST(packet_list), row, &bg);
} else {
color_filter_t *cfilter = frame->color_filter;
unmark_frame(&cfile, frame);
/* Restore the color from the matching color filter if any */
if (cfilter) { /* The packet matches a color filter */
color_t_to_gdkcolor(&fg, &cfilter->fg_color);
color_t_to_gdkcolor(&bg, &cfilter->bg_color);
eth_clist_set_foreground(ETH_CLIST(packet_list), row, &fg);
eth_clist_set_background(ETH_CLIST(packet_list), row, &bg);
} else { /* No color filter match */
eth_clist_set_foreground(ETH_CLIST(packet_list), row, NULL);
eth_clist_set_background(ETH_CLIST(packet_list), row, NULL);
}
}
file_set_save_marked_sensitive();
}
void mark_frame_cb(GtkWidget *w _U_, gpointer data _U_) {
if (cfile.current_frame) {
/* XXX hum, should better have a "cfile->current_row" here ... */
set_frame_mark(!cfile.current_frame->flags.marked,
cfile.current_frame,
eth_clist_find_row_from_data(ETH_CLIST(packet_list),
cfile.current_frame));
}
}
static void mark_all_frames(gboolean set) {
frame_data *fdata;
cfile.marked_count = 0;
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
set_frame_mark(set,
fdata,
eth_clist_find_row_from_data(ETH_CLIST(packet_list), fdata));
}
}
void update_marked_frames(void) {
frame_data *fdata;
if (cfile.plist == NULL) return;
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
if (fdata->flags.marked)
set_frame_mark(TRUE,
fdata,
eth_clist_find_row_from_data(ETH_CLIST(packet_list),
fdata));
}
}
void mark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_) {
mark_all_frames(TRUE);
}
void unmark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_) {
mark_all_frames(FALSE);
}
gboolean
packet_list_get_event_row_column(GtkWidget *w, GdkEventButton *event_button,
gint *row, gint *column)
{
return eth_clist_get_selection_info(ETH_CLIST(w),
(gint) event_button->x, (gint) event_button->y,
row, column);
}
#if GTK_MAJOR_VERSION < 2
static void
packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
{
GdkEventButton *event_button = (GdkEventButton *)event;
gint row, column;
if (w == NULL || event == NULL)
return;
if (event->type == GDK_BUTTON_PRESS && event_button->button == 2 &&
event_button->window == ETH_CLIST(w)->clist_window &&
packet_list_get_event_row_column(w, event_button, &row, &column)) {
frame_data *fdata = (frame_data *) eth_clist_get_row_data(ETH_CLIST(w),
row);
set_frame_mark(!fdata->flags.marked, fdata, row);
}
}
#else
static gint
packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
{
GdkEventButton *event_button = (GdkEventButton *)event;
gint row, column;
if (w == NULL || event == NULL)
return FALSE;
if (event->type == GDK_BUTTON_PRESS && event_button->button == 2 &&
event_button->window == ETH_CLIST(w)->clist_window &&
eth_clist_get_selection_info(ETH_CLIST(w), (gint) event_button->x,
(gint) event_button->y, &row, &column)) {
frame_data *fdata = (frame_data *)eth_clist_get_row_data(ETH_CLIST(w),
row);
set_frame_mark(!fdata->flags.marked, fdata, row);
return TRUE;
}
return FALSE;
}
#endif
/* Set the selection mode of the packet list window. */
void
set_plist_sel_browse(gboolean val)
{
GtkSelectionMode new_mode;
/* initialize with a mode we don't use, so that the mode == new_mode
* test will fail the first time */
static GtkSelectionMode mode = GTK_SELECTION_MULTIPLE;
/* Yeah, GTK uses "browse" in the case where we do not, but oh well. I
* think "browse" in Ethereal makes more sense than "SINGLE" in GTK+ */
new_mode = val ? GTK_SELECTION_SINGLE : GTK_SELECTION_BROWSE;
if (mode == new_mode) {
/*
* The mode isn't changing, so don't do anything.
* In particular, don't gratuitiously unselect the
* current packet.
*
* XXX - why do we have to unselect the current packet
* ourselves? The documentation for the GtkCList at
*
* http://developer.gnome.org/doc/API/gtk/gtkclist.html
*
* says "Note that setting the widget's selection mode to
* one of GTK_SELECTION_BROWSE or GTK_SELECTION_SINGLE will
* cause all the items in the GtkCList to become deselected."
*/
return;
}
if (cfile.finfo_selected)
unselect_packet(&cfile);
mode = new_mode;
eth_clist_set_selection_mode(ETH_CLIST(packet_list), mode);
}
/* Set the font of the packet list window. */
#if GTK_MAJOR_VERSION < 2
void
set_plist_font(GdkFont *font)
#else
void
set_plist_font(PangoFontDescription *font)
#endif
{
int i;
gint col_width;
#if GTK_MAJOR_VERSION < 2
GtkStyle *style;
style = gtk_style_new();
gdk_font_unref(style->font);
style->font = font;
gdk_font_ref(font);
gtk_widget_set_style(packet_list, style);
#else
PangoLayout *layout;
gtk_widget_modify_font(packet_list, font);
#endif
/* Compute default column sizes. */
for (i = 0; i < cfile.cinfo.num_cols; i++) {
#if GTK_MAJOR_VERSION < 2
col_width = gdk_string_width(font,
get_column_longest_string(get_column_format(i)));
#else
layout = gtk_widget_create_pango_layout(packet_list,
get_column_longest_string(get_column_format(i)));
pango_layout_get_pixel_size(layout, &col_width, NULL);
g_object_unref(G_OBJECT(layout));
#endif
eth_clist_set_column_width(ETH_CLIST(packet_list), i,
col_width);
}
}
void
packet_list_new(GtkWidget *u_pane, e_prefs *prefs, gint pl_size)
{
GtkWidget *pkt_scrollw;
int i;
/* Packet list */
pkt_scrollw = scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(pkt_scrollw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show(pkt_scrollw);
gtk_paned_add1(GTK_PANED(u_pane), pkt_scrollw);
packet_list = eth_clist_new(cfile.cinfo.num_cols);
/* Column titles are filled in below */
gtk_container_add(GTK_CONTAINER(pkt_scrollw), packet_list);
set_plist_sel_browse(prefs->gui_plist_sel_browse);
set_plist_font(m_r_font);
gtk_widget_set_name(packet_list, "packet list");
SIGNAL_CONNECT(packet_list, "select-row", packet_list_select_cb, NULL);
SIGNAL_CONNECT(packet_list, "unselect-row", packet_list_unselect_cb, NULL);
for (i = 0; i < cfile.cinfo.num_cols; i++) {
/* Columns do not automatically resize, but are resizeable by
the user. */
eth_clist_set_column_auto_resize(ETH_CLIST(packet_list), i, FALSE);
eth_clist_set_column_resizeable(ETH_CLIST(packet_list), i, TRUE);
/* Right-justify the packet number column. */
if (cfile.cinfo.col_fmt[i] == COL_NUMBER)
eth_clist_set_column_justification(ETH_CLIST(packet_list), i,
GTK_JUSTIFY_RIGHT);
}
WIDGET_SET_SIZE(packet_list, -1, pl_size);
SIGNAL_CONNECT(packet_list, "button_press_event", popup_menu_handler,
OBJECT_GET_DATA(popup_menu_object, PM_PACKET_LIST_KEY));
SIGNAL_CONNECT(packet_list, "button_press_event",
packet_list_button_pressed_cb, NULL);
eth_clist_set_compare_func(ETH_CLIST(packet_list), packet_list_compare);
gtk_widget_show(packet_list);
}
void
packet_list_set_column_titles(void)
{
GtkStyle *win_style;
GdkPixmap *ascend_pm, *descend_pm;
GdkBitmap *ascend_bm, *descend_bm;
column_arrows *col_arrows;
int i;
GtkWidget *column_lb;
win_style = gtk_widget_get_style(top_level);
ascend_pm = gdk_pixmap_create_from_xpm_d(top_level->window, &ascend_bm,
&win_style->bg[GTK_STATE_NORMAL],
(gchar **)clist_ascend_xpm);
descend_pm = gdk_pixmap_create_from_xpm_d(top_level->window, &descend_bm,
&win_style->bg[GTK_STATE_NORMAL],
(gchar **)clist_descend_xpm);
col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) *
cfile.cinfo.num_cols);
for (i = 0; i < cfile.cinfo.num_cols; i++) {
col_arrows[i].table = gtk_table_new(2, 2, FALSE);
gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
column_lb = gtk_label_new(cfile.cinfo.col_title[i]);
gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show(column_lb);
col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
gtk_table_attach(GTK_TABLE(col_arrows[i].table),
col_arrows[i].ascend_pm,
1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
if (i == 0) {
gtk_widget_show(col_arrows[i].ascend_pm);
}
col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
gtk_table_attach(GTK_TABLE(col_arrows[i].table),
col_arrows[i].descend_pm,
1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
eth_clist_set_column_widget(ETH_CLIST(packet_list), i,
col_arrows[i].table);
gtk_widget_show(col_arrows[i].table);
}
eth_clist_column_titles_show(ETH_CLIST(packet_list));
SIGNAL_CONNECT(packet_list, "click-column", packet_list_click_column_cb,
col_arrows);
}
void
packet_list_clear(void)
{
gtk_clist_clear(GTK_CLIST(packet_list));
eth_clist_clear(ETH_CLIST(packet_list));
}
void
packet_list_freeze(void)
{
gtk_clist_freeze(GTK_CLIST(packet_list));
eth_clist_freeze(ETH_CLIST(packet_list));
}
void
packet_list_thaw(void)
{
gtk_clist_thaw(GTK_CLIST(packet_list));
eth_clist_thaw(ETH_CLIST(packet_list));
}
void
@ -64,8 +508,8 @@ packet_list_select_row(gint row)
void
packet_list_moveto_end(void)
{
gtk_clist_moveto(GTK_CLIST(packet_list),
GTK_CLIST(packet_list)->rows - 1, -1, 1.0, 1.0);
eth_clist_moveto(ETH_CLIST(packet_list),
ETH_CLIST(packet_list)->rows - 1, -1, 1.0, 1.0);
}
gint
@ -73,8 +517,8 @@ 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);
row = eth_clist_append(ETH_CLIST(packet_list), text);
eth_clist_set_row_data(ETH_CLIST(packet_list), row, data);
return row;
}
@ -86,25 +530,25 @@ packet_list_set_colors(gint row, color_t *fg, color_t *bg)
if (fg)
{
color_t_to_gdkcolor(&gdkfg, fg);
gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &gdkfg);
eth_clist_set_foreground(ETH_CLIST(packet_list), row, &gdkfg);
}
if (bg)
{
color_t_to_gdkcolor(&gdkbg, bg);
gtk_clist_set_background(GTK_CLIST(packet_list), row, &gdkbg);
eth_clist_set_background(ETH_CLIST(packet_list), row, &gdkbg);
}
}
gint
packet_list_find_row_from_data(gpointer data)
{
return gtk_clist_find_row_from_data(GTK_CLIST(packet_list), data);
return eth_clist_find_row_from_data(ETH_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);
eth_clist_set_text(ETH_CLIST(packet_list), row, column, text);
}
/* Set the column widths of those columns that show the time in
@ -127,13 +571,13 @@ packet_list_set_cls_time_width(gint column)
pango_layout_get_pixel_size(layout, &width, NULL);
g_object_unref(G_OBJECT(layout));
#endif
gtk_clist_set_column_width(GTK_CLIST(packet_list), column, width);
eth_clist_set_column_width(ETH_CLIST(packet_list), column, width);
}
gpointer
packet_list_get_row_data(gint row)
{
return gtk_clist_get_row_data(GTK_CLIST(packet_list), row);
return eth_clist_get_row_data(ETH_CLIST(packet_list), row);
}
/* Set the selected row and the focus row of the packet list to the specified
@ -141,23 +585,23 @@ packet_list_get_row_data(gint row)
void
packet_list_set_selected_row(gint row)
{
if (gtk_clist_row_is_visible(GTK_CLIST(packet_list), row) !=
if (eth_clist_row_is_visible(ETH_CLIST(packet_list), row) !=
GTK_VISIBILITY_FULL)
gtk_clist_moveto(GTK_CLIST(packet_list), row, -1, 0.0, 0.0);
eth_clist_moveto(ETH_CLIST(packet_list), row, -1, 0.0, 0.0);
/* XXX - why is there no "gtk_clist_set_focus_row()", so that we
/* XXX - why is there no "eth_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;
ETH_CLIST(packet_list)->focus_row = row;
gtk_clist_select_row(GTK_CLIST(packet_list), row, -1);
eth_clist_select_row(ETH_CLIST(packet_list), row, -1);
}
/* Return the column number that the clist is currently sorted by */
gint
packet_list_get_sort_column(void)
{
return GTK_CLIST(packet_list)->sort_column;
return ETH_CLIST(packet_list)->sort_column;
}

47
gtk/packet_list.h Normal file
View File

@ -0,0 +1,47 @@
/* packet_list.h
* Declarations of GTK+-specific routines for managing the packet list.
*
* $Id: packet_list.h,v 1.1 2004/01/09 08:36:23 guy Exp $
*
* 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 __PACKET_LIST_H__
#define __PACKET_LIST_H__
extern void packet_list_new(GtkWidget *u_pane, e_prefs *prefs, gint pl_size);
extern void packet_list_set_column_titles(void);
extern void mark_frame_cb(GtkWidget *, gpointer);
extern void mark_all_frames_cb(GtkWidget *w, gpointer);
extern void unmark_all_frames_cb(GtkWidget *w, gpointer);
extern void update_marked_frames(void);
extern gboolean packet_list_get_event_row_column(GtkWidget *w,
GdkEventButton *event_button, gint *row, gint *column);
#if GTK_MAJOR_VERSION < 2
extern void set_plist_font(GdkFont *font);
#else
extern void set_plist_font(PangoFontDescription *font);
#endif
extern void set_plist_sel_browse(gboolean);
#endif /* __PACKET_LIST_H__ */