Skip to content
This repository has been archived by the owner on May 13, 2018. It is now read-only.

Commit

Permalink
Fix LP :1156201
Browse files Browse the repository at this point in the history
  • Loading branch information
phanimahesh authored and jokerdino committed Mar 17, 2013
1 parent 6555a17 commit 3c4cb39
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions UnityTweakTool/elements/cbox.py
Expand Up @@ -46,21 +46,30 @@ def __init__(self,controlObj):
self.type = controlObj['type']
self.map = controlObj['map']
self.invmap = dict([ (v,k) for (k,v) in self.map.items() ])
assert gsettings.is_valid(
schema=self.schema,
path=self.path,
key=self.key
)
self.disabled = False
try:
gsettings.is_valid(
schema=self.schema,
path=self.path,
key=self.key
)
except AssertionError as e:
self.disabled = True
logger.debug('Initialised a ComboBox with id {self.id} to control key {self.key} of type {self.type} in schema {self.schema} with path {self.path}'.format(self=self))

def register(self,handler):
''' register handler on a handler object '''
if self.disabled:
return
handler['on_%s_changed'%self.id]=self.handler
logger.debug('Handler for {self.id} registered'.format(self=self))

def refresh(self):
''' Refresh UI reading from backend '''
logger.debug('Refreshing UI display for {self.id}'.format(self=self))
if self.disabled:
self.ui.set_active(False)
return
self.ui.set_active(
self.map[
gsettings.get(
Expand All @@ -85,5 +94,7 @@ def handler(self,*args,**kwargs):

def reset(self):
''' Reset the controlled key '''
if self.disabled:
return
gsettings.reset(schema=self.schema,path=self.path,key=self.key)
logger.debug('Key {self.key} in schema {self.schema} and path {self.path} reset.'.format(self=self))

0 comments on commit 3c4cb39

Please sign in to comment.