Example #1
0
 def load_changed(self, webview, state):
     if state == WebKit2.LoadEvent.STARTED:
         Bus.emit("trigger_website_loading")
     finished = state == WebKit2.LoadEvent.FINISHED
     if not finished:
         return
     self.www.run_javascript_from_gresource('/hn/js/Readability.js', None,
                                            self._loaded_readability, None)
Example #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.old_child = None
        self.setup_styles()
        self.set_default_size(360, 720)
        self.show_all()

        Bus.on("open_thread", self.set_thread)
        Bus.on("open_website", self.set_website)
Example #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # https://stackoverflow.com/questions/60126579/gtk-builder-error-quark-invalid-object-type-webkitwebview
        # Can't have the WevView in ui file without hacks, doing it programatically is clearer
        ctx = WebKit2.WebContext.get_default()
        ctx.set_web_extensions_directory(WEBEXT_DIR)
        self.www = WebKit2.WebView.new_with_context(ctx)
        self.www.connect('load-changed', self.load_changed)
        self.www.set_hexpand(True)
        self.www.set_vexpand(True)
        self.add(self.www)

        Bus.on("trigger_readability", self.convert_to_readable)
        Bus.on("open_website", self.load_uri)
        Bus.on("trigger_stop_website", self.www.stop_loading)
Example #4
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     Bus.on("open_website",
            lambda url, title: self.page_title.set_label(title))
     Bus.on("trigger_website_loading", self.readable_toggle.hide)
     Bus.on("website_can_be_readable", self.readable_toggle.show)
Example #5
0
 def do_activate(self):
     self.window = AppWindow(application=self, title="Hacker News")
     self.window.present()
     Bus.emit("refresh_news_list")
Example #6
0
 def activate_link(self, label, link):
     Bus.emit("open_website", url=link, title="FIX TITLE")
     return True
Example #7
0
 def title_click(self, event):
     Bus.emit("open_website", url=self.article_url, title=self.thread_title)
Example #8
0
 def comments_click(self, event):
     Bus.emit("open_thread", story=self.story)
Example #9
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     Bus.on("open_thread", self.async_load_thread)
Example #10
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     Bus.on("open_thread", self.set_story_details)
Example #11
0
 def on_refresh(self, event):
     Bus.emit("refresh_news_list")
Example #12
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     Bus.on('refresh_news_list', self.async_refresh)
Example #13
0
 def on_readerable_result(self, webview, result, user_data):
     result = self.www.run_javascript_finish(result)
     if result.get_js_value().to_boolean():
         Bus.emit("website_can_be_readable")
         print('making visible', flush=True)
Example #14
0
 def back_click(self, event):
     Bus.emit("trigger_stop_website")
     # FIXME
     window = self.get_toplevel()
     window.pop_website()
Example #15
0
 def readability_click(self, event):
     self.readable_toggle.hide()
     Bus.emit("trigger_readability")