added a close button to the dialogs,

use the dlg_window_new function for all dialogs

svn path=/trunk/; revision=10586
This commit is contained in:
Ulf Lamping 2004-04-12 09:48:19 +00:00
parent 05aade5c91
commit d4f93b305f
5 changed files with 122 additions and 69 deletions

View File

@ -1,7 +1,7 @@
/* http_stat.c
* http_stat 2003 Jean-Michel FAYARD
*
* $Id: http_stat.c,v 1.27 2004/04/12 08:53:02 ulfl Exp $
* $Id: http_stat.c,v 1.28 2004/04/12 09:48:18 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -426,7 +426,7 @@ gtk_httpstat_init(char *optarg)
SIGNAL_CONNECT( sp->win, "destroy", win_destroy_cb, sp);
/* container for each group of status code */
main_vb = gtk_vbox_new(FALSE, 6);
main_vb = gtk_vbox_new(FALSE, 12);
gtk_container_border_width(GTK_CONTAINER(main_vb), 12);
gtk_container_add(GTK_CONTAINER(sp->win), main_vb);

View File

@ -1,7 +1,7 @@
/* rpc_progs.c
* rpc_progs 2002 Ronnie Sahlberg
*
* $Id: rpc_progs.c,v 1.22 2004/03/13 12:09:27 ulfl Exp $
* $Id: rpc_progs.c,v 1.23 2004/04/12 09:48:18 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -43,6 +43,7 @@
#include "packet-rpc.h"
#include "../globals.h"
#include "ui_util.h"
#include "dlg_utils.h"
#include "compat_macros.h"
static GtkWidget *win=NULL;
@ -316,6 +317,16 @@ win_destroy_cb(void *dummy _U_, gpointer data _U_)
}
static void
rpcprogs_gtk_dlg_close_cb(
GtkButton *button _U_,
gpointer user_data _U_)
{
gtk_grab_remove(GTK_WIDGET(user_data));
gtk_widget_destroy(GTK_WIDGET(user_data));
}
/* When called, this function will start rpcprogs
*/
void
@ -325,23 +336,23 @@ gtk_rpcprogs_init(char *optarg _U_)
GtkWidget *stat_label;
GtkWidget *tmp;
GString *error_string;
GtkWidget *bt_close;
GtkWidget *bbox;
if(win){
gdk_window_raise(win->window);
return;
}
win=window_new(GTK_WINDOW_TOPLEVEL, "ONC-RPC Program Statistics");
win=dlg_window_new("ONC-RPC Program Statistics");
SIGNAL_CONNECT(win, "destroy", win_destroy_cb, win);
vbox=gtk_vbox_new(FALSE, 0);
vbox=gtk_vbox_new(FALSE, 3);
gtk_container_add(GTK_CONTAINER(win), vbox);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
gtk_widget_show(vbox);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
stat_label=gtk_label_new("ONC-RPC Program Statistics");
gtk_box_pack_start(GTK_BOX(vbox), stat_label, FALSE, FALSE, 0);
gtk_widget_show(stat_label);
table=gtk_table_new(1, 5, TRUE);
@ -350,35 +361,26 @@ gtk_rpcprogs_init(char *optarg _U_)
tmp=gtk_label_new("Program");
gtk_table_attach_defaults(GTK_TABLE(table), tmp, 0,1,0,1);
gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT);
gtk_widget_show(tmp);
tmp=gtk_label_new("Version");
gtk_table_attach_defaults(GTK_TABLE(table), tmp, 1,2,0,1);
gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
gtk_widget_show(tmp);
tmp=gtk_label_new("Calls");
gtk_table_attach_defaults(GTK_TABLE(table), tmp, 2,3,0,1);
gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
gtk_widget_show(tmp);
tmp=gtk_label_new("Min RTT");
gtk_table_attach_defaults(GTK_TABLE(table), tmp, 3,4,0,1);
gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
gtk_widget_show(tmp);
tmp=gtk_label_new("Max RTT");
gtk_table_attach_defaults(GTK_TABLE(table), tmp, 4,5,0,1);
gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
gtk_widget_show(tmp);
tmp=gtk_label_new("Avg RTT");
gtk_table_attach_defaults(GTK_TABLE(table), tmp, 5,6,0,1);
gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
gtk_widget_show(tmp);
gtk_widget_show(table);
error_string=register_tap_listener("rpc", win, NULL, (void*)rpcprogs_reset, (void*)rpcprogs_packet, (void*)rpcprogs_draw);
if(error_string){
@ -388,6 +390,18 @@ gtk_rpcprogs_init(char *optarg _U_)
exit(1);
}
/* Button row. */
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
bt_close = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
SIGNAL_CONNECT(bt_close, "clicked", rpcprogs_gtk_dlg_close_cb, win);
gtk_widget_grab_default(bt_close);
/* Catch the "key_press_event" signal in the window, so that we can
catch the ESC key being pressed and act as if the "Close" button had
been selected. */
dlg_set_cancel(win, bt_close);
gtk_widget_show_all(win);
redissect_packets(&cfile);

