merge_all_tap_menus() has been moved to menus.c.
[obnox/wireshark/wip.git] / gtk / gsm_map_stat.c
index c174e865695d15e386564a7d12dbaee43cf34594..7db2c3b84daa082f36bd50adbc52293955c2bda7 100644 (file)
@@ -48,8 +48,6 @@
 
 #include "../stat_menu.h"
 #include "../simple_dialog.h"
-#include "../register.h"
-#include "../globals.h"
 
 #include "gtk/gui_stat_menu.h"
 #include "gtk/dlg_utils.h"
@@ -57,6 +55,7 @@
 #include "gtk/filter_dlg.h"
 #include "gtk/gsm_map_stat.h"
 
+#include "gtk/old-gtk-compat.h"
 
 enum
 {
@@ -105,10 +104,8 @@ GtkWidget* create_list(void)
     list_view = GTK_TREE_VIEW(list);
     sortable = GTK_TREE_SORTABLE(list_store);
 
-#if GTK_CHECK_VERSION(2,6,0)
     /* Speed up the list display */
     gtk_tree_view_set_fixed_height_mode(list_view, TRUE);
-#endif
 
     /* Setup the sortable columns */
     gtk_tree_sortable_set_sort_column_id(sortable, ID_COLUMN, GTK_SORT_ASCENDING);
@@ -117,14 +114,14 @@ GtkWidget* create_list(void)
     /* The view now holds a reference.  We can get rid of our own reference */
     g_object_unref (G_OBJECT (list_store));
 
-    /* 
+    /*
      * Create the first column packet, associating the "text" attribute of the
-     * cell_renderer to the first column of the model 
+     * cell_renderer to the first column of the model
      */
     /* 1:st column */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("ID", renderer, 
-        "text", ID_COLUMN, 
+    column = gtk_tree_view_column_new_with_attributes ("ID", renderer,
+        "text", ID_COLUMN,
         NULL);
 
     gtk_tree_view_column_set_sort_column_id(column, ID_COLUMN);
@@ -137,7 +134,7 @@ GtkWidget* create_list(void)
 
     /* 2:nd column..Operation Code. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("Operation Code", renderer, 
+    column = gtk_tree_view_column_new_with_attributes ("Operation Code", renderer,
         "text", OP_CODE_COLUMN,
         NULL);
     gtk_tree_view_column_set_sort_column_id(column, OP_CODE_COLUMN);
@@ -148,7 +145,7 @@ GtkWidget* create_list(void)
 
     /* 3:d column..Invokes. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("Invokes", renderer, 
+    column = gtk_tree_view_column_new_with_attributes ("Invokes", renderer,
         "text", INVOKES_COLUMN,
         NULL);
     gtk_tree_view_column_set_sort_column_id(column, INVOKES_COLUMN);
@@ -159,10 +156,10 @@ GtkWidget* create_list(void)
 
     /* 4:th column.. Num Bytes. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("Num Bytes", renderer, 
-        "text", NUM_BYTES_FWD_COLUMN, 
+    column = gtk_tree_view_column_new_with_attributes ("Num Bytes", renderer,
+        "text", NUM_BYTES_FWD_COLUMN,
         NULL);
-    
+
 
     gtk_tree_view_column_set_sort_column_id(column, NUM_BYTES_FWD_COLUMN);
     gtk_tree_view_column_set_resizable(column, TRUE);
@@ -172,10 +169,10 @@ GtkWidget* create_list(void)
 
     /* 5:th column.. Avg Bytes. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer, 
-        "text", AVG_BYTES_FWD_COLUMN, 
+    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer,
+        "text", AVG_BYTES_FWD_COLUMN,
         NULL);
-    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func, 
+    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func,
         GINT_TO_POINTER(AVG_BYTES_FWD_COLUMN), NULL);
 
     gtk_tree_view_column_set_sort_column_id(column, AVG_BYTES_FWD_COLUMN);
@@ -186,7 +183,7 @@ GtkWidget* create_list(void)
 
     /* 6:d column..Invokes. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("ReturnResult", renderer, 
+    column = gtk_tree_view_column_new_with_attributes ("ReturnResult", renderer,
         "text", RET_RES_COLUMN,
         NULL);
     gtk_tree_view_column_set_sort_column_id(column, RET_RES_COLUMN);
@@ -197,10 +194,10 @@ GtkWidget* create_list(void)
 
     /* 7:th column.. Num Bytes. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("Num Bytes", renderer, 
-        "text", NUM_BYTES_REV_COLUMN, 
+    column = gtk_tree_view_column_new_with_attributes ("Num Bytes", renderer,
+        "text", NUM_BYTES_REV_COLUMN,
         NULL);
-    
+
 
     gtk_tree_view_column_set_sort_column_id(column, NUM_BYTES_FWD_COLUMN);
     gtk_tree_view_column_set_resizable(column, TRUE);
@@ -210,10 +207,10 @@ GtkWidget* create_list(void)
 
     /* 8:th column.. Avg Bytes. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer, 
-        "text", AVG_BYTES_REV_COLUMN, 
+    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer,
+        "text", AVG_BYTES_REV_COLUMN,
         NULL);
-    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func, 
+    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func,
         GINT_TO_POINTER(AVG_BYTES_REV_COLUMN), NULL);
 
 
@@ -225,10 +222,10 @@ GtkWidget* create_list(void)
 
     /* 9:th column.. Total Bytes. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("Total Bytes", renderer, 
-        "text", TOT_BYTES_COLUMN, 
+    column = gtk_tree_view_column_new_with_attributes ("Total Bytes", renderer,
+        "text", TOT_BYTES_COLUMN,
         NULL);
-    
+
 
     gtk_tree_view_column_set_sort_column_id(column, NUM_BYTES_FWD_COLUMN);
     gtk_tree_view_column_set_resizable(column, TRUE);
@@ -238,10 +235,10 @@ GtkWidget* create_list(void)
 
     /* 10:th column.. Avg Bytes. */
     renderer = gtk_cell_renderer_text_new ();
-    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer, 
-        "text", AVG_BYTES_COLUMN, 
+    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer,
+        "text", AVG_BYTES_COLUMN,
         NULL);
-    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func, 
+    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func,
         GINT_TO_POINTER(AVG_BYTES_COLUMN), NULL);
 
     gtk_tree_view_column_set_sort_column_id(column, AVG_BYTES_COLUMN);
