def quit_gtk(window): if before_quit is not None: before_quit() # disable plugins import quodlibet.plugins quodlibet.plugins.quit() # for debug: this will list active copools from quodlibet.util import copool copool.pause_all() # See which browser windows are open and save their names # so we can restore them on start from quodlibet.qltk.browser import LibraryBrowser LibraryBrowser.save() # destroy all open windows so they hide immediately on close: # destroying all top level windows doesn't work (weird errors), # so we hide them all and only destroy our tracked instances # (browser windows, tag editors, pref window etc.) from quodlibet.qltk import Window for toplevel in Gtk.Window.list_toplevels(): toplevel.hide() for window in Window.windows: window.destroy() Gtk.main_quit() print_d("Quit GTK: done.")
def test_pause_all(self): self.buffer = None copool.add(self.__set_buffer, funcid="test") self._assert_eventually(True) copool.pause_all() self.buffer = None self._assert_never(True)
def test_pause_all(self): copool.add(self.__set_buffer, funcid="test") Gtk.main_iteration_do(False) Gtk.main_iteration_do(False) self.failUnless(self.buffer) copool.pause_all() self.buffer = None Gtk.main_iteration_do(False) Gtk.main_iteration_do(False) self.failIf(self.buffer)
def quit_gtk(m): _quit_before() # disable plugins import quodlibet.plugins quodlibet.plugins.quit() # stop all copools print_d("Quit GTK: Stop all copools") from quodlibet.util import copool copool.pause_all() # events that add new events to the main loop (like copool) # can block the shutdown, so force stop after some time. # gtk.main_iteration will return True if quit gets called here from gi.repository import GLib GLib.timeout_add(4 * 1000, Gtk.main_quit, priority=GLib.PRIORITY_HIGH) # See which browser windows are open and save their names # so we can restore them on start from quodlibet.qltk.browser import LibraryBrowser LibraryBrowser.save() # destroy all open windows so they hide immediately on close: # destroying all top level windows doesn't work (weird errors), # so we hide them all and only destroy our tracked instances # (browser windows, tag editors, pref window etc.) from quodlibet.qltk import Window for toplevel in Gtk.Window.list_toplevels(): toplevel.hide() for window in Window.windows: window.destroy() print_d("Quit GTK: Process pending events...") while Gtk.events_pending(): if Gtk.main_iteration_do(False): print_d("Quit GTK: Timeout occurred, force quit.") break else: Gtk.main_quit() print_d("Quit GTK: done.")