Rename the tap_dfilter_dlg.[ch] files to reflect that they can do more
[obnox/wireshark/wip.git] / gtk / fc_stat.c
index 1837901ad4cb696690253a90e0f92ea83e731326..599a8dfe8e821b07d04ae915bdc1f13e75cfb07f 100644 (file)
 #include <epan/packet_info.h>
 #include <epan/epan.h>
 #include <epan/value_string.h>
-
 #include <epan/tap.h>
 #include <epan/conversation.h>
 #include <epan/dissectors/packet-scsi.h>
 #include <epan/dissectors/packet-fc.h>
-#include "../register.h"
+
 #include "../timestats.h"
-#include "compat_macros.h"
 #include "../simple_dialog.h"
-#include "gui_utils.h"
-#include "dlg_utils.h"
 #include "../file.h"
-#include "../globals.h"
-#include "filter_dlg.h"
-#include "service_response_time_table.h"
 #include "../stat_menu.h"
-#include "../tap_dfilter_dlg.h"
-#include "gtkglobals.h"
+
+#include "gtk/gui_utils.h"
+#include "gtk/dlg_utils.h"
+#include "gtk/filter_dlg.h"
+#include "gtk/service_response_time_table.h"
+#include "gtk/tap_param_dlg.h"
+#include "gtk/gtkglobals.h"
+#include "gtk/main.h"
 
 
 /* used to keep track of the statistics for an entire program interface */
@@ -114,8 +113,6 @@ fcstat_draw(void *pfc)
 }
 
 
-void protect_thread_critical_region(void);
-void unprotect_thread_critical_region(void);
 static void
 win_destroy_cb(GtkWindow *win _U_, gpointer data)
 {
@@ -136,7 +133,7 @@ gtk_fcstat_init(const char *optarg, void *userdata _U_)
        fcstat_t *fc;
        const char *filter=NULL;
        GtkWidget *label;
-       char filter_string[256];
+       char *filter_string;
        GString *error_string;
        int i;
        GtkWidget *vbox;
@@ -151,7 +148,9 @@ gtk_fcstat_init(const char *optarg, void *userdata _U_)
 
        fc=g_malloc(sizeof(fcstat_t));
 
-       fc->win=window_new(GTK_WINDOW_TOPLEVEL, "fc-stat");
+       fc->win = dlg_window_new("fc-stat");  /* transient_for top_level */
+       gtk_window_set_destroy_with_parent (GTK_WINDOW(fc->win), TRUE);
+
        gtk_window_set_default_size(GTK_WINDOW(fc->win), 550, 400);
        fcstat_set_title(fc);
 
@@ -162,8 +161,10 @@ gtk_fcstat_init(const char *optarg, void *userdata _U_)
        label=gtk_label_new("Fibre Channel Service Response Time statistics");
        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
-       g_snprintf(filter_string,255,"Filter:%s",filter?filter:"");
+       filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
        label=gtk_label_new(filter_string);
+       g_free(filter_string);
+       gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
 
        label=gtk_label_new("Fibre Channel Types");
@@ -178,9 +179,9 @@ gtk_fcstat_init(const char *optarg, void *userdata _U_)
        }
 
 
-       error_string=register_tap_listener("fc", fc, filter, fcstat_reset, fcstat_packet, fcstat_draw);
+       error_string=register_tap_listener("fc", fc, filter, 0, fcstat_reset, fcstat_packet, fcstat_draw);
        if(error_string){
-               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
+               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
                g_string_free(error_string, TRUE);
                g_free(fc);
                return;
@@ -190,23 +191,30 @@ gtk_fcstat_init(const char *optarg, void *userdata _U_)
        bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
        gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
 
-       close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
+       close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
        window_set_cancel_button(fc->win, close_bt, window_cancel_button_cb);
 
-       SIGNAL_CONNECT(fc->win, "delete_event", window_delete_event_cb, NULL);
-       SIGNAL_CONNECT(fc->win, "destroy", win_destroy_cb, fc);
+       g_signal_connect(fc->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
+       g_signal_connect(fc->win, "destroy", G_CALLBACK(win_destroy_cb), fc);
 
        gtk_widget_show_all(fc->win);
        window_present(fc->win);
 
-       cf_retap_packets(&cfile, FALSE);
+       cf_retap_packets(&cfile);
+       gdk_window_raise(fc->win->window);
 }
 
-static tap_dfilter_dlg fc_stat_dlg = {
+static tap_param fc_stat_params[] = {
+       { PARAM_FILTER, "Filter", NULL }
+};
+
+static tap_param_dlg fc_stat_dlg = {
        "Fibre Channel Service Response Time statistics",
        "fc,srt",
        gtk_fcstat_init,
-       -1
+       -1,
+       G_N_ELEMENTS(fc_stat_params),
+       fc_stat_params
 };
 
 void