def _refresh_buttons(self): if len(self.bookmarks_list.get_children()) == 0: self.clear_button.set_sensitive(False) else: self.clear_button.set_sensitive(True) if wikiview.get_base_uri() in bookmarks.items or wikiview.is_local(): self.add_button.set_sensitive(False) else: self.add_button.set_sensitive(True)
def _add_bookmark_cb(self, action, parameter): if not wikiview.is_local(): uri = wikiview.get_base_uri() title = wikiview.get_title() lang = wikiview.get_lang() if self.headerbar.bookmarks_popover.add_bookmark(uri, title, lang): if self.headerbar.bookmarks_popover.is_visible(): self.headerbar.bookmarks_popover.bookmarks_list.show_all() else: message = _('New bookmark: ') + title self.show_notification(message)
def _wikiview_load_changed_cb(self, wikiview, event): if event == WebKit2.LoadEvent.STARTED: if self.search_bar.get_search_mode(): self.search_bar.set_search_mode(False) self.headerbar.toc_button.set_sensitive(False) self.headerbar.langlinks_button.set_sensitive(False) elif event == WebKit2.LoadEvent.FINISHED: self.headerbar.hide_spinner() props = wikiview.get_props() self.headerbar.set_page_menus(props) if settings.get_boolean( 'keep-historic') and not wikiview.is_local(): historic.add(wikiview.get_base_uri(), wikiview.get_title(), wikiview.get_lang())
def _menu_button_cb(self, menu_button): if menu_button.get_active(): window = self.get_toplevel() show_historic_action = window.lookup_action('show_historic') open_browser_action = window.lookup_action('open_browser') copy_url_action = window.lookup_action('copy_url') if wikiview.is_local(): open_browser_action.set_enabled(False) copy_url_action.set_enabled(False) else: open_browser_action.set_enabled(True) copy_url_action.set_enabled(True) if settings.get_boolean('keep-historic') and len( historic.items) > 0: show_historic_action.set_enabled(True) else: show_historic_action.set_enabled(False)
def _window_delete_cb(self, window, event): if window.is_maximized(): settings.set_boolean('window-max', True) else: settings.set_boolean('window-max', False) size = window.get_size() settings.set_int('window-width', size[0]) settings.set_int('window-height', size[1]) if wikiview.is_local(): settings.set_string('last-uri', '') else: settings.set_string('last-uri', wikiview.get_base_uri()) settings.sync() languages.save() if not settings.get_boolean('keep-historic'): historic.clear() historic.save() if settings.get_boolean('clear-bookmarks'): bookmarks.clear() bookmarks.save() self.quit()