Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controls: Ensure last refresh is finished before starting the next #239

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions nwg_panel/modules/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,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 @@ -696,7 +699,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()
if "net" in self.settings["components"] and commands["netifaces"] and self.settings["net-interface"]:
Expand Down Expand Up @@ -746,7 +749,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