[gnome-software/wip/ubuntu: 1/5] Download changelog information on demand - this stops the UI blocking on startup
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/ubuntu: 1/5] Download changelog information on demand - this stops the UI blocking on startup
- Date: Fri, 23 Sep 2016 02:21:32 +0000 (UTC)
commit 6e8e5ab940ef1630e9033c4fcd785ac00cdb76f9
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Sep 15 21:19:50 2016 +1200
Download changelog information on demand - this stops the UI blocking on startup
src/gs-plugin.h | 1 +
src/gs-update-dialog.c | 35 +++++++++++++++++++++++++++++++++++
src/plugins/gs-plugin-apt.cc | 2 +-
3 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index d40fcfa..4e3b536 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -113,6 +113,7 @@ typedef enum {
GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE = 1 << 17,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS = 1 << 18,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS = 1 << 19,
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_CHANGELOG = 1 << 20,
GS_PLUGIN_REFINE_FLAGS_LAST
} GsPluginRefineFlags;
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 9f8e449..1c78137 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -43,6 +43,7 @@ struct _GsUpdateDialog
GQueue *back_entry_stack;
GCancellable *cancellable;
GsPluginLoader *plugin_loader;
+ GsApp *app;
GtkWidget *box_header;
GtkWidget *button_back;
GtkWidget *image_icon;
@@ -88,12 +89,34 @@ back_entry_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_app_refine_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)
{
AsAppKind kind;
const GdkPixbuf *pixbuf;
const gchar *update_desc;
+ g_clear_object (&dialog->app);
+ dialog->app = g_object_ref (app);
+
/* set window title */
kind = gs_app_get_kind (app);
if (kind == AS_APP_KIND_OS_UPDATE) {
@@ -126,6 +149,17 @@ set_updates_description_ui (GsUpdateDialog *dialog, GsApp *app)
/* set update header */
gtk_widget_set_visible (dialog->box_header, kind == AS_APP_KIND_DESKTOP);
+ if (update_desc == NULL) {
+ /* TRANSLATORS: this is displayed while the changelog is being downloaded */
+ update_desc = _("Downloading change information…");
+
+ gs_plugin_loader_app_refine_async (dialog->plugin_loader,
+ app,
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_CHANGELOG,
+ dialog->cancellable,
+ (GAsyncReadyCallback) refine_cb,
+ dialog);
+ }
if (update_desc != NULL)
gtk_label_set_markup (GTK_LABEL (dialog->label_details), update_desc);
gtk_label_set_label (GTK_LABEL (dialog->label_name), gs_app_get_name (app));
@@ -464,6 +498,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);
}
diff --git a/src/plugins/gs-plugin-apt.cc b/src/plugins/gs-plugin-apt.cc
index a0c547d..565c094 100644
--- a/src/plugins/gs-plugin-apt.cc
+++ b/src/plugins/gs-plugin-apt.cc
@@ -650,7 +650,7 @@ gs_plugin_refine (GsPlugin *plugin,
gs_app_set_license (app, GS_APP_QUALITY_LOWEST, "@LicenseRef-free=" LICENSE_URL);
}
- if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS) != 0) {
+ if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_CHANGELOG) != 0) {
get_changelog (plugin, app);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]