From fa35ac959122def2dcc6811e47250d12061b577b Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 04 Dec 2009 02:00:13 +0000 Subject: Remote : Code review changes --- (limited to 'src') diff --git a/src/extensions/tutoriusremote.py b/src/extensions/tutoriusremote.py index dfe6f37..fc93659 100755 --- a/src/extensions/tutoriusremote.py +++ b/src/extensions/tutoriusremote.py @@ -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')) @@ -68,48 +63,38 @@ class TPalette(Palette): 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.connect('activate', self._toggle_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): + 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.hide() - self._stop_creator_item.show() + self._creator_item.props.label = _("Stop this tutorial") 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() + else: + # Attempt to close the creator - this will popup a confirmation + # dialog if the user has unsaved changes + creator._cleanup_cb() - 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() + # 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): dlg = gtk.Dialog('Run a tutorial', @@ -147,4 +132,4 @@ class TPalette(Palette): service.launch(guid) def setup(tray): - tray.add_device(TutoriusRemote(default_creator())) + tray.add_device(TutoriusRemote()) -- cgit v0.9.1