Start moving to hippo canvas. (Friends presence in the activity regressed)
This commit is contained in:
@@ -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]
|
||||
+42
-42
@@ -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()
|
||||
|
||||
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)
|
||||
|
||||
panel = BottomPanel(shell)
|
||||
grid.set_constraints(panel, 5, 55)
|
||||
root.add_child(panel)
|
||||
|
||||
self._add_panel(model, 0, 55, 80, 5)
|
||||
|
||||
panel = TopPanel(shell, self._menu_shell)
|
||||
root.add_child(panel)
|
||||
|
||||
self._add_panel(model, 0, 0, 80, 5)
|
||||
|
||||
panel = RightPanel(shell, self._menu_shell)
|
||||
grid.set_constraints(panel, 75, 5)
|
||||
root.add_child(panel)
|
||||
|
||||
self._add_panel(model, 75, 5, 5, 50)
|
||||
|
||||
self._add_panel(model, 0, 5, 5, 50)
|
||||
|
||||
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()
|
||||
|
||||
def _add_panel(self, model, x, y, width, height):
|
||||
grid = self._shell.get_grid()
|
||||
grid = Grid()
|
||||
|
||||
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._menu_shell = MenuShell(grid)
|
||||
self._menu_shell.connect('activated', self._menu_shell_activated_cb)
|
||||
self._menu_shell.connect('deactivated', self._menu_shell_deactivated_cb)
|
||||
|
||||
self._windows.append(panel_window)
|
||||
top_panel = self._create_panel(grid, 0, 0, 16, 1)
|
||||
|
||||
box = ZoomBox(self._shell, self._menu_shell)
|
||||
top_panel.append(box, hippo.PACK_FIXED)
|
||||
|
||||
[x, y] = grid.point(1, 0)
|
||||
top_panel.move(box, x, y)
|
||||
|
||||
bottom_panel = self._create_panel(grid, 0, 11, 16, 1)
|
||||
|
||||
box = ActivitiesBox(self._shell)
|
||||
bottom_panel.append(box, hippo.PACK_FIXED)
|
||||
|
||||
[x, y] = grid.point(1, 0)
|
||||
bottom_panel.move(box, x, y)
|
||||
|
||||
left_panel = self._create_panel(grid, 0, 1, 1, 10)
|
||||
|
||||
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)
|
||||
|
||||
panel.move(x, y)
|
||||
panel.resize(width, height)
|
||||
|
||||
self._windows.append(panel)
|
||||
|
||||
return panel.get_root()
|
||||
|
||||
def _menu_shell_activated_cb(self, menu_shell):
|
||||
self._timeline.goto('slide_in', True)
|
||||
|
||||
@@ -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()
|
||||
canvas = hippo.Canvas()
|
||||
|
||||
self._bg = hippo.CanvasBox(background_color=0x4f4f4fff)
|
||||
canvas.set_root(self._bg)
|
||||
|
||||
self.add(canvas)
|
||||
canvas.show()
|
||||
|
||||
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)
|
||||
|
||||
screen = gtk.gdk.screen_get_default()
|
||||
self.window.set_transient_for(screen.get_root_window())
|
||||
|
||||
view = CanvasView()
|
||||
view.show()
|
||||
self.add(view)
|
||||
view.set_model(model)
|
||||
|
||||
self._grid.set_constraints(self, x, y, width, height)
|
||||
self._grid.set_constraints(view, x, y, width, height)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
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)
|
||||
|
||||
box = CanvasBox(grid, CanvasBox.HORIZONTAL)
|
||||
grid.set_constraints(box, 5, 0)
|
||||
self.add_child(box)
|
||||
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-mesh')
|
||||
icon.connect('clicked', self._level_clicked_cb, sugar.ZOOM_MESH)
|
||||
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)
|
||||
|
||||
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 = 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 = 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)
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user