forked from osmocom/wireshark
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>
This commit is contained in:
parent
f5e072a2c3
commit
e07b7953a8
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue