Пример #1
0
    def __init__(self, parent, account, cert):
        issuer = cert.get_issuer()
        subject = cert.get_subject()
        InformationDialog.__init__(
            self,
            _('Certificate for account %s') % account,
            _('''<b>Issued to:</b>
Common Name (CN): %(scn)s
Organization (O): %(sorg)s
Organizationl Unit (OU): %(sou)s
Serial Number: %(sn)s

<b>Issued by:</b>
Common Name (CN): %(icn)s
Organization (O): %(iorg)s
Organizationl Unit (OU): %(iou)s

<b>Validity:</b>
Issued on: %(io)s
Expires on: %(eo)s

<b>Fingerprint</b>
SHA-1 Fingerprint: %(sha1)s

SHA-256 Fingerprint: %(sha256)s
''') % {
                'scn': subject.commonName,
                'sorg': subject.organizationName,
                'sou': subject.organizationalUnitName,
                'sn': cert.get_serial_number(),
                'icn': issuer.commonName,
                'iorg': issuer.organizationName,
                'iou': issuer.organizationalUnitName,
                'io': cert.get_notBefore().decode('utf-8'),
                'eo': cert.get_notAfter().decode('utf-8'),
                'sha1': cert.digest('sha1').decode('utf-8'),
                'sha256': cert.digest('sha256').decode('utf-8')
            })
        surface = load_icon('application-certificate', self, size=32)
        if surface is not None:
            img = Gtk.Image.new_from_surface(surface)
            img.show_all()
            self.set_image(img)
        self.set_transient_for(parent)
        self.set_title(_('Certificate for account %s') % account)
Пример #2
0
    def __init__(self, assistant):
        super().__init__(orientation=Gtk.Orientation.VERTICAL)
        self.set_spacing(18)
        self.assistant = assistant
        self.count = 0
        self.received = 0

        surface = load_icon('folder-download-symbolic', self, size=64)
        image = Gtk.Image.new_from_surface(surface)

        self.progress = Gtk.ProgressBar()
        self.progress.set_show_text(True)
        self.progress.set_text(_('Connecting...'))
        self.progress.set_pulse_step(0.1)
        self.progress.set_vexpand(True)
        self.progress.set_valign(Gtk.Align.CENTER)

        self.pack_start(image, False, False, 0)
        self.pack_start(self.progress, False, False, 0)
Пример #3
0
    def _process_img(self, attrs, loaded=None):
        '''Process a img tag.
        '''
        mem = ''
        pixbuf = None
        replace_mark = None
        replace_tags = None

        try:
            if attrs['src'].startswith('data:image/'):
                # The "data" URL scheme http://tools.ietf.org/html/rfc2397
                import base64
                img = attrs['src'].split(',')[1]
                mem = base64.standard_b64decode(
                    urllib.parse.unquote(img).encode('utf-8'))
            elif loaded is not None:
                (mem, alt, replace_mark, replace_tags) = loaded
            else:
                if self.conv_textview:
                    img_mark = self.textbuf.create_mark(None, self.iter, True)
                    app.thread_interface(
                        helpers.download_image,
                        [self.conv_textview.account, attrs], self._update_img,
                        [attrs, img_mark,
                         self._get_style_tags()])
                    alt = attrs.get('alt', '')
                    if alt:
                        alt += '\n'
                    alt += _('Loading')
                    pixbuf = load_icon('image-missing',
                                       self.textview,
                                       pixbuf=True)
            if mem:
                # Caveat: GdkPixbuf is known not to be safe to load
                # images from network... this program is now potentially
                # hackable ;)
                loader = GdkPixbuf.PixbufLoader()
                dims = [0, 0]

                def height_cb(length):
                    dims[1] = length

                def width_cb(length):
                    dims[0] = length

                # process width and height attributes
                width = attrs.get('width')
                height = attrs.get('height')
                # override with width and height styles
                for attr, val in style_iter(attrs.get('style', '')):
                    if attr == 'width':
                        width = val
                    elif attr == 'height':
                        height = val
                if width:
                    self._parse_length(width, False, False, 1, 1000, width_cb)
                if height:
                    self._parse_length(height, False, False, 1, 1000,
                                       height_cb)

                def set_size(_pixbuf, width_, height_, dims):
                    """
                    FIXME: Floats should be relative to the whole textview, and
                    resize with it. This needs new pifbufs for every resize,
                    GdkPixbuf.Pixbuf.scale_simple or similar.
                    """
                    if isinstance(dims[0], float):
                        dims[0] = int(dims[0] * width_)
                    elif not dims[0]:
                        dims[0] = width_
                    if isinstance(dims[1], float):
                        dims[1] = int(dims[1] * height_)
                    if not dims[1]:
                        dims[1] = height_
                    loader.set_size(*dims)

                if width or height:
                    loader.connect('size-prepared', set_size, dims)
                loader.write(mem)
                loader.close()
                pixbuf = loader.get_pixbuf()
                alt = attrs.get('alt', '')
            working_iter = self.iter
            if replace_mark is not None:
                working_iter = self.textbuf.get_iter_at_mark(replace_mark)
                next_iter = working_iter.copy()
                next_iter.forward_char()
                self.textbuf.delete(working_iter, next_iter)
                self.textbuf.delete_mark(replace_mark)
            if pixbuf is not None:
                if replace_mark:
                    tags = replace_tags
                else:
                    tags = self._get_style_tags()
                if tags:
                    tmpmark = self.textbuf.create_mark(None, working_iter,
                                                       True)
                self.textbuf.insert_pixbuf(working_iter, pixbuf)
                self.starting = False
                if tags:
                    start = self.textbuf.get_iter_at_mark(tmpmark)
                    for tag in tags:
                        self.textbuf.apply_tag(tag, start, working_iter)
                    self.textbuf.delete_mark(tmpmark)
            else:
                self._insert_text('[IMG: %s]' % alt, working_iter)
        except Exception as ex:
            log.error('Error loading image %s', str(ex))
            pixbuf = None
            alt = attrs.get('alt', 'Broken image')
            try:
                loader.close()
            except Exception:
                pass
        return pixbuf
