Skip to content

Commit

Permalink
Merge pull request #239 from MoetaYuko/refresh
Browse files Browse the repository at this point in the history
controls: Ensure last refresh is finished before starting the next
  • Loading branch information
nwg-piotr authored Jul 9, 2023
2 parents d901750 + 635c711 commit aaa26a3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions nwg_panel/modules/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ def __init__(self, parent, position, alignment, settings, width, monitor=None, i

e_box.connect('button-press-event', self.switch_menu_box)

Gdk.threads_add_timeout(GLib.PRIORITY_LOW, 500, self.refresh)
self.refresh(True)

def schedule_refresh(self):
Gdk.threads_add_timeout(GLib.PRIORITY_LOW, 500, self.refresh, (True, ))

def set_up_bcg_window(self):
self.bcg_window = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
Expand Down Expand Up @@ -580,7 +583,7 @@ def custom_item(self, name, icon, cmd):

return eb

def refresh(self, *args):
def refresh(self, schedule=False):
if self.get_visible():
self.refresh_sinks()

Expand Down Expand Up @@ -615,7 +618,8 @@ def refresh(self, *args):
with self.bri_scale.handler_block(self.bri_scale_handler):
self.bri_scale.set_value(self.parent.bri_value)

return True
if schedule:
self.schedule_refresh()

def on_enter_notify_event(self, widget, event):
widget.set_state_flags(Gtk.StateFlags.DROP_ACTIVE, clear=False)
Expand Down

0 comments on commit aaa26a3

Please sign in to comment.