Move implementation of the datasheet variable popup menu to the GtkBuilder file
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 9 May 2010 18:12:14 +0000 (20:12 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 9 May 2010 18:12:14 +0000 (20:12 +0200)
src/ui/gui/data-editor.ui
src/ui/gui/psppire-data-window.c

index 9ba686771aae33c7f3b3d1710117f7f178c35133..9e1fa74e876652e468b2c4de643614874899bedc 100644 (file)
@@ -1,6 +1,23 @@
 <?xml version="1.0"?>
 <interface>
   <object class="GtkUIManager" id="uimanager1">
+    <child>
+      <object class="GtkActionGroup" id="actiongroup2">
+        <child>
+          <object class="GtkAction" id="sort-up">
+            <property name="stock-id">gtk-sort-ascending</property>
+            <property name="label" translatable="yes">Sort Ascending</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkAction" id="sort-down">
+            <property name="stock-id">gtk-sort-descending</property>
+            <property name="label" translatable="yes">Sort Descending</property>
+          </object>
+        </child>
+      </object>
+   </child>
+       
     <child>
       <object class="GtkActionGroup" id="actiongroup1">
         <child>
          <toolitem name="toolbar_select-cases" action="view_value-labels"/>
         </placeholder>
       </toolbar>
+      <popup name="datasheet-variable-popup">
+         <menuitem action="action_insert-variable"/>
+         <separator/>
+         <menuitem action="edit_clear-variables"/>
+         <separator/>
+          <menuitem action="sort-up"/>
+          <menuitem action="sort-down"/>
+      </popup>
 </ui>
   </object>
   <!-- interface-requires gtk+ 2.6 -->
   <object class="GtkMenuBar" constructor="uimanager1" id="menubar">
     <property name="visible">True</property>
   </object>
+  <object class="GtkMenu" constructor="uimanager1" id="datasheet-variable-popup">
+    <property name="visible">True</property>
+  </object>
   <object class="GtkHandleBox" id="handlebox1">
     <property name="visible">True</property>
     <child>
index 55e206e1a9226731b741c9b4e72fcf2c217657fd..aedfe4f0737c0961c478ee73653d490bf251ac5f 100644 (file)
@@ -843,73 +843,6 @@ file_quit (GtkCheckMenuItem *menuitem, gpointer data)
 }
 
 
-
-static GtkWidget *
-create_data_sheet_variable_popup_menu (PsppireDataWindow *de)
-{
-  GtkWidget *menu = gtk_menu_new ();
-
-  GtkWidget *sort_ascending =
-    gtk_action_create_menu_item (gtk_action_new ("sort-up",
-                                                _("Sort Ascending"),
-                                                NULL,
-                                                "gtk-sort-ascending"));
-
-  GtkWidget *sort_descending =
-    gtk_action_create_menu_item (gtk_action_new ("sort-down",
-                                                _("Sort Descending"),
-                                                NULL,
-                                                "gtk-sort-descending"));
-
-  GtkWidget *insert_variable =
-    gtk_menu_item_new_with_label (_("Insert Variable"));
-
-  GtkWidget *clear_variable =
-    gtk_menu_item_new_with_label (_("Clear"));
-
-
-  gtk_action_connect_proxy (de->delete_variables,
-                           clear_variable );
-
-
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable);
-
-
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu),
-                        gtk_separator_menu_item_new ());
-
-
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), clear_variable);
-
-
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu),
-                        gtk_separator_menu_item_new ());
-
-
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_ascending);
-
-
-  g_signal_connect_swapped (sort_ascending, "activate",
-                           G_CALLBACK (psppire_data_editor_sort_ascending),
-                           de->data_editor);
-
-  g_signal_connect_swapped (sort_descending, "activate",
-                           G_CALLBACK (psppire_data_editor_sort_descending),
-                           de->data_editor);
-
-  g_signal_connect_swapped (insert_variable, "activate",
-                           G_CALLBACK (gtk_action_activate),
-                           de->insert_variable);
-
-
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_descending);
-
-  gtk_widget_show_all (menu);
-
-  return menu;
-}
-
-
 static GtkWidget *
 create_data_sheet_cases_popup_menu (PsppireDataWindow *de)
 {
@@ -1817,8 +1750,16 @@ psppire_data_window_init (PsppireDataWindow *de)
   }
 
   {
-    GtkMenu *data_sheet_variable_popup_menu =
-      GTK_MENU (create_data_sheet_variable_popup_menu (de));
+    GtkMenu *data_sheet_variable_popup_menu = get_widget_assert (de->builder,
+                                                                "datasheet-variable-popup");
+
+    g_signal_connect_swapped (get_action_assert (de->builder, "sort-up"), "activate",
+                           G_CALLBACK (psppire_data_editor_sort_ascending),
+                           de->data_editor);
+
+    g_signal_connect_swapped (get_action_assert (de->builder, "sort-down"), "activate",
+                           G_CALLBACK (psppire_data_editor_sort_descending),
+                           de->data_editor);
 
     GtkMenu *var_sheet_variable_popup_menu =
       GTK_MENU (create_var_sheet_variable_popup_menu (de));