[d-feet/aleksander/ui: 1/6] application: load app menu from ui file



commit 845fab7563731c0b29c44a83a69b2f4e661e28f0
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Sun Sep 29 15:14:49 2013 +0200

    application: load app menu from ui file

 data/ui/Makefile.am      |    2 +-
 data/ui/app-menu.ui      |   22 ++++++++++++++++++++++
 src/dfeet/application.py |   32 ++++----------------------------
 3 files changed, 27 insertions(+), 29 deletions(-)
---
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
index 7b35464..67594d0 100644
--- a/data/ui/Makefile.am
+++ b/data/ui/Makefile.am
@@ -6,9 +6,9 @@ ui_DATA =                       \
        executedialog.ui        \
        introspection.ui        \
        mainwindow.ui           \
+       app-menu.ui             \
        $(NULL)
 
 EXTRA_DIST =                   \
        $(ui_DATA)              \
        $(NULL)
-
diff --git a/data/ui/app-menu.ui b/data/ui/app-menu.ui
new file mode 100644
index 0000000..03df69d
--- /dev/null
+++ b/data/ui/app-menu.ui
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.0"/>
+  <menu id='app-menu'>
+    <section>
+      <item>
+        <attribute name='label' translatable='yes'>About</attribute>
+        <attribute name='action'>app.about</attribute>
+      </item>
+      <item>
+        <attribute name='label' translatable='yes'>Help</attribute>
+        <attribute name='action'>app.help</attribute>
+        <attribute name="accel">F1</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Quit</attribute>
+        <attribute name="action">app.quit</attribute>
+        <attribute name="accel">&lt;Primary&gt;q</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
\ No newline at end of file
diff --git a/src/dfeet/application.py b/src/dfeet/application.py
index 7415af3..4613e78 100644
--- a/src/dfeet/application.py
+++ b/src/dfeet/application.py
@@ -1,33 +1,9 @@
 # -*- coding: utf-8 -*-
-from __future__ import print_function
 
+from __future__    import print_function
 from gi.repository import Gtk, Gio, GObject, Gdk
-
-from dfeet.window import DFeetWindow
-
-
-APP_MENU = """
-<interface>
-  <menu id='app-menu'>
-    <section>
-      <item>
-        <attribute name='label' translatable='yes'>About</attribute>
-        <attribute name='action'>app.about</attribute>
-      </item>
-      <item>
-        <attribute name='label' translatable='yes'>Help</attribute>
-        <attribute name='action'>app.help</attribute>
-        <attribute name="accel">F1</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Quit</attribute>
-        <attribute name="action">app.quit</attribute>
-        <attribute name="accel">&lt;Primary&gt;q</attribute>
-      </item>
-    </section>
-  </menu>
-</interface>
-"""
+from dfeet.window  import DFeetWindow
+import os
 
 
 class DFeetApp(Gtk.Application):
@@ -47,7 +23,7 @@ class DFeetApp(Gtk.Application):
     def do_startup(self):
         Gtk.Application.do_startup(self)
         builder = Gtk.Builder()
-        builder.add_from_string(APP_MENU)
+        builder.add_from_file(os.path.join(self.data_dir, "ui", "app-menu.ui"))
 
         #create actions
         action = Gio.SimpleAction.new("about", None)


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