[baobab] Use a separate directory for resources



commit 28b322ce4d583304d8ded89029440915a8176f08
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Mon Jul 7 22:20:59 2014 +0200

    Use a separate directory for resources
    
    Notably, menus are now at resource path /org/gnome/baobab/gtk/menus.ui,
    which allows for automatic picking of app-menu by GTK+.

 po/POTFILES.in                                 |    4 ++--
 src/Makefile.am                                |   14 ++++++--------
 src/baobab-application.vala                    |   11 +----------
 src/baobab-chart.vala                          |    2 +-
 src/baobab.gresource.xml                       |    9 ---------
 src/{ => resources}/baobab.css                 |    0
 src/resources/baobab.gresource.xml             |    9 +++++++++
 src/{baobab-menu.ui => resources/gtk/menus.ui} |    2 +-
 src/{ => resources/ui}/baobab-location-row.ui  |    0
 src/{ => resources/ui}/baobab-main-window.ui   |    0
 10 files changed, 20 insertions(+), 31 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 072d7fc..743adc2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,6 +6,6 @@ data/org.gnome.baobab.gschema.xml.in.in
 src/baobab-application.vala
 src/baobab-cellrenderers.vala
 src/baobab-location.vala
-[type: gettext/glade]src/baobab-main-window.ui
-[type: gettext/glade]src/baobab-menu.ui
+[type: gettext/glade]src/resources/gtk/menus.ui
+[type: gettext/glade]src/resources/ui/baobab-main-window.ui
 src/baobab-window.vala
diff --git a/src/Makefile.am b/src/Makefile.am
index 4c8130a..0b6aa8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,7 +14,7 @@ baobab_VALAFLAGS = \
        --pkg gtk+-3.0                          \
        --pkg gio-2.0                           \
        --pkg gio-unix-2.0                      \
-       --gresources=baobab.gresource.xml       \
+       --gresources=$(srcdir)/resources/baobab.gresource.xml   \
        $(NULL)
 
 VALA_SOURCES = \
@@ -37,8 +37,9 @@ baobab_SOURCES = \
        $(BUILT_SOURCES)                \
        $(NULL)
 
-baobab-resources.c: baobab.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies 
--sourcedir=$(srcdir) $(srcdir)/baobab.gresource.xml)
-       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $<
+resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(srcdir)/resources 
$(srcdir)/resources/baobab.gresource.xml)
+baobab-resources.c: $(srcdir)/resources/baobab.gresource.xml $(resource_files)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/resources --generate-source $<
 
 AM_CFLAGS = \
        $(BAOBAB_CFLAGS)                \
@@ -60,11 +61,8 @@ MAINTAINERCLEANFILES =       \
        $(NULL)
 
 EXTRA_DIST = \
-       baobab.gresource.xml    \
-       baobab.css              \
-       baobab-location-row.ui  \
-       baobab-main-window.ui   \
-       baobab-menu.ui          \
+       resources/baobab.gresource.xml  \
+       $(resource_files)               \
        $(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index 0cca507..0fdbaa0 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -77,7 +77,7 @@ namespace Baobab {
 
             // Load custom CSS
             var css_provider = new Gtk.CssProvider ();
-            var css_file = File.new_for_uri ("resource:///org/gnome/baobab/ui/baobab.css");
+            var css_file = File.new_for_uri ("resource:///org/gnome/baobab/baobab.css");
             try {
               css_provider.load_from_file (css_file);
             } catch (Error e) {
@@ -91,15 +91,6 @@ namespace Baobab {
 
             ui_settings.delay ();
 
-            var builder = new Gtk.Builder ();
-            try {
-                builder.add_from_resource ("/org/gnome/baobab/ui/baobab-menu.ui");
-            } catch (Error e) {
-                error ("loading menu builder file: %s", e.message);
-            }
-            var app_menu = builder.get_object ("appmenu") as MenuModel;
-            set_app_menu (app_menu);
-
             set_accels_for_action ("win.gear-menu", { "F10" });
             set_accels_for_action ("win.reload", { "<Primary>r" });
         }
diff --git a/src/baobab-chart.vala b/src/baobab-chart.vala
index 38aea5d..5ef2554 100644
--- a/src/baobab-chart.vala
+++ b/src/baobab-chart.vala
@@ -588,7 +588,7 @@ namespace Baobab {
 
             var builder = new Gtk.Builder ();
             try {
-                builder.add_from_resource ("/org/gnome/baobab/ui/baobab-menu.ui");
+                builder.add_from_resource ("/org/gnome/baobab/gtk/menus.ui");
             } catch (Error e) {
                 error ("loading context menu from resources: %s", e.message);
             }
diff --git a/src/baobab.css b/src/resources/baobab.css
similarity index 100%
rename from src/baobab.css
rename to src/resources/baobab.css
diff --git a/src/resources/baobab.gresource.xml b/src/resources/baobab.gresource.xml
new file mode 100644
index 0000000..8455584
--- /dev/null
+++ b/src/resources/baobab.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/baobab">
+    <file compressed="true">ui/baobab-location-row.ui</file>
+    <file compressed="true">ui/baobab-main-window.ui</file>
+    <file compressed="true">gtk/menus.ui</file>
+    <file compressed="true">baobab.css</file>
+  </gresource>
+</gresources>
diff --git a/src/baobab-menu.ui b/src/resources/gtk/menus.ui
similarity index 98%
rename from src/baobab-menu.ui
rename to src/resources/gtk/menus.ui
index ff09a00..1f9fe9b 100644
--- a/src/baobab-menu.ui
+++ b/src/resources/gtk/menus.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <menu id="appmenu">
+  <menu id="app-menu">
     <section>
       <item>
         <attribute name="label" translatable="yes">_Help</attribute>
diff --git a/src/baobab-location-row.ui b/src/resources/ui/baobab-location-row.ui
similarity index 100%
rename from src/baobab-location-row.ui
rename to src/resources/ui/baobab-location-row.ui
diff --git a/src/baobab-main-window.ui b/src/resources/ui/baobab-main-window.ui
similarity index 100%
rename from src/baobab-main-window.ui
rename to src/resources/ui/baobab-main-window.ui


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