/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to viz/treeview.py

  • Committer: Daniel Schierbeck
  • Date: 2007-10-20 21:43:04 UTC
  • Revision ID: daniel.schierbeck@gmail.com-20071020214304-t301wk5rbzf15j6o
Made forward/back buttons work again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    def get_parents(self):
40
40
        return self.parents
41
41
 
 
42
    def set_branch(self, branch, start, maxnum):
 
43
        self.branch = branch
 
44
 
 
45
        gobject.idle_add(self.populate, start, maxnum)
 
46
 
 
47
    def back(self):
 
48
        (path, col) = self.treeview.get_cursor()
 
49
        revision = self.model[path][treemodel.REVISION]
 
50
        parents = self.model[path][treemodel.PARENTS]
 
51
        if not len(parents):
 
52
            return
 
53
 
 
54
        for parent_id in parents:
 
55
            parent_index = self.index[parent_id]
 
56
            parent = self.model[parent_index][treemodel.REVISION]
 
57
            if same_branch(revision, parent):
 
58
                self.treeview.set_cursor(parent_index)
 
59
                break
 
60
        else:
 
61
            self.treeview.set_cursor(self.index[parents[0]])
 
62
        self.treeview.grab_focus()
 
63
 
 
64
    def forward(self):
 
65
        (path, col) = self.treeview.get_cursor()
 
66
        revision = self.model[path][treemodel.REVISION]
 
67
        children = self.model[path][treemodel.CHILDREN]
 
68
        if not len(children):
 
69
            return
 
70
 
 
71
        for child_id in children:
 
72
            child_index = self.index[child_id]
 
73
            child = self.model[child_index][treemodel.REVISION]
 
74
            if same_branch(child, revision):
 
75
                self.treeview.set_cursor(child_index)
 
76
                break
 
77
        else:
 
78
            self.treeview.set_cursor(self.index[children[0]])
 
79
        self.treeview.grab_focus()
 
80
 
 
81
    def populate(self, start, maxnum):
 
82
        self.branch.lock_read()
 
83
 
 
84
        (linegraphdata, index, columns_len) = linegraph(self.branch,
 
85
                                                        start,
 
86
                                                        maxnum)
 
87
 
 
88
        self.model = TreeModel(self.branch, linegraphdata)
 
89
        self.graph_cell.columns_len = columns_len
 
90
        width = self.graph_cell.get_size(self.treeview)[2]
 
91
        self.graph_column.set_fixed_width(width)
 
92
        self.graph_column.set_max_width(width)
 
93
        self.index = index
 
94
        self.treeview.set_model(self.model)
 
95
        self.treeview.set_cursor(0)
 
96
 
 
97
        return False
 
98
 
42
99
    def construct_treeview(self):
43
100
        self.treeview = gtk.TreeView()
44
101
 
102
159
        column.add_attribute(cell, "text", treemodel.COMMITER)
103
160
        self.treeview.append_column(column)
104
161
 
105
 
    def set_branch(self, branch, start, maxnum):
106
 
        self.branch = branch
107
 
 
108
 
        gobject.idle_add(self.populate, start, maxnum)
109
 
 
110
 
    def populate(self, start, maxnum):
111
 
        self.branch.lock_read()
112
 
 
113
 
        (linegraphdata, index, columns_len) = linegraph(self.branch,
114
 
                                                        start,
115
 
                                                        maxnum)
116
 
 
117
 
        self.model = TreeModel(self.branch, linegraphdata)
118
 
        self.graph_cell.columns_len = columns_len
119
 
        width = self.graph_cell.get_size(self.treeview)[2]
120
 
        self.graph_column.set_fixed_width(width)
121
 
        self.graph_column.set_max_width(width)
122
 
        self.index = index
123
 
        self.treeview.set_model(self.model)
124
 
        self.treeview.get_selection().select_path(0)
125
 
 
126
 
        return False
127
 
    
128
162
    def _on_selection_changed(self, selection, *args):
129
163
        """callback for when the treeview changes."""
130
164
        (model, selected_rows) = selection.get_selected_rows()