Opened 11 years ago

Closed 11 years ago

Last modified 7 years ago

#407 closed defect (fixed)

Set keyboard layout from control panel

Reported by: alsroot Owned by: erikos
Priority: Unspecified by Maintainer Milestone:
Component: Sugar Version: Git as of bugdate
Severity: Unspecified Keywords: r+
Cc: mtd, sdz, erikos, sayamindu Distribution/OS:
Bug Status: New

Description

should it be implemented in sugar level?
(in that case, guess it could be complicated due to diversity of sugarized distros) or its task only for SoaS.

Attachments (3)

controlpanel_keyboard_screenshot3.png (35.4 KB) - added by mtd 11 years ago.
keyboard_cpextension.png (22.4 KB) - added by sayamindu 11 years ago.
Mockup of libxklavier based capplet
add_python_xklavier_to_jhbuild.patch (779 bytes) - added by sayamindu 11 years ago.
Patch for jhbuild

Download all attachments as: .zip

Change History (28)

comment:1 Changed 11 years ago by wadeb

I'd like to see this in a Sugar control panel. I do this all the time on XO and it would be handy to avoid the command line.

There is also the issue that if you switch to a keyboard layout that you don't know well, it would be nice to have a mouse driven way to "recover" your old layout, i.e. a control panel.

It would be ideal if you could set up multiple languages to be swapped using the XO language key (or equivalent on a standard keyboard).

comment:2 Changed 11 years ago by mtd

  • Bug Status changed from Unconfimed to New
  • Cc mtd sdz erikos added
  • Component changed from sugar to design
  • Owner changed from marcopg to eben
  • Status changed from new to assigned

#473 seems to be a dupe of this.

And yes, it's complicated because the gnome system-config-keyboard only lets you set the keytable, but OLPC has supported different koyboard layout variants; see http://wiki.laptop.org/go/Localization/Changing_Keyboard_Layout and http://wiki.laptop.org/go/Mfg-data .

I'm going to collapse #473 into this one with #473's status, since it seems to be there's a bit of a UI question. I'll mock up something trivial in the meantime.

comment:3 Changed 11 years ago by mtd

  • Version changed from 0.83.x to Git as of bugdate

skierpage reported the OLPC-specific problem upstream: https://bugzilla.redhat.com/show_bug.cgi?id=490311

I'll attach a screenshot of a mockup for which I'd love improvement suggestions. It's very simple.

erikos sent me the correct icon for use in the next screenshot.

Changed 11 years ago by mtd

comment:4 Changed 11 years ago by mk8

  • Type changed from enhancement to defect

Moreover, it can be very useful improve some shortcuts for non-XO keyboards to replace the special XO keys. For example F11, to show the frame instead of Ctrl-Shift-F.

Eben, are you still active on this bug? Would you like me to take over?

comment:5 Changed 11 years ago by eben

I have a few thoughts here. First, I wonder if the keyboard layout choice would be work in a popup menu instead of the huge scrolling list. If we keep the list, perhaps it can be sized to fill only the left 1/3 of the window, to allow room for other keyboard controls.

Other items which I think could/should be included in the keyboard control panel are key repeat rate & delay, and the suggested keyboard shortcut mapping system.

Going forward, I'm more than happy to provide design feedback, or even make some mockups once there is basic consensus on what options to provide, but if you want to take the bug and make sure it's active that's fine with me.

comment:6 Changed 11 years ago by sayamindu

  • Cc sayamindu added

Changed 11 years ago by sayamindu

Mockup of libxklavier based capplet

comment:7 Changed 11 years ago by sayamindu

I have attached a mockup of something I am working on (based on Python bindings for libxklavier, which is the library used by GNOME to modify keyboard settings). Things we should provide as a bare minimal:

  • Keyboard model selection
  • Keyboard layout selection (including multiple layouts)

Apart from this, from Eben, we have:

  • Repeat rate & delay

I'm not sure if shortcuts should go here, or should be in a separate section altogether.

Another option which should ideally be provided is the key-trigger to cycle between multiple layouts. While this is not required for XO laptops, other keyboards need this. There is a pre-defined set of key-triggers to do this:

  • Right Alt (while pressed)
  • Left Alt (while pressed)
  • Left Win (while pressed)
  • Right Win (while pressed)
  • Any Win key (while pressed)
  • CapsLock (while pressed), Alt+CapsLock does the original capslock action
  • Right Ctrl (while pressed)
  • Right Alt
  • Left Alt
  • CapsLock
  • Shift+CapsLock
  • CapsLock (to first layout), Shift+CapsLock (to last layout)
  • Left Win (to first layout), Right Win/Menu (to last layout)
  • Alt+CapsLock
  • Both Shift keys together
  • Both Alt keys together
  • Both Ctrl keys together
  • Ctrl+Shift
  • Left Ctrl+Left Shift
  • Alt+Ctrl
  • Alt+Shift
  • Alt+Space
  • Menu
  • Left Win
  • Right Win
  • Left Shift
  • Right Shift
  • Left Ctrl
  • Right Ctrl

