[gnome-disk-utility] Include UI files in application binary via gresource(1)



commit ae3af185b4ad5fb1cc10c3aa2b5ba4e748ab75ca
Author: David Zeuthen <zeuthen gmail com>
Date:   Mon Jan 20 12:07:54 2014 -0800

    Include UI files in application binary via gresource(1)
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 configure.ac                                       |    3 +-
 data/Makefile.am                                   |    2 +-
 data/ui/Makefile.am                                |   35 ----------------
 po/POTFILES.in                                     |   42 ++++++++++----------
 src/disks/Makefile.am                              |   13 ++++++-
 src/disks/gduapplication.c                         |   35 ++--------------
 src/disks/gnome-disks.gresource.xml                |   26 ++++++++++++
 {data => src/disks}/ui/about-dialog.ui             |    0
 {data => src/disks}/ui/app-menu.ui                 |    0
 {data => src/disks}/ui/benchmark-dialog.ui         |    0
 {data => src/disks}/ui/change-passphrase-dialog.ui |    0
 {data => src/disks}/ui/create-disk-image-dialog.ui |    0
 {data => src/disks}/ui/create-partition-dialog.ui  |    0
 {data => src/disks}/ui/disk-settings-dialog.ui     |    0
 {data => src/disks}/ui/disks.ui                    |    0
 {data => src/disks}/ui/edit-crypttab-dialog.ui     |    0
 .../disks}/ui/edit-dos-partition-dialog.ui         |    0
 {data => src/disks}/ui/edit-filesystem-dialog.ui   |    0
 {data => src/disks}/ui/edit-fstab-dialog.ui        |    0
 .../disks}/ui/edit-gpt-partition-dialog.ui         |    0
 {data => src/disks}/ui/edit-partition-dialog.ui    |    0
 .../disks}/ui/erase-multiple-disks-dialog.ui       |    0
 {data => src/disks}/ui/filesystem-create.ui        |    0
 {data => src/disks}/ui/format-disk-dialog.ui       |    0
 {data => src/disks}/ui/format-volume-dialog.ui     |    0
 .../disks}/ui/restore-disk-image-dialog.ui         |    0
 {data => src/disks}/ui/smart-dialog.ui             |    0
 {data => src/disks}/ui/unlock-device-dialog.ui     |    0
 28 files changed, 66 insertions(+), 90 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0cadced..59dd951 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,6 +129,8 @@ AC_SUBST([gsd_plugindir])
 
 GLIB_GSETTINGS
 
+AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
+
 dnl **********************************
 dnl *** Check for libsystemd-login ***
 dnl **********************************
@@ -209,7 +211,6 @@ data/icons/HighContrast/48x48/Makefile
 data/icons/HighContrast/256x256/Makefile
 data/org.gnome.Disks.gschema.xml.in
 data/org.gnome.settings-daemon.plugins.gdu-sd.gschema.xml.in
-data/ui/Makefile
 doc/Makefile
 doc/man/Makefile
 ])
diff --git a/data/Makefile.am b/data/Makefile.am
index d0c80d7..2f402e7 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,6 +1,6 @@
 NULL =
 
-SUBDIRS = ui icons
+SUBDIRS = icons
 
 desktopdir = $(datadir)/applications
 desktop_in_files =                             \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8358bb0..76a944d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,27 +6,6 @@ data/gnome-disk-image-writer.desktop.in
 data/gnome-disks.desktop.in
 data/org.gnome.Disks.gschema.xml.in.in
 data/org.gnome.settings-daemon.plugins.gdu-sd.gschema.xml.in.in
-[type: gettext/glade]data/ui/about-dialog.ui
-[type: gettext/glade]data/ui/app-menu.ui
-[type: gettext/glade]data/ui/benchmark-dialog.ui
-[type: gettext/glade]data/ui/change-passphrase-dialog.ui
-[type: gettext/glade]data/ui/create-disk-image-dialog.ui
-[type: gettext/glade]data/ui/create-partition-dialog.ui
-[type: gettext/glade]data/ui/disk-settings-dialog.ui
-[type: gettext/glade]data/ui/disks.ui
-[type: gettext/glade]data/ui/edit-crypttab-dialog.ui
-[type: gettext/glade]data/ui/edit-dos-partition-dialog.ui
-[type: gettext/glade]data/ui/edit-filesystem-dialog.ui
-[type: gettext/glade]data/ui/edit-fstab-dialog.ui
-[type: gettext/glade]data/ui/edit-gpt-partition-dialog.ui
-[type: gettext/glade]data/ui/edit-partition-dialog.ui
-[type: gettext/glade]data/ui/erase-multiple-disks-dialog.ui
-[type: gettext/glade]data/ui/filesystem-create.ui
-[type: gettext/glade]data/ui/format-disk-dialog.ui
-[type: gettext/glade]data/ui/format-volume-dialog.ui
-[type: gettext/glade]data/ui/restore-disk-image-dialog.ui
-[type: gettext/glade]data/ui/smart-dialog.ui
-[type: gettext/glade]data/ui/unlock-device-dialog.ui
 src/disk-image-mounter/main.c
 src/disks/gduapplication.c
 src/disks/gduatasmartdialog.c
