[gnome-applets/wip/segeiger/in-process: 5/6] trash: migrate to GResource



commit 88626a3faa40e6e0383ed0abe696577ebf35b10a
Author: Sebastian Geiger <sbastig gmx net>
Date:   Fri Jul 29 00:17:04 2016 +0200

    trash: migrate to GResource

 trash/Makefile.am                                  |   11 +++--------
 trash/src/Makefile.am                              |   16 ++++++++++++++--
 trash/src/trash-applet.c                           |   12 ++++++++----
 trash/src/trash-empty.c                            |   10 +++++++---
 .../trash-empty.ui}                                |    0
 trash/{trashapplet-menu.xml => src/trash-menu.xml} |    0
 trash/src/trash-resources.gresource.xml            |    7 +++++++
 7 files changed, 39 insertions(+), 17 deletions(-)
---
diff --git a/trash/Makefile.am b/trash/Makefile.am
index 1f543bf..b63ce26 100644
--- a/trash/Makefile.am
+++ b/trash/Makefile.am
@@ -1,3 +1,5 @@
+NULL =
+
 SUBDIRS = help src
 
 appletdir       = $(LIBPANEL_APPLET_DIR)
@@ -21,17 +23,10 @@ org.gnome.panel.applet.TrashAppletFactory.service: $(service_in_files)
             -e "s|\@LIBEXECDIR\@|$(libexecdir)|" \
             $< > $@
 
-uidir = $(pkgdatadir)/ui
-ui_DATA = trashapplet-menu.xml
-
-builderdir = $(pkgdatadir)/builder
-builder_DATA = trashapplet-empty-progress.ui
-
 EXTRA_DIST = \
-       $(ui_DATA) \
        org.gnome.applets.TrashApplet.panel-applet.in.in \
        $(service_in_files) \
-       $(builder_DATA)
+       $(NULL)
 
 CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA)
 
diff --git a/trash/src/Makefile.am b/trash/src/Makefile.am
index 92ed843..0baf701 100644
--- a/trash/src/Makefile.am
+++ b/trash/src/Makefile.am
@@ -1,9 +1,7 @@
 NULL =
 
 trashapplet_CPPFLAGS = \
-       -DTRASH_MENU_UI_DIR=\""$(pkgdatadir)/ui"\" \
        -DGNOMELOCALEDIR=\""$(localedir)"\" \
-       -DGTK_BUILDERDIR=\""$(pkgdatadir)/builder"\" \
        -I$(top_srcdir) \
        $(GNOME_APPLETS_CFLAGS) \
        $(GIO_CFLAGS) \
@@ -18,6 +16,8 @@ trashapplet_SOURCES = \
        trash-applet.h \
        trash-empty.h \
        trash-empty.c \
+       trash-resources.c \
+       trash-resources.h \
        $(NULL)
 
 trashapplet_LDFLAGS = \
@@ -31,4 +31,16 @@ trashapplet_LDADD =          \
        $(X_LIBS) \
        $(NULL)
 
+trash-resources.c: trash-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) 
--generate-dependencies $(srcdir)/trash-resources.gresource.xml)
+       $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name trash $<
+
+trash-resources.h: trash-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) 
--generate-dependencies $(srcdir)/trash-resources.gresource.xml)
+       $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name trash $<
+
+EXTRA_DIST = \
+       trash-empty.ui \
+       trash-menu.xml \
+       trash-resources.gresource.xml \
+       $(NULL)
+
 -include $(top_srcdir)/git.mk
diff --git a/trash/src/trash-applet.c b/trash/src/trash-applet.c
index 4f49941..9a0d4f2 100644
--- a/trash/src/trash-applet.c
+++ b/trash/src/trash-applet.c
@@ -33,6 +33,8 @@
 
 #include "trash-empty.h"
 
+#define GRESOURCE "/org/gnome/gnome-applets/trash/"
+
 typedef PanelAppletClass TrashAppletClass;
 
 typedef struct
@@ -598,7 +600,7 @@ trash_applet_factory (PanelApplet *applet,
   if (!strcmp (iid, "TrashApplet"))
     {
       GSimpleActionGroup *action_group;
-      gchar          *ui_path;
+      const gchar *resource_name;
 
       g_set_application_name (_("Trash Applet"));
 
@@ -610,9 +612,11 @@ trash_applet_factory (PanelApplet *applet,
                                        trash_applet_menu_actions,
                                        G_N_ELEMENTS (trash_applet_menu_actions),
                                        applet);
-      ui_path = g_build_filename (TRASH_MENU_UI_DIR, "trashapplet-menu.xml", NULL);
-      panel_applet_setup_menu_from_file (applet, ui_path, action_group, GETTEXT_PACKAGE);
-      g_free (ui_path);
+
+      resource_name = GRESOURCE "trash-menu.xml";
+
+      panel_applet_setup_menu_from_resource (applet, resource_name,
+                                             action_group, GETTEXT_PACKAGE);
 
       gtk_widget_insert_action_group (GTK_WIDGET (applet), "trash",
                                       G_ACTION_GROUP (action_group));
diff --git a/trash/src/trash-empty.c b/trash/src/trash-empty.c
index 1ddde33..4ec8cc6 100644
--- a/trash/src/trash-empty.c
+++ b/trash/src/trash-empty.c
@@ -23,6 +23,8 @@
 #include "trash-empty.h"
 #include "config.h"
 
+#define GRESOURCE "/org/gnome/gnome-applets/trash/"
+
 /* only one concurrent trash empty operation can occur */
 static GtkDialog          *trash_empty_confirm_dialog;
 static GtkDialog          *trash_empty_dialog;
@@ -233,11 +235,13 @@ trash_empty_start (GtkWidget *parent)
   GCancellable *cancellable;
   GtkBuilder *builder;
   gint i;
+  const gchar *resource_name;
 
   builder = gtk_builder_new ();
-  gtk_builder_add_from_file (builder,
-                             GTK_BUILDERDIR "/trashapplet-empty-progress.ui",
-                             NULL);
+
+  resource_name = GRESOURCE "trash-empty.ui";
+
+  gtk_builder_add_from_resource (builder, resource_name, NULL);
 
   for (i = 0; i < G_N_ELEMENTS (widgets); i++)
     {
diff --git a/trash/trashapplet-empty-progress.ui b/trash/src/trash-empty.ui
similarity index 100%
rename from trash/trashapplet-empty-progress.ui
rename to trash/src/trash-empty.ui
diff --git a/trash/trashapplet-menu.xml b/trash/src/trash-menu.xml
similarity index 100%
rename from trash/trashapplet-menu.xml
rename to trash/src/trash-menu.xml
diff --git a/trash/src/trash-resources.gresource.xml b/trash/src/trash-resources.gresource.xml
new file mode 100644
index 0000000..4c395f8
--- /dev/null
+++ b/trash/src/trash-resources.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+    <gresource prefix="/org/gnome/gnome-applets/trash">
+        <file compressed="true">trash-empty.ui</file>
+        <file compressed="true">trash-menu.xml</file>
+    </gresource>
+</gresources>


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