/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
1 by Scott James Remnant
Commit the first version of bzrk.
1
#!/usr/bin/python
2
# -*- coding: UTF-8 -*-
3
"""Branch window.
4
5
This module contains the code to manage the branch information window,
6
which contains both the revision graph and details panes.
7
"""
8
9
__copyright__ = "Copyright © 2005 Canonical Ltd."
10
__author__    = "Scott James Remnant <scott@ubuntu.com>"
11
12
13
import gtk
14
import gobject
15
import pango
16
17
from bzrlib.osutils import format_date
18
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
19
from graph import distances, graph, same_branch
1 by Scott James Remnant
Commit the first version of bzrk.
20
from graphcell import CellRendererGraph
21
22
23
class BranchWindow(gtk.Window):
24
    """Branch window.
25
26
    This object represents and manages a single window containing information
27
    for a particular branch.
28
    """
29
10 by Scott James Remnant
Add an extra window type, clicking the little icons next to a parent
30
    def __init__(self, app=None):
1 by Scott James Remnant
Commit the first version of bzrk.
31
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
32
        self.set_border_width(0)
33
        self.set_title("bzrk")
34
10 by Scott James Remnant
Add an extra window type, clicking the little icons next to a parent
35
        self.app = app
36
1 by Scott James Remnant
Commit the first version of bzrk.
37
        # Use three-quarters of the screen by default
38
        screen = self.get_screen()
4 by Scott James Remnant
Use the size of the first monitor rather than the entire screen
39
        monitor = screen.get_monitor_geometry(0)
40
        width = int(monitor.width * 0.75)
41
        height = int(monitor.height * 0.75)
1 by Scott James Remnant
Commit the first version of bzrk.
42
        self.set_default_size(width, height)
43
44
        # FIXME AndyFitz!
45
        icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
46
        self.set_icon(icon)
47
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
48
        self.accel_group = gtk.AccelGroup()
49
        self.add_accel_group(self.accel_group)
50
1 by Scott James Remnant
Commit the first version of bzrk.
51
        self.construct()
52
53
    def construct(self):
54
        """Construct the window contents."""
44 by David Allouche
reorganise branch window
55
        vbox = gtk.VBox(spacing=0)
56
        self.add(vbox)
57
58
        vbox.pack_start(self.construct_navigation(), expand=False, fill=True)
59
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
60
        paned = gtk.VPaned()
61
        paned.pack1(self.construct_top(), resize=True, shrink=False)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
62
        paned.pack2(self.construct_bottom(), resize=False, shrink=True)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
63
        paned.show()
44 by David Allouche
reorganise branch window
64
        vbox.pack_start(paned, expand=True, fill=True)
65
        vbox.set_focus_child(paned)
66
67
        vbox.show()
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
68
69
    def construct_top(self):
70
        """Construct the top-half of the window."""
1 by Scott James Remnant
Commit the first version of bzrk.
71
        scrollwin = gtk.ScrolledWindow()
72
        scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
73
        scrollwin.set_shadow_type(gtk.SHADOW_IN)
74
        scrollwin.show()
75
76
        self.treeview = gtk.TreeView()
77
        self.treeview.set_rules_hint(True)
78
        self.treeview.set_search_column(4)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
79
        self.treeview.connect("cursor-changed", self._treeview_cursor_cb)
47 by Wouter van Heyst
rename _treeview_clicked_cb to correcter _treeview_row_activated_cb
80
        self.treeview.connect("row-activated", self._treeview_row_activated_cb)
1 by Scott James Remnant
Commit the first version of bzrk.
81
        scrollwin.add(self.treeview)
82
        self.treeview.show()
83
84
        cell = CellRendererGraph()
85
        column = gtk.TreeViewColumn()
45 by David Allouche
resizable graph column
86
        column.set_resizable(True)
1 by Scott James Remnant
Commit the first version of bzrk.
87
        column.pack_start(cell, expand=False)
88
        column.add_attribute(cell, "node", 1)
89
        column.add_attribute(cell, "in-lines", 2)
90
        column.add_attribute(cell, "out-lines", 3)
91
        self.treeview.append_column(column)
92
93
        cell = gtk.CellRendererText()
94
        cell.set_property("width-chars", 40)
95
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
96
        column = gtk.TreeViewColumn("Message")
97
        column.set_resizable(True)
98
        column.pack_start(cell, expand=True)
