mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
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.
This commit is contained in:
parent
254ebd8765
commit
8d8d4ae7e5
@ -600,6 +600,45 @@ clutter_script_load_from_data (ClutterScript *script,
|
||||
return priv->last_merge_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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])
|
||||
|
Loading…
Reference in New Issue
Block a user