[gnome-software/wip/kalev/download-step: 4/5] plugin loader: Reset related apps progress when a job finishes



commit db9d9a090dda5f43eb799df88a07d2f4a18f867f
Author: Kalev Lember <klember redhat com>
Date:   Tue Oct 23 23:12:14 2018 +0200

    plugin loader: Reset related apps progress when a job finishes

 lib/gs-plugin-loader.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 630d0c6c..0252eb7e 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -208,6 +208,19 @@ gs_plugin_loader_helper_new (GsPluginLoader *plugin_loader, GsPluginJob *plugin_
        return helper;
 }
 
+static void
+reset_app_progress (GsApp *app)
+{
+       GsAppList *related = gs_app_get_related (app);
+
+       gs_app_set_progress (app, 0);
+
+       for (guint i = 0; i < gs_app_list_length (related); i++) {
+               GsApp *app_related = gs_app_list_index (related, i);
+               gs_app_set_progress (app_related, 0);
+       }
+}
+
 static void
 gs_plugin_loader_helper_free (GsPluginLoaderHelper *helper)
 {
@@ -218,9 +231,18 @@ gs_plugin_loader_helper_free (GsPluginLoaderHelper *helper)
        case GS_PLUGIN_ACTION_UPDATE:
        case GS_PLUGIN_ACTION_DOWNLOAD:
                {
-                       GsApp *app = gs_plugin_job_get_app (helper->plugin_job);
+                       GsApp *app;
+                       GsAppList *list;
+
+                       app = gs_plugin_job_get_app (helper->plugin_job);
                        if (app != NULL)
-                               gs_app_set_progress (app, 0);
+                               reset_app_progress (app);
+
+                       list = gs_plugin_job_get_list (helper->plugin_job);
+                       for (guint i = 0; i < gs_app_list_length (list); i++) {
+                               GsApp *app_tmp = gs_app_list_index (list, i);
+                               reset_app_progress (app_tmp);
+                       }
                }
                break;
        default:


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