/**
 * gs_plugin_loader_refresh:
 **/
gboolean
gs_plugin_loader_refresh (GsPluginLoader *plugin_loader,
			  guint cache_age,
			  GsPluginRefreshFlags flags,
			  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_refresh_async (plugin_loader,
					cache_age,
					flags,
					cancellable,
					(GAsyncReadyCallback) gs_plugin_loader_refresh_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.ret;
}
Пример #2
0
static void
gs_shell_loading_load (GsShellLoading *self)
{
	GsShellLoadingPrivate *priv = gs_shell_loading_get_instance_private (self);

	/* ensure that at least some metadata of any age is present, and also
	 * spin up the plugins enough as to prime caches */
	gs_plugin_loader_refresh_async (priv->plugin_loader, G_MAXUINT,
					GS_PLUGIN_REFRESH_FLAGS_METADATA,
					GS_PLUGIN_FAILURE_FLAGS_USE_EVENTS,
					priv->cancellable,
					gs_shell_loading_refresh_cb,
					self);
	g_signal_connect (priv->plugin_loader, "status-changed",
			  G_CALLBACK (gs_shell_loading_status_changed_cb),
			  self);
}