View File

@ -1,7 +1,7 @@
/* sip_stat.c
* sip_stat 2004 Martin Mathieson
*
* $Id: sip_stat.c,v 1.3 2004/03/30 18:55:47 guy Exp $
* $Id: sip_stat.c,v 1.4 2004/04/12 09:48:18 ulfl Exp $
* Copied from http_stat.c
*
* Ethereal - Network traffic analyzer
@ -480,6 +480,18 @@ win_destroy_cb(GtkWindow *win _U_, gpointer data)
g_free(sp);
}
static void
sipstat_gtk_dlg_close_cb(
GtkButton *button _U_,
gpointer user_data _U_)
{
sipstat_t *sp = user_data;
gtk_grab_remove(GTK_WIDGET(sp->win));
gtk_widget_destroy(GTK_WIDGET(sp->win));
}
/* Create a new instance of gtk_sipstat. */
static void
gtk_sipstat_init(char *optarg)
@ -492,6 +504,8 @@ gtk_sipstat_init(char *optarg)
*informational_fr, *success_fr, *redirection_fr,
*client_errors_fr, *server_errors_fr, *global_failures_fr,
*request_fr;
GtkWidget *bt_close;
GtkWidget *bbox;
if (strncmp (optarg, "sip,stat,", 9) == 0)
@ -521,7 +535,7 @@ gtk_sipstat_init(char *optarg)
}
/* Create underlying window */
sp->win = window_new(GTK_WINDOW_TOPLEVEL, title);
sp->win = dlg_window_new(title);
g_free(title);
/* Set destroy callback for underlying window */
@ -529,93 +543,71 @@ gtk_sipstat_init(char *optarg)
/* Create container for all widgets */
main_vb = gtk_vbox_new(FALSE, 10);
gtk_container_border_width(GTK_CONTAINER(main_vb), 10);
main_vb = gtk_vbox_new(FALSE, 12);
gtk_container_border_width(GTK_CONTAINER(main_vb), 12);
gtk_container_add(GTK_CONTAINER(sp->win), main_vb);
gtk_widget_show(main_vb);
/* Initialise & show number of packets */
sp->packets = 0;
sp->packets_label = gtk_label_new("SIP stats (0 SIP packets)");
gtk_container_add(GTK_CONTAINER(main_vb), sp->packets_label);
gtk_widget_show(sp->packets_label);
/* Informational response frame */
informational_fr = gtk_frame_new("Informational SIP 1xx");
gtk_container_add(GTK_CONTAINER(main_vb), informational_fr);
gtk_widget_show(informational_fr);
/* Information table (within that frame) */
sp->informational_table = gtk_table_new(0, 2, FALSE);
gtk_container_add(GTK_CONTAINER(informational_fr), sp->informational_table);
gtk_widget_show(sp->informational_table);
/* Success table and frame */
success_fr = gtk_frame_new ("Success SIP 2xx");
gtk_container_add(GTK_CONTAINER(main_vb), success_fr);
gtk_widget_show(success_fr);
sp->success_table = gtk_table_new(0, 2, FALSE);
gtk_container_add(GTK_CONTAINER(success_fr), sp->success_table);
gtk_widget_show(sp->success_table);
/* Redirection table and frame */
redirection_fr = gtk_frame_new ("Redirection SIP 3xx");
gtk_container_add(GTK_CONTAINER(main_vb), redirection_fr);
gtk_widget_show(redirection_fr);
sp->redirection_table = gtk_table_new(0, 2, FALSE);
gtk_container_add(GTK_CONTAINER(redirection_fr), sp->redirection_table);
gtk_widget_show(sp->redirection_table);
/* Client Errors table and frame */
client_errors_fr = gtk_frame_new("Client errors SIP 4xx");
gtk_container_add(GTK_CONTAINER(main_vb), client_errors_fr);
gtk_widget_show(client_errors_fr);
sp->client_error_table = gtk_table_new(0, 2, FALSE);
gtk_container_add(GTK_CONTAINER(client_errors_fr), sp->client_error_table);
gtk_widget_show(sp->client_error_table);
/* Server Errors table and frame */
server_errors_fr = gtk_frame_new("Server errors SIP 5xx");
gtk_container_add(GTK_CONTAINER(main_vb), server_errors_fr);
gtk_widget_show(server_errors_fr);
sp->server_errors_table = gtk_table_new(0, 2, FALSE);
gtk_container_add(GTK_CONTAINER(server_errors_fr), sp->server_errors_table);
gtk_widget_show(sp->server_errors_table);
/* Global Failures table and frame */
global_failures_fr = gtk_frame_new("Global failures SIP 6xx");
gtk_container_add(GTK_CONTAINER(main_vb), global_failures_fr);
gtk_widget_show(global_failures_fr);
sp->global_failures_table = gtk_table_new(0, 2, FALSE);
gtk_container_add(GTK_CONTAINER(global_failures_fr), sp->global_failures_table);
gtk_widget_show(sp->global_failures_table);
/* Separator between requests and responses */
separator = gtk_hseparator_new();
gtk_container_add(GTK_CONTAINER(main_vb), separator);
/* Request table and frame */
request_fr = gtk_frame_new("List of request methods");
gtk_container_add(GTK_CONTAINER(main_vb), request_fr);
gtk_container_border_width(GTK_CONTAINER(request_fr), 0);
gtk_widget_show(request_fr);
sp->request_box = gtk_vbox_new(FALSE, 10);
gtk_container_add(GTK_CONTAINER(request_fr), sp->request_box);
gtk_widget_show(sp->request_box);
/* Register this tap listener now */
@ -635,6 +627,19 @@ gtk_sipstat_init(char *optarg)
return;
}
/* Button row. */
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
bt_close = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
SIGNAL_CONNECT(bt_close, "clicked", sipstat_gtk_dlg_close_cb, sp);
gtk_widget_grab_default(bt_close);
/* Catch the "key_press_event" signal in the window, so that we can
catch the ESC key being pressed and act as if the "Close" button had
been selected. */
dlg_set_cancel(sp->win, bt_close);
/* Display up-to-date contents */
gtk_widget_show_all(sp->win);
sip_init_hash(sp);

