Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Vinet <vince.vinet@gmail.com>2009-03-19 03:47:04 (GMT)
committer Vincent Vinet <vince.vinet@gmail.com>2009-03-19 18:23:13 (GMT)
commit72e28a934bc26b5f9c9b8ac6d917aad5eb76b51d (patch)
tree121f8ec9b365f82f367e920113b6fb85f2157fe5
parentcd4b5c8d01e68f170c783b638ad24992dbba8aea (diff)
Add the Widget Identifier and corresponding Action
Make Writus use it Fix a dupe in the ActivityToolbar Use the ObjectStore in tutorial.attach() Do a rebase onto master and hope it works
-rw-r--r--src/sugar/activity/activity.py12
-rw-r--r--src/sugar/tutorius/Makefile.am3
-rw-r--r--src/sugar/tutorius/actions.py23
-rw-r--r--src/sugar/tutorius/core.py3
-rw-r--r--src/sugar/tutorius/editor.py115
5 files changed, 142 insertions, 14 deletions
diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py
index 0ad1d91..21e38f6 100644
--- a/src/sugar/activity/activity.py
+++ b/src/sugar/activity/activity.py
@@ -182,18 +182,6 @@ class ActivityToolbar(gtk.Toolbar):
self._updating_share = False
- def __tutorial_changed_cb(self, combo):
- if self._current_tutorial:
- self._current_tutorial.detach()
-
- model = self.tutorials.combo.get_model()
- it = self.tutorials.combo.get_active_iter()
- (key, ) = model.get(it, 0)
- t = self._activity.get_tutorials.get(key,None)
- if t:
- self._current_tutorial = t
- self._current_tutorial.attach(self._activity)
-
def __share_changed_cb(self, combo):
if self._updating_share:
return
diff --git a/src/sugar/tutorius/Makefile.am b/src/sugar/tutorius/Makefile.am
index 6fd32c7..1fb11e1 100644
--- a/src/sugar/tutorius/Makefile.am
+++ b/src/sugar/tutorius/Makefile.am
@@ -7,4 +7,5 @@ sugar_PYTHON = \
gtkutils.py \
filters.py \
services.py \
- overlayer.py
+ overlayer.py \
+ editor.py
diff --git a/src/sugar/tutorius/actions.py b/src/sugar/tutorius/actions.py
index da8219e..12de298 100644
--- a/src/sugar/tutorius/actions.py
+++ b/src/sugar/tutorius/actions.py
@@ -16,11 +16,13 @@
"""
This module defines Actions that can be done and undone on a state
"""
+from gettext import gettext as _
from sugar.tutorius import gtkutils
from dialog import TutoriusDialog
-from sugar.tutorius.services import ObjectStore
import overlayer
+from sugar.tutorius.editor import WidgetIdentifier
+from sugar.tutorius.services import ObjectStore
class Action(object):
@@ -149,4 +151,23 @@ class BubbleMessage(Action):
if self._bubble:
self._bubble.destroy()
self._bubble = None
+
+class WidgetIdentifyAction(Action):
+ def __init__(self):
+ self.activity = None
+ self._dialog = None
+
+ def do(self):
+ os = ObjectStore()
+ if os.activity:
+ self.activity = os.activity
+
+ self._dialog = WidgetIdentifier(self.activity)
+ self._dialog.show()
+
+
+ def undo(self):
+ if self._dialog:
+ self._dialog.destroy()
+
diff --git a/src/sugar/tutorius/core.py b/src/sugar/tutorius/core.py
index f817ba9..14bb751 100644
--- a/src/sugar/tutorius/core.py
+++ b/src/sugar/tutorius/core.py
@@ -26,6 +26,7 @@ import logging
from sugar.tutorius.dialog import TutoriusDialog
from sugar.tutorius.gtkutils import find_widget
+from sugar.tutorius.services import ObjectStore
logger = logging.getLogger("tutorius")
@@ -60,6 +61,8 @@ class Tutorial (object):
if self.activity:
self.detach()
self.activity = activity
+ ObjectStore().activity = activity
+ ObjectStore().tutorial = self
self.state_machine.set_state("INIT")
def detach(self):
diff --git a/src/sugar/tutorius/editor.py b/src/sugar/tutorius/editor.py
new file mode 100644
index 0000000..1a1eb61
--- /dev/null
+++ b/src/sugar/tutorius/editor.py
@@ -0,0 +1,115 @@
+# Copyright (C) 2009, Tutorius.org
+# Greatly influenced by sugar/activity/namingalert.py
+#
+# 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 gtk
+import gobject
+import hippo
+import gconf
+
+from gettext import gettext as _
+
+class WidgetIdentifier(gtk.Window):
+ """
+ Tool that allows identifying widgets
+ """
+ __gtype_name__ = 'TutoriusWidgetIdentifier'
+
+ def __init__(self, activity):
+ gtk.Window.__init__(self)
+
+ self._activity = activity
+ self._handlers = []
+
+ self.set_decorated(False)
+ self.set_resizable(False)
+ self.set_modal(False)
+
+ self.connect('realize', self.__realize_cb)
+
+ self._expander = gtk.Expander(_("Widget Identifier"))
+ self._expander.set_expanded(True)
+ self.add(self._expander)
+ self._expander.connect("notify::expanded", self.__expander_cb)
+
+ self._expander.show()
+
+ vbox = gtk.VBox()
+ self._expander.add(vbox)
+ vbox.show()
+
+
+ self.logview = gtk.TextView()
+ self.logview.set_editable(False)
+ self.logview.set_cursor_visible(False)
+ self.logview.set_wrap_mode(gtk.WRAP_NONE)
+ self._textbuffer = self.logview.get_buffer()
+
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ sw.add(self.logview)
+ self.logview.show()
+
+ vbox.pack_start(sw)
+ sw.show()
+
+ from sugar.tutorius.gtkutils import register_signals_numbered
+ self._handlers = register_signals_numbered(self._activity, self._handle_events)
+
+ def __expander_cb(self, *args):
+ if self._expander.get_expanded():
+ self.__move_expanded()
+ else:
+ self.__move_collapsed()
+
+ def __move_expanded(self):
+ width = 400
+ height = 300
+ ww = gtk.gdk.screen_width()
+ wh = gtk.gdk.screen_height()
+
+ self.set_size_request(width, height)
+ self.move((ww-width)/2, wh-height)
+
+ def __move_collapsed(self):
+ width = 150
+ height = 40
+ ww = gtk.gdk.screen_width()
+ wh = gtk.gdk.screen_height()
+
+ self.set_size_request(width, height)
+ self.move((ww-width)/2, wh-height)
+
+ def __realize_cb(self, widget):
+ self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
+ self.window.set_accept_focus(True)
+ self.__move_expanded()
+
+ def _disconnect_handlers(self):
+ for widget, handlerid in self._handlers:
+ widget.handler_disconnect(handlerid)
+ self._handlers = []
+
+ def _handle_events(self,*args):
+ sig, name = args[-1]
+ text = "\r\n".join(
+ (["%s event received from %s" % (sig, name)] +
+ self._textbuffer.get_text(*(self._textbuffer.get_bounds())
+ ).split("\r\n"))[:80]
+ )
+ self._textbuffer.set_text(text)
+
+