mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-02 15:40:19 +00:00
prevent some gtk main loop error to appear on close
This commit is contained in:
parent
032ebd09c6
commit
a449755049
@ -29,7 +29,7 @@ from argparse import ArgumentParser
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('GLib', '2.0')
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
from keymapper.logger import update_verbosity, log_info
|
||||
from keymapper.gtk.window import Window
|
||||
@ -65,6 +65,7 @@ if __name__ == '__main__':
|
||||
# it created its own temporary daemon inside the process
|
||||
# because none was running
|
||||
window.dbus.stop()
|
||||
|
||||
window.on_close()
|
||||
|
||||
atexit.register(stop)
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
|
||||
import evdev
|
||||
import sys
|
||||
from evdev.ecodes import EV_KEY
|
||||
|
||||
import gi
|
||||
@ -130,11 +131,14 @@ class Window:
|
||||
|
||||
def on_close(self, *_):
|
||||
"""Safely close the application."""
|
||||
logger.debug('Closing window')
|
||||
for timeout in self.timeouts:
|
||||
GLib.source_remove(timeout)
|
||||
self.timeouts = []
|
||||
keycode_reader.stop_reading()
|
||||
Gtk.main_quit()
|
||||
self.window.destroy()
|
||||
gtk_iteration()
|
||||
sys.exit(0)
|
||||
|
||||
def check_add_row(self):
|
||||
"""Ensure that one empty row is available at all times."""
|
||||
@ -289,18 +293,20 @@ class Window:
|
||||
|
||||
def on_apply_preset_clicked(self, _):
|
||||
"""Apply a preset without saving changes."""
|
||||
logger.debug(
|
||||
'Applying preset "%s" for "%s"',
|
||||
self.selected_preset,
|
||||
self.selected_device
|
||||
)
|
||||
self.get('status_bar').push(
|
||||
CTX_APPLY,
|
||||
f'Applied "{self.selected_preset}"'
|
||||
)
|
||||
preset = self.selected_preset
|
||||
device = self.selected_device
|
||||
|
||||
logger.debug('Applying preset "%s" for "%s"', preset, device)
|
||||
|
||||
push = self.get('status_bar').push
|
||||
if custom_mapping.changed:
|
||||
push(CTX_APPLY, f'Applied outdated preset "{preset}"')
|
||||
else:
|
||||
push(CTX_APPLY, f'Applied preset "{preset}"')
|
||||
|
||||
success = self.dbus.start_injecting(
|
||||
self.selected_device,
|
||||
self.selected_preset
|
||||
preset
|
||||
)
|
||||
|
||||
if not success:
|
||||
@ -311,7 +317,7 @@ class Window:
|
||||
|
||||
# restart reading because after injecting the device landscape
|
||||
# changes a bit
|
||||
keycode_reader.start_reading(self.selected_device)
|
||||
keycode_reader.start_reading(device)
|
||||
GLib.timeout_add(10, self.show_device_mapping_status)
|
||||
|
||||
def on_preset_autoload_switch_activate(self, _, active):
|
||||
|
@ -114,6 +114,8 @@ def log_info():
|
||||
logger.info('Could not figure out the version')
|
||||
logger.debug(error)
|
||||
|
||||
logger.debug('pid %s', os.getpid())
|
||||
|
||||
|
||||
def update_verbosity(debug):
|
||||
"""Set the logging verbosity according to the settings object."""
|
||||
|
Loading…
Reference in New Issue
Block a user