Commit 9ba3d365 authored by Richard Hughes's avatar Richard Hughes
Browse files

Add sync helpers for the new category functionality

This allows us to use it in the self test framework.
parent b3c55611
......@@ -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;
}
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment