From 9eb66fe2746987882a155da826f27e3d8858b7b1 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Fri, 10 Aug 2018 11:32:44 -0500 Subject: [PATCH] Show composite update titles in fu-tool too Commit 171ec0dd95 added this information for 'update' and 'downgrade' operations in fwupdmgr but forgot to add for the 'install' and 'install-blob' operations of fwupdtool --- src/fu-tool.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/fu-tool.c b/src/fu-tool.c index ad0ee0097..8f7b16029 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -34,6 +34,8 @@ typedef struct { FuProgressbar *progressbar; FwupdInstallFlags flags; gboolean show_all_devices; + /* only valid in update and downgrade */ + FwupdDevice *current_device; } FuUtilPrivate; typedef gboolean (*FuUtilPrivateCb) (FuUtilPrivate *util, @@ -222,6 +224,8 @@ fu_util_private_free (FuUtilPrivate *priv) g_object_unref (priv->progressbar); if (priv->context != NULL) g_option_context_free (priv->context); + if (priv->current_device != NULL) + g_object_unref (priv->current_device); g_free (priv); } @@ -476,6 +480,26 @@ fu_util_prompt_for_device (FuUtilPrivate *priv, GError **error) return g_object_ref (dev); } +static void +fu_util_install_device_changed_cb (FwupdClient *client, + FwupdDevice *device, + FuUtilPrivate *priv) +{ + g_autofree gchar *str = NULL; + + /* same as last time, so ignore */ + if (priv->current_device != NULL && + fwupd_device_compare (priv->current_device, device) == 0) + return; + + /* show message in progressbar */ + /* TRANSLATORS: %1 is a device name */ + str = g_strdup_printf (_("Installing %s"), + fwupd_device_get_name (device)); + fu_progressbar_set_title (priv->progressbar, str); + g_set_object (&priv->current_device, device); +} + static gboolean fu_util_install_blob (FuUtilPrivate *priv, gchar **values, GError **error) { @@ -513,6 +537,9 @@ fu_util_install_blob (FuUtilPrivate *priv, gchar **values, GError **error) return FALSE; } + g_signal_connect (priv->engine, "device-changed", + G_CALLBACK (fu_util_install_device_changed_cb), priv); + /* write bare firmware */ return fu_engine_install_blob (priv->engine, device, NULL, /* blob_cab */ @@ -616,6 +643,9 @@ fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error) return FALSE; } + g_signal_connect (priv->engine, "device-changed", + G_CALLBACK (fu_util_install_device_changed_cb), priv); + /* install all the tasks */ if (!fu_engine_install_tasks (priv->engine, install_tasks, blob_cab, priv->flags, error)) return FALSE;