Exemple #1
0
    def show_tags_dialog_cb(self, widget):
        """Show Tags dialog."""

        self.tags_mode = True
        tags_box = self.tags_box
        self.switcher.set_current_page(1)
        for child in tags_box.get_children():
            tags_box.remove(child)
        is_exists_default_tag = False
        for tag in self.database().get_tags():
            hbox = widgets.create_tag_checkbox(unicode(tag.name), \
                tag.name in self.selected_tags)
            tags_box.pack_start(hbox)
            if tag.name == u"<default>":
                is_exists_default_tag = True
        if not is_exists_default_tag:
            tag = widgets.create_tag_checkbox(u"<default>", True)
            tags_box.pack_start(tag)
Exemple #2
0
    def add_new_tag_cb(self, widget):
        """Create new tag."""

        new_tag = self.new_tag_entry.get_text()
        box_tags = [hbox.get_children()[1].get_label() for \
            hbox in self.tags_box.get_children()]
        if new_tag and not new_tag in box_tags:
            tag_widget = widgets.create_tag_checkbox(new_tag, True)
            self.tags_box.pack_start(tag_widget)
            self.tags_box.reorder_child(tag_widget, 0)
            self.new_tag_entry.set_text("")
Exemple #3
0
    def display_criterion(self, criterion):
        """Display current criterion."""

        tags_box = self.tags_box
        for child in tags_box.get_children():
            tags_box.remove(child)
        for tag in self.database().get_tags():
            self.tags_dict[tag.name] = tag._id
            cards_count = self.database().total_card_count_for__tag_id(tag._id)
            tags_box.pack_start(widgets.create_tag_checkbox(tag.name + \
                unicode(" (%s cards)" % cards_count), \
                tag._id in criterion.active_tag__ids))
Exemple #4
0
    def display_criterion(self, criterion):
        """Display current criterion."""

        tags_box = self.tags_box
        for child in tags_box.get_children():
            tags_box.remove(child)
        for tag in self.database().get_tags():
            self.tags_dict[tag.name] = tag._id
            # get cards count for tag
            cards_count = sum([ \
                self.database().card_count_for_grade_and__tag_id( \
                    grade, tag._id) for grade in range(-1, 6)])
            tags_box.pack_start(widgets.create_tag_checkbox(tag.name + \
                unicode(" (%s cards)" % cards_count), \
                tag._id in criterion.active_tag__ids))