[glom/gmenu] gmenu: Relationships Overview: Move context menu into .glade file



commit 892a77cf7338c5d5535ae9d0c2005ea8616511cb
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Sep 24 11:54:23 2013 +0200

    gmenu: Relationships Overview: Move context menu into .glade file

 .../dialog_relationships_overview.cc               |   34 ++------------------
 ui/developer/dialog_relationships_overview.glade   |   13 +++++++
 2 files changed, 16 insertions(+), 31 deletions(-)
---
diff --git a/glom/mode_design/relationships_overview/dialog_relationships_overview.cc 
b/glom/mode_design/relationships_overview/dialog_relationships_overview.cc
index 7914e81..cf7b3f3 100644
--- a/glom/mode_design/relationships_overview/dialog_relationships_overview.cc
+++ b/glom/mode_design/relationships_overview/dialog_relationships_overview.cc
@@ -465,42 +465,14 @@ void Dialog_RelationshipsOverview::setup_context_menu()
 {
   Glib::RefPtr<Gio::SimpleActionGroup> action_group = Gio::SimpleActionGroup::create();
 
-  m_action_edit_fields = action_group->add_action("editfields");
-
-  m_action_edit_relationships = action_group->add_action("editrelationships");
+  m_action_edit_fields = action_group->add_action("edit-fields");
+  m_action_edit_relationships = action_group->add_action("edit-relationships");
 
   insert_action_group("context", action_group);
 
-  Glib::RefPtr<Gtk::Builder> context_menu_builder = Gtk::Builder::create();
-
-  try
-  {
-    const char* ui_info =
-      "<interface>"
-      "  <menu id='ContextMenu'>"
-      "    <section>"
-      "      <item>"
-      "        <attribute name='label' translatable='yes'>Edit _Fields</attribute>"
-      "        <attribute name='action'>context.editfields</attribute>"
-      "      </item>"
-      "      <item>"
-      "        <attribute name='label' translatable='yes'>Edit _Relationships</attribute>"
-      "        <attribute name='action'>context.editrelationships</attribute>"
-      "      </item>"
-      "    </section>"
-      "  </menu>"
-      "</interface>";
-
-    context_menu_builder->add_from_string(ui_info);
-  }
-  catch(const Glib::Error& ex)
-  {
-    std::cerr << G_STRFUNC << ": building menus failed: " <<  ex.what();
-  }
-
   //Get the menu:
   Glib::RefPtr<Glib::Object> object =
-    context_menu_builder->get_object("ContextMenu");
+    m_builder->get_object("ContextMenu");
   Glib::RefPtr<Gio::Menu> gmenu =
     Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
   if(!gmenu)
diff --git a/ui/developer/dialog_relationships_overview.glade 
b/ui/developer/dialog_relationships_overview.glade
index da04a04..4bfa9b6 100644
--- a/ui/developer/dialog_relationships_overview.glade
+++ b/ui/developer/dialog_relationships_overview.glade
@@ -27,6 +27,19 @@
     </submenu>
   </menu>
 
+  <menu id='ContextMenu'>
+    <section>
+      <item>
+        <attribute name='label' translatable='yes'>Edit _Fields</attribute>
+        <attribute name='action'>context.edit-fields</attribute>
+      </item>
+      <item>
+        <attribute name='label' translatable='yes'>Edit _Relationships</attribute>
+        <attribute name='action'>context.edit-relationships</attribute>
+      </item>
+    </section>
+  </menu>
+
   <object class="GtkDialog" id="dialog_relationships_overview">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]