diff --git a/extensions/cpsection/keyboard/model.py b/extensions/cpsection/keyboard/model.py
index bfd7e31..9cd4b99 100644
a
|
b
|
|
16 | 16 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | 17 | # |
18 | 18 | |
19 | | import xklavier |
| 19 | from gi.repository import Xkl |
20 | 20 | from gi.repository import GConf |
21 | 21 | |
22 | 22 | |
… |
… |
_MODEL_KEY = '/desktop/sugar/peripherals/keyboard/model' |
29 | 29 | |
30 | 30 | class KeyboardManager(object): |
31 | 31 | def __init__(self, display): |
32 | | self._engine = xklavier.Engine(display) |
33 | | self._configregistry = xklavier.ConfigRegistry(self._engine) |
| 32 | self._engine = Xkl.Engine.get_instance(display) |
| 33 | self._configregistry = Xkl.ConfigRegistry.get_instance(self._engine) |
34 | 34 | self._configregistry.load(False) |
35 | | self._configrec = xklavier.ConfigRec() |
| 35 | self._configrec = Xkl.ConfigRec() |
36 | 36 | self._configrec.get_from_server(self._engine) |
37 | 37 | |
38 | 38 | self._gconf_client = GConf.Client.get_default() |
39 | 39 | |
40 | 40 | def _populate_one(self, config_registry, item, store): |
41 | | store.append([item.get_description(), item.get_name()]) |
| 41 | store.append([item.description, item.name]) |
42 | 42 | |
43 | 43 | def _populate_two(self, config_registry, item, subitem, store): |
44 | | layout = item.get_name() |
| 44 | layout = item.name |
45 | 45 | if subitem: |
46 | | description = '%s, %s' % (subitem.get_description(), \ |
47 | | item.get_description()) |
48 | | variant = subitem.get_name() |
| 46 | description = '%s, %s' % (subitem.description, \ |
| 47 | item.description) |
| 48 | variant = subitem.name |
49 | 49 | else: |
50 | | description = 'Default layout, %s' % item.get_description() |
| 50 | description = 'Default layout, %s' % item.description |
51 | 51 | variant = '' |
52 | 52 | |
53 | 53 | store.append([description, ('%s(%s)' % (layout, variant))]) |
… |
… |
class KeyboardManager(object): |
85 | 85 | def get_current_model(self): |
86 | 86 | """Return the enabled keyboard model""" |
87 | 87 | model = self._gconf_client.get_string(_MODEL_KEY) |
88 | | if model: |
89 | | return model |
90 | | else: |
91 | | model = self._configrec.get_model() |
| 88 | if not model: |
| 89 | model = self._configrec.model |
92 | 90 | self.set_model(model) |
93 | | return model |
| 91 | return model |
94 | 92 | |
95 | 93 | def get_current_layouts(self): |
96 | 94 | """Return the enabled keyboard layouts with variants""" |
… |
… |
class KeyboardManager(object): |
105 | 103 | if layouts: |
106 | 104 | return layouts |
107 | 105 | |
108 | | layouts = self._configrec.get_layouts() |
109 | | variants = self._configrec.get_variants() |
| 106 | layouts = self._configrec.layouts |
| 107 | variants = self._configrec.variants |
110 | 108 | |
111 | 109 | layout_list = [] |
112 | 110 | i = 0 |
… |
… |
class KeyboardManager(object): |
125 | 123 | """Return the enabled option for switching keyboard group""" |
126 | 124 | options = [] |
127 | 125 | # FIXME, gconf_client_get_list not introspectable #681433 |
128 | | options_from_gconf = gconf_client.get(\ |
129 | | '/desktop/sugar/peripherals/keyboard/options') |
| 126 | options_from_gconf = gconf_client.get(_LAYOUTS_KEY) |
130 | 127 | if options_from_gconf: |
131 | 128 | for gval in options_from_gconf.get_list(): |
132 | 129 | option = gval.get_string() |
133 | 130 | options.append(option) |
134 | 131 | |
135 | 132 | if not options: |
136 | | options = self._configrec.get_options() |
| 133 | options = self._configrec.options |
137 | 134 | self.set_option_group(options) |
138 | 135 | |
139 | 136 | for option in options: |
… |
… |
class KeyboardManager(object): |
163 | 160 | options = option_group |
164 | 161 | else: |
165 | 162 | options = [option_group] |
166 | | self._gconf_client.set_list(_OPTIONS_KEY, GConf.ValueType.STRING, options) |
| 163 | # FIXME, gconf_client_set_list not introspectable #681433 |
| 164 | # self._gconf_client.set_list(_OPTIONS_KEY, GConf.ValueType.STRING, |
| 165 | # options) |
167 | 166 | self._configrec.set_options(options) |
168 | 167 | self._configrec.activate(self._engine) |
169 | 168 | |
… |
… |
class KeyboardManager(object): |
171 | 170 | """Sets the supplied keyboard layouts (with variants)""" |
172 | 171 | if layouts is None or not layouts: |
173 | 172 | return |
174 | | self._gconf_client.set_list(_LAYOUTS_KEY, GConf.ValueType.STRING, layouts) |
| 173 | # FIXME, gconf_client_set_list not introspectable #681433 |
| 174 | # self._gconf_client.set_list(_LAYOUTS_KEY, GConf.ValueType.STRING, |
| 175 | # layouts) |
175 | 176 | layouts_list = [] |
176 | 177 | variants_list = [] |
177 | 178 | for layout in layouts: |
diff --git a/extensions/cpsection/keyboard/view.py b/extensions/cpsection/keyboard/view.py
index 085ec10..74632dd 100644
a
|
b
|
|
16 | 16 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | 17 | |
18 | 18 | from gi.repository import Gtk |
| 19 | from gi.repository import GdkX11 |
19 | 20 | from gi.repository import GObject |
20 | 21 | from gi.repository import Pango |
21 | 22 | import logging |
… |
… |
class Keyboard(SectionView): |
159 | 160 | |
160 | 161 | self._layout_table = Gtk.Table(rows=4, columns=2, homogeneous=False) |
161 | 162 | |
162 | | self._keyboard_manager = model.KeyboardManager(self.get_display()) |
| 163 | display = GdkX11.x11_get_default_xdisplay() |
| 164 | self._keyboard_manager = model.KeyboardManager(display) |
163 | 165 | self._layout_combo_list = [] |
164 | 166 | self._layout_addremovebox_list = [] |
165 | 167 | |
… |
… |
class Keyboard(SectionView): |
338 | 340 | layout_combo.select_layout(self._klayouts[i]) |
339 | 341 | |
340 | 342 | self._vbox.pack_start(self._layout_table, False, True, 0) |
341 | | self._layout_table.set_size_request(self._vbox.size_request()[0], -1) |
| 343 | self._layout_table.set_size_request(self._vbox.size_request().width, -1) |
342 | 344 | self._layout_table.show() |
343 | 345 | self._update_klayouts() |
344 | 346 | |