Ticket #4492: 0001-finish-conversion-to-introspection.patch

File 0001-finish-conversion-to-introspection.patch, 5.2 KB (added by walter, 10 years ago)

mostly works... just won't save to gconf

  • extensions/cpsection/keyboard/model.py

    From 85d60d384e9afd7876dc8513a5ed94a7cf37f8dc Mon Sep 17 00:00:00 2001
    From: Walter Bender <walter.bender@gmail.com>
    Date: Sat, 27 Apr 2013 11:25:59 -0400
    Subject: [PATCH] finish conversion to introspection
    Organization: Sugar Labs Foundation
    
    ---
     extensions/cpsection/keyboard/model.py | 30 ++++++++++++++++--------------
     extensions/cpsection/keyboard/view.py  |  7 +++++--
     2 files changed, 21 insertions(+), 16 deletions(-)
    
    diff --git a/extensions/cpsection/keyboard/model.py b/extensions/cpsection/keyboard/model.py
    index bfd7e31..47b2a71 100644
    a b  
    1616# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1717#
    1818
    19 import xklavier
     19# import xklavier
     20from gi.repository import Xkl
    2021from gi.repository import GConf
    2122
    2223
    _MODEL_KEY = '/desktop/sugar/peripherals/keyboard/model' 
    2930
    3031class KeyboardManager(object):
    3132    def __init__(self, display):
    32         self._engine = xklavier.Engine(display)
    33         self._configregistry = xklavier.ConfigRegistry(self._engine)
     33        self._engine = Xkl.Engine.get_instance(display)
     34        self._configregistry = Xkl.ConfigRegistry.get_instance(self._engine)
    3435        self._configregistry.load(False)
    35         self._configrec = xklavier.ConfigRec()
     36        self._configrec = Xkl.ConfigRec()
    3637        self._configrec.get_from_server(self._engine)
    3738
    3839        self._gconf_client = GConf.Client.get_default()
    3940
    4041    def _populate_one(self, config_registry, item, store):
    41         store.append([item.get_description(), item.get_name()])
     42        store.append([item.description, item.name])
    4243
    4344    def _populate_two(self, config_registry, item, subitem, store):
    44         layout = item.get_name()
     45        layout = item.name
    4546        if subitem:
    46             description = '%s, %s' % (subitem.get_description(), \
    47                                             item.get_description())
    48             variant = subitem.get_name()
     47            description = '%s, %s' % (subitem.description, item.description)
     48            variant = subitem.name
    4949        else:
    50             description = 'Default layout, %s' % item.get_description()
     50            description = 'Default layout, %s' % item.description
    5151            variant = ''
    52 
    5352        store.append([description, ('%s(%s)' % (layout, variant))])
    5453
    5554    def get_models(self):
    class KeyboardManager(object): 
    125124        """Return the enabled option for switching keyboard group"""
    126125        options = []
    127126        # FIXME, gconf_client_get_list not introspectable #681433
    128         options_from_gconf = gconf_client.get(\
     127        options_from_gconf = self._gconf_client.get(
    129128            '/desktop/sugar/peripherals/keyboard/options')
    130129        if options_from_gconf:
    131130            for gval in options_from_gconf.get_list():
    class KeyboardManager(object): 
    163162            options = option_group
    164163        else:
    165164            options = [option_group]
    166         self._gconf_client.set_list(_OPTIONS_KEY, GConf.ValueType.STRING, options)
     165        # FIXME, gconf_client_set_list not introspectable #681433
     166        # self._gconf_client.set_list(_OPTIONS_KEY, GConf.ValueType.STRING, options)
    167167        self._configrec.set_options(options)
    168168        self._configrec.activate(self._engine)
    169169
    class KeyboardManager(object): 
    171171        """Sets the supplied keyboard layouts (with variants)"""
    172172        if layouts is None or not layouts:
    173173            return
    174         self._gconf_client.set_list(_LAYOUTS_KEY, GConf.ValueType.STRING, layouts)
     174        # FIXME, gconf_client_set_list not introspectable #681433
     175        # self._gconf_client.set_list(_LAYOUTS_KEY, GConf.ValueType.STRING, layouts)
    175176        layouts_list = []
    176177        variants_list = []
    177178        for layout in layouts:
    class KeyboardManager(object): 
    181182        self._configrec.set_layouts(layouts_list)
    182183        self._configrec.set_variants(variants_list)
    183184        self._configrec.activate(self._engine)
     185
  • extensions/cpsection/keyboard/view.py

    diff --git a/extensions/cpsection/keyboard/view.py b/extensions/cpsection/keyboard/view.py
    index 085ec10..0df3ee7 100644
    a b  
    1616# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
    1717
    1818from gi.repository import Gtk
     19from gi.repository import GdkX11
    1920from gi.repository import GObject
    2021from gi.repository import Pango
    2122import logging
    class Keyboard(SectionView): 
    159160
    160161        self._layout_table = Gtk.Table(rows=4, columns=2, homogeneous=False)
    161162
    162         self._keyboard_manager = model.KeyboardManager(self.get_display())
     163        display = GdkX11.x11_get_default_xdisplay()
     164        self._keyboard_manager = model.KeyboardManager(display) # self.get_display())
    163165        self._layout_combo_list = []
    164166        self._layout_addremovebox_list = []
    165167
    class Keyboard(SectionView): 
    338340                layout_combo.select_layout(self._klayouts[i])
    339341
    340342        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(
     344            self._vbox.get_size_request()[0], -1)
    342345        self._layout_table.show()
    343346        self._update_klayouts()
    344347