bluetooth: use a GResource for GtkBuilder UI definition

https://bugzilla.gnome.org/show_bug.cgi?id=691132
This commit is contained in:
Cosimo Cecchi 2013-01-04 13:29:29 +01:00 committed by Bastien Nocera
parent e30613e355
commit ddf9d29f66
3 changed files with 25 additions and 10 deletions

View file

@ -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

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/control-center/bluetooth">
<file preprocess="xml-stripblanks">bluetooth.ui</file>
</gresource>
</gresources>

View file

@ -29,6 +29,7 @@
#include <shell/cc-shell.h>
#include "cc-bluetooth-panel.h"
#include "cc-bluetooth-resources.h"
#include <bluetooth-client.h>
#include <bluetooth-utils.h>
@ -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;
}