[gnome-software: 8/20] gs-application: Remove redundant get_plugin_loader() method




commit 70edec04d063ede408ac44dab849ea378fa79a0d
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Mar 7 15:21:04 2022 +0000

    gs-application: Remove redundant get_plugin_loader() method
    
    It was only used in `GsUpdateMonitor`, and it’s more flexible to just
    pass a `GsPluginLoader` directly to its constructor.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 src/gs-application.c    | 9 +--------
 src/gs-application.h    | 1 -
 src/gs-update-monitor.c | 7 ++++---
 src/gs-update-monitor.h | 3 ++-
 4 files changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index c56b6dec1..efeed5353 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -99,12 +99,6 @@ gs_activation_helper_free (GsActivationHelper *helper)
        g_slice_free (GsActivationHelper, helper);
 }
 
-GsPluginLoader *
-gs_application_get_plugin_loader (GsApplication *application)
-{
-       return application->plugin_loader;
-}
-
 gboolean
 gs_application_has_active_window (GsApplication *application)
 {
@@ -1016,8 +1010,7 @@ gs_application_startup (GApplication *application)
        app->main_window = GTK_WINDOW (app->shell);
        gtk_application_add_window (GTK_APPLICATION (app), app->main_window);
 
-       GS_APPLICATION (application)->update_monitor =
-               gs_update_monitor_new (GS_APPLICATION (application));
+       app->update_monitor = gs_update_monitor_new (app, app->plugin_loader);
 
        gs_application_update_software_sources_presence (application);
 }
diff --git a/src/gs-application.h b/src/gs-application.h
index cf8fb7ab1..8aee69720 100644
--- a/src/gs-application.h
+++ b/src/gs-application.h
@@ -18,7 +18,6 @@
 G_DECLARE_FINAL_TYPE (GsApplication, gs_application, GS, APPLICATION, AdwApplication)
 
 GsApplication  *gs_application_new                     (GsDebug *debug);
-GsPluginLoader *gs_application_get_plugin_loader       (GsApplication *application);
 gboolean        gs_application_has_active_window       (GsApplication *application);
 void            gs_application_emit_install_resources_done
                                                        (GsApplication *application,
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index da338f52b..1431d5a4d 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -1408,7 +1408,7 @@ gs_update_monitor_dispose (GObject *object)
                g_signal_handlers_disconnect_by_func (monitor->plugin_loader,
                                                      network_available_notify_cb,
                                                      monitor);
-               monitor->plugin_loader = NULL;
+               g_clear_object (&monitor->plugin_loader);
        }
        g_clear_object (&monitor->settings);
        g_clear_object (&monitor->proxy_upower);
@@ -1436,7 +1436,8 @@ gs_update_monitor_class_init (GsUpdateMonitorClass *klass)
 }
 
 GsUpdateMonitor *
-gs_update_monitor_new (GsApplication *application)
+gs_update_monitor_new (GsApplication  *application,
+                       GsPluginLoader *plugin_loader)
 {
        GsUpdateMonitor *monitor;
 
@@ -1444,7 +1445,7 @@ gs_update_monitor_new (GsApplication *application)
        monitor->application = G_APPLICATION (application);
        g_application_hold (monitor->application);
 
-       monitor->plugin_loader = gs_application_get_plugin_loader (application);
+       monitor->plugin_loader = g_object_ref (plugin_loader);
        g_signal_connect (monitor->plugin_loader, "notify::allow-updates",
                          G_CALLBACK (allow_updates_notify_cb), monitor);
        g_signal_connect (monitor->plugin_loader, "notify::network-available",
diff --git a/src/gs-update-monitor.h b/src/gs-update-monitor.h
index db8c36336..0d39f5214 100644
--- a/src/gs-update-monitor.h
+++ b/src/gs-update-monitor.h
@@ -20,7 +20,8 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GsUpdateMonitor, gs_update_monitor, GS, UPDATE_MONITOR, GObject)
 
-GsUpdateMonitor        *gs_update_monitor_new                  (GsApplication  *app);
+GsUpdateMonitor        *gs_update_monitor_new                  (GsApplication  *app,
+                                                        GsPluginLoader *plugin_loader);
 void            gs_update_monitor_autoupdate           (GsUpdateMonitor *monitor);
 void            gs_update_monitor_show_error           (GsUpdateMonitor *monitor,
                                                         GtkWindow      *window);


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