[gnome-software] Add sync helpers for the new category functionality



commit 9ba3d365546efc1ef2d5c0c5dd40ea88e8262ed5
Author: Richard Hughes <richard hughsie com>
Date:   Mon Sep 2 14:53:57 2013 +0100

    Add sync helpers for the new category functionality
    
    This allows us to use it in the self test framework.

 src/gs-plugin-loader-sync.c |   88 +++++++++++++++++++++++++++++++++++++++++++
 src/gs-plugin-loader-sync.h |    7 +++
 2 files changed, 95 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader-sync.c b/src/gs-plugin-loader-sync.c
index f3e9812..28fac39 100644
--- a/src/gs-plugin-loader-sync.c
+++ b/src/gs-plugin-loader-sync.c
@@ -159,3 +159,91 @@ gs_plugin_loader_get_popular (GsPluginLoader *plugin_loader,
 
        return helper.list;
 }
+
+static void
+gs_plugin_loader_get_categories_finish_sync (GsPluginLoader *plugin_loader,
+                                            GAsyncResult *res,
+                                            GsPluginLoaderHelper *helper)
+{
+       helper->list = gs_plugin_loader_get_categories_finish (plugin_loader,
+                                                              res,
+                                                              helper->error);
+       g_main_loop_quit (helper->loop);
+}
+
+/**
+ * gs_plugin_loader_get_categories:
+ **/
+GList *
+gs_plugin_loader_get_categories (GsPluginLoader *plugin_loader,
+                                GCancellable *cancellable,
+                                GError **error)
+{
+       GsPluginLoaderHelper helper;
+
+       /* create temp object */
+       helper.context = g_main_context_new ();
+       helper.loop = g_main_loop_new (helper.context, FALSE);
+       helper.error = error;
+
+       g_main_context_push_thread_default (helper.context);
+
+       /* run async method */
+       gs_plugin_loader_get_categories_async (plugin_loader,
+                                              cancellable,
+                                              (GAsyncReadyCallback) 
gs_plugin_loader_get_categories_finish_sync,
+                                              &helper);
+       g_main_loop_run (helper.loop);
+
+       g_main_context_pop_thread_default (helper.context);
+
+       g_main_loop_unref (helper.loop);
+       g_main_context_unref (helper.context);
+
+       return helper.list;
+}
+
+static void
+gs_plugin_loader_get_category_apps_finish_sync (GsPluginLoader *plugin_loader,
+                                               GAsyncResult *res,
+                                               GsPluginLoaderHelper *helper)
+{
+       helper->list = gs_plugin_loader_get_category_apps_finish (plugin_loader,
+                                                                 res,
+                                                                 helper->error);
+       g_main_loop_quit (helper->loop);
+}
+
+/**
+ * gs_plugin_loader_get_category_apps:
+ **/
+GList *
+gs_plugin_loader_get_category_apps (GsPluginLoader *plugin_loader,
+                                   GsCategory *category,
+                                   GCancellable *cancellable,
+                                   GError **error)
+{
+       GsPluginLoaderHelper helper;
+
+       /* create temp object */
+       helper.context = g_main_context_new ();
+       helper.loop = g_main_loop_new (helper.context, FALSE);
+       helper.error = error;
+
+       g_main_context_push_thread_default (helper.context);
+
+       /* run async method */
+       gs_plugin_loader_get_category_apps_async (plugin_loader,
+                                                 category,
+                                                 cancellable,
+                                                 (GAsyncReadyCallback) 
gs_plugin_loader_get_category_apps_finish_sync,
+                                                 &helper);
+       g_main_loop_run (helper.loop);
+
+       g_main_context_pop_thread_default (helper.context);
+
+       g_main_loop_unref (helper.loop);
+       g_main_context_unref (helper.context);
+
+       return helper.list;
+}
diff --git a/src/gs-plugin-loader-sync.h b/src/gs-plugin-loader-sync.h
index ef43254..a314fcb 100644
--- a/src/gs-plugin-loader-sync.h
+++ b/src/gs-plugin-loader-sync.h
@@ -37,6 +37,13 @@ GList                *gs_plugin_loader_get_updates           (GsPluginLoader 
*plugin_loader,
 GList          *gs_plugin_loader_get_popular           (GsPluginLoader *plugin_loader,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
+GList          *gs_plugin_loader_get_categories        (GsPluginLoader *plugin_loader,
+                                                        GCancellable   *cancellable,
+                                                        GError         **error);
+GList          *gs_plugin_loader_get_category_apps     (GsPluginLoader *plugin_loader,
+                                                        GsCategory     *category,
+                                                        GCancellable   *cancellable,
+                                                        GError         **error);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]