/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 commit.py

  • Committer: John Arbash Meinel
  • Date: 2007-10-01 20:30:54 UTC
  • mto: (322.1.1 trunk) (330.3.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 368.
  • Revision ID: john@arbash-meinel.com-20071001203054-uizh8fzgp29gtnuc
Hook up the list of modified files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
 
109
109
         self.setup_params()
110
110
         self.construct()
 
111
         # These could potentially be set based on the size of your monitor.
 
112
         # But for now, they seem like a reasonable default
111
113
         self.set_default_size(800, 600)
 
114
         self._hpane.set_position(300)
112
115
         self.fill_in_data()
113
116
 
114
117
    def setup_params(self):
122
125
    def fill_in_data(self):
123
126
        # Now that we are built, handle changes to the view based on the state
124
127
        self._fill_in_pending()
 
128
        self._fill_in_files()
125
129
 
126
130
    def _fill_in_pending(self):
127
131
        if not self._pending:
131
135
        # TODO: We'd really prefer this to be a nested list
132
136
        for rev, children in self._pending:
133
137
            rev_info = self._rev_to_pending_info(rev)
134
 
            self._pending_liststore.append([
 
138
            self._pending_store.append([
135
139
                rev_info['revision_id'],
136
140
                rev_info['date'],
137
141
                rev_info['committer'],
139
143
                ])
140
144
            for child in children:
141
145
                rev_info = self._rev_to_pending_info(child)
142
 
                self._pending_liststore.append([
 
146
                self._pending_store.append([
143
147
                    rev_info['revision_id'],
144
148
                    rev_info['date'],
145
149
                    rev_info['committer'],
147
151
                    ])
148
152
        self._pending_box.show()
149
153
 
 
154
    def _fill_in_files(self):
 
155
        # We should really use _iter_changes, and then add a progress bar of
 
156
        # some kind.
 
157
        self._compute_delta()
 
158
 
 
159
        # While we fill in the view, hide the store
 
160
        store = self._files_store
 
161
        self._treeview_files.set_model(None)
 
162
 
 
163
        added = _('added')
 
164
        removed = _('removed')
 
165
        renamed = _('renamed')
 
166
        renamed_and_modified = _('renamed and modified')
 
167
        modified = _('modified')
 
168
 
 
169
        # [file_id, real path, checkbox, display path, changes type]
 
170
        for path, file_id, kind in self._delta.added:
 
171
            marker = osutils.kind_marker(kind)
 
172
            store.append([file_id, path, True, path+marker, added])
 
173
 
 
174
        for path, file_id, kind in self._delta.removed:
 
175
            marker = osutils.kind_marker(kind)
 
176
            store.append([file_id, path, True, path+marker, removed])
 
177
 
 
178
        for oldpath, newpath, file_id, kind, text_mod, meta_mod in self._delta.renamed:
 
179
            marker = osutils.kind_marker(kind)
 
180
            if text_mod or meta_mod:
 
181
                changes = renamed_and_modified
 
182
            else:
 
183
                changes = renamed
 
184
            store.append([file_id, newpath, True,
 
185
                          oldpath+marker + '  =>  ' + newpath+marker,
 
186
                          changes,
 
187
                         ])
 
188
 
 
189
        for path, file_id, kind, text_mod, meta_mod in self._delta.modified:
 
190
            marker = osutils.kind_marker(kind)
 
191
            store.append([file_id, path, True, path+marker, modified])
 
192
 
 
193
        self._treeview_files.set_model(store)
 
194
 
150
195
    def _compute_delta(self):
151
196
        self._delta = self._wt.changes_from(self._basis_tree)
152
197
 
168
213
        self._construct_file_list()
169
214
        self._construct_pending_list()
170
215
 
171
 
        self._hpane.pack1(self._left_pane_box, resize=False, shrink=True)
 
216
        self._hpane.pack1(self._left_pane_box, resize=False, shrink=False)
172
217
        self._left_pane_box.show()
173
218
 
174
219
    def _construct_right_pane(self):
225
270
        self._files_box.show()
226
271
        self._left_pane_box.pack_start(self._files_box)
227
272
 
 
273
        liststore = gtk.ListStore(
 
274
            gobject.TYPE_STRING,  # [0] file_id
 
275
            gobject.TYPE_STRING,  # [1] real path
 
276
            gobject.TYPE_BOOLEAN, # [2] checkbox
 
277
            gobject.TYPE_STRING,  # [3] display path
 
278
            gobject.TYPE_STRING,  # [4] changes type
 
279
            )
 
280
        self._files_store = liststore
 
281
        self._treeview_files.set_model(liststore)
 
282
        crt = gtk.CellRendererToggle()
 
283
        crt.set_property("activatable", True) # not bool(self._pending))
 
284
        crt.connect("toggled", self._toggle_commit, self._files_store)
 
285
        self._treeview_files.append_column(gtk.TreeViewColumn(_('Commit'),
 
286
                                           crt, active=2))
 
287
        self._treeview_files.append_column(gtk.TreeViewColumn(_('Path'),
 
288
                                           gtk.CellRendererText(), text=3))
 
289
        self._treeview_files.append_column(gtk.TreeViewColumn(_('Type'),
 
290
                                           gtk.CellRendererText(), text=4))
 
291
 
 
292
    def _toggle_commit(self, cell, path, model):
 
293
        model[path][2] = not model[path][2]
 
294
        return
 
295
 
228
296
    def _construct_pending_list(self):
229
297
        # Pending information defaults to hidden, we put it all in 1 box, so
230
298
        # that we can show/hide all of them at once
253
321
        self._treeview_pending.show()
254
322
        self._left_pane_box.pack_start(self._pending_box)
255
323
 
256
 
        liststore = gtk.ListStore(gobject.TYPE_STRING,
257
 
                                  gobject.TYPE_STRING,
258
 
                                  gobject.TYPE_STRING,
259
 
                                  gobject.TYPE_STRING,
 
324
        liststore = gtk.ListStore(gobject.TYPE_STRING, # revision_id
 
325
                                  gobject.TYPE_STRING, # date
 
326
                                  gobject.TYPE_STRING, # committer
 
327
                                  gobject.TYPE_STRING, # summary
260
328
                                 )
261
 
        self._pending_liststore = liststore
 
329
        self._pending_store = liststore
262
330
        self._treeview_pending.set_model(liststore)
263
331
        self._treeview_pending.append_column(gtk.TreeViewColumn(_('Date'),
264
332
                                             gtk.CellRendererText(), text=1))