[shotwell] publishing-extra: Load resources from GResource



commit 83e2e81d8c3f824ff7131ec42ef0dc9d83a9ef8c
Author: Jens Georg <mail jensge org>
Date:   Wed Jul 20 00:41:20 2016 +0200

    publishing-extra: Load resources from GResource
    
    Signed-off-by: Jens Georg <mail jensge org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747368

 .../GalleryConnector.vala                          |   14 ++++++--------
 .../RajcePublishing.vala                           |   11 ++++++-----
 .../TumblrPublishing.vala                          |   16 +++++++---------
 .../YandexPublishing.vala                          |    5 ++---
 ....gnome.Shotwell.Publishing.Extras.gresource.xml |   15 +++++++++++++++
 publish-extra.am                                   |   11 ++++++++++-
 6 files changed, 46 insertions(+), 26 deletions(-)
---
diff --git a/plugins/shotwell-publishing-extras/GalleryConnector.vala 
b/plugins/shotwell-publishing-extras/GalleryConnector.vala
index 3fe3eea..ee7bd19 100644
--- a/plugins/shotwell-publishing-extras/GalleryConnector.vala
+++ b/plugins/shotwell-publishing-extras/GalleryConnector.vala
@@ -63,8 +63,8 @@ public class Gallery3Service : Object, Spit.Pluggable,
 
     public Gallery3Service(GLib.File resource_directory) {
         if (icon_pixbuf_set == null)
-            icon_pixbuf_set = Resources.load_icon_set(
-                resource_directory.get_child(ICON_FILENAME));
+            icon_pixbuf_set = Resources.load_from_resource
+                (Resources.RESOURCE_PATH + "/" + ICON_FILENAME);
     }
 
     public int get_pluggable_interface(int min_host_interface,
@@ -1011,9 +1011,8 @@ public class GalleryPublisher : Spit.Publishing.Publisher, GLib.Object {
         Gtk.Builder builder = new Gtk.Builder();
 
         try {
-            builder.add_from_file(
-                host.get_module_file().get_parent().get_child(
-                    "gallery3_publishing_options_pane.ui").get_path());
+            builder.add_from_resource(Resources.RESOURCE_PATH +
+                    "/gallery3_publishing_options_pane.ui");
         }
         catch (Error e) {
             warning("Could not parse UI file! Error: %s.", e.message);
@@ -1764,9 +1763,8 @@ internal class CredentialsPane : Spit.Publishing.DialogPane, GLib.Object {
         Gtk.Builder builder = new Gtk.Builder();
 
         try {
-            builder.add_from_file(
-                host.get_module_file().get_parent().get_child(
-                    "gallery3_authentication_pane.ui").get_path());
+            builder.add_from_resource (Resources.RESOURCE_PATH +
+                    "/gallery3_authentication_pane.ui");
         }
         catch (Error e) {
             warning("Could not parse UI file! Error: %s.", e.message);
diff --git a/plugins/shotwell-publishing-extras/RajcePublishing.vala 
b/plugins/shotwell-publishing-extras/RajcePublishing.vala
index 20038aa..4cf232c 100644
--- a/plugins/shotwell-publishing-extras/RajcePublishing.vala
+++ b/plugins/shotwell-publishing-extras/RajcePublishing.vala
@@ -13,7 +13,9 @@ public class RajceService : Object, Spit.Pluggable, Spit.Publishing.Service
     public RajceService(GLib.File resource_directory)
        {
         if (icon_pixbuf_set == null)
-            icon_pixbuf_set = Resources.load_icon_set(resource_directory.get_child(ICON_FILENAME));
+            icon_pixbuf_set =
+                Resources.load_from_resource(Resources.RESOURCE_PATH + "/" +
+                        ICON_FILENAME);
     }
 
     public int get_pluggable_interface(int min_host_interface, int max_host_interface)
@@ -844,11 +846,11 @@ internal class AuthenticationPane : Spit.Publishing.DialogPane, Object
     public AuthenticationPane( RajcePublisher publisher, Mode mode = Mode.INTRO )
        {
         this.pane_widget = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
-        File ui_file = 
publisher.get_host().get_module_file().get_parent().get_child("rajce_authentication_pane.ui");
         try
                {
             builder = new Gtk.Builder();
-            builder.add_from_file(ui_file.get_path());
+            builder.add_from_resource (Resources.RESOURCE_PATH +
+                    "/rajce_authentication_pane.ui");
             builder.connect_signals(null);
             Gtk.Alignment align = builder.get_object("alignment") as Gtk.Alignment;
             Gtk.Label message_label = builder.get_object("message_label") as Gtk.Label;
@@ -986,11 +988,10 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object
         this.publisher = publisher;
         this.pane_widget = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
                
-        File ui_file = 
publisher.get_host().get_module_file().get_parent().get_child("rajce_publishing_options_pane.ui");
         try
                {
                    this.builder = new Gtk.Builder();
-                       builder.add_from_file(ui_file.get_path());
+                       builder.add_from_resource (Resources.RESOURCE_PATH + 
"/rajce_publishing_options_pane.ui");
             builder.connect_signals(null);
                        
                    pane_widget = (Gtk.Box) builder.get_object("rajce_pane_widget");
diff --git a/plugins/shotwell-publishing-extras/TumblrPublishing.vala 
b/plugins/shotwell-publishing-extras/TumblrPublishing.vala
index 97c6adb..3f5a2ed 100644
--- a/plugins/shotwell-publishing-extras/TumblrPublishing.vala
+++ b/plugins/shotwell-publishing-extras/TumblrPublishing.vala
@@ -13,7 +13,9 @@ public class TumblrService : Object, Spit.Pluggable, Spit.Publishing.Service {
     
     public TumblrService(GLib.File resource_directory) {
         if (icon_pixbuf_set == null)
-            icon_pixbuf_set = Resources.load_icon_set(resource_directory.get_child(ICON_FILENAME));
+            icon_pixbuf_set =
+                Resources.load_from_resource(Resources.RESOURCE_PATH + "/" +
+                        ICON_FILENAME);
     }
 
     public int get_pluggable_interface(int min_host_interface, int max_host_interface) {
@@ -596,12 +598,9 @@ internal class AuthenticationPane : Spit.Publishing.DialogPane, Object {
     public AuthenticationPane(TumblrPublisher publisher, Mode mode = Mode.INTRO) {
         this.pane_widget = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
 
-        File ui_file = publisher.get_host().get_module_file().get_parent().
-            get_child("tumblr_authentication_pane.ui");
-        
         try {
             builder = new Gtk.Builder();
-            builder.add_from_file(ui_file.get_path());
+            builder.add_from_resource (Resources.RESOURCE_PATH + "/tumblr_authentication_pane.ui");
             builder.connect_signals(null);
             Gtk.Alignment align = builder.get_object("alignment") as Gtk.Alignment;
             
@@ -714,12 +713,11 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, GLib.Object {
                this.media_type = media_type;
                this.sizes = sizes;
                this.blogs=blogs;
-        File ui_file = publisher.get_host().get_module_file().get_parent().
-            get_child("tumblr_publishing_options_pane.ui");
-        
+
         try {
                        builder = new Gtk.Builder();
-                       builder.add_from_file(ui_file.get_path());
+                       builder.add_from_resource (Resources.RESOURCE_PATH +
+                    "/tumblr_publishing_options_pane.ui");
                        builder.connect_signals(null);
 
                        // pull in the necessary widgets from the glade file
diff --git a/plugins/shotwell-publishing-extras/YandexPublishing.vala 
b/plugins/shotwell-publishing-extras/YandexPublishing.vala
index 99e980d..2ee67cf 100644
--- a/plugins/shotwell-publishing-extras/YandexPublishing.vala
+++ b/plugins/shotwell-publishing-extras/YandexPublishing.vala
@@ -238,11 +238,10 @@ internal class PublishingOptionsPane: Spit.Publishing.DialogPane, GLib.Object {
 
         box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
         
-        File ui_file = host.get_module_file().get_parent().get_child("yandex_publish_model.ui");
-        
         try {
             builder = new Gtk.Builder();
-            builder.add_from_file(ui_file.get_path());
+            builder.add_from_resource (Resources.RESOURCE_PATH + "/yandex_publish_model.ui");
+
             builder.connect_signals(null);
             Gtk.Alignment align = builder.get_object("alignment") as Gtk.Alignment;
 
diff --git a/plugins/shotwell-publishing-extras/org.gnome.Shotwell.Publishing.Extras.gresource.xml 
b/plugins/shotwell-publishing-extras/org.gnome.Shotwell.Publishing.Extras.gresource.xml
new file mode 100644
index 0000000..ab8a367
--- /dev/null
+++ b/plugins/shotwell-publishing-extras/org.gnome.Shotwell.Publishing.Extras.gresource.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+    <gresource prefix="/org/gnome/Shotwell/Publishing/Extras">
+        <file>gallery3.png</file>
+        <file>rajce.png</file>
+        <file>tumblr.png</file>
+        <file>gallery3_authentication_pane.ui</file>
+        <file>gallery3_publishing_options_pane.ui</file>
+        <file>rajce_authentication_pane.ui</file>
+        <file>rajce_publishing_options_pane.ui</file>
+        <file>tumblr_authentication_pane.ui</file>
+        <file>tumblr_publishing_options_pane.ui</file>
+        <file>yandex_publish_model.ui</file>
+    </gresource>
+</gresources>
diff --git a/publish-extra.am b/publish-extra.am
index 6c713bf..fbadf6c 100644
--- a/publish-extra.am
+++ b/publish-extra.am
@@ -1,5 +1,6 @@
 plugin_LTLIBRARIES += plugins/shotwell-publishing-extras/shotwell-publishing-extras.la
-dist_plugin_DATA += \
+
+dist_noinst_DATA += \
        plugins/shotwell-publishing-extras/gallery3.png \
        plugins/shotwell-publishing-extras/rajce.png \
        plugins/shotwell-publishing-extras/tumblr.png \
@@ -19,6 +20,13 @@ plugins_shotwell_publishing_extras_shotwell_publishing_extras_la_SOURCES = \
        plugins/shotwell-publishing-extras/YandexPublishing.vala \
        plugins/shotwell-plugin-common.vapi
 
+nodist_plugins_shotwell_publishing_extras_shotwell_publishing_extras_la_SOURCES = \
+       plugins/shotwell-publishing-extras/resource.c
+
+plugins/shotwell-publishing-extras/resource.c: 
plugins/shotwell-publishing-extras/org.gnome.Shotwell.Publishing.Extras.gresource.xml
+       $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=plugins/shotwell-publishing-extras 
--generate $<
+
+
 plugins_shotwell_publishing_extras_shotwell_publishing_extras_la_VALAFLAGS = \
        $(COMMON_VALAFLAGS) \
        --pkg gtk+-3.0 \
@@ -33,6 +41,7 @@ plugins_shotwell_publishing_extras_shotwell_publishing_extras_la_VALAFLAGS = \
        --vapidir $(abs_top_srcdir)/plugins
 
 plugins_shotwell_publishing_extras_shotwell_publishing_extras_la_CFLAGS = \
+       -DPLUGIN_RESOURCE_PATH='"/org/gnome/Shotwell/Publishing/Extras"' \
        $(PLUGIN_CFLAGS) \
        $(COMMON_CFLAGS) \
        -I $(abs_top_srcdir)/plugins


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