def activate_links(self): if self.text_buffer.get_selection_bounds() == (): pos = self.text_buffer.props.cursor_position target = next( (url for start, end, url in self.hyperlinks if start < pos < end), None) if target is not None: util.open_website(target)
def _navigation_policy_decision(self, wv, fr, req, action, decision): REASON_LINK_CLICKED, REASON_OTHER = 0, 5 if action.get_reason() == REASON_LINK_CLICKED: util.open_website(req.get_uri()) decision.ignore() elif action.get_reason() == REASON_OTHER: decision.use() else: decision.ignore()
def navigation_policy_decision(wv, fr, req, action, decision): REASON_LINK_CLICKED, REASON_OTHER = 0, 5 if action.get_reason() == REASON_LINK_CLICKED: util.open_website(req.get_uri()) decision.ignore() elif action.get_reason() == REASON_OTHER: decision.use() else: decision.ignore()
def show_preferences(self): box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) box.set_border_width(10) checkbox = Gtk.CheckButton( _('Parse YouTube channel feeds with youtube-dl to access more than 15 episodes' )) checkbox.set_active(self.container.config.manage_channel) checkbox.connect('toggled', self.toggle_manage_channel) box.pack_start(checkbox, False, False, 0) box.pack_start(Gtk.HSeparator(), False, False, 0) checkbox = Gtk.CheckButton( _('Download all supported episodes with youtube-dl')) checkbox.set_active(self.container.config.manage_downloads) checkbox.connect('toggled', self.toggle_manage_downloads) box.pack_start(checkbox, False, False, 0) note = Gtk.Label( use_markup=True, wrap=True, label= _('youtube-dl provides access to additional YouTube formats and DRM content.' ' Episodes from non-YouTube channels, that have youtube-dl support, will <b>fail</b> to download unless you manually' ' <a href="https://gpodder.github.io/docs/youtube.html#formats">add custom formats</a> for each site.' ' <b>Download with youtube-dl</b> appears in the episode menu when this option is disabled,' ' and can be used to manually download from supported sites.')) note.connect('activate-link', lambda label, url: util.open_website(url)) note.set_property('xalign', 0.0) box.add(note) box.show_all() return box
def on_decide_policy(self, webview, decision, decision_type): if decision_type == WebKit2.PolicyDecisionType.NEW_WINDOW_ACTION: decision.ignore() return False elif decision_type == WebKit2.PolicyDecisionType.NAVIGATION_ACTION: req = decision.get_request() # about:blank is for plain text shownotes if req.get_uri() in (self._base_uri, 'about:blank'): decision.use() else: # Avoid opening the page inside the WebView and open in the browser instead decision.ignore() util.open_website(req.get_uri()) return False else: decision.use() return False
def on_about(self, action, param): dlg = Gtk.Dialog(_('About gPodder'), self.window.gPodder, Gtk.DialogFlags.MODAL) dlg.add_button(_('_Close'), Gtk.ResponseType.OK).show() dlg.set_resizable(True) bg = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6, margin=16) pb = GdkPixbuf.Pixbuf.new_from_file_at_size(gpodder.icon_file, 160, 160) bg.pack_start(Gtk.Image.new_from_pixbuf(pb), False, False, 0) label = Gtk.Label(justify=Gtk.Justification.CENTER) label.set_selectable(True) label.set_markup('\n'.join(x.strip() for x in """ <b>gPodder {version} ({date})</b> {copyright} {license} <a href="{url}">{tr_website}</a> · <a href="{bugs_url}">{tr_bugtracker}</a> """.format(version=gpodder.__version__, date=gpodder.__date__, copyright=gpodder.__copyright__, license=gpodder.__license__, bugs_url='https://github.com/gpodder/gpodder/issues', url=html.escape(gpodder.__url__), tr_website=_('Website'), tr_bugtracker=_('Bug Tracker')).strip().split('\n'))) label.connect('activate-link', lambda label, url: util.open_website(url)) bg.pack_start(label, False, False, 0) bg.pack_start(Gtk.Label(), False, False, 0) dlg.vbox.pack_start(bg, False, False, 0) dlg.connect('response', lambda dlg, response: dlg.destroy()) dlg.vbox.show_all() dlg.run()
def on_populate_popup(self, textview, context_menu): # TODO: Remove items from context menu that are always insensitive in a read-only buffer if self.episode.link: # TODO: It is currently not possible to copy links in description. # Detect if context menu was opened on a hyperlink and add # "Open Link" and "Copy Link Address" menu items. # See https://github.com/gpodder/gpodder/issues/1097 item = Gtk.SeparatorMenuItem() item.show() context_menu.append(item) # label links can be opened from context menu or by clicking them, do the same here item = Gtk.MenuItem(label=_('Open Episode Title Link')) item.connect('activate', lambda i: util.open_website(self.episode.link)) item.show() context_menu.append(item) # hack to allow copying episode.link item = Gtk.MenuItem(label=_('Copy Episode Title Link Address')) item.connect('activate', lambda i: util.copy_text_to_clipboard(self.episode.link)) item.show() context_menu.append(item)
def on_display_text(self): # Now do the stuff that takes a bit longer... heading = self.episode.title subheading = 'from %s' % (self.episode.channel.title) description = self.episode.description if self.have_gtkhtml2: import gtkhtml2 self.d.connect('link-clicked', lambda doc, url: util.open_website(url)) def request_url(document, url, stream): def opendata(url, stream): fp = util.urlopen(url) data = fp.read(1024*10) while data != '': stream.write(data) data = fp.read(1024*10) stream.close() threading.Thread(target=opendata, args=[url, stream]).start() self.d.connect('request-url', request_url) self.d.clear() self.d.open_stream('text/html') self.d.write_stream('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/></head><body>') self.d.write_stream('<span style="font-size: big; font-weight: bold;">%s</span><br><span style="font-size: small;">%s</span><hr style="border: 1px #eeeeee solid;"><p>' % (saxutils.escape(heading), saxutils.escape(subheading))) self.d.write_stream(self.episode.description) self.d.write_stream('</p></body></html>') self.d.close_stream() else: self.b.create_tag('heading', scale=pango.SCALE_LARGE, weight=pango.WEIGHT_BOLD) self.b.create_tag('subheading', scale=pango.SCALE_SMALL) self.b.insert_with_tags_by_name(self.b.get_end_iter(), heading, 'heading') self.b.insert_at_cursor('\n') self.b.insert_with_tags_by_name(self.b.get_end_iter(), subheading, 'subheading') self.b.insert_at_cursor('\n\n') self.b.insert(self.b.get_end_iter(), util.remove_html_tags(description)) self.b.place_cursor(self.b.get_start_iter())
def on_open_in_browser(self, action): util.open_website(action.url)
def open_website(self): util.open_website('http://' + self._config.mygpo.server)
def on_help_activate(self, action, param): util.open_website('https://gpodder.github.io/docs/')
def new(self): self.show_on_cover_load = True self.gPodderChannel.set_transient_for(self.parent_widget) self.title_label.set_text(self.channel.title) self.labelURL.set_text(self.channel.url) self.skip_feed_update_switch.set_active( self.channel.pause_subscription) self.enable_device_sync_switch.set_active( self.channel.sync_to_mp3_player) self.section_list = Gtk.ListStore(str) active_index = 0 for index, section in enumerate(sorted(self.sections)): self.section_list.append([section]) if section == self.channel.section: active_index = index self.combo_section.set_model(self.section_list) cell_renderer = Gtk.CellRendererText() self.combo_section.pack_start(cell_renderer, True) self.combo_section.add_attribute(cell_renderer, 'text', 0) self.combo_section.set_active(active_index) self.strategy_list = Gtk.ListStore(str, int) active_index = 0 for index, (checked, strategy_id, strategy) in \ enumerate(self.channel.get_download_strategies()): self.strategy_list.append([strategy, strategy_id]) if checked: active_index = index self.combo_strategy.set_model(self.strategy_list) cell_renderer = Gtk.CellRendererText() self.combo_strategy.pack_start(cell_renderer, True) self.combo_strategy.add_attribute(cell_renderer, 'text', 0) self.combo_strategy.set_active(active_index) self.LabelDownloadTo.set_text(self.channel.save_dir) self.website_label.set_markup('<a href="{}">{}</a>'.format( self.channel.link, self.channel.link) if self.channel.link else '') self.website_label.connect('activate-link', lambda label, url: util.open_website(url)) if self.channel.auth_username: self.FeedUsername.set_text(self.channel.auth_username) if self.channel.auth_password: self.FeedPassword.set_text(self.channel.auth_password) self.cover_downloader.register('cover-available', self.cover_download_finished) self.cover_downloader.request_cover(self.channel) if self.channel._update_error: err = '\n\n' + (_('ERROR: %s') % self.channel._update_error) else: err = '' self.channel_description.set_text( util.remove_html_tags(self.channel.description) + err) # Add Drag and Drop Support flags = Gtk.DestDefaults.ALL targets = [ Gtk.TargetEntry.new('text/uri-list', 0, 2), Gtk.TargetEntry.new('text/plain', 0, 4) ] actions = Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY self.imgCover.drag_dest_set(flags, targets, actions) self.imgCover.connect('drag_data_received', self.drag_data_received) border = 6 size = self.MAX_SIZE + border * 2 self.imgCover.set_size_request(size, size) self.imgCoverEventBox.connect('button-press-event', self.on_cover_popup_menu) # Title save button state self.title_save_button_saves = True self._config.connect_gtk_window(self.gPodderChannel, 'channel_editor', True) gpodder.user_extensions.on_ui_object_available('channel-gtk', self) result = gpodder.user_extensions.on_channel_settings(self.channel) if result: for label, callback in result: sw = Gtk.ScrolledWindow() sw.add(callback(self.channel)) sw.show_all() self.notebookChannelEditor.append_page(sw, Gtk.Label(label))
def on_visit_website_button_clicked(self, widget=None): if self.episode and self.episode.link: util.open_website(self.episode.link)
def on_visit_website_button_clicked(self, widget): util.open_website(self.channel.link)
def on_open_in_browser(self, action, var): util.open_website(var.get_string())
def activate_links(self): if self.text_buffer.get_selection_bounds() == (): pos = self.text_buffer.props.cursor_position target = next((url for start, end, url in self.hyperlinks if start < pos < end), None) if target is not None: util.open_website(target)
def on_website_button_clicked(self, widget): if self.channel is not None: util.open_website(self.channel.link)
def on_btn_website_clicked(self, widget): util.open_website(self.channel.link)
def open_website(self, episodes): for episode in episodes: if episode.link: util.open_website(episode.link)
def open_channel_website(self, channel): util.open_website(channel.link)
def open_weblink(self, w, url): util.open_website(url)
def open_website(self, episodes): for episode in episodes: util.open_website(episode.link)
def on_button_youtube_api_key_clicked(self, widget): util.open_website('https://developers.google.com/youtube/v3/')
def on_button_youtube_api_key_clicked(self, widget): util.open_website('http://wiki.gpodder.org/wiki/Youtube')
def activate_links(self): if self.text_buffer.get_selection_bounds() == (): pos = self.text_buffer.props.cursor_position target = self.hyperlink_at_pos(pos) if target is not None: util.open_website(target)