diff --git a/safeeyes/safeeyes.py b/safeeyes/safeeyes.py index 1345e9c..bf1ddb4 100644 --- a/safeeyes/safeeyes.py +++ b/safeeyes/safeeyes.py @@ -71,8 +71,8 @@ class SafeEyes: self.show_about) self.context['api']['enable_safeeyes'] = lambda next_break_time=-1, reset_breaks=False: \ utility.execute_main_thread(self.enable_safeeyes, next_break_time, reset_breaks) - self.context['api']['disable_safeeyes'] = lambda status: utility.execute_main_thread( - self.disable_safeeyes, status) + self.context['api']['disable_safeeyes'] = lambda status=None, is_resting=False: utility.execute_main_thread( + self.disable_safeeyes, status, is_resting) self.context['api']['status'] = self.status self.context['api']['quit'] = lambda: utility.execute_main_thread( self.quit) diff --git a/safeeyes/utility.py b/safeeyes/utility.py index 3976140..ea25088 100644 --- a/safeeyes/utility.py +++ b/safeeyes/utility.py @@ -94,28 +94,16 @@ def start_thread(target_function, **args): thread.start() -# def execute_main_thread(target_function, args=None): +# def execute_main_thread(target_function, *args, **kwargs): # """ -# Execute the given function in main thread. +# Execute the given function in main thread, forwarding positional and keyword arguments. # """ -# if args: -# GLib.idle_add(lambda: target_function(args)) -# else: -# GLib.idle_add(target_function) -def execute_main_thread(target_function, arg1=None, arg2=None): +def execute_main_thread(target_function, *args, **kwargs): """ Execute the given function in main thread. """ - if arg1 is not None and arg2 is not None: - GLib.idle_add(lambda: target_function(arg1, arg2)) - elif arg1 is not None: - GLib.idle_add(lambda: target_function(arg1)) - elif arg2 is not None: - GLib.idle_add(lambda: target_function(arg2)) - else: - GLib.idle_add(target_function) - + GLib.idle_add(lambda: target_function(*args, **kwargs)) def system_locale(category=locale.LC_MESSAGES): """