2006-08-19 01:29:42 +02:00
|
|
|
import gtk
|
2006-08-29 11:48:20 +02:00
|
|
|
import goocanvas
|
|
|
|
import cairo
|
2006-08-19 01:29:42 +02:00
|
|
|
|
2006-08-29 11:48:20 +02:00
|
|
|
from home.MeshGroup import MeshGroup
|
|
|
|
from home.HomeGroup import HomeGroup
|
|
|
|
from home.FriendsGroup import FriendsGroup
|
2006-08-29 16:07:23 +02:00
|
|
|
from home.IconLayout import IconLayout
|
2006-08-29 11:48:20 +02:00
|
|
|
import sugar
|
2006-08-19 01:29:42 +02:00
|
|
|
|
|
|
|
class HomeWindow(gtk.Window):
|
2006-08-22 16:15:34 +02:00
|
|
|
def __init__(self, shell):
|
2006-08-19 01:29:42 +02:00
|
|
|
gtk.Window.__init__(self)
|
2006-08-22 16:15:34 +02:00
|
|
|
self._shell = shell
|
2006-08-29 14:39:34 +02:00
|
|
|
self._width = MeshGroup.WIDTH
|
|
|
|
self._height = MeshGroup.HEIGHT
|
2006-08-19 01:29:42 +02:00
|
|
|
|
2006-08-29 17:12:39 +02:00
|
|
|
self._view = goocanvas.CanvasView()
|
|
|
|
self._view.set_size_request(gtk.gdk.screen_width(),
|
|
|
|
gtk.gdk.screen_height())
|
2006-08-31 17:58:18 +02:00
|
|
|
self.set_zoom_level(sugar.ZOOM_HOME)
|
2006-08-29 17:12:39 +02:00
|
|
|
model = goocanvas.CanvasModelSimple()
|
|
|
|
self._view.set_model(model)
|
|
|
|
|
|
|
|
self.add(self._view)
|
|
|
|
self._view.show()
|
|
|
|
|
2006-08-29 11:48:20 +02:00
|
|
|
self.realize()
|
|
|
|
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)
|
|
|
|
|
2006-08-30 11:46:14 +02:00
|
|
|
def set_owner(self, owner):
|
2006-08-29 17:12:39 +02:00
|
|
|
root = self._view.get_model().get_root_item()
|
2006-08-19 01:29:42 +02:00
|
|
|
|
2006-08-29 16:07:23 +02:00
|
|
|
icon_layout = IconLayout(MeshGroup.WIDTH, MeshGroup.HEIGHT)
|
|
|
|
x1 = (self._width - FriendsGroup.WIDTH) / 2
|
|
|
|
y1 = (self._height - FriendsGroup.HEIGHT) / 2
|
|
|
|
x2 = x1 + FriendsGroup.WIDTH
|
|
|
|
y2 = y1 + FriendsGroup.HEIGHT
|
|
|
|
icon_layout.set_bounds(x1, y1, x2, y2)
|
|
|
|
|
2006-08-30 12:22:01 +02:00
|
|
|
self._mesh_group = MeshGroup(self._shell, icon_layout)
|
2006-08-29 11:48:20 +02:00
|
|
|
root.add_child(self._mesh_group)
|
2006-08-19 01:29:42 +02:00
|
|
|
|
2006-08-29 16:07:23 +02:00
|
|
|
icon_layout = IconLayout(FriendsGroup.WIDTH, FriendsGroup.HEIGHT)
|
|
|
|
x1 = (self._width - HomeGroup.WIDTH) / 2
|
|
|
|
y1 = (self._height - HomeGroup.HEIGHT) / 2
|
|
|
|
x2 = x1 + HomeGroup.WIDTH
|
|
|
|
y2 = y1 + HomeGroup.HEIGHT
|
|
|
|
icon_layout.set_bounds(x1, y1, x2, y2)
|
|
|
|
|
2006-09-04 14:30:44 +02:00
|
|
|
self._friends_group = FriendsGroup(self._shell, owner.get_friends(),
|
|
|
|
icon_layout)
|
2006-08-29 14:39:34 +02:00
|
|
|
self._friends_group.translate((self._width - FriendsGroup.WIDTH) / 2,
|
|
|
|
(self._height - FriendsGroup.HEIGHT) / 2)
|
2006-08-29 11:48:20 +02:00
|
|
|
root.add_child(self._friends_group)
|
2006-08-22 16:15:34 +02:00
|
|
|
|
2006-08-29 11:48:20 +02:00
|
|
|
self._home_group = HomeGroup(self._shell)
|
2006-08-29 14:39:34 +02:00
|
|
|
self._home_group.translate((self._width - HomeGroup.WIDTH) / 2,
|
|
|
|
(self._height - HomeGroup.HEIGHT) / 2)
|
2006-08-29 11:48:20 +02:00
|
|
|
root.add_child(self._home_group)
|
|
|
|
|
|
|
|
def set_zoom_level(self, level):
|
|
|
|
if level == sugar.ZOOM_HOME:
|
2006-08-29 14:39:34 +02:00
|
|
|
width = HomeGroup.WIDTH * 1.1
|
|
|
|
height = HomeGroup.HEIGHT * 1.1
|
2006-08-29 11:48:20 +02:00
|
|
|
elif level == sugar.ZOOM_FRIENDS:
|
2006-08-29 14:39:34 +02:00
|
|
|
width = FriendsGroup.WIDTH * 1.1
|
|
|
|
height = FriendsGroup.HEIGHT * 1.1
|
2006-08-29 11:48:20 +02:00
|
|
|
elif level == sugar.ZOOM_MESH:
|
2006-08-29 14:39:34 +02:00
|
|
|
width = MeshGroup.WIDTH
|
|
|
|
height = MeshGroup.HEIGHT
|
|
|
|
|
2006-08-29 17:12:39 +02:00
|
|
|
self._view.set_bounds((self._width - width) / 2,
|
|
|
|
(self._height - height) / 2,
|
|
|
|
width, height)
|
|
|
|
self._view.set_scale(gtk.gdk.screen_width() / width)
|