[gnome-control-center] notifications: use a GResource for GtkBuilder UI definition



commit 5975b1773a27d8d92901582f530fcbb74ecbfa9f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 15:37:54 2013 +0100

    notifications: use a GResource for GtkBuilder UI definition
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691132

 panels/notifications/Makefile.am                 |   17 ++++++++++++-----
 panels/notifications/cc-notifications-panel.c    |    8 +++++---
 panels/notifications/notifications.gresource.xml |    6 ++++++
 3 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/panels/notifications/Makefile.am b/panels/notifications/Makefile.am
index d621df2..0135b04 100644
--- a/panels/notifications/Makefile.am
+++ b/panels/notifications/Makefile.am
@@ -3,14 +3,17 @@ cappletname = notifications
 INCLUDES = 						\
 	$(PANEL_CFLAGS)					\
 	$(NOTIFICATIONS_PANEL_CFLAGS)			\
-	-DGNOMECC_UI_DIR="\"$(uidir)\""			\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
 	$(NULL)
 
 noinst_LTLIBRARIES = libnotifications.la
 
+BUILT_SOURCES =				\
+	cc-notifications-resources.c	\
+	cc-notifications-resources.h
+
 libnotifications_la_SOURCES =		\
+	$(BUILT_SOURCES)		\
 	cc-edit-dialog.c		\
 	cc-edit-dialog.h		\
 	cc-notifications-panel.c	\
@@ -18,8 +21,11 @@ libnotifications_la_SOURCES =		\
 
 libnotifications_la_LIBADD = $(NOTIFICATIONS_PANEL_LIBS) $(PANEL_LIBS)
 
-uidir = $(pkgdatadir)/ui
-dist_ui_DATA = notifications.ui
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/notifications.gresource.xml)
+cc-notifications-resources.c: notifications.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_notifications $<
+cc-notifications-resources.h: notifications.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_notifications $<
 
 @INTLTOOL_DESKTOP_RULE@
 
@@ -27,6 +33,7 @@ desktopdir = $(datadir)/applications
 desktop_in_files = gnome-notifications-panel.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 
-CLEANFILES = $(desktop_in_files) $(desktop_DATA)
+CLEANFILES = $(desktop_in_files) $(desktop_DATA) $(BUILT_SOURCES)
+EXTRA_DIST = $(resource_files) notifications.gresource.xml
 
 -include $(top_srcdir)/git.mk
diff --git a/panels/notifications/cc-notifications-panel.c b/panels/notifications/cc-notifications-panel.c
index a32d719..f2995cb 100644
--- a/panels/notifications/cc-notifications-panel.c
+++ b/panels/notifications/cc-notifications-panel.c
@@ -29,6 +29,7 @@
 
 #include <egg-list-box/egg-list-box.h>
 #include "cc-notifications-panel.h"
+#include "cc-notifications-resources.h"
 #include "cc-edit-dialog.h"
 
 #define MASTER_SCHEMA "org.gnome.desktop.notifications"
@@ -114,13 +115,14 @@ cc_notifications_panel_init (CcNotificationsPanel *panel)
   GtkWidget *w;
   GError *error = NULL;
 
+  g_resources_register (cc_notifications_get_resource ());
   panel->known_applications = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                      NULL, g_free);
 
   panel->builder = gtk_builder_new ();
-  if (gtk_builder_add_from_file (panel->builder,
-                                 GNOMECC_UI_DIR "/notifications.ui",
-                                 &error) == 0)
+  if (gtk_builder_add_from_resource (panel->builder,
+                                     "/org/gnome/control-center/notifications/notifications.ui",
+                                     &error) == 0)
     {
       g_error ("Error loading UI file: %s", error->message);
       g_error_free (error);
diff --git a/panels/notifications/notifications.gresource.xml b/panels/notifications/notifications.gresource.xml
new file mode 100644
index 0000000..fa82dfe
--- /dev/null
+++ b/panels/notifications/notifications.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/notifications">
+    <file preprocess="xml-stripblanks">notifications.ui</file>
+  </gresource>
+</gresources>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]