summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorChris Maynard <Christopher.Maynard@GTECH.COM>2014-06-19 12:40:11 -0700
committerBalint Reczey <balint@balintreczey.hu>2014-06-19 22:21:05 +0000
commite07b7953a80af30ad1f7dd51f8c8f773cd514f56 (patch)
tree76435e218cad8830ce01565d769ec8f60d5bab63 /ui
parentf5e072a2c3fb913bf4615bee77e8f4b7fd14dae8 (diff)
downloadwireshark-e07b7953a80af30ad1f7dd51f8c8f773cd514f56.tar.gz
Save the size and position of the expert info dialog
Set initialize position to center on parent bug: 3817 Change-Id: Iad48aa762d892908d50f742606160c8305084f48 Reviewed-on: https://code.wireshark.org/review/2459 Reviewed-by: Balint Reczey <balint@balintreczey.hu> Tested-by: Balint Reczey <balint@balintreczey.hu>
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/dlg_utils.c36
-rw-r--r--ui/gtk/dlg_utils.h13
-rw-r--r--ui/gtk/expert_comp_dlg.c3
-rw-r--r--ui/gtk/gui_utils.c14
-rw-r--r--ui/gtk/gui_utils.h4
-rw-r--r--ui/gtk/mac_lte_stat_dlg.c2
-rw-r--r--ui/gtk/rlc_lte_stat_dlg.c2
-rw-r--r--ui/gtk/stats_tree_stat.c2
-rw-r--r--ui/gtk/tap_param_dlg.c2
-rw-r--r--ui/gtk/wlan_stat_dlg.c12
10 files changed, 77 insertions, 13 deletions
diff --git a/ui/gtk/dlg_utils.c b/ui/gtk/dlg_utils.c
index 36fb2c90ea..28a2875a81 100644
--- a/ui/gtk/dlg_utils.c
+++ b/ui/gtk/dlg_utils.c
@@ -471,6 +471,42 @@ dlg_window_new(const gchar *title)
return win;
}
+/* Create a dialog box window that belongs to Wireshark's main window. */
+GtkWidget *
+dlg_window_new_with_geom(const gchar *title, const gchar *geom_name, GtkWindowPosition pos)
+{
+ GtkWidget *win;
+
+ win = window_new_with_geom(GTK_WINDOW_TOPLEVEL, title, geom_name ? geom_name : title, pos);
+
+ /*
+ * XXX - if we're running in the capture child process, we can't easily
+ * make this window transient for the main process's window. We just
+ * punt here.
+ *
+ * Perhaps the child process should only capture packets, write them to
+ * a file, and somehow notify the parent process and let *it* do all
+ * the GUI work. If we can do that efficiently (so that we don't drop
+ * more packets), perhaps we can also do so even when we're *not* doing
+ * an "Update list of packets in real time" capture. That'd let the
+ * child process run set-UID on platforms where you need that in order
+ * 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 its title bar
*/
diff --git a/ui/gtk/dlg_utils.h b/ui/gtk/dlg_utils.h
index 878a55625f..bf5231ede2 100644
--- a/ui/gtk/dlg_utils.h
+++ b/ui/gtk/dlg_utils.h
@@ -101,6 +101,19 @@
*/
extern GtkWidget *dlg_window_new(const gchar *title);
+/** Create a dialog box window that belongs to Wireshark's main window.
+ * If you want to create a window, use window_new_with_geom() instead.
+ * See window_new_with_geom() for general window usage.
+ *
+ * @param title the title for the new dialog
+ * @param geom_name A unique name for the geometry of this new dialog
+ * @parm pos the initial position of the window if a previously saved geometry was not saved or found.
+ * If the initial position does not matter, specify GTK_WIN_POS_NONE.
+ * @return the newly created dialog
+ */
+extern GtkWidget *
+dlg_window_new_with_geom(const gchar *title, const gchar *geom_name, GtkWindowPosition pos);
+
/** Create a configuration dialog box window that belongs to Wireshark's
* main window and add the name of the current profile name to its title bar
* If you want to create a window, use window_new() instead.
diff --git a/ui/gtk/expert_comp_dlg.c b/ui/gtk/expert_comp_dlg.c
index bbce45f834..c604709a53 100644
--- a/ui/gtk/expert_comp_dlg.c
+++ b/ui/gtk/expert_comp_dlg.c
@@ -781,7 +781,8 @@ expert_comp_init(const char *opt_arg _U_, void* userdata _U_)
ss->warn_events = 0;
ss->error_events = 0;
- expert_comp_dlg_w = ss->win=dlg_window_new("err"); /* transient_for top_level */
+ expert_comp_dlg_w = ss->win = dlg_window_new_with_geom("Expert Info",
+ NULL, GTK_WIN_POS_CENTER_ON_PARENT); /* transient_for top_level */
gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE);
gtk_window_set_default_size(GTK_WINDOW(ss->win), 700, 300);
diff --git a/ui/gtk/gui_utils.c b/ui/gtk/gui_utils.c
index 62607ca430..5d72960f3d 100644
--- a/ui/gtk/gui_utils.c
+++ b/ui/gtk/gui_utils.c
@@ -186,7 +186,8 @@ window_new(GtkWindowType type,
GtkWidget *
window_new_with_geom(GtkWindowType type,
const gchar *title,
- const gchar *geom_name)
+ const gchar *geom_name,
+ GtkWindowPosition pos)
{
window_geometry_t geom;
GtkWidget *win = window_new(type, title);
@@ -203,6 +204,17 @@ window_new_with_geom(GtkWindowType type,
geom.set_size = TRUE;
geom.set_maximized = FALSE; /* don't maximize until window is shown */
window_set_geometry(win, &geom);
+ } else if (pos != GTK_WIN_POS_NONE) {
+#ifdef _WIN32
+ /* Testing using GTK+ 2.24.10 shows that
+ * GTK_WIN_POS_CENTER_ON_PARENT doesn't seem to work on Windows, so
+ * use the next best thing. Is this a problem for all OS's though,
+ * or just Windows? Unknown. (Tested with Windows XP SP3 32-bit)
+ */
+ if (pos == GTK_WIN_POS_CENTER_ON_PARENT)
+ pos = GTK_WIN_POS_CENTER;
+#endif
+ gtk_window_set_position(GTK_WINDOW(win), pos);
}
}
diff --git a/ui/gtk/gui_utils.h b/ui/gtk/gui_utils.h
index e9174239cd..68624cb835 100644
--- a/ui/gtk/gui_utils.h
+++ b/ui/gtk/gui_utils.h
@@ -109,9 +109,11 @@ extern GtkWidget *window_new(GtkWindowType type, const gchar *title);
* @param type window type, typical GTK_WINDOW_TOPLEVEL
* @param title the title for the new window
* @param geom_name the name to distinguish this window; will also be used for the recent file (don't use special chars)
+ * @parm pos the initial position of the window if a previously saved geometry was not saved or found.
+ * If the initial position does not matter, specify GTK_WIN_POS_NONE.
* @return the newly created window
*/
-extern GtkWidget *window_new_with_geom(GtkWindowType type, const gchar *title, const gchar *geom_name);
+extern GtkWidget *window_new_with_geom(GtkWindowType type, const gchar *title, const gchar *geom_name, GtkWindowPosition pos);
/** Create a new splash window, with no icon or title bar.
*
diff --git a/ui/gtk/mac_lte_stat_dlg.c b/ui/gtk/mac_lte_stat_dlg.c
index a9a8785cbb..0e9afd504a 100644
--- a/ui/gtk/mac_lte_stat_dlg.c
+++ b/ui/gtk/mac_lte_stat_dlg.c
@@ -1068,7 +1068,7 @@ static void gtk_mac_lte_stat_init(const char *opt_arg, void *userdata _U_)
g_free(display_name);
/* Create top-level window */
- hs->mac_lte_stat_dlg_w = window_new_with_geom(GTK_WINDOW_TOPLEVEL, title, "LTE MAC Statistics");
+ hs->mac_lte_stat_dlg_w = window_new_with_geom(GTK_WINDOW_TOPLEVEL, title, "LTE MAC Statistics", GTK_WIN_POS_CENTER_ON_PARENT);
/* Window size */
gtk_window_set_default_size(GTK_WINDOW(hs->mac_lte_stat_dlg_w), 750, 300);
diff --git a/ui/gtk/rlc_lte_stat_dlg.c b/ui/gtk/rlc_lte_stat_dlg.c
index 5e277e0dd3..87716a6e56 100644
--- a/ui/gtk/rlc_lte_stat_dlg.c
+++ b/ui/gtk/rlc_lte_stat_dlg.c
@@ -1316,7 +1316,7 @@ static void gtk_rlc_lte_stat_init(const char *opt_arg, void *userdata _U_)
g_snprintf(title, sizeof(title), "Wireshark: LTE RLC Statistics: %s",
display_name);
g_free(display_name);
- hs->dlg_w = window_new_with_geom(GTK_WINDOW_TOPLEVEL, title, "LTE RLC Statistics");
+ hs->dlg_w = window_new_with_geom(GTK_WINDOW_TOPLEVEL, title, "LTE RLC Statistics", GTK_WIN_POS_CENTER_ON_PARENT);
/* Window size */
gtk_window_set_default_size(GTK_WINDOW(hs->dlg_w), 600, 300);
diff --git a/ui/gtk/stats_tree_stat.c b/ui/gtk/stats_tree_stat.c
index 76681f4760..73e1afdb98 100644
--- a/ui/gtk/stats_tree_stat.c
+++ b/ui/gtk/stats_tree_stat.c
@@ -451,7 +451,7 @@ init_gtk_tree(const char* opt_arg, void *userdata _U_)
window_name = g_strdup_printf("%s Stats Tree", st->display_name);
- st->pr->win = window_new_with_geom(GTK_WINDOW_TOPLEVEL,window_name,window_name);
+ st->pr->win = window_new_with_geom(GTK_WINDOW_TOPLEVEL, window_name, NULL, GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_default_size(GTK_WINDOW(st->pr->win), st->num_columns*80+80, 400);
g_free(window_name);
diff --git a/ui/gtk/tap_param_dlg.c b/ui/gtk/tap_param_dlg.c
index 5c43af8a00..dc07ac6abc 100644
--- a/ui/gtk/tap_param_dlg.c
+++ b/ui/gtk/tap_param_dlg.c
@@ -247,7 +247,7 @@ tap_param_dlg_cb(GtkAction *action _U_, gpointer data)
title = g_strdup_printf("Wireshark: %s: %s", current_dlg->cont.win_title , display_name);
g_free(display_name);
- current_dlg->dlg=dlg_window_new(title);
+ current_dlg->dlg=dlg_window_new_with_geom(title, current_dlg->cont.win_title, GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_default_size(GTK_WINDOW(current_dlg->dlg), 300, -1);
g_free(title);
diff --git a/ui/gtk/wlan_stat_dlg.c b/ui/gtk/wlan_stat_dlg.c
index 7f0d4f0438..65b969e0da 100644
--- a/ui/gtk/wlan_stat_dlg.c
+++ b/ui/gtk/wlan_stat_dlg.c
@@ -1753,12 +1753,12 @@ wlanstat_dlg_create (void)
hs->use_dfilter = FALSE;
hs->show_only_existing = FALSE;
- display_name = cf_get_display_name(&cfile);
- g_snprintf (title, sizeof(title), "Wireshark: WLAN Traffic Statistics: %s",
- display_name);
- g_free(display_name);
- wlanstat_dlg_w = window_new_with_geom (GTK_WINDOW_TOPLEVEL, title, "WLAN Statistics");
- gtk_window_set_default_size (GTK_WINDOW(wlanstat_dlg_w), 750, 400);
+ display_name = cf_get_display_name(&cfile);
+ g_snprintf (title, sizeof(title), "Wireshark: WLAN Traffic Statistics: %s",
+ display_name);
+ g_free(display_name);
+ wlanstat_dlg_w = window_new_with_geom (GTK_WINDOW_TOPLEVEL, title, "WLAN Statistics", GTK_WIN_POS_CENTER_ON_PARENT);
+ gtk_window_set_default_size (GTK_WINDOW(wlanstat_dlg_w), 750, 400);
vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
gtk_container_add(GTK_CONTAINER(wlanstat_dlg_w), vbox);