Commit 31fc3c03 authored by Robert Ancell's avatar Robert Ancell

Download changelog information on demand - this stops the UI blocking on startup

parent f0e84096
......@@ -153,6 +153,7 @@ typedef enum {
* @GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI: Require the origin for UI
* @GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME: Require the runtime
* @GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS: Require screenshot information
* @GS_PLUGIN_REFINE_FLAGS_REQUIRE_CHANGELOG: Require the changelog
*
* The refine flags.
**/
......@@ -184,6 +185,7 @@ typedef enum {
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI ((guint64) 1 << 24)
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME ((guint64) 1 << 25)
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS ((guint64) 1 << 26)
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_CHANGELOG ((guint64) 1 << 27)
typedef guint64 GsPluginRefineFlags;
/**
......
......@@ -50,6 +50,7 @@ struct _GsUpdateDialog
GQueue *back_entry_stack;
GCancellable *cancellable;
GsPluginLoader *plugin_loader;
GsApp *app;
GtkWidget *box_header;
GtkWidget *button_back;
GtkWidget *image_icon;
......@@ -96,6 +97,25 @@ back_entry_free (BackEntry *entry)
g_slice_free (BackEntry, entry);
}
static void
refine_cb (GsPluginLoader *plugin_loader, GAsyncResult *res, GsUpdateDialog *dialog)
{
const gchar *update_details;
g_autoptr(GError) error = NULL;
if (!gs_plugin_loader_job_action_finish (plugin_loader, res, &error))
g_warning ("Failed to get changelog information: %s", error->message);
update_details = gs_app_get_update_details (dialog->app);
if (update_details == NULL) {
/* TRANSLATORS: this is where the packager did not write
* a description for the update */
update_details = _("No update description available.");
}
gtk_label_set_label (GTK_LABEL (dialog->label_details), update_details);
}
static void
set_updates_description_ui (GsUpdateDialog *dialog, GsApp *app)
{
......@@ -103,6 +123,8 @@ set_updates_description_ui (GsUpdateDialog *dialog, GsApp *app)
const GdkPixbuf *pixbuf;
const gchar *update_details;
g_set_object (&dialog->app, app);
/* set window title */
kind = gs_app_get_kind (app);
if (kind == AS_APP_KIND_OS_UPDATE) {
......@@ -126,9 +148,20 @@ set_updates_description_ui (GsUpdateDialog *dialog, GsApp *app)
gtk_widget_set_visible (dialog->box_header, kind == AS_APP_KIND_DESKTOP);
update_details = gs_app_get_update_details (app);
if (update_details == NULL) {
/* TRANSLATORS: this is where the packager did not write
* a description for the update */
update_details = _("No update description available.");
g_autoptr(GsPluginJob) plugin_job = NULL;
/* TRANSLATORS: this is displayed while the changelog is being downloaded */
update_details = _("Downloading change information…");
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
"app", app,
"refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_CHANGELOG,
NULL);
gs_plugin_loader_job_process_async (dialog->plugin_loader,
plugin_job,
dialog->cancellable,
(GAsyncReadyCallback) refine_cb,
dialog);
}
gtk_label_set_label (GTK_LABEL (dialog->label_details), update_details);
gtk_label_set_label (GTK_LABEL (dialog->label_name), gs_app_get_name (app));
......@@ -688,6 +721,7 @@ gs_update_dialog_dispose (GObject *object)
}
g_clear_object (&dialog->plugin_loader);
g_clear_object (&dialog->app);
G_OBJECT_CLASS (gs_update_dialog_parent_class)->dispose (object);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment