From ddf9d29f66458d2d0fe14cc76abc348dadcf996c Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 4 Jan 2013 13:29:29 +0100 Subject: [PATCH] bluetooth: use a GResource for GtkBuilder UI definition https://bugzilla.gnome.org/show_bug.cgi?id=691132 --- panels/bluetooth/Makefile.am | 19 +++++++++++++------ panels/bluetooth/bluetooth.gresource.xml | 6 ++++++ panels/bluetooth/cc-bluetooth-panel.c | 10 ++++++---- 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 panels/bluetooth/bluetooth.gresource.xml diff --git a/panels/bluetooth/Makefile.am b/panels/bluetooth/Makefile.am index d07b79546..78303b624 100644 --- a/panels/bluetooth/Makefile.am +++ b/panels/bluetooth/Makefile.am @@ -7,25 +7,32 @@ INCLUDES = \ $(PANEL_CFLAGS) \ $(BLUETOOTH_CFLAGS) \ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \ - -DPKGDATADIR="\"$(pkgdatadir)\"" \ $(NULL) +BUILT_SOURCES = \ + cc-bluetooth-resources.h \ + cc-bluetooth-resources.c + libbluetooth_la_SOURCES = \ + $(BUILT_SOURCES) \ cc-bluetooth-panel.c \ cc-bluetooth-panel.h libbluetooth_la_LIBADD = $(PANEL_LIBS) $(BLUETOOTH_LIBS) +resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/bluetooth.gresource.xml) +cc-bluetooth-resources.c: bluetooth.gresource.xml $(resource_files) + $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_bluetooth $< +cc-bluetooth-resources.h: bluetooth.gresource.xml $(resource_files) + $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_bluetooth $< + desktopdir = $(datadir)/applications desktop_in_in_files = gnome-bluetooth-panel.desktop.in.in desktop_in_files = gnome-bluetooth-panel.desktop.in desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) @INTLTOOL_DESKTOP_RULE@ -ui_DATA = bluetooth.ui -uidir = $(pkgdatadir) - -CLEANFILES = $(desktop_DATA) -EXTRA_DIST = $(man_MANS) $(desktop_in_in_files) $(ui_DATA) +CLEANFILES = $(desktop_DATA) $(BUILT_SOURCES) +EXTRA_DIST = $(man_MANS) $(desktop_in_in_files) $(resource_files) bluetooth.gresource.xml -include $(top_srcdir)/git.mk diff --git a/panels/bluetooth/bluetooth.gresource.xml b/panels/bluetooth/bluetooth.gresource.xml new file mode 100644 index 000000000..95f0a0741 --- /dev/null +++ b/panels/bluetooth/bluetooth.gresource.xml @@ -0,0 +1,6 @@ + + + + bluetooth.ui + + diff --git a/panels/bluetooth/cc-bluetooth-panel.c b/panels/bluetooth/cc-bluetooth-panel.c index accd9b810..978404439 100644 --- a/panels/bluetooth/cc-bluetooth-panel.c +++ b/panels/bluetooth/cc-bluetooth-panel.c @@ -29,6 +29,7 @@ #include #include "cc-bluetooth-panel.h" +#include "cc-bluetooth-resources.h" #include #include @@ -782,6 +783,7 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self) GtkStyleContext *context; self->priv = BLUETOOTH_PANEL_PRIVATE (self); + g_resources_register (cc_bluetooth_get_resource ()); bluetooth_plugin_manager_init (); self->priv->killswitch = bluetooth_killswitch_new (); @@ -794,11 +796,11 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self) self->priv->builder = gtk_builder_new (); gtk_builder_set_translation_domain (self->priv->builder, GETTEXT_PACKAGE); - gtk_builder_add_from_file (self->priv->builder, - PKGDATADIR "/bluetooth.ui", - &error); + gtk_builder_add_from_resource (self->priv->builder, + "/org/gnome/control-center/bluetooth/bluetooth.ui", + &error); if (error != NULL) { - g_warning ("Failed to load '%s': %s", PKGDATADIR "/bluetooth.ui", error->message); + g_warning ("Could not load ui: %s", error->message); g_error_free (error); return; }