Skip to content

Commit

Permalink
Handle situations where keyboard model is stored as '' or None. Compl…
Browse files Browse the repository at this point in the history
…etes dslo #1341
  • Loading branch information
sayamindu committed Sep 21, 2009
1 parent 5683aaa commit e584e14
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/sugar-session
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def setup_keyboard_cb(gconf_client):

model = gconf_client.get_string(\
'/desktop/sugar/peripherals/keyboard/model')
if model is not None:
if model:
configrec.set_model(model)

options = gconf_client.get_list(\
Expand Down
4 changes: 4 additions & 0 deletions extensions/cpsection/keyboard/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def get_max_layouts(self):

def set_model(self, model):
"""Sets the supplied keyboard model"""
if model is None or not model:
return
self._gconf_client.set_string(_MODEL_KEY, model)
self._configrec.set_model(model)
self._configrec.activate(self._engine)
Expand All @@ -150,6 +152,8 @@ def set_option_group(self, option_group):

def set_layouts(self, layouts):
"""Sets the supplied keyboard layouts (with variants)"""
if layouts is None or not layouts:
return
self._gconf_client.set_list(_LAYOUTS_KEY, gconf.VALUE_STRING, layouts)
layouts_list = []
variants_list = []
Expand Down
9 changes: 5 additions & 4 deletions extensions/cpsection/keyboard/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,11 @@ def _setup_kmodel(self):
kmodel_combo.add_attribute(cell, 'text', 1)

self._kmodel = self._keyboard_manager.get_current_model()
for row in kmodel_store:
if self._kmodel in row[0]:
kmodel_combo.set_active_iter(row.iter)
break
if self._kmodel is not None:
for row in kmodel_store:
if self._kmodel in row[0]:
kmodel_combo.set_active_iter(row.iter)
break

box_kmodel.pack_start(kmodel_combo, expand = False)
self._vbox.pack_start(box_kmodel, expand=False)
Expand Down

0 comments on commit e584e14

Please sign in to comment.