@@ -355,18 +352,13 @@ gsm_map_stat_draw(
             }else{
                 avrage_bytes_tot = 0;
             }
-            /* Creates a new row at position. iter will be changed to point to this new row. 
+            /* Creates a new row at position. iter will be changed to point to this new row.
              * If position is larger than the number of rows on the list, then the new row will be appended to the list.
              * The row will be filled with the values given to this function.
              * :
              * should generally be preferred when inserting rows in a sorted list store.
              */
-#if GTK_CHECK_VERSION(2,6,0)
             gtk_list_store_insert_with_values( list_store , &iter, G_MAXINT,
-#else
-            gtk_list_store_append  (list_store, &iter);
-            gtk_list_store_set  (list_store, &iter,
-#endif
                    ID_COLUMN,               gsm_map_opr_code_strings[i].value,
                    OP_CODE_COLUMN,          (char*)gsm_map_opr_code_strings[i].strptr,
                    INVOKES_COLUMN,          stat_p->opr_code[i],
@@ -386,7 +378,7 @@ gsm_map_stat_draw(
 static void
 gsm_map_stat_gtk_win_destroy_cb(
     GtkWindow       *win _U_,
-    gpointer        user_data _U_)
+    gpointer        user_data)
 {
     memset((void *) user_data, 0, sizeof(gsm_map_stat_dlg_t));
 }
@@ -432,11 +424,15 @@ gsm_map_stat_gtk_win_create(
     window_present(dlg_p->win);
 }
 
-
+#ifdef MAIN_MENU_USE_UIMANAGER
+void
+gsm_map_stat_gtk_cb(GtkAction *action _U_, gpointer user_data _U_)
+#else
 static void
 gsm_map_stat_gtk_cb(
     GtkWidget       *w _U_,
     gpointer        d _U_)
+#endif
 {
 
 
@@ -444,7 +440,7 @@ gsm_map_stat_gtk_cb(
      * if the window is already open, bring it to front
      */
     if (dlg.win){
-        gdk_window_raise(dlg.win->window);
+        gdk_window_raise(gtk_widget_get_window(dlg.win));
         return;
     }
 
@@ -484,7 +480,10 @@ register_tap_listener_gtkgsm_map_stat(void)
         exit(1);
     }
 
+#ifdef MAIN_MENU_USE_UIMANAGER
+#else
     register_stat_menu_item("_GSM/MAP Operation",  REGISTER_STAT_GROUP_TELEPHONY,
         gsm_map_stat_gtk_cb, NULL, NULL, NULL);
+#endif
     register_stat_cmd_arg("gsm_map", gsm_map_stat_gtk_init,NULL);
 }