[gnome-software/wip/mcrha/m1024-to-gnome-41] gs-overview-page: Refresh the application after third-party repositories enable/disable



commit 296848dbc8dced4c6d189186304bd3e096560e01
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 5 19:45:10 2021 +0200

    gs-overview-page: Refresh the application after third-party repositories enable/disable
    
    The enable/disable can cause other applications being found, thus call
    the refresh, to update the repositories information.

 src/gs-application.h   |  2 +-
 src/gs-overview-page.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-application.h b/src/gs-application.h
index 40bad4d4c..04461bd3b 100644
--- a/src/gs-application.h
+++ b/src/gs-application.h
@@ -23,4 +23,4 @@ gboolean       gs_application_has_active_window       (GsApplication *application);
 void            gs_application_emit_install_resources_done
                                                        (GsApplication *application,
                                                         const gchar *ident,
-                                                        const GError *op_error);
\ No newline at end of file
+                                                        const GError *op_error);
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index 9ba33fb2b..65ee413e2 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -563,11 +563,30 @@ gs_overview_page_switch_to (GsPage *page)
        gs_overview_page_load (self);
 }
 
+static void
+gs_overview_page_refresh_cb (GsPluginLoader *plugin_loader,
+                            GAsyncResult *result,
+                            GsOverviewPage *self)
+{
+       gboolean success;
+       g_autoptr(GError) error = NULL;
+
+       success = gs_plugin_loader_job_action_finish (plugin_loader, result, &error);
+       if (!success &&
+           !g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
+               g_warning ("failed to refresh: %s", error->message);
+
+       if (success)
+               g_signal_emit_by_name (self->plugin_loader, "reload", 0, NULL);
+}
+
 static void
 third_party_response_cb (GtkInfoBar *info_bar,
                          gint response_id,
                          GsOverviewPage *self)
 {
+       g_autoptr(GsPluginJob) plugin_job = NULL;
+
        if (response_id == GTK_RESPONSE_YES)
                fedora_third_party_enable (self);
        else
@@ -575,6 +594,15 @@ third_party_response_cb (GtkInfoBar *info_bar,
 
        self->third_party_needs_question = FALSE;
        refresh_third_party_repo (self);
+
+       plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFRESH,
+                                        "interactive", FALSE,
+                                        "age", (guint64) 1,
+                                        NULL);
+       gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
+                                           self->cancellable,
+                                           (GAsyncReadyCallback) gs_overview_page_refresh_cb,
+                                           self);
 }
 
 static gboolean


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