Example #1
0
File: gui.py Project: gajim/gajim
    def __init__(self):
        '''Initialize Plugins window'''
        self.xml = gtkgui_helpers.get_gtk_builder('plugins_window.ui')
        self.window = self.xml.get_object('plugins_window')
        self.window.set_transient_for(gajim.interface.roster.window)

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

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

        self.plugin_description_textview = HtmlTextView()
        sw = self.xml.get_object('scrolledwindow2')
        sw.add(self.plugin_description_textview)
        self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool,
            GdkPixbuf.Pixbuf)
        self.installed_plugins_treeview.set_model(self.installed_plugins_model)
        self.installed_plugins_treeview.set_rules_hint(True)

        renderer = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(_('Plugin'))#, renderer, text=NAME)
        cell = Gtk.CellRendererPixbuf()
        col.pack_start(cell, False)
        col.add_attribute(cell, 'pixbuf', ICON)
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', 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=ACTIVE,
            activatable=ACTIVATABLE)
        self.installed_plugins_treeview.append_column(col)

        self.def_icon = gtkgui_helpers.get_icon_pixmap('preferences-desktop')

        # 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 )

        self.xml.connect_signals(self)

        self.plugins_notebook.set_current_page(0)
        self.xml.get_object('close_button').grab_focus()

        self.window.show_all()
        gtkgui_helpers.possibly_move_window_in_current_desktop(self.window)
Example #2
0
        def _on_plugin_exists(zip_filename):
            def on_yes(is_checked):
                plugin = gajim.plugin_manager.install_from_zip(
                    zip_filename, True)
                if not plugin:
                    show_warn_dialog()
                    return
                model = self.installed_plugins_model

                for row in list(range(len(model))):
                    if plugin == model[row][PLUGIN]:
                        model.remove(model.get_iter((row, PLUGIN)))
                        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_)

            YesNoDialog(_('Plugin already exists'),
                        sectext=_('Overwrite?'),
                        on_response_yes=on_yes,
                        transient_for=self.window)
Example #3
0
    def _display_installed_plugin_info(self, plugin):
        self.plugin_name_label.set_text(plugin.name)
        self.plugin_version_label.set_text(plugin.version)
        self.plugin_authors_label.set_text(plugin.authors)
        self.plugin_homepage_linkbutton.set_uri(plugin.homepage)
        self.plugin_homepage_linkbutton.set_label(plugin.homepage)
        label = self.plugin_homepage_linkbutton.get_children()[0]
        label.set_ellipsize(Pango.EllipsizeMode.END)
        self.plugin_homepage_linkbutton.set_property('sensitive', True)

        desc_textbuffer = self.plugin_description_textview.get_buffer()
        desc_textbuffer.set_text('')
        txt = plugin.description
        txt.replace('</body>', '')
        if plugin.available_text:
            txt += '<br/><br/>' + _('Warning: %s') % plugin.available_text
        if not txt.startswith('<body '):
            txt = '<body  xmlns=\'http://www.w3.org/1999/xhtml\'>' + txt
        txt += ' </body>'
        self.plugin_description_textview.display_html(
            txt, self.plugin_description_textview, None)

        self.plugin_description_textview.set_property('sensitive', True)
        self.uninstall_plugin_button.set_property(
            'sensitive', gajim.PLUGINS_DIRS[1] in plugin.__path__)
        self.configure_plugin_button.set_property(
            'sensitive', not plugin.config_dialog is None)
