Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-01 23:50:43 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-01 23:50:43 (GMT)
commit0a912e214a815717be270a4ae49becc8721a26dc (patch)
treea4d6813a0709963269f579f7f40bf7971ac0126f /shell
parentd05f1f13d325dc41674ff99020dbcb67ef78dab8 (diff)
Start moving to hippo canvas. (Friends presence in the activity regressed)
Diffstat (limited to 'shell')
-rw-r--r--shell/view/frame/ActivitiesBox.py (renamed from shell/view/frame/BottomPanel.py)47
-rw-r--r--shell/view/frame/Frame.py70
-rw-r--r--shell/view/frame/PanelWindow.py31
-rw-r--r--shell/view/frame/RightPanel.py12
-rw-r--r--shell/view/frame/ZoomBox.py (renamed from shell/view/frame/TopPanel.py)58
5 files changed, 102 insertions, 116 deletions
diff --git a/shell/view/frame/BottomPanel.py b/shell/view/frame/ActivitiesBox.py
index 7509576..d46f3be 100644
--- a/shell/view/frame/BottomPanel.py
+++ b/shell/view/frame/ActivitiesBox.py
@@ -1,26 +1,25 @@
-import gtk
-import goocanvas
+import hippo
import logging
import conf
-from sugar.canvas.IconItem import IconItem
-from sugar.canvas.IconColor import IconColor
+from sugar.graphics.canvasicon import CanvasIcon
from sugar.presence import PresenceService
-from sugar.canvas.CanvasBox import CanvasBox
+from sugar.graphics import style
-class ActivityItem(IconItem):
+class ActivityItem(CanvasIcon):
def __init__(self, activity):
icon_name = activity.get_icon()
- IconItem.__init__(self, icon_name=icon_name, color=IconColor('white'))
+ CanvasIcon.__init__(self, icon_name=icon_name)
+ style.apply_stylesheet(self, 'frame-activity-icon')
self._activity = activity
def get_bundle_id(self):
return self._activity.get_id()
-class InviteItem(IconItem):
+class InviteItem(CanvasIcon):
def __init__(self, invite):
- IconItem.__init__(self, icon_name=invite.get_icon(),
- color=invite.get_color())
+ CanvasIcon.__init__(self, icon_name=invite.get_icon(),
+ color=invite.get_color())
self._invite = invite
def get_activity_id(self):
@@ -32,9 +31,9 @@ class InviteItem(IconItem):
def get_invite(self):
return self._invite
-class BottomPanel(CanvasBox):
+class ActivitiesBox(hippo.CanvasBox):
def __init__(self, shell):
- CanvasBox.__init__(self, shell.get_grid(), CanvasBox.HORIZONTAL)
+ hippo.CanvasBox.__init__(self, orientation=hippo.ORIENTATION_HORIZONTAL)
self._shell = shell
self._invite_to_item = {}
@@ -47,37 +46,35 @@ class BottomPanel(CanvasBox):
for invite in self._invites:
self.add_invite(invite)
- self._invites.connect('invite-added', self.__invite_added_cb)
- self._invites.connect('invite-removed', self.__invite_removed_cb)
+ self._invites.connect('invite-added', self._invite_added_cb)
+ self._invites.connect('invite-removed', self._invite_removed_cb)
- def __activity_clicked_cb(self, icon):
+ def _activity_clicked_cb(self, icon):
self._shell.start_activity(icon.get_bundle_id())
- def __invite_clicked_cb(self, icon):
+ def _invite_clicked_cb(self, icon):
self._invites.remove_invite(icon.get_invite())
self._shell.join_activity(icon.get_bundle_id(),
icon.get_activity_id())
- def __invite_added_cb(self, invites, invite):
+ def _invite_added_cb(self, invites, invite):
self.add_invite(invite)
- def __invite_removed_cb(self, invites, invite):
+ def _invite_removed_cb(self, invites, invite):
self.remove_invite(invite)
def add_activity(self, activity):
item = ActivityItem(activity)
- item.connect('clicked', self.__activity_clicked_cb)
- self.set_constraints(item, 5, 5)
- self.add_child(item)
+ item.connect('activated', self._activity_clicked_cb)
+ self.append(item, 0)
def add_invite(self, invite):
item = InviteItem(invite)
- item.connect('clicked', self.__invite_clicked_cb)
- self.set_constraints(item, 5, 5)
- self.add_child(item, 0)
+ item.connect('activated', self._invite_clicked_cb)
+ self.append(item, 0)
self._invite_to_item[invite] = item
def remove_invite(self, invite):
- self.remove_child(self._invite_to_item[invite])
+ self.remove(self._invite_to_item[invite])
del self._invite_to_item[invite]
diff --git a/shell/view/frame/Frame.py b/shell/view/frame/Frame.py
index 0206080..bd7e51f 100644
--- a/shell/view/frame/Frame.py
+++ b/shell/view/frame/Frame.py
@@ -1,15 +1,14 @@
import gtk
import gobject
-import goocanvas
+import hippo
import wnck
-from view.frame.BottomPanel import BottomPanel
-from view.frame.RightPanel import RightPanel
-from view.frame.TopPanel import TopPanel
+from view.frame.ActivitiesBox import ActivitiesBox
+from view.frame.ZoomBox import ZoomBox
from view.frame.PanelWindow import PanelWindow
-from sugar.canvas.Grid import Grid
from sugar.canvas.Timeline import Timeline
from sugar.canvas.MenuShell import MenuShell
+from sugar.graphics.grid import Grid
class EventFrame(gobject.GObject):
__gsignals__ = {
@@ -116,51 +115,52 @@ class Frame:
self._timeline.add_tag('before_slide_out', 36, 36)
self._timeline.add_tag('slide_out', 37, 42)
- model = goocanvas.CanvasModelSimple()
- root = model.get_root_item()
+ self._event_frame = EventFrame()
+ self._event_frame.connect('enter-edge', self._enter_edge_cb)
+ self._event_frame.connect('enter-corner', self._enter_corner_cb)
+ self._event_frame.connect('leave', self._event_frame_leave_cb)
+ self._event_frame.show()
+
+ grid = Grid()
- grid = shell.get_grid()
self._menu_shell = MenuShell(grid)
self._menu_shell.connect('activated', self._menu_shell_activated_cb)
self._menu_shell.connect('deactivated', self._menu_shell_deactivated_cb)
- bg = goocanvas.Rect(fill_color="#4f4f4f", line_width=0)
- grid.set_constraints(bg, 0, 0, 80, 60)
- root.add_child(bg)
+ top_panel = self._create_panel(grid, 0, 0, 16, 1)
- panel = BottomPanel(shell)
- grid.set_constraints(panel, 5, 55)
- root.add_child(panel)
+ box = ZoomBox(self._shell, self._menu_shell)
+ top_panel.append(box, hippo.PACK_FIXED)
- self._add_panel(model, 0, 55, 80, 5)
+ [x, y] = grid.point(1, 0)
+ top_panel.move(box, x, y)
- panel = TopPanel(shell, self._menu_shell)
- root.add_child(panel)
+ bottom_panel = self._create_panel(grid, 0, 11, 16, 1)
- self._add_panel(model, 0, 0, 80, 5)
-
- panel = RightPanel(shell, self._menu_shell)
- grid.set_constraints(panel, 75, 5)
- root.add_child(panel)
+ box = ActivitiesBox(self._shell)
+ bottom_panel.append(box, hippo.PACK_FIXED)
- self._add_panel(model, 75, 5, 5, 50)
+ [x, y] = grid.point(1, 0)
+ bottom_panel.move(box, x, y)
- self._add_panel(model, 0, 5, 5, 50)
+ left_panel = self._create_panel(grid, 0, 1, 1, 10)
- self._event_frame = EventFrame()
- self._event_frame.connect('enter-edge', self._enter_edge_cb)
- self._event_frame.connect('enter-corner', self._enter_corner_cb)
- self._event_frame.connect('leave', self._event_frame_leave_cb)
- self._event_frame.show()
+ right_panel = self._create_panel(grid, 15, 1, 1, 10)
+
+ def _create_panel(self, grid, x, y, width, height):
+ panel = PanelWindow()
+
+ panel.connect('enter-notify-event', self._enter_notify_cb)
+ panel.connect('leave-notify-event', self._leave_notify_cb)
+
+ [x, y, width, height] = grid.rectangle(x, y, width, height)
- def _add_panel(self, model, x, y, width, height):
- grid = self._shell.get_grid()
+ panel.move(x, y)
+ panel.resize(width, height)
- panel_window = PanelWindow(grid, model, x, y, width, height)
- panel_window.connect('enter-notify-event', self._enter_notify_cb)
- panel_window.connect('leave-notify-event', self._leave_notify_cb)
+ self._windows.append(panel)
- self._windows.append(panel_window)
+ return panel.get_root()
def _menu_shell_activated_cb(self, menu_shell):
self._timeline.goto('slide_in', True)
diff --git a/shell/view/frame/PanelWindow.py b/shell/view/frame/PanelWindow.py
index 549776f..0c2930c 100644
--- a/shell/view/frame/PanelWindow.py
+++ b/shell/view/frame/PanelWindow.py
@@ -1,27 +1,24 @@
import gtk
-import goocanvas
-
-from sugar.canvas.CanvasView import CanvasView
+import hippo
class PanelWindow(gtk.Window):
- def __init__(self, grid, model, x, y, width, height):
+ def __init__(self):
gtk.Window.__init__(self)
- self._grid = grid
-
self.set_decorated(False)
+ self.connect('realize', self._realize_cb)
- self.realize()
- self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
- self.window.set_accept_focus(False)
+ canvas = hippo.Canvas()
- screen = gtk.gdk.screen_get_default()
- self.window.set_transient_for(screen.get_root_window())
+ self._bg = hippo.CanvasBox(background_color=0x4f4f4fff)
+ canvas.set_root(self._bg)
- view = CanvasView()
- view.show()
- self.add(view)
- view.set_model(model)
+ self.add(canvas)
+ canvas.show()
- self._grid.set_constraints(self, x, y, width, height)
- self._grid.set_constraints(view, x, y, width, height)
+ def get_root(self):
+ return self._bg
+
+ def _realize_cb(self, widget):
+ self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
+ self.window.set_accept_focus(False)
diff --git a/shell/view/frame/RightPanel.py b/shell/view/frame/RightPanel.py
index 28c81b3..9c16402 100644
--- a/shell/view/frame/RightPanel.py
+++ b/shell/view/frame/RightPanel.py
@@ -1,16 +1,15 @@
-import goocanvas
+import hippo
-from sugar.canvas.IconItem import IconItem
+from sugar.graphics.CanvasIcon import CanvasIcon
from sugar.canvas.IconColor import IconColor
-from sugar.canvas.CanvasBox import CanvasBox
from sugar.presence import PresenceService
from view.BuddyIcon import BuddyIcon
from model.BuddyModel import BuddyModel
from view.frame.MenuStrategy import MenuStrategy
-class RightPanel(CanvasBox):
+class RightPanel(hippo.CanvasBox):
def __init__(self, shell, menu_shell):
- CanvasBox.__init__(self, shell.get_grid(), CanvasBox.VERTICAL)
+ CanvasBox.__init__(self)
self._shell = shell
self._menu_shell = menu_shell
self._activity_ps = None
@@ -28,8 +27,7 @@ class RightPanel(CanvasBox):
model = BuddyModel(buddy=buddy)
icon = BuddyIcon(self._shell, self._menu_shell, model)
icon.set_menu_strategy(MenuStrategy())
- self.set_constraints(icon, 5, 5)
- self.add_child(icon)
+ self.append(icon, 0)
self._buddies[buddy.get_name()] = icon
diff --git a/shell/view/frame/TopPanel.py b/shell/view/frame/ZoomBox.py
index e0aec2e..8e78979 100644
--- a/shell/view/frame/TopPanel.py
+++ b/shell/view/frame/ZoomBox.py
@@ -1,9 +1,11 @@
import goocanvas
+import hippo
-from sugar.canvas.CanvasBox import CanvasBox
-from sugar.canvas.IconItem import IconItem
-from sugar.canvas.MenuIcon import MenuIcon
+from sugar.graphics.canvasicon import CanvasIcon
+from sugar.graphics.menuicon import MenuIcon
+from sugar.graphics import style
from sugar.canvas.Menu import Menu
+from sugar.canvas.IconItem import IconItem
from view.frame.MenuStrategy import MenuStrategy
import sugar
@@ -51,53 +53,45 @@ class ActivityIcon(MenuIcon):
if action == ActivityMenu.ACTION_CLOSE:
activity.close()
-class TopPanel(goocanvas.Group):
+class ZoomBox(hippo.CanvasBox):
def __init__(self, shell, menu_shell):
- goocanvas.Group.__init__(self)
+ hippo.CanvasBox.__init__(self, orientation=hippo.ORIENTATION_HORIZONTAL)
self._shell = shell
self._menu_shell = menu_shell
self._activity_icon = None
- grid = shell.get_grid()
-
- box = CanvasBox(grid, CanvasBox.HORIZONTAL)
- grid.set_constraints(box, 5, 0)
- self.add_child(box)
-
- icon = IconItem(icon_name='stock-zoom-mesh')
- icon.connect('clicked', self._level_clicked_cb, sugar.ZOOM_MESH)
- box.set_constraints(icon, 5, 5)
- box.add_child(icon)
-
- icon = IconItem(icon_name='stock-zoom-friends')
- icon.connect('clicked', self._level_clicked_cb, sugar.ZOOM_FRIENDS)
- box.set_constraints(icon, 5, 5)
- box.add_child(icon)
+ icon = CanvasIcon(icon_name='stock-zoom-mesh')
+ style.apply_stylesheet(icon, 'frame-zoom-icon')
+ icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_MESH)
+ self.append(icon, 0)
- icon = IconItem(icon_name='stock-zoom-home')
- icon.connect('clicked', self._level_clicked_cb, sugar.ZOOM_HOME)
- box.set_constraints(icon, 5, 5)
- box.add_child(icon)
+ icon = CanvasIcon(icon_name='stock-zoom-friends')
+ style.apply_stylesheet(icon, 'frame-zoom-icon')
+ icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_FRIENDS)
+ self.append(icon, 0)
- icon = IconItem(icon_name='stock-zoom-activity')
- icon.connect('clicked', self._level_clicked_cb, sugar.ZOOM_ACTIVITY)
- box.set_constraints(icon, 5, 5)
- box.add_child(icon)
+ icon = CanvasIcon(icon_name='stock-zoom-home')
+ style.apply_stylesheet(icon, 'frame-zoom-icon')
+ icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_HOME)
+ self.append(icon, 0)
- self._box = box
+ icon = CanvasIcon(icon_name='stock-zoom-activity')
+ style.apply_stylesheet(icon, 'frame-zoom-icon')
+ icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_ACTIVITY)
+ self.append(icon, 0)
shell.connect('activity-changed', self._activity_changed_cb)
self._set_current_activity(shell.get_current_activity())
def _set_current_activity(self, activity):
if self._activity_icon:
- self._box.remove_child(self._activity_icon)
+ self.remove(self._activity_icon)
if activity:
icon = ActivityIcon(self._shell, self._menu_shell, activity)
- self._box.set_constraints(icon, 5, 5)
- self._box.add_child(icon)
+ style.apply_stylesheet(icon, 'frame-zoom-icon')
+ self.append(icon, 0)
self._activity_icon = icon
else:
self._activity_icon = None