forked from osmocom/wireshark
using text files from help dir, to display the help texts.
the "dynamic protocol fields" are already moved to gtk/supported_protos_dlg.c svn path=/trunk/; revision=9098
This commit is contained in:
parent
4c5b5d8d51
commit
2cd8629c86
535
gtk/help_dlg.c
535
gtk/help_dlg.c
|
@ -1,6 +1,6 @@
|
||||||
/* help_dlg.c
|
/* help_dlg.c
|
||||||
*
|
*
|
||||||
* $Id: help_dlg.c,v 1.36 2003/11/16 23:17:26 guy Exp $
|
* $Id: help_dlg.c,v 1.37 2003/11/27 00:22:12 ulfl Exp $
|
||||||
*
|
*
|
||||||
* Laurent Deniel <laurent.deniel@free.fr>
|
* Laurent Deniel <laurent.deniel@free.fr>
|
||||||
*
|
*
|
||||||
|
@ -29,25 +29,28 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#ifdef NEED_SNPRINTF_H
|
|
||||||
# include "snprintf.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "help_dlg.h"
|
#include "help_dlg.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "globals.h"
|
|
||||||
#include "gtkglobals.h"
|
#include "gtkglobals.h"
|
||||||
#include "main.h"
|
|
||||||
#include "ui_util.h"
|
#include "ui_util.h"
|
||||||
#include <epan/proto.h>
|
|
||||||
#include "compat_macros.h"
|
#include "compat_macros.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* include texts from converted ascii ".txt" files */
|
||||||
|
#include "../help/overview.h"
|
||||||
|
#include "../help/capture_filters.h"
|
||||||
|
#include "../help/display_filters.h"
|
||||||
|
#include "../help/well_known.h"
|
||||||
|
#include "../help/faq.h"
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OVERVIEW_HELP,
|
OVERVIEW_HELP,
|
||||||
PROTOCOL_HELP,
|
|
||||||
DFILTER_HELP,
|
|
||||||
CFILTER_HELP,
|
CFILTER_HELP,
|
||||||
|
DFILTER_HELP,
|
||||||
|
WELL_KNOWN_HELP,
|
||||||
FAQ_HELP
|
FAQ_HELP
|
||||||
} help_type_t;
|
} help_type_t;
|
||||||
|
|
||||||
|
@ -65,23 +68,57 @@ static void set_help_text(GtkWidget *w, help_type_t type);
|
||||||
static GtkWidget *help_w = NULL;
|
static GtkWidget *help_w = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keep static pointers to the text widgets as well.
|
* Keep static pointers to the text widgets as well (for text format changes).
|
||||||
*/
|
*/
|
||||||
GtkWidget *overview_text, *proto_text, *dfilter_text, *faq_text, *cfilter_text;
|
static GtkWidget *overview_text, *cfilter_text, *dfilter_text;
|
||||||
|
static GtkWidget *well_known_text, *faq_text;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper function to show a simple help text page.
|
||||||
|
*/
|
||||||
|
static GtkWidget * help_page(help_type_t page_type, GtkWidget **page_text)
|
||||||
|
{
|
||||||
|
GtkWidget *page_vb, *txt_scrollw;
|
||||||
|
|
||||||
|
page_vb = gtk_vbox_new(FALSE, 0);
|
||||||
|
gtk_container_border_width(GTK_CONTAINER(page_vb), 1);
|
||||||
|
txt_scrollw = scrolled_window_new(NULL, NULL);
|
||||||
|
gtk_box_pack_start(GTK_BOX(page_vb), txt_scrollw, TRUE, TRUE, 0);
|
||||||
|
#if GTK_MAJOR_VERSION < 2
|
||||||
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
||||||
|
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
||||||
|
*page_text = gtk_text_new(NULL, NULL );
|
||||||
|
gtk_text_set_editable(GTK_TEXT(*page_text), FALSE);
|
||||||
|
gtk_text_set_word_wrap(GTK_TEXT(*page_text), TRUE);
|
||||||
|
gtk_text_set_line_wrap(GTK_TEXT(*page_text), TRUE);
|
||||||
|
#else
|
||||||
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
||||||
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||||
|
*page_text = gtk_text_view_new();
|
||||||
|
gtk_text_view_set_editable(GTK_TEXT_VIEW(*page_text), FALSE);
|
||||||
|
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(*page_text), GTK_WRAP_WORD);
|
||||||
|
#endif
|
||||||
|
set_help_text(*page_text, page_type);
|
||||||
|
gtk_container_add(GTK_CONTAINER(txt_scrollw), *page_text);
|
||||||
|
gtk_widget_show(txt_scrollw);
|
||||||
|
gtk_widget_show(*page_text);
|
||||||
|
gtk_widget_show(page_vb);
|
||||||
|
|
||||||
|
return page_vb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void help_cb(GtkWidget *w _U_, gpointer data _U_)
|
void help_cb(GtkWidget *w _U_, gpointer data _U_)
|
||||||
{
|
{
|
||||||
|
|
||||||
GtkWidget *main_vb, *bbox, *help_nb, *close_bt, *label, *txt_scrollw,
|
GtkWidget *main_vb, *bbox, *help_nb, *close_bt, *label,
|
||||||
*overview_vb,
|
*overview_vb,
|
||||||
*proto_vb,
|
*cfilter_vb,
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
*dfilter_tb, *dfilter_vsb,
|
|
||||||
#else
|
|
||||||
*dfilter_vb,
|
*dfilter_vb,
|
||||||
#endif
|
*well_known_vb,
|
||||||
*faq_vb,
|
*faq_vb;
|
||||||
*cfilter_vb;
|
|
||||||
|
|
||||||
if (help_w != NULL) {
|
if (help_w != NULL) {
|
||||||
/* There's already a "Help" dialog box; reactivate it. */
|
/* There's already a "Help" dialog box; reactivate it. */
|
||||||
|
@ -98,214 +135,43 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_)
|
||||||
gtk_window_set_title(GTK_WINDOW(help_w), "Ethereal: Help");
|
gtk_window_set_title(GTK_WINDOW(help_w), "Ethereal: Help");
|
||||||
SIGNAL_CONNECT(help_w, "destroy", help_destroy_cb, NULL);
|
SIGNAL_CONNECT(help_w, "destroy", help_destroy_cb, NULL);
|
||||||
SIGNAL_CONNECT(help_w, "realize", window_icon_realize_cb, NULL);
|
SIGNAL_CONNECT(help_w, "realize", window_icon_realize_cb, NULL);
|
||||||
|
/* XXX: improve this, e.g. remember the last window size in a file */
|
||||||
WIDGET_SET_SIZE(help_w, DEF_WIDTH * 2/3, DEF_HEIGHT * 2/3);
|
WIDGET_SET_SIZE(help_w, DEF_WIDTH * 2/3, DEF_HEIGHT * 2/3);
|
||||||
gtk_container_border_width(GTK_CONTAINER(help_w), 2);
|
gtk_container_border_width(GTK_CONTAINER(help_w), 2);
|
||||||
|
|
||||||
/* Container for each row of widgets */
|
/* Container for each row of widgets */
|
||||||
|
|
||||||
main_vb = gtk_vbox_new(FALSE, 1);
|
main_vb = gtk_vbox_new(FALSE, 1);
|
||||||
gtk_container_border_width(GTK_CONTAINER(main_vb), 1);
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 1);
|
||||||
gtk_container_add(GTK_CONTAINER(help_w), main_vb);
|
gtk_container_add(GTK_CONTAINER(help_w), main_vb);
|
||||||
gtk_widget_show(main_vb);
|
gtk_widget_show(main_vb);
|
||||||
|
|
||||||
/* help topics container */
|
/* help topics container */
|
||||||
|
|
||||||
help_nb = gtk_notebook_new();
|
help_nb = gtk_notebook_new();
|
||||||
gtk_container_add(GTK_CONTAINER(main_vb), help_nb);
|
gtk_container_add(GTK_CONTAINER(main_vb), help_nb);
|
||||||
|
|
||||||
/* Overview panel */
|
|
||||||
|
|
||||||
overview_vb = gtk_vbox_new(FALSE, 0);
|
/* Overview panel */
|
||||||
gtk_container_border_width(GTK_CONTAINER(overview_vb), 1);
|
overview_vb = help_page(OVERVIEW_HELP, &overview_text);
|
||||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
|
||||||
gtk_box_pack_start(GTK_BOX(overview_vb), txt_scrollw, TRUE, TRUE, 0);
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_NEVER,
|
|
||||||
GTK_POLICY_ALWAYS);
|
|
||||||
overview_text = gtk_text_new(NULL, NULL );
|
|
||||||
gtk_text_set_editable(GTK_TEXT(overview_text), FALSE);
|
|
||||||
gtk_text_set_word_wrap(GTK_TEXT(overview_text), TRUE);
|
|
||||||
gtk_text_set_line_wrap(GTK_TEXT(overview_text), TRUE);
|
|
||||||
#else
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_AUTOMATIC,
|
|
||||||
GTK_POLICY_AUTOMATIC);
|
|
||||||
overview_text = gtk_text_view_new();
|
|
||||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(overview_text), FALSE);
|
|
||||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(overview_text), GTK_WRAP_WORD);
|
|
||||||
#endif
|
|
||||||
set_help_text(overview_text, OVERVIEW_HELP);
|
|
||||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), overview_text);
|
|
||||||
gtk_widget_show(txt_scrollw);
|
|
||||||
gtk_widget_show(overview_text);
|
|
||||||
gtk_widget_show(overview_vb);
|
|
||||||
label = gtk_label_new("Overview");
|
label = gtk_label_new("Overview");
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), overview_vb, label);
|
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), overview_vb, label);
|
||||||
|
|
||||||
/* humm, gtk 1.2 does not support horizontal scrollbar for text widgets */
|
|
||||||
|
|
||||||
/* protocol list */
|
|
||||||
|
|
||||||
proto_vb = gtk_vbox_new(FALSE, 0);
|
|
||||||
gtk_container_border_width(GTK_CONTAINER(proto_vb), 1);
|
|
||||||
|
|
||||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
|
||||||
gtk_box_pack_start(GTK_BOX(proto_vb), txt_scrollw, TRUE, TRUE, 0);
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_ALWAYS,
|
|
||||||
GTK_POLICY_ALWAYS);
|
|
||||||
proto_text = gtk_text_new(NULL, NULL);
|
|
||||||
gtk_text_set_editable(GTK_TEXT(proto_text), FALSE);
|
|
||||||
gtk_text_set_line_wrap(GTK_TEXT(proto_text), FALSE);
|
|
||||||
set_help_text(proto_text, PROTOCOL_HELP);
|
|
||||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
proto_text);
|
|
||||||
#else
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_AUTOMATIC,
|
|
||||||
GTK_POLICY_AUTOMATIC);
|
|
||||||
proto_text = gtk_text_view_new();
|
|
||||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(proto_text), FALSE);
|
|
||||||
set_help_text(proto_text, PROTOCOL_HELP);
|
|
||||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), proto_text);
|
|
||||||
#endif
|
|
||||||
gtk_widget_show(txt_scrollw);
|
|
||||||
gtk_widget_show(proto_text);
|
|
||||||
gtk_widget_show(proto_vb);
|
|
||||||
label = gtk_label_new("Protocols");
|
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), proto_vb, label);
|
|
||||||
|
|
||||||
/* display filter help */
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
/* X windows have a maximum size of 32767. Since the height can easily
|
|
||||||
exceed this, we have to jump through some hoops to have a functional
|
|
||||||
vertical scroll bar. */
|
|
||||||
|
|
||||||
dfilter_tb = gtk_table_new(2, 2, FALSE);
|
|
||||||
gtk_table_set_col_spacing (GTK_TABLE (dfilter_tb), 0, 3);
|
|
||||||
gtk_table_set_row_spacing (GTK_TABLE (dfilter_tb), 0, 3);
|
|
||||||
gtk_container_border_width(GTK_CONTAINER(dfilter_tb), 1);
|
|
||||||
|
|
||||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_ALWAYS,
|
|
||||||
GTK_POLICY_NEVER);
|
|
||||||
dfilter_text = gtk_text_new(NULL, NULL);
|
|
||||||
dfilter_vsb = gtk_vscrollbar_new(GTK_TEXT(dfilter_text)->vadj);
|
|
||||||
if (prefs.gui_scrollbar_on_right) {
|
|
||||||
gtk_table_attach (GTK_TABLE (dfilter_tb), txt_scrollw, 0, 1, 0, 1,
|
|
||||||
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
|
||||||
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
|
||||||
gtk_table_attach (GTK_TABLE (dfilter_tb), dfilter_vsb, 1, 2, 0, 1,
|
|
||||||
GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
||||||
} else {
|
|
||||||
gtk_table_attach (GTK_TABLE (dfilter_tb), txt_scrollw, 1, 2, 0, 1,
|
|
||||||
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
|
||||||
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
|
||||||
gtk_table_attach (GTK_TABLE (dfilter_tb), dfilter_vsb, 0, 1, 0, 1,
|
|
||||||
GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
||||||
}
|
|
||||||
gtk_text_set_editable(GTK_TEXT(dfilter_text), FALSE);
|
|
||||||
gtk_text_set_line_wrap(GTK_TEXT(dfilter_text), FALSE);
|
|
||||||
set_help_text(dfilter_text, DFILTER_HELP);
|
|
||||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
dfilter_text);
|
|
||||||
#else
|
|
||||||
dfilter_vb = gtk_vbox_new(FALSE, 0);
|
|
||||||
gtk_container_border_width(GTK_CONTAINER(dfilter_vb), 1);
|
|
||||||
|
|
||||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
|
||||||
gtk_box_pack_start(GTK_BOX(dfilter_vb), txt_scrollw, TRUE, TRUE, 0);
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_AUTOMATIC,
|
|
||||||
GTK_POLICY_AUTOMATIC);
|
|
||||||
dfilter_text = gtk_text_view_new();
|
|
||||||
if (prefs.gui_scrollbar_on_right) {
|
|
||||||
gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_CORNER_TOP_LEFT);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_CORNER_TOP_RIGHT);
|
|
||||||
}
|
|
||||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(dfilter_text), FALSE);
|
|
||||||
set_help_text(dfilter_text, DFILTER_HELP);
|
|
||||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), dfilter_text);
|
|
||||||
#endif
|
|
||||||
gtk_widget_show(txt_scrollw);
|
|
||||||
gtk_widget_show(dfilter_text);
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
gtk_widget_show(dfilter_tb);
|
|
||||||
gtk_widget_show(dfilter_vsb);
|
|
||||||
#else
|
|
||||||
gtk_widget_show(dfilter_vb);
|
|
||||||
#endif
|
|
||||||
label = gtk_label_new("Display Filters");
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), dfilter_tb, label);
|
|
||||||
#else
|
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), dfilter_vb, label);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* capture filter help (this one has no horizontal scrollbar) */
|
/* capture filter help (this one has no horizontal scrollbar) */
|
||||||
|
cfilter_vb = help_page(CFILTER_HELP, &cfilter_text);
|
||||||
cfilter_vb = gtk_vbox_new(FALSE, 0);
|
|
||||||
gtk_container_border_width(GTK_CONTAINER(cfilter_vb), 1);
|
|
||||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
|
||||||
gtk_box_pack_start(GTK_BOX(cfilter_vb), txt_scrollw, TRUE, TRUE, 0);
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_NEVER,
|
|
||||||
GTK_POLICY_ALWAYS);
|
|
||||||
cfilter_text = gtk_text_new(NULL, NULL );
|
|
||||||
gtk_text_set_editable(GTK_TEXT(cfilter_text), FALSE);
|
|
||||||
gtk_text_set_word_wrap(GTK_TEXT(cfilter_text), TRUE);
|
|
||||||
gtk_text_set_line_wrap(GTK_TEXT(cfilter_text), TRUE);
|
|
||||||
#else
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_NEVER,
|
|
||||||
GTK_POLICY_AUTOMATIC);
|
|
||||||
cfilter_text = gtk_text_view_new();
|
|
||||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(cfilter_text), FALSE);
|
|
||||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(cfilter_text), GTK_WRAP_WORD);
|
|
||||||
#endif
|
|
||||||
set_help_text(cfilter_text, CFILTER_HELP);
|
|
||||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), cfilter_text);
|
|
||||||
gtk_widget_show(txt_scrollw);
|
|
||||||
gtk_widget_show(cfilter_text);
|
|
||||||
gtk_widget_show(cfilter_vb);
|
|
||||||
label = gtk_label_new("Capture Filters");
|
label = gtk_label_new("Capture Filters");
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), cfilter_vb, label);
|
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), cfilter_vb, label);
|
||||||
|
|
||||||
/* FAQ help (this one has no horizontal scrollbar) */
|
/* display filter help (this one has no horizontal scrollbar) */
|
||||||
|
dfilter_vb = help_page(DFILTER_HELP, &dfilter_text);
|
||||||
|
label = gtk_label_new("Display Filters");
|
||||||
|
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), dfilter_vb, label);
|
||||||
|
|
||||||
faq_vb = gtk_vbox_new(FALSE, 0);
|
/* well known things help (this one has no horizontal scrollbar) */
|
||||||
gtk_container_border_width(GTK_CONTAINER(faq_vb), 1);
|
well_known_vb = help_page(WELL_KNOWN_HELP, &well_known_text);
|
||||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
label = gtk_label_new("Well Known");
|
||||||
gtk_box_pack_start(GTK_BOX(faq_vb), txt_scrollw, TRUE, TRUE, 0);
|
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), well_known_vb, label);
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
/* FAQ help (this one has no horizontal scrollbar) */
|
||||||
GTK_POLICY_NEVER,
|
faq_vb = help_page(FAQ_HELP, &faq_text);
|
||||||
GTK_POLICY_ALWAYS);
|
|
||||||
faq_text = gtk_text_new(NULL, NULL );
|
|
||||||
gtk_text_set_editable(GTK_TEXT(faq_text), FALSE);
|
|
||||||
gtk_text_set_word_wrap(GTK_TEXT(faq_text), TRUE);
|
|
||||||
gtk_text_set_line_wrap(GTK_TEXT(faq_text), TRUE);
|
|
||||||
#else
|
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
|
||||||
GTK_POLICY_NEVER,
|
|
||||||
GTK_POLICY_AUTOMATIC);
|
|
||||||
faq_text = gtk_text_view_new();
|
|
||||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(faq_text), FALSE);
|
|
||||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(faq_text), GTK_WRAP_WORD);
|
|
||||||
#endif
|
|
||||||
set_help_text(faq_text, FAQ_HELP);
|
|
||||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), faq_text);
|
|
||||||
gtk_widget_show(txt_scrollw);
|
|
||||||
gtk_widget_show(faq_text);
|
|
||||||
gtk_widget_show(faq_vb);
|
|
||||||
label = gtk_label_new("FAQ");
|
label = gtk_label_new("FAQ");
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), faq_vb, label);
|
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), faq_vb, label);
|
||||||
|
|
||||||
|
@ -313,15 +179,15 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_)
|
||||||
|
|
||||||
gtk_widget_show(help_nb);
|
gtk_widget_show(help_nb);
|
||||||
|
|
||||||
/* Buttons (only one for now) */
|
/* Buttons (only "Close" for now) */
|
||||||
|
bbox = gtk_hbutton_box_new();
|
||||||
bbox = gtk_hbox_new(FALSE, 1);
|
/*bbox = gtk_hbox_new(FALSE, 1);*/
|
||||||
gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show(bbox);
|
gtk_widget_show(bbox);
|
||||||
#if GTK_MAJOR_VERSION < 2
|
#if GTK_MAJOR_VERSION < 2
|
||||||
close_bt = gtk_button_new_with_label("Close");
|
close_bt = gtk_button_new_with_label("OK");
|
||||||
#else
|
#else
|
||||||
close_bt = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
close_bt = gtk_button_new_from_stock(GTK_STOCK_OK);
|
||||||
#endif
|
#endif
|
||||||
SIGNAL_CONNECT(close_bt, "clicked", help_close_cb, help_w);
|
SIGNAL_CONNECT(close_bt, "clicked", help_close_cb, help_w);
|
||||||
GTK_WIDGET_SET_FLAGS(close_bt, GTK_CAN_DEFAULT);
|
GTK_WIDGET_SET_FLAGS(close_bt, GTK_CAN_DEFAULT);
|
||||||
|
@ -361,77 +227,13 @@ static void insert_text(GtkWidget *w, const char *buffer, int nchars)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *proto_help =
|
|
||||||
"The following %d protocols (and packet types) are currently\n"
|
|
||||||
"supported by Ethereal:\n\n";
|
|
||||||
|
|
||||||
static const char *dfilter_help =
|
|
||||||
"The following per-protocol fields can be used in display\n"
|
|
||||||
"filters:\n";
|
|
||||||
|
|
||||||
static const char *cfilter_help =
|
|
||||||
"Packet capturing is performed with the pcap library. The capture filter "
|
|
||||||
"syntax follows the rules of this library.\nSo this syntax is different "
|
|
||||||
"from the display filter syntax: see manual page of tcpdump.\n"
|
|
||||||
#ifndef HAVE_LIBPCAP
|
|
||||||
"\nNote: packet capturing is not enabled in this version.\n";
|
|
||||||
#else
|
|
||||||
;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char *overview_help =
|
|
||||||
"Ethereal is a GUI network protocol analyzer. It lets you interactively "
|
|
||||||
"browse packet data from a live network or from a previously saved "
|
|
||||||
"capture file. Ethereal's native capture file format is libpcap format, "
|
|
||||||
"which is also the format used by tcpdump and various other tools. In "
|
|
||||||
"addition, Ethereal can read capture files from snoop and atmsnoop, "
|
|
||||||
"Shomiti/Finisar Surveyor, Novell LANalyzer, Network General/Network "
|
|
||||||
"Associates DOS-based Sniffer (compressed or uncompressed), Microsoft "
|
|
||||||
"Network Monitor, AIX's iptrace, Cinco Networks NetXRay, Network "
|
|
||||||
"Associates Windows-based Sniffer, AG Group/WildPackets "
|
|
||||||
"EtherPeek/TokenPeek/AiroPeek, RADCOM's WAN/LAN analyzer, Lucent/Ascend "
|
|
||||||
"router debug output, HP-UX's nettl, the dump output from Toshiba's ISDN "
|
|
||||||
"routers, the output from i4btrace from the ISDN4BSD project, the output "
|
|
||||||
"in IPLog format from the Cisco Secure Intrusion Detection System, pppd "
|
|
||||||
"logs (pppdump format), the output from VMS's TCPIPtrace utility, the "
|
|
||||||
"text output from the DBS Etherwatch VMS utility, traffic capture files "
|
|
||||||
"from Visual Networks' Visual UpTime, and the output from CoSine L2 debug."
|
|
||||||
"\n\n"
|
|
||||||
"There is no need to tell Ethereal what type of file you are reading; "
|
|
||||||
"it will determine the file type by itself. Ethereal is also "
|
|
||||||
"capable of reading any of these file formats if they are compressed "
|
|
||||||
"using gzip. Ethereal recognizes this directly from the file; the '.gz' "
|
|
||||||
"extension is not required for this purpose.";
|
|
||||||
|
|
||||||
/* FAQ_PARTS, FAQ_SIZE, faq_part[0] ... faq_part[FAQ_PARTS-1] */
|
|
||||||
#include "../FAQ.include"
|
|
||||||
|
|
||||||
static void set_help_text(GtkWidget *w, help_type_t type)
|
static void set_help_text(GtkWidget *w, help_type_t type)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
#define BUFF_LEN 4096
|
#ifndef HAVE_LIBPCAP
|
||||||
#define B_LEN 256
|
char *tmp;
|
||||||
char buffer[BUFF_LEN];
|
|
||||||
header_field_info *hfinfo;
|
|
||||||
int i, len, maxlen = 0, maxlen2 = 0, maxlen4 = 0;
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
int maxlen3 = 0, nb_lines = 0;
|
|
||||||
int width, height;
|
|
||||||
#endif
|
#endif
|
||||||
const char *type_name;
|
|
||||||
void *cookie, *cookie2;
|
|
||||||
protocol_t *protocol;
|
|
||||||
char *name, *short_name, *filter_name;
|
|
||||||
int namel = 0, short_namel = 0, filter_namel = 0;
|
|
||||||
int count, fcount;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX quick hack:
|
|
||||||
* the width and height computations are performed to make the
|
|
||||||
* horizontal scrollbar work in gtk1.2. This is only necessary for the
|
|
||||||
* PROTOCOL_HELP and DFILTER_HELP windows since all others should
|
|
||||||
* not have any horizontal scrollbar (line wrapping enabled).
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
#if GTK_MAJOR_VERSION < 2
|
||||||
|
@ -441,163 +243,34 @@ static void set_help_text(GtkWidget *w, help_type_t type)
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
|
||||||
case OVERVIEW_HELP :
|
case OVERVIEW_HELP :
|
||||||
insert_text(w, overview_help, -1);
|
for (i=0; i<OVERVIEW_PARTS; i++) {
|
||||||
|
insert_text(w, overview_part[i], strlen(overview_part[i]));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
case CFILTER_HELP :
|
||||||
case PROTOCOL_HELP :
|
#ifndef HAVE_LIBPCAP
|
||||||
/* first pass to know the maximum length of first field */
|
tmp = "NOTE: packet capturing is not enabled in this version!\n \n";
|
||||||
count = 0;
|
insert_text(w, tmp, strlen(tmp));
|
||||||
for (i = proto_get_first_protocol(&cookie); i != -1;
|
|
||||||
i = proto_get_next_protocol(&cookie)) {
|
|
||||||
count++;
|
|
||||||
protocol = find_protocol_by_id(i);
|
|
||||||
name = proto_get_protocol_name(i);
|
|
||||||
short_name = proto_get_protocol_short_name(protocol);
|
|
||||||
filter_name = proto_get_protocol_filter_name(i);
|
|
||||||
if ((len = strlen(name)) > namel)
|
|
||||||
namel = len;
|
|
||||||
if ((len = strlen(short_name)) > short_namel)
|
|
||||||
short_namel = len;
|
|
||||||
if ((len = strlen(filter_name)) > filter_namel)
|
|
||||||
filter_namel = len;
|
|
||||||
}
|
|
||||||
maxlen = namel + short_namel + filter_namel;
|
|
||||||
|
|
||||||
len = snprintf(buffer, BUFF_LEN, proto_help, count);
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
maxlen2 = len;
|
|
||||||
width = gdk_string_width(m_r_font, buffer);
|
|
||||||
insert_text(w, buffer, maxlen2);
|
|
||||||
#else
|
|
||||||
insert_text(w, buffer, len);
|
|
||||||
#endif
|
#endif
|
||||||
|
for (i=0; i<CAPTURE_FILTERS_PARTS; i++) {
|
||||||
/* ok, display the correctly aligned strings */
|
insert_text(w, capture_filters_part[i], strlen(capture_filters_part[i]));
|
||||||
for (i = proto_get_first_protocol(&cookie); i != -1;
|
|
||||||
i = proto_get_next_protocol(&cookie)) {
|
|
||||||
protocol = find_protocol_by_id(i);
|
|
||||||
name = proto_get_protocol_name(i);
|
|
||||||
short_name = proto_get_protocol_short_name(protocol);
|
|
||||||
filter_name = proto_get_protocol_filter_name(i);
|
|
||||||
|
|
||||||
/* the name used for sorting in the left column */
|
|
||||||
len = snprintf(buffer, BUFF_LEN, "%*s %*s %*s\n",
|
|
||||||
-short_namel, short_name,
|
|
||||||
-namel, name,
|
|
||||||
-filter_namel, filter_name);
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
if (len > maxlen2) {
|
|
||||||
maxlen2 = len;
|
|
||||||
if ((len = gdk_string_width(m_r_font, buffer)) > width)
|
|
||||||
width = len;
|
|
||||||
}
|
}
|
||||||
insert_text(w, buffer, strlen(buffer));
|
|
||||||
nb_lines++;
|
|
||||||
#else
|
|
||||||
insert_text(w, buffer, strlen(buffer));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
height = (3 + nb_lines) * m_font_height;
|
|
||||||
WIDGET_SET_SIZE(w, 20 + width, 20 + height);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DFILTER_HELP :
|
case DFILTER_HELP :
|
||||||
|
for (i=0; i<DISPLAY_FILTERS_PARTS; i++) {
|
||||||
/* XXX we should display hinfo->blurb instead of name (if not empty) */
|
insert_text(w, display_filters_part[i], strlen(display_filters_part[i]));
|
||||||
|
|
||||||
/* first pass to know the maximum length of first and second fields */
|
|
||||||
for (i = proto_get_first_protocol(&cookie); i != -1;
|
|
||||||
i = proto_get_next_protocol(&cookie)) {
|
|
||||||
|
|
||||||
for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
|
|
||||||
hfinfo = proto_get_next_protocol_field(&cookie2)) {
|
|
||||||
|
|
||||||
if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((len = strlen(hfinfo->abbrev)) > maxlen)
|
|
||||||
maxlen = len;
|
|
||||||
if ((len = strlen(hfinfo->name)) > maxlen2)
|
|
||||||
maxlen2 = len;
|
|
||||||
if ((len = strlen(hfinfo->blurb)) > maxlen4)
|
|
||||||
maxlen4 = len;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case WELL_KNOWN_HELP :
|
||||||
|
for (i=0; i<WELL_KNOWN_PARTS; i++) {
|
||||||
|
insert_text(w, well_known_part[i], strlen(well_known_part[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
maxlen3 = strlen(dfilter_help);
|
|
||||||
width = gdk_string_width(m_r_font, dfilter_help);
|
|
||||||
insert_text(w, dfilter_help, maxlen3);
|
|
||||||
#else
|
|
||||||
insert_text(w, dfilter_help, strlen(dfilter_help));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fcount = 0;
|
|
||||||
for (i = proto_get_first_protocol(&cookie); i != -1;
|
|
||||||
i = proto_get_next_protocol(&cookie)) {
|
|
||||||
protocol = find_protocol_by_id(i);
|
|
||||||
name = proto_get_protocol_name(i);
|
|
||||||
short_name = proto_get_protocol_short_name(protocol);
|
|
||||||
filter_name = proto_get_protocol_filter_name(i);
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
|
|
||||||
hfinfo = proto_get_next_protocol_field(&cookie2)) {
|
|
||||||
|
|
||||||
if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
|
|
||||||
continue;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
fcount += count;
|
|
||||||
|
|
||||||
len = snprintf(buffer, BUFF_LEN, "\n%s - %s (%s) [%d fields]:\n",
|
|
||||||
short_name, name, filter_name, count);
|
|
||||||
insert_text(w, buffer, len);
|
|
||||||
|
|
||||||
for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
|
|
||||||
hfinfo = proto_get_next_protocol_field(&cookie2)) {
|
|
||||||
|
|
||||||
if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
|
|
||||||
continue;
|
|
||||||
|
|
||||||
type_name = ftype_pretty_name(hfinfo->type);
|
|
||||||
len = snprintf(buffer, BUFF_LEN, "%*s %*s %*s (%s)\n",
|
|
||||||
-maxlen, hfinfo->abbrev,
|
|
||||||
-maxlen2, hfinfo->name,
|
|
||||||
-maxlen4, hfinfo->blurb,
|
|
||||||
type_name);
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
if (len > maxlen3) {
|
|
||||||
maxlen3 = len;
|
|
||||||
if ((len = gdk_string_width(m_r_font, buffer)) > width)
|
|
||||||
width = len;
|
|
||||||
}
|
|
||||||
insert_text(w, buffer, strlen(buffer));
|
|
||||||
nb_lines ++;
|
|
||||||
#else
|
|
||||||
insert_text(w, buffer, strlen(buffer));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
len = snprintf(buffer, BUFF_LEN, "\n-- Total %d fields\n", fcount);
|
|
||||||
insert_text(w, buffer, len);
|
|
||||||
|
|
||||||
#if GTK_MAJOR_VERSION < 2
|
|
||||||
height = (5 + nb_lines) * m_font_height;
|
|
||||||
WIDGET_SET_SIZE(w, 20 + width, 20 + height);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case FAQ_HELP :
|
case FAQ_HELP :
|
||||||
for (i=0; i<FAQ_PARTS; i++) {
|
for (i=0; i<FAQ_PARTS; i++) {
|
||||||
insert_text(w, faq_part[i], strlen(faq_part[i]));
|
insert_text(w, faq_part[i], strlen(faq_part[i]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CFILTER_HELP :
|
|
||||||
insert_text(w, cfilter_help, -1);
|
|
||||||
break;
|
|
||||||
default :
|
default :
|
||||||
g_assert_not_reached();
|
g_assert_not_reached();
|
||||||
break;
|
break;
|
||||||
|
@ -607,6 +280,7 @@ static void set_help_text(GtkWidget *w, help_type_t type)
|
||||||
#endif
|
#endif
|
||||||
} /* set_help_text */
|
} /* set_help_text */
|
||||||
|
|
||||||
|
|
||||||
static void clear_help_text(GtkWidget *w)
|
static void clear_help_text(GtkWidget *w)
|
||||||
{
|
{
|
||||||
#if GTK_MAJOR_VERSION < 2
|
#if GTK_MAJOR_VERSION < 2
|
||||||
|
@ -626,6 +300,7 @@ static void clear_help_text(GtkWidget *w)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Redraw all the text widgets, to use a new font. */
|
/* Redraw all the text widgets, to use a new font. */
|
||||||
void help_redraw(void)
|
void help_redraw(void)
|
||||||
{
|
{
|
||||||
|
@ -638,12 +313,12 @@ void help_redraw(void)
|
||||||
#if GTK_MAJOR_VERSION < 2
|
#if GTK_MAJOR_VERSION < 2
|
||||||
gtk_text_thaw(GTK_TEXT(overview_text));
|
gtk_text_thaw(GTK_TEXT(overview_text));
|
||||||
|
|
||||||
gtk_text_freeze(GTK_TEXT(proto_text));
|
gtk_text_freeze(GTK_TEXT(cfilter_text));
|
||||||
#endif
|
#endif
|
||||||
clear_help_text(proto_text);
|
clear_help_text(cfilter_text);
|
||||||
set_help_text(proto_text, PROTOCOL_HELP);
|
set_help_text(cfilter_text, CFILTER_HELP);
|
||||||
#if GTK_MAJOR_VERSION < 2
|
#if GTK_MAJOR_VERSION < 2
|
||||||
gtk_text_thaw(GTK_TEXT(proto_text));
|
gtk_text_thaw(GTK_TEXT(cfilter_text));
|
||||||
|
|
||||||
gtk_text_freeze(GTK_TEXT(dfilter_text));
|
gtk_text_freeze(GTK_TEXT(dfilter_text));
|
||||||
#endif
|
#endif
|
||||||
|
@ -652,12 +327,12 @@ void help_redraw(void)
|
||||||
#if GTK_MAJOR_VERSION < 2
|
#if GTK_MAJOR_VERSION < 2
|
||||||
gtk_text_thaw(GTK_TEXT(dfilter_text));
|
gtk_text_thaw(GTK_TEXT(dfilter_text));
|
||||||
|
|
||||||
gtk_text_freeze(GTK_TEXT(cfilter_text));
|
gtk_text_freeze(GTK_TEXT(well_known_text));
|
||||||
#endif
|
#endif
|
||||||
clear_help_text(cfilter_text);
|
clear_help_text(well_known_text);
|
||||||
set_help_text(cfilter_text, CFILTER_HELP);
|
set_help_text(well_known_text, WELL_KNOWN_HELP);
|
||||||
#if GTK_MAJOR_VERSION < 2
|
#if GTK_MAJOR_VERSION < 2
|
||||||
gtk_text_thaw(GTK_TEXT(cfilter_text));
|
gtk_text_thaw(GTK_TEXT(well_known_text));
|
||||||
|
|
||||||
gtk_text_freeze(GTK_TEXT(faq_text));
|
gtk_text_freeze(GTK_TEXT(faq_text));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue