2006-08-23 11:52:18 +02:00
|
|
|
import gtk
|
|
|
|
import goocanvas
|
|
|
|
|
2006-08-28 16:53:29 +02:00
|
|
|
class PanelView(goocanvas.CanvasView):
|
2006-08-23 11:52:18 +02:00
|
|
|
BORDER = 4
|
|
|
|
|
2006-08-28 16:53:29 +02:00
|
|
|
def construct(self, x, y):
|
|
|
|
model = goocanvas.CanvasModelSimple()
|
|
|
|
root = model.get_root_item()
|
2006-08-23 11:52:18 +02:00
|
|
|
|
2006-08-28 16:53:29 +02:00
|
|
|
item = goocanvas.Rect(x=0, y=0,
|
|
|
|
width=self.get_allocation().width,
|
|
|
|
height=self.get_allocation().height,
|
2006-08-23 11:52:18 +02:00
|
|
|
line_width=0, fill_color="#4f4f4f")
|
|
|
|
root.add_child(item)
|
|
|
|
|
2006-08-28 16:53:29 +02:00
|
|
|
self._group = goocanvas.Group()
|
|
|
|
root.add_child(self._group)
|
|
|
|
self._group.translate(x + PanelView.BORDER, y + PanelView.BORDER)
|
|
|
|
|
|
|
|
self.set_model(model)
|
|
|
|
|
|
|
|
def get_root_group(self):
|
|
|
|
return self._group
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
class Panel(gtk.Window):
|
|
|
|
def __init__(self):
|
|
|
|
gtk.Window.__init__(self)
|
2006-08-28 16:53:29 +02:00
|
|
|
self._x = 0
|
|
|
|
self._y = 0
|
2006-08-29 00:18:35 +02:00
|
|
|
self._constructed = False
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
self._view = PanelView()
|
|
|
|
self.add(self._view)
|
|
|
|
self._view.show()
|
|
|
|
|
2006-08-28 16:53:29 +02:00
|
|
|
self.set_decorated(False)
|
|
|
|
|
|
|
|
self.realize()
|
|
|
|
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
2006-08-31 10:10:45 +02:00
|
|
|
self.window.set_accept_focus(False)
|
2006-08-28 16:53:29 +02:00
|
|
|
|
|
|
|
screen = gtk.gdk.screen_get_default()
|
|
|
|
self.window.set_transient_for(screen.get_root_window())
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
def get_view(self):
|
|
|
|
return self._view
|
|
|
|
|
2006-08-28 14:04:51 +02:00
|
|
|
def get_root(self):
|
2006-08-28 16:53:29 +02:00
|
|
|
return self._view.get_root_group()
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
def get_height(self):
|
|
|
|
height = self._view.get_allocation().height
|
2006-08-28 16:53:29 +02:00
|
|
|
return height - PanelView.BORDER * 2
|
2006-08-23 11:52:18 +02:00
|
|
|
|
2006-08-28 14:58:21 +02:00
|
|
|
def get_width(self):
|
|
|
|
width = self._view.get_allocation().width
|
2006-08-28 16:53:29 +02:00
|
|
|
return width - PanelView.BORDER * 2
|
2006-08-28 14:58:21 +02:00
|
|
|
|
2006-08-28 16:53:29 +02:00
|
|
|
def set_position(self, x, y):
|
|
|
|
self._x = x
|
|
|
|
self._y = y
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
def construct(self):
|
2006-08-28 16:53:29 +02:00
|
|
|
self._view.construct(self._x, self._y)
|
2006-08-29 00:18:35 +02:00
|
|
|
self._constructed = True
|
2006-08-23 11:52:18 +02:00
|
|
|
|
|
|
|
def show(self):
|
|
|
|
gtk.Window.show(self)
|
2006-08-29 00:18:35 +02:00
|
|
|
|
|
|
|
if not self._constructed:
|
|
|
|
self.construct()
|