summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsegfault <segfault@riseup.net>2019-12-18 16:00:34 +0100
committersegfault <segfault@riseup.net>2019-12-18 16:00:34 +0100
commit83c2436e1d7ff101f1154323f0b8f3eca9c8c365 (patch)
tree3869875842c8f4fdc85ab9e84eb3c5babc859623
parent2f53c0ec0701781b921286960d4ceb31c6d4488e (diff)
WIP: Show all known formats in the Greeter (refs: #17271)bugfix/17271-all-formats-in-greeter
This adds all locales known to GNOME to the Greeter. This increases the startup time of the Greeter by quite a lot, 15s instead of 8s in my test VM.
-rw-r--r--config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/formats.py18
-rw-r--r--config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/localization_settings.py6
2 files changed, 13 insertions, 11 deletions
diff --git a/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/formats.py b/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/formats.py
index b85d205..3657a1f 100644
--- a/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/formats.py
+++ b/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/formats.py
@@ -11,10 +11,10 @@ from gi.repository import GObject, GnomeDesktop, Gtk
class FormatsSetting(LocalizationSetting):
- def __init__(self, language_codes: [str]):
+ def __init__(self):
super().__init__()
self.value = 'en_US'
- self.locales_per_country = self._make_locales_per_country_dict(language_codes)
+ self.locales_per_country = self._make_locales_per_country_dict()
def get_tree(self) -> Gtk.TreeStore:
treestore = Gtk.TreeStore(GObject.TYPE_STRING, # id
@@ -105,17 +105,21 @@ class FormatsSetting(LocalizationSetting):
return locale_code
@staticmethod
- def _make_locales_per_country_dict(language_codes: [str]) -> {str: [str]}:
+ def _make_locales_per_country_dict() -> {str: [str]}:
"""assemble dictionary of country codes to corresponding locales list
example {FR: [fr_FR, en_FR], ...}"""
res = {}
- for language_code in language_codes:
- country_code = country_from_locale(language_code)
+ locales = GnomeDesktop.get_all_locales()
+ for locale in locales:
+ success, _, country_code, _, _ = GnomeDesktop.parse_locale(locale)
+ if not success or country_code is None:
+ continue
+
if country_code not in res:
res[country_code] = []
- if language_code not in res[country_code]:
- res[country_code].append(language_code)
+ if locale not in res[country_code]:
+ res[country_code].append(locale)
return res
def on_language_changed(self, language_code: str):
diff --git a/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/localization_settings.py b/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/localization_settings.py
index 0c25ba4..4d65a89 100644
--- a/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/localization_settings.py
+++ b/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/settings/localization_settings.py
@@ -22,15 +22,13 @@ class LocalisationSettings(object):
self._user_account = None
self._actusermanager_loadedid = None
- locales = self._get_locales()
-
self._actusermanager = AccountsService.UserManager.get_default()
self._actusermanager_loadedid = self._actusermanager.connect(
"notify::is-loaded", self.__on_usermanager_loaded)
- self.language = LanguageSetting(locales, locale_selected_cb)
+ self.language = LanguageSetting(self._get_locales(), locale_selected_cb)
self.keyboard = KeyboardSetting()
- self.formats = FormatsSetting(locales)
+ self.formats = FormatsSetting()
def __del__(self):
if self._actusermanager_loadedid: