aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/dlg_utils.c169
-rw-r--r--gtk/filter_prefs.c22
-rw-r--r--gtk/help_dlg.c50
-rw-r--r--gtk/help_dlg.h3
4 files changed, 157 insertions, 87 deletions
diff --git a/gtk/dlg_utils.c b/gtk/dlg_utils.c
index 8a31739207..9936edd71a 100644
--- a/gtk/dlg_utils.c
+++ b/gtk/dlg_utils.c
@@ -1,7 +1,7 @@
/* dlg_utils.c
* Utilities to use when constructing dialogs
*
- * $Id: dlg_utils.c,v 1.17 2004/01/22 20:33:21 guy Exp $
+ * $Id: dlg_utils.c,v 1.18 2004/01/25 21:27:15 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -47,14 +47,14 @@ dlg_key_press (GtkWidget *widget, GdkEventKey *event, gpointer cancel_button);
/* create a button for the button row (helper for dlg_button_row_new) */
static GtkWidget *
-dlg_button_new(GtkWidget *button_hbox, gchar *stock_id)
+dlg_button_new(GtkWidget *hbox, GtkWidget *button_hbox, gchar *stock_id)
{
GtkWidget *button;
button = BUTTON_NEW_FROM_STOCK(stock_id);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- OBJECT_SET_DATA(button_hbox, stock_id, button);
- gtk_box_pack_start(GTK_BOX(button_hbox), button, FALSE, FALSE, 0);
+ OBJECT_SET_DATA(hbox, stock_id, button);
+ gtk_box_pack_end(GTK_BOX(button_hbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
return button;
}
@@ -74,9 +74,12 @@ GtkWidget *
dlg_button_row_new(gchar *stock_id_first, ...)
{
gint buttons = 0;
- GtkWidget *button_hbox;
va_list stock_id_list;
gchar *stock_id = stock_id_first;
+ GtkWidget *hbox;
+ GtkWidget *button_hbox;
+ GtkWidget *help_hbox;
+ GtkWidget *button;
gchar *ok = NULL;
gchar *apply = NULL;
@@ -132,125 +135,139 @@ dlg_button_row_new(gchar *stock_id_first, ...)
/* we should have at least one button */
g_assert(buttons);
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(hbox);
+
button_hbox = gtk_hbutton_box_new();
+ gtk_box_pack_end(GTK_BOX(hbox), button_hbox, TRUE, TRUE, 0);
+ gtk_widget_show(button_hbox);
+
+ help_hbox = gtk_hbutton_box_new();
+ gtk_box_pack_end(GTK_BOX(hbox), help_hbox, FALSE, FALSE, 0);
+ gtk_widget_show(help_hbox);
if (buttons == 1) {
/* if only one button, simply put it in the middle (default) */
- dlg_button_new(button_hbox, stock_id_first);
- return button_hbox;
- } else {
- /* if more than one button, sort buttons from left to right */
- /* (the whole button cluster will then be right aligned) */
- gtk_button_box_set_layout (GTK_BUTTON_BOX(button_hbox), GTK_BUTTONBOX_END);
- gtk_button_box_set_spacing(GTK_BUTTON_BOX(button_hbox), 5);
+ dlg_button_new(hbox, button_hbox, stock_id_first);
+ return hbox;
}
+ /* do we have a help button? -> special handling for it */
+ if (help) {
+ button = BUTTON_NEW_FROM_STOCK(help);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ OBJECT_SET_DATA(hbox, help, button);
+ gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
+ gtk_widget_show(button);
+ buttons--;
+ }
+
+ /* if more than one button, sort buttons from left to right */
+ /* (the whole button cluster will then be right aligned) */
+ gtk_button_box_set_layout (GTK_BUTTON_BOX(button_hbox), GTK_BUTTONBOX_END);
+ gtk_button_box_set_spacing(GTK_BUTTON_BOX(button_hbox), 5);
+
#if /*!WIN32 ||*/ GTK_MAJOR_VERSION >= 2
/* beware: sequence of buttons are important! */
/* XXX: this can be implemented more elegant of course, but it works as it should */
if (buttons == 2) {
if (ok && cancel) {
- dlg_button_new(button_hbox, cancel);
- dlg_button_new(button_hbox, ok);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, ok);
+ return hbox;
}
if (print && cancel) {
- dlg_button_new(button_hbox, cancel);
- dlg_button_new(button_hbox, print);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, print);
+ return hbox;
}
if (find && cancel) {
- dlg_button_new(button_hbox, cancel);
- dlg_button_new(button_hbox, find);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, find);
+ return hbox;
}
if (jump && cancel) {
- dlg_button_new(button_hbox, cancel);
- dlg_button_new(button_hbox, jump);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, jump);
+ return hbox;
}
if (save && cancel) {
- dlg_button_new(button_hbox, cancel);
- dlg_button_new(button_hbox, save);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, save);
+ return hbox;
}
if (ok && clear) {
- dlg_button_new(button_hbox, clear);
- dlg_button_new(button_hbox, ok);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, clear);
+ dlg_button_new(hbox, button_hbox, ok);
+ return hbox;
}
if (save && close) {
- dlg_button_new(button_hbox, close);
- dlg_button_new(button_hbox, save);
- return button_hbox;
- }
- if (help && close) {
- dlg_button_new(button_hbox, help);
- dlg_button_new(button_hbox, close);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, close);
+ dlg_button_new(hbox, button_hbox, save);
+ return hbox;
}
if (create_stat && cancel) {
- dlg_button_new(button_hbox, cancel);
- dlg_button_new(button_hbox, create_stat);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, create_stat);
+ return hbox;
}
}
if (buttons == 3) {
if (ok && save && close) {
- dlg_button_new(button_hbox, save);
- dlg_button_new(button_hbox, close);
- dlg_button_new(button_hbox, ok);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, save);
+ dlg_button_new(hbox, button_hbox, close);
+ dlg_button_new(hbox, button_hbox, ok);
+ return hbox;
}
if (ok && apply && cancel) {
- dlg_button_new(button_hbox, apply);
- dlg_button_new(button_hbox, cancel);
- dlg_button_new(button_hbox, ok);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, apply);
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, ok);
+ return hbox;
}
if (apply && save && close) {
- dlg_button_new(button_hbox, save);
- dlg_button_new(button_hbox, close);
- dlg_button_new(button_hbox, apply);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, save);
+ dlg_button_new(hbox, button_hbox, close);
+ dlg_button_new(hbox, button_hbox, apply);
+ return hbox;
}
}
if (buttons == 4) {
if (ok && apply && save && cancel) {
- dlg_button_new(button_hbox, save);
- dlg_button_new(button_hbox, apply);
- dlg_button_new(button_hbox, cancel);
- dlg_button_new(button_hbox, ok);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, save);
+ dlg_button_new(hbox, button_hbox, apply);
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, ok);
+ return hbox;
}
if (ok && apply && save && close) {
- dlg_button_new(button_hbox, save);
- dlg_button_new(button_hbox, apply);
- dlg_button_new(button_hbox, close);
- dlg_button_new(button_hbox, ok);
- return button_hbox;
+ dlg_button_new(hbox, button_hbox, save);
+ dlg_button_new(hbox, button_hbox, apply);
+ dlg_button_new(hbox, button_hbox, close);
+ dlg_button_new(hbox, button_hbox, ok);
+ return hbox;
}
}
#endif
/* beware: sequence of buttons is important! */
- if (help != NULL) dlg_button_new(button_hbox, help);
- if (ok != NULL) dlg_button_new(button_hbox, ok);
- if (jump != NULL) dlg_button_new(button_hbox, jump);
- if (find != NULL) dlg_button_new(button_hbox, find);
- if (print != NULL) dlg_button_new(button_hbox, print);
- if (create_stat != NULL) dlg_button_new(button_hbox, create_stat);
- if (apply != NULL) dlg_button_new(button_hbox, apply);
- if (save != NULL) dlg_button_new(button_hbox, save);
- if (stop != NULL) dlg_button_new(button_hbox, stop);
- if (close != NULL) dlg_button_new(button_hbox, close);
- if (clear != NULL) dlg_button_new(button_hbox, clear);
- if (cancel != NULL) dlg_button_new(button_hbox, cancel);
+ if (ok != NULL) dlg_button_new(hbox, button_hbox, ok);
+ if (jump != NULL) dlg_button_new(hbox, button_hbox, jump);
+ if (find != NULL) dlg_button_new(hbox, button_hbox, find);
+ if (print != NULL) dlg_button_new(hbox, button_hbox, print);
+ if (create_stat != NULL) dlg_button_new(hbox, button_hbox, create_stat);
+ if (apply != NULL) dlg_button_new(hbox, button_hbox, apply);
+ if (save != NULL) dlg_button_new(hbox, button_hbox, save);
+ if (stop != NULL) dlg_button_new(hbox, button_hbox, stop);
+ if (close != NULL) dlg_button_new(hbox, button_hbox, close);
+ if (clear != NULL) dlg_button_new(hbox, button_hbox, clear);
+ if (cancel != NULL) dlg_button_new(hbox, button_hbox, cancel);
/* GTK2: we don't know that button combination, add it to the above list! */
/* g_assert_not_reached(); */
- return button_hbox;
+ return hbox;
}
diff --git a/gtk/filter_prefs.c b/gtk/filter_prefs.c
index ff36acaf12..974081824c 100644
--- a/gtk/filter_prefs.c
+++ b/gtk/filter_prefs.c
@@ -3,7 +3,7 @@
* (This used to be a notebook page under "Preferences", hence the
* "prefs" in the file name.)
*
- * $Id: filter_prefs.c,v 1.54 2004/01/25 15:10:35 ulfl Exp $
+ * $Id: filter_prefs.c,v 1.55 2004/01/25 21:27:15 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -43,6 +43,7 @@
#include "dfilter_expr_dlg.h"
#include "compat_macros.h"
#include "gtkglobals.h"
+#include "help_dlg.h"
#define E_FILT_DIALOG_PTR_KEY "filter_dialog_ptr"
#define E_FILT_BUTTON_PTR_KEY "filter_button_ptr"
@@ -294,7 +295,8 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
*ok_bt, /* "OK" button */
*apply_bt, /* "Apply" button */
*save_bt, /* "Save" button */
- *close_bt; /* "Cancel" button */
+ *close_bt, /* "Cancel" button */
+ *help_bt; /* "Help" button */
GtkWidget *filter_vb, /* filter settings box */
*props_vb;
GtkWidget *top_hb,
@@ -562,15 +564,15 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
/* button row */
if (parent_filter_te != NULL) {
if (construct_args->wants_apply_button) {
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CLOSE, NULL);
+ bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
} else {
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_SAVE, GTK_STOCK_CLOSE, NULL);
+ bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_SAVE, GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
}
} else {
if (construct_args->wants_apply_button) {
- bbox = dlg_button_row_new(GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CLOSE, NULL);
+ bbox = dlg_button_row_new(GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
} else {
- bbox = dlg_button_row_new(GTK_STOCK_SAVE, GTK_STOCK_CLOSE, NULL);
+ bbox = dlg_button_row_new(GTK_STOCK_SAVE, GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
}
}
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
@@ -611,6 +613,14 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
if (parent_filter_te == NULL)
gtk_widget_grab_default(close_bt);
+ help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
+ if (list == CFILTER_LIST) {
+ SIGNAL_CONNECT(help_bt, "clicked", help_topic_cb, "Capture Filters");
+ } else {
+ SIGNAL_CONNECT(help_bt, "clicked", help_topic_cb, "Display Filters");
+ }
+ gtk_tooltips_set_tip (tooltips, help_bt, ("Show topic specific help"), NULL);
+
/*
* Catch the "key_press_event" signal in the window, so that we can
* catch the ESC key being pressed and act as if the "Close" button
diff --git a/gtk/help_dlg.c b/gtk/help_dlg.c
index f1e06e9804..440d5d589e 100644
--- a/gtk/help_dlg.c
+++ b/gtk/help_dlg.c
@@ -1,6 +1,6 @@
/* help_dlg.c
*
- * $Id: help_dlg.c,v 1.42 2004/01/21 21:19:33 ulfl Exp $
+ * $Id: help_dlg.c,v 1.43 2004/01/25 21:27:16 ulfl Exp $
*
* Laurent Deniel <laurent.deniel@free.fr>
*
@@ -43,6 +43,9 @@
#define HELP_DIR "help"
+
+#define NOTEBOOK_KEY "notebook_key"
+
static void help_close_cb(GtkWidget *w, gpointer data);
static void help_destroy_cb(GtkWidget *w, gpointer data);
static void insert_text(GtkWidget *w, const char *buffer, int nchars);
@@ -61,6 +64,7 @@ static GtkWidget *help_w = NULL;
* (for text format changes).
*/
typedef struct {
+ char *topic;
char *pathname;
GtkWidget *txt;
} help_page_t;
@@ -70,7 +74,7 @@ static GSList *help_text_pages = NULL;
/*
* Helper function to show a simple help text page.
*/
-static GtkWidget * help_page(const char *filename)
+static GtkWidget * help_page(const char *topic, const char *filename)
{
GtkWidget *page_vb, *txt_scrollw, *txt;
char *relative_path, *absolute_path;
@@ -105,9 +109,10 @@ static GtkWidget * help_page(const char *filename)
gtk_widget_show(page_vb);
page = g_malloc(sizeof (help_page_t));
+ page->topic = g_strdup(topic);
page->pathname = absolute_path;
page->txt = txt;
- help_text_pages = g_slist_prepend(help_text_pages, page);
+ help_text_pages = g_slist_append(help_text_pages, page);
return page_vb;
}
@@ -155,6 +160,7 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_)
/* help topics container */
help_nb = gtk_notebook_new();
gtk_container_add(GTK_CONTAINER(main_vb), help_nb);
+ OBJECT_SET_DATA(help_w, NOTEBOOK_KEY, help_nb);
/* help topics */
while (fgets(line, sizeof line, help_toc_file) != NULL) {
@@ -173,7 +179,7 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_)
* "line" refers to the topic now, and "filename" refers to the
* file name.
*/
- topic_vb = help_page(filename);
+ topic_vb = help_page(line, filename);
label = gtk_label_new(line);
gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), topic_vb, label);
}
@@ -209,6 +215,41 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_)
/*
+ * Open the help dialog and show a specific help page.
+ */
+
+void help_topic_cb(GtkWidget *w _U_, gpointer data _U_) {
+ gchar *topic = data;
+ gchar *page_topic;
+ GtkWidget *help_nb;
+ GSList *help_page_ent;
+ gint page_num = 0;
+ help_page_t *page;
+
+ /* show help dialog, if not already opened */
+ help_cb(NULL, NULL);
+
+ help_nb = OBJECT_GET_DATA(help_w, NOTEBOOK_KEY);
+
+ /* find page to display */
+ for (help_page_ent = help_text_pages; help_page_ent != NULL;
+ help_page_ent = g_slist_next(help_page_ent))
+ {
+ page = (help_page_t *)help_page_ent->data;
+ page_topic = page->topic;
+ if (strcmp (page_topic, topic) == 0) {
+ /* topic page found, switch to notebook page */
+ gtk_notebook_set_page(GTK_NOTEBOOK(help_nb), page_num);
+ return;
+ }
+ page_num++;
+ }
+
+ /* topic page not found, default (first page) will be shown */
+}
+
+
+/*
* Close help dialog.
*/
static void help_close_cb(GtkWidget *w _U_, gpointer data)
@@ -229,6 +270,7 @@ static void help_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
for (help_page_ent = help_text_pages; help_page_ent != NULL;
help_page_ent = g_slist_next(help_page_ent)) {
page = (help_page_t *)help_page_ent->data;
+ g_free(page->topic);
g_free(page->pathname);
g_free(page);
}
diff --git a/gtk/help_dlg.h b/gtk/help_dlg.h
index e23e9c1d6e..986e1c052b 100644
--- a/gtk/help_dlg.h
+++ b/gtk/help_dlg.h
@@ -1,6 +1,6 @@
/* help_dlg.h
*
- * $Id: help_dlg.h,v 1.5 2003/01/26 19:35:31 deniel Exp $
+ * $Id: help_dlg.h,v 1.6 2004/01/25 21:27:16 ulfl Exp $
*
* Laurent Deniel <laurent.deniel@free.fr>
*
@@ -28,6 +28,7 @@
#define __HELP_DLG_H__
void help_cb(GtkWidget *, gpointer);
+void help_topic_cb(GtkWidget *w _U_, gpointer data _U_);
/* Redraw all the text widgets, to use a new font. */
void help_redraw(void);