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

Commit

Permalink
port to rewrite - color_launcher_color_cus
Browse files Browse the repository at this point in the history
  • Loading branch information
phanimahesh committed Mar 19, 2013
1 parent 5036351 commit 3385410
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
26 changes: 18 additions & 8 deletions UnityTweakTool/elements/colorchooser.py
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions UnityTweakTool/section/sphagetti/unity.py
Expand Up @@ -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')
Expand Down
21 changes: 10 additions & 11 deletions UnityTweakTool/section/unity.py
Expand Up @@ -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({
Expand All @@ -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 ==========================

Expand Down

0 comments on commit 3385410

Please sign in to comment.