99
        column.add_attribute(cell, "text", 4)
100
        self.treeview.append_column(column)
101
102
        cell = gtk.CellRendererText()
103
        cell.set_property("width-chars", 40)
104
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
105
        column = gtk.TreeViewColumn("Committer")
106
        column.set_resizable(True)
107
        column.pack_start(cell, expand=True)
108
        column.add_attribute(cell, "text", 5)
109
        self.treeview.append_column(column)
110
111
        cell = gtk.CellRendererText()
112
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
113
        column = gtk.TreeViewColumn("Date")
114
        column.set_resizable(True)
115
        column.pack_start(cell, expand=True)
116
        column.add_attribute(cell, "text", 6)
117
        self.treeview.append_column(column)
118
44 by David Allouche
reorganise branch window
119
        return scrollwin
120
121
    def construct_navigation(self):
122
        """Construct the navigation buttons."""
123
        frame = gtk.Frame()
124
        frame.set_shadow_type(gtk.SHADOW_OUT)
125
        frame.show()
126
        
127
        hbox = gtk.HBox(spacing=12)
128
        frame.add(hbox)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
129
        hbox.show()
130
131
        self.back_button = gtk.Button(stock=gtk.STOCK_GO_BACK)
44 by David Allouche
reorganise branch window
132
        self.back_button.set_relief(gtk.RELIEF_NONE)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
133
        self.back_button.add_accelerator("clicked", self.accel_group, ord('['),
134
                                         0, 0)
135
        self.back_button.connect("clicked", self._back_clicked_cb)
136
        hbox.pack_start(self.back_button, expand=False, fill=True)
137
        self.back_button.show()
138
139
        self.fwd_button = gtk.Button(stock=gtk.STOCK_GO_FORWARD)
44 by David Allouche
reorganise branch window
140
        self.fwd_button.set_relief(gtk.RELIEF_NONE)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
141
        self.fwd_button.add_accelerator("clicked", self.accel_group, ord(']'),
142
                                        0, 0)
143
        self.fwd_button.connect("clicked", self._fwd_clicked_cb)
144
        hbox.pack_start(self.fwd_button, expand=False, fill=True)
145
        self.fwd_button.show()
146
44 by David Allouche
reorganise branch window
147
        return frame
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
148
149
    def construct_bottom(self):
150
        """Construct the bottom half of the window."""
44 by David Allouche
reorganise branch window
151
        scrollwin = gtk.ScrolledWindow()
152
        scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
153
        scrollwin.set_shadow_type(gtk.SHADOW_NONE)
154
        (width, height) = self.get_size()
155
        scrollwin.set_size_request(width, int(height / 2.5))
156
        scrollwin.show()
157
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
158
        vbox = gtk.VBox(False, spacing=6)
43 by David Allouche
parent buttons look like buttons, some layout changes
159
        vbox.set_border_width(6)
44 by David Allouche
reorganise branch window
160
        scrollwin.add_with_viewport(vbox)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
161
        vbox.show()
162
43 by David Allouche
parent buttons look like buttons, some layout changes
163
        table = gtk.Table(rows=4, columns=2)
164
        table.set_row_spacings(6)
165
        table.set_col_spacings(6)
166
        vbox.pack_start(table, expand=False, fill=True)
167
        table.show()
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
168
8 by Scott James Remnant
Fiddle around with the alignment and size allocations a little
169
        align = gtk.Alignment(0.0, 0.5)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
170
        label = gtk.Label()
171
        label.set_markup("<b>Revision:</b>")
172
        align.add(label)
43 by David Allouche
parent buttons look like buttons, some layout changes
173
        table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
174
        label.show()
175
        align.show()
176
8 by Scott James Remnant
Fiddle around with the alignment and size allocations a little
177
        align = gtk.Alignment(0.0, 0.5)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
178
        self.revid_label = gtk.Label()
179
        self.revid_label.set_selectable(True)
180
        align.add(self.revid_label)
43 by David Allouche
parent buttons look like buttons, some layout changes
181
        table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
182
        self.revid_label.show()
183
        align.show()
184
8 by Scott James Remnant
Fiddle around with the alignment and size allocations a little
185
        align = gtk.Alignment(0.0, 0.5)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
186
        label = gtk.Label()
187
        label.set_markup("<b>Committer:</b>")
188
        align.add(label)
43 by David Allouche
parent buttons look like buttons, some layout changes
189
        table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
