/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 annotate/gannotate.py

  • Committer: Daniel Schierbeck
  • Date: 2007-10-14 15:33:50 UTC
  • mto: This revision was merged to the branch mainline in revision 317.
  • Revision ID: daniel.schierbeck@gmail.com-20071014153350-ejjs1qt77w66fzzr
Refactored the GTK window code, creating a single base window class that handles keyboard events.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from colormap import AnnotateColorMap, AnnotateColorSaturation
31
31
from bzrlib.plugins.gtk.logview import LogView
 
32
from bzrlib.plugins.gtk.window import Window
32
33
 
33
34
 
34
35
(
41
42
) = range(6)
42
43
 
43
44
 
44
 
class GAnnotateWindow(gtk.Window):
 
45
class GAnnotateWindow(Window):
45
46
    """Annotate window."""
46
47
 
47
48
    def __init__(self, all=False, plain=False, parent=None):
48
49
        self.all = all
49
50
        self.plain = plain
50
 
        self._parent = parent
51
51
        
52
 
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
53
 
 
54
 
        self.connect("key-press-event", self._on_key_pressed)
 
52
        Window.__init__(self, parent)
55
53
        
56
54
        self.set_icon(self.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON))
57
55
        self.annotate_colormap = AnnotateColorSaturation()
394
392
            if i + n >= row:
395
393
                return j - i
396
394
 
397
 
    def _on_key_pressed(self, widget, event):
398
 
        """ Key press event handler. """
399
 
        keyname = gtk.gdk.keyval_name(event.keyval)
400
 
        func = getattr(self, '_on_key_press_' + keyname, None)
401
 
        if func:
402
 
            return func(event)
403
 
 
404
 
    def _on_key_press_w(self, event):
405
 
        if event.state & gtk.gdk.CONTROL_MASK:
406
 
            self.destroy()
407
 
            if self._parent is None:
408
 
                gtk.main_quit()
409
 
 
410
 
    def _on_key_press_q(self, event):
411
 
        if event.state & gtk.gdk.CONTROL_MASK:
412
 
            gtk.main_quit()
413
 
    
414
 
 
415
 
 
416
395
 
417
396
class FakeRevision:
418
397
    """ A fake revision.