[clutter] script: Add loading from a resource
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] script: Add loading from a resource
- Date: Tue, 24 Jan 2012 15:14:25 +0000 (UTC)
commit 8d8d4ae7e59d869c05251f9ad351f85e6784d136
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Mon Jan 16 11:27:08 2012 +0000
script: Add loading from a resource
GLib has gained support for compiling ancillary data files into the same
binary blob as a library or as an executable.
We should add this feature to ClutterScript, so that it's possible to
bundle UI definitions with an application.
clutter/clutter-script.c | 39 +++++++++++++++++++++++++++++++++++++++
clutter/clutter-script.h | 3 +++
clutter/clutter.symbols | 1 +
configure.ac | 2 +-
4 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/clutter/clutter-script.c b/clutter/clutter-script.c
index 1ae6105..566adc8 100644
--- a/clutter/clutter-script.c
+++ b/clutter/clutter-script.c
@@ -601,6 +601,45 @@ clutter_script_load_from_data (ClutterScript *script,
}
/**
+ * clutter_script_load_from_resource:
+ * @script: a #ClutterScript
+ * @resource_path: the resource path of the file to parse
+ * @error: return location for a #GError, or %NULL
+ *
+ * Loads the definitions from a resource file into @script and merges with
+ * the currently loaded ones, if any.
+ *
+ * Return value: on error, zero is returned and @error is set
+ * accordingly. On success, the merge id for the UI definitions is
+ * returned. You can use the merge id with clutter_script_unmerge_objects().
+ *
+ * Since: 1.10
+ */
+guint
+clutter_script_load_from_resource (ClutterScript *script,
+ const gchar *resource_path,
+ GError **error)
+{
+ GBytes *data;
+ guint res;
+
+ g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), 0);
+
+ data = g_resources_lookup_data (resource_path, 0, error);
+ if (data == NULL)
+ return 0;
+
+ res = clutter_script_load_from_data (script,
+ g_bytes_get_data (data, NULL),
+ g_bytes_get_size (data),
+ error);
+
+ g_bytes_unref (data);
+
+ return res;
+}
+
+/**
* clutter_script_get_object:
* @script: a #ClutterScript
* @name: the name of the object to retrieve
diff --git a/clutter/clutter-script.h b/clutter/clutter-script.h
index 1da9870..db33c51 100644
--- a/clutter/clutter-script.h
+++ b/clutter/clutter-script.h
@@ -153,6 +153,9 @@ guint clutter_script_load_from_data (ClutterScript
const gchar *data,
gssize length,
GError **error);
+guint clutter_script_load_from_resource (ClutterScript *script,
+ const gchar *resource_path,
+ GError **error);
GObject * clutter_script_get_object (ClutterScript *script,
const gchar *name);
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index a3d6796..294200f 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -936,6 +936,7 @@ clutter_script_get_type_from_name
clutter_script_list_objects
clutter_script_load_from_data
clutter_script_load_from_file
+clutter_script_load_from_resource
clutter_script_lookup_filename
clutter_script_new
clutter_script_unmerge_objects
diff --git a/configure.ac b/configure.ac
index 9ae7aea..b6b58dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,7 +129,7 @@ LT_INIT([disable-static])
AC_HEADER_STDC
# required versions for dependencies
-m4_define([glib_req_version], [2.31.0])
+m4_define([glib_req_version], [2.31.10])
m4_define([cogl_req_version], [1.9.4])
m4_define([json_glib_req_version], [0.12.0])
m4_define([atk_req_version], [2.1.5])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]