Ticket #3926: temp.patch

File temp.patch, 5.8 KB (added by manuq, 12 years ago)

Partial patch, I still need to find a fix for the gconf_client_set_list #681433

  • extensions/cpsection/keyboard/model.py

    diff --git a/extensions/cpsection/keyboard/model.py b/extensions/cpsection/keyboard/model.py
    index bfd7e31..9cd4b99 100644
    a b  
    1616# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1717#
    1818
    19 import xklavier
     19from gi.repository import Xkl
    2020from gi.repository import GConf
    2121
    2222
    _MODEL_KEY = '/desktop/sugar/peripherals/keyboard/model' 
    2929
    3030class KeyboardManager(object):
    3131    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)
    3434        self._configregistry.load(False)
    35         self._configrec = xklavier.ConfigRec()
     35        self._configrec = Xkl.ConfigRec()
    3636        self._configrec.get_from_server(self._engine)
    3737
    3838        self._gconf_client = GConf.Client.get_default()
    3939
    4040    def _populate_one(self, config_registry, item, store):
    41         store.append([item.get_description(), item.get_name()])
     41        store.append([item.description, item.name])
    4242
    4343    def _populate_two(self, config_registry, item, subitem, store):
    44         layout = item.get_name()
     44        layout = item.name
    4545        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
    4949        else:
    50             description = 'Default layout, %s' % item.get_description()
     50            description = 'Default layout, %s' % item.description
    5151            variant = ''
    5252
    5353        store.append([description, ('%s(%s)' % (layout, variant))])
    class KeyboardManager(object): 
    8585    def get_current_model(self):
    8686        """Return the enabled keyboard model"""
    8787        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
    9290            self.set_model(model)
    93             return model
     91        return model
    9492
    9593    def get_current_layouts(self):
    9694        """Return the enabled keyboard layouts with variants"""
    class KeyboardManager(object): 
    105103            if layouts:
    106104                return layouts
    107105
    108         layouts = self._configrec.get_layouts()
    109         variants = self._configrec.get_variants()
     106        layouts = self._configrec.layouts
     107        variants = self._configrec.variants
    110108
    111109        layout_list = []
    112110        i = 0
    class KeyboardManager(object): 
    125123        """Return the enabled option for switching keyboard group"""
    126124        options = []
    127125        # 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)
    130127        if options_from_gconf:
    131128            for gval in options_from_gconf.get_list():
    132129                option = gval.get_string()
    133130                options.append(option)
    134131
    135132        if not options:
    136             options = self._configrec.get_options()
     133            options = self._configrec.options
    137134            self.set_option_group(options)
    138135
    139136        for option in options:
    class KeyboardManager(object): 
    163160            options = option_group
    164161        else:
    165162            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)
    167166        self._configrec.set_options(options)
    168167        self._configrec.activate(self._engine)
    169168
    class KeyboardManager(object): 
    171170        """Sets the supplied keyboard layouts (with variants)"""
    172171        if layouts is None or not layouts:
    173172            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)
    175176        layouts_list = []
    176177        variants_list = []
    177178        for layout in layouts:
  • extensions/cpsection/keyboard/view.py

    diff --git a/extensions/cpsection/keyboard/view.py b/extensions/cpsection/keyboard/view.py
    index 085ec10..74632dd 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)
    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(self._vbox.size_request().width, -1)
    342344        self._layout_table.show()
    343345        self._update_klayouts()
    344346