[sound-juicer] Use GResources
- From: Phillip Wood <pwood src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer] Use GResources
- Date: Mon, 15 Feb 2016 10:34:13 +0000 (UTC)
commit d3d9e0a745eddcf15642eb2ce7e021607f937f9e
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Mon Feb 1 11:01:41 2016 +0000
Use GResources
This simplifies the code for setting up the app-menu and builder xml
files. It will also simplify adding a shortcuts window.
This increases the required Gtk version to 3.14 for GtkApplication to
automatically load the app-menu.
https://bugzilla.gnome.org/show_bug.cgi?id=761567
Makefile.am | 1 +
configure.ac | 6 +++++-
data/Makefile.am | 7 +++----
data/sound-juicer.gresource.xml | 7 +++++++
src/Makefile.am | 13 +++++++++++++
src/sj-main.c | 26 +-------------------------
6 files changed, 30 insertions(+), 30 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 06d343c..c8e4613 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
bin_PROGRAMS =
noinst_PROGRAMS =
sound_juicer_SOURCES =
+nodist_sound_juicer_SOURCES =
libjuicer_SOURCES =
CLEANFILES =
DISTCLEANFILES =
diff --git a/configure.ac b/configure.ac
index b52d756..cd2a916 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,9 +32,13 @@ IT_PROG_INTLTOOL([0.50.0])
GNOME_COMPILE_WARNINGS([maximum])
-GTK_REQUIRED=3.4.0
+GTK_REQUIRED=3.14.0
GLIB_GSETTINGS
+# Find glib-compile-resources
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
# Use the GNOME documentation framework
diff --git a/data/Makefile.am b/data/Makefile.am
index 9d3a69d..28c50da 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,6 +1,3 @@
-privatedatadir = $(pkgdatadir)
-dist_privatedata_DATA = data/sound-juicer.ui data/sound-juicer-menu.ui
-
desktopdir = $(datadir)/applications
desktop_in_files = data/sound-juicer.desktop.in.in
desktop_DATA = $(desktop_in_files:.desktop.in.in=.desktop)
@@ -85,6 +82,8 @@ EXTRA_DIST += \
data/sound-juicer.convert \
$(man1_MANS) \
$(icons) \
- $(appstream_in_files)
+ $(appstream_in_files) \
+ $(gresource_xml) \
+ $(gresource_deps)
MAINTAINERCLEANFILES += $(gsettings_SCHEMAS:.xml=.valid)
diff --git a/data/sound-juicer.gresource.xml b/data/sound-juicer.gresource.xml
new file mode 100644
index 0000000..ed79d99
--- /dev/null
+++ b/data/sound-juicer.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/sound-juicer">
+ <file preprocess="xml-stripblanks">sound-juicer.ui</file>
+ <file alias="gtk/menus.ui" preprocess="xml-stripblanks">sound-juicer-menu.ui</file>
+ </gresource>
+</gresources>
diff --git a/src/Makefile.am b/src/Makefile.am
index ef76661..1ca13bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,3 +22,16 @@ sound_juicer_SOURCES += \
src/sj-window-state.c \
src/sj-window-state.h \
src/sound-juicer.h
+
+nodist_sound_juicer_SOURCES += $(gresource_source)
+
+gresource_source = \
+ src/sj-resources.c
+
+gresource_xml = $(srcdir)/data/sound-juicer.gresource.xml
+gresource_deps = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/data --generate-dependencies
$(gresource_xml))
+$(gresource_source) : $(gresource_xml) $(gresource_deps)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --generate-source --target=$@ --sourcedir=$(srcdir)/data $<
+
+CLEANFILES += \
+ $(gresource_source)
diff --git a/src/sj-main.c b/src/sj-main.c
index 364cc08..1f3faea 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -120,10 +120,6 @@ static CellCbContext cell_editing_context;
#define DEFAULT_PARANOIA 15
#define RAISE_WINDOW "raise-window"
-#define SOURCE_BUILDER TOPSRCDIR"/data/sound-juicer.ui"
-#define INSTALLED_BUILDER DATADIR"/sound-juicer/sound-juicer.ui"
-#define SOURCE_MENU_BUILDER TOPSRCDIR"/data/sound-juicer-menu.ui"
-#define INSTALLED_MENU_BUILDER DATADIR"/sound-juicer/sound-juicer-menu.ui"
#define COMPOSER_ROW 2 /* Row of entry_table containing composer_entry */
void
@@ -2238,27 +2234,7 @@ startup_cb (GApplication *app, gpointer user_data)
G_CALLBACK (reread_state_changed_cb),
NULL);
- builder = gtk_builder_new ();
- if (g_file_test (SOURCE_BUILDER, G_FILE_TEST_EXISTS) != FALSE) {
- gtk_builder_add_from_file (builder, SOURCE_BUILDER, &error);
- } else {
- gtk_builder_add_from_file (builder, INSTALLED_BUILDER, &error);
- }
-
- if (g_file_test (SOURCE_MENU_BUILDER, G_FILE_TEST_EXISTS) != FALSE) {
- gtk_builder_add_from_file (builder, SOURCE_MENU_BUILDER, &error);
- } else {
- gtk_builder_add_from_file (builder, INSTALLED_MENU_BUILDER, &error);
- }
-
- gtk_application_set_app_menu (GTK_APPLICATION (app),
- G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
-
- if (error != NULL) {
- error_on_start (error);
- g_error_free (error);
- exit (1);
- }
+ builder = gtk_builder_new_from_resource ("/org/gnome/sound-juicer/sound-juicer.ui");
gtk_builder_connect_signals (builder, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]