Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/extensions/tutoriusremote.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/extensions/tutoriusremote.py')
-rwxr-xr-xsrc/extensions/tutoriusremote.py80
1 files changed, 78 insertions, 2 deletions
diff --git a/src/extensions/tutoriusremote.py b/src/extensions/tutoriusremote.py
index 9bb4bfb..dfe6f37 100755
--- a/src/extensions/tutoriusremote.py
+++ b/src/extensions/tutoriusremote.py
@@ -21,20 +21,29 @@ 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
@@ -61,14 +70,81 @@ class TPalette(Palette):
self._creator_item = gtk.MenuItem(_('Create a tutorial'))
self._creator_item.connect('activate', self._start_creator)
self._creator_item.show()
+
+ self._stop_creator_item = gtk.MenuItem(_('Stop creating tutorial'))
+ self._stop_creator_item.connect('activate', self._stop_creator)
+
+ 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._stop_creator_item)
+ self.menu.append(self._tut_list_item)
self.set_content(None)
def _start_creator(self, widget):
- default_creator().start_authoring(tutorial=None)
-
+ creator = default_creator()
+
+ if creator.is_authoring == False:
+ # Replace the start creator button by the stop creator
+ # Allocate a white color for the text
+ self._creator_item.hide()
+ self._stop_creator_item.show()
+ creator.start_authoring(tutorial=None)
+
+ def _stop_creator(self, widget):
+ # Close the creator but let the confirmation dialog appear
+ # if the user hasn't saved his tutorial
+ creator = default_creator()
+
+ if creator.is_authoring == False:
+ return
+
+ creator._cleanup_cb()
+
+ # If the creator was not actually closed
+ if creator.is_authoring == True:
+ return
+ # Switch back to start creator entry
+ self._stop_creator_item.hide()
+ self._creator_item.show()
+ def _list_tutorials(self, widget):
+ dlg = gtk.Dialog('Run a tutorial',
+ None,
+ gtk.DIALOG_MODAL,
+ (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
+ gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
+ dlg.vbox.pack_start(gtk.Label(_('Which tutorial do you want to run?\n')))
+
+ 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()
+ dlg.destroy()
+
+ 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)
def setup(tray):
tray.add_device(TutoriusRemote(default_creator()))