[gnome-initial-setup/wip/pwithnall/misc-fixes: 22/70] input-chooser: consider only language or country layouts non-extra
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wip/pwithnall/misc-fixes: 22/70] input-chooser: consider only language or country layouts non-extra
- Date: Fri, 11 Sep 2020 13:29:12 +0000 (UTC)
commit 4ee68bb5733e1dd0dcd247f03685aa41ea8a4813
Author: Cosimo Cecchi <cosimo endlessm com>
Date: Fri Feb 6 16:16:26 2015 -0800
input-chooser: consider only language or country layouts non-extra
By default, we don't want to just show a random number of these.
(Rebase 3.38: This could potentially be dropped in future if we update
cc-input-chooser.c from gnome-control-center; it’s copy/paste code.)
.../pages/keyboard/cc-input-chooser.c | 54 ++++++----------------
1 file changed, 13 insertions(+), 41 deletions(-)
---
diff --git a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
index d1bc25c7..bcd5407a 100644
--- a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
+++ b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
@@ -324,41 +324,12 @@ no_results_widget_new (void)
return widget;
}
-static void
-choose_non_extras_foreach (GtkWidget *row,
- gpointer user_data)
-{
- GtkWidget *child;
- InputWidget *widget;
- guint *count = user_data;
-
- *count += 1;
- if (*count > MIN_ROWS)
- return;
-
- child = gtk_bin_get_child (GTK_BIN (row));
- widget = get_input_widget (child);
- if (widget == NULL)
- return;
-
- widget->is_extra = FALSE;
-}
-
-static void
-choose_non_extras (CcInputChooser *chooser)
-{
- CcInputChooserPrivate *priv = cc_input_chooser_get_instance_private (chooser);
- guint count = 0;
-
- gtk_container_foreach (GTK_CONTAINER (priv->input_list),
- choose_non_extras_foreach, &count);
-}
-
static void
add_rows_to_list (CcInputChooser *chooser,
GList *list,
const gchar *type,
- const gchar *default_id)
+ const gchar *default_id,
+ gboolean is_extra)
{
CcInputChooserPrivate *priv = cc_input_chooser_get_instance_private (chooser);
const gchar *id;
@@ -378,7 +349,9 @@ add_rows_to_list (CcInputChooser *chooser,
}
g_hash_table_add (priv->inputs, key);
- widget = input_widget_new (chooser, type, id, TRUE);
+ if (g_hash_table_size (priv->inputs) > MIN_ROWS)
+ is_extra = TRUE;
+ widget = input_widget_new (chooser, type, id, is_extra);
gtk_container_add (GTK_CONTAINER (priv->input_list), widget);
}
}
@@ -386,11 +359,12 @@ add_rows_to_list (CcInputChooser *chooser,
static void
add_row_to_list (CcInputChooser *chooser,
const gchar *type,
- const gchar *id)
+ const gchar *id,
+ gboolean is_extra)
{
GList tmp = { 0 };
tmp.data = (gpointer)id;
- add_rows_to_list (chooser, &tmp, type, NULL);
+ add_rows_to_list (chooser, &tmp, type, NULL, is_extra);
}
static void
@@ -403,7 +377,7 @@ get_locale_infos (CcInputChooser *chooser)
GList *list;
if (gnome_get_input_source_from_locale (priv->locale, &type, &id)) {
- add_row_to_list (chooser, type, id);
+ add_row_to_list (chooser, type, id, FALSE);
if (!priv->id) {
priv->id = g_strdup (id);
priv->type = g_strdup (type);
@@ -414,19 +388,17 @@ get_locale_infos (CcInputChooser *chooser)
goto out;
list = gnome_xkb_info_get_layouts_for_language (priv->xkb_info, lang);
- add_rows_to_list (chooser, list, INPUT_SOURCE_TYPE_XKB, id);
+ add_rows_to_list (chooser, list, INPUT_SOURCE_TYPE_XKB, id, FALSE);
g_list_free (list);
if (country != NULL) {
list = gnome_xkb_info_get_layouts_for_country (priv->xkb_info, country);
- add_rows_to_list (chooser, list, INPUT_SOURCE_TYPE_XKB, id);
+ add_rows_to_list (chooser, list, INPUT_SOURCE_TYPE_XKB, id, FALSE);
g_list_free (list);
}
- choose_non_extras (chooser);
-
list = gnome_xkb_info_get_all_layouts (priv->xkb_info);
- add_rows_to_list (chooser, list, INPUT_SOURCE_TYPE_XKB, id);
+ add_rows_to_list (chooser, list, INPUT_SOURCE_TYPE_XKB, id, TRUE);
g_list_free (list);
gtk_widget_show_all (priv->input_list);
@@ -647,7 +619,7 @@ get_ibus_locale_infos (CcInputChooser *chooser)
g_hash_table_iter_init (&iter, priv->ibus_engines);
while (g_hash_table_iter_next (&iter, (gpointer *) &engine_id, (gpointer *) &engine))
- add_row_to_list (chooser, INPUT_SOURCE_TYPE_IBUS, engine_id);
+ add_row_to_list (chooser, INPUT_SOURCE_TYPE_IBUS, engine_id, TRUE);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]