summaryrefslogtreecommitdiff
path: root/cut-n-paste/toolbar-editor/egg-toolbars-model.c
diff options
context:
space:
mode:
authorChristian Persch <[email protected]>2012-06-12 20:20:47 +0200
committerraveit65 <[email protected]>2018-03-22 21:24:30 +0100
commit5d51dc6793aaf4147ebee75072cdc09333b91fc6 (patch)
treed51e0259de24434bea5cc8e579b3824e2735954d /cut-n-paste/toolbar-editor/egg-toolbars-model.c
parentc3fe25efdf8861b9e4582d84a320f37e3b89ccbd (diff)
downloadatril-5d51dc6793aaf4147ebee75072cdc09333b91fc6.tar.bz2
atril-5d51dc6793aaf4147ebee75072cdc09333b91fc6.tar.xz
toolbar-editor: Add methods to load from GResource
origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-6&id=8c240d9
Diffstat (limited to 'cut-n-paste/toolbar-editor/egg-toolbars-model.c')
-rw-r--r--cut-n-paste/toolbar-editor/egg-toolbars-model.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/cut-n-paste/toolbar-editor/egg-toolbars-model.c b/cut-n-paste/toolbar-editor/egg-toolbars-model.c
index 279533c1..57cc1884 100644
--- a/cut-n-paste/toolbar-editor/egg-toolbars-model.c
+++ b/cut-n-paste/toolbar-editor/egg-toolbars-model.c
@@ -607,6 +607,36 @@ egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
return TRUE;
}
+gboolean
+egg_toolbars_model_load_toolbars_from_resource (EggToolbarsModel *model,
+ const char *path)
+{
+ xmlDocPtr doc;
+ xmlNodePtr root;
+ GBytes *bytes;
+ GError *error = NULL;
+ const guint8 *data;
+ gsize data_len;
+
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE);
+
+ bytes = g_resources_lookup_data (path, G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
+ g_assert_no_error (error);
+
+ data = g_bytes_get_data (bytes, &data_len);
+ doc = xmlParseMemory ((const char *) data, data_len);
+ if (doc == NULL)
+ g_error ("Failed to load XML data from resource %s", path);
+
+ root = xmlDocGetRootElement (doc);
+ parse_toolbars (model, root->children);
+
+ xmlFreeDoc (doc);
+ g_bytes_unref (bytes);
+
+ return TRUE;
+}
+
static void
parse_available_list (EggToolbarsModel *model,
xmlNodePtr child)
@@ -671,6 +701,36 @@ egg_toolbars_model_load_names (EggToolbarsModel *model,
return TRUE;
}
+gboolean
+egg_toolbars_model_load_names_from_resource (EggToolbarsModel *model,
+ const char *path)
+{
+ xmlDocPtr doc;
+ xmlNodePtr root;
+ GBytes *bytes;
+ GError *error = NULL;
+ const guint8 *data;
+ gsize data_len;
+
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE);
+
+ bytes = g_resources_lookup_data (path, G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
+ g_assert_no_error (error);
+
+ data = g_bytes_get_data (bytes, &data_len);
+ doc = xmlParseMemory ((const char *) data, data_len);
+ if (doc == NULL)
+ g_error ("Failed to load XML data from resource %s", path);
+
+ root = xmlDocGetRootElement (doc);
+ parse_names (model, root->children);
+
+ xmlFreeDoc (doc);
+ g_bytes_unref (bytes);
+
+ return TRUE;
+}
+
static void
egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
{