Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Kubuntu User (http://www.linux-archive.org/kubuntu-user/)
-   -   Add 'English (US)' and a language-related layout in the Welcome spoke (http://www.linux-archive.org/kubuntu-user/662673-add-english-us-language-related-layout-welcome-spoke.html)

Vratislav Podzimek 05-03-2012 01:20 PM

Add 'English (US)' and a language-related layout in the Welcome spoke
 
---
pyanaconda/ui/gui/spokes/keyboard.py | 12 +++++++++++-
pyanaconda/ui/gui/spokes/welcome.py | 25 ++++++++++++++++++++++++-
pyanaconda/xklavier.py | 15 +++++++++++++--
3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index bc2023c..2a634f8 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -131,7 +131,12 @@ class KeyboardSpoke(NormalSpoke):
self._xkl_wrapper = xklavier.XklWrapper.get_instance()

def apply(self):
- self.data.keyboard.keyboard = None
+ # Clear and repopulate self.data with actual values
+ self.data.keyboard.layouts_list = list()
+ itr = self._store.get_iter_first()
+ while itr:
+ self.data.keyboard.layouts_list.append(self._store[itr][0])
+ itr = self._store.iter_next(itr)
# FIXME: Set the keyboard layout here, too.

@property
@@ -163,6 +168,11 @@ class KeyboardSpoke(NormalSpoke):
def refresh(self):
NormalSpoke.refresh(self)

+ # Clear and repopulate addedLayoutStore with values from self.data
+ self._store.clear()
+ for layout in self.data.keyboard.layouts_list:
+ self._addLayout(self._store, layout)
+
self._upButton = self.builder.get_object("upButton")
self._downButton = self.builder.get_object("downButton")
self._removeButton = self.builder.get_object("removeLayoutButton")
diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py
index 0a6953f..8f82745 100644
--- a/pyanaconda/ui/gui/spokes/welcome.py
+++ b/pyanaconda/ui/gui/spokes/welcome.py
@@ -28,6 +28,7 @@ from pyanaconda.ui.gui.utils import enlightbox

from pyanaconda.localization import Language, LOCALE_PREFERENCES
from pyanaconda.product import productName, productVersion
+from pyanaconda import xklavier

__all__ = ["WelcomeLanguageSpoke"]

@@ -38,15 +39,37 @@ class WelcomeLanguageSpoke(StandaloneSpoke):
preForHub = SummaryHub
priority = 0

+ def __init__(self, *args):
+ StandaloneSpoke.__init__(self, *args)
+ self._xklwrapper = xklavier.XklWrapper.get_instance()
+
def apply(self):
selected = self.builder.get_object("languageViewSelection")
(store, itr) = selected.get_selected()

lang = store[itr][2]
self.language.select_translation(lang)
-
self.data.lang.lang = lang

+ if self.data.keyboard.layouts_list:
+ #do not add layouts if there are any specified in the kickstart
+ return
+
+ #get language name without any additional specifications
+ #e.g. 'English (United States)' -> 'English'
+ lang_name = store[itr][1]
+ lang_name = lang_name.split()[0]
+
+ #add one language-related and 'English (US)' layouts by default
+ new_layouts = ['us']
+ language_layout = self._xklwrapper.get_default_language_layout(lang_ name)
+ if language_layout:
+ new_layouts.append(language_layout)
+
+ for layout in new_layouts:
+ if layout not in self.data.keyboard.layouts_list:
+ self.data.keyboard.layouts_list.append(layout)
+
@property
def completed(self):
return self.data.lang.lang and self.data.lang.lang != ""
diff --git a/pyanaconda/xklavier.py b/pyanaconda/xklavier.py
index d0ac444..386dea2 100755
--- a/pyanaconda/xklavier.py
+++ b/pyanaconda/xklavier.py
@@ -105,7 +105,7 @@ class XklWrapper(object):

c_reg.foreach_language_variant(lang_name, self._get_variant, lang_desc)

- self._language_keyboard_variants[(lang_name, lang_desc)] = self._variants_list
+ self._language_keyboard_variants[lang_desc] = self._variants_list

def _get_country_variants(self, c_reg, item, user_data=None):
#helper "global" variable
@@ -119,7 +119,18 @@ class XklWrapper(object):
def get_available_layouts(self):
"""A generator yielding layouts (no need to store them as a bunch)"""

- for (lang_name, lang_desc), variants in sorted(self._language_keyboard_variants.items()):
+ for lang_desc, variants in sorted(self._language_keyboard_variants.items()):
for layout in variants:
yield layout.name

+ def get_default_language_layout(self, language):
+ """Get the default layout for a given language"""
+
+ language_layouts = self._language_keyboard_variants.get(language, None)
+
+ if not language_layouts:
+ return None
+
+ #first layout (should exist for every language)
+ return language_layouts[0].name
+
--
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


All times are GMT. The time now is 05:21 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.