[gnome-initial-setup/wip/pwithnall/misc-fixes: 38/70] language: make sure initial language is always at the top
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wip/pwithnall/misc-fixes: 38/70] language: make sure initial language is always at the top
- Date: Fri, 11 Sep 2020 13:29:13 +0000 (UTC)
commit 811de3b8ae7a121561f727213144574cb9ea2da6
Author: Cosimo Cecchi <cosimo endlessm com>
Date: Thu Jul 25 13:39:08 2019 -0700
language: make sure initial language is always at the top
It could be confusing to have to scroll back to see other languages;
make sure the initial language is always the first in the list.
(Rebase 3.38: This could potentially be dropped in future if we update
cc-language-chooser.c from gnome-control-center; it’s copy/paste code.)
.../pages/language/cc-language-chooser.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gnome-initial-setup/pages/language/cc-language-chooser.c
b/gnome-initial-setup/pages/language/cc-language-chooser.c
index 2e15331c..a15fbfa7 100644
--- a/gnome-initial-setup/pages/language/cc-language-chooser.c
+++ b/gnome-initial-setup/pages/language/cc-language-chooser.c
@@ -51,6 +51,7 @@ struct _CcLanguageChooserPrivate
gboolean showing_extra;
gchar *language;
+ gchar *initial_language;
};
typedef struct _CcLanguageChooserPrivate CcLanguageChooserPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (CcLanguageChooser, cc_language_chooser, GTK_TYPE_BOX);
@@ -414,6 +415,8 @@ sort_languages (GtkListBoxRow *a,
GtkListBoxRow *b,
gpointer data)
{
+ CcLanguageChooser *chooser = data;
+ CcLanguageChooserPrivate *priv = cc_language_chooser_get_instance_private (chooser);
LanguageWidget *la, *lb;
int ret;
@@ -426,6 +429,12 @@ sort_languages (GtkListBoxRow *a,
if (lb == NULL)
return -1;
+ if (g_strcmp0 (la->locale_id, priv->initial_language) == 0)
+ return -1;
+
+ if (g_strcmp0 (lb->locale_id, priv->initial_language) == 0)
+ return 1;
+
if (la->is_extra && !lb->is_extra)
return 1;
@@ -554,6 +563,11 @@ cc_language_chooser_constructed (GObject *object)
update_header_func, chooser, NULL);
gtk_list_box_set_selection_mode (GTK_LIST_BOX (priv->language_list),
GTK_SELECTION_NONE);
+
+ if (priv->language == NULL)
+ priv->language = cc_common_language_get_current_language ();
+ priv->initial_language = g_strdup (priv->language);
+
add_all_languages (chooser);
g_signal_connect (priv->filter_entry, "changed",
@@ -563,9 +577,6 @@ cc_language_chooser_constructed (GObject *object)
g_signal_connect (priv->language_list, "row-activated",
G_CALLBACK (row_activated), chooser);
- if (priv->language == NULL)
- priv->language = cc_common_language_get_current_language ();
-
sync_all_checkmarks (chooser);
show_more (chooser);
}
@@ -577,6 +588,7 @@ cc_language_chooser_finalize (GObject *object)
CcLanguageChooserPrivate *priv = cc_language_chooser_get_instance_private (chooser);
g_free (priv->language);
+ g_free (priv->initial_language);
G_OBJECT_CLASS (cc_language_chooser_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]