[glom/gmenu] gmenu: Move Print Layouts menu to .glade file



commit f615d809fcd644d731dda8e5d2766182d28763d7
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Sep 23 22:01:53 2013 +0200

    gmenu: Move Print Layouts menu to .glade file

 .../print_layouts/window_print_layout_edit.cc      |  175 +-------------------
 .../print_layouts/window_print_layout_edit.h       |    1 +
 ui/developer/window_print_layout_edit.glade        |  158 ++++++++++++++++++
 3 files changed, 161 insertions(+), 173 deletions(-)
---
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.cc 
b/glom/mode_design/print_layouts/window_print_layout_edit.cc
index a89b869..60f3c53 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.cc
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.cc
@@ -50,6 +50,7 @@ Window_PrintLayout_Edit::Window_PrintLayout_Edit(BaseObjectType* cobject, const
   m_entry_title(0),
   m_label_table_name(0),
   m_button_close(0),
+  m_builder(builder),
   m_box(0),
   m_box_item_position(0),
   m_spinbutton_x(0),
@@ -268,181 +269,9 @@ void Window_PrintLayout_Edit::init_menu()
 
   insert_action_group("printlayout", action_group);
 
-  static const char* ui_description =
-    "<interface>"
-    "  <menu id='Menubar'>"
-    "    <submenu>"
-    "      <attribute name='label' translatable='yes'>_File</attribute>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Page Set_up</attribute>"
-    "          <attribute name='action'>printlayout.pagesetup</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Print Pre_view</attribute>"
-    "          <attribute name='action'>printlayout.printpreview</attribute>"
-    "        </item>"
-    "      </section>"
-    "    </submenu>"
-    "    <submenu>"
-    "      <attribute name='label' translatable='yes'>_Edit</attribute>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Cu_t</attribute>"
-    "          <attribute name='action'>printlayout.cut</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>_Copy</attribute>"
-    "          <attribute name='action'>printlayout.copy</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>_Paste</attribute>"
-    "          <attribute name='action'>printlayout.paste</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>_Delete</attribute>"
-    "          <attribute name='action'>printlayout.delete</attribute>"
-    "        </item>"
-    "      </section>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Select _All</attribute>"
-    "          <attribute name='action'>printlayout.selectall</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>_Unselect All</attribute>"
-    "          <attribute name='action'>printlayout.unselectall</attribute>"
-    "        </item>"
-    "      </section>"
-    "    </submenu>"
-    "    <submenu>"
-    "      <attribute name='label' translatable='yes'>_Insert</attribute>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Insert _Field</attribute>"
-    "          <attribute name='action'>printlayout.insertfield</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Insert _Text</attribute>"
-    "          <attribute name='action'>printlayout.inserttext</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Insert _Image</attribute>"
-    "          <attribute name='action'>printlayout.insertimage</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Insert _Related Records</attribute>"
-    "          <attribute name='action'>printlayout.insertrelatedrecords</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Insert _Horizontal Line</attribute>"
-    "          <attribute name='action'>printlayout.inserthorizontalline</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Insert _Vertical Line</attribute>"
-    "          <attribute name='action'>printlayout.insertverticalline</attribute>"
-    "        </item>"
-    "      </section>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Create _Standard</attribute>"
-    "          <attribute name='action'>printlayout.createstandard</attribute>"
-    "        </item>"
-    "      </section>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Add Page</attribute>"
-    "          <attribute name='action'>printlayout.addpage</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Delete Page</attribute>"
-    "          <attribute name='action'>printlayout.deletepage</attribute>"
-    "        </item>"
-    "      </section>"
-    "    </submenu>"
-    "    <submenu>"
-    "      <attribute name='label' translatable='yes'>_Align</attribute>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Align _Top</attribute>"
-    "          <attribute name='action'>printlayout.aligntop</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Align _Bottom</attribute>"
-    "          <attribute name='action'>printlayout.alignbottom</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Align _Left</attribute>"
-    "          <attribute name='action'>printlayout.alignleft</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Align _Right</attribute>"
-    "          <attribute name='action'>printlayout.alignright</attribute>"
-    "        </item>"
-    "      </section>"
-    "    </submenu>"
-    "    <submenu>"
-    "      <attribute name='label' translatable='yes'>_View</attribute>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Show _Grid</attribute>"
-    "          <attribute name='action'>printlayout.showgrid</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Show _Rules</attribute>"
-    "          <attribute name='action'>printlayout.showrules</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Show _Outlines</attribute>"
-    "          <attribute name='action'>printlayout.showoutlines</attribute>"
-    "        </item>"
-    "      </section>"
-    "      <section>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Fit Page _Width</attribute>"
-    "          <attribute name='action'>printlayout.zoom</attribute>"
-    "          <attribute name='target' type='i'>0</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Zoom 200%</attribute>"
-    "          <attribute name='action'>printlayout.zoom</attribute>"
-    "          <attribute name='target' type='i'>200</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Zoom 100%</attribute>"
-    "          <attribute name='action'>printlayout.zoom</attribute>"
-    "          <attribute name='target' type='i'>100</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Zoom 50%</attribute>"
-    "          <attribute name='action'>printlayout.zoom</attribute>"
-    "          <attribute name='target' type='i'>50</attribute>"
-    "        </item>"
-    "        <item>"
-    "          <attribute name='label' translatable='yes'>Zoom 25%</attribute>"
-    "          <attribute name='action'>printlayout.zoom</attribute>"
-    "          <attribute name='target' type='i'>25</attribute>"
-    "        </item>"
-    "      </section>"
-    "    </submenu>"
-    "  </menu>"
-    "</interface>";
-
-  //Add menu:
-  Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create();
-
-  try
-  {
-    builder->add_from_string(ui_description);
-  }
-  catch(const Glib::Error& ex)
-  {
-    std::cerr << G_STRFUNC << ": building menus failed: " <<  ex.what();
-  }
-
   //Get the menu:
   Glib::RefPtr<Glib::Object> object =
-    builder->get_object("Menubar");
+    m_builder->get_object("Menubar");
   Glib::RefPtr<Gio::Menu> gmenu =
     Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
   if(!gmenu)
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.h 
b/glom/mode_design/print_layouts/window_print_layout_edit.h
index 3e87184..d1868ce 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.h
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.h
@@ -150,6 +150,7 @@ private:
   //Gtk::Label* m_label_table_title;
   Gtk::Button* m_button_close;
 
+  Glib::RefPtr<Gtk::Builder> m_builder;
   Gtk::Box* m_box_menu;
   Gtk::Box* m_box_canvas;
   Gtk::Box* m_box;
diff --git a/ui/developer/window_print_layout_edit.glade b/ui/developer/window_print_layout_edit.glade
index eeed45f..c51db64 100644
--- a/ui/developer/window_print_layout_edit.glade
+++ b/ui/developer/window_print_layout_edit.glade
@@ -1,6 +1,164 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+
+  <menu id='Menubar'>
+    <submenu>
+      <attribute name='label' translatable='yes'>_File</attribute>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Page Set_up</attribute>
+          <attribute name='action'>printlayout.pagesetup</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Print Pre_view</attribute>
+          <attribute name='action'>printlayout.printpreview</attribute>
+        </item>
+      </section>
+    </submenu>
+    <submenu>
+      <attribute name='label' translatable='yes'>_Edit</attribute>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Cu_t</attribute>
+          <attribute name='action'>printlayout.cut</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>_Copy</attribute>
+          <attribute name='action'>printlayout.copy</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>_Paste</attribute>
+          <attribute name='action'>printlayout.paste</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>_Delete</attribute>
+          <attribute name='action'>printlayout.delete</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Select _All</attribute>
+          <attribute name='action'>printlayout.selectall</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>_Unselect All</attribute>
+          <attribute name='action'>printlayout.unselectall</attribute>
+        </item>
+      </section>
+    </submenu>
+    <submenu>
+      <attribute name='label' translatable='yes'>_Insert</attribute>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Insert _Field</attribute>
+          <attribute name='action'>printlayout.insertfield</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Insert _Text</attribute>
+          <attribute name='action'>printlayout.inserttext</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Insert _Image</attribute>
+          <attribute name='action'>printlayout.insertimage</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Insert _Related Records</attribute>
+          <attribute name='action'>printlayout.insertrelatedrecords</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Insert _Horizontal Line</attribute>
+          <attribute name='action'>printlayout.inserthorizontalline</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Insert _Vertical Line</attribute>
+          <attribute name='action'>printlayout.insertverticalline</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Create _Standard</attribute>
+          <attribute name='action'>printlayout.createstandard</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Add Page</attribute>
+          <attribute name='action'>printlayout.addpage</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Delete Page</attribute>
+          <attribute name='action'>printlayout.deletepage</attribute>
+        </item>
+      </section>
+    </submenu>
+    <submenu>
+      <attribute name='label' translatable='yes'>_Align</attribute>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Align _Top</attribute>
+          <attribute name='action'>printlayout.aligntop</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Align _Bottom</attribute>
+          <attribute name='action'>printlayout.alignbottom</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Align _Left</attribute>
+          <attribute name='action'>printlayout.alignleft</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Align _Right</attribute>
+          <attribute name='action'>printlayout.alignright</attribute>
+        </item>
+      </section>
+    </submenu>
+    <submenu>
+      <attribute name='label' translatable='yes'>_View</attribute>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Show _Grid</attribute>
+          <attribute name='action'>printlayout.showgrid</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Show _Rules</attribute>
+          <attribute name='action'>printlayout.showrules</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Show _Outlines</attribute>
+          <attribute name='action'>printlayout.showoutlines</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name='label' translatable='yes'>Fit Page _Width</attribute>
+          <attribute name='action'>printlayout.zoom</attribute>
+          <attribute name='target' type='i'>0</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Zoom 200%</attribute>
+          <attribute name='action'>printlayout.zoom</attribute>
+          <attribute name='target' type='i'>200</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Zoom 100%</attribute>
+          <attribute name='action'>printlayout.zoom</attribute>
+          <attribute name='target' type='i'>100</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Zoom 50%</attribute>
+          <attribute name='action'>printlayout.zoom</attribute>
+          <attribute name='target' type='i'>50</attribute>
+        </item>
+        <item>
+          <attribute name='label' translatable='yes'>Zoom 25%</attribute>
+          <attribute name='action'>printlayout.zoom</attribute>
+          <attribute name='target' type='i'>25</attribute>
+        </item>
+      </section>
+    </submenu>
+  </menu>
+
   <object class="GtkWindow" id="window_print_layout_edit">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Print Layout Editor</property>


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