Example #4
0
File: gui.py Project: irl/gajim
    def _display_installed_plugin_info(self, plugin):
        self.plugin_name_label.set_text(plugin.name)
        self.plugin_version_label.set_text(plugin.version)
        self.plugin_authors_label.set_text(plugin.authors)
        self.plugin_homepage_linkbutton.set_uri(plugin.homepage)
        self.plugin_homepage_linkbutton.set_label(plugin.homepage)
        label = self.plugin_homepage_linkbutton.get_children()[0]
        label.set_ellipsize(Pango.EllipsizeMode.END)
        self.plugin_homepage_linkbutton.set_property('sensitive', True)

        desc_textbuffer = self.plugin_description_textview.get_buffer()
        desc_textbuffer.set_text('')
        txt = plugin.description
        txt.replace('</body>', '')
        if plugin.available_text:
            txt += '<br/><br/>' + _('Warning: %s') % plugin.available_text
        if not txt.startswith('<body '):
            txt = '<body  xmlns=\'http://www.w3.org/1999/xhtml\'>' + txt
        txt += ' </body>'
        self.plugin_description_textview.display_html(txt,
            self.plugin_description_textview, None)

        self.plugin_description_textview.set_property('sensitive', True)
        self.uninstall_plugin_button.set_property('sensitive',
            gajim.PLUGINS_DIRS[1] in plugin.__path__)
        self.configure_plugin_button.set_property(
            'sensitive', not plugin.config_dialog is None)
 def install_from_zip(self, zip_filename, owerwrite=None):
     '''
     Install plagin from zip and return plugin
     '''
     try:
         zip_file = zipfile.ZipFile(zip_filename)
     except zipfile.BadZipfile, e:
         # it is not zip file
         raise PluginsystemError(_('Archive corrupted'))
Example #6
0
 def install_from_zip(self, zip_filename, owerwrite=None):
     '''
     Install plagin from zip and return plugin
     '''
     try:
         zip_file = zipfile.ZipFile(zip_filename)
     except zipfile.BadZipfile, e:
         # it is not zip file
         raise PluginsystemError(_('Archive corrupted'))
Example #7
0
File: gui.py Project: irl/gajim
    def __init__(self, plugin, **kwargs):
        Gtk.Dialog.__init__(self, '%s %s'%(plugin.name, _('Configuration')),
                                                                    **kwargs)
        self.plugin = plugin
        button = self.add_button('gtk-close', Gtk.ResponseType.CLOSE)
        button.connect('clicked', self.on_close_button_clicked)

        self.get_child().set_spacing(3)

        self.init()
Example #8
0
    def __init__(self, plugin, **kwargs):
        Gtk.Dialog.__init__(self,
                            title='%s %s' % (plugin.name, _('Configuration')),
                            **kwargs)
        self.plugin = plugin
        button = self.add_button('gtk-close', Gtk.ResponseType.CLOSE)
        button.connect('clicked', self.on_close_button_clicked)

        self.get_child().set_spacing(3)

        self.init()
Example #9
0
File: gui.py Project: irl/gajim
        def _on_plugin_exists(zip_filename):
            def on_yes(is_checked):
                plugin = gajim.plugin_manager.install_from_zip(zip_filename,
                    True)
                if not plugin:
                    show_warn_dialog()
                    return
                model = self.installed_plugins_model

                for row in list(range(len(model))):
                    if plugin == model[row][PLUGIN]:
                        model.remove(model.get_iter((row, PLUGIN)))
                        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_)

            YesNoDialog(_('Plugin already exists'), sectext=_('Overwrite?'),
                on_response_yes=on_yes, transient_for=self.window)
Example #10
0
File: gui.py Project: irl/gajim
 def on_uninstall_plugin_button_clicked(self, widget):
     selection = self.installed_plugins_treeview.get_selection()
     model, iter = selection.get_selected()
     if iter:
         plugin = model.get_value(iter, PLUGIN)
         plugin_name = model.get_value(iter, NAME)
         is_active = model.get_value(iter, ACTIVE)
         try:
             gajim.plugin_manager.remove_plugin(plugin)
         except PluginsystemError as e:
             WarningDialog(_('Unable to properly remove the plugin'),
                 str(e), self.window)
             return
         model.remove(iter)
Example #11
0
 def on_uninstall_plugin_button_clicked(self, widget):
     selection = self.installed_plugins_treeview.get_selection()
     model, iter = selection.get_selected()
     if iter:
         plugin = model.get_value(iter, PLUGIN)
         plugin_name = model.get_value(iter, NAME)
         is_active = model.get_value(iter, ACTIVE)
         try:
             gajim.plugin_manager.remove_plugin(plugin)
         except PluginsystemError as e:
             WarningDialog(_('Unable to properly remove the plugin'),
                           str(e), self.window)
             return
         model.remove(iter)