190
        label.show()
191
        align.show()
192
8 by Scott James Remnant
Fiddle around with the alignment and size allocations a little
193
        align = gtk.Alignment(0.0, 0.5)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
194
        self.committer_label = gtk.Label()
195
        self.committer_label.set_selectable(True)
196
        align.add(self.committer_label)
43 by David Allouche
parent buttons look like buttons, some layout changes
197
        table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
198
        self.committer_label.show()
199
        align.show()
200
8 by Scott James Remnant
Fiddle around with the alignment and size allocations a little
201
        align = gtk.Alignment(0.0, 0.5)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
202
        label = gtk.Label()
19.1.1 by Erik Bagfors
Support for showing the branch nick
203
        label.set_markup("<b>Branch nick:</b>")
204
        align.add(label)
43 by David Allouche
parent buttons look like buttons, some layout changes
205
        table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
19.1.1 by Erik Bagfors
Support for showing the branch nick
206
        label.show()
207
        align.show()
208
209
        align = gtk.Alignment(0.0, 0.5)
210
        self.branchnick_label = gtk.Label()
211
        self.branchnick_label.set_selectable(True)
212
        align.add(self.branchnick_label)
43 by David Allouche
parent buttons look like buttons, some layout changes
213
        table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
19.1.1 by Erik Bagfors
Support for showing the branch nick
214
        self.branchnick_label.show()
215
        align.show()
216
217
        align = gtk.Alignment(0.0, 0.5)
218
        label = gtk.Label()
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
219
        label.set_markup("<b>Timestamp:</b>")
220
        align.add(label)
43 by David Allouche
parent buttons look like buttons, some layout changes
221
        table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
222
        label.show()
223
        align.show()
224
8 by Scott James Remnant
Fiddle around with the alignment and size allocations a little
225
        align = gtk.Alignment(0.0, 0.5)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
226
        self.timestamp_label = gtk.Label()
227
        self.timestamp_label.set_selectable(True)
228
        align.add(self.timestamp_label)
43 by David Allouche
parent buttons look like buttons, some layout changes
229
        table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
230
        self.timestamp_label.show()
231
        align.show()
232
43 by David Allouche
parent buttons look like buttons, some layout changes
233
        self.parents_table = gtk.Table(rows=1, columns=2)
234
        self.parents_table.set_row_spacings(3)
235
        self.parents_table.set_col_spacings(6)
236
        self.parents_table.show()
237
        vbox.pack_start(self.parents_table, expand=False, fill=True)
238
        self.parents_widgets = []
239
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
240
        label = gtk.Label()
241
        label.set_markup("<b>Parents:</b>")
43 by David Allouche
parent buttons look like buttons, some layout changes
242
        align = gtk.Alignment(0.0, 0.5)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
243
        align.add(label)
43 by David Allouche
parent buttons look like buttons, some layout changes
244
        self.parents_table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
245
        label.show()
246
        align.show()
247
248
        self.message_buffer = gtk.TextBuffer()
249
        textview = gtk.TextView(self.message_buffer)
250
        textview.set_editable(False)
251
        textview.set_wrap_mode(gtk.WRAP_WORD)
252
        textview.modify_font(pango.FontDescription("Monospace"))
44 by David Allouche
reorganise branch window
253
        vbox.pack_start(textview, expand=True, fill=True)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
254
        textview.show()
255
44 by David Allouche
reorganise branch window
256
        return scrollwin
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
257
40 by David Allouche
remove --robust, pyflakes fixes, update README
258
    def set_branch(self, branch, start, maxnum):
1 by Scott James Remnant
Commit the first version of bzrk.
259
        """Set the branch and start position for this window.
260
261
        Creates a new TreeModel and populates it with information about
262
        the new branch before updating the window title and model of the
263
        treeview itself.
264
        """
10 by Scott James Remnant
Add an extra window type, clicking the little icons next to a parent
265
        self.branch = branch
266
1 by Scott James Remnant
Commit the first version of bzrk.
267
        # [ revision, node, last_lines, lines, message, committer, timestamp ]
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
268
        self.model = gtk.ListStore(gobject.TYPE_PYOBJECT,
269
                                   gobject.TYPE_PYOBJECT,
270
                                   gobject.TYPE_PYOBJECT,
271
                                   gobject.TYPE_PYOBJECT,
272
                                   str, str, str)
273
        self.index = {}
274
        index = 0
