[totem] browser-plugin: Use GResource to load the D-Bus XML
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] browser-plugin: Use GResource to load the D-Bus XML
- Date: Wed, 27 Mar 2013 13:13:19 +0000 (UTC)
commit 9301641ce42defd87666ee4eac3425e599ff3477
Author: Bastien Nocera <hadess hadess net>
Date: Fri Mar 22 16:01:23 2013 +0100
browser-plugin: Use GResource to load the D-Bus XML
Instead of loading it through a local file with no error checking.
browser-plugin/Makefile.am | 10 +++++++++-
browser-plugin/totem-plugin-viewer.c | 12 +++++++-----
browser-plugin/totem-plugin-viewer.gresource.xml | 6 ++++++
3 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/browser-plugin/Makefile.am b/browser-plugin/Makefile.am
index 041ecb3..a8b04af 100644
--- a/browser-plugin/Makefile.am
+++ b/browser-plugin/Makefile.am
@@ -14,7 +14,6 @@ AM_CPPFLAGS = \
-I$(top_builddir)/src/backend \
-DSYSCONFDIR="\"$(sysconfdir)\"" \
-DLIBEXECDIR="\"$(libexecdir)\"" \
- -DPKGDATADIR="\"$(pkgdatadir)\"" \
$(DISABLE_DEPRECATED)
plugin_sources = \
@@ -69,6 +68,14 @@ test_glow_button_CFLAGS = \
# Totem Plugin Viewer
libexec_PROGRAMS = totem-plugin-viewer
+BUILT_SOURCES = totem-plugin-viewer-resources.c totem-plugin-viewer-resources.h
+
+resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies
$(srcdir)/totem-plugin-viewer.gresource.xml)
+totem-plugin-viewer-resources.c: totem-plugin-viewer.gresource.xml $(resource_files)
+ $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name
totem_plugin_viewer $<
+totem-plugin-viewer-resources.h: totem-plugin-viewer.gresource.xml $(resource_files)
+ $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name
totem_plugin_viewer $<
+
# Are we a bit thick, Mister?
totem-plugin-viewer.c: $(MARSHAL_FILES)
@@ -79,6 +86,7 @@ totem_plugin_viewer_SOURCES = \
totem-plugin-viewer.c \
totem-plugin-viewer-constants.h \
totem-plugin-viewer-options.h \
+ $(BUILT_SOURCES) \
$(MARSHAL_FILES)
totem_plugin_viewer_CPPFLAGS = \
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c
index a4b5a14..f2f6c91 100644
--- a/browser-plugin/totem-plugin-viewer.c
+++ b/browser-plugin/totem-plugin-viewer.c
@@ -49,6 +49,7 @@
#include "totem-glow-button.h"
#include "video-utils.h"
+#include "totem-plugin-viewer-resources.h"
#include "totem-plugin-viewer-constants.h"
#include "totem-plugin-viewer-options.h"
@@ -2261,6 +2262,7 @@ int main (int argc, char **argv)
GError *e = NULL;
char svcname[256];
GtkSettings *gtk_settings;
+ GBytes *introspection_xml;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -2341,6 +2343,8 @@ int main (int argc, char **argv)
exit (1);
}
+ g_resources_register (totem_plugin_viewer_get_resource ());
+
g_type_ensure (TOTEM_TYPE_GLOW_BUTTON);
g_type_ensure (TOTEM_TYPE_STATUSBAR);
g_type_ensure (TOTEM_TYPE_TIME_LABEL);
@@ -2401,11 +2405,9 @@ int main (int argc, char **argv)
totem_embedded_construct (emb, 0, -1, -1);
}
- //FIXME error checking
- char *introspection_xml;
- g_file_get_contents (PKGDATADIR "/org_gnome_totem_PluginViewer.xml", &introspection_xml, NULL, NULL);
- emb->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
- g_free (introspection_xml);
+ introspection_xml = g_resources_lookup_data ("/org/gnome/totem/org_gnome_totem_PluginViewer.xml", 0,
NULL);
+ emb->introspection_data = g_dbus_node_info_new_for_xml (g_bytes_get_data (introspection_xml, NULL),
NULL);
+ g_bytes_unref (introspection_xml);
if (!(emb->conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &e))) {
g_warning ("Failed to get DBUS connection: %s", e->message);
diff --git a/browser-plugin/totem-plugin-viewer.gresource.xml
b/browser-plugin/totem-plugin-viewer.gresource.xml
new file mode 100644
index 0000000..500c768
--- /dev/null
+++ b/browser-plugin/totem-plugin-viewer.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/totem">
+ <file preprocess="xml-stripblanks">org_gnome_totem_PluginViewer.xml</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]