示例#1
0
    def __init__(self, index, ui):
        self.index = index
        self.ui = ui
        self.current_tag = None

        self.model = gtk.ListStore(str, int, str)  # PAGE_COL, TAGS_COL
        SingleClickTreeView.__init__(self, self.model)

        cells = (('Page', self.PAGE_COL, True), ('N', self.TAGS_N_COL, False),
                 ('Tags', self.TAGS_COL, True))
        for name, col_id, expand in (cells):
            cell = gtk.CellRendererText()
            cell.set_property('ellipsize', pango.ELLIPSIZE_END)
            cell.set_property('cell-background', 'white')
            col = gtk.TreeViewColumn(name, cell)
            col.set_attributes(cell, text=col_id)
            col.set_resizable(expand)
            col.set_expand(expand)
            col.set_sort_column_id(col_id)
            self.append_column(col)

        self.connect(
            'row-activated',
            lambda treeview, path, column: self.row_activated(path, column))
        self.refill_model()
示例#2
0
    def __init__(self, parent, notebook):
        Dialog.__init__(
            self,
            parent,
            _('Pages By Number Of Links'),  # T: dialog title
            buttons=gtk.BUTTONS_CLOSE)
        self.notebook = notebook

        self.direction_input = gtk.combo_box_new_text()
        for dir in sorted(self.LABELS):
            self.direction_input.append_text(self.LABELS[dir])

        self.uistate.setdefault('link_direction', LINK_DIR_BACKWARD,
                                self.LABELS.keys())
        gtk_combobox_set_active_text(
            self.direction_input, self.LABELS[self.uistate['link_direction']])
        self.direction_input.connect('changed',
                                     self.on_direction_input_changed)

        hbox = gtk.HBox()
        hbox.pack_start(gtk.Label(_('Trace Links') + ':'), False)
        hbox.add(self.direction_input)
        self.vbox.pack_start(hbox, False)

        self.listview = SingleClickTreeView(gtk.ListStore(int, str))
        self.listview.set_reorderable(True)
        for i, label in enumerate((_('#'), _('Page'))):
            column = gtk.TreeViewColumn(label, gtk.CellRendererText(), text=i)
            column.set_sort_column_id(i)
            self.listview.append_column(column)
        # TODO: self.listview.connect('row-activated', self.on_row_activated())

        self.vbox.add(ScrolledWindow(self.listview))
        self.populate_listview()
示例#3
0
    def __init__(self, index, preferences):
        self.index = index
        # Icons corresponding to tags, prevent unnecessary changing.
        self.icons_for_tags = preferences.copy()

        self.model = gtk.ListStore(
            str, gtk.gdk.Pixbuf, str,
            int)  # TAG_COL, ICON_COL, ICON_NAME, N_PAGES_COL
        SingleClickTreeView.__init__(self, self.model)

        cells = (('Tags', self.TAG_COL, True), ('Pages', self.N_PAGES_COL,
                                                False))
        for name, col_id, expand in (cells):
            cell = gtk.CellRendererText()
            cell.set_property('ellipsize', pango.ELLIPSIZE_END)
            cell.set_property('cell-background', 'white')
            col = gtk.TreeViewColumn(name, cell)
            col.set_attributes(cell, text=col_id)
            col.set_resizable(expand)
            col.set_expand(expand)
            col.set_sort_column_id(col_id)
            self.append_column(col)

        cell = gtk.CellRendererPixbuf()
        cell.set_property('cell-background', 'white')
        col = gtk.TreeViewColumn('Icon', cell)
        col.set_attributes(cell, pixbuf=self.ICON_COL)
        col.set_resizable(False)
        col.set_expand(False)
        col.set_sort_column_id(self.ICON_NAME)
        self.append_column(col)

        self.refill_model()
示例#4
0
    def __init__(self, index, ui):
        self.tagview = TagsView.new_from_index(index)
        self.ui = ui
        self.current_tag = None

        self.model = gtk.ListStore(str, int, str) # PAGE_COL, TAGS_COL
        SingleClickTreeView.__init__(self, self.model)

        cells = (('Page', self.PAGE_COL, True),
                 ('N', self.TAGS_N_COL, False),
                 ('Tags', self.TAGS_COL, True))
        for name, col_id, expand in cells:
            cell = gtk.CellRendererText()
            cell.set_property('ellipsize', pango.ELLIPSIZE_END)
            cell.set_property('cell-background', 'white')
            col = gtk.TreeViewColumn(name, cell)
            col.set_attributes(cell, text = col_id)
            col.set_resizable(expand)
            col.set_expand(expand)
            col.set_sort_column_id(col_id)
            self.append_column(col)

        self.connect('row-activated', lambda treeview, path, column:
                              self.row_activated(path, column))
        self.refill_model()
