From 49ab39870266196f6267f83dd6951f839ebde773 Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 04 Dec 2009 02:21:14 +0000 Subject: Merge ../../simpoirs-clone into remote_integration Conflicts: src/extensions/tutoriusremote.py --- (limited to 'src') diff --git a/src/extensions/tutoriusremote.py b/src/extensions/tutoriusremote.py index 918f3da..fc93659 100755 --- a/src/extensions/tutoriusremote.py +++ b/src/extensions/tutoriusremote.py @@ -36,7 +36,7 @@ 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.creator import default_creator from sugar.tutorius.vault import Vault @@ -45,12 +45,7 @@ _ICON_NAME = 'tutortool' LOGGER = logging.getLogger('remote') class TutoriusRemote(TrayIcon): - - FRAME_POSITION_RELATIVE = 102 - - def __init__(self):#, creator): - #self._creator = creator - + def __init__(self): client = gconf.client_get_default() self._color = XoColor(client.get_string('/desktop/sugar/user/color')) @@ -67,69 +62,74 @@ 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._creator_item = gtk.MenuItem(_('Create a tutorial')) + self._creator_item.connect('activate', self._toggle_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._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 _toggle_creator(self, widget): + 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.props.label = _("Stop this tutorial") + creator.start_authoring(tutorial=None) + + else: + # Attempt to close the creator - this will popup a confirmation + # dialog if the user has unsaved changes + creator._cleanup_cb() + + # If the creator was not actually closed - (in case cancel + # is implemented one day) + if creator.is_authoring == True: + return + # Switch back to start creator entry + self._creator_item.props.label = _("Create a tutorial") def _list_tutorials(self, widget): - # Create the selection dialog dlg = gtk.Dialog('Run a tutorial', None, gtk.DIALOG_MODAL, - (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, - gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) - # Write the user prompt + (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'))) - # Fetchthe current activity name activity = get_model().get_active_activity() - act_name = activity.get_activity_name() - # Query the vault to get the tutorials related to this activity + act_name = activity.get_activity_name() tutorial_dict = Vault.list_available_tutorials(act_name) # Build the combo box combo = ComboBox() - - # Insert all the related tutorials for (tuto_name, tuto_guid) in tutorial_dict.items(): combo.append_item(tuto_name, tuto_guid) dlg.vbox.pack_end(combo) dlg.show_all() - # Show the dialog to the user result = dlg.run() + dlg.destroy() - # If the user cliked OK if result == gtk.RESPONSE_ACCEPT: - # Get the current active item in the row = combo.get_active_item() if row: - # Fetch the name and Guid guid = row[0] name = row[1] - LOGGER.debug("TPalette :: Got message to launch tutorial %s with guid %s"%(str(name), str(guid))) - # Send a DBus message to the Engine to run this tutorial from sugar.tutorius.service import ServiceProxy service = ServiceProxy() + service.launch(guid) - - # Close the dialog - dlg.destroy() def setup(tray): - tray.add_device(TutoriusRemote())#default_creator())) + tray.add_device(TutoriusRemote()) -- cgit v0.9.1