Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--shell/Makefile.am2
-rwxr-xr-xshell/Shell.py3
-rw-r--r--shell/home/HomeView.py51
-rw-r--r--shell/panel/FriendsPanel.py5
-rw-r--r--shell/panel/Makefile.am7
-rw-r--r--shell/panel/Panel.py53
-rw-r--r--shell/panel/PanelManager.py29
-rw-r--r--shell/panel/VerbsPanel.py64
-rw-r--r--shell/panel/__init__.py0
-rw-r--r--shell/session/Emulator.py19
-rw-r--r--shell/session/Session.py19
12 files changed, 187 insertions, 68 deletions
diff --git a/configure.ac b/configure.ac
index a6786f3..5afbf87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([Sugar],[0.20],[],[sugar])
+AC_INIT([Sugar],[0.22],[],[sugar])
AC_PREREQ([2.59])
@@ -39,6 +39,7 @@ activities/terminal/Makefile
shell/Makefile
shell/data/Makefile
shell/home/Makefile
+shell/panel/Makefile
shell/session/Makefile
shell/PresenceService/Makefile
sugar/Makefile
diff --git a/shell/Makefile.am b/shell/Makefile.am
index bad3fd8..7a9eb50 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = data session home PresenceService
+SUBDIRS = data session home panel PresenceService
bin_SCRIPTS = \
sugar \
diff --git a/shell/Shell.py b/shell/Shell.py
index 08890df..bb91bf3 100755
--- a/shell/Shell.py
+++ b/shell/Shell.py
@@ -17,6 +17,7 @@ from ChatController import ChatController
from sugar.activity import ActivityFactory
from sugar.activity import Activity
from FirstTimeDialog import FirstTimeDialog
+from panel.PanelManager import PanelManager
from sugar import conf
import sugar.logger
@@ -102,6 +103,8 @@ class Shell(gobject.GObject):
self._home_window.set_model(home_model)
self._set_zoom_level(Shell.ZOOM_HOME)
+ self._panel_manager = PanelManager(self)
+
def set_console(self, console):
self._console = console
diff --git a/shell/home/HomeView.py b/shell/home/HomeView.py
index 48a3044..9cc01ac 100644
--- a/shell/home/HomeView.py
+++ b/shell/home/HomeView.py
@@ -7,7 +7,6 @@ from sugar.canvas.IconItem import IconColor
from sugar.canvas.DonutItem import DonutItem
from sugar.canvas.DonutItem import PieceItem
from sugar.canvas.DonutItem import PieceIcon
-from sugar import conf
class TasksItem(DonutItem):
def __init__(self, shell):
@@ -39,50 +38,16 @@ class TasksItem(DonutItem):
self._items[activity.get_id()] = item
-class ActivityItem(IconItem):
- ICON_SIZE = 30
-
- def __init__(self, activity):
- IconItem.__init__(self, activity.get_icon(),
- IconColor('white'),
- ActivityItem.ICON_SIZE)
- self._activity = activity
-
- def get_activity_id(self):
- return self._activity.get_id()
-
-class ActivityBar(goocanvas.Group):
- def __init__(self, shell):
- goocanvas.Group.__init__(self)
-
- self._shell = shell
-
- registry = conf.get_activity_registry()
- for activity in registry.list_activities():
- if activity.get_show_launcher():
- self.add_activity(activity)
-
- def add_activity(self, activity):
- item = ActivityItem(activity)
- x = (ActivityItem.ICON_SIZE + 6) * self.get_n_children()
- item.set_property('x', x)
- self.add_child(item)
-
class Background(goocanvas.Group):
def __init__(self):
goocanvas.Group.__init__(self)
item = goocanvas.Rect(width=1200, height=900,
- fill_color="#4f4f4f")
- self.add_child(item)
-
- item = goocanvas.Rect(x=50, y=50, width=1100, height=800,
- line_width=0, fill_color="#d8d8d8",
- radius_x=30, radius_y=30)
+ fill_color="#d8d8d8")
self.add_child(item)
item = goocanvas.Text(text="My Activities",
- x=60, y=10, fill_color="white",
+ x=12, y=12, fill_color="black",
font="Sans 21")
self.add_child(item)
@@ -95,10 +60,6 @@ class Model(goocanvas.CanvasModelSimple):
background = Background()
root.add_child(background)
- activity_bar = ActivityBar(shell)
- activity_bar.translate(50, 860)
- root.add_child(activity_bar)
-
tasks = TasksItem(shell)
tasks.translate(600, 450)
root.add_child(tasks)
@@ -119,12 +80,8 @@ class HomeView(goocanvas.CanvasView):
self.set_model(canvas_model)
def __item_view_created_cb(self, view, item_view, item):
- if isinstance(item, ActivityItem):
- item_view.connect("button_press_event",
- self.__activity_button_press_cb,
- item.get_activity_id())
- elif isinstance(item, PieceItem) or \
- isinstance(item, PieceIcon):
+ if isinstance(item, PieceItem) or \
+ isinstance(item, PieceIcon):
item_view.connect("button_press_event",
self.__task_button_press_cb)
diff --git a/shell/panel/FriendsPanel.py b/shell/panel/FriendsPanel.py
new file mode 100644
index 0000000..5d14893
--- /dev/null
+++ b/shell/panel/FriendsPanel.py
@@ -0,0 +1,5 @@
+from panel.Panel import Panel
+
+class FriendsPanel(Panel):
+ def __init__(self, shell):
+ Panel.__init__(self)
diff --git a/shell/panel/Makefile.am b/shell/panel/Makefile.am
new file mode 100644
index 0000000..271a007
--- /dev/null
+++ b/shell/panel/Makefile.am
@@ -0,0 +1,7 @@
+sugardir = $(pkgdatadir)/shell/panel
+sugar_PYTHON = \
+ __init__.py \
+ FriendsPanel.py \
+ Panel.py \
+ PanelManager.py \
+ VerbsPanel.py
diff --git a/shell/panel/Panel.py b/shell/panel/Panel.py
new file mode 100644
index 0000000..7c3798b
--- /dev/null
+++ b/shell/panel/Panel.py
@@ -0,0 +1,53 @@
+import gtk
+import goocanvas
+
+class PanelModel(goocanvas.CanvasModelSimple):
+ BORDER = 4
+
+ def __init__(self, width, height):
+ goocanvas.CanvasModelSimple.__init__(self)
+
+ root = self.get_root_item()
+
+ item = goocanvas.Rect(x=0, y=0, width=width, height=height,
+ line_width=0, fill_color="#4f4f4f")
+ root.add_child(item)
+
+class PanelView(goocanvas.CanvasView):
+ def construct(self):
+ canvas_model = PanelModel(self.get_allocation().width,
+ self.get_allocation().height)
+ self.set_model(canvas_model)
+
+class Panel(gtk.Window):
+ def __init__(self):
+ gtk.Window.__init__(self)
+
+ self._view = PanelView()
+ self.add(self._view)
+ self._view.show()
+
+ self.connect('realize', self.__realize_cb)
+
+ def get_view(self):
+ return self._view
+
+ def get_model(self):
+ return self._view.get_model()
+
+ def get_border(self):
+ return PanelModel.BORDER
+
+ def get_height(self):
+ height = self._view.get_allocation().height
+ return height - self.get_border() * 2
+
+ def __realize_cb(self, window):
+ self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
+
+ def construct(self):
+ self._view.construct()
+
+ def show(self):
+ gtk.Window.show(self)
+ self.construct()
diff --git a/shell/panel/PanelManager.py b/shell/panel/PanelManager.py
new file mode 100644
index 0000000..998ba72
--- /dev/null
+++ b/shell/panel/PanelManager.py
@@ -0,0 +1,29 @@
+import gtk
+
+from panel.VerbsPanel import VerbsPanel
+from panel.FriendsPanel import FriendsPanel
+from panel.Panel import Panel
+
+class PanelManager:
+ def __init__(self, shell):
+ size = 30
+
+ self._verbs_panel = VerbsPanel(shell)
+ self._verbs_panel.move(0, gtk.gdk.screen_height() - size)
+ self._verbs_panel.resize(gtk.gdk.screen_width(), size)
+ self._verbs_panel.show()
+
+ self._friends_panel = FriendsPanel(shell)
+ self._friends_panel.move(gtk.gdk.screen_width() - size, 0)
+ self._friends_panel.resize(size, gtk.gdk.screen_height())
+ self._friends_panel.show()
+
+ panel = Panel()
+ panel.move(0, 0)
+ panel.resize(gtk.gdk.screen_width(), size)
+ panel.show()
+
+ panel = Panel()
+ panel.move(0, 0)
+ panel.resize(size, gtk.gdk.screen_height())
+ panel.show()
diff --git a/shell/panel/VerbsPanel.py b/shell/panel/VerbsPanel.py
new file mode 100644
index 0000000..751acbc
--- /dev/null
+++ b/shell/panel/VerbsPanel.py
@@ -0,0 +1,64 @@
+import gtk
+import goocanvas
+
+from sugar.canvas.IconItem import IconItem
+from sugar.canvas.IconItem import IconColor
+from sugar import conf
+from panel.Panel import Panel
+
+class ActivityItem(IconItem):
+ def __init__(self, activity, size):
+ IconItem.__init__(self, activity.get_icon(),
+ IconColor('white'), size)
+ self._activity = activity
+
+ def get_activity_id(self):
+ return self._activity.get_id()
+
+class ActivityBar(goocanvas.Group):
+ def __init__(self, shell, height):
+ goocanvas.Group.__init__(self)
+
+ self._shell = shell
+ self._height = height
+
+ registry = conf.get_activity_registry()
+ for activity in registry.list_activities():
+ if activity.get_show_launcher():
+ self.add_activity(activity)
+
+ def add_activity(self, activity):
+ item = ActivityItem(activity, self._height)
+
+ icon_size = self._height
+ x = (icon_size + 6) * self.get_n_children()
+ item.set_property('x', x)
+
+ self.add_child(item)
+
+class VerbsPanel(Panel):
+ def __init__(self, shell):
+ Panel.__init__(self)
+
+ self._shell = shell
+
+ view = self.get_view()
+ view.connect("item_view_created", self.__item_view_created_cb)
+
+ def construct(self):
+ Panel.construct(self)
+
+ root = self.get_model().get_root_item()
+
+ activity_bar = ActivityBar(self._shell, self.get_height())
+ activity_bar.translate(self.get_border(), self.get_border())
+ root.add_child(activity_bar)
+
+ def __item_view_created_cb(self, view, item_view, item):
+ if isinstance(item, ActivityItem):
+ item_view.connect("button_press_event",
+ self.__activity_button_press_cb,
+ item.get_activity_id())
+
+ def __activity_button_press_cb(self, view, target, event, activity_id):
+ self._shell.start_activity(activity_id)
diff --git a/shell/panel/__init__.py b/shell/panel/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/shell/panel/__init__.py
diff --git a/shell/session/Emulator.py b/shell/session/Emulator.py
index a46a46d..e15d152 100644
--- a/shell/session/Emulator.py
+++ b/shell/session/Emulator.py
@@ -54,22 +54,6 @@ class XnestProcess(Process):
Process.start(self)
os.environ['DISPLAY'] = ":%d" % (self._display)
-class DbusProcess(Process):
- def __init__(self):
- config = sugar.env.get_dbus_config()
- cmd = "dbus-daemon --print-address --config-file %s" % config
- Process.__init__(self, cmd)
-
- def get_name(self):
- return 'Dbus'
-
- def start(self):
- Process.start(self, True)
- dbus_file = os.fdopen(self._stdout)
- addr = dbus_file.readline().strip()
- dbus_file.close()
- os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr
-
class Emulator:
"""The OLPC emulator"""
def start(self):
@@ -84,6 +68,3 @@ class Emulator:
print 'Cannot run the emulator. You need to install \
Xephyr or Xnest.'
sys.exit(0)
-
- process = DbusProcess()
- process.start()
diff --git a/shell/session/Session.py b/shell/session/Session.py
index 1019851..f864da5 100644
--- a/shell/session/Session.py
+++ b/shell/session/Session.py
@@ -9,6 +9,22 @@ from ConsoleWindow import ConsoleWindow
from session.Process import Process
import sugar.env
+class DbusProcess(Process):
+ def __init__(self):
+ config = sugar.env.get_dbus_config()
+ cmd = "dbus-daemon --print-address --config-file %s" % config
+ Process.__init__(self, cmd)
+
+ def get_name(self):
+ return 'Dbus'
+
+ def start(self):
+ Process.start(self, True)
+ dbus_file = os.fdopen(self._stdout)
+ addr = dbus_file.readline().strip()
+ dbus_file.close()
+ os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr
+
class MatchboxProcess(Process):
def __init__(self):
kbd_config = os.path.join(sugar.env.get_data_dir(), 'kbdconfig')
@@ -26,6 +42,9 @@ class Session:
"""Takes care of running the shell and all the sugar processes"""
def start(self):
"""Start the session"""
+ process = DbusProcess()
+ process.start()
+
process = MatchboxProcess()
process.start()