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

84 lines
2.1 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
2006-09-08 01:13:42 +02:00
from frame.RightPanel import RightPanel
2006-09-08 00:51:45 +02:00
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
from sugar.canvas.GridModel import GridModel
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 = GridModel("#4f4f4f")
layout = self._model.get_layout()
2006-09-07 15:11:51 +02:00
self._screen_layout = GridLayout()
self._screen_container = ScreenContainer(self._windows)
2006-08-23 11:52:18 +02:00
2006-09-08 00:51:45 +02:00
constraints = GridConstraints(0, 0, 16, 1)
2006-09-07 15:11:51 +02:00
self._create_window(constraints)
2006-09-01 15:33:55 +02:00
2006-09-08 00:51:45 +02:00
panel = TopPanel(shell)
2006-09-07 15:11:51 +02:00
layout.set_constraints(panel, constraints)
self._model.add(panel)
2006-09-07 15:11:51 +02:00
2006-09-08 01:13:42 +02:00
constraints = GridConstraints(15, 1, 1, 10)
self._create_window(constraints)
panel = RightPanel(shell, owner.get_friends())
layout.set_constraints(panel, constraints)
self._model.add(panel)
2006-09-08 00:51:45 +02:00
constraints = GridConstraints(0, 11, 16, 1)
2006-09-07 15:11:51 +02:00
self._create_window(constraints)
2006-09-08 00:51:45 +02:00
panel = BottomPanel(shell, owner.get_invites())
layout.set_constraints(panel, constraints)
self._model.add(panel)
2006-09-07 15:11:51 +02:00
# Left
constraints = GridConstraints(0, 1, 1, 10)
self._create_window(constraints)
self._screen_container.set_layout(self._screen_layout)
def _create_window(self, constraints):
window = PanelWindow(self._model)
self._screen_layout.set_constraints(window, constraints)
2006-09-07 15:11:51 +02:00
self._windows.append(window)
bounds = self._model.get_layout().get_bounds(self._model._root, constraints)
window.scale_to_screen()
window.set_bounds(constraints)
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()