Exemplo n.º 1
0
    def update_model(self, a=None, b=None, expand=False):
        self.janitor_model.clear()
        self.result_model.clear()
        size_list = []

        loader = ModuleLoader('janitor')
        plugin_to_load = self.plugins_setting.get_value()

        system_text = _('System')
        iter = self.janitor_model.append(
            None, (None, icon.get_from_name('distributor-logo'), system_text,
                   "<b><big>%s</big></b>" % system_text, None, None, None))

        for plugin in loader.get_modules_by_category('system'):
            if plugin.is_user_extension() and plugin.get_name(
            ) not in plugin_to_load:
                log.debug("User extension: %s not in setting to load" %
                          plugin.get_name())
                continue
            size_list.append(
                Gtk.Label(
                    label=plugin.get_title()).get_layout().get_pixel_size()[0])
            self.janitor_model.append(
                iter, (False, None, plugin.get_title(), plugin.get_title(),
                       plugin(), None, None))

        personal_text = _('Personal')

        iter = self.janitor_model.append(
            None, (None, icon.get_from_name('system-users'), personal_text,
                   "<b><big>%s</big></b>" % personal_text, None, None, None))

        for plugin in loader.get_modules_by_category('personal'):
            if plugin.is_user_extension() and plugin.get_name(
            ) not in plugin_to_load:
                log.debug("User extension: %s not in setting to load" %
                          plugin.get_name())
                continue
            size_list.append(
                Gtk.Label(
                    label=plugin.get_title()).get_layout().get_pixel_size()[0])
            self.janitor_model.append(
                iter, (False, None, plugin.get_title(), plugin.get_title(),
                       plugin(), None, None))

        app_text = _('Apps')

        iter = self.janitor_model.append(
            None, (None, icon.get_from_name('gnome-app-install'), app_text,
                   "<b><big>%s</big></b>" % app_text, None, None, None))

        for plugin in loader.get_modules_by_category('application'):
            if plugin.is_user_extension() and plugin.get_name(
            ) not in plugin_to_load:
                log.debug("User extension: %s not in setting to load" %
                          plugin.get_name())
                continue
            size_list.append(
                Gtk.Label(
                    label=plugin.get_title()).get_layout().get_pixel_size()[0])
            self.janitor_model.append(
                iter, (False, None, plugin.get_title(), plugin.get_title(),
                       plugin(), None, None))
        if size_list:
            self.max_janitor_view_width = max(size_list) + 80

        if expand:
            self._expand_janitor_view()