[gnome-software/154-gs-details-page-lack-of-information-when-flatpak-app-data-is-being-loaded] gs-details-page: Lack of information when flatpak app data is being loaded
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/154-gs-details-page-lack-of-information-when-flatpak-app-data-is-being-loaded] gs-details-page: Lack of information when flatpak app data is being loaded
- Date: Thu, 22 Oct 2020 16:26:34 +0000 (UTC)
commit 0336d4f875dbd51b3d2ce62ab811b2a7f86f6d66
Author: Milan Crha <mcrha redhat com>
Date: Thu Oct 22 18:25:03 2020 +0200
gs-details-page: Lack of information when flatpak app data is being loaded
Show information from the plugin loader when populating the details page,
thus there's a feedback about what the plugin does when it takes long time.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/154
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/529
src/gs-details-page.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/gs-details-page.ui | 21 +++++++++++++++++
2 files changed, 82 insertions(+)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 210724ce..88ad13d0 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -126,6 +126,9 @@ struct _GsDetailsPage
GtkWidget *scrolledwindow_details;
GtkWidget *spinner_details;
GtkWidget *spinner_remove;
+ GtkWidget *loading_progressbar;
+ guint loading_progress_pulse_id;
+ GtkWidget *loading_label;
GtkWidget *stack_details;
GtkWidget *grid_details_kudo;
GtkWidget *image_details_kudo_docs;
@@ -157,6 +160,43 @@ struct _GsDetailsPage
G_DEFINE_TYPE (GsDetailsPage, gs_details_page, GS_TYPE_PAGE)
+static gboolean
+gs_details_page_loading_pulse_cb (gpointer user_data)
+{
+ GsDetailsPage *self = GS_DETAILS_PAGE (user_data);
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR (self->loading_progressbar));
+ return TRUE;
+}
+
+static void
+gs_details_page_status_changed_cb (GsPluginLoader *plugin_loader,
+ GsApp *app,
+ GsPluginStatus status,
+ GsDetailsPage *self)
+{
+ const gchar *str = NULL;
+
+ if (status == GS_PLUGIN_STATUS_DOWNLOADING && app)
+ str = gs_app_get_summary_missing (app);
+
+ if (str)
+ gtk_label_set_label (GTK_LABEL (self->loading_label), str);
+
+ if (app) {
+ if (self->loading_progress_pulse_id != 0) {
+ g_source_remove (self->loading_progress_pulse_id);
+ self->loading_progress_pulse_id = 0;
+ }
+
+ if (gs_app_get_progress (app) == GS_APP_PROGRESS_UNKNOWN) {
+ self->loading_progress_pulse_id = g_timeout_add (50,
gs_details_page_loading_pulse_cb, self);
+ } else {
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->loading_progressbar),
+ (gdouble) gs_app_get_progress (app) / 100.0f);
+ }
+ }
+}
+
static void
gs_details_page_set_state (GsDetailsPage *self,
GsDetailsPageState state)
@@ -165,12 +205,24 @@ gs_details_page_set_state (GsDetailsPage *self,
switch (state) {
case GS_DETAILS_PAGE_STATE_LOADING:
gs_start_spinner (GTK_SPINNER (self->spinner_details));
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->loading_progressbar), 0.0);
+ if (!self->loading_progress_pulse_id)
+ self->loading_progress_pulse_id = g_timeout_add (50,
gs_details_page_loading_pulse_cb, self);
+ gtk_label_set_label (GTK_LABEL (self->loading_label), _("Loading…"));
gtk_widget_show (self->spinner_details);
+ g_signal_connect (self->plugin_loader, "status-changed",
+ G_CALLBACK (gs_details_page_status_changed_cb),
+ self);
break;
case GS_DETAILS_PAGE_STATE_READY:
case GS_DETAILS_PAGE_STATE_FAILED:
gs_stop_spinner (GTK_SPINNER (self->spinner_details));
gtk_widget_hide (self->spinner_details);
+ g_signal_handlers_disconnect_by_func (self->plugin_loader, G_CALLBACK
(gs_details_page_status_changed_cb), self);
+ if (self->loading_progress_pulse_id != 0) {
+ g_source_remove (self->loading_progress_pulse_id);
+ self->loading_progress_pulse_id = 0;
+ }
break;
default:
g_assert_not_reached ();
@@ -2726,6 +2778,13 @@ gs_details_page_dispose (GObject *object)
g_signal_handlers_disconnect_by_func (self->app, gs_details_page_progress_changed_cb, self);
g_clear_object (&self->app);
}
+ if (self->plugin_loader) {
+ g_signal_handlers_disconnect_by_func (self->plugin_loader, G_CALLBACK
(gs_details_page_status_changed_cb), self);
+ }
+ if (self->loading_progress_pulse_id != 0) {
+ g_source_remove (self->loading_progress_pulse_id);
+ self->loading_progress_pulse_id = 0;
+ }
g_clear_object (&self->app_local_file);
g_clear_object (&self->builder);
g_clear_object (&self->plugin_loader);
@@ -2822,6 +2881,8 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, scrolledwindow_details);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, spinner_details);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, spinner_remove);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, loading_progressbar);
+ gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, loading_label);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, stack_details);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, grid_details_kudo);
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, image_details_kudo_docs);
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index f86674fe..be22e3a0 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -33,6 +33,27 @@
<property name="vexpand">True</property>
</object>
</child>
+ <child>
+ <object class="GtkProgressBar" id="loading_progressbar">
+ <property name="visible">True</property>
+ <property name="width_request">480</property>
+ <property name="halign">center</property>
+ <property name="fraction">0.0</property>
+ <property name="margin_top">8</property>
+ <style>
+ <class name="upgrade-progressbar"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="loading_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Loading…</property>
+ <attributes>
+ <attribute name="scale" value="1.4"/>
+ </attributes>
+ </object>
+ </child>
</object>
<packing>
<property name="name">spinner</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]