This patch adds checkbutton as was suggested in the bugzilla discussion. The result can be seen at [1]. I know the text is quite small, but I didn't find ay way how to set attributes of the checkbutton's label. We could either leave it as it is or use checkbutton with no label, add new label next to it and wire click events on the label to checkbutton toggling.
[1] http://vpodzime.fedorapeople.org/welcome_spoke_new_checkbutton.png
Vratislav Podzimek (1): Add checkbox for setting language default layout (#866887)
pyanaconda/ui/gui/spokes/welcome.glade | 17 ++++++++++++++ pyanaconda/ui/gui/spokes/welcome.py | 41 +++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 13 deletions(-)
Some users expect that when they select language Anaconda automatically sets their keyboard layout to the one that is default for the selected language. But this would not be a good implicit behaviour because we would be changing layout in background without letting user now. Adding checkbox for the behaviour some users want seems to be a best solution.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- pyanaconda/ui/gui/spokes/welcome.glade | 17 ++++++++++++++ pyanaconda/ui/gui/spokes/welcome.py | 41 +++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/welcome.glade b/pyanaconda/ui/gui/spokes/welcome.glade index b9761b9..fa439bc 100644 --- a/pyanaconda/ui/gui/spokes/welcome.glade +++ b/pyanaconda/ui/gui/spokes/welcome.glade @@ -376,6 +376,23 @@ <property name="position">2</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="setKeyboardCheckButton"> + <property name="label" translatable="yes">Set _keyboard to default layout for selected language.</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">3</property> + </packing> + </child> </object> </child> </object> diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py index 7362a18..0621646 100644 --- a/pyanaconda/ui/gui/spokes/welcome.py +++ b/pyanaconda/ui/gui/spokes/welcome.py @@ -66,6 +66,17 @@ class LanguageMixIn(object): if lang_timezone: self.data.timezone.timezone = lang_timezone
+ lang_country = self.language.preferred_locale.territory + self._set_keyboard_defaults(store[itr][1], lang_country) + + def _set_keyboard_defaults(self, lang_name, country): + """ + Set default keyboard settings (layouts, layout switching). + + @param lang_name: name of the selected language (e.g. "Czech") + + """ + #remove all X layouts that are not valid X layouts (unsupported) #from the ksdata #XXX: could go somewhere else, but we need X running and we have @@ -80,20 +91,24 @@ class LanguageMixIn(object):
#get language name without any additional specifications #e.g. 'English (United States)' -> 'English' - lang_name = store[itr][1] lang_name = lang_name.split()[0] - country = self.language.preferred_locale.territory - - #add one language-related and 'English (US)' layouts by default - new_layouts = ['us'] - default_layout = self._xklwrapper.get_default_lang_country_layout(lang_name, country) - if default_layout and default_layout not in new_layouts: - new_layouts.append(default_layout) - - for layout in new_layouts: - self.data.keyboard.x_layouts.append(layout) - if flags.can_touch_runtime_system("add runtime X layout"): - self._xklwrapper.add_layout(layout) + + default_layout = self._xklwrapper.get_default_lang_country_layout(lang_name, + country) + if default_layout: + new_layouts = [default_layout] + else: + new_layouts = ["us"] + + checkbutton = self.builder.get_object("setKeyboardCheckButton") + if not checkbutton.get_active() and "us" not in new_layouts: + #user doesn't want only the language-default layout, prepend + #'English (US)' layout + new_layouts.insert(0, "us") + + self.data.keyboard.x_layouts = new_layouts + if flags.can_touch_runtime_system("replace runtime X layouts"): + self._xklwrapper.replace_layouts(new_layouts)
if len(new_layouts) >= 2 and not self.data.keyboard.switch_options: #initialize layout switching if needed
This patch adds checkbutton as was suggested in the bugzilla discussion. The result can be seen at [1]. I know the text is quite small, but I didn't find ay way how to set attributes of the checkbutton's label. We could either leave it as it is or use checkbutton with no label, add new label next to it and wire click events on the label to checkbutton toggling.
[1] http://vpodzime.fedorapeople.org/welcome_spoke_new_checkbutton.png
After reading the bug, I guess I'm okay with this (especially given mizmo's input), though I am concerned about the precedent of solving things with checkboxes. We need to continue to fight this so that we only do it where we absolutely need to.
I'm not really concerned about the size of the text. If you really need to, you can do it in python by reaching down into the button:
button.get_children()[0]
That should be the label, and then you can call set_attributes() or whatever to deal with it.
- Chris
On Mon, 2012-12-10 at 15:45 -0500, Chris Lumens wrote:
This patch adds checkbutton as was suggested in the bugzilla discussion. The result can be seen at [1]. I know the text is quite small, but I didn't find ay way how to set attributes of the checkbutton's label. We could either leave it as it is or use checkbutton with no label, add new label next to it and wire click events on the label to checkbutton toggling.
[1] http://vpodzime.fedorapeople.org/welcome_spoke_new_checkbutton.png
After reading the bug, I guess I'm okay with this (especially given mizmo's input), though I am concerned about the precedent of solving things with checkboxes. We need to continue to fight this so that we only do it where we absolutely need to.
Yeah, I agree with that, but for now I don't think we have a better solution. As we have already discussed some basic keyboard configuration UI elements should probably appear on the welcome spoke so this should be a temporary solution only for F18.
I'm not really concerned about the size of the text. If you really need to, you can do it in python by reaching down into the button:
button.get_children()[0]
That should be the label, and then you can call set_attributes() or whatever to deal with it.
Thanks for the tip. Since that checkbox is not anything of high importance I believe we can avoid adding such piece of code and leave the text size as it is. Thus I'm pushing the patch as it is.
anaconda-patches@lists.fedorahosted.org