[gnome-software/wip/mcrha/show-metainfo-enh] show-metainfo: Set the application also to the featured carousel on the Overview page
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/mcrha/show-metainfo-enh] show-metainfo: Set the application also to the featured carousel on the Overview page
- Date: Fri, 21 Jan 2022 12:30:01 +0000 (UTC)
commit 5f731eb0fcf79640a05c6401ec25671582d6fb9f
Author: Milan Crha <mcrha redhat com>
Date: Fri Jan 21 13:27:24 2022 +0100
show-metainfo: Set the application also to the featured carousel on the Overview page
By using the --show-metainfo a user could see how it looks in the details
page, but it was not easy to see it in the featured carousel, which this
change tries to address. The app is shown in the Details page and when
the back button is pressed it's also visible in the carousel.
src/gs-details-page.c | 23 +++++++++++++++++++++++
src/gs-overview-page.c | 23 +++++++++++++++++++++++
src/gs-overview-page.h | 4 ++--
src/gs-shell.c | 12 ++++++++++++
src/gs-shell.ui | 1 +
5 files changed, 61 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index fffb8d2c4..887822d41 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -148,6 +148,11 @@ struct _GsDetailsPage
G_DEFINE_TYPE (GsDetailsPage, gs_details_page, GS_TYPE_PAGE)
+enum {
+ SIGNAL_METAINFO_LOADED,
+ SIGNAL_LAST
+};
+
typedef enum {
PROP_ODRS_PROVIDER = 1,
PROP_IS_NARROW,
@@ -156,6 +161,7 @@ typedef enum {
} GsDetailsPageProperty;
static GParamSpec *obj_props[PROP_IS_NARROW + 1] = { NULL, };
+static guint signals [SIGNAL_LAST] = { 0 };
static GsDetailsPageState
gs_details_page_get_state (GsDetailsPage *self)
@@ -2200,6 +2206,21 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
g_object_class_override_property (object_class, PROP_TITLE, "title");
+ /**
+ * GsDetailsPage:metainfo-loaded:
+ * @app: a #GsApp
+ *
+ * Emitted after a custom metainfo @app is loaded in the page, but before
+ * it's fully shown.
+ *
+ * Since: 42
+ */
+ signals[SIGNAL_METAINFO_LOADED] =
+ g_signal_new ("metainfo-loaded",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GS_TYPE_APP);
+
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-details-page.ui");
gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, application_details_icon);
@@ -2439,6 +2460,8 @@ gs_details_page_metainfo_ready_cb (GObject *source_object,
g_set_object (&self->app_local_file, app);
_set_app (self, app);
gs_details_page_load_stage2 (self, FALSE);
+
+ g_signal_emit (self, signals[SIGNAL_METAINFO_LOADED], 0, app);
}
static void
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index 5362ee910..e257c608e 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -39,6 +39,7 @@ struct _GsOverviewPage
gboolean loading_recent;
gboolean loading_categories;
gboolean empty;
+ gboolean featured_overwritten;
GHashTable *category_hash; /* id : GsCategory */
GsFedoraThirdParty *third_party;
gboolean third_party_needs_question;
@@ -255,6 +256,11 @@ gs_overview_page_get_featured_cb (GObject *source_object,
if (g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
goto out;
+ if (self->featured_overwritten) {
+ g_debug ("Skipping set of featured apps, because being overwritten");
+ goto out;
+ }
+
if (list == NULL || gs_app_list_length (list) == 0) {
g_warning ("failed to get featured apps: %s",
(error != NULL) ? error->message : "no apps to show");
@@ -541,6 +547,7 @@ static void
gs_overview_page_reload (GsPage *page)
{
GsOverviewPage *self = GS_OVERVIEW_PAGE (page);
+ self->featured_overwritten = FALSE;
gs_overview_page_invalidate (self);
gs_overview_page_load (self);
}
@@ -780,3 +787,19 @@ gs_overview_page_new (void)
{
return GS_OVERVIEW_PAGE (g_object_new (GS_TYPE_OVERVIEW_PAGE, NULL));
}
+
+void
+gs_overview_page_set_featured (GsOverviewPage *self,
+ GsApp *app)
+{
+ g_autoptr(GsAppList) list = NULL;
+
+ g_return_if_fail (GS_IS_OVERVIEW_PAGE (self));
+ g_return_if_fail (GS_IS_APP (app));
+
+ self->featured_overwritten = TRUE;
+
+ list = gs_app_list_new ();
+ gs_app_list_add (list, app);
+ gs_featured_carousel_set_apps (GS_FEATURED_CAROUSEL (self->featured_carousel), list);
+}
diff --git a/src/gs-overview-page.h b/src/gs-overview-page.h
index 49df243f8..55cad9c82 100644
--- a/src/gs-overview-page.h
+++ b/src/gs-overview-page.h
@@ -18,7 +18,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GsOverviewPage, gs_overview_page, GS, OVERVIEW_PAGE, GsPage)
GsOverviewPage *gs_overview_page_new (void);
-void gs_overview_page_set_category (GsOverviewPage *self,
- const gchar *category);
+void gs_overview_page_set_featured (GsOverviewPage *self,
+ GsApp *app);
G_END_DECLS
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 939434f3d..89b611364 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -859,6 +859,17 @@ gs_shell_reload_cb (GsPluginLoader *plugin_loader, GsShell *shell)
}
}
+static void
+gs_shell_details_page_metainfo_loaded_cb (GtkWidget *details_page,
+ GsApp *app,
+ GsShell *self)
+{
+ g_return_if_fail (GS_IS_APP (app));
+ g_return_if_fail (GS_IS_SHELL (self));
+
+ gs_overview_page_set_featured (GS_OVERVIEW_PAGE (self->pages[GS_SHELL_MODE_OVERVIEW]), app);
+}
+
static gboolean
change_mode_idle (gpointer user_data)
{
@@ -2660,6 +2671,7 @@ gs_shell_class_init (GsShellClass *klass)
gtk_widget_class_bind_template_callback (widget_class, stack_notify_visible_child_cb);
gtk_widget_class_bind_template_callback (widget_class, initial_refresh_done);
gtk_widget_class_bind_template_callback (widget_class, overlay_get_child_position_cb);
+ gtk_widget_class_bind_template_callback (widget_class, gs_shell_details_page_metainfo_loaded_cb);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_q, GDK_CONTROL_MASK, "window.close", NULL);
}
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index 8bced6857..935028275 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -464,6 +464,7 @@
<child>
<object class="GsDetailsPage" id="details_page">
<property name="is-narrow" bind-source="GsShell" bind-property="is-narrow"
bind-flags="sync-create"/>
+ <signal name="metainfo-loaded"
handler="gs_shell_details_page_metainfo_loaded_cb"/>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]