def close(self, button): """ Close this dialog and destroy it. """ self.parent.dialog_open = False self.dialog.destroy() player.stop() player.unload() player.emit_event("stop")
def __player_changed(self, event, message): """ Listen to and handle all gst player messages that are important for the ui. """ if event == "stop": if self.__inhibit_cookie: self.app.uninhibit(self.__inhibit_cookie) self.is_playing = False self.stop() self.titlebar.stop() self.sleep_timer.stop() elif event == "play": self.is_playing = True self.play() self.titlebar.play() self.sleep_timer.start() self.book_overview.select_track(None, True) self.refresh_recent() self.__inhibit_cookie = self.app.inhibit( self.window, Gtk.ApplicationInhibitFlags.SUSPEND, "Playback of audiobook") elif event == "pause": if self.__inhibit_cookie: self.app.uninhibit(self.__inhibit_cookie) self.is_playing = False self.pause() self.titlebar.pause() self.sleep_timer.stop() self.book_overview.select_track(None, False) elif event == "track-changed": self.track_changed() if self.sort_stack.props.visible_child_name == "recent": self.book_box.invalidate_filter() self.book_box.invalidate_sort() elif event == "error": if self.dialog_open: return if "Resource not found" in str(message): current_track = player.get_current_track() if db.is_external(current_track.book): player.stop() player.unload() player.emit_event("stop") else: self.dialog_open = True dialog = FileNotFoundDialog( current_track.file) dialog.show()