gnome-software/0003-rpm-ostree-Hook-up-the-progress-info-required-for-th.patch
2020-05-12 20:28:27 +02:00

107 lines
3.9 KiB
Diff

From 73c6118c15cdcbc33828dc2b470f2e652f4a64ac Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Tue, 12 May 2020 16:53:20 +0200
Subject: [PATCH 3/3] rpm-ostree: Hook up the progress info required for the
loading page
---
plugins/rpm-ostree/gs-plugin-rpm-ostree.c | 34 ++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
index e3824df1..96531759 100644
--- a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
+++ b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
@@ -255,8 +255,9 @@ transaction_progress_new (void)
static void
transaction_progress_free (TransactionProgress *self)
{
- g_main_loop_unref (self->loop);
+ g_clear_object (&self->plugin);
g_clear_error (&self->error);
+ g_main_loop_unref (self->loop);
g_clear_object (&self->app);
g_slice_free (TransactionProgress, self);
}
@@ -281,11 +282,30 @@ on_transaction_progress (GDBusProxy *proxy,
if (g_strcmp0 (signal_name, "PercentProgress") == 0) {
const gchar *message = NULL;
guint32 percentage;
+
g_variant_get_child (parameters, 0, "&s", &message);
g_variant_get_child (parameters, 1, "u", &percentage);
g_debug ("PercentProgress: %u, %s\n", percentage, message);
+
if (tp->app != NULL)
gs_app_set_progress (tp->app, (guint) percentage);
+
+ if (tp->app != NULL && tp->plugin != NULL) {
+ GsPluginStatus plugin_status;
+
+ switch (gs_app_get_state (tp->app)) {
+ case AS_APP_STATE_INSTALLING:
+ plugin_status = GS_PLUGIN_STATUS_INSTALLING;
+ break;
+ case AS_APP_STATE_REMOVING:
+ plugin_status = GS_PLUGIN_STATUS_REMOVING;
+ break;
+ default:
+ plugin_status = GS_PLUGIN_STATUS_DOWNLOADING;
+ break;
+ }
+ gs_plugin_status_update (tp->plugin, tp->app, plugin_status);
+ }
} else if (g_strcmp0 (signal_name, "Finished") == 0) {
if (tp->error == NULL) {
g_autofree gchar *error_message = NULL;
@@ -603,6 +623,7 @@ ensure_rpmostree_dnf_context (GsPlugin *plugin, GCancellable *cancellable, GErro
{
GsPluginData *priv = gs_plugin_get_data (plugin);
g_autofree gchar *transaction_address = NULL;
+ g_autoptr(GsApp) progress_app = gs_app_new (gs_plugin_get_name (plugin));
g_autoptr(DnfContext) context = dnf_context_new ();
g_autoptr(DnfState) state = dnf_state_new ();
g_autoptr(GVariant) options = NULL;
@@ -611,6 +632,9 @@ ensure_rpmostree_dnf_context (GsPlugin *plugin, GCancellable *cancellable, GErro
if (priv->dnf_context != NULL)
return TRUE;
+ tp->app = g_object_ref (progress_app);
+ tp->plugin = g_object_ref (plugin);
+
dnf_context_set_repo_dir (context, "/etc/yum.repos.d");
dnf_context_set_cache_dir (context, RPMOSTREE_CORE_CACHEDIR RPMOSTREE_DIR_CACHE_REPOMD);
dnf_context_set_solv_dir (context, RPMOSTREE_CORE_CACHEDIR RPMOSTREE_DIR_CACHE_SOLV);
@@ -669,9 +693,13 @@ gs_plugin_refresh (GsPlugin *plugin,
{
g_autofree gchar *transaction_address = NULL;
+ g_autoptr(GsApp) progress_app = gs_app_new (gs_plugin_get_name (plugin));
g_autoptr(GVariant) options = NULL;
g_autoptr(TransactionProgress) tp = transaction_progress_new ();
+ tp->app = g_object_ref (progress_app);
+ tp->plugin = g_object_ref (plugin);
+
options = make_rpmostree_options_variant (FALSE, /* reboot */
FALSE, /* allow-downgrade */
FALSE, /* cache-only */
@@ -703,10 +731,14 @@ gs_plugin_refresh (GsPlugin *plugin,
{
g_autofree gchar *transaction_address = NULL;
+ g_autoptr(GsApp) progress_app = gs_app_new (gs_plugin_get_name (plugin));
g_autoptr(GVariant) options = NULL;
GVariantDict dict;
g_autoptr(TransactionProgress) tp = transaction_progress_new ();
+ tp->app = g_object_ref (progress_app);
+ tp->plugin = g_object_ref (plugin);
+
g_variant_dict_init (&dict, NULL);
g_variant_dict_insert (&dict, "mode", "s", "check");
options = g_variant_ref_sink (g_variant_dict_end (&dict));
--
2.26.2