@@ -52,6 +31,27 @@ src/disks/gduvolumegrid.c
 src/disks/gduwindow.c
 src/disks/gduxzdecompressor.c
 src/disks/main.c
+[type: gettext/glade]src/disks/ui/about-dialog.ui
+[type: gettext/glade]src/disks/ui/app-menu.ui
+[type: gettext/glade]src/disks/ui/benchmark-dialog.ui
+[type: gettext/glade]src/disks/ui/change-passphrase-dialog.ui
+[type: gettext/glade]src/disks/ui/create-disk-image-dialog.ui
+[type: gettext/glade]src/disks/ui/create-partition-dialog.ui
+[type: gettext/glade]src/disks/ui/disk-settings-dialog.ui
+[type: gettext/glade]src/disks/ui/disks.ui
+[type: gettext/glade]src/disks/ui/edit-crypttab-dialog.ui
+[type: gettext/glade]src/disks/ui/edit-dos-partition-dialog.ui
+[type: gettext/glade]src/disks/ui/edit-filesystem-dialog.ui
+[type: gettext/glade]src/disks/ui/edit-fstab-dialog.ui
+[type: gettext/glade]src/disks/ui/edit-gpt-partition-dialog.ui
+[type: gettext/glade]src/disks/ui/edit-partition-dialog.ui
+[type: gettext/glade]src/disks/ui/erase-multiple-disks-dialog.ui
+[type: gettext/glade]src/disks/ui/filesystem-create.ui
+[type: gettext/glade]src/disks/ui/format-disk-dialog.ui
+[type: gettext/glade]src/disks/ui/format-volume-dialog.ui
+[type: gettext/glade]src/disks/ui/restore-disk-image-dialog.ui
+[type: gettext/glade]src/disks/ui/smart-dialog.ui
+[type: gettext/glade]src/disks/ui/unlock-device-dialog.ui
 src/libgdu/gduutils.c
 src/notify/gdusdmonitor.c
 [type: gettext/ini]src/notify/gdu-sd-plugin.gnome-settings-plugin.in
diff --git a/src/disks/Makefile.am b/src/disks/Makefile.am
index 352ff77..79e8329 100644
--- a/src/disks/Makefile.am
+++ b/src/disks/Makefile.am
@@ -4,6 +4,15 @@ BUILT_SOURCES =
 
 bin_PROGRAMS = gnome-disks
 
+GRESDEPS = $(srcdir)/$1 $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir 
$(srcdir)/$(dir $1) $(srcdir)/$1)
+
+GRESGEN = $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target="$@" --sourcedir="$(dir $<)" --generate-source "$<"
+
+disks_resource_deps = $(call GRESDEPS,gnome-disks.gresource.xml)
+resources.c: $(disks_resource_deps)
+       echo $(disks_resource_deps)
+       $(GRESGEN)
+
 gduenumtypes.h: gduenums.h gduenumtypes.h.template
        ( top_builddir=`cd $(top_builddir) && pwd`;                                             \
         cd $(srcdir) && glib-mkenums --template gduenumtypes.h.template gduenums.h ) >         \
@@ -20,10 +29,11 @@ enum_built_sources =                                                        \
        gduenumtypes.h                  gduenumtypes.c                  \
        $(NULL)
 
-BUILT_SOURCES += $(enum_built_sources)
+BUILT_SOURCES += $(enum_built_sources) resources.c
 
 gnome_disks_SOURCES =                                                  \
                                        main.c                          \
+                                       resources.c                     \
        gduapplication.h                gduapplication.c                \
        gdudevicetreemodel.h            gdudevicetreemodel.c            \
        gdutypes.h                                                      \