View File

@ -3,7 +3,7 @@
* By Pavel Mores <pvl@uh.cz>
* Win32 port: rwh@unifiedtech.com
*
* $Id: tcp_graph.c,v 1.59 2004/03/17 09:00:16 guy Exp $
* $Id: tcp_graph.c,v 1.60 2004/04/12 09:48:18 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -581,7 +581,7 @@ static void create_text_widget (struct graph *g)
GtkWidget *streamwindow, *txt_scrollw, *box;
debug(DBS_FENTRY) puts ("create_text_widget()");
streamwindow = window_new (GTK_WINDOW_TOPLEVEL, "Ethereal: Packet chain");
streamwindow = dlg_window_new ("Ethereal: Packet chain");
gtk_widget_set_name (streamwindow, "Packet chain");
WIDGET_SET_SIZE(streamwindow, TXT_WIDTH, TXT_HEIGHT);
gtk_container_border_width (GTK_CONTAINER(streamwindow), 2);
@ -722,7 +722,7 @@ static void create_drawing_area (struct graph *g)
(current.iphdr.daddr>>24)&0xff,
g_ntohs(current.tcphdr.dest)
);
g->toplevel = window_new (GTK_WINDOW_TOPLEVEL, window_title);
g->toplevel = dlg_window_new (window_title);
gtk_widget_set_name (g->toplevel, "Test Graph");
/* Create the drawing area */
@ -882,7 +882,7 @@ static void control_panel_create (struct graph *g)
g_snprintf (window_title, WINDOW_TITLE_LENGTH,
"Graph %d - Control - Ethereal", refnum);
toplevel = window_new (GTK_WINDOW_TOPLEVEL, window_title);
toplevel = dlg_window_new (window_title);
SIGNAL_CONNECT(toplevel, "destroy", callback_toplevel_destroy, g);
table = gtk_table_new (2, 1, FALSE);
@ -891,11 +891,10 @@ static void control_panel_create (struct graph *g)
gtk_table_attach (GTK_TABLE (table), notebook, 0, 1, 0, 1,
GTK_FILL|GTK_EXPAND, GTK_FILL, 5, 5);
/* bottom buttons */
/* Button row. */
bbox = dlg_button_row_new(GTK_STOCK_HELP, GTK_STOCK_CLOSE, NULL);
gtk_table_attach (GTK_TABLE (table), bbox, 0, 1, 1, 2,
GTK_FILL|GTK_EXPAND, GTK_FILL, 5, 5);
gtk_widget_show(bbox);
help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
SIGNAL_CONNECT(help_bt, "clicked", callback_create_help, g);
@ -904,6 +903,11 @@ static void control_panel_create (struct graph *g)
gtk_widget_grab_default(close_bt);
SIGNAL_CONNECT(close_bt, "clicked", callback_close, g);
/* Catch the "key_press_event" signal in the window, so that we can
catch the ESC key being pressed and act as if the "Close" button had
been selected. */
dlg_set_cancel(toplevel, close_bt);
/* gtk_widget_show_all (table); */
/* g->gui.control_panel = table; */
gtk_widget_show_all (toplevel);
@ -1019,24 +1023,26 @@ static void callback_close (GtkWidget *widget _U_, gpointer data)
static void callback_create_help(GtkWidget *widget _U_, gpointer data _U_)
{
GtkWidget *toplevel, *box, *text, *scroll, *bbox, *close_bt;
GtkWidget *toplevel, *vbox, *text, *scroll, *bbox, *close_bt;
#if GTK_MAJOR_VERSION < 2
struct graph *g = (struct graph * )data;
#else
GtkTextBuffer *buf;
#endif
toplevel = window_new (GTK_WINDOW_TOPLEVEL, "Help for TCP graphing");
toplevel = dlg_window_new ("Help for TCP graphing");
WIDGET_SET_SIZE(toplevel, 500, 400);
box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (toplevel), box);
vbox = gtk_vbox_new (FALSE, 3);
gtk_container_border_width(GTK_CONTAINER(vbox), 12);
gtk_container_add (GTK_CONTAINER (toplevel), vbox);
scroll = scrolled_window_new (NULL, NULL);
#if GTK_MAJOR_VERSION >= 2
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll),
GTK_SHADOW_IN);
#endif
gtk_box_pack_start (GTK_BOX (box), scroll, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
#if GTK_MAJOR_VERSION < 2
text = gtk_text_new (NULL, NULL);
gtk_text_set_editable (GTK_TEXT (text), FALSE);
@ -1051,14 +1057,20 @@ static void callback_create_help(GtkWidget *widget _U_, gpointer data _U_)
#endif
gtk_container_add (GTK_CONTAINER (scroll), text);
/* Button row. */
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
gtk_box_pack_start (GTK_BOX (box), bbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
gtk_widget_show(bbox);
close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
SIGNAL_CONNECT(close_bt, "clicked", callback_close_help, toplevel);
gtk_widget_grab_default(close_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 "Close" button had
been selected. */
dlg_set_cancel(toplevel, close_bt);
gtk_widget_show_all (toplevel);
}
@ -2693,7 +2705,7 @@ static void magnify_create (struct graph *g, int x, int y)
mg = g->magnify.g = (struct graph * )malloc (sizeof (struct graph));
memcpy ((void * )mg, (void * )g, sizeof (struct graph));
mg->toplevel = window_new (GTK_WINDOW_POPUP, NULL);
mg->toplevel = dlg_window_new (NULL);
mg->drawing_area = mg->toplevel;
WIDGET_SET_SIZE(mg->toplevel, g->magnify.width, g->magnify.height);
gtk_widget_set_events (mg->drawing_area, GDK_EXPOSURE_MASK

View File

@ -1,7 +1,7 @@
/* wsp_stat.c
* wsp_stat 2003 Jean-Michel FAYARD
*
* $Id: wsp_stat.c,v 1.25 2004/03/27 11:13:03 guy Exp $
* $Id: wsp_stat.c,v 1.26 2004/04/12 09:48:19 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -250,6 +250,18 @@ win_destroy_cb(GtkWindow *win _U_, gpointer data)
g_free(sp);
}
static void
wsp_gtk_dlg_close_cb(
GtkButton *button _U_,
gpointer user_data _U_)
{
wspstat_t *sp = user_data;
gtk_grab_remove(GTK_WIDGET(sp->win));
gtk_widget_destroy(GTK_WIDGET(sp->win));
}
static void
add_table_entry(wspstat_t *sp, char *str, int x, int y, int index)
{
@ -311,6 +323,8 @@ gtk_wspstat_init(char *optarg)
char *title=NULL;
GString *error_string;
GtkWidget *main_vb, *pdutypes_fr, *statuscode_fr ;
GtkWidget *bt_close;
GtkWidget *bbox;
guint32 i;
wsp_status_code_t *sc;
@ -342,50 +356,44 @@ gtk_wspstat_init(char *optarg)
sp->pdu_stats=g_malloc( (sp->num_pdus+1) * sizeof( wsp_pdu_t) );
if(filter){
sp->filter=g_strdup(filter);
title=g_strdup_printf("Ethereal: WSP statistics with filter: %s", filter);
title=g_strdup_printf("Ethereal: WAP-WSP statistics with filter: %s", filter);
} else {
sp->filter=NULL;
title=g_strdup("Ethereal: WSP statistics");
title=g_strdup("Ethereal: WAP-WSP statistics");
}
for (i=0;i<=sp->num_pdus; i++)
{
sp->pdu_stats[i].packets=0;
}
sp->win = window_new( GTK_WINDOW_TOPLEVEL, title);
sp->win = dlg_window_new(title);
g_free(title);
SIGNAL_CONNECT( sp->win, "destroy", win_destroy_cb, sp);
/* container for the two frames */
main_vb = gtk_vbox_new(FALSE, 10);
gtk_container_border_width(GTK_CONTAINER(main_vb), 10);
main_vb = gtk_vbox_new(FALSE, 3);
gtk_container_border_width(GTK_CONTAINER(main_vb), 12);
gtk_container_add(GTK_CONTAINER(sp->win), main_vb);
gtk_widget_show(main_vb);
/* PDU Types frame */
pdutypes_fr = gtk_frame_new("Summary of PDU Types (wsp.pdu_type)");
gtk_container_add(GTK_CONTAINER(main_vb), pdutypes_fr);
gtk_widget_show(pdutypes_fr);
sp->table_pdu_types = gtk_table_new( (sp->num_pdus+1) / 2 + 1, 4, FALSE);
gtk_container_add( GTK_CONTAINER( pdutypes_fr), sp->table_pdu_types);
gtk_container_set_border_width( GTK_CONTAINER(sp->table_pdu_types) , 10);
wsp_init_table(sp);
gtk_widget_show( sp->table_pdu_types );
/* Status Codes frame */
statuscode_fr = gtk_frame_new("Summary of Status Code (wsp.reply.status)");
gtk_container_add(GTK_CONTAINER(main_vb), statuscode_fr);
gtk_widget_show(statuscode_fr);
sp->table_status_code = gtk_table_new( 0, 4, FALSE);
gtk_container_add( GTK_CONTAINER( statuscode_fr), sp->table_status_code);
gtk_container_set_border_width( GTK_CONTAINER(sp->table_status_code) , 10);
sp->index = 0; /* No answers to display yet */
error_string = register_tap_listener(
"wsp",
sp,
@ -402,7 +410,21 @@ gtk_wspstat_init(char *optarg)
g_string_free(error_string, TRUE);
return ;
}
gtk_widget_show_all( sp->win );
/* Button row. */
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
bt_close = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
SIGNAL_CONNECT(bt_close, "clicked", wsp_gtk_dlg_close_cb, sp);
gtk_widget_grab_default(bt_close);
/* Catch the "key_press_event" signal in the window, so that we can
catch the ESC key being pressed and act as if the "Close" button had
been selected. */
dlg_set_cancel(sp->win, bt_close);
gtk_widget_show_all( sp->win );
retap_packets(&cfile);
}