|
|
|
@ -21,11 +21,12 @@ from sugar.graphics import style
|
|
|
|
|
|
|
|
|
|
class FrameWindow(gtk.Window):
|
|
|
|
|
__gtype_name__ = 'SugarFrameWindow'
|
|
|
|
|
def __init__(self, orientation):
|
|
|
|
|
|
|
|
|
|
def __init__(self, position):
|
|
|
|
|
gtk.Window.__init__(self)
|
|
|
|
|
self.hover = False
|
|
|
|
|
|
|
|
|
|
self._orientation = orientation
|
|
|
|
|
self._position = position
|
|
|
|
|
|
|
|
|
|
self.set_decorated(False)
|
|
|
|
|
self.connect('realize', self._realize_cb)
|
|
|
|
@ -36,33 +37,55 @@ class FrameWindow(gtk.Window):
|
|
|
|
|
self.add(self._canvas)
|
|
|
|
|
self._canvas.show()
|
|
|
|
|
|
|
|
|
|
self._bg = hippo.CanvasBox(orientation=self._orientation)
|
|
|
|
|
self._canvas.set_root(self._bg)
|
|
|
|
|
box = hippo.CanvasBox()
|
|
|
|
|
self._canvas.set_root(box)
|
|
|
|
|
|
|
|
|
|
padding = style.GRID_CELL_SIZE
|
|
|
|
|
if self._position == gtk.POS_TOP or self._position == gtk.POS_BOTTOM:
|
|
|
|
|
box.props.orientation = hippo.ORIENTATION_HORIZONTAL
|
|
|
|
|
box.props.padding_left = padding
|
|
|
|
|
box.props.padding_right = padding
|
|
|
|
|
box.props.padding_top = 0
|
|
|
|
|
box.props.padding_bottom = 0
|
|
|
|
|
else:
|
|
|
|
|
box.props.orientation = hippo.ORIENTATION_VERTICAL
|
|
|
|
|
box.props.padding_left = 0
|
|
|
|
|
box.props.padding_right = 0
|
|
|
|
|
box.props.padding_top = padding
|
|
|
|
|
box.props.padding_bottom = padding
|
|
|
|
|
|
|
|
|
|
self._bg = hippo.CanvasBox(
|
|
|
|
|
border_color=style.COLOR_BUTTON_GREY.get_int())
|
|
|
|
|
|
|
|
|
|
border = style.LINE_WIDTH
|
|
|
|
|
if position == gtk.POS_TOP:
|
|
|
|
|
self._bg.props.orientation = hippo.ORIENTATION_HORIZONTAL
|
|
|
|
|
self._bg.props.border_bottom = border
|
|
|
|
|
elif position == gtk.POS_BOTTOM:
|
|
|
|
|
self._bg.props.orientation = hippo.ORIENTATION_HORIZONTAL
|
|
|
|
|
self._bg.props.border_top = border
|
|
|
|
|
elif position == gtk.POS_LEFT:
|
|
|
|
|
self._bg.props.orientation = hippo.ORIENTATION_VERTICAL
|
|
|
|
|
self._bg.props.border_right = border
|
|
|
|
|
elif position == gtk.POS_RIGHT:
|
|
|
|
|
self._bg.props.orientation = hippo.ORIENTATION_VERTICAL
|
|
|
|
|
self._bg.props.border_left = border
|
|
|
|
|
|
|
|
|
|
box.append(self._bg, hippo.PACK_EXPAND)
|
|
|
|
|
|
|
|
|
|
self._update_size()
|
|
|
|
|
|
|
|
|
|
screen = gtk.gdk.screen_get_default()
|
|
|
|
|
screen.connect('size-changed', self._size_changed_cb)
|
|
|
|
|
|
|
|
|
|
def get_root(self):
|
|
|
|
|
return self._bg
|
|
|
|
|
def append(self, child, flags=0):
|
|
|
|
|
self._bg.append(child, flags)
|
|
|
|
|
|
|
|
|
|
def _update_size(self):
|
|
|
|
|
padding = style.GRID_CELL_SIZE
|
|
|
|
|
if self._orientation == hippo.ORIENTATION_HORIZONTAL:
|
|
|
|
|
self._bg.props.padding_left = padding
|
|
|
|
|
self._bg.props.padding_right = padding
|
|
|
|
|
self._bg.props.padding_top = 0
|
|
|
|
|
self._bg.props.padding_bottom = 0
|
|
|
|
|
|
|
|
|
|
if self._position == gtk.POS_TOP or self._position == gtk.POS_BOTTOM:
|
|
|
|
|
width = gtk.gdk.screen_width()
|
|
|
|
|
height = style.GRID_CELL_SIZE
|
|
|
|
|
else:
|
|
|
|
|
self._bg.props.padding_left = 0
|
|
|
|
|
self._bg.props.padding_right = 0
|
|
|
|
|
self._bg.props.padding_top = padding
|
|
|
|
|
self._bg.props.padding_bottom = padding
|
|
|
|
|
|
|
|
|
|
width = style.GRID_CELL_SIZE
|
|
|
|
|
height = gtk.gdk.screen_height()
|
|
|
|
|
self.resize(width, height)
|
|
|
|
|