@@ -92,6 +102,7 @@ gnome_disks_LDADD =                                  \
 EXTRA_DIST =                                           \
        gduenumtypes.h.template                         \
        gduenumtypes.c.template                         \
+       $(disks_resource_deps)                          \
        $(NULL)
 
 clean-local :
diff --git a/src/disks/gduapplication.c b/src/disks/gduapplication.c
index 8984c56..679616f 100644
--- a/src/disks/gduapplication.c
+++ b/src/disks/gduapplication.c
@@ -26,8 +26,6 @@ struct _GduApplication
 {
   GtkApplication parent_instance;
 
-  gboolean running_from_source_tree;
-
   UDisksClient *client;
   GduWindow *window;
 
@@ -75,26 +73,6 @@ gdu_application_finalize (GObject *object)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-/* called in local instance */
-static gboolean
-gdu_application_local_command_line (GApplication    *_app,
-                                    gchar         ***arguments,
-                                    int             *exit_status)
-{
-  GduApplication *app = GDU_APPLICATION (_app);
-
-  /* figure out if running from source tree */
-  if (g_strcmp0 ((*arguments)[0], "./gnome-disks") == 0)
-    app->running_from_source_tree = TRUE;
-
-  /* chain up */
-  return G_APPLICATION_CLASS (gdu_application_parent_class)->local_command_line (_app,
-                                                                                 arguments,
-                                                                                 exit_status);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
 static void
 gdu_application_ensure_client (GduApplication *app)
 {
@@ -410,10 +388,9 @@ gdu_application_class_init (GduApplicationClass *klass)
   gobject_class->finalize = gdu_application_finalize;
 
   application_class = G_APPLICATION_CLASS (klass);
-  application_class->local_command_line = gdu_application_local_command_line;
   application_class->command_line = gdu_application_command_line;
-  application_class->activate           = gdu_application_activate;
-  application_class->startup            = gdu_application_startup;
+  application_class->activate     = gdu_application_activate;
+  application_class->startup      = gdu_application_startup;
 }
 
 GApplication *
@@ -449,14 +426,10 @@ gdu_application_new_widget (GduApplication  *application,
 
   builder = gtk_builder_new ();
 
-  path = g_strdup_printf ("%s/%s",
-                          application->running_from_source_tree ?
-                            "../../data/ui" :
-                            PACKAGE_DATA_DIR "/gnome-disk-utility",
-                          ui_file);
+  path = g_strdup_printf ("/org/gnome/Disks/ui/%s", ui_file);
 
   error = NULL;
-  if (gtk_builder_add_from_file (builder, path, &error) == 0)
+  if (gtk_builder_add_from_resource (builder, path, &error) == 0)
     {
       g_error ("Error loading UI file %s: %s", path, error->message);
       g_error_free (error);
diff --git a/src/disks/gnome-disks.gresource.xml b/src/disks/gnome-disks.gresource.xml
new file mode 100644
index 0000000..146a7cc
--- /dev/null
+++ b/src/disks/gnome-disks.gresource.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/Disks">
+    <file preprocess="xml-stripblanks">ui/about-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/app-menu.ui</file>
+    <file preprocess="xml-stripblanks">ui/benchmark-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/change-passphrase-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/create-disk-image-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/create-partition-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/disk-settings-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/disks.ui</file>
+    <file preprocess="xml-stripblanks">ui/edit-crypttab-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/edit-dos-partition-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/edit-filesystem-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/edit-fstab-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/edit-gpt-partition-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/edit-partition-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/erase-multiple-disks-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/filesystem-create.ui</file>
+    <file preprocess="xml-stripblanks">ui/format-disk-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/format-volume-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/restore-disk-image-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/smart-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ui/unlock-device-dialog.ui</file>
+  </gresource>
+</gresources>
diff --git a/data/ui/about-dialog.ui b/src/disks/ui/about-dialog.ui
similarity index 100%
rename from data/ui/about-dialog.ui
rename to src/disks/ui/about-dialog.ui
diff --git a/data/ui/app-menu.ui b/src/disks/ui/app-menu.ui
similarity index 100%
rename from data/ui/app-menu.ui
rename to src/disks/ui/app-menu.ui
diff --git a/data/ui/benchmark-dialog.ui b/src/disks/ui/benchmark-dialog.ui
similarity index 100%
rename from data/ui/benchmark-dialog.ui
rename to src/disks/ui/benchmark-dialog.ui
diff --git a/data/ui/change-passphrase-dialog.ui b/src/disks/ui/change-passphrase-dialog.ui
similarity index 100%
rename from data/ui/change-passphrase-dialog.ui
rename to src/disks/ui/change-passphrase-dialog.ui
diff --git a/data/ui/create-disk-image-dialog.ui b/src/disks/ui/create-disk-image-dialog.ui
similarity index 100%
rename from data/ui/create-disk-image-dialog.ui
rename to src/disks/ui/create-disk-image-dialog.ui
diff --git a/data/ui/create-partition-dialog.ui b/src/disks/ui/create-partition-dialog.ui
similarity index 100%
rename from data/ui/create-partition-dialog.ui
rename to src/disks/ui/create-partition-dialog.ui
diff --git a/data/ui/disk-settings-dialog.ui b/src/disks/ui/disk-settings-dialog.ui
similarity index 100%
rename from data/ui/disk-settings-dialog.ui
rename to src/disks/ui/disk-settings-dialog.ui
diff --git a/data/ui/disks.ui b/src/disks/ui/disks.ui
similarity index 100%
rename from data/ui/disks.ui
rename to src/disks/ui/disks.ui
diff --git a/data/ui/edit-crypttab-dialog.ui b/src/disks/ui/edit-crypttab-dialog.ui
similarity index 100%
rename from data/ui/edit-crypttab-dialog.ui
rename to src/disks/ui/edit-crypttab-dialog.ui
diff --git a/data/ui/edit-dos-partition-dialog.ui b/src/disks/ui/edit-dos-partition-dialog.ui
similarity index 100%
rename from data/ui/edit-dos-partition-dialog.ui
rename to src/disks/ui/edit-dos-partition-dialog.ui
diff --git a/data/ui/edit-filesystem-dialog.ui b/src/disks/ui/edit-filesystem-dialog.ui
similarity index 100%
rename from data/ui/edit-filesystem-dialog.ui
rename to src/disks/ui/edit-filesystem-dialog.ui
diff --git a/data/ui/edit-fstab-dialog.ui b/src/disks/ui/edit-fstab-dialog.ui
similarity index 100%
rename from data/ui/edit-fstab-dialog.ui
rename to src/disks/ui/edit-fstab-dialog.ui
diff --git a/data/ui/edit-gpt-partition-dialog.ui b/src/disks/ui/edit-gpt-partition-dialog.ui
similarity index 100%
rename from data/ui/edit-gpt-partition-dialog.ui
rename to src/disks/ui/edit-gpt-partition-dialog.ui
diff --git a/data/ui/edit-partition-dialog.ui b/src/disks/ui/edit-partition-dialog.ui
similarity index 100%
rename from data/ui/edit-partition-dialog.ui
rename to src/disks/ui/edit-partition-dialog.ui
diff --git a/data/ui/erase-multiple-disks-dialog.ui b/src/disks/ui/erase-multiple-disks-dialog.ui
similarity index 100%
rename from data/ui/erase-multiple-disks-dialog.ui
rename to src/disks/ui/erase-multiple-disks-dialog.ui
diff --git a/data/ui/filesystem-create.ui b/src/disks/ui/filesystem-create.ui
similarity index 100%
rename from data/ui/filesystem-create.ui
rename to src/disks/ui/filesystem-create.ui
diff --git a/data/ui/format-disk-dialog.ui b/src/disks/ui/format-disk-dialog.ui
similarity index 100%
rename from data/ui/format-disk-dialog.ui
rename to src/disks/ui/format-disk-dialog.ui
diff --git a/data/ui/format-volume-dialog.ui b/src/disks/ui/format-volume-dialog.ui
similarity index 100%
rename from data/ui/format-volume-dialog.ui
rename to src/disks/ui/format-volume-dialog.ui
diff --git a/data/ui/restore-disk-image-dialog.ui b/src/disks/ui/restore-disk-image-dialog.ui
similarity index 100%
rename from data/ui/restore-disk-image-dialog.ui
rename to src/disks/ui/restore-disk-image-dialog.ui
diff --git a/data/ui/smart-dialog.ui b/src/disks/ui/smart-dialog.ui
similarity index 100%
rename from data/ui/smart-dialog.ui
rename to src/disks/ui/smart-dialog.ui
diff --git a/data/ui/unlock-device-dialog.ui b/src/disks/ui/unlock-device-dialog.ui
similarity index 100%
rename from data/ui/unlock-device-dialog.ui
rename to src/disks/ui/unlock-device-dialog.ui


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