aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/smb_stat.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-09-26 02:09:44 +0000
committerGuy Harris <guy@alum.mit.edu>2003-09-26 02:09:44 +0000
commit59938a45fe143d4b4f862cf2dcebe66d727de44e (patch)
tree468c708281c137b584bb51d0f4df8c353c74a948 /gtk/smb_stat.c
parent87d87ace4e628c8826391817f67a373af1712a4f (diff)
Assorted GUI cleanups.
svn path=/trunk/; revision=8544
Diffstat (limited to 'gtk/smb_stat.c')
-rw-r--r--gtk/smb_stat.c102
1 files changed, 75 insertions, 27 deletions
diff --git a/gtk/smb_stat.c b/gtk/smb_stat.c
index b00dad787d..6b0dfd9ac8 100644
--- a/gtk/smb_stat.c
+++ b/gtk/smb_stat.c
@@ -1,7 +1,7 @@
/* smb_stat.c
* smb_stat 2003 Ronnie Sahlberg
*
- * $Id: smb_stat.c,v 1.19 2003/09/24 02:36:35 guy Exp $
+ * $Id: smb_stat.c,v 1.20 2003/09/26 02:09:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -44,6 +44,7 @@
#include "../timestats.h"
#include "compat_macros.h"
#include "../simple_dialog.h"
+#include "dlg_utils.h"
#include "../file.h"
#include "../globals.h"
#include "service_response_time_table.h"
@@ -58,19 +59,26 @@ typedef struct _smbstat_t {
srt_stat_table nt_trans_srt_table;
} smbstat_t;
+static void
+smbstat_set_title(smbstat_t *ss)
+{
+ char *title;
+ title = g_strdup_printf("SMB Service Response Time statistics: %s",
+ cf_get_display_name(&cfile));
+ gtk_window_set_title(GTK_WINDOW(ss->win), title);
+ g_free(title);
+}
static void
smbstat_reset(void *pss)
{
smbstat_t *ss=(smbstat_t *)pss;
- char title[256];
reset_srt_table_data(&ss->smb_srt_table);
reset_srt_table_data(&ss->trans2_srt_table);
reset_srt_table_data(&ss->nt_trans_srt_table);
- snprintf(title, 255, "SMB Service Response Time statistics: %s", cf_get_display_name(&cfile));
- gtk_window_set_title(GTK_WINDOW(ss->win), title);
+ smbstat_set_title(ss);
}
static int
@@ -144,7 +152,6 @@ gtk_smbstat_init(char *optarg)
GString *error_string;
int i;
GtkWidget *vbox;
- char title[256];
if(!strncmp(optarg,"smb,srt,",8)){
filter=optarg+8;
@@ -156,8 +163,7 @@ gtk_smbstat_init(char *optarg)
ss->win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(ss->win), 550, 600);
- snprintf(title, 255, "SMB Service Response Time statistics: %s", cf_get_display_name(&cfile));
- gtk_window_set_title(GTK_WINDOW(ss->win), title);
+ smbstat_set_title(ss);
SIGNAL_CONNECT(ss->win, "destroy", win_destroy_cb, ss);
vbox=gtk_vbox_new(FALSE, 0);
@@ -220,10 +226,8 @@ gtk_smbstat_init(char *optarg)
-static GtkWidget *dlg=NULL, *dlg_box;
-static GtkWidget *filter_box;
-static GtkWidget *filter_label, *filter_entry;
-static GtkWidget *start_button;
+static GtkWidget *dlg=NULL;
+static GtkWidget *filter_entry;
static void
dlg_destroy_cb(void)
@@ -232,23 +236,32 @@ dlg_destroy_cb(void)
}
static void
+dlg_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
+{
+ gtk_widget_destroy(GTK_WIDGET(parent_w));
+}
+
+static void
smbstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
{
+ GString *str;
char *filter;
- char str[256];
+ str = g_string_new("smb,srt");
filter=(char *)gtk_entry_get_text(GTK_ENTRY(filter_entry));
- if(filter[0]==0){
- gtk_smbstat_init("smb,srt");
- } else {
- sprintf(str,"smb,srt,%s", filter);
- gtk_smbstat_init(str);
+ if(filter[0]!=0){
+ g_string_sprintfa(str,",%s", filter);
}
+ gtk_smbstat_init(str->str);
+ g_string_free(str, TRUE);
}
static void
gtk_smbstat_cb(GtkWidget *w _U_, gpointer d _U_)
{
+ GtkWidget *dlg_box;
+ GtkWidget *filter_box, *filter_label;
+ GtkWidget *bbox, *start_button, *cancel_button;
char *filter;
/* if the window is already open, bring it to front */
@@ -257,24 +270,26 @@ gtk_smbstat_cb(GtkWidget *w _U_, gpointer d _U_)
return;
}
- dlg=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(dlg), "SMB Service Response Time statistics");
+ dlg=dlg_window_new("Ethereal: Compute SMB SRT statistics");
SIGNAL_CONNECT(dlg, "destroy", dlg_destroy_cb, NULL);
- dlg_box=gtk_vbox_new(FALSE, 0);
+
+ dlg_box=gtk_vbox_new(FALSE, 10);
+ gtk_container_border_width(GTK_CONTAINER(dlg_box), 10);
gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
gtk_widget_show(dlg_box);
+ /* Filter box */
+ filter_box=gtk_hbox_new(FALSE, 3);
- /* filter box */
- filter_box=gtk_hbox_new(FALSE, 10);
/* Filter label */
- gtk_container_set_border_width(GTK_CONTAINER(filter_box), 10);
filter_label=gtk_label_new("Filter:");
gtk_box_pack_start(GTK_BOX(filter_box), filter_label, FALSE, FALSE, 0);
gtk_widget_show(filter_label);
- filter_entry=gtk_entry_new_with_max_length(250);
- gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, FALSE, FALSE, 0);
+ /* Filter entry */
+ filter_entry=gtk_entry_new();
+ gtk_widget_set_usize(filter_entry, 300, -2);
+ gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, TRUE, TRUE, 0);
filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
if(filter){
gtk_entry_set_text(GTK_ENTRY(filter_entry), filter);
@@ -284,14 +299,47 @@ gtk_smbstat_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
gtk_widget_show(filter_box);
+ /* button box */
+ bbox=gtk_hbutton_box_new();
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_DEFAULT_STYLE);
+ gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
+ gtk_box_pack_start(GTK_BOX(dlg_box), bbox, FALSE, FALSE, 0);
+ gtk_widget_show(bbox);
/* the start button */
start_button=gtk_button_new_with_label("Create Stat");
SIGNAL_CONNECT_OBJECT(start_button, "clicked",
smbstat_start_button_clicked, NULL);
- gtk_box_pack_start(GTK_BOX(dlg_box), start_button, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(bbox), start_button, TRUE, TRUE, 0);
+ GTK_WIDGET_SET_FLAGS(start_button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default(start_button);
gtk_widget_show(start_button);
+#if GTK_MAJOR_VERSION < 2
+ cancel_button=gtk_button_new_with_label("Cancel");
+#else
+ cancel_button=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#endif
+ SIGNAL_CONNECT(cancel_button, "clicked", dlg_cancel_cb, dlg);
+ GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start(GTK_BOX(bbox), cancel_button, TRUE, TRUE, 0);
+ gtk_widget_show(cancel_button);
+
+ /* Catch the "activate" signal on the filter text entry, so that
+ if the user types Return there, we act as if the "Create Stat"
+ button had been selected, as happens if Return is typed if some
+ widget that *doesn't* handle the Return key has the input
+ focus. */
+ dlg_set_activate(filter_entry, start_button);
+
+ /* Catch the "key_press_event" signal in the window, so that we can
+ catch the ESC key being pressed and act as if the "Cancel" button
+ had been selected. */
+ dlg_set_cancel(dlg, cancel_button);
+
+ /* Give the initial focus to the "Filter" entry box. */
+ gtk_widget_grab_focus(filter_entry);
+
gtk_widget_show_all(dlg);
}
@@ -304,6 +352,6 @@ register_tap_listener_gtksmbstat(void)
void
register_tap_menu_gtksmbstat(void)
{
- register_tap_menu_item("Statistics/Service Response Time/SMB",
+ register_tap_menu_item("Statistics/Service Response Time/SMB...",
gtk_smbstat_cb, NULL, NULL);
}