Add box property management

Widgets can be put in left, center or right box.
Warning: right box is available (no error), but seems undefined (Gnome Shell 3.36)...
This commit is contained in:
2020-05-05 09:56:59 +02:00
parent 506660f1da
commit f536c89e36
3 changed files with 94 additions and 44 deletions

View File

@@ -1,22 +1,25 @@
class DBUSItem:
def __init__(self, name, text='', style='', icon='', iconStyle='', onClick=''):
def __init__(self, name, text='', style='', icon='', iconStyle='', onClick='', box=''):
self.name = name
self.text = text
self.style= style
self.icon = icon
self.iconStyle = iconStyle
self.onClick = onClick
self.box = box
self._checkValues()
def _checkValues(self):
if self.onClick and not self.onClick in ('signal', 'delete'):
raise ValueError('Invalid onClick value')
if self.box and not self.box in ('left', 'center', 'right'):
raise ValueError('Invalid box value')
def toMap(self):
myMap = {"name":self.name}
for p in ('text', 'style', 'icon'):
for p in ('text', 'style', 'icon', 'box'):
if self.__dict__[p]:
myMap[p] = self.__dict__[p]
if self.iconStyle:

View File

@@ -45,7 +45,7 @@ class TimerThread(Thread):
def _displayTimerValue(self):
encoder = json.JSONEncoder()
res = {'group':'Timer', 'items':[]}
item = DBUSItem('timer', onClick='signal')
item = DBUSItem('timer', onClick='signal', box='right')
curValue = self.timers[self.curTimer]
item.text = '%02d:%02d' % (int(curValue/60)%60, curValue%60)
if curValue >= (60*60):