From d6eeb0936db40bb3b402fa31c87521981fe3d0eb Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Sat, 22 May 2004 19:56:19 +0000 Subject: going to have a standard behaviour of the dialogs (including remebering of the dialog size in recent file). for a first step, I replaced all window_new() calls from dialogs into dlg_window_new() ones, and removed all gtk_window_set_position calls, this should be done in a more generalized way svn path=/trunk/; revision=10964 --- gtk/color_dlg.c | 3 +-- gtk/dlg_utils.c | 48 +++++++++++++++++++++++++++++++++++++----------- gtk/dlg_utils.h | 6 +++++- gtk/follow_dlg.c | 4 ++-- gtk/gsm_map_summary.c | 5 ++--- gtk/h225_counter.c | 4 ++-- gtk/help_dlg.c | 11 ++++------- gtk/io_stat.c | 6 ++---- gtk/mgcp_stat.c | 4 ++-- gtk/mtp3_summary.c | 5 ++--- gtk/rtp_analysis.c | 5 ++--- gtk/summary_dlg.c | 3 +-- 12 files changed, 62 insertions(+), 42 deletions(-) diff --git a/gtk/color_dlg.c b/gtk/color_dlg.c index 79feb05fc5..0b7ac8711e 100644 --- a/gtk/color_dlg.c +++ b/gtk/color_dlg.c @@ -1,7 +1,7 @@ /* color_dlg.c * Definitions for dialog boxes for color filters * - * $Id: color_dlg.c,v 1.47 2004/05/01 17:22:09 obiot Exp $ + * $Id: color_dlg.c,v 1.48 2004/05/22 19:56:18 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1208,7 +1208,6 @@ edit_color_filter_dialog_new(GtkWidget *color_filters, /* dialog window */ edit_dialog = dlg_window_new ("Ethereal: Edit Color Filter"); gtk_window_set_default_size(GTK_WINDOW(edit_dialog), 500, -1); - /* gtk_window_set_position(GTK_WINDOW(edit_dialog), GTK_WIN_POS_MOUSE); */ OBJECT_SET_DATA(edit_dialog, "edit_dialog", edit_dialog); colorf->edit_dialog = edit_dialog; diff --git a/gtk/dlg_utils.c b/gtk/dlg_utils.c index fba86ccd33..105a954f33 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.30 2004/05/21 00:25:04 ulfl Exp $ + * $Id: dlg_utils.c,v 1.31 2004/05/22 19:56:18 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -286,16 +286,21 @@ dlg_button_row_new(gchar *stock_id_first, ...) } -#if GTK_MAJOR_VERSION >= 2 /* this is called, when a dialog was closed */ -void on_dialog_destroyed(GtkWidget *dialog _U_, gpointer data) +void on_dialog_destroyed(GtkWidget *dialog _U_, gpointer data _U_) { - /* 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(data)); -} +#if GTK_MAJOR_VERSION >= 2 + 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 + /* XXX - saved the size of this dialog */ + /* currently unclear, how the dialogs should be identified */ +} + /* Create a dialog box window that belongs to Ethereal's main window. */ GtkWidget * @@ -325,15 +330,36 @@ dlg_window_new(const gchar *title) if (top_level) { gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(top_level)); } + + SIGNAL_CONNECT(win, "destroy", on_dialog_destroyed, win); + + return win; +} + +void +dlg_window_present(GtkWidget *win, GtkWindowPosition pos) +{ + + /* to stay compatible with GTK1.x, only these three pos values are allowed */ + g_assert( + pos == GTK_WIN_POS_NONE || + pos == GTK_WIN_POS_CENTER || + pos == GTK_WIN_POS_MOUSE); /* preferred for most dialogs */ + #if GTK_MAJOR_VERSION >= 2 - gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ON_PARENT); - if(top_level) - SIGNAL_CONNECT(win, "destroy", on_dialog_destroyed, top_level); gtk_window_present(GTK_WINDOW(win)); + + if(pos == GTK_WIN_POS_CENTER) { + pos = GTK_WIN_POS_CENTER_ON_PARENT; + } #endif - return win; + gtk_window_set_position(GTK_WINDOW(win), pos); + + /* XXX - set a previously saved size of this dialog */ + /* currently unclear, how the dialogs should be identified */ } + /* Create a file selection dialog box window that belongs to Ethereal's main window. */ #if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2 diff --git a/gtk/dlg_utils.h b/gtk/dlg_utils.h index d0e1f10393..151c33a089 100644 --- a/gtk/dlg_utils.h +++ b/gtk/dlg_utils.h @@ -1,7 +1,7 @@ /* dlg_utils.h * Declarations of utilities to use when constructing dialogs * - * $Id: dlg_utils.h,v 1.12 2004/03/29 22:55:13 guy Exp $ + * $Id: dlg_utils.h,v 1.13 2004/05/22 19:56:18 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -28,6 +28,10 @@ /* Create a dialog box window that belongs to Ethereal's main window. */ extern GtkWidget *dlg_window_new(const gchar *); +/* Show the created dialog box window. */ +/* use GTK_WIN_POS_CENTER or GTK_WIN_POS_MOUSE only! */ +extern void dlg_window_present(GtkWidget *win, GtkWindowPosition pos); + /* Create a file selection dialog box window that belongs to Ethereal's main window. */ typedef enum { diff --git a/gtk/follow_dlg.c b/gtk/follow_dlg.c index 33fd895bd4..3d81b64bd8 100644 --- a/gtk/follow_dlg.c +++ b/gtk/follow_dlg.c @@ -1,6 +1,6 @@ /* follow_dlg.c * - * $Id: follow_dlg.c,v 1.58 2004/05/09 10:03:40 guy Exp $ + * $Id: follow_dlg.c,v 1.59 2004/05/22 19:56:18 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -247,7 +247,7 @@ follow_stream_cb(GtkWidget * w, gpointer data _U_) fclose(data_out_file); /* The data_out_filename file now has all the text that was in the session */ - streamwindow = window_new(GTK_WINDOW_TOPLEVEL, "Follow TCP stream"); + streamwindow = dlg_window_new("Follow TCP stream"); /* needed in follow_filter_out_stream(), is there a better way? */ follow_info->streamwindow = streamwindow; diff --git a/gtk/gsm_map_summary.c b/gtk/gsm_map_summary.c index cee0d109d6..486844dc50 100644 --- a/gtk/gsm_map_summary.c +++ b/gtk/gsm_map_summary.c @@ -6,7 +6,7 @@ * * Modified from summary_dlg.c * - * $Id: gsm_map_summary.c,v 1.1 2004/04/21 17:57:31 guy Exp $ + * $Id: gsm_map_summary.c,v 1.2 2004/05/22 19:56:18 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -85,7 +85,7 @@ gsm_map_stat_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) /* initial compututations */ seconds = summary.stop_time - summary.start_time; - sum_open_w = window_new(GTK_WINDOW_TOPLEVEL, "GSM MAP Statistics: Summary"); + sum_open_w = dlg_window_new("GSM MAP Statistics: Summary"); /* Container for each row of widgets */ main_vb = gtk_vbox_new(FALSE, 3); @@ -257,7 +257,6 @@ gsm_map_stat_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) been selected. */ dlg_set_cancel(sum_open_w, close_bt); - gtk_window_set_position(GTK_WINDOW(sum_open_w), GTK_WIN_POS_MOUSE); gtk_widget_show(sum_open_w); } diff --git a/gtk/h225_counter.c b/gtk/h225_counter.c index 5d6f4a940b..7c89e3d462 100644 --- a/gtk/h225_counter.c +++ b/gtk/h225_counter.c @@ -2,7 +2,7 @@ * h225 message counter for ethereal * Copyright 2003 Lars Roland * - * $Id: h225_counter.c,v 1.18 2004/04/12 08:53:02 ulfl Exp $ + * $Id: h225_counter.c,v 1.19 2004/05/22 19:56:18 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -523,7 +523,7 @@ gtk_h225counter_init(char *optarg) h225counter_reset(hs); - hs->win=window_new(GTK_WINDOW_TOPLEVEL, NULL); + hs->win=dlg_window_new("Ethereal: H225 counters"); SIGNAL_CONNECT(hs->win, "destroy", win_destroy_cb, hs); hs->vbox=gtk_vbox_new(FALSE, 3); diff --git a/gtk/help_dlg.c b/gtk/help_dlg.c index 64764c17ea..6c403caac5 100644 --- a/gtk/help_dlg.c +++ b/gtk/help_dlg.c @@ -1,6 +1,6 @@ /* help_dlg.c * - * $Id: help_dlg.c,v 1.51 2004/05/22 04:25:57 guy Exp $ + * $Id: help_dlg.c,v 1.52 2004/05/22 19:56:18 ulfl Exp $ * * Laurent Deniel * @@ -174,7 +174,7 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_) return; } - help_w = window_new(GTK_WINDOW_TOPLEVEL, "Ethereal: Help"); + help_w = dlg_window_new("Ethereal: Help"); SIGNAL_CONNECT(help_w, "destroy", help_destroy_cb, NULL); /* XXX: improve this, e.g. remember the last window size in a file */ WIDGET_SET_SIZE(help_w, DEF_WIDTH, DEF_HEIGHT); @@ -184,7 +184,6 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_) main_vb = gtk_vbox_new(FALSE, 1); gtk_container_border_width(GTK_CONTAINER(main_vb), 1); gtk_container_add(GTK_CONTAINER(help_w), main_vb); - gtk_widget_show(main_vb); /* help topics container */ help_nb = gtk_notebook_new(); @@ -219,13 +218,10 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_) } fclose(help_toc_file); - gtk_widget_show(help_nb); /* Buttons (only "Ok" for now) */ bbox = dlg_button_row_new(GTK_STOCK_OK, NULL); - gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5); - gtk_widget_show(bbox); close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK); SIGNAL_CONNECT(close_bt, "clicked", help_close_cb, help_w); @@ -238,7 +234,8 @@ void help_cb(GtkWidget *w _U_, gpointer data _U_) been selected. */ dlg_set_cancel(help_w, close_bt); - gtk_widget_show(help_w); + gtk_widget_show_all(help_w); + dlg_window_present(help_w, GTK_WIN_POS_MOUSE); } /* help_cb */ diff --git a/gtk/io_stat.c b/gtk/io_stat.c index a634d38d17..a590967e96 100644 --- a/gtk/io_stat.c +++ b/gtk/io_stat.c @@ -1,7 +1,7 @@ /* io_stat.c * io_stat 2002 Ronnie Sahlberg * - * $Id: io_stat.c,v 1.74 2004/04/17 01:01:22 guy Exp $ + * $Id: io_stat.c,v 1.75 2004/05/22 19:56:18 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1886,9 +1886,7 @@ init_io_stat_window(io_stat_t *io) GtkWidget *bt_close; /* create the main window */ - io->window=window_new(GTK_WINDOW_TOPLEVEL, NULL); - - gtk_widget_set_name(io->window, "I/O Statistics"); + io->window=dlg_window_new("I/O Graphs"); vbox=gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(io->window), vbox); diff --git a/gtk/mgcp_stat.c b/gtk/mgcp_stat.c index 441ac7e917..b9ea9acaa9 100644 --- a/gtk/mgcp_stat.c +++ b/gtk/mgcp_stat.c @@ -2,7 +2,7 @@ * mgcp-statistics for ethereal * Copyright 2003 Lars Roland * - * $Id: mgcp_stat.c,v 1.33 2004/03/27 11:13:02 guy Exp $ + * $Id: mgcp_stat.c,v 1.34 2004/05/22 19:56:19 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -276,7 +276,7 @@ gtk_mgcpstat_init(char *optarg) mgcpstat_reset(ms); - ms->win=window_new(GTK_WINDOW_TOPLEVEL, NULL); + ms->win=dlg_window_new("MGCP SRT"); SIGNAL_CONNECT(ms->win, "destroy", win_destroy_cb, ms); ms->vbox=gtk_vbox_new(FALSE, 0); diff --git a/gtk/mtp3_summary.c b/gtk/mtp3_summary.c index 74e14357cd..e339c763fa 100644 --- a/gtk/mtp3_summary.c +++ b/gtk/mtp3_summary.c @@ -6,7 +6,7 @@ * * Modified from gsm_map_summary.c * - * $Id: mtp3_summary.c,v 1.1 2004/04/21 17:57:31 guy Exp $ + * $Id: mtp3_summary.c,v 1.2 2004/05/22 19:56:19 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -258,7 +258,7 @@ mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) /* initial compututations */ seconds = summary.stop_time - summary.start_time; - sum_open_w = window_new(GTK_WINDOW_TOPLEVEL, "MTP3 Statistics: Summary"); + sum_open_w = dlg_window_new("MTP3 Statistics: Summary"); /* Container for each row of widgets */ main_vb = gtk_vbox_new(FALSE, 3); @@ -435,7 +435,6 @@ mtp3_sum_gtk_sum_cb(GtkWidget *w _U_, gpointer d _U_) been selected. */ dlg_set_cancel(sum_open_w, close_bt); - gtk_window_set_position(GTK_WINDOW(sum_open_w), GTK_WIN_POS_MOUSE); gtk_widget_show_all(sum_open_w); } diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index d47352e1c1..6235e03bd4 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -1,7 +1,7 @@ /* rtp_analysis.c * RTP analysis addition for ethereal * - * $Id: rtp_analysis.c,v 1.40 2004/03/13 12:09:27 ulfl Exp $ + * $Id: rtp_analysis.c,v 1.41 2004/05/22 19:56:19 ulfl Exp $ * * Copyright 2003, Alcatel Business Systems * By Lars Ruoff @@ -1920,8 +1920,7 @@ void create_rtp_dialog(user_data_t* user_data) column_arrows *col_arrows_rev; - window = window_new (GTK_WINDOW_TOPLEVEL, "Ethereal: RTP Stream Analysis"); - gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); + window = dlg_window_new("Ethereal: RTP Stream Analysis"); SIGNAL_CONNECT(window, "destroy", on_destroy, user_data); /* Container for each row of widgets */ diff --git a/gtk/summary_dlg.c b/gtk/summary_dlg.c index 579481f763..c332711fac 100644 --- a/gtk/summary_dlg.c +++ b/gtk/summary_dlg.c @@ -1,7 +1,7 @@ /* summary_dlg.c * Routines for capture file summary window * - * $Id: summary_dlg.c,v 1.31 2004/05/21 08:55:07 ulfl Exp $ + * $Id: summary_dlg.c,v 1.32 2004/05/22 19:56:19 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -312,6 +312,5 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_) been selected. */ dlg_set_cancel(sum_open_w, close_bt); - gtk_window_set_position(GTK_WINDOW(sum_open_w), GTK_WIN_POS_MOUSE); gtk_widget_show_all(sum_open_w); } -- cgit v1.2.3