Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsetup.py14
-rwxr-xr-xsrc/extensions/tutoriusremote.py123
2 files changed, 131 insertions, 6 deletions
diff --git a/setup.py b/setup.py
index e33873c..49bae4c 100755
--- a/setup.py
+++ b/setup.py
@@ -74,7 +74,7 @@ class TestCommand(Command):
sources)
coverage.report(sources)
coverage.erase()
-
+
def _listsources(self, arg, dirname, fnames):
fnames = filter(lambda x:x.endswith('.py'), fnames)
for name in fnames:
@@ -83,7 +83,7 @@ class TestCommand(Command):
setup(name='Tutorius',
version='0.0',
description='Interactive tutor and Tutorial creator',
- maintainer='Simon Poirier',
+ maintainer='Simon Poirier',
maintainer_email='simpoir@gmail.com',
author='Tutorius team',
author_email='sugar-narratives@googlegroups.com',
@@ -97,13 +97,15 @@ setup(name='Tutorius',
'sugar.tutorius.apilib.httplib2',
],
package_dir={
- 'sugar.tutorius': 'tutorius',
- 'sugar.tutorius.addons': 'addons',
- },
+ 'sugar.tutorius': 'tutorius',
+ 'sugar.tutorius.addons': 'addons',
+ },
cmdclass = {'test': TestCommand},
data_files=[('share/icons/sugar/scalable/actions', glob.glob('data/icons/*.svg')),
+ ('share/icons/sugar/scalable/device', ['data/icons/tutortool.svg']),
('share/tutorius/ui', glob.glob('data/ui/*.glade')),
+ ('share/sugar/extensions/deviceicon', glob.glob('src/extensions/*')),
]
)
-# vim: set et sw=4 sts=4 ts=4:
+# vim: set et sw=4 sts=4 ts=4:
diff --git a/src/extensions/tutoriusremote.py b/src/extensions/tutoriusremote.py
new file mode 100755
index 0000000..92e031a
--- /dev/null
+++ b/src/extensions/tutoriusremote.py
@@ -0,0 +1,123 @@
+# Copyright (C) 2009, Tutorius.org
+# Copyright (C) 2009, Simon Poirier <simpoir@gmail.com>
+#
+#
+# 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
+"""
+This modules regroups the UI elements that drives the tutorial and tutorial
+creator from the Sugar frame.
+"""
+
+import gtk
+
+from gettext import gettext as _
+import gconf
+import dbus
+
+import logging
+
+from sugar.graphics.tray import TrayIcon
+from sugar.graphics.palette import Palette
+from sugar.graphics.xocolor import XoColor
+from sugar.graphics.combobox import ComboBox
+
+from jarabe.frame.frameinvoker import FrameWidgetInvoker
+from jarabe.model.shell import get_model
+
+from sugar.tutorius.creator import default_creator
+
+from sugar.tutorius.vault import Vault
+
+_ICON_NAME = 'tutortool'
+
+LOGGER = logging.getLogger('remote')
+
+class TutoriusRemote(TrayIcon):
+
+ FRAME_POSITION_RELATIVE = 102
+
+ def __init__(self, creator):
+ self._creator = creator
+
+ client = gconf.client_get_default()
+ self._color = XoColor(client.get_string('/desktop/sugar/user/color'))
+
+ super(TutoriusRemote, self).__init__(icon_name=_ICON_NAME,
+ xo_color=self._color)
+
+ self.set_palette_invoker(FrameWidgetInvoker(self))
+
+ self.palette = TPalette(_('Tutorius'))
+ self.palette.set_group_id('frame')
+
+
+class TPalette(Palette):
+ def __init__(self, primary_text):
+ super(TPalette, self).__init__(primary_text)
+
+ self._creator_item = gtk.MenuItem(_('Create a tutorial'))
+ self._creator_item.connect('activate', self._start_creator)
+ self._creator_item.show()
+
+ self._tut_list_item = gtk.MenuItem(_('Show tutorials'))
+ self._tut_list_item.connect('activate', self._list_tutorials)
+ self._tut_list_item.show()
+
+ self.menu.append(self._creator_item)
+ self.menu.append(self._tut_list_item)
+
+ self.set_content(None)
+
+ def _start_creator(self, widget):
+ default_creator().start_authoring(tutorial=None)
+
+ def _list_tutorials(self, widget):
+ dlg = gtk.Dialog('Run a tutorial',
+ None,
+ gtk.DIALOG_MODAL,
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+ gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+ dlg.vbox.pack_start(gtk.Label(_('Which tutorial do you want to run?')))
+
+ activity = get_model().get_active_activity()
+
+ act_name = activity.get_activity_name()
+ tutorial_dict = Vault.list_available_tutorials(act_name)
+
+ # Build the combo box
+ combo = ComboBox()
+ for (tuto_name, tuto_guid) in tutorial_dict.items():
+ combo.append_item(tuto_name, tuto_guid)
+ dlg.vbox.pack_end(combo)
+ dlg.show_all()
+
+ result = dlg.run()
+
+ if result == gtk.RESPONSE_ACCEPT:
+ row = combo.get_active_item()
+ if row:
+ guid = row[0]
+ name = row[1]
+ LOGGER.debug("TPalette :: Got message to launch tutorial %s with guid %s"%(str(name), str(guid)))
+
+ from sugar.tutorius.service import ServiceProxy
+ service = ServiceProxy()
+
+ service.launch(guid)
+
+ dlg.destroy()
+
+def setup(tray):
+ tray.add_device(TutoriusRemote(default_creator()))