1 by Scott James Remnant
Commit the first version of bzrk.
275
276
        last_lines = []
40 by David Allouche
remove --robust, pyflakes fixes, update README
277
        (self.revisions, colours, self.children, self.parent_ids,
41 by David Allouche
restore --maxnum functionality, reflush some comments
278
         merge_sorted) = distances(branch, start)
279
        for (index, (revision, node, lines)) in enumerate(graph(
280
                self.revisions, colours, merge_sorted)):
281
            # FIXME: at this point we should be able to show the graph order
282
            # and lines with no message or commit data - and then incrementally
283
            # fill the timestamp, committer etc data as desired.
1 by Scott James Remnant
Commit the first version of bzrk.
284
            message = revision.message.split("\n")[0]
285
            if revision.committer is not None:
286
                timestamp = format_date(revision.timestamp, revision.timezone)
287
            else:
288
                timestamp = None
41 by David Allouche
restore --maxnum functionality, reflush some comments
289
            self.model.append([revision, node, last_lines, lines,
290
                               message, revision.committer, timestamp])
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
291
            self.index[revision] = index
1 by Scott James Remnant
Commit the first version of bzrk.
292
            last_lines = lines
41 by David Allouche
restore --maxnum functionality, reflush some comments
293
            if maxnum is not None and index > maxnum:
294
                break
