[gnome-software/1364-implement-other-apps-by-author-section-in-app-details-page: 35/38] gs-details-page: Better limit shown other apps




commit 1d42ccd2f36ecf485976abee25d3ee8ca064f41c
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 15 18:21:59 2022 +0100

    gs-details-page: Better limit shown other apps
    
    Ask for more apps than will be shown, because some of them can be dropped
    due to being same as the shown application.

 src/gs-details-page.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 9265f6cda..e4e4fd2d0 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -40,6 +40,10 @@
 /* the number of reviews to show before clicking the 'More Reviews' button */
 #define SHOW_NR_REVIEWS_INITIAL                4
 
+/* How many other developer apps can be shown; should be divisible by 3 and 2,
+   to catch full width and smaller width without bottom gap */
+#define N_OTHER_APPS 18
+
 #define GS_DETAILS_PAGE_REFINE_FLAGS   GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS | \
                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_CATEGORIES | \
                                        GS_PLUGIN_REFINE_FLAGS_REQUIRE_CONTENT_RATING | \
@@ -969,7 +973,7 @@ gs_details_page_search_other_apps_cb (GObject *source_object,
        GsDetailsPage *self = GS_DETAILS_PAGE (user_data);
        g_autoptr(GsAppList) list = NULL;
        g_autoptr(GError) local_error = NULL;
-       gboolean any_added = FALSE;
+       guint n_added = 0;
 
        list = gs_plugin_loader_job_process_finish (GS_PLUGIN_LOADER (source_object), result, &local_error);
        if (list == NULL) {
@@ -992,11 +996,13 @@ gs_details_page_search_other_apps_cb (GObject *source_object,
                        g_signal_connect (tile, "clicked", G_CALLBACK (gs_details_page_app_tile_clicked), 
self);
                        gtk_flow_box_insert (GTK_FLOW_BOX (self->box_other_apps), tile, -1);
 
-                       any_added = TRUE;
+                       n_added++;
+                       if (n_added == N_OTHER_APPS)
+                               break;
                }
        }
 
-       gtk_widget_set_visible (self->box_other_apps, any_added);
+       gtk_widget_set_visible (self->box_other_apps, n_added > 0);
 }
 
 static void
@@ -1099,7 +1105,7 @@ gs_details_page_refresh_all (GsDetailsPage *self)
 
                        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH_OTHER_APPS,
                                                         "search", self->last_developer_name,
-                                                        "max-results", 18,
+                                                        "max-results", N_OTHER_APPS * 3, /* Ask for more, 
some can be skipped */
                                                         "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
                                                                         
GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
                                                                         
GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY |


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]