forked from AuroraMiddleware/gtk
Add gtk_ui_manager_add_ui_from_resource
This is a helper function to easily add ui from resource files.
This commit is contained in:
parent
c72a76c754
commit
739ab8548d
@ -2001,6 +2001,41 @@ gtk_ui_manager_add_ui_from_file (GtkUIManager *manager,
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_ui_manager_add_ui_from_resource:
|
||||
* @manager: a #GtkUIManager object
|
||||
* @resource_path: the resource path of the file to parse
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Parses a resource file containing a <link linkend="XML-UI">UI definition</link> and
|
||||
* merges it with the current contents of @manager.
|
||||
*
|
||||
* Return value: The merge id for the merged UI. The merge id can be used
|
||||
* to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred,
|
||||
* the return value is 0.
|
||||
*
|
||||
* Since: 3.4
|
||||
**/
|
||||
guint
|
||||
gtk_ui_manager_add_ui_from_resource (GtkUIManager *manager,
|
||||
const gchar *resource_path,
|
||||
GError **error)
|
||||
{
|
||||
GBytes *data;
|
||||
guint res;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), 0);
|
||||
|
||||
data = g_resources_lookup_data (resource_path, 0, error);
|
||||
if (data == NULL)
|
||||
return 0;
|
||||
|
||||
res = add_ui_from_string (manager, g_bytes_get_data (data, NULL), g_bytes_get_size (data), FALSE, error);
|
||||
g_bytes_unref (data);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_ui_manager_add_ui:
|
||||
* @manager: a #GtkUIManager
|
||||
|
@ -152,6 +152,9 @@ guint gtk_ui_manager_add_ui_from_string (GtkUIManager *manage
|
||||
guint gtk_ui_manager_add_ui_from_file (GtkUIManager *manager,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
guint gtk_ui_manager_add_ui_from_resource(GtkUIManager *manager,
|
||||
const gchar *resource_path,
|
||||
GError **error);
|
||||
void gtk_ui_manager_add_ui (GtkUIManager *manager,
|
||||
guint merge_id,
|
||||
const gchar *path,
|
||||
|
Loading…
Reference in New Issue
Block a user