Blame SOURCES/0002-appchooserdialog-improve-handling-of-INITIAL_LIST_SI.patch

32b021
From 86bd1b0055d32b8356011cde82b51296b9880588 Mon Sep 17 00:00:00 2001
32b021
From: Michael Catanzaro <mcatanzaro@gnome.org>
32b021
Date: Wed, 6 May 2020 10:43:13 -0500
32b021
Subject: [PATCH 2/4] appchooserdialog: improve handling of INITIAL_LIST_SIZE
32b021
32b021
Currently INITIAL_LIST_SIZE is one greater than the initial number of
32b021
desktop files presented, which is actually 3. I guess the "show more"
32b021
button is considered part of the initial list, in which case the size of
32b021
the list is indeed 4, but that's *really* confusing. Let's change this
32b021
so that it matches the number of desktop files presented initially. No
32b021
behavior changes.
32b021
32b021
(cherry picked from commit 15c6cd88b1ba2f913bc00eb46a04b045e77349ad)
32b021
---
32b021
 src/appchooserdialog.c | 9 +++------
32b021
 1 file changed, 3 insertions(+), 6 deletions(-)
32b021
32b021
diff --git a/src/appchooserdialog.c b/src/appchooserdialog.c
32b021
index 0b9f31e..b779f43 100644
32b021
--- a/src/appchooserdialog.c
32b021
+++ b/src/appchooserdialog.c
32b021
@@ -32,7 +32,7 @@
32b021
 #include "appchooserrow.h"
32b021
 
32b021
 #define LOCATION_MAX_LENGTH 40
32b021
-#define INITIAL_LIST_SIZE 4
32b021
+#define INITIAL_LIST_SIZE 3
32b021
 
32b021
 struct _AppChooserDialog {
32b021
   GtkWindow parent;
32b021
@@ -132,7 +132,7 @@ show_more (AppChooserDialog *dialog)
32b021
   gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
32b021
   gtk_widget_hide (dialog->more_row);
32b021
 
32b021
-  for (i = INITIAL_LIST_SIZE - 1; dialog->choices[i]; i++)
32b021
+  for (i = INITIAL_LIST_SIZE; dialog->choices[i]; i++)
32b021
     {
32b021
       g_autofree char *desktop_id = g_strconcat (dialog->choices[i], ".desktop", NULL);
32b021
       g_autoptr(GAppInfo) info = G_APP_INFO (g_desktop_app_info_new (desktop_id));
32b021
@@ -387,7 +387,7 @@ app_chooser_dialog_new (const char **choices,
32b021
   dialog->choices = g_strdupv ((char **)choices);
32b021
   n_choices = g_strv_length ((char **)choices);
32b021
 
32b021
-  ensure_default_is_below (dialog->choices, default_id, MIN (n_choices, INITIAL_LIST_SIZE - 1));
32b021
+  ensure_default_is_below (dialog->choices, default_id, MIN (n_choices, INITIAL_LIST_SIZE));
32b021
 
32b021
   if (n_choices == 0)
32b021
     {
32b021
@@ -416,9 +416,6 @@ app_chooser_dialog_new (const char **choices,
32b021
           g_autoptr(GAppInfo) info = G_APP_INFO (g_desktop_app_info_new (desktop_id));
32b021
           GtkWidget *row;
32b021
 
32b021
-          if (i == INITIAL_LIST_SIZE - 1 && n_choices > INITIAL_LIST_SIZE)
32b021
-            break;
32b021
-
32b021
           row = GTK_WIDGET (app_chooser_row_new (info));
32b021
           gtk_widget_set_visible (row, TRUE);
32b021
           gtk_list_box_insert (GTK_LIST_BOX (dialog->list), row, -1);
32b021
-- 
32b021
2.26.2
32b021