GnomeShellGenericMonitor/examples/dbusitem.py
Grégory Soutadé 506660f1da Update examples:
* Move examples in examples directory
       * Create separate DBUSItem class
       * Add timer example
2020-05-04 10:35:52 +02:00

27 lines
805 B
Python

class DBUSItem:
def __init__(self, name, text='', style='', icon='', iconStyle='', onClick=''):
self.name = name
self.text = text
self.style= style
self.icon = icon
self.iconStyle = iconStyle
self.onClick = onClick
self._checkValues()
def _checkValues(self):
if self.onClick and not self.onClick in ('signal', 'delete'):
raise ValueError('Invalid onClick value')
def toMap(self):
myMap = {"name":self.name}
for p in ('text', 'style', 'icon'):
if self.__dict__[p]:
myMap[p] = self.__dict__[p]
if self.iconStyle:
myMap['icon-style'] = self.iconStyle
if self.onClick:
myMap['on-click'] = self.onClick
return [myMap]