1999-03-23 03:14:46 +00:00
|
|
|
/* gtkpacket.c
|
|
|
|
* Routines for GTK+ packet display
|
|
|
|
*
|
2000-04-27 20:39:21 +00:00
|
|
|
* $Id: proto_draw.c,v 1.17 2000/04/27 20:39:21 guy Exp $
|
1999-03-23 03:14:46 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* 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
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
1999-03-23 03:54:46 +00:00
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
1999-03-23 19:41:51 +00:00
|
|
|
#include <stdio.h>
|
1999-09-09 02:42:40 +00:00
|
|
|
#include "main.h"
|
1999-03-23 03:14:46 +00:00
|
|
|
#include "packet.h"
|
1999-11-22 06:24:56 +00:00
|
|
|
#include "util.h"
|
1999-03-23 03:14:46 +00:00
|
|
|
|
2000-02-29 06:24:41 +00:00
|
|
|
#include "prefs.h"
|
1999-09-09 02:42:40 +00:00
|
|
|
#include "proto_draw.h"
|
2000-02-29 06:24:41 +00:00
|
|
|
#include "gtkglobals.h"
|
1999-03-23 03:14:46 +00:00
|
|
|
|
|
|
|
#define BYTE_VIEW_WIDTH 16
|
1999-04-16 18:39:07 +00:00
|
|
|
#define BYTE_VIEW_SEP 8
|
1999-03-23 03:14:46 +00:00
|
|
|
|
|
|
|
extern GdkFont *m_r_font, *m_b_font;
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
static void
|
|
|
|
proto_tree_draw_node(GNode *node, gpointer data);
|
|
|
|
|
2000-02-29 06:24:41 +00:00
|
|
|
void
|
|
|
|
create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
|
2000-03-02 07:05:57 +00:00
|
|
|
GtkWidget **bv_scrollw_p, int pos)
|
2000-02-29 06:24:41 +00:00
|
|
|
{
|
2000-03-02 07:05:57 +00:00
|
|
|
GtkWidget *byte_view, *byte_scrollw;
|
|
|
|
|
|
|
|
/* Byte view. Create a scrolled window for the text. */
|
|
|
|
byte_scrollw = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_paned_pack2(GTK_PANED(pane), byte_scrollw, FALSE, FALSE);
|
|
|
|
gtk_widget_set_usize(byte_scrollw, -1, bv_size);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(byte_scrollw),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_ALWAYS);
|
|
|
|
set_scrollbar_placement_scrollw(byte_scrollw, pos);
|
|
|
|
remember_scrolled_window(byte_scrollw);
|
|
|
|
gtk_widget_show(byte_scrollw);
|
2000-02-29 06:24:41 +00:00
|
|
|
|
|
|
|
byte_view = gtk_text_new(NULL, NULL);
|
|
|
|
gtk_text_set_editable(GTK_TEXT(byte_view), FALSE);
|
|
|
|
gtk_text_set_word_wrap(GTK_TEXT(byte_view), FALSE);
|
2000-03-02 07:05:57 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(byte_scrollw), byte_view);
|
2000-02-29 06:24:41 +00:00
|
|
|
gtk_widget_show(byte_view);
|
|
|
|
|
|
|
|
*byte_view_p = byte_view;
|
2000-03-02 07:05:57 +00:00
|
|
|
*bv_scrollw_p = byte_scrollw;
|
2000-02-29 06:24:41 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
void
|
1999-11-22 06:24:56 +00:00
|
|
|
packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
|
|
|
|
char_enc encoding) {
|
1999-03-23 03:14:46 +00:00
|
|
|
gint i = 0, j, k, cur;
|
2000-04-27 20:39:21 +00:00
|
|
|
guchar line[128], hexchars[] = "0123456789abcdef", c = '\0';
|
1999-03-23 03:14:46 +00:00
|
|
|
GdkFont *cur_font, *new_font;
|
1999-12-14 06:52:09 +00:00
|
|
|
gint bend = -1;
|
1999-11-22 06:24:56 +00:00
|
|
|
|
1999-12-03 21:28:58 +00:00
|
|
|
/* Freeze the text for faster display */
|
|
|
|
gtk_text_freeze(bv);
|
|
|
|
|
|
|
|
/* Clear out the text */
|
|
|
|
gtk_text_set_point(bv, 0);
|
2000-01-25 03:45:45 +00:00
|
|
|
/* Keep GTK+ 1.2.3 through 1.2.6 from dumping core - see
|
|
|
|
http://ethereal.zing.org/lists/ethereal-dev/199912/msg00312.html and
|
|
|
|
http://www.gnome.org/mailing-lists/archives/gtk-devel-list/1999-October/0051.shtml
|
|
|
|
for more information */
|
|
|
|
gtk_adjustment_set_value(bv->vadj, 0.0);
|
1999-12-03 21:28:58 +00:00
|
|
|
gtk_text_forward_delete(bv, gtk_text_get_length(bv));
|
|
|
|
|
1999-12-14 06:52:09 +00:00
|
|
|
if (bstart >= 0 && blen >= 0) {
|
|
|
|
bend = bstart + blen;
|
|
|
|
}
|
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
while (i < len) {
|
|
|
|
/* Print the line number */
|
|
|
|
sprintf(line, "%04x ", i);
|
|
|
|
gtk_text_insert(bv, m_r_font, NULL, NULL, line, -1);
|
|
|
|
/* Do we start in bold? */
|
1999-12-12 05:11:57 +00:00
|
|
|
cur_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
|
1999-03-23 03:14:46 +00:00
|
|
|
j = i;
|
|
|
|
k = i + BYTE_VIEW_WIDTH;
|
|
|
|
cur = 0;
|
|
|
|
/* Print the hex bit */
|
|
|
|
while (i < k) {
|
|
|
|
if (i < len) {
|
|
|
|
line[cur++] = hexchars[(pd[i] & 0xf0) >> 4];
|
|
|
|
line[cur++] = hexchars[pd[i] & 0x0f];
|
|
|
|
} else {
|
|
|
|
line[cur++] = ' '; line[cur++] = ' ';
|
|
|
|
}
|
|
|
|
line[cur++] = ' ';
|
|
|
|
i++;
|
1999-04-16 18:39:07 +00:00
|
|
|
/* insert a space every BYTE_VIEW_SEP bytes */
|
|
|
|
if( ( i % BYTE_VIEW_SEP ) == 0 ) line[cur++] = ' ';
|
1999-03-23 03:14:46 +00:00
|
|
|
/* Did we cross a bold/plain boundary? */
|
1999-12-12 05:11:57 +00:00
|
|
|
new_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
|
1999-03-23 03:14:46 +00:00
|
|
|
if (cur_font != new_font) {
|
|
|
|
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
|
|
|
|
cur_font = new_font;
|
|
|
|
cur = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line[cur++] = ' ';
|
|
|
|
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
|
1999-11-22 06:24:56 +00:00
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
cur = 0;
|
|
|
|
i = j;
|
|
|
|
/* Print the ASCII bit */
|
1999-12-12 05:11:57 +00:00
|
|
|
cur_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
|
1999-03-23 03:14:46 +00:00
|
|
|
while (i < k) {
|
|
|
|
if (i < len) {
|
1999-11-22 06:24:56 +00:00
|
|
|
if (encoding == CHAR_ASCII) {
|
|
|
|
c = pd[i];
|
|
|
|
}
|
|
|
|
else if (encoding == CHAR_EBCDIC) {
|
|
|
|
c = EBCDIC_to_ASCII1(pd[i]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2000-04-27 20:39:21 +00:00
|
|
|
line[cur++] = (isprint(c)) ? c : '.';
|
1999-03-23 03:14:46 +00:00
|
|
|
} else {
|
|
|
|
line[cur++] = ' ';
|
|
|
|
}
|
|
|
|
i++;
|
1999-04-16 18:39:07 +00:00
|
|
|
/* insert a space every BYTE_VIEW_SEP bytes */
|
|
|
|
if( ( i % BYTE_VIEW_SEP ) == 0 ) line[cur++] = ' ';
|
1999-03-23 03:14:46 +00:00
|
|
|
/* Did we cross a bold/plain boundary? */
|
1999-12-12 05:11:57 +00:00
|
|
|
new_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
|
1999-03-23 03:14:46 +00:00
|
|
|
if (cur_font != new_font) {
|
|
|
|
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
|
|
|
|
cur_font = new_font;
|
|
|
|
cur = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line[cur++] = '\n';
|
|
|
|
line[cur] = '\0';
|
|
|
|
gtk_text_insert(bv, cur_font, NULL, NULL, line, -1);
|
|
|
|
}
|
1999-12-03 21:28:58 +00:00
|
|
|
|
|
|
|
/* scroll text into position */
|
|
|
|
gtk_text_thaw(bv); /* must thaw before adjusting scroll bars */
|
|
|
|
if ( bstart > 0 ) {
|
1999-12-14 06:52:09 +00:00
|
|
|
int lineheight, linenum;
|
|
|
|
float scrollval;
|
1999-12-03 21:28:58 +00:00
|
|
|
linenum = bstart / BYTE_VIEW_WIDTH;
|
|
|
|
|
|
|
|
/* need to change to some way of getting that offset instead of +4 */
|
|
|
|
lineheight = gdk_string_height(m_b_font, "0") + 4;
|
|
|
|
scrollval = MIN(linenum * lineheight,bv->vadj->upper - bv->vadj->page_size);
|
|
|
|
|
|
|
|
gtk_adjustment_set_value(bv->vadj, scrollval);
|
|
|
|
}
|
1999-03-23 03:14:46 +00:00
|
|
|
}
|
|
|
|
|
2000-02-29 06:24:41 +00:00
|
|
|
void
|
|
|
|
create_tree_view(gint tv_size, e_prefs *prefs, GtkWidget *pane,
|
2000-03-02 07:05:57 +00:00
|
|
|
GtkWidget **tv_scrollw_p, GtkWidget **tree_view_p, int pos)
|
2000-02-29 06:24:41 +00:00
|
|
|
{
|
|
|
|
GtkWidget *tv_scrollw, *tree_view;
|
|
|
|
|
|
|
|
/* Tree view */
|
|
|
|
tv_scrollw = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(tv_scrollw),
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
2000-03-02 07:05:57 +00:00
|
|
|
set_scrollbar_placement_scrollw(tv_scrollw, pos);
|
|
|
|
remember_scrolled_window(tv_scrollw);
|
2000-02-29 06:24:41 +00:00
|
|
|
gtk_paned_pack1(GTK_PANED(pane), tv_scrollw, TRUE, TRUE);
|
|
|
|
gtk_widget_set_usize(tv_scrollw, -1, tv_size);
|
|
|
|
gtk_widget_show(tv_scrollw);
|
|
|
|
|
|
|
|
tree_view = gtk_ctree_new(1, 0);
|
|
|
|
/* I need this next line to make the widget work correctly with hidden
|
|
|
|
* column titles and GTK_SELECTION_BROWSE */
|
|
|
|
gtk_clist_set_column_auto_resize( GTK_CLIST(tree_view), 0, TRUE );
|
|
|
|
gtk_container_add( GTK_CONTAINER(tv_scrollw), tree_view );
|
|
|
|
set_ptree_sel_browse(tree_view, prefs->gui_ptree_sel_browse);
|
|
|
|
set_ptree_line_style(tree_view, prefs->gui_ptree_line_style);
|
|
|
|
set_ptree_expander_style(tree_view, prefs->gui_ptree_expander_style);
|
|
|
|
|
|
|
|
*tree_view_p = tree_view;
|
|
|
|
*tv_scrollw_p = tv_scrollw;
|
|
|
|
}
|
|
|
|
|
1999-09-11 12:38:18 +00:00
|
|
|
void expand_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view) {
|
|
|
|
int i;
|
1999-11-16 11:44:20 +00:00
|
|
|
for(i=0; i < num_tree_types; i++) {
|
1999-09-12 20:23:43 +00:00
|
|
|
tree_is_expanded[i] = TRUE;
|
1999-09-11 12:38:18 +00:00
|
|
|
}
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
gtk_clist_clear ( GTK_CLIST(tree_view) );
|
1999-09-11 12:38:18 +00:00
|
|
|
proto_tree_draw(protocol_tree, tree_view);
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
gtk_ctree_expand_recursive(GTK_CTREE(tree_view), NULL);
|
1999-09-11 12:38:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void collapse_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view) {
|
|
|
|
int i;
|
1999-11-16 11:44:20 +00:00
|
|
|
for(i=0; i < num_tree_types; i++) {
|
1999-09-12 20:23:43 +00:00
|
|
|
tree_is_expanded[i] = FALSE;
|
1999-09-11 12:38:18 +00:00
|
|
|
}
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
gtk_clist_clear ( GTK_CLIST(tree_view) );
|
1999-12-15 07:03:11 +00:00
|
|
|
proto_tree_draw(protocol_tree, tree_view);
|
1999-09-11 12:38:18 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
static void
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
expand_tree(GtkCTree *ctree, GList *node, gpointer user_data)
|
|
|
|
{
|
|
|
|
field_info *finfo;
|
|
|
|
gboolean *val;
|
1999-03-23 03:14:46 +00:00
|
|
|
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
finfo = gtk_ctree_node_get_row_data( ctree, GTK_CTREE_NODE(node) );
|
|
|
|
g_assert(finfo);
|
|
|
|
|
|
|
|
val = &tree_is_expanded[finfo->tree_type];
|
|
|
|
*val = TRUE;
|
1999-03-23 03:14:46 +00:00
|
|
|
}
|
|
|
|
|
1999-12-15 07:03:11 +00:00
|
|
|
static void
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
collapse_tree(GtkCTree *ctree, GList *node, gpointer user_data)
|
1999-03-23 03:14:46 +00:00
|
|
|
{
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
field_info *finfo;
|
|
|
|
gboolean *val;
|
|
|
|
|
|
|
|
finfo = gtk_ctree_node_get_row_data( ctree, GTK_CTREE_NODE(node) );
|
|
|
|
g_assert(finfo);
|
|
|
|
|
|
|
|
val = &tree_is_expanded[finfo->tree_type];
|
|
|
|
*val = FALSE;
|
1999-12-15 07:03:11 +00:00
|
|
|
}
|
1999-03-23 03:14:46 +00:00
|
|
|
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
struct proto_tree_draw_info {
|
|
|
|
GtkCTree *ctree;
|
|
|
|
GtkCTreeNode *ctree_node;
|
|
|
|
};
|
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
void
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view)
|
1999-03-23 03:14:46 +00:00
|
|
|
{
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
struct proto_tree_draw_info info;
|
|
|
|
|
|
|
|
info.ctree = GTK_CTREE(tree_view);
|
|
|
|
info.ctree_node = NULL;
|
|
|
|
|
|
|
|
gtk_clist_freeze ( GTK_CLIST(tree_view) );
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
g_node_children_foreach((GNode*) protocol_tree, G_TRAVERSE_ALL,
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
proto_tree_draw_node, &info);
|
|
|
|
|
|
|
|
gtk_signal_connect( GTK_OBJECT(info.ctree), "tree-expand",
|
|
|
|
(GtkSignalFunc) expand_tree, NULL );
|
|
|
|
gtk_signal_connect( GTK_OBJECT(info.ctree), "tree-collapse",
|
|
|
|
(GtkSignalFunc) collapse_tree, NULL );
|
|
|
|
|
|
|
|
gtk_clist_thaw ( GTK_CLIST(tree_view) );
|
1999-03-23 03:14:46 +00:00
|
|
|
}
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
static void
|
|
|
|
proto_tree_draw_node(GNode *node, gpointer data)
|
1999-03-23 03:14:46 +00:00
|
|
|
{
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
struct proto_tree_draw_info info;
|
|
|
|
struct proto_tree_draw_info *parent_info = (struct proto_tree_draw_info*) data;
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
field_info *fi = (field_info*) (node->data);
|
|
|
|
gchar label_str[ITEM_LABEL_LENGTH];
|
|
|
|
gchar *label_ptr;
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
GtkCTreeNode *parent;
|
|
|
|
gboolean is_leaf, is_expanded;
|
1999-07-07 22:52:57 +00:00
|
|
|
|
|
|
|
if (!fi->visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* was a free format label produced? */
|
|
|
|
if (fi->representation) {
|
|
|
|
label_ptr = fi->representation;
|
|
|
|
}
|
|
|
|
else { /* no, make a generic label */
|
|
|
|
label_ptr = label_str;
|
|
|
|
proto_item_fill_label(fi, label_str);
|
|
|
|
}
|
1999-12-15 06:53:36 +00:00
|
|
|
|
1999-12-15 07:03:11 +00:00
|
|
|
if (g_node_n_children(node) > 0) {
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
is_leaf = FALSE;
|
|
|
|
if (tree_is_expanded[fi->tree_type]) {
|
|
|
|
is_expanded = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
is_expanded = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
is_leaf = TRUE;
|
|
|
|
is_expanded = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.ctree = parent_info->ctree;
|
|
|
|
parent = gtk_ctree_insert_node ( info.ctree, parent_info->ctree_node, NULL,
|
|
|
|
&label_ptr, 5, NULL, NULL, NULL, NULL,
|
|
|
|
is_leaf, is_expanded );
|
|
|
|
|
|
|
|
gtk_ctree_node_set_row_data( GTK_CTREE(info.ctree), parent, fi );
|
|
|
|
gtk_ctree_node_set_row_style( GTK_CTREE(info.ctree), parent, item_style);
|
1999-07-07 22:52:57 +00:00
|
|
|
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
if (!is_leaf) {
|
|
|
|
info.ctree_node = parent;
|
1999-07-07 22:52:57 +00:00
|
|
|
g_node_children_foreach(node, G_TRAVERSE_ALL,
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
proto_tree_draw_node, &info);
|
1999-07-07 22:52:57 +00:00
|
|
|
}
|
1999-03-23 03:14:46 +00:00
|
|
|
}
|