Example #12
0
File: gui.py Project: irl/gajim
    def installed_plugins_toggled_cb(self, cell, path):
        is_active = self.installed_plugins_model[path][ACTIVE]
        plugin = self.installed_plugins_model[path][PLUGIN]

        if is_active:
            gajim.plugin_manager.deactivate_plugin(plugin)
        else:
            try:
                gajim.plugin_manager.activate_plugin(plugin)
            except GajimPluginActivateException as e:
                WarningDialog(_('Plugin failed'), str(e),
                    transient_for=self.window)
                return

        self.installed_plugins_model[path][ACTIVE] = not is_active
Example #13
0
    def installed_plugins_toggled_cb(self, cell, path):
        is_active = self.installed_plugins_model[path][ACTIVE]
        plugin = self.installed_plugins_model[path][PLUGIN]

        if is_active:
            gajim.plugin_manager.deactivate_plugin(plugin)
        else:
            try:
                gajim.plugin_manager.activate_plugin(plugin)
            except GajimPluginActivateException as e:
                WarningDialog(_('Plugin failed'),
                              str(e),
                              transient_for=self.window)
                return

        self.installed_plugins_model[path][ACTIVE] = not is_active
Example #14
0
File: gui.py Project: irl/gajim
        def _try_install(zip_filename):
            try:
                plugin = gajim.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_)
Example #15
0
    def install_from_zip(self, zip_filename, owerwrite=None):
        '''
        Install plagin from zip and return plugin
        '''
        try:
            zip_file = zipfile.ZipFile(zip_filename)
        except zipfile.BadZipfile:
            # it is not zip file
            raise PluginsystemError(_('Archive corrupted'))
        except IOError:
            raise PluginsystemError(_('Archive empty'))

        if zip_file.testzip():
            # CRC error
            raise PluginsystemError(_('Archive corrupted'))

        dirs = []
        manifest = None
        for filename in zip_file.namelist():
            if filename.startswith('.') or filename.startswith('/') or \
            ('/' not in filename):
                # members not safe
                raise PluginsystemError(_('Archive is malformed'))
            if filename.endswith('/') and filename.find('/', 0, -1) < 0:
                dirs.append(filename)
            if 'manifest.ini' in filename.split('/')[1]:
                manifest = True
        if not manifest:
            return
        if len(dirs) > 1:
            raise PluginsystemError(_('Archive is malformed'))

        base_dir, user_dir = gajim.PLUGINS_DIRS
        plugin_dir = os.path.join(user_dir, dirs[0])

        if os.path.isdir(plugin_dir):
        # Plugin dir already exists
            if not owerwrite:
                raise PluginsystemError(_('Plugin already exists'))
            self.remove_plugin(self.get_plugin_by_path(plugin_dir))

        zip_file.extractall(user_dir)
        zip_file.close()
        path = os.path.join(user_dir, dirs[0])
        plugins = self.scan_dir_for_plugins(plugin_dir, False)
        if not plugins:
            return
        self.add_plugin(plugins[0])
        plugin = self.plugins[-1]
        return plugin
Example #16
0
    def install_from_zip(self, zip_filename, owerwrite=None):
        '''
        Install plagin from zip and return plugin
        '''
        try:
            zip_file = zipfile.ZipFile(zip_filename)
        except zipfile.BadZipfile:
            # it is not zip file
            raise PluginsystemError(_('Archive corrupted'))
        except IOError:
            raise PluginsystemError(_('Archive empty'))

        if zip_file.testzip():
            # CRC error
            raise PluginsystemError(_('Archive corrupted'))

        dirs = []
        manifest = None
        for filename in zip_file.namelist():
            if filename.startswith('.') or filename.startswith('/') or \
            ('/' not in filename):
                # members not safe
                raise PluginsystemError(_('Archive is malformed'))
            if filename.endswith('/') and filename.find('/', 0, -1) < 0:
                dirs.append(filename)
            if 'manifest.ini' in filename.split('/')[1]:
                manifest = True
        if not manifest:
            return
        if len(dirs) > 1:
            raise PluginsystemError(_('Archive is malformed'))

        base_dir, user_dir = gajim.PLUGINS_DIRS
        plugin_dir = os.path.join(user_dir, dirs[0])

        if os.path.isdir(plugin_dir):
            # Plugin dir already exists
            if not owerwrite:
                raise PluginsystemError(_('Plugin already exists'))
            self.remove_plugin(self.get_plugin_by_path(plugin_dir))

        zip_file.extractall(user_dir)
        zip_file.close()
        path = os.path.join(user_dir, dirs[0])
        plugins = self.scan_dir_for_plugins(plugin_dir, False)
        if not plugins:
            return
        self.add_plugin(plugins[0])
        plugin = self.plugins[-1]
        return plugin
