summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-09-13 16:30:41 +0100
committerRichard Hughes <richard@hughsie.com>2016-09-13 16:30:42 +0100
commit6c643f1a662315df12692b16428f53202a26c043 (patch)
treef0a1b51105d01dc94ba3c37c9493d79715a910a8
parentf408f4dc840281e50438c5daf8baed79dad072f4 (diff)
downloadappstream-glib-6c643f1a662315df12692b16428f53202a26c043.tar.gz
Add as_store_add_apps()
This allows us to add lots of apps without issuing a 'changed' signal for each.
-rw-r--r--libappstream-glib/as-store.c31
-rw-r--r--libappstream-glib/as-store.h2
2 files changed, 33 insertions, 0 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 33278a8..082af45 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -893,6 +893,37 @@ _as_app_is_perhaps_merge_component (AsApp *app)
}
/**
+ * as_store_add_apps:
+ * @store: a #AsStore instance.
+ * @apps: (element-type AsApp): an array of apps
+ *
+ * Adds several applications to the store.
+ *
+ * Additionally only applications where the kind is known will be added.
+ *
+ * Since: 0.6.4
+ **/
+void
+as_store_add_apps (AsStore *store, GPtrArray *apps)
+{
+ guint i;
+ _cleanup_uninhibit_ guint32 *tok = NULL;
+
+ g_return_if_fail (AS_IS_STORE (store));
+
+ /* emit once when finished */
+ tok = as_store_changed_inhibit (store);
+ for (i = 0; i < apps->len; i++) {
+ AsApp *app = g_ptr_array_index (apps, i);
+ as_store_add_app (store, app);
+ }
+
+ /* this store has changed */
+ as_store_changed_uninhibit (&tok);
+ as_store_perhaps_emit_changed (store, "add-apps");
+}
+
+/**
* as_store_add_app:
* @store: a #AsStore instance.
* @app: a #AsApp instance.
diff --git a/libappstream-glib/as-store.h b/libappstream-glib/as-store.h
index 5daba5b..b09169a 100644
--- a/libappstream-glib/as-store.h
+++ b/libappstream-glib/as-store.h
@@ -201,6 +201,8 @@ AsApp *as_store_get_app_by_provide (AsStore *store,
const gchar *value);
void as_store_add_app (AsStore *store,
AsApp *app);
+void as_store_add_apps (AsStore *store,
+ GPtrArray *apps);
void as_store_remove_app (AsStore *store,
AsApp *app);
void as_store_remove_app_by_id (AsStore *store,