Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def save_and_quit(self, *args):
""" Save configuration and exit the main loop.
"""
self.scribbler.disable_scribbling()
self.medias.hide_all()
extras.FileWatcher.stop_daemon()
self.doc.cleanup_media_files()
self.config.update_layout('notes' if self.notes_mode else 'plain',
self.p_central.get_children()[0], self.pane_handle_pos)
if bool(self.c_win.get_window().get_state() & Gdk.WindowState.FULLSCREEN):
util.set_screensaver(False, self.c_win.get_window())
self.config.save_config()
Gtk.main_quit()
def on_window_state_event(self, widget, event):
""" Track whether the preview window is maximized.
Args:
widget (:class:`~Gtk.Widget`): the widget in which the event occurred
event (:class:`~Gtk.Event`): the event that occurred
Returns:
`bool`: whether the event was consumed.
"""
if widget.get_name() == self.c_win.get_name():
fullscreen = (Gdk.WindowState.FULLSCREEN & event.new_window_state) != 0
util.set_screensaver(fullscreen, self.c_win.get_window())
return False
GLib.idle_add(lambda: util.set_screensaver(True, self.c_win.get_window()))