示例#5
0
    def __init__(self, index, preferences):
        self.index = index
        # Icons corresponding to tags, prevent unnecessary changing.
        self.icons_for_tags = preferences.copy()

        self.model = gtk.ListStore(str, gtk.gdk.Pixbuf, str, int) # TAG_COL, ICON_COL, ICON_NAME, N_PAGES_COL
        SingleClickTreeView.__init__(self, self.model)

        cells = (('Tags', self.TAG_COL, True),
                 ('Pages', self.N_PAGES_COL, False))
        for name, col_id, expand in cells:
            cell = gtk.CellRendererText()
            cell.set_property('ellipsize', pango.ELLIPSIZE_END)
            cell.set_property('cell-background', 'white')
            col = gtk.TreeViewColumn(name, cell)
            col.set_attributes(cell, text = col_id)
            col.set_resizable(expand)
            col.set_expand(expand)
            col.set_sort_column_id(col_id)
            self.append_column(col)

        cell = gtk.CellRendererPixbuf()
        cell.set_property('cell-background', 'white')
        col = gtk.TreeViewColumn('Icon', cell)
        col.set_attributes(cell, pixbuf = self.ICON_COL)
        col.set_resizable(False)
        col.set_expand(False)
        col.set_sort_column_id(self.ICON_NAME)
        self.append_column(col)

        self.refill_model()
示例#6
0
    def __init__(self, task_list):
        model = Gtk.ListStore(str, int, int,
                              int)  # tag name, number of tasks, type, weight
        SingleClickTreeView.__init__(self, model)
        self.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
        self.task_list = task_list

        column = Gtk.TreeViewColumn(_('Tags'))
        # T: Column header for tag list in Task List dialog
        self.append_column(column)

        cr1 = Gtk.CellRendererText()
        cr1.set_property('ellipsize', Pango.EllipsizeMode.END)
        column.pack_start(cr1, True)
        column.set_attributes(cr1, text=0, weight=3)  # tag name, weight

        cr2 = self.get_cell_renderer_number_of_items()
        column.pack_start(cr2, False)
        column.set_attributes(cr2, text=1)  # number of tasks

        self.set_row_separator_func(
            lambda m, i: m[i][2] == self._type_separator)

        self._block_selection_change = False
        self.get_selection().connect('changed', self.on_selection_changed)

        self.refresh(task_list)
示例#7
0
    def __init__(self, task_list):
        model = gtk.ListStore(str, int, int, int)  # tag name, number of tasks, type, weight
        SingleClickTreeView.__init__(self, model)
        self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.task_list = task_list

        column = gtk.TreeViewColumn(_('Tags'))
            # T: Column header for tag list in Task List dialog
        self.append_column(column)

        cr1 = gtk.CellRendererText()
        cr1.set_property('ellipsize', pango.ELLIPSIZE_END)
        column.pack_start(cr1, True)
        column.set_attributes(cr1, text=0, weight=3)  # tag name, weight

        cr2 = self.get_cell_renderer_number_of_items()
        column.pack_start(cr2, False)
        column.set_attributes(cr2, text=1)  # number of tasks

        self.set_row_separator_func(lambda m, i: m[i][2] == self._type_separator)

        self._block_selection_change = False
        self.get_selection().connect('changed', self.on_selection_changed)

        self.refresh(task_list)
示例#8
0
class PagesByNumberOfLinksDialog(Dialog):

    LABELS = {
        LINK_DIR_FORWARD: _('Forward'),
        LINK_DIR_BACKWARD: _('Backward'),
        #LINK_DIR_BOTH: _('Both'),
    }

    def __init__(self, parent, notebook):
        Dialog.__init__(
            self,
            parent,
            _('Pages By Number Of Links'),  # T: dialog title
            buttons=gtk.BUTTONS_CLOSE)
        self.notebook = notebook

        self.direction_input = gtk.combo_box_new_text()
        for dir in sorted(self.LABELS):
            self.direction_input.append_text(self.LABELS[dir])

        self.uistate.setdefault('link_direction', LINK_DIR_BACKWARD,
                                self.LABELS.keys())
        gtk_combobox_set_active_text(
            self.direction_input, self.LABELS[self.uistate['link_direction']])
        self.direction_input.connect('changed',
                                     self.on_direction_input_changed)

        hbox = gtk.HBox()
        hbox.pack_start(gtk.Label(_('Trace Links') + ':'), False)
        hbox.add(self.direction_input)
        self.vbox.pack_start(hbox, False)

        self.listview = SingleClickTreeView(gtk.ListStore(int, str))
        self.listview.set_reorderable(True)
        for i, label in enumerate((_('#'), _('Page'))):
            column = gtk.TreeViewColumn(label, gtk.CellRendererText(), text=i)
            column.set_sort_column_id(i)
            self.listview.append_column(column)
        # TODO: self.listview.connect('row-activated', self.on_row_activated())

        self.vbox.add(ScrolledWindow(self.listview))
        self.populate_listview()

    def get_direction(self):
        label = self.direction_input.get_active_text()
        for k, v in self.LABELS.items():
            if v == label:
                return k
        else:
            raise ValueError

    def on_direction_input_changed(self, *a):
        self.uistate['link_direction'] = self.get_direction()
        self.populate_listview()

    def populate_listview(self):
        model = self.listview.get_model()
        model.clear()
        for i, page in sort_by_number_of_links(self.notebook,
                                               self.get_direction()):
            model.append((i, page))