Skip to content

Commit

Permalink
Fixed module/indicator styling
Browse files Browse the repository at this point in the history
  • Loading branch information
thnikk committed Dec 6, 2024
1 parent 5ead587 commit 40e8124
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 8 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def __init__(self, icon=True, text=True):
self.default_styles = self.get_style_context().list_classes()
self.con = box('v')
self.indicator = box('h', style='indicator')
self.indicator_styles = \
self.indicator.get_style_context().list_classes()
self.box = box('h', spacing=5)
self.con.pack_start(self.box, 1, 1, 0)
self.con.add(self.indicator)
Expand All @@ -58,6 +60,12 @@ def reset_style(self):
if style not in self.default_styles:
self.get_style_context().remove_class(style)

indicator_styles = self.indicator.get_style_context().list_classes()
if self.indicator_styles != indicator_styles:
for style in indicator_styles:
if style not in self.indicator_styles:
self.indicator.get_style_context().remove_class(style)

def get_styles(self):
""" Get styles """
return self.get_style_context().list_classes()
Expand Down
5 changes: 1 addition & 4 deletions module.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,19 @@ def get_output():
module.cache.widget = output['widget']

# Override class and set to gray if module is stale
module.reset_style()
if 'interval' in module_config and 'timestamp' in output:
if (
datetime.now() -
datetime.fromtimestamp(output['timestamp'])
).seconds > module_config['interval'] * 2:
c.add_style(module, 'gray')
else:
module.reset_style()

# Set class
if 'indicator' in config and config['indicator']:
module.indicator.reset_style()
if 'class' in list(output):
c.add_style(module.indicator, output['class'])
else:
module.reset_style()
if 'class' in list(output):
c.add_style(module, output['class'])

Expand Down

0 comments on commit 40e8124

Please sign in to comment.