#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include <string.h>
+#include <stdarg.h>
#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#include "gtkglobals.h"
-#include "gui_utils.h"
-#include "dlg_utils.h"
-#include "compat_macros.h"
+#include "gtk/gtkglobals.h"
+#include "gtk/gui_utils.h"
+#include "gtk/dlg_utils.h"
+#include "gtk/stock_icons.h"
+
+#include "epan/filesystem.h"
-#include <string.h>
-#include <stdarg.h>
static void
dlg_activate (GtkWidget *widget, gpointer ok_button);
{
GtkWidget *button;
- button = BUTTON_NEW_FROM_STOCK(stock_id);
+ button = gtk_button_new_from_stock(stock_id);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- OBJECT_SET_DATA(hbox, stock_id, button);
+ g_object_set_data(G_OBJECT(hbox), stock_id, button);
gtk_box_pack_end(GTK_BOX(button_hbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
return button;
if (!hbox)
return;
- button_hbox = OBJECT_GET_DATA(hbox, BUTTON_HBOX_KEY);
- children = gtk_container_children(GTK_CONTAINER(button_hbox));
+ button_hbox = g_object_get_data(G_OBJECT(hbox), BUTTON_HBOX_KEY);
+ children = gtk_container_get_children(GTK_CONTAINER(button_hbox));
while (children) {
if (cur_item == focus_item) {
*
* a.) keep the button layout more consistent over the different dialogs
* b.) being able to switch between different button layouts, e.g.:
- * GTK1 (e.g. win32) "OK" "Apply" "Cancel"
- * GTK2 (e.g. GNOME) "Apply" "Cancel" "OK"
+ * e.g. Win32: "OK" "Apply" "Cancel"
+ * e.g. GNOME: "Apply" "Cancel" "OK"
*/
GtkWidget *
dlg_button_row_new(const gchar *stock_id_first, ...)
const gchar *ok = NULL;
const gchar *print = NULL;
const gchar *save = NULL;
+ const gchar *save_as = NULL;
+ const gchar *save_all = NULL;
const gchar *stop = NULL;
const gchar *yes = NULL;
+#ifdef HAVE_GEOIP
+ const gchar *map = NULL;
+#endif /* HAVE_GEOIP */
+ const gchar *follow_stream = NULL;
va_start(stock_id_list, stock_id_first);
apply = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_SAVE) == 0) {
save = stock_id;
+ } else if (strcmp(stock_id, GTK_STOCK_SAVE_AS) == 0) {
+ save_as = stock_id;
+ } else if (strcmp(stock_id, WIRESHARK_STOCK_SAVE_ALL) == 0) {
+ save_all = stock_id;
} else if (strcmp(stock_id, WIRESHARK_STOCK_DONT_SAVE) == 0) {
- dont_save = stock_id;
+ dont_save = stock_id;
+ } else if (strcmp(stock_id, WIRESHARK_STOCK_QUIT_DONT_SAVE) == 0) {
+ dont_save = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_CANCEL) == 0) {
cancel = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_CLOSE) == 0) {
} else if (strcmp(stock_id, WIRESHARK_STOCK_CAPTURE_STOP) == 0) {
cap_stop = stock_id;
#endif /* HAVE_LIBPCAP */
+#ifdef HAVE_GEOIP
+ } else if (strcmp(stock_id, WIRESHARK_STOCK_MAP) == 0) {
+ map = stock_id;
+#endif /* HAVE_GEOIP */
+ } else if (strcmp(stock_id, WIRESHARK_STOCK_FOLLOW_STREAM) == 0) {
+ follow_stream = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_STOP) == 0) {
stop = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_HELP) == 0) {
button_hbox = gtk_hbutton_box_new();
gtk_box_pack_end(GTK_BOX(hbox), button_hbox, TRUE, TRUE, 0);
- OBJECT_SET_DATA(hbox, BUTTON_HBOX_KEY, button_hbox);
+ g_object_set_data(G_OBJECT(hbox), BUTTON_HBOX_KEY, button_hbox);
gtk_widget_show(button_hbox);
+ gtk_box_set_spacing(GTK_BOX(button_hbox), 5);
help_hbox = gtk_hbutton_box_new();
gtk_box_pack_end(GTK_BOX(hbox), help_hbox, FALSE, FALSE, 0);
gtk_widget_show(help_hbox);
+ gtk_box_set_spacing(GTK_BOX(help_hbox), 5);
if (buttons == 0) {
/* if no buttons wanted, simply do nothing */
/* do we have a help button? -> special handling for it */
if (help) {
- button = BUTTON_NEW_FROM_STOCK(help);
+ button = gtk_button_new_from_stock(help);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ g_object_set_data(G_OBJECT(hbox), help, button);
+ gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
+ gtk_widget_show(button);
+ buttons--;
+ }
+
+ /* do we have a copy button? -> special handling for it */
+ if (copy) {
+ button = gtk_button_new_from_stock(copy);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ g_object_set_data(G_OBJECT(hbox), copy, button);
+ gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
+ gtk_widget_show(button);
+ buttons--;
+ }
+
+#ifdef HAVE_GEOIP
+ /* do we have a map button? -> special handling for it */
+ if (map) {
+ button = gtk_button_new_from_stock(map);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- OBJECT_SET_DATA(hbox, help, button);
+ g_object_set_data(G_OBJECT(hbox), map, button);
gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
buttons--;
}
+#endif /* HAVE_GEOIP */
/* 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);
-/* GTK+ 1.3 and later - on Win32, we use 1.3[.x] or 2.x, not 1.2[.x] */
#if !defined(_WIN32)
/* beware: sequence of buttons are important! */
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 (copy != NULL) dlg_button_new(hbox, button_hbox, copy);
if (create_stat != NULL) dlg_button_new(hbox, button_hbox, create_stat);
if (apply != NULL) dlg_button_new(hbox, button_hbox, apply);
if (yes != NULL) dlg_button_new(hbox, button_hbox, yes);
if (no != NULL) dlg_button_new(hbox, button_hbox, no);
if (save != NULL) dlg_button_new(hbox, button_hbox, save);
+ if (save_as != NULL) dlg_button_new(hbox, button_hbox, save_as);
+ if (save_all != NULL) dlg_button_new(hbox, button_hbox, save_all);
if (dont_save != NULL) dlg_button_new(hbox, button_hbox, dont_save);
if (cap_start != NULL) dlg_button_new(hbox, button_hbox, cap_start);
if (cap_stop != NULL) dlg_button_new(hbox, button_hbox, cap_stop);
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);
if (filter_stream!= NULL) dlg_button_new(hbox, button_hbox, filter_stream);
+ if (follow_stream != NULL) dlg_button_new(hbox, button_hbox, follow_stream);
+ if (close != NULL) dlg_button_new(hbox, button_hbox, close);
+ 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 hbox;
}
-/* this is called, when a dialog was closed */
-static void dlg_destroy_cb(GtkWidget *dialog _U_, gpointer data _U_)
-{
-#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4
- if(top_level) {
- /* bring main window back to front (workaround for a bug in win32 GTK2.x)
- XXX - do this only on Windows? */
- gtk_window_present(GTK_WINDOW(top_level));
- }
-#endif
-}
-
-
/* Create a dialog box window that belongs to Wireshark's main window. */
GtkWidget *
dlg_window_new(const gchar *title)
* to capture, and might also simplify the job of having the GUI main
* loop wait both for user input and packet arrival.
*/
+ /*
+ * On Windows, making the dialogs transient to top_level behaves strangely.
+ * It is not possible any more to bring the top level window to front easily.
+ * So we don't do this on Windows.
+ */
+#ifndef _WIN32
if (top_level) {
gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(top_level));
}
+#endif /*_WIN32*/
+
+ return win;
+}
+
+/* Create a configuration dialog box window that belongs to Wireshark's
+ * main window and add the name of the current profile name to it's title bar
+ */
+GtkWidget *
+dlg_conf_window_new(const gchar *title)
+{
+ const char *profile_name;
+ gchar *win_name;
+ GtkWidget *win;
+
+ /*
+ * Set window title to reflect which preferences profile we are
+ * working with.
+ */
+ profile_name = get_profile_name();
+
+ win_name = g_strdup_printf("%s - Profile: %s", title, profile_name);
+ win = dlg_window_new(win_name);
- SIGNAL_CONNECT(win, "destroy", dlg_destroy_cb, NULL);
+ g_free(win_name);
return win;
}
void
dlg_set_activate(GtkWidget *widget, GtkWidget *ok_button)
{
- SIGNAL_CONNECT(widget, "activate", dlg_activate, ok_button);
+ g_signal_connect(widget, "activate", G_CALLBACK(dlg_activate), ok_button);
}
static void