Maybe this can go in as a combobox as well ?

comment:8 Changed 11 years ago by erikos

Personally I am not a big fan of comboboxes. They are quite hard to navigate - especially when they contain a lot of entries. I think treeviews are easier to handle. For searching, someone suggested to me the other day to just do it like we did in the Journal - display only the matching entries.

comment:9 Changed 11 years ago by sayamindu

  • Component changed from design to sugar
  • Keywords r? added
  • Owner changed from eben to erikos

I have completed work on this feature, and it seems to be working fine in my initial tests. Merge request at http://git.sugarlabs.org/projects/sugar/repos/mainline/merge_requests/79

The original feature proposal: http://wiki.sugarlabs.org/go/Features/Keyboard_CP_Section

comment:10 Changed 11 years ago by erikos

  • Keywords r! added; r? removed

Just some nitpicks that can be done, while I read through all the code: As Tomeu likes to point out: Don't use abbreviations.

Example:

def get_current_layouts(self):
	"""Return the enabled keyboard layouts with variants"""
        layouts = self._gconf_client.get_list(_LAYOUTS_KEY, 'string')
        if layouts:
            return layouts

        layouts = self._configrec.get_layouts()
        variants = self._configrec.get_variants()

        ret = []
        i = 0
        for layout in layouts:
            if len(variants) <= i or variants[i] == '':
                ret.append('%s(%s)' % (layout, ''))
            else:
                ret.append('%s(%s)' % (layout, variants[i]))
            i += 1

        return ret

or

desc = 'Default layout, %s' % item.get_description()

Run again pylint over it, and best the pep8 as well.

[erikos@laptop sugar]$ pylint ../sugar-xkb/extensions/cpsection/keyboard/view.py 
************* Module view
W0622:106:LayoutCombo.get_layout: Redefining built-in 'iter'
W0704:225:Keyboard.__kmodel_timeout_cb: Except doesn't do anything
W0702:226:Keyboard.__kmodel_timeout_cb: No exception type(s) specified
W0704:290:Keyboard.__group_switch_timeout_cb: Except doesn't do anything
W0702:291:Keyboard.__group_switch_timeout_cb: No exception type(s) specified
W0704:397:Keyboard.__layout_timeout_cb: Except doesn't do anything
W0702:398:Keyboard.__layout_timeout_cb: No exception type(s) specified

comment:11 Changed 11 years ago by sayamindu

Thanks for the feedback - I'll go through it. Meanwhile I'm attaching the patch to build python-xklavier via jhbuild.

Changed 11 years ago by sayamindu

Patch for jhbuild

comment:12 Changed 11 years ago by erikos

Model:

class XKB(gobject.GObject)

I think we can derive from 'object' here. Not sure xkb is the best naming for the class, maybe we can use another name to avoid name clashes.

self._configreg = xklavier.ConfigRegistry(self._engine)

Maybe you just call it self._registry if self._config_registry is too long.

def _populate_one(self, c_reg, item, store)

Abbreviation

def get_options_grp(self)

Abbreviation
(and some more in the code)

General: We do not have a command line option (get, set in the model) anymore for the keyboard. Though, as this is problematic when one have messed up his keyboard, I think this is a good thing.

comment:13 Changed 11 years ago by erikos

View:
I am a bit skeptical with the design (if I may raise this point). I find combo boxes hard to use - at least the one in gtk. We do not get a search functionality by default, and scrolling takes a lot of time etc. Same is true for the language CP section, btw. Another possibility would be to use a treeview, like we do for the journal listview, and limit the number of entries by a search field for example. One can use the type ahead search functionality here as well.

comment:14 Changed 11 years ago by erikos

Sugar-session:

def setup_keyboard_cb(gconf_client):
    logging.debug('STARTUP: setup_keyboard_cb')
    try:
      ...
except:
        logging.debug('ERROR in setup_keyboard_cb: %s' % str(sys.exc_info()))
        pass

I am not a big fan of catching all the errors. Can we split the code and catch the real errors?

for layout in layouts:
	    layouts_list.append(layout.split('(')[0])
	    variants_list.append(layout.split('(')[1][:-1])

Is the split save? Maybe you have to catch possible errors here.

model = gconf_client.get_string(\
            '/desktop/sugar/peripherals/keyboard/model')

