/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 branchview/treeview.py

  • Committer: Daniel Schierbeck
  • Date: 2008-01-13 14:12:49 UTC
  • mto: (423.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 429.
  • Revision ID: daniel.schierbeck@gmail.com-20080113141249-gd0i2lknr3yik55r
Moved branch view to its own package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
                                 'Date',
59
59
                                 'Show date column',
60
60
                                 False,
61
 
                                 gobject.PARAM_READWRITE)
 
61
                                 gobject.PARAM_READWRITE),
 
62
 
 
63
        'compact': (gobject.TYPE_BOOLEAN,
 
64
                    'Compact view',
 
65
                    'Break ancestry lines to save space',
 
66
                    True,
 
67
                    gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE)
62
68
 
63
69
    }
64
70
 
71
77
                              ())
72
78
    }
73
79
 
74
 
    def __init__(self, branch, start, maxnum, broken_line_length=None):
 
80
    def __init__(self, branch, start, maxnum, compact=True):
75
81
        """Create a new TreeView.
76
82
 
77
83
        :param branch: Branch object for branch to show.
91
97
        self.iter   = None
92
98
        self.branch = branch
93
99
 
94
 
        gobject.idle_add(self.populate, start, maxnum, 
95
 
                         broken_line_length)
 
100
        self.start = start
 
101
        self.maxnum = maxnum
 
102
        self.compact = compact
 
103
 
 
104
        gobject.idle_add(self.populate)
96
105
 
97
106
        self.connect("destroy", lambda x: self.branch.unlock())
98
107
 
101
110
            return self.revno_column.get_visible()
102
111
        elif property.name == 'date-column-visible':
103
112
            return self.date_column.get_visible()
 
113
        elif property.name == 'compact':
 
114
            return self.compact
104
115
        elif property.name == 'branch':
105
116
            return self.branch
106
117
        elif property.name == 'revision':
119
130
            self.revno_column.set_visible(value)
120
131
        elif property.name == 'date-column-visible':
121
132
            self.date_column.set_visible(value)
 
133
        elif property.name == 'compact':
 
134
            self.compact = value
122
135
        elif property.name == 'branch':
123
136
            self.branch = value
124
137
        elif property.name == 'revision':
155
168
        """
156
169
        return self.get_property('parents')
157
170
        
 
171
    def refresh(self):
 
172
        gobject.idle_add(self.populate, self.get_revision())
 
173
 
 
174
    def update(self):
 
175
        try:
 
176
            self.branch.unlock()
 
177
            try:
 
178
                self.branch.lock_write()
 
179
                self.branch.update()
 
180
            finally:
 
181
                self.branch.unlock()
 
182
        finally:
 
183
            self.branch.lock_read()
 
184
 
158
185
    def back(self):
159
186
        """Signal handler for the Back button."""
160
187
        parents = self.get_parents()
185
212
        else:
186
213
            self.set_revision_id(children[0])
187
214
 
188
 
    def populate(self, start, maxnum, broken_line_length=None):
 
215
    def populate(self, revision=None):
189
216
        """Fill the treeview with contents.
190
217
 
191
218
        :param start: Revision id of revision to start with.
194
221
        :param broken_line_length: After how much lines branches \
195
222
                       should be broken.
196
223
        """
 
224
 
 
225
        if self.compact:
 
226
            broken_line_length = 32
 
227
        else:
 
228
            broken_line_length = None
 
229
 
197
230
        self.branch.lock_read()
198
231
        (linegraphdata, index, columns_len) = linegraph(self.branch.repository,
199
 
                                                        start,
200
 
                                                        maxnum, 
 
232
                                                        self.start,
 
233
                                                        self.maxnum, 
201
234
                                                        broken_line_length)
202
235
 
203
236
        self.model = TreeModel(self.branch.repository, linegraphdata)
204
237
        self.graph_cell.columns_len = columns_len
205
238
        width = self.graph_cell.get_size(self.treeview)[2]
 
239
        if width > 500:
 
240
            width = 500
206
241
        self.graph_column.set_fixed_width(width)
207
242
        self.graph_column.set_max_width(width)
208
243
        self.index = index
209
244
        self.treeview.set_model(self.model)
210
 
        self.treeview.set_cursor(0)
 
245
 
 
246
        if revision is None:
 
247
            self.treeview.set_cursor(0)
 
248
        else:
 
249
            self.set_revision(revision)
 
250
 
211
251
        self.emit('revisions-loaded')
212
252
 
213
253
        return False
289
329
        self.msg_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
290
330
        self.msg_column.set_fixed_width(cell.get_size(self.treeview)[2])
291
331
        self.msg_column.pack_start(cell, expand=True)
292
 
        self.msg_column.add_attribute(cell, "text", treemodel.MESSAGE)
 
332
        self.msg_column.add_attribute(cell, "markup", treemodel.MESSAGE)
293
333
        self.treeview.append_column(self.msg_column)
294
334
 
295
335
        cell = gtk.CellRendererText()