sugar-toolkit-gtk3/shell/frame/Frame.py

87 lines
2.2 KiB
Python
Raw Normal View History

2006-08-23 11:52:18 +02:00
import gtk
import gobject
2006-09-07 15:11:51 +02:00
import goocanvas
2006-08-23 11:52:18 +02:00
2006-09-01 15:11:52 +02:00
from frame.BottomPanel import BottomPanel
from frame.RightPanel import RightPanel
from frame.TopPanel import TopPanel
2006-09-07 15:11:51 +02:00
from frame.PanelWindow import PanelWindow
from sugar.canvas.ScreenContainer import ScreenContainer
from sugar.canvas.GridLayout import GridLayout
from sugar.canvas.GridLayout import GridConstraints
from sugar.canvas.GridLayout import GridGroup
2006-08-23 11:52:18 +02:00
2006-09-01 15:11:52 +02:00
class Frame:
def __init__(self, shell, owner):
2006-09-07 15:11:51 +02:00
self._windows = []
self._model = goocanvas.CanvasModelSimple()
item = goocanvas.Rect(x=0, y=0, width=800, height=600,
line_width=0, fill_color="#4f4f4f")
self._model.get_root_item().add_child(item)
self._screen_layout = GridLayout()
self._screen_container = ScreenContainer(self._windows)
2006-08-23 11:52:18 +02:00
2006-09-07 15:11:51 +02:00
group = GridGroup()
group.props.width = 800
group.props.height = 600
layout = group.get_layout()
constraints = GridConstraints(0, 11, 16, 1)
self._create_window(constraints)
2006-09-01 15:33:55 +02:00
panel = BottomPanel(shell, owner.get_invites())
2006-09-07 15:11:51 +02:00
layout.set_constraints(panel, constraints)
group.add_child(panel)
# Top
constraints = GridConstraints(0, 0, 16, 1)
self._create_window(constraints)
# Left
constraints = GridConstraints(0, 1, 1, 10)
self._create_window(constraints)
# Right
constraints = GridConstraints(15, 1, 1, 10)
self._create_window(constraints)
self._model.get_root_item().add_child(group)
self._screen_container.set_layout(self._screen_layout)
def _create_window(self, constraints):
layout = self._screen_layout
window = PanelWindow(self._model)
layout.set_constraints(window, constraints)
self._windows.append(window)
bounds = layout.get_bounds(self._screen_container, constraints)
window.get_view().set_bounds(bounds[0], bounds[1],
bounds[2], bounds[3])
2006-08-28 16:53:29 +02:00
def __hide_timeout_cb(self):
self.hide()
return False
def show_and_hide(self, seconds):
self.show()
gobject.timeout_add(seconds * 1000, self.__hide_timeout_cb)
2006-08-28 16:53:29 +02:00
def show(self):
2006-09-07 15:11:51 +02:00
for panel in self._windows:
2006-09-01 15:33:55 +02:00
panel.show()
2006-08-28 16:53:29 +02:00
def hide(self):
2006-09-07 15:11:51 +02:00
for panel in self._windows:
2006-09-01 15:33:55 +02:00
panel.hide()
2006-08-23 11:52:18 +02:00
2006-08-28 16:53:29 +02:00
def toggle_visibility(self):
2006-09-07 15:11:51 +02:00
for panel in self._windows:
2006-09-01 15:33:55 +02:00
if panel.props.visible:
panel.hide()
else:
panel.show()