[rhythmbox] move GtkBuilder and CSS files into GResources for normal builds
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] move GtkBuilder and CSS files into GResources for normal builds
- Date: Wed, 10 Aug 2016 04:39:01 +0000 (UTC)
commit 6a85e2c72c0d5c5442fb2b352e1133d06709d47c
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Jun 22 20:27:53 2016 +1000
move GtkBuilder and CSS files into GResources for normal builds
Loading CSS from a resource requires gtk+ 3.16.
configure.ac | 2 +-
data/ui/Makefile.am | 8 ++------
lib/rb-builder-helpers.c | 36 +++++++++++++++++++++++++++---------
shell/rb-application.c | 9 ++++-----
shell/rhythmbox.gresource.xml | 35 +++++++++++++++++++++++++++++++++++
sources/rb-media-player-source.c | 21 +++------------------
sources/sync/rb-sync-state-ui.c | 9 +--------
7 files changed, 73 insertions(+), 47 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 22dff98..8d939dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,7 +42,7 @@ m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(long)
-GTK_REQS=3.12.0
+GTK_REQS=3.16.0
GST_REQS=1.4.0
GDK_PIXBUF_REQS=2.18.0
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
index 142f459..a42a59f 100644
--- a/data/ui/Makefile.am
+++ b/data/ui/Makefile.am
@@ -31,11 +31,7 @@ GTK_BUILDER_FILES = \
song-info-multiple.ui \
sync-dialog.ui \
sync-state.ui \
- uri-new.ui \
- style.css
+ uri-new.ui
-uidir = $(pkgdatadir)
-ui_DATA = $(GTK_BUILDER_FILES)
-
-EXTRA_DIST = $(GTK_BUILDER_FILES)
+EXTRA_DIST = $(GTK_BUILDER_FILES) style.css
diff --git a/lib/rb-builder-helpers.c b/lib/rb-builder-helpers.c
index f975089..81fbea7 100644
--- a/lib/rb-builder-helpers.c
+++ b/lib/rb-builder-helpers.c
@@ -47,9 +47,11 @@
* @user_data: user data to pass to autoconnected signal handlers
*
* Locates and reads a GtkBuilder file, automatically connecting
- * signal handlers where possible. The caller can specify a path
- * relative to the shared data directory, or its 'ui' or 'art'
- * subdirectories.
+ * signal handlers where possible.
+ *
+ * The caller can specify an absolute path to the file, or just filename,
+ * in which case the file will be loaded from GResources (in normal builds)
+ * or the source data/ui directory (in uninstalled builds).
*
* Return value: (transfer full): #GtkBuilder object built from the file
*/
@@ -59,24 +61,40 @@ rb_builder_load (const char *file, gpointer user_data)
GtkBuilder *builder;
const char *name;
GError *error = NULL;
+ char *resource;
g_return_val_if_fail (file != NULL, NULL);
- /* if the first character is /, it's an absolute path, otherwise locate it */
- if (file[0] == G_DIR_SEPARATOR)
+ if (g_path_is_absolute (file)) {
name = file;
- else
+ resource = NULL;
+ } else {
+#if defined(USE_UNINSTALLED_DIRS)
name = rb_file (file);
+ resource = NULL;
+#else
+ resource = g_strdup_printf ("/org/gnome/Rhythmbox/ui/%s", file);
+ name = NULL;
+#endif
+ }
builder = gtk_builder_new ();
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
- if (gtk_builder_add_from_file (builder, name, &error) == 0) {
- g_warning ("Error loading GtkBuilder file %s: %s", name, error->message);
- g_error_free (error);
+ if (resource != NULL) {
+ if (gtk_builder_add_from_resource (builder, resource, &error) == 0) {
+ g_warning ("Error loading GtkBuilder resource %s; %s", resource, error->message);
+ g_error_free (error);
+ }
+ } else {
+ if (gtk_builder_add_from_file (builder, name, &error) == 0) {
+ g_warning ("Error loading GtkBuilder file %s: %s", name, error->message);
+ g_error_free (error);
+ }
}
gtk_builder_connect_signals (builder, user_data);
+ g_free (resource);
return builder;
}
diff --git a/shell/rb-application.c b/shell/rb-application.c
index 8e91f1d..fe4b3d2 100644
--- a/shell/rb-application.c
+++ b/shell/rb-application.c
@@ -389,11 +389,10 @@ impl_startup (GApplication *app)
/* Use our own css provider */
provider = gtk_css_provider_new ();
- if (gtk_css_provider_load_from_path (provider, rb_file ("style.css"), NULL)) {
- gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
- GTK_STYLE_PROVIDER (provider),
- 600);
- }
+ gtk_css_provider_load_from_resource (provider, "/org/gnome/Rhythmbox/ui/style.css");
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default(),
+ GTK_STYLE_PROVIDER (provider),
+ 600);
rb->priv->shell = RB_SHELL (g_object_new (RB_TYPE_SHELL,
"application", rb,
diff --git a/shell/rhythmbox.gresource.xml b/shell/rhythmbox.gresource.xml
index 124fb01..751c61b 100644
--- a/shell/rhythmbox.gresource.xml
+++ b/shell/rhythmbox.gresource.xml
@@ -5,5 +5,40 @@
<file preprocess="to-pixdata">icons/hicolor/16x16/status/rhythmbox-unset-star.png</file>
<file preprocess="to-pixdata">icons/hicolor/16x16/status/rhythmbox-no-star.png</file>
<file preprocess="to-pixdata">icons/hicolor/48x48/status/rhythmbox-missing-artwork.png</file>
+
+ <file>ui/style.css</file>
+
+ <file preprocess="xml-stripblanks">ui/app-menu.ui</file>
+ <file preprocess="xml-stripblanks">ui/browser-popup.ui</file>
+ <file preprocess="xml-stripblanks">ui/create-playlist.ui</file>
+ <file preprocess="xml-stripblanks">ui/display-page-add-menu.ui</file>
+ <file preprocess="xml-stripblanks">ui/edit-menu.ui</file>
+ <file preprocess="xml-stripblanks">ui/encoding-settings.ui</file>
+ <file preprocess="xml-stripblanks">ui/general-prefs.ui</file>
+ <file preprocess="xml-stripblanks">ui/import-dialog.ui</file>
+ <file preprocess="xml-stripblanks">ui/import-errors-popup.ui</file>
+ <file preprocess="xml-stripblanks">ui/library-prefs.ui</file>
+ <file preprocess="xml-stripblanks">ui/library-toolbar.ui</file>
+ <file preprocess="xml-stripblanks">ui/main-toolbar.ui</file>
+ <file preprocess="xml-stripblanks">ui/media-player-properties.ui</file>
+ <file preprocess="xml-stripblanks">ui/missing-files-popup.ui</file>
+ <file preprocess="xml-stripblanks">ui/playback-prefs.ui</file>
+ <file preprocess="xml-stripblanks">ui/playlist-menu.ui</file>
+ <file preprocess="xml-stripblanks">ui/playlist-popup.ui</file>
+ <file preprocess="xml-stripblanks">ui/playlist-save.ui</file>
+ <file preprocess="xml-stripblanks">ui/playlist-toolbar.ui</file>
+ <file preprocess="xml-stripblanks">ui/podcast-add-dialog.ui</file>
+ <file preprocess="xml-stripblanks">ui/podcast-feed-properties.ui</file>
+ <file preprocess="xml-stripblanks">ui/podcast-popups.ui</file>
+ <file preprocess="xml-stripblanks">ui/podcast-prefs.ui</file>
+ <file preprocess="xml-stripblanks">ui/podcast-properties.ui</file>
+ <file preprocess="xml-stripblanks">ui/podcast-toolbar.ui</file>
+ <file preprocess="xml-stripblanks">ui/queue-popups.ui</file>
+ <file preprocess="xml-stripblanks">ui/queue-toolbar.ui</file>
+ <file preprocess="xml-stripblanks">ui/song-info-multiple.ui</file>
+ <file preprocess="xml-stripblanks">ui/song-info.ui</file>
+ <file preprocess="xml-stripblanks">ui/sync-dialog.ui</file>
+ <file preprocess="xml-stripblanks">ui/sync-state.ui</file>
+ <file preprocess="xml-stripblanks">ui/uri-new.ui</file>
</gresource>
</gresources>
diff --git a/sources/rb-media-player-source.c b/sources/rb-media-player-source.c
index f086d10..cf25236 100644
--- a/sources/rb-media-player-source.c
+++ b/sources/rb-media-player-source.c
@@ -543,7 +543,6 @@ rb_media_player_source_show_properties (RBMediaPlayerSource *source)
RBMediaPlayerSourceClass *klass = RB_MEDIA_PLAYER_SOURCE_GET_CLASS (source);
GtkBuilder *builder;
GtkContainer *container;
- const char *ui_file;
char *name;
char *text;
@@ -553,13 +552,7 @@ rb_media_player_source_show_properties (RBMediaPlayerSource *source)
}
/* load dialog UI */
- ui_file = rb_file ("media-player-properties.ui");
- if (ui_file == NULL) {
- g_warning ("Couldn't find media-player-properties.ui");
- return;
- }
-
- builder = rb_builder_load (ui_file, NULL);
+ builder = rb_builder_load ("media-player-properties.ui", NULL);
if (builder == NULL) {
g_warning ("Couldn't load media-player-properties.ui");
return;
@@ -886,7 +879,6 @@ display_sync_settings_dialog (RBMediaPlayerSource *source)
GtkWidget *content;
GtkWidget *widget;
GtkBuilder *builder;
- const char *ui_file;
char *name;
char *title;
@@ -917,16 +909,9 @@ display_sync_settings_dialog (RBMediaPlayerSource *source)
*/
content = gtk_dialog_get_content_area (GTK_DIALOG (priv->sync_dialog));
- ui_file = rb_file ("sync-dialog.ui");
- if (ui_file == NULL) {
- g_warning ("Couldn't find sync-state.ui");
- gtk_widget_show_all (priv->sync_dialog);
- return;
- }
-
- builder = rb_builder_load (ui_file, NULL);
+ builder = rb_builder_load ("sync-dialog.ui", NULL);
if (builder == NULL) {
- g_warning ("Couldn't load sync-state.ui");
+ g_warning ("Couldn't load sync-dialog.ui");
gtk_widget_show_all (priv->sync_dialog);
return;
}
diff --git a/sources/sync/rb-sync-state-ui.c b/sources/sync/rb-sync-state-ui.c
index ef86649..48edd87 100644
--- a/sources/sync/rb-sync-state-ui.c
+++ b/sources/sync/rb-sync-state-ui.c
@@ -225,19 +225,12 @@ build_ui (RBSyncStateUI *ui)
GtkWidget *container;
guint64 capacity;
GtkBuilder *builder;
- const char *ui_file;
g_object_get (ui->priv->state, "source", &source, NULL);
capacity = rb_media_player_source_get_capacity (source);
g_object_unref (source);
- ui_file = rb_file ("sync-state.ui");
- if (ui_file == NULL) {
- g_warning ("Couldn't find sync-state.ui");
- return;
- }
-
- builder = rb_builder_load (ui_file, NULL);
+ builder = rb_builder_load ("sync-state.ui", NULL);
if (builder == NULL) {
g_warning ("Couldn't load sync-state.ui");
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]