[gnome-software/1265-launch-button-takes-a-while-to-appear-after-installing-an-app: 3/3] gs-details-page: Refresh the 'Launch' button on app info changes
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1265-launch-button-takes-a-while-to-appear-after-installing-an-app: 3/3] gs-details-page: Refresh the 'Launch' button on app info changes
- Date: Fri, 23 Jul 2021 12:23:46 +0000 (UTC)
commit 6ae29b44ba2221345cbcabe3598428d3af717478
Author: Milan Crha <mcrha redhat com>
Date: Thu Jul 22 13:01:41 2021 +0200
gs-details-page: Refresh the 'Launch' button on app info changes
It can happen that after an application installation the GDesktopAppInfo
cache is not updated before the details page is refreshed, which causes
the 'Launch' button not being shown, even the application can be launched.
Let the button visibility be updated on any app info changes, which
is the time when also the GDesktopAppInfo cache is updated.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1265
src/gs-details-page.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 0060dd734..702a40ac2 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -78,6 +78,7 @@ struct _GsDetailsPage
GSettings *settings;
GtkSizeGroup *size_group_origin_popover;
GsOdrsProvider *odrs_provider; /* (nullable) (owned), NULL if reviews are disabled */
+ GAppInfoMonitor *app_info_monitor; /* (owned) */
GtkWidget *application_details_icon;
GtkWidget *application_details_summary;
@@ -776,6 +777,10 @@ gs_details_page_can_launch_app (GsDetailsPage *self)
gs_app_has_quirk (self->app, GS_APP_QUIRK_PARENTAL_NOT_LAUNCHABLE))
return FALSE;
+ /* don't show the launch button if the app doesn't have a desktop ID */
+ if (gs_app_get_id (self->app) == NULL)
+ return FALSE;
+
desktop_id = gs_app_get_launchable (self->app, AS_LAUNCHABLE_KIND_DESKTOP_ID);
if (!desktop_id)
desktop_id = gs_app_get_id (self->app);
@@ -875,11 +880,6 @@ gs_details_page_refresh_buttons (GsDetailsPage *self)
/* TRANSLATORS: A label for a button to execute the selected application. */
_("_Launch"));
- /* don't show the launch and shortcut buttons if the app doesn't have a desktop ID */
- if (gs_app_get_id (self->app) == NULL) {
- gtk_widget_set_visible (self->button_details_launch, FALSE);
- }
-
/* remove button */
if (gs_app_has_quirk (self->app, GS_APP_QUIRK_COMPULSORY) ||
gs_app_get_kind (self->app) == AS_COMPONENT_KIND_FIRMWARE) {
@@ -1780,6 +1780,20 @@ settings_changed_cb (GsDetailsPage *self, const gchar *key, gpointer data)
}
}
+static void
+gs_details_page_app_info_changed_cb (GAppInfoMonitor *monitor,
+ gpointer user_data)
+{
+ GsDetailsPage *self = user_data;
+
+ g_return_if_fail (GS_IS_DETAILS_PAGE (self));
+
+ if (!self->app || !gs_page_is_active (GS_PAGE (self)))
+ return;
+
+ gtk_widget_set_visible (self->button_details_launch, gs_details_page_can_launch_app (self));
+}
+
/* this is being called from GsShell */
void
gs_details_page_set_app (GsDetailsPage *self, GsApp *app)
@@ -2210,6 +2224,7 @@ gs_details_page_dispose (GObject *object)
g_clear_object (&self->session);
g_clear_object (&self->size_group_origin_popover);
g_clear_object (&self->odrs_provider);
+ g_clear_object (&self->app_info_monitor);
G_OBJECT_CLASS (gs_details_page_parent_class)->dispose (object);
}
@@ -2338,6 +2353,9 @@ gs_details_page_init (GsDetailsPage *self)
G_CALLBACK (settings_changed_cb),
self);
self->size_group_origin_popover = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ self->app_info_monitor = g_app_info_monitor_get ();
+ g_signal_connect_object (self->app_info_monitor, "changed",
+ G_CALLBACK (gs_details_page_app_info_changed_cb), self, 0);
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->list_box_addons),
list_sort_func,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]