File: toplevelwindow.py

package info (click to toggle)
gaphor 0.13.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,692 kB
  • ctags: 2,971
  • sloc: python: 19,981; xml: 247; makefile: 54; sh: 40
file content (53 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Basic stuff for toplevel windows.
"""

import gtk

from zope import interface
from interfaces import IUIComponent


class ToplevelWindow(object):

    interface.implements(IUIComponent)

    menubar_path = ''
    toolbar_path = ''

    def __init__(self):
        self.window = None

    def construct(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title(self.title)
        self.window.set_size_request(*self.size)
        self.window.set_resizable(True)

        self.window.add_accel_group(self.ui_manager.get_accel_group())

        vbox = gtk.VBox()
        self.window.add(vbox)
        vbox.show()

        #self.ui_manager.insert_action_group(self.action_group, 0)
        #self.ui_manager.add_ui_from_string(self.menu_xml)

        menubar = self.ui_manager.get_widget(self.menubar_path)
        if menubar:
            vbox.pack_start(menubar, expand=False)
            #menubar.show()
        
        if self.toolbar_path:
            toolbar = self.ui_manager.get_widget(self.toolbar_path)
            if toolbar:
                vbox.pack_start(toolbar, expand=False)
                #toolbar.show()

        vbox.pack_end(self.ui_component(), expand=True)
        vbox.show()
        # TODO: add statusbar
        self.window.show()


# vim:sw=4:et:ai