/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-11-22 00:25:35 UTC
  • mfrom: (401.1.3 dynamic-branch)
  • Revision ID: daniel.schierbeck@gmail.com-20071122002535-sli6q0dvme6wtjvv
Merged dynamic treeview refreshing branch.

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
 
158
174
    def back(self):
159
175
        """Signal handler for the Back button."""
160
176
        parents = self.get_parents()
185
201
        else:
186
202
            self.set_revision_id(children[0])
187
203
 
188
 
    def populate(self, start, maxnum, broken_line_length=None):
 
204
    def populate(self, revision=None):
189
205
        """Fill the treeview with contents.
190
206
 
191
207
        :param start: Revision id of revision to start with.
194
210
        :param broken_line_length: After how much lines branches \
195
211
                       should be broken.
196
212
        """
 
213
 
 
214
        if self.compact:
 
215
            broken_line_length = 32
 
216
        else:
 
217
            broken_line_length = None
 
218
 
197
219
        self.branch.lock_read()
198
220
        (linegraphdata, index, columns_len) = linegraph(self.branch.repository,
199
 
                                                        start,
200
 
                                                        maxnum, 
 
221
                                                        self.start,
 
222
                                                        self.maxnum, 
201
223
                                                        broken_line_length)
202
224
 
203
225
        self.model = TreeModel(self.branch.repository, linegraphdata)
207
229
        self.graph_column.set_max_width(width)
208
230
        self.index = index
209
231
        self.treeview.set_model(self.model)
210
 
        self.treeview.set_cursor(0)
 
232
 
 
233
        if revision is None:
 
234
            self.treeview.set_cursor(0)
 
235
        else:
 
236
            self.set_revision(revision)
 
237
 
211
238
        self.emit('revisions-loaded')
212
239
 
213
240
        return False