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

  • Committer: Gary van der Merwe
  • Date: 2007-09-20 21:57:46 UTC
  • mfrom: (278 trunk)
  • mto: (256.2.54 gtk)
  • mto: This revision was merged to the branch mainline in revision 289.
  • Revision ID: garyvdm@gmail.com-20070920215746-l2pcdqlj73q4luug
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    for a particular branch.
29
29
    """
30
30
 
31
 
    def __init__(self):
 
31
    def __init__(self, parent=None):
32
32
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
33
33
        self.set_border_width(0)
34
34
        self.set_title("bzrk")
35
35
 
 
36
        self._parent = parent
 
37
 
 
38
        self.connect('key-press-event', self._on_key_pressed)
 
39
 
36
40
        # Use three-quarters of the screen by default
37
41
        screen = self.get_screen()
38
42
        monitor = screen.get_monitor_geometry(0)
169
173
 
170
174
    def set_branch(self, branch, start, maxnum):
171
175
        """Set the branch and start position for this window.
172
 
        
 
176
 
173
177
        Creates a new TreeModel and populates it with information about
174
178
        the new branch before updating the window title and model of the
175
179
        treeview itself.
185
189
        self.model = TreeModel(self.branch, linegraphdata)
186
190
        self.index = index
187
191
        self.treeview.set_model(self.model)
188
 
 
 
192
    def _on_key_pressed(self, widget, event):
 
193
        """ Key press event handler. """
 
194
        keyname = gtk.gdk.keyval_name(event.keyval)
 
195
        func = getattr(self, '_on_key_press_' + keyname, None)
 
196
        if func:
 
197
            return func(event)
 
198
 
 
199
    def _on_key_press_w(self, event):
 
200
        if event.state & gtk.gdk.CONTROL_MASK:
 
201
            self.destroy()
 
202
            if self._parent is None:
 
203
                gtk.main_quit()
 
204
 
 
205
    def _on_key_press_q(self, event):
 
206
        if event.state & gtk.gdk.CONTROL_MASK:
 
207
            gtk.main_quit()
 
208
    
189
209
    def _treeview_cursor_cb(self, *args):
190
210
        """Callback for when the treeview cursor changes."""
191
211
        (path, col) = self.treeview.get_cursor()