[gnome-software] trivial: Use the same AsProfile object everywhere
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Use the same AsProfile object everywhere
- Date: Wed, 14 Sep 2016 12:44:15 +0000 (UTC)
commit c1c16827198780a856257e56549c035cb42d9574
Author: Richard Hughes <richard hughsie com>
Date: Wed Sep 14 13:17:41 2016 +0100
trivial: Use the same AsProfile object everywhere
To do this, use the AsProfile from the GsPluginLoader object.
src/gs-application.c | 8 ++++----
src/gs-cmd.c | 8 +++-----
src/gs-plugin-loader.c | 7 +++++++
src/gs-plugin-loader.h | 2 ++
4 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 2b874fa..3c1453c 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -52,7 +52,6 @@
struct _GsApplication {
GtkApplication parent;
- AsProfile *profile;
GCancellable *cancellable;
GtkApplication *application;
GtkCssProvider *provider;
@@ -121,7 +120,6 @@ gs_application_init (GsApplication *application)
g_application_add_main_option_entries (G_APPLICATION (application), options);
- application->profile = as_profile_new ();
application->network_changed_handler = 0;
}
@@ -399,7 +397,10 @@ profile_activated (GSimpleAction *action,
gpointer data)
{
GsApplication *app = GS_APPLICATION (data);
- as_profile_dump (app->profile);
+ if (app->plugin_loader != NULL) {
+ AsProfile *profile = gs_plugin_loader_get_profile (app->plugin_loader);
+ as_profile_dump (profile);
+ }
}
static void
@@ -812,7 +813,6 @@ gs_application_dispose (GObject *object)
g_clear_object (&app->shell);
g_clear_object (&app->provider);
g_clear_object (&app->update_monitor);
- g_clear_object (&app->profile);
if (app->network_changed_handler != 0) {
g_signal_handler_disconnect (app->network_monitor, app->network_changed_handler);
app->network_changed_handler = 0;
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index 439d812..7e8eb2d 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -187,6 +187,7 @@ gs_cmd_refresh_flag_from_string (const gchar *flag)
int
main (int argc, char **argv)
{
+ AsProfile *profile = NULL;
GOptionContext *context;
gboolean prefer_local = FALSE;
gboolean ret;
@@ -209,7 +210,6 @@ main (int argc, char **argv)
g_autoptr(GsApp) app = NULL;
g_autoptr(GFile) file = NULL;
g_autoptr(GsPluginLoader) plugin_loader = NULL;
- g_autoptr(AsProfile) profile = NULL;
g_autoptr(AsProfileTask) ptask = NULL;
const GOptionEntry options[] = {
{ "show-results", '\0', 0, G_OPTION_ARG_NONE, &show_results,
@@ -263,12 +263,10 @@ main (int argc, char **argv)
goto out;
}
- profile = as_profile_new ();
- ptask = as_profile_start_literal (profile, "GsCmd");
- g_assert (ptask != NULL);
-
/* load plugins */
plugin_loader = gs_plugin_loader_new ();
+ profile = gs_plugin_loader_get_profile (plugin_loader);
+ ptask = as_profile_start_literal (profile, "GsCmd");
gs_plugin_loader_set_location (plugin_loader, "./plugins/.libs");
if (plugin_whitelist_str != NULL)
plugin_whitelist = g_strsplit (plugin_whitelist_str, ",", -1);
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 5b6c8fa..854198e 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -4851,4 +4851,11 @@ gs_plugin_loader_get_plugin_supported (GsPluginLoader *plugin_loader,
/******************************************************************************/
+AsProfile *
+gs_plugin_loader_get_profile (GsPluginLoader *plugin_loader)
+{
+ GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
+ return priv->profile;
+}
+
/* vim: set noexpandtab: */
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index 6a977ca..7501cc0 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -241,6 +241,8 @@ GsPluginEvent *gs_plugin_loader_get_event_by_id (GsPluginLoader
*plugin_loader,
GsPluginEvent *gs_plugin_loader_get_event_default (GsPluginLoader *plugin_loader);
void gs_plugin_loader_remove_events (GsPluginLoader *plugin_loader);
+AsProfile *gs_plugin_loader_get_profile (GsPluginLoader *plugin_loader);
+
G_END_DECLS
#endif /* __GS_PLUGIN_LOADER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]