1 by Scott James Remnant
Commit the first version of bzrk.
295
36.1.2 by Jamie Wilkinson
put the branch nick in the titlebar instead of the path basename (which didn't work anyway)
296
        self.set_title(branch.nick + " - bzrk")
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
297
        self.treeview.set_model(self.model)
298
299
    def _treeview_cursor_cb(self, *args):
300
        """Callback for when the treeview cursor changes."""
301
        (path, col) = self.treeview.get_cursor()
302
        revision = self.model[path][0]
303
20 by David Allouche
ignore redundent parents
304
        self.back_button.set_sensitive(len(self.parent_ids[revision]) > 0)
5 by Scott James Remnant
Reverse the meaning of the Back and Forward buttons so Back actually
305
        self.fwd_button.set_sensitive(len(self.children[revision]) > 0)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
306
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
307
        if revision.committer is not None:
37.1.1 by Robert Collins
Retab branchwin.py
308
            branchnick = ""
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
309
            committer = revision.committer
310
            timestamp = format_date(revision.timestamp, revision.timezone)
311
            message = revision.message
37.1.1 by Robert Collins
Retab branchwin.py
312
            try:
313
                branchnick = revision.properties['branch-nick']
314
            except KeyError:
315
                pass
19.1.1 by Erik Bagfors
Support for showing the branch nick
316
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
317
        else:
318
            committer = ""
319
            timestamp = ""
320
            message = ""
37.1.1 by Robert Collins
Retab branchwin.py
321
            branchnick = ""
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
322
323
        self.revid_label.set_text(revision.revision_id)
37.1.1 by Robert Collins
Retab branchwin.py
324
        self.branchnick_label.set_text(branchnick)
19.1.1 by Erik Bagfors
Support for showing the branch nick
325
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
326
        self.committer_label.set_text(committer)
327
        self.timestamp_label.set_text(timestamp)
328
        self.message_buffer.set_text(message)
329
330
        for widget in self.parents_widgets:
43 by David Allouche
parent buttons look like buttons, some layout changes
331
            self.parents_table.remove(widget)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
332
333
        self.parents_widgets = []
43 by David Allouche
parent buttons look like buttons, some layout changes
334
        self.parents_table.resize(max(len(self.parent_ids[revision]), 1), 2)
335
        
20 by David Allouche
ignore redundent parents
336
        for idx, parent_id in enumerate(self.parent_ids[revision]):
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
337
            align = gtk.Alignment(0.0, 0.0)
338
            self.parents_widgets.append(align)
43 by David Allouche
parent buttons look like buttons, some layout changes
339
            self.parents_table.attach(align, 1, 2, idx, idx + 1,
340
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
341
            align.show()
342
43 by David Allouche
parent buttons look like buttons, some layout changes
343
            hbox = gtk.HBox(False, spacing=6)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
344
            align.add(hbox)
345
            hbox.show()
346
43 by David Allouche
parent buttons look like buttons, some layout changes
347
            image = gtk.Image()
348
            image.set_from_stock(
349
                gtk.STOCK_FIND, gtk.ICON_SIZE_SMALL_TOOLBAR)
350
            image.show()
351
352
            button = gtk.Button()
353
            button.add(image)
354
            button.set_sensitive(self.app is not None)
355
            button.connect("clicked", self._show_clicked_cb,
356
                           revision.revision_id, parent_id)
357
            hbox.pack_start(button, expand=False, fill=True)
358
            button.show()
359
45.1.1 by Michael Ellerman
Instead of having a "jump to revision" button with a dubious icon, make
360
            button = gtk.Button(parent_id)
70 by Jelmer Vernooij
Don't treat underscores in revision ids as special characters
361
            button.set_use_underline(False)
45.1.1 by Michael Ellerman
Instead of having a "jump to revision" button with a dubious icon, make
362
            button.connect("clicked", self._go_clicked_cb, parent_id)
363
            hbox.pack_start(button, expand=False, fill=True)
364
            button.show()
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
365
366
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
367
    def _back_clicked_cb(self, *args):
368
        """Callback for when the back button is clicked."""
369
        (path, col) = self.treeview.get_cursor()
370
        revision = self.model[path][0]
20 by David Allouche
ignore redundent parents
371
        if not len(self.parent_ids[revision]):
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
372
            return
373
20 by David Allouche
ignore redundent parents
374
        for parent_id in self.parent_ids[revision]:
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
375
            parent = self.revisions[parent_id]
376
            if same_branch(revision, parent):
377
                self.treeview.set_cursor(self.index[parent])
378
                break
379
        else:
20 by David Allouche
ignore redundent parents
380
            next = self.revisions[self.parent_ids[revision][0]]
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
381
            self.treeview.set_cursor(self.index[next])
13 by Scott James Remnant
Keep the focus on the treeview
382
        self.treeview.grab_focus()
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
383
5 by Scott James Remnant
Reverse the meaning of the Back and Forward buttons so Back actually
384
    def _fwd_clicked_cb(self, *args):
385
        """Callback for when the forward button is clicked."""
386
        (path, col) = self.treeview.get_cursor()
387
        revision = self.model[path][0]
388
        if not len(self.children[revision]):
389
            return
390
391
        for child in self.children[revision]:
392
            if same_branch(child, revision):
393
                self.treeview.set_cursor(self.index[child])
394
                break
395
        else:
396
            prev = list(self.children[revision])[0]
397
            self.treeview.set_cursor(self.index[prev])
13 by Scott James Remnant
Keep the focus on the treeview
398
        self.treeview.grab_focus()
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
399
400
    def _go_clicked_cb(self, widget, revid):
401
        """Callback for when the go button for a parent is clicked."""
402
        self.treeview.set_cursor(self.index[self.revisions[revid]])
13 by Scott James Remnant
Keep the focus on the treeview
403
        self.treeview.grab_focus()
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
404
10 by Scott James Remnant
Add an extra window type, clicking the little icons next to a parent
405
    def _show_clicked_cb(self, widget, revid, parentid):
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
406
        """Callback for when the show button for a parent is clicked."""
10 by Scott James Remnant
Add an extra window type, clicking the little icons next to a parent
407
        if self.app is not None:
408
            self.app.show_diff(self.branch, revid, parentid)
13 by Scott James Remnant
Keep the focus on the treeview
409
        self.treeview.grab_focus()
46 by Wouter van Heyst
show diff on row activation, LP# 44591
410
47 by Wouter van Heyst
rename _treeview_clicked_cb to correcter _treeview_row_activated_cb
411
    def _treeview_row_activated_cb(self, widget, path, col):
46 by Wouter van Heyst
show diff on row activation, LP# 44591
412
        # TODO: more than one parent
47 by Wouter van Heyst
rename _treeview_clicked_cb to correcter _treeview_row_activated_cb
413
        """Callback for when a treeview row gets activated."""
46 by Wouter van Heyst
show diff on row activation, LP# 44591
414
        revision = self.model[path][0]
74 by Jelmer Vernooij
Fix exception when double-clicking revision without parents.
415
        if len(self.parent_ids[revision]) == 0:
416
            # Ignore revisions without parent
417
            return
46 by Wouter van Heyst
show diff on row activation, LP# 44591
418
        parent_id = self.parent_ids[revision][0]
419
        if self.app is not None:
420
            self.app.show_diff(self.branch, revision.revision_id, parent_id)
421
        self.treeview.grab_focus()