Don't hardcode settings keys

Bug #1110370 reported by Sergey "Shnatsel" Davidoff
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Switchboard Keyboard Plug
Triaged
Low
Unassigned

Bug Description

Currently the Keyboard plug hardcodes the list of supported settings keys, which is not a good idea for compatibility reasons and imposes additional maintenance burden.

What's worse, the plug accesses keys via Granite.Services.Settings, class which relies on the simple Glib.Settings creation method which crashes the whole thing if it tries to access a nonexistent schema or key.

The plug should use http://www.valadoc.org/#!api=gio-2.0/GLib.Settings.list_keys instead to list the available keys, then obtain their descriptions and list those instead of hardcoded values. I haven't yet figured out how to obtain the description for a given key, but it must be possible. Descriptions support localization with gettext, so we will be able to get rid of hardcoded values completely.

Ordering should be done either alphabetically, or by hardcoded order info for known keys (or by any other sane rule you come up with).

Bonus points for using "Settings.full" creation method with error handling to not crash on absence of some schemas (e.g. Gala's schema), as I did in http://bazaar.launchpad.net/~elementary-os/elementaryos/user-specific-alternatives/view/head:/src/user-specific-alternatives.vala#L108

tags: added: technical-debt
Changed in switchboard-plug-keyboard:
status: New → Triaged
Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

bug 1110568 is a prerequisite of this one

Revision history for this message
Julien Spautz (julien-spautz) wrote :

I implemented some error handling as described by Shnatsel (thanks for the code!) so the plug doesn't crash anymore but it'll give you a nice warning and ignore non existent shortcuts.

I'd really like not to hardcode the settings keys, but there are several problems that are hard to solve w/o hardcoding some information:

- Sections like "Windows", "Workspaces"… do not exits in gsettings, and there is no easy way to assign the key to the correct section.
- Ordering alphanumerically is not a bad idea, but certain keys that belong together (like maximize & unmaximize) will be separated.
- Some schemas might contain keys that are not keyboard shortcuts (gala and media-keys, and possibly others)
- We might want to hide certain shortcuts like "switch-to-workspace-up" because they don't make any sense

I think it would be a good idea to put the list of used keys into an xml-file that is easier to maintain while allowing us to control the order and grouping of the shortcuts. If other distros want to use the plug, they can simply provide their own file.

Changed in switchboard-plug-keyboard:
importance: Undecided → Medium
assignee: nobody → Julien Spautz (julien-spautz)
status: Triaged → In Progress
milestone: none → luna-beta2
Changed in switchboard-plug-keyboard:
milestone: luna-beta2 → luna-beta3
Changed in switchboard-plug-keyboard:
status: In Progress → Fix Released
Changed in switchboard-plug-keyboard:
status: Fix Released → In Progress
Changed in switchboard-plug-keyboard:
milestone: luna-beta3 → none
Cody Garver (codygarver)
Changed in switchboard-plug-keyboard:
status: In Progress → Confirmed
assignee: Julien Spautz (julien-spautz) → nobody
Changed in switchboard-plug-keyboard:
milestone: none → loki-beta1
Cody Garver (codygarver)
Changed in switchboard-plug-keyboard:
status: Confirmed → Triaged
Cody Garver (codygarver)
Changed in switchboard-plug-keyboard:
importance: Medium → Low
Changed in switchboard-plug-keyboard:
milestone: loki-beta1 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.