[gnome-power-manager] Compile the GtkBuilder file as a GResource to speed up startup



commit dc898bde48622f3d9d9b7538ffa0d0f40d84f02f
Author: Richard Hughes <richard hughsie com>
Date:   Thu Feb 9 15:23:24 2012 +0000

    Compile the GtkBuilder file as a GResource to speed up startup

 configure.ac                          |    2 +-
 contrib/gnome-power-manager.spec.in   |    1 -
 data/Makefile.am                      |    4 ++--
 src/Makefile.am                       |   15 +++++++++++++++
 src/gnome-power-manager.gresource.xml |    6 ++++++
 src/gpm-statistics.c                  |    4 +++-
 6 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1b7add8..9b10417 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,7 +89,7 @@ GLIB_GSETTINGS
 dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.13.0 gobject-2.0 gio-2.0 >= 2.25.9)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.31.10 gobject-2.0 gio-2.0 >= 2.25.9)
 
 PKG_CHECK_MODULES(GNOME, [
  gtk+-3.0 >= 2.91.0
diff --git a/contrib/gnome-power-manager.spec.in b/contrib/gnome-power-manager.spec.in
index 67543de..ac4587c 100644
--- a/contrib/gnome-power-manager.spec.in
+++ b/contrib/gnome-power-manager.spec.in
@@ -64,7 +64,6 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
 %{_bindir}/*
 %{_datadir}/applications/*.desktop
 %{_datadir}/glib-2.0/schemas/*.gschema.xml
-%{_datadir}/gnome-power-manager/*.ui
 %{_datadir}/gnome-power-manager/icons/hicolor/*/*/*.*
 %{_datadir}/icons/hicolor/*/apps/gnome-power-statistics.*
 %{_datadir}/icons/gnome/*/status/keyboard-brightness-symbolic.svg
diff --git a/data/Makefile.am b/data/Makefile.am
index cad260e..fbc5768 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -10,14 +10,14 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 gsettings_schemas_in_files = org.gnome.power-manager.gschema.xml.in
 gsettings_SCHEMAS = $(gsettings_schemas_in_files:.gschema.xml.in=.gschema.xml)
 
-pkgdata_DATA =						\
+UI_FILES =						\
 	gpm-statistics.ui
 
 EXTRA_DIST =						\
 	$(gsettings_SCHEMAS)				\
 	$(desktop_in_files)				\
 	$(gsettings_schemas_in_files)			\
-	$(pkgdata_DATA)
+	$(UI_FILES)
 
 clean-local :
 	rm -f *~
diff --git a/src/Makefile.am b/src/Makefile.am
index 3603d70..23e2918 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,6 +32,8 @@ gnome_power_statistics_SOURCES =			\
 	gpm-array-float.c				\
 	gpm-array-float.h				\
 	gpm-statistics.c				\
+	gpm-resources.c					\
+	gpm-resources.h					\
 	gpm-point-obj.c					\
 	gpm-point-obj.h					\
 	gpm-graph-widget.h				\
@@ -65,6 +67,19 @@ gnome_power_self_test_LDADD =				\
 
 gnome_power_self_test_CFLAGS = -DEGG_TEST $(AM_CFLAGS) $(WARNINGFLAGS)
 
+gpm-resources.c: gnome-power-manager.gresource.xml ../data/gpm-statistics.ui
+	glib-compile-resources --target=$@ --sourcedir=$(top_srcdir)/data --generate-source --c-name gpm $(srcdir)/gnome-power-manager.gresource.xml
+gpm-resources.h: gnome-power-manager.gresource.xml
+	glib-compile-resources --target=$@ --sourcedir=$(top_srcdir)/data --generate-header --c-name gpm $(srcdir)/gnome-power-manager.gresource.xml
+
+BUILT_SOURCES =						\
+	gpm-resources.c					\
+	gpm-resources.h					\
+	$(NULL)
+
+EXTRA_DIST =						\
+	gnome-power-manager.gresource.xml
+
 clean-local:
 	rm -f *~
 
diff --git a/src/gnome-power-manager.gresource.xml b/src/gnome-power-manager.gresource.xml
new file mode 100644
index 0000000..c9a9f9a
--- /dev/null
+++ b/src/gnome-power-manager.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/power-manager">
+ <file compressed="true">gpm-statistics.ui</file>
+ </gresource>
+</gresources>
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index 45b48c9..30cd559 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -1908,7 +1908,9 @@ gpm_stats_startup_cb (GApplication *application,
 
 	/* get UI */
 	builder = gtk_builder_new ();
-	retval = gtk_builder_add_from_file (builder, GPM_DATA "/gpm-statistics.ui", &error);
+	retval = gtk_builder_add_from_resource (builder,
+						"/org/gnome/power-manager/gpm-statistics.ui",
+						&error);
 	if (retval == 0) {
 		g_warning ("failed to load ui: %s", error->message);
 		g_error_free (error);



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