diff --git a/UnityTweakTool/elements/colorchooser.py b/UnityTweakTool/elements/colorchooser.py index 694cf3a..7cab856 100644 --- a/UnityTweakTool/elements/colorchooser.py +++ b/UnityTweakTool/elements/colorchooser.py @@ -45,23 +45,31 @@ def __init__(self,controlObj): self.path = controlObj['path'] self.key = controlObj['key'] self.type = 'string' - self.usealpha = controlObj['usealpha'] - assert gsettings.is_valid( - schema=self.schema, - path=self.path, - key=self.key - ) + self.disabled = False + try: + assert gsettings.is_valid( + schema=self.schema, + path=self.path, + key=self.key + ) + except AssertionError as e: + self.disabled = True self.color=Gdk.RGBA() logger.debug('Initialised a colorchooser 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_color_set'%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_sensitive(False) + return color = gsettings.get( schema=self.schema, path =self.path, @@ -77,15 +85,17 @@ def refresh(self): colorspec='rgba(%s,%s,%s,%f)'%components valid = Gdk.RGBA.parse(self.color,colorspec) if valid: - self.ui.set_color(self.color) + self.ui.set_rgba(self.color) def get_color(self): self.ui.get_rgba(self.color) - return '#{:02x}{:02x}{:02x}{:02x}'.format(*[round(x*255) for x in [c.red, c.green, c.blue, c.alpha]]) + return '#{:02x}{:02x}{:02x}{:02x}'.format(*[round(x*255) for x in [self.color.red, self.color.green, self.color.blue, self.color.alpha]]) logger.debug('Getting color for {self.id}'.format(self=self)) def handler(self,*args,**kwargs): ''' handle toggle signals ''' + if self.disabled: + return gsettings.set( schema=self.schema, path=self.path, diff --git a/UnityTweakTool/section/sphagetti/unity.py b/UnityTweakTool/section/sphagetti/unity.py index 4f6af80..75ff0cc 100644 --- a/UnityTweakTool/section/sphagetti/unity.py +++ b/UnityTweakTool/section/sphagetti/unity.py @@ -211,10 +211,6 @@ def on_radio_launcher_color_cus_toggled(self, widget, udata = None): self.ui.unsensitize(dependants) gsettings.unityshell.set_string('background-color', colorhash[:-2]+'00') - def on_color_launcher_color_cus_color_set(self, widget, udata = None): - color = self.ui['color_launcher_color_cus'].get_color() - colorhash = gsettings.color_to_hash(color) - gsettings.unityshell.set_string('background-color', colorhash) def on_sw_show_desktop_active_notify(self, widget, udata = None): fav = gsettings.launcher.get_strv('favorites') diff --git a/UnityTweakTool/section/unity.py b/UnityTweakTool/section/unity.py index 23e7d9e..4a110ea 100644 --- a/UnityTweakTool/section/unity.py +++ b/UnityTweakTool/section/unity.py @@ -190,15 +190,14 @@ # TODO: Yet to be fully implemented # TypeError: argument color: Expected Gdk.Color, but got gi.overrides.Gdk.RGBA -# color_launcher_color_cus=ColorChooser({ -# 'id' : 'color_launcher_color_cus', -# 'builder' : Unity.builder, -# 'schema' : 'org.compiz.unityshell', -# 'path' : '/org/compiz/profiles/unity/plugins/unityshell/', -# 'key' : 'background-color', -# 'type' : 'string', -# 'usealpha': 'gdkcolor' -# }) +color_launcher_color_cus=ColorChooser({ + 'id' : 'color_launcher_color_cus', + 'builder' : Unity.builder, + 'schema' : 'org.compiz.unityshell', + 'path' : '/org/compiz/profiles/unity/plugins/unityshell/', + 'key' : 'background-color', + 'type' : 'string', + }) sc_reveal_sensitivity=Scale({ @@ -224,9 +223,9 @@ cbox_urgent_animation, cbox_launch_animation, cbox_launcher_icon_colouring, - spin_launcher_icon_size]) #, + spin_launcher_icon_size, # sc_reveal_sensitivity, - # color_launcher_color_cus]) + color_launcher_color_cus]) #=============== DASH ==========================