aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/http_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/http_stat.c
parent87d87ace4e628c8826391817f67a373af1712a4f (diff)
Assorted GUI cleanups.
svn path=/trunk/; revision=8544
Diffstat (limited to 'gtk/http_stat.c')
-rw-r--r--gtk/http_stat.c90
1 files changed, 66 insertions, 24 deletions
diff --git a/gtk/http_stat.c b/gtk/http_stat.c
index 158f537525..5eb30b5132 100644
--- a/gtk/http_stat.c
+++ b/gtk/http_stat.c
@@ -1,7 +1,7 @@
/* http_stat.c
* http_stat 2003 Jean-Michel FAYARD
*
- * $Id: http_stat.c,v 1.5 2003/09/24 02:36:34 guy Exp $
+ * $Id: http_stat.c,v 1.6 2003/09/26 02:09:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -31,6 +31,7 @@
#include "epan/epan.h"
#include "menu.h"
#include "simple_dialog.h"
+#include "dlg_utils.h"
#include "tap.h"
#include "../register.h"
#include "../globals.h"
@@ -77,10 +78,8 @@ typedef struct _http_request_methode_t {
httpstat_t *sp;
} http_request_methode_t;
-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 const value_string vals_status_code[] = {
{ 100, "Continue" },
@@ -389,10 +388,10 @@ gtk_httpstat_init(char *optarg)
if(filter){
sp->filter=g_malloc(strlen(filter)+1);
strcpy(sp->filter,filter);
- title=g_strdup_printf("HTTP Stats with filter: %s", filter);
+ title=g_strdup_printf("HTTP statistics with filter: %s", filter);
} else {
sp->filter=NULL;
- title=g_strdup("HTTP Stats");
+ title=g_strdup("HTTP statistics");
}
/* top level window */
@@ -506,16 +505,14 @@ gtk_httpstat_init(char *optarg)
static void
httpstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
{
+ GString *str;
char *filter;
- char str[256];
+ str = g_string_new("http,stat,");
filter=(char *)gtk_entry_get_text(GTK_ENTRY(filter_entry));
- if(filter[0]==0){
- gtk_httpstat_init("http,stat,");
- } else {
- sprintf(str, "http,stat,%s", filter);
- gtk_httpstat_init(str);
- }
+ str = g_string_append(str, filter);
+ gtk_httpstat_init(str->str);
+ g_string_free(str, TRUE);
}
static void
@@ -525,45 +522,90 @@ 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
gtk_httpstat_cb(GtkWidget *w _U_, gpointer d _U_)
{
+ GtkWidget *dlg_box;
+ GtkWidget *filter_box, *filter_label;
+ GtkWidget *bbox, *start_button, *cancel_button;
+
/* if the window is already open, bring it to front */
if(dlg){
gdk_window_raise(dlg->window);
return;
}
- dlg=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(dlg), "HTTP Statistics");
+ dlg=dlg_window_new("Ethereal: Compute HTTP 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);
gtk_widget_show(filter_entry);
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",
httpstat_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);
}
@@ -577,6 +619,6 @@ register_tap_listener_gtkhttpstat(void)
void
register_tap_menu_gtkhttpstat(void)
{
- register_tap_menu_item("Statistics/Watch protocol/HTTP",
+ register_tap_menu_item("Statistics/Watch protocol/HTTP...",
gtk_httpstat_cb, NULL, NULL);
}