/* capture_dlg.c
* Routines for packet capture windows
*
- * $Id: capture_dlg.c,v 1.100 2004/01/31 03:22:39 guy Exp $
+ * $Id: capture_dlg.c,v 1.101 2004/01/31 12:13:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
/* user didn't saved his current file, ask him */
- dialog = simple_dialog(ESD_TYPE_QUEST | ESD_TYPE_MODAL,
+ dialog = simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL,
ESD_BTN_YES | ESD_BTN_NO | ESD_BTN_CANCEL,
- "Save packets to \"%s\" before capturing?",
- cf_get_display_name(&cfile));
+ PRIMARY_TEXT_START "Save capture file before starting a new capture?" PRIMARY_TEXT_END "\n\n"
+ "If you start a new capture without saving, your current capture data will be discarded.");
simple_dialog_set_cb(dialog, capture_prep_answered_cb, NULL);
} else {
/* unchanged file, just capture a new one */
/* color_dlg.c
* Definitions for dialog boxes for color filters
*
- * $Id: color_dlg.c,v 1.38 2004/01/31 03:22:39 guy Exp $
+ * $Id: color_dlg.c,v 1.39 2004/01/31 12:13:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
/* Remove all user defined color filters and revert to the global file. */
static void
-color_clear_cb(GtkWidget *widget, gpointer user_data _U_)
+color_clear_cmd(GtkWidget *widget)
{
GtkWidget * color_filters;
colorize_packets(&cfile);
/* Destroy the dialog box. */
+ /* XXX: is this useful? user might want to continue with editing new colors */
gtk_widget_destroy(colorize_win);
}
+/* clear button: user responded to question */
+void color_clear_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
+{
+ switch(btn) {
+ case(ESD_BTN_CLEAR):
+ color_clear_cmd(data);
+ break;
+ case(ESD_BTN_CANCEL):
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
+/* clear button: ask user before really doing it */
+void
+color_clear_cb(GtkWidget *widget, gpointer data _U_) {
+ gpointer dialog;
+
+ /* ask user, if he/she is really sure */
+ dialog = simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL,
+ ESD_BTN_CLEAR | ESD_BTN_CANCEL,
+ PRIMARY_TEXT_START "Remove all your personal color settings?" PRIMARY_TEXT_END "\n\n"
+ "This will revert the color settings to global defaults.\n\n"
+ "Are you really sure?");
+
+ simple_dialog_set_cb(dialog, color_clear_answered_cb, widget);
+}
+
/* Exit dialog and apply new list of color filters to the capture. */
static void
color_ok_cb(GtkButton *button _U_, gpointer user_data _U_)
/* compat_macros.h
* GTK-related Global defines, etc.
*
- * $Id: compat_macros.h,v 1.12 2004/01/29 22:37:45 ulfl Exp $
+ * $Id: compat_macros.h,v 1.13 2004/01/31 12:13:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#define TOGGLE_BUTTON_NEW_WITH_MNEMONIC(label_text, accel_group) \
dlg_toggle_button_new_with_label_with_mnemonic(label_text, accel_group)
+#define PRIMARY_TEXT_START ""
+#define PRIMARY_TEXT_END ""
+
#else /* GTK_MAJOR_VERSION >= 2 */
#define SIGNAL_CONNECT(widget, name, callback, arg) \
#define TOGGLE_BUTTON_NEW_WITH_MNEMONIC(label_text, accel_group) \
gtk_toggle_button_new_with_mnemonic(label_text)
+#define PRIMARY_TEXT_START "<span weight=\"bold\" size=\"larger\">"
+#define PRIMARY_TEXT_END "</span>"
+
#endif /* GTK_MAJOR_VERSION */
#endif /* __COMPAT_MACROS_H__ */
/* dlg_utils.c
* Utilities to use when constructing dialogs
*
- * $Id: dlg_utils.c,v 1.19 2004/01/29 22:37:45 ulfl Exp $
+ * $Id: dlg_utils.c,v 1.20 2004/01/31 12:13:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
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
+#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 */
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.87 2004/01/31 03:22:39 guy Exp $
+ * $Id: file_dlg.c,v 1.88 2004/01/31 12:13:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
/* user didn't saved his current file, ask him */
- dialog = simple_dialog(ESD_TYPE_QUEST | ESD_TYPE_MODAL,
+ dialog = simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL,
ESD_BTN_YES | ESD_BTN_NO | ESD_BTN_CANCEL,
- "Save your capture file before open a new one?");
+ PRIMARY_TEXT_START "Save capture file before opening a new one?" PRIMARY_TEXT_END "\n\n"
+ "If you open a new capture file without saving, your capture data will be discarded.");
simple_dialog_set_cb(dialog, file_open_answered_cb, widget);
} else {
/* unchanged file, just open a new one */
if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
/* user didn't saved his current file, ask him */
- dialog = simple_dialog(ESD_TYPE_QUEST | ESD_TYPE_MODAL,
+ dialog = simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL,
ESD_BTN_YES | ESD_BTN_NO | ESD_BTN_CANCEL,
- "Save your capture file before closing it?");
+ PRIMARY_TEXT_START "Save capture file before closing?" PRIMARY_TEXT_END "\n\n"
+ "If you close without saving, your capture data will be discarded.");
+
simple_dialog_set_cb(dialog, file_close_confirmed_cb, NULL);
} else {
/* unchanged file, just close it */
/* main.c
*
- * $Id: main.c,v 1.381 2004/01/31 03:22:41 guy Exp $
+ * $Id: main.c,v 1.382 2004/01/31 12:13:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
/* user didn't saved his current file, ask him */
- dialog = simple_dialog(ESD_TYPE_QUEST | ESD_TYPE_MODAL,
+ dialog = simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL,
ESD_BTN_YES | ESD_BTN_NO | ESD_BTN_CANCEL,
- "Save packets to \"%s\" before quit?",
- cf_get_display_name(&cfile));
+ PRIMARY_TEXT_START "Save capture file before program quit?" PRIMARY_TEXT_END "\n\n"
+ "If you quit the program without saving, your capture data will be discarded.");
simple_dialog_set_cb(dialog, file_quit_answered_cb, NULL);
return TRUE;
} else {
if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
/* user didn't saved his current file, ask him */
- dialog = simple_dialog(ESD_TYPE_QUEST | ESD_TYPE_MODAL,
+ dialog = simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL,
ESD_BTN_YES | ESD_BTN_NO | ESD_BTN_CANCEL,
- "Save packets to \"%s\" before quit?",
- cf_get_display_name(&cfile));
+ PRIMARY_TEXT_START "Save capture file before program quit?" PRIMARY_TEXT_END "\n\n"
+ "If you quit the program without saving, your capture data will be discarded.");
simple_dialog_set_cb(dialog, file_quit_answered_cb, NULL);
} else {
/* unchanged file, just exit */
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.152 2004/01/29 23:11:37 ulfl Exp $
+ * $Id: menu.c,v 1.153 2004/01/31 12:13:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
/* user didn't saved his current file, ask him */
- dialog = simple_dialog(ESD_TYPE_QUEST | ESD_TYPE_MODAL,
+ dialog = simple_dialog(ESD_TYPE_WARN | ESD_TYPE_MODAL,
ESD_BTN_YES | ESD_BTN_NO | ESD_BTN_CANCEL,
- "Save packets to \"%s\" before opening a new capture file?",
- cf_get_display_name(&cfile));
+ PRIMARY_TEXT_START "Save capture file before opening a new one?" PRIMARY_TEXT_END "\n\n"
+ "If you open a new capture file without saving, your current capture data will be discarded.");
simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, widget);
} else {
/* unchanged file */
/* simple_dialog.c
* Simple message dialog box routines.
*
- * $Id: simple_dialog.c,v 1.20 2004/01/31 03:22:42 guy Exp $
+ * $Id: simple_dialog.c,v 1.21 2004/01/31 12:13:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
*
*/
-#define ESD_MAX_MSG_LEN 2048
gpointer
simple_dialog(gint type, gint btn_mask, gchar *msg_format, ...) {
GtkWidget *win, *main_vb, *top_hb, *type_pm, *msg_label,
- *bbox, *bt;
+ *bbox, *ok_bt, *bt;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
GdkColormap *cmap;
va_list ap;
- gchar message[ESD_MAX_MSG_LEN];
+ gchar message[2048];
gchar **icon;
/* Main window */
icon = stock_dialog_warning_48_xpm;
win = dlg_window_new("Ethereal: Warning");
break;
+ case ESD_TYPE_QUESTION:
+ icon = stock_dialog_question_48_xpm;
+ win = dlg_window_new("Ethereal: Question");
+ break;
case ESD_TYPE_ERROR:
icon = stock_dialog_error_48_xpm;
win = dlg_window_new("Ethereal: Error");
break;
- case ESD_TYPE_QUEST:
- icon = stock_dialog_question_48_xpm;
- win = dlg_window_new("Ethereal: Question");
- break;
case ESD_TYPE_INFO :
default :
icon = stock_dialog_info_48_xpm;
break;
}
+#if GTK_MAJOR_VERSION >= 2
+ /* the GNOME HIG suggest to keep the title empty for simple dialogs */
+ /* at least on win32 systems, this isn't possible, so use the programs name */
+ gtk_window_set_title(GTK_WINDOW(win), "Ethereal");
+#endif
+
if (type & ESD_TYPE_MODAL)
gtk_window_set_modal(GTK_WINDOW(win), TRUE);
-
- gtk_container_border_width(GTK_CONTAINER(win), 7);
+ gtk_container_border_width(GTK_CONTAINER(win), 6);
/* Container for our rows */
- main_vb = gtk_vbox_new(FALSE, 5);
- gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
+ main_vb = gtk_vbox_new(FALSE, 12);
gtk_container_add(GTK_CONTAINER(win), main_vb);
gtk_widget_show(main_vb);
/* Top row: Icon and message text */
- top_hb = gtk_hbox_new(FALSE, 10);
+ top_hb = gtk_hbox_new(FALSE, 12);
+ gtk_container_border_width(GTK_CONTAINER(main_vb), 6);
gtk_container_add(GTK_CONTAINER(main_vb), top_hb);
gtk_widget_show(top_hb);
/* Load our vararg list into the message string */
va_start(ap, msg_format);
- vsnprintf(message, ESD_MAX_MSG_LEN, msg_format, ap);
+ vsnprintf(message, sizeof(message), msg_format, ap);
va_end(ap);
msg_label = gtk_label_new(message);
+
+#if GTK_MAJOR_VERSION >= 2
+ gtk_label_set_markup(GTK_LABEL(msg_label), message);
+#endif
+
+ gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
+ gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5, 0.0);
gtk_container_add(GTK_CONTAINER(top_hb), msg_label);
gtk_widget_show(msg_label);
case(ESD_BTN_OK):
bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
break;
- case(ESD_BTN_OK | ESD_BTN_CANCEL):
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
+ case(ESD_BTN_CLEAR | ESD_BTN_CANCEL):
+ bbox = dlg_button_row_new(GTK_STOCK_CLEAR, GTK_STOCK_CANCEL, NULL);
break;
case(ESD_BTN_YES | ESD_BTN_NO | ESD_BTN_CANCEL):
bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL, NULL);
gtk_container_add(GTK_CONTAINER(main_vb), bbox);
gtk_widget_show(bbox);
- bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
+ ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
+ if(ok_bt) {
+ OBJECT_SET_DATA(ok_bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_OK));
+ SIGNAL_CONNECT(ok_bt, "clicked", simple_dialog_cancel_cb, win);
+ }
+
+ bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLEAR);
if(bt) {
- OBJECT_SET_DATA(bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_OK));
+ OBJECT_SET_DATA(bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CLEAR));
SIGNAL_CONNECT(bt, "clicked", simple_dialog_cancel_cb, win);
- gtk_widget_grab_default(bt);
- /* Catch the "key_press_event" signal in the window, so that we can catch
- the ESC key being pressed and act as if the "OK" button had
- been selected. */
- dlg_set_cancel(win, bt);
}
bt = OBJECT_GET_DATA(bbox, GTK_STOCK_YES);
gtk_widget_grab_default(bt);
}
+ if(!bt) {
+ /* Catch the "key_press_event" signal in the window, so that we can catch
+ the ESC key being pressed and act as if the "OK" button had
+ been selected. */
+ dlg_set_cancel(win, ok_bt);
+ gtk_widget_grab_default(ok_bt);
+ }
+
gtk_widget_show(win);
return win;
* Definitions for dialog box routines with toolkit-independent APIs but
* toolkit-dependent implementations.
*
- * $Id: simple_dialog.h,v 1.6 2004/01/31 02:25:43 ulfl Exp $
+ * $Id: simple_dialog.h,v 1.7 2004/01/31 12:13:21 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#endif /* __cplusplus */
/* Dialog type. */
-#define ESD_TYPE_INFO 0x00
-#define ESD_TYPE_WARN 0x01
-#define ESD_TYPE_ERROR 0x02
-#define ESD_TYPE_QUEST 0x03
+#define ESD_TYPE_INFO 0x00
+#define ESD_TYPE_WARN 0x01
+#define ESD_TYPE_QUESTION 0x02
+#define ESD_TYPE_ERROR 0x03
/* Flag to be ORed with the dialog type, to specify that the dialog is
to be modal. */
#define ESD_BTN_CANCEL 0x02
#define ESD_BTN_YES 0x04
#define ESD_BTN_NO 0x08
+#define ESD_BTN_CLEAR 0x10
/* show a simple dialog */
#if __GNUC__ >= 2