From d220a5673b11e17bc89e77653f66cc48bcf68728 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 3 Mar 2023 11:33:03 +0000 Subject: keyboard: Don't ensure CcInputChooser type twice Calling g_type_ensure (CC_TYPE_INPUT_CHOOSER) in constructed() is too late, because the template has already been instantiated, which will fail if the type is not available. Happily gis_keyboard_page_init() also calls g_type_ensure (CC_TYPE_INPUT_CHOOSER) just before instantiating the template. --- gnome-initial-setup/pages/keyboard/gis-keyboard-page.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c index 8899527..71effda 100644 --- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c +++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c @@ -465,8 +465,6 @@ gis_keyboard_page_constructed (GObject *object) GisKeyboardPage *self = GIS_KEYBOARD_PAGE (object); GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self); - g_type_ensure (CC_TYPE_INPUT_CHOOSER); - G_OBJECT_CLASS (gis_keyboard_page_parent_class)->constructed (object); g_signal_connect (priv->input_chooser, "confirm", -- cgit v1.2.1 From 151688f670e8c6f5ecc8a7bac686ddcc815cdf11 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 3 Mar 2023 13:17:18 +0000 Subject: keyboard: Resort & refilter list when picking shortlist Each row of the keyboard layout/input method list has a flag for whether it is an "extra" layout, hidden by default, or not. All rows are added with the is_extra flag set to TRUE; later, they can be marked as non-extra in a few ways: - The currently-selected layout is (indirectly) marked as non-extra - Selecting a layout marks it as non-extra - 5 semi-arbitrary layouts are marked as non-extra To make the list work, the GtkListBox has sort and filter functions set: - The sort function sorts extra layouts after non-extra layouts - The filter function hides extra layouts, unless the user is searching or has clicked the vertical ellipsis to see all layouts But previously, the sort and filter of the list were not always invalidated when one or more layouts' is_extra flags were changed. As a result, the list always showed no layouts by default, just the vertical ellipsis to see all layouts. Fix this by invalidating both sort and filter when a layout is marked non-extra. Fixes #165 --- .../pages/keyboard/cc-input-chooser.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c index b5dd397..80f36f2 100644 --- a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c +++ b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c @@ -255,6 +255,7 @@ sync_all_checkmarks (CcInputChooser *chooser) { CcInputChooserPrivate *priv; GtkWidget *row; + gboolean invalidate = FALSE; priv = cc_input_chooser_get_instance_private (chooser); row = gtk_widget_get_first_child (priv->input_list); @@ -267,7 +268,7 @@ sync_all_checkmarks (CcInputChooser *chooser) widget = get_input_widget (child); if (widget == NULL) - return; + break; if (priv->id == NULL || priv->type == NULL) should_be_visible = FALSE; @@ -276,13 +277,20 @@ sync_all_checkmarks (CcInputChooser *chooser) g_strcmp0 (widget->type, priv->type) == 0; gtk_widget_set_opacity (widget->checkmark, should_be_visible ? 1.0 : 0.0); - if (widget->is_extra && should_be_visible) + if (widget->is_extra && should_be_visible) { + g_debug ("Marking selected layout %s (%s:%s) as non-extra", + widget->name, widget->type, widget->id); widget->is_extra = FALSE; + invalidate = TRUE; + } row = gtk_widget_get_next_sibling (row); } - gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->input_list)); + if (invalidate) { + gtk_list_box_invalidate_sort (GTK_LIST_BOX (priv->input_list)); + gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->input_list)); + } } static GtkWidget * @@ -340,10 +348,18 @@ choose_non_extras (CcInputChooser *chooser) if (widget == NULL) break; + g_debug ("Picking %s (%s:%s) as non-extra", + widget->name, widget->type, widget->id); widget->is_extra = FALSE; row = gtk_widget_get_next_sibling (row); } + + /* Changing is_extra above affects the ordering and the visibility + * of the newly non-extra rows. + */ + gtk_list_box_invalidate_sort (GTK_LIST_BOX (priv->input_list)); + gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->input_list)); } static void -- cgit v1.2.1