Example #17
0
        def _try_install(zip_filename):
            try:
                plugin = gajim.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_)
Example #18
0
File: gui.py Project: irl/gajim
 def show_warn_dialog():
     text = _('Archive is malformed')
     dialog = WarningDialog(text, '', transient_for=self.window)
     dialog.set_modal(False)
     dialog.popup()
Example #19
0
                try:
                    if not issubclass(module_attr, GajimPlugin) or \
                    module_attr is GajimPlugin:
                        continue
                    log.debug('is subclass of GajimPlugin')
                    module_attr.__path__ = os.path.abspath(
                        os.path.dirname(file_path))

                    # read metadata from manifest.ini
                    conf.readfp(open(manifest_path, 'r'))
                    for option in fields:
                        if conf.get('info', option) is '':
                            raise ConfigParser.NoOptionError, 'field empty'
                        if option == 'description':
                            setattr(module_attr, option, _(conf.get('info', option)))
                            continue
                        setattr(module_attr, option, conf.get('info', option))
                    conf.remove_section('info')

                    plugins_found.append(module_attr)

                except TypeError, type_error:
                    # set plugin localization
                    try:
                        module_attr._ = _
                    except AttributeError, type_error:
                        pass
                except ConfigParser.NoOptionError, type_error:
                    # all fields are required
                    log.debug('%s : %s' % (module_attr_name,
Example #20
0
    def scan_dir_for_plugins(path, scan_dirs=True):
        r'''
        Scans given directory for plugin classes.

        :param path: directory to scan for plugins
        :type path: str

        :return: list of found plugin classes (subclasses of `GajimPlugin`
        :rtype: [] of class objects

        :note: currently it only searches for plugin classes in '\*.py' files
                present in given direcotory `path` (no recursion here)

        :todo: add scanning packages
        :todo: add scanning zipped modules
        '''
        from plugins.plugins_i18n import _
        plugins_found = []
        conf = configparser.ConfigParser()
        fields = ('name', 'short_name', 'version', 'description', 'authors',
                  'homepage')
        if not os.path.isdir(path):
            return plugins_found

        dir_list = os.listdir(path)

        sys.path.insert(0, path)

        for elem_name in dir_list:
            file_path = os.path.join(path, elem_name)

            if os.path.isfile(file_path) and fnmatch.fnmatch(
                    file_path, '*.py'):
                module_name = os.path.splitext(elem_name)[0]
            elif os.path.isdir(file_path) and scan_dirs:
                module_name = elem_name
                file_path += os.path.sep

            manifest_path = os.path.join(os.path.dirname(file_path),
                                         'manifest.ini')
            if scan_dirs and (not os.path.isfile(manifest_path)):
                continue

            # read metadata from manifest.ini
            conf.remove_section('info')
            with open(manifest_path, encoding='utf-8') as conf_file:
                try:
                    conf.read_file(conf_file)
                except configparser.Error:
                    log.warning(("Plugin {plugin} not loaded, error loading"
                                 " manifest").format(plugin=elem_name),
                                exc_info=True)
                    continue

            min_v = conf.get('info', 'min_gajim_version', fallback=None)
            max_v = conf.get('info', 'max_gajim_version', fallback=None)

            gajim_v = gajim.config.get('version').split('-', 1)[0]
            gajim_v_cmp = parse_version(gajim_v)

            if min_v and gajim_v_cmp < parse_version(min_v):
                log.warning(('Plugin {plugin} not loaded, newer version of'
                             'gajim required: {gajim_v} < {min_v}').format(
                                 plugin=elem_name,
                                 gajim_v=gajim_v,
                                 min_v=min_v))
                continue
            if max_v and gajim_v_cmp > parse_version(max_v):
                log.warning(('Plugin {plugin} not loaded, plugin incompatible '
                             'with current version of gajim: '
                             '{gajim_v} > {max_v}').format(plugin=elem_name,
                                                           gajim_v=gajim_v,
                                                           max_v=max_v))
                continue

            module = None

            if module_name in sys.modules:
                # do not load the module twice
                continue
            try:
                module = __import__(module_name)
            except Exception as error:
                log.warning(
                    "While trying to load {plugin}, exception occurred".format(
                        plugin=elem_name),
                    exc_info=sys.exc_info())
                continue

            if module is None:
                continue

            log.debug('Attributes processing started')
            for module_attr_name in [
                    attr_name for attr_name in dir(module) if not (
                        attr_name.startswith('__') or attr_name.endswith('__'))
            ]:
                module_attr = getattr(module, module_attr_name)
                log.debug('%s : %s' % (module_attr_name, module_attr))

                try:
                    if not issubclass(module_attr, GajimPlugin) or \
                    module_attr is GajimPlugin:
                        continue
                    log.debug('is subclass of GajimPlugin')
                    module_attr.__path__ = os.path.abspath(
                        os.path.dirname(file_path))

                    for option in fields:
                        if conf.get('info', option) is '':
                            raise configparser.NoOptionError('field empty')
                        if option == 'description':
                            setattr(module_attr, option,
                                    _(conf.get('info', option)))
                            continue
                        setattr(module_attr, option, conf.get('info', option))

                    plugins_found.append(module_attr)
                except TypeError:
                    # set plugin localization
                    try:
                        module_attr._ = _
                    except AttributeError:
                        pass
                except configparser.NoOptionError:
                    # all fields are required
                    log.debug(
                        '%s : %s' %
                        (module_attr_name,
                         'wrong manifest file. all fields are required!'))
                except configparser.NoSectionError:
                    # info section are required
                    log.debug(
                        '%s : %s' %
                        (module_attr_name,
                         'wrong manifest file. info section are required!'))
                except configparser.MissingSectionHeaderError:
                    # info section are required
                    log.debug('%s : %s' %
                              (module_attr_name,
                               'wrong manifest file. section are required!'))

        return plugins_found
Example #21
0
    def scan_dir_for_plugins(path, scan_dirs=True):
        '''
        Scans given directory for plugin classes.

        :param path: directory to scan for plugins
        :type path: str

        :return: list of found plugin classes (subclasses of `GajimPlugin`
        :rtype: [] of class objects

        :note: currently it only searches for plugin classes in '\*.py' files
                present in given direcotory `path` (no recursion here)

        :todo: add scanning packages
        :todo: add scanning zipped modules
        '''
        from plugins.plugins_i18n import _
        plugins_found = []
        conf = configparser.ConfigParser()
        fields = ('name', 'short_name', 'version', 'description', 'authors',
            'homepage')
        if not os.path.isdir(path):
            return plugins_found

        dir_list = os.listdir(path)

        sys.path.insert(0, path)

        for elem_name in dir_list:
            file_path = os.path.join(path, elem_name)

            if os.path.isfile(file_path) and fnmatch.fnmatch(file_path, '*.py'):
                module_name = os.path.splitext(elem_name)[0]
            elif os.path.isdir(file_path) and scan_dirs:
                module_name = elem_name
                file_path += os.path.sep

            manifest_path = os.path.join(os.path.dirname(file_path),
                'manifest.ini')
            if scan_dirs and (not os.path.isfile(manifest_path)):
                continue

            # read metadata from manifest.ini
            conf.remove_section('info')
            conf_file = open(manifest_path)
            conf.read_file(conf_file)
            conf_file.close()

            try:
                min_v = conf.get('info', 'min_gajim_version')
            except Exception:
                min_v = None
            try:
                max_v = conf.get('info', 'max_gajim_version')
            except Exception:
                max_v = None

            gajim_v = gajim.config.get('version')
            gajim_v = gajim_v.split('-', 1)[0]
            gajim_v = gajim_v.split('.')

            if min_v:
                min_v = min_v.split('.')
                if gajim_v < min_v:
                    continue
            if max_v:
                max_v = max_v.split('.')
                if gajim_v > max_v:
                    continue


            module = None

            if module_name in sys.modules:
            # do not load the module twice
                continue
            try:
                module = __import__(module_name)
            except ValueError as value_error:
                log.debug(str(value_error))
            except ImportError as import_error:
                log.debug(str(import_error))

            if module is None:
                continue

            log.debug('Attributes processing started')
            for module_attr_name in [attr_name for attr_name in dir(module)
            if not (attr_name.startswith('__') or attr_name.endswith('__'))]:
                module_attr = getattr(module, module_attr_name)
                log.debug('%s : %s' % (module_attr_name, module_attr))

                try:
                    if not issubclass(module_attr, GajimPlugin) or \
                    module_attr is GajimPlugin:
                        continue
                    log.debug('is subclass of GajimPlugin')
                    module_attr.__path__ = os.path.abspath(
                        os.path.dirname(file_path))

                    for option in fields:
                        if conf.get('info', option) is '':
                            raise configparser.NoOptionError('field empty')
                        if option == 'description':
                            setattr(module_attr, option, _(conf.get('info', option)))
                            continue
                        setattr(module_attr, option, conf.get('info', option))

                    plugins_found.append(module_attr)
                except TypeError:
                    # set plugin localization
                    try:
                        module_attr._ = _
                    except AttributeError:
                        pass
                except configparser.NoOptionError:
                    # all fields are required
                    log.debug('%s : %s' % (module_attr_name,
                        'wrong manifest file. all fields are required!'))
                except configparser.NoSectionError:
                    # info section are required
                    log.debug('%s : %s' % (module_attr_name,
                        'wrong manifest file. info section are required!'))
                except configparser.MissingSectionHeaderError:
                    # info section are required
                    log.debug('%s : %s' % (module_attr_name,
                        'wrong manifest file. section are required!'))

        return plugins_found
Example #22
0
 def show_warn_dialog():
     text = _('Archive is malformed')
     dialog = WarningDialog(text, '', transient_for=self.window)
     dialog.set_modal(False)
     dialog.popup()
Example #23
0
    def __init__(self):
        '''Initialize Plugins window'''
        self.xml = gtkgui_helpers.get_gtk_builder('plugins_window.ui')
        self.window = self.xml.get_object('plugins_window')
        self.window.set_transient_for(gajim.interface.roster.window)

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

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

        self.plugin_description_textview = HtmlTextView()
        sw = self.xml.get_object('scrolledwindow2')
        sw.add(self.plugin_description_textview)
        self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool,
                                                     GdkPixbuf.Pixbuf)
        self.installed_plugins_treeview.set_model(self.installed_plugins_model)
        self.installed_plugins_treeview.set_rules_hint(True)

        renderer = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(_('Plugin'))  #, renderer, text=NAME)
        cell = Gtk.CellRendererPixbuf()
        col.pack_start(cell, False)
        col.add_attribute(cell, 'pixbuf', ICON)
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', 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=ACTIVE,
                                 activatable=ACTIVATABLE)
        self.installed_plugins_treeview.append_column(col)

        self.def_icon = gtkgui_helpers.get_icon_pixmap('preferences-desktop')

        # 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)

        self.xml.connect_signals(self)

        self.plugins_notebook.set_current_page(0)
        self.xml.get_object('close_button').grab_focus()

        self.window.show_all()
        gtkgui_helpers.possibly_move_window_in_current_desktop(self.window)
                    log.debug('is subclass of GajimPlugin')
                    module_attr.__path__ = os.path.abspath(
                        os.path.dirname(file_path))

                    # read metadata from manifest.ini
                    print 494, "read METADATA"
                    conf.readfp(open(manifest_path, 'r'))
                    for option in fields:
                        print 497, "option", option
                        if conf.get('info', option) is '':
                            print 499, "field is empty"
                            raise ConfigParser.NoOptionError, 'field empty'
                        if option == 'description':
                            print 502, "parse option"
                            setattr(module_attr, option,
                                    _(conf.get('info', option)))
                            print 504, "parsed"
                            continue
                        setattr(module_attr, option, conf.get('info', option))
                        print 507, "was set"
                    conf.remove_section('info')
                    print "was removed"
                    plugins_found.append(module_attr)

                except TypeError, type_error:
                    # set plugin localization
                    print 514, "TypeError", module_attr_name
                    try:
                        module_attr._ = _
                    except AttributeError, type_error:
                        pass