/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
"""Application object.
4
5
This module contains the application object that manages the windows
6
on screen, and can be used to create new windows of various types.
7
"""
8
9
__copyright__ = "Copyright © 2005 Canonical Ltd."
10
__author__    = "Scott James Remnant <scott@ubuntu.com>"
11
12
13
import pygtk
14
pygtk.require("2.0")
15
16
import gtk
17
18
from branchwin import BranchWindow
19
20
21
class BzrkApp(object):
22
    """Application manager.
23
24
    This object manages the bzrk application, creating and managing
25
    individual branch windows and ensuring the application exits when
26
    the last window is closed.
27
    """
28
29
    def __init__(self):
30
        self._num_windows = 0
31
32
    def show(self, branch, start):
33
        """Open a new window to show the given branch."""
34
        self._num_windows += 1
35
36
        window = BranchWindow()
37
        window.set_branch(branch, start)
38
        window.connect("destroy", self._destroy_cb)
39
        window.show()
40
41
    def _destroy_cb(self, widget):
42
        """Callback for when a window we manage is destroyed."""
43
        self._num_windows -= 1
44
        if self._num_windows <= 0:
45
            self.quit()
46
47
    def main(self):
48
        """Start the GTK+ main loop."""
49
        gtk.main()
50
51
    def quit(self):
52
        """Stop the GTK+ main loop."""
53
        gtk.main_quit()