[gnome-applets/wip/segeiger/in-process: 7/7] tracker-search-bar: migrate to GResource



commit accd40bb2451f99742aaea67bfb11cfb3369eaa8
Author: Sebastian Geiger <sbastig gmx net>
Date:   Fri Jul 29 23:27:14 2016 +0200

    tracker-search-bar: migrate to GResource

 tracker-search-bar/Makefile.am                     |   13 -------
 tracker-search-bar/src/Makefile.am                 |   19 ++++++++++
 tracker-search-bar/src/tracker-applet.c            |   37 ++++++--------------
 .../{ => src}/tracker-search-bar-menu.xml          |    0
 .../src/tracker-search-bar-resources.gresource.xml |    7 ++++
 tracker-search-bar/{ => src}/tracker-search-bar.ui |    0
 6 files changed, 37 insertions(+), 39 deletions(-)
---
diff --git a/tracker-search-bar/Makefile.am b/tracker-search-bar/Makefile.am
index 184f167..21cdfbe 100644
--- a/tracker-search-bar/Makefile.am
+++ b/tracker-search-bar/Makefile.am
@@ -1,16 +1,3 @@
-NULL =
-
 SUBDIRS = src data
 
-# Applet UIs and menu
-uidir = $(pkgdatadir)/ui
-ui_DATA =                                             \
-       tracker-search-bar.ui                         \
-       tracker-search-bar-menu.xml \
-       $(NULL)
-
-EXTRA_DIST = \
-       $(ui_DATA) \
-       $(NULL)
-
 -include $(top_srcdir)/git.mk
diff --git a/tracker-search-bar/src/Makefile.am b/tracker-search-bar/src/Makefile.am
index 6eae134..9ca9283 100644
--- a/tracker-search-bar/src/Makefile.am
+++ b/tracker-search-bar/src/Makefile.am
@@ -36,6 +36,25 @@ libtracker_search_bar_applet_la_SOURCES = \
        tracker-results-window.h \
        tracker-utils.c \
        tracker-utils.h \
+       tracker-resources.c \
+       tracker-resources.h \
+       $(NULL)
+
+tracker-resources.c: tracker-search-bar-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) 
--sourcedir=$(srcdir) --generate-dependencies $(srcdir)/tracker-search-bar-resources.gresource.xml)
+       $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name tracker $<
+
+tracker-resources.h: tracker-search-bar-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) 
--sourcedir=$(srcdir) --generate-dependencies $(srcdir)/tracker-search-bar-resources.gresource.xml)
+       $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name tracker $<
+
+EXTRA_DIST = \
+       tracker-search-bar.ui \
+       tracker-search-bar-menu.xml \
+       tracker-search-bar-resources.gresource.xml \
+       $(NULL)
+
+CLEANFILES = \
+       tracker-resources.c \
+       tracker-resources.h \
        $(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/tracker-search-bar/src/tracker-applet.c b/tracker-search-bar/src/tracker-applet.c
index c080394..639b11f 100644
--- a/tracker-search-bar/src/tracker-applet.c
+++ b/tracker-search-bar/src/tracker-applet.c
@@ -361,28 +361,15 @@ static gboolean
 applet_new (PanelApplet *parent_applet)
 {
        TrackerApplet *applet;
-       GError *error = NULL;
        GtkBuilder *builder;
        GSimpleActionGroup *action_group;
-       gchar *ui_path;
+       const gchar *resource_name;
 
        builder = gtk_builder_new ();
-       ui_path = g_build_filename (PKG_DATA_DIR,
-                                   "ui",
-                                   "tracker-search-bar.ui",
-                                   NULL);
-
-       if (gtk_builder_add_from_file (builder, ui_path, &error) == 0) {
-               g_printerr ("Could not load builder file, %s", error->message);
-               g_error_free (error);
-               g_free (ui_path);
-               g_object_unref (builder);
-
-               return FALSE;
-       }
 
-       g_print ("Added builder file:'%s'\n", ui_path);
-       g_free (ui_path);
+       resource_name = "/org/gnome/gnome-applets/tracker-search-bar.ui";
+
+       gtk_builder_add_from_resource (builder, resource_name, NULL);
 
        applet = g_new0 (TrackerApplet, 1);
 
@@ -405,15 +392,13 @@ applet_new (PanelApplet *parent_applet)
                                         applet_menu_actions,
                                         G_N_ELEMENTS (applet_menu_actions),
                                         applet);
-       ui_path = g_build_filename (PKG_DATA_DIR,
-                                   "ui",
-                                   "tracker-search-bar-menu.xml",
-                                   NULL);
-       panel_applet_setup_menu_from_file (PANEL_APPLET (applet->parent),
-                                          ui_path,
-                                          action_group,
-                                          GETTEXT_PACKAGE);
-       g_free (ui_path);
+
+       resource_name = "/org/gnome/gnome-applets/tracker-search-bar-menu.xml";
+
+       panel_applet_setup_menu_from_resource (PANEL_APPLET (applet->parent),
+                                              resource_name,
+                                              action_group,
+                                              GETTEXT_PACKAGE);
 
        gtk_widget_insert_action_group (GTK_WIDGET (applet->parent), "tracker-search-bar",
                                        G_ACTION_GROUP (action_group));
diff --git a/tracker-search-bar/tracker-search-bar-menu.xml 
b/tracker-search-bar/src/tracker-search-bar-menu.xml
similarity index 100%
rename from tracker-search-bar/tracker-search-bar-menu.xml
rename to tracker-search-bar/src/tracker-search-bar-menu.xml
diff --git a/tracker-search-bar/src/tracker-search-bar-resources.gresource.xml 
b/tracker-search-bar/src/tracker-search-bar-resources.gresource.xml
new file mode 100644
index 0000000..95b44e0
--- /dev/null
+++ b/tracker-search-bar/src/tracker-search-bar-resources.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+    <gresource prefix="/org/gnome/gnome-applets/tracker-search-bar">
+        <file compressed="true">tracker-search-bar.ui</file>
+        <file compressed="true">tracker-search-bar-menu.xml</file>
+    </gresource>
+</gresources>
diff --git a/tracker-search-bar/tracker-search-bar.ui b/tracker-search-bar/src/tracker-search-bar.ui
similarity index 100%
rename from tracker-search-bar/tracker-search-bar.ui
rename to tracker-search-bar/src/tracker-search-bar.ui


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