Returned None here. I think you have to handle the 'None' or case here, too. I think you can select the default value for the gconf option accordingly.

comment:15 Changed 11 years ago by sayamindu

  • Keywords r? added; r! removed

I fixed most of the issues that you have outlined in the review:

Unfortunately, in

def setup_keyboard_cb(gconf_client):
    logging.debug('STARTUP: setup_keyboard_cb')
    try:
      ...
except:
        logging.debug('ERROR in setup_keyboard_cb: %s' % str(sys.exc_info()))
        pass

I have no way of figuring out what error is going to happen (we are trying to interact with GConf, the core X protocol, a layer of Python and a layer of C+GObject and a layer of Xlib on top of the protocol - all in this section of the code).

comment:16 Changed 11 years ago by sayamindu

  • Resolution set to fixed
  • Status changed from assigned to closed

We have python-xklavier packaged in Fedora (Rawhide as of now), thanks to the effort of Kushal. Closing the ticket for now.

comment:17 Changed 11 years ago by tomeu

  • Keywords r+ added; r? removed

Great job!

comment:18 follow-up: Changed 11 years ago by RafaelOrtiz

as a side note is this going to be on soas anytime soon ?-

comment:19 in reply to: ↑ 18 ; follow-up: Changed 11 years ago by tomeu

Replying to RafaelOrtiz:

as a side note is this going to be on soas anytime soon ?-

This will be part of 0.86 (is already in 0.85) and the next version of SoaS will include that, so yes.

comment:20 in reply to: ↑ 19 ; follow-up: Changed 11 years ago by garycmartin

Replying to tomeu:

Replying to RafaelOrtiz:

as a side note is this going to be on soas anytime soon ?-

This will be part of 0.86 (is already in 0.85) and the next version of SoaS will include that, so yes.

FWIW: the control panel has not been working at all here on sugar-jhbuild for a number of days now. I just assumed we were between working builds. Here's the traceback when I select the "My Settings" option:

Traceback (most recent call last):
  File "/home/garycmartin/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/view/buddymenu.py", line 113, in __controlpanel_activate_cb
    panel = ControlPanel()
  File "/home/garycmartin/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/controlpanel/gui.py", line 81, in __init__
    self._setup_main()
  File "/home/garycmartin/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/controlpanel/gui.py", line 122, in _setup_main
    self._setup_options()
  File "/home/garycmartin/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/controlpanel/gui.py", line 140, in _setup_options
    options.remove('keyboard')
ValueError: list.remove(x): x not in list

comment:21 in reply to: ↑ 20 ; follow-up: Changed 11 years ago by sayamindu

Replying to garycmartin:

Replying to tomeu:

Replying to RafaelOrtiz:

as a side note is this going to be on soas anytime soon ?-

This will be part of 0.86 (is already in 0.85) and the next version of SoaS will include that, so yes.

FWIW: the control panel has not been working at all here on sugar-jhbuild for a number of days now. I just assumed we were between working builds. Here's the traceback when I select the "My Settings" option:

Traceback (most recent call last):
  File "/home/garycmartin/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/view/buddymenu.py", line 113, in __controlpanel_activate_cb
    panel = ControlPanel()
  File "/home/garycmartin/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/controlpanel/gui.py", line 81, in __init__
    self._setup_main()
  File "/home/garycmartin/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/controlpanel/gui.py", line 122, in _setup_main
    self._setup_options()
  File "/home/garycmartin/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/controlpanel/gui.py", line 140, in _setup_options
    options.remove('keyboard')
ValueError: list.remove(x): x not in list

Sounds like a stale sugar-jhbuild issue to me ? Could you verify if the keyboard stuff has been installed (or try to run autogen.sh again).

comment:22 in reply to: ↑ 21 Changed 11 years ago by garycmartin

Replying to sayamindu:

Sounds like a stale sugar-jhbuild issue to me ? Could you verify if the keyboard stuff has been installed (or try to run autogen.sh again).

Thanks Sayamindu. controlpanel actually started working with a rebuild yesterday (previous rebuilds had made no difference and I'd been building pretty much every day for a ~week). Chatting on IRC after, Tomeu did mention something about autogen. All good now, I can test CP modules again :-)

comment:23 Changed 10 years ago by sascha_silbe

  • Component changed from sugar to SoaS
  • Distribution/OS changed from SoaS to Unspecified

Bulk change distribution=SoaS -> component=SoaS

comment:24 Changed 9 years ago by sascha_silbe

  • Component changed from Sugar on a Stick (SoaS) to sugar
  • Distribution/OS Unspecified deleted

comment:25 Changed 7 years ago by dnarvaez

  • Milestone 0.86 deleted

Milestone 0.86 deleted

Note: See TracTickets for help on using tickets.