Пример #4
0
Файл: gui.py Проект: bj-h/gajim
    def __init__(self):
        '''Initialize Plugins window'''
        builder = get_builder('plugins_window.ui')
        self.window = builder.get_object('plugins_window')
        self.window.set_transient_for(app.interface.roster.window)

        widgets_to_extract = ('plugins_notebook', 'plugin_name_label',
                              'plugin_version_label', 'plugin_authors_label',
                              'plugin_homepage_linkbutton',
                              'install_plugin_button',
                              'uninstall_plugin_button',
                              'configure_plugin_button',
                              'installed_plugins_treeview', 'available_text',
                              'available_text_label')

        for widget_name in widgets_to_extract:
            setattr(self, widget_name, builder.get_object(widget_name))

        self.plugin_description_textview = builder.get_object('description')

        # Disable 'Install from ZIP' for Flatpak installs
        if app.is_flatpak():
            self.install_plugin_button.set_tooltip_text(
                _('Click to view Gajim\'s wiki page on how to install plugins in Flatpak.'
                  ))

        self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool,
                                                     GdkPixbuf.Pixbuf)
        self.installed_plugins_treeview.set_model(self.installed_plugins_model)

        renderer = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(_('Plugin'))  #, renderer, text=Column.NAME)
        cell = Gtk.CellRendererPixbuf()
        col.pack_start(cell, False)
        col.add_attribute(cell, 'pixbuf', Column.ICON)
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.NAME)
        col.set_property('expand', True)
        self.installed_plugins_treeview.append_column(col)

        renderer = Gtk.CellRendererToggle()
        renderer.connect('toggled', self.installed_plugins_toggled_cb)
        col = Gtk.TreeViewColumn(_('Active'),
                                 renderer,
                                 active=Column.ACTIVE,
                                 activatable=Column.ACTIVATABLE)
        self.installed_plugins_treeview.append_column(col)

        self.def_icon = load_icon('preferences-desktop',
                                  self.window,
                                  pixbuf=True)

        # connect signal for selection change
        selection = self.installed_plugins_treeview.get_selection()
        selection.connect('changed',
                          self.installed_plugins_treeview_selection_changed)
        selection.set_mode(Gtk.SelectionMode.SINGLE)

        self._clear_installed_plugin_info()

        self.fill_installed_plugins_model()
        root_iter = self.installed_plugins_model.get_iter_first()
        if root_iter:
            selection.select_iter(root_iter)

        builder.connect_signals(self)

        self.plugins_notebook.set_current_page(0)

        # Adding GUI extension point for Plugins that want to hook the Plugin Window
        app.plugin_manager.gui_extension_point('plugin_window', self)

        self.window.show_all()