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