Exemple #1
0
    def rule(self):
        r = Rule(self.fm)
        r.color = unicode(self.color_box.currentText())
        idx = self.column_box.currentIndex()
        col = unicode(self.column_box.itemData(idx).toString())
        for c in self.conditions:
            condition = c.condition
            if condition is not None:
                r.add_condition(*condition)

        return col, r
Exemple #2
0
    def rule(self):
        r = Rule(self.fm)
        if self.rule_kind != 'color':
            r.color = self.get_filenames_from_box()
        else:
            r.color = self.color_box.color
        idx = self.column_box.currentIndex()
        col = unicode_type(self.column_box.itemData(idx) or '')
        for c in self.conditions:
            condition = c.condition
            if condition is not None:
                r.add_condition(*condition)
        if self.rule_kind == 'icon':
            kind = unicode_type(self.kind_box.itemData(
                                    self.kind_box.currentIndex()) or '')
        else:
            kind = self.rule_kind

        return kind, col, r
Exemple #3
0
 def validate(self):
     r = Rule(self.fm)
     for c in self.conditions:
         condition = c.condition
         if condition is not None:
             try:
                 r.add_condition(*condition)
             except Exception as e:
                 import traceback
                 error_dialog(self, _('Invalid condition'),
                         _('One of the conditions for this rule is'
                             ' invalid: <b>%s</b>')%e,
                         det_msg=traceback.format_exc(), show=True)
                 return False
     if len(r.conditions) < 1:
         error_dialog(self, _('No conditions'),
                 _('You must specify at least one non-empty condition'
                     ' for this rule'), show=True)
         return False
     return True
Exemple #4
0
    def rule(self):
        r = Rule(self.fm)
        if self.rule_kind != 'color':
            r.color = unicode(self.filename_box.currentText())
        else:
            r.color = unicode(self.color_box.currentText())
        idx = self.column_box.currentIndex()
        col = unicode(self.column_box.itemData(idx).toString())
        for c in self.conditions:
            condition = c.condition
            if condition is not None:
                r.add_condition(*condition)
        if self.rule_kind == 'icon':
            kind = unicode(
                self.kind_box.itemData(
                    self.kind_box.currentIndex()).toString())
        else:
            kind = 'color'

        return kind, col, r