def hyperlink_handler(self, texttag, _widget, event, iter_, _kind): if event.type != Gdk.EventType.BUTTON_PRESS: return Gdk.EVENT_PROPAGATE begin_iter = iter_.copy() # we get the beginning of the tag while not begin_iter.starts_tag(texttag): begin_iter.backward_char() end_iter = iter_.copy() # we get the end of the tag while not end_iter.ends_tag(texttag): end_iter.forward_char() # Detect XHTML-IM link word = getattr(texttag, 'href', None) if not word: word = self.get_buffer().get_text(begin_iter, end_iter, True) uri = parse_uri(word) if event.button.button == 3: # right click self.show_context_menu(uri) return Gdk.EVENT_STOP self.plugin_modified = False app.plugin_manager.extension_point('hyperlink_handler', uri, self, self.get_toplevel()) if self.plugin_modified: return Gdk.EVENT_STOP open_uri(uri, account=self.account) return Gdk.EVENT_STOP
def _on_open_menuitem_activate(self, menu, data): filepath = data['filepath'] original_filename = data['original_filename'] url = data['url'] if original_filename.startswith('location_'): open_uri(url) return open_file(filepath)
def on_install_plugin_button_clicked(self, widget): if app.is_flatpak(): open_uri('https://dev.gajim.org/gajim/gajim/wikis/help/flathub') return def show_warn_dialog(): text = _('Archive is malformed') dialog = WarningDialog(text, '', transient_for=self.window) dialog.set_modal(False) dialog.popup() def _on_plugin_exists(zip_filename): def _on_yes(): plugin = app.plugin_manager.install_from_zip( zip_filename, True) if not plugin: show_warn_dialog() return NewConfirmationDialog( _('Overwrite Plugin?'), _('Plugin already exists'), _('Do you want to overwrite the currently installed version?'), [ DialogButton.make('Cancel'), DialogButton.make( 'Remove', text=_('_Overwrite'), callback=_on_yes) ], transient_for=self.window).show() def _try_install(zip_filename): try: plugin = app.plugin_manager.install_from_zip(zip_filename) except PluginsystemError as er_type: error_text = str(er_type) if error_text == _('Plugin already exists'): _on_plugin_exists(zip_filename) return WarningDialog(error_text, '"%s"' % zip_filename, self.window) return if not plugin: show_warn_dialog() return ArchiveChooserDialog(_try_install, transient_for=self.window)
def __init__(self, fields): Gtk.ScrolledWindow.__init__(self) self.set_hexpand(True) self.set_vexpand(True) self.set_overlay_scrolling(False) self.get_style_context().add_class('data-form-widget') self._grid = Gtk.Grid() self._grid.set_column_spacing(12) self._grid.set_row_spacing(12) self._grid.set_halign(Gtk.Align.CENTER) self._fields = fields self._entries = {} self._row_count = 0 instructions = fields.pop('instructions', None) if instructions is not None: label = Gtk.Label(label=instructions) label.set_justify(Gtk.Justification.CENTER) label.set_max_width_chars(40) label.set_line_wrap(True) label.set_line_wrap_mode(Pango.WrapMode.WORD) self._grid.attach(label, 0, self._row_count, 2, 1) self._row_count += 1 redirect_url = fields.pop('redirect-url', None) if not fields and redirect_url is not None: # Server wants to redirect registration button = Gtk.Button(label='Register') button.set_halign(Gtk.Align.CENTER) button.get_style_context().add_class('suggested-action') button.connect('clicked', lambda *args: open_uri(redirect_url)) self._grid.attach(button, 0, self._row_count, 2, 1) else: self._add_fields() self.add(self._grid) self.show_all()
def _on_activate_log_link(button): open_uri(button.get_uri()) return Gdk.EVENT_STOP
def _on_activate_link(self, _label, _value): open_uri(self._uri, self._account) return Gdk.EVENT_STOP
def _on_activate_link(self, label, *args): open_uri(label.get_text(), account=self.account) return Gdk.EVENT_STOP
def _on_activate_link(_label, uri): # We have to use this, because the default GTK handler # is not cross-platform compatible open_uri(uri) return Gdk.EVENT_STOP
def on_install_plugin_button_clicked(self, widget): if app.is_flatpak(): open_uri('https://dev.gajim.org/gajim/gajim/wikis/help/flathub') return def show_warn_dialog(): text = _('Archive is malformed') dialog = WarningDialog(text, '', transient_for=self.window) dialog.set_modal(False) dialog.popup() def _on_plugin_exists(zip_filename): def _on_yes(): plugin = app.plugin_manager.install_from_zip( zip_filename, True) if not plugin: show_warn_dialog() return model = self.installed_plugins_model for _index, row in enumerate(model): if plugin == row[Column.PLUGIN]: model.remove(row.iter) break iter_ = model.append([ plugin, plugin.name, False, plugin.activatable, self.get_plugin_icon(plugin) ]) sel = self.installed_plugins_treeview.get_selection() sel.select_iter(iter_) NewConfirmationDialog( _('Overwrite Plugin?'), _('Plugin already exists'), _('Do you want to overwrite the currently installed version?'), [ DialogButton.make('Cancel'), DialogButton.make( 'Remove', text=_('_Overwrite'), callback=_on_yes) ], transient_for=self.window).show() def _try_install(zip_filename): try: plugin = app.plugin_manager.install_from_zip(zip_filename) except PluginsystemError as er_type: error_text = str(er_type) if error_text == _('Plugin already exists'): _on_plugin_exists(zip_filename) return WarningDialog(error_text, '"%s"' % zip_filename, self.window) return if not plugin: show_warn_dialog() return model = self.installed_plugins_model iter_ = model.append([ plugin, plugin.name, False, plugin.activatable, self.get_plugin_icon(plugin) ]) sel = self.installed_plugins_treeview.get_selection() sel.select_iter(iter_) ArchiveChooserDialog(_try_install, transient_for=self.window)
def _on_link_button(self, _button): open_uri(self._link)
def _on_visit_server(self, _widget): server = self._ui.server_comboboxtext_sign_up_entry.get_text().strip() server = 'https://' + server open_uri(server) return Gdk.EVENT_STOP
def _on_activate_contact_link(self, button): open_uri('xmpp:%s?message' % button.get_uri(), account=self._account) return Gdk.EVENT_STOP
def open_link(_action, param): uri = param.get_string() helpers.open_uri(uri)
def _on_open_link_in_browser_menuitem_activate(self, menu, data): url = data['url'] if data['encrypted']: self._on_open_menuitem_activate(self, data) else: open_uri(url)
def open_link(_action, param): account, uri = param.get_strv() helpers.open_uri(uri, account=account)
def open_mail(_action, param): uri = param.get_string() if not uri.startswith('mailto:'): uri = 'mailto:%s' % uri helpers.open_uri(uri)
def on_faq(_action, _param): helpers.open_uri('https://dev.gajim.org/gajim/gajim/wikis/help/gajimfaq')
def on_contents(_action, _param): helpers.open_uri('https://dev.gajim.org/gajim/gajim/wikis')