Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/view/frame
diff options
context:
space:
mode:
Diffstat (limited to 'shell/view/frame')
-rw-r--r--shell/view/frame/BottomPanel.py83
-rw-r--r--shell/view/frame/Frame.py70
-rw-r--r--shell/view/frame/Makefile.am8
-rw-r--r--shell/view/frame/PanelWindow.py27
-rw-r--r--shell/view/frame/RightPanel.py81
-rw-r--r--shell/view/frame/TopPanel.py70
-rw-r--r--shell/view/frame/__init__.py0
7 files changed, 339 insertions, 0 deletions
diff --git a/shell/view/frame/BottomPanel.py b/shell/view/frame/BottomPanel.py
new file mode 100644
index 0000000..d43160d
--- /dev/null
+++ b/shell/view/frame/BottomPanel.py
@@ -0,0 +1,83 @@
+import gtk
+import goocanvas
+import logging
+
+import conf
+from sugar.canvas.IconItem import IconItem
+from sugar.canvas.IconColor import IconColor
+from sugar.presence import PresenceService
+from sugar.canvas.CanvasBox import CanvasBox
+
+class ActivityItem(IconItem):
+ def __init__(self, activity):
+ icon_name = activity.get_icon()
+ IconItem.__init__(self, icon_name=icon_name, color=IconColor('white'))
+ self._activity = activity
+
+ def get_bundle_id(self):
+ return self._activity.get_id()
+
+class InviteItem(IconItem):
+ def __init__(self, invite):
+ IconItem.__init__(self, icon_name=invite.get_icon(),
+ color=invite.get_color())
+ self._invite = invite
+
+ def get_activity_id(self):
+ return self._invite.get_activity_id()
+
+ def get_bundle_id(self):
+ return self._invite.get_bundle_id()
+
+ def get_invite(self):
+ return self._invite
+
+class BottomPanel(CanvasBox):
+ def __init__(self, grid, shell_model):
+ CanvasBox.__init__(self, grid, CanvasBox.HORIZONTAL, 1)
+
+ self._shell_model = shell_model
+ self._invite_to_item = {}
+ self._invites = shell_model.get_invites()
+
+ registry = conf.get_activity_registry()
+ for activity in registry.list_activities():
+ if activity.get_show_launcher():
+ self.add_activity(activity)
+
+ 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)
+
+ def __activity_clicked_cb(self, icon):
+ self._shell_model.start_activity(icon.get_bundle_id())
+
+ def __invite_clicked_cb(self, icon):
+ self._invites.remove_invite(icon.get_invite())
+ self._shell_model.join_activity(icon.get_bundle_id(),
+ icon.get_activity_id())
+
+ def __invite_added_cb(self, invites, invite):
+ self.add_invite(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, 3, 3)
+ self.add_child(item)
+
+ def add_invite(self, invite):
+ item = InviteItem(invite)
+ item.connect('clicked', self.__invite_clicked_cb)
+ self.set_constraints(item, 3, 3)
+ self.add_child(item, 0)
+
+ self._invite_to_item[invite] = item
+
+ def remove_invite(self, invite):
+ self.remove_child(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
new file mode 100644
index 0000000..5ebeccc
--- /dev/null
+++ b/shell/view/frame/Frame.py
@@ -0,0 +1,70 @@
+import gtk
+import gobject
+import goocanvas
+
+from view.frame.BottomPanel import BottomPanel
+from view.frame.RightPanel import RightPanel
+from view.frame.TopPanel import TopPanel
+from view.frame.PanelWindow import PanelWindow
+from sugar.canvas.Grid import Grid
+
+class Frame:
+ def __init__(self, shell):
+ self._windows = []
+
+ shell_model = shell.get_model()
+
+ model = goocanvas.CanvasModelSimple()
+ root = model.get_root_item()
+
+ grid = Grid()
+
+ bg = goocanvas.Rect(fill_color="#4f4f4f", line_width=0)
+ grid.set_constraints(bg, 0, 0, 80, 60)
+ root.add_child(bg)
+
+ panel = BottomPanel(grid, shell_model)
+ grid.set_constraints(panel, 5, 55)
+ root.add_child(panel)
+
+ panel_window = PanelWindow(grid, model, 0, 55, 80, 5)
+ self._windows.append(panel_window)
+
+ panel = TopPanel(grid, shell)
+ root.add_child(panel)
+
+ panel_window = PanelWindow(grid, model, 0, 0, 80, 5)
+ self._windows.append(panel_window)
+
+ panel = RightPanel(grid, shell_model)
+ grid.set_constraints(panel, 75, 5)
+ root.add_child(panel)
+
+ panel_window = PanelWindow(grid, model, 75, 5, 5, 50)
+ self._windows.append(panel_window)
+
+ panel_window = PanelWindow(grid, model, 0, 5, 5, 50)
+ self._windows.append(panel_window)
+
+ 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)
+
+ def show(self):
+ for panel in self._windows:
+ panel.show()
+
+ def hide(self):
+ for panel in self._windows:
+ panel.hide()
+
+ def toggle_visibility(self):
+ for panel in self._windows:
+ if panel.props.visible:
+ panel.hide()
+ else:
+ panel.show()
diff --git a/shell/view/frame/Makefile.am b/shell/view/frame/Makefile.am
new file mode 100644
index 0000000..a737e01
--- /dev/null
+++ b/shell/view/frame/Makefile.am
@@ -0,0 +1,8 @@
+sugardir = $(pkgdatadir)/shell/view/frame
+sugar_PYTHON = \
+ __init__.py \
+ RightPanel.py \
+ PanelWindow.py \
+ Frame.py \
+ TopPanel.py \
+ BottomPanel.py
diff --git a/shell/view/frame/PanelWindow.py b/shell/view/frame/PanelWindow.py
new file mode 100644
index 0000000..549776f
--- /dev/null
+++ b/shell/view/frame/PanelWindow.py
@@ -0,0 +1,27 @@
+import gtk
+import goocanvas
+
+from sugar.canvas.CanvasView import CanvasView
+
+class PanelWindow(gtk.Window):
+ def __init__(self, grid, model, x, y, width, height):
+ gtk.Window.__init__(self)
+
+ self._grid = grid
+
+ self.set_decorated(False)
+
+ self.realize()
+ 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)
diff --git a/shell/view/frame/RightPanel.py b/shell/view/frame/RightPanel.py
new file mode 100644
index 0000000..f12ccf5
--- /dev/null
+++ b/shell/view/frame/RightPanel.py
@@ -0,0 +1,81 @@
+import goocanvas
+
+from sugar.canvas.IconItem import IconItem
+from sugar.canvas.IconColor import IconColor
+from sugar.canvas.CanvasBox import CanvasBox
+from sugar.presence import PresenceService
+from view.FriendIcon import FriendIcon
+from model.Friends import Friend
+
+class RightPanel(CanvasBox):
+ def __init__(self, grid, shell_model):
+ CanvasBox.__init__(self, grid, CanvasBox.VERTICAL, 1)
+ self._shell_model = shell_model
+ self._friends = shell_model.get_friends()
+ self._activity_ps = None
+ self._joined_hid = -1
+ self._left_hid = -1
+ self._buddies = {}
+
+ self._pservice = PresenceService.get_instance()
+ self._pservice.connect('activity-appeared',
+ self.__activity_appeared_cb)
+
+ shell_model.connect('activity-changed', self.__activity_changed_cb)
+
+ def add(self, buddy):
+ friend = Friend(buddy.get_name(), buddy.get_color())
+ icon = FriendIcon(self._shell_model, friend)
+ icon.set_popup_distance(1)
+ self.set_constraints(icon, 3, 3)
+ self.add_child(icon)
+
+ self._buddies[buddy.get_name()] = icon
+
+ def remove(self, buddy):
+ i = self.find_child(self._buddies[buddy.get_name()])
+ self.remove_child(i)
+
+ def clear(self):
+ while (self.get_n_children() > 0):
+ self.remove_child(0)
+ self._buddies = {}
+
+ def __activity_appeared_cb(self, pservice, activity_ps):
+ activity = self._shell_model.get_current_activity()
+ if activity and activity_ps.get_id() == activity.get_id():
+ self._set_activity_ps(activity_ps)
+
+ def _set_activity_ps(self, activity_ps):
+ if self._activity_ps == activity_ps:
+ return
+
+ if self._joined_hid > 0:
+ self._activity_ps.disconnect(self._joined_hid)
+ self._joined_hid = -1
+ if self._left_hid > 0:
+ self._activity_ps.disconnect(self._left_hid)
+ self._left_hid = -1
+
+ self._activity_ps = activity_ps
+
+ self.clear()
+
+ if activity_ps != None:
+ for buddy in activity_ps.get_joined_buddies():
+ self.add(buddy)
+
+ self._joined_hid = activity_ps.connect(
+ 'buddy-joined', self.__buddy_joined_cb)
+ self._left_hid = activity_ps.connect(
+ 'buddy-left', self.__buddy_left_cb)
+
+ def __activity_changed_cb(self, group, activity):
+ activity_ps = self._pservice.get_activity(activity.get_id())
+ self._set_activity_ps(activity_ps)
+
+ def __buddy_joined_cb(self, activity, buddy):
+ self.add(buddy)
+
+ def __buddy_left_cb(self, activity, buddy):
+ self.remove(buddy)
diff --git a/shell/view/frame/TopPanel.py b/shell/view/frame/TopPanel.py
new file mode 100644
index 0000000..1409d85
--- /dev/null
+++ b/shell/view/frame/TopPanel.py
@@ -0,0 +1,70 @@
+import goocanvas
+
+from sugar.canvas.CanvasBox import CanvasBox
+from sugar.canvas.IconItem import IconItem
+import sugar
+
+class TopPanel(goocanvas.Group):
+ def __init__(self, grid, shell):
+ goocanvas.Group.__init__(self)
+
+ self._grid = grid
+ self._shell = shell
+
+ box = CanvasBox(grid, CanvasBox.HORIZONTAL, 1)
+ self._grid.set_constraints(box, 5, 0)
+ self.add_child(box)
+
+ icon = IconItem(icon_name='stock-zoom-activity')
+ icon.connect('clicked', self.__level_clicked_cb, sugar.ZOOM_ACTIVITY)
+ box.set_constraints(icon, 3, 3)
+ 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, 3, 3)
+ 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, 3, 3)
+ box.add_child(icon)
+
+ icon = IconItem(icon_name='stock-zoom-mesh')
+ icon.connect('clicked', self.__level_clicked_cb, sugar.ZOOM_MESH)
+ box.set_constraints(icon, 3, 3)
+ box.add_child(icon)
+
+ box = CanvasBox(grid, CanvasBox.HORIZONTAL, 1)
+ self._grid.set_constraints(box, 60, 0)
+ self.add_child(box)
+
+ icon = IconItem(icon_name='stock-share')
+ icon.connect('clicked', self.__share_clicked_cb)
+ box.set_constraints(icon, 3, 3)
+ box.add_child(icon)
+
+ icon = IconItem(icon_name='stock-invite')
+ icon.connect('clicked', self.__invite_clicked_cb)
+ box.set_constraints(icon, 3, 3)
+ box.add_child(icon)
+
+ icon = IconItem(icon_name='stock-chat')
+ icon.connect('clicked', self.__chat_clicked_cb)
+ box.set_constraints(icon, 3, 3)
+ box.add_child(icon)
+
+ def __level_clicked_cb(self, item, level):
+ self._shell.set_zoom_level(level)
+
+ def __share_clicked_cb(self, item):
+ shell_model = self._shell.get_model()
+ activity = shell_model.get_current_activity()
+ if activity != None:
+ activity.share()
+
+ def __invite_clicked_cb(self, item):
+ pass
+
+ def __chat_clicked_cb(self, item):
+ pass
diff --git a/shell/view/frame/__init__.py b/shell/view/frame/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/shell/view/frame/__init__.py