Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/model
diff options
context:
space:
mode:
Diffstat (limited to 'shell/model')
-rw-r--r--shell/model/Makefile.am4
-rw-r--r--shell/model/homeactivity.py32
-rw-r--r--shell/model/homemodel.py69
3 files changed, 104 insertions, 1 deletions
diff --git a/shell/model/Makefile.am b/shell/model/Makefile.am
index 50fe145..010f000 100644
--- a/shell/model/Makefile.am
+++ b/shell/model/Makefile.am
@@ -6,4 +6,6 @@ sugar_PYTHON = \
Invites.py \
Owner.py \
MeshModel.py \
- ShellModel.py
+ ShellModel.py \
+ homeactivity.py \
+ homemodel.py
diff --git a/shell/model/homeactivity.py b/shell/model/homeactivity.py
new file mode 100644
index 0000000..8c4d232
--- /dev/null
+++ b/shell/model/homeactivity.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2006, Owen Williams.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+from sugar.graphics.canvasicon import CanvasIcon
+
+class HomeActivity:
+ def __init__(self, activity):
+ self._icon_name = activity.get_icon_name()
+ self._icon_color = activity.get_icon_color()
+ self._id = activity.get_id()
+
+ def get_icon_name(self):
+ return self._icon_name
+
+ def get_icon_color(self):
+ return self._icon_color
+
+ def get_id(self):
+ return self._id
diff --git a/shell/model/homemodel.py b/shell/model/homemodel.py
new file mode 100644
index 0000000..a5e2634
--- /dev/null
+++ b/shell/model/homemodel.py
@@ -0,0 +1,69 @@
+# Copyright (C) 2006, Owen Williams.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import gobject
+
+from sugar.graphics.canvasicon import CanvasIcon
+from sugar.graphics import style
+from model.homeactivity import HomeActivity
+
+class HomeModel(gobject.GObject):
+
+ __gsignals__ = {
+ 'activity-added': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT])),
+ 'activity-removed': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT]))
+ }
+
+ def __init__(self, shell):
+ gobject.GObject.__init__(self)
+ self._activities = []
+ self._shell = shell
+
+ shell.connect('activity-opened', self.__activity_opened_cb)
+ shell.connect('activity-closed', self.__activity_closed_cb)
+
+ def __iter__(self):
+ return iter(self._activities)
+
+ def __len__(self):
+ return len(self._activities)
+
+ def __getitem__(self, i):
+ return self._activities[i]
+
+ def __activity_opened_cb(self, model, activity):
+ self._add_activity(activity)
+
+ def __activity_closed_cb(self, model, activity):
+ self._remove_activity(activity)
+
+ def _add_activity(self, activity):
+ h_activity = HomeActivity(activity)
+ self._activities.append(h_activity)
+ self.emit('activity-added', h_activity)
+
+ def _remove_activity(self, activity):
+ i = 0
+ for h_activity in self._activities:
+ if h_activity.get_id() == activity.get_id():
+ self.emit('activity-removed', self._activities[i])
+ del self._activities[i]
+ return
+ i += 1