[Sugar-devel] [PATCH] Enhancements to Pippy UI

2010-06-10 Thread anishmangal2002
From: anishmangal2002 anishmangal2...@gmail.com

[1] Added a standard 'Edit' toolbar having undo, redo, copy and
paste buttons which also work when the activity is shared.

[2] When the activity is shared, the treeview in the activity host's
window does not disappear so he can load examples by clicking
on them. For other participants, the treeview is kept hidden.

[3] Bump version to v37

Tested alone on sugar-jhbuild-0.88 and as a shared session with
another sugar-jhbuild-0.88 session. (Thanks walterbender)

Signed-off-by: anishmangal2002 anishmangal2...@gmail.com
---
 NEWS   |7 +++
 activity/activity.info |2 +-
 pippy_app.py   |   34 --
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index b19533b..ab6ba9e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+37
+* Added a standard 'Edit' toolbar having undo, redo, copy and  
+  paste buttons which also work when the activity is shared.
+* When the activity is shared, the treeview in the activity host's
+  window does not disappear so he can load examples by clicking 
+  on them. For other participants, the treeview is kept hidden.
+
 36
 * Add COPYING based on activity.info license field, verify source file
   licenses, include LICENSE from Elements upstream SVN, fixes
diff --git a/activity/activity.info b/activity/activity.info
index 26108f7..1664fd6 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -4,7 +4,7 @@ bundle_id = org.laptop.Pippy
 service_name = org.laptop.Pippy
 class = pippy_app.PippyActivity
 icon = activity-icon
-activity_version = 36
+activity_version = 37
 mime_types = text/x-python, pickle/groupthink-pippy
 show_launcher = yes
 
diff --git a/pippy_app.py b/pippy_app.py
index 8edad4e..8f3580e 100644
--- a/pippy_app.py
+++ b/pippy_app.py
@@ -33,6 +33,7 @@ from gettext import gettext as _
 from activity import ViewSourceActivity, TARGET_TYPE_TEXT
 from sugar.activity.activity import ActivityToolbox, \
  get_bundle_path, get_bundle_name
+from sugar.activity import activity
 from sugar.graphics import style
 from sugar.graphics.toolbutton import ToolButton
 
@@ -80,6 +81,16 @@ class PippyActivity(ViewSourceActivity, 
groupthink.sugar_tools.GroupActivity):
 palette.menu.append(menu_item)
 menu_item.show()
 
+ EDIT TOOLBAR
+self._edit_toolbar = activity.EditToolbar()
+toolbox.add_toolbar(_('Edit'), self._edit_toolbar)
+self._edit_toolbar.show()
+
+self._edit_toolbar.undo.connect('clicked', self.undobutton_cb)
+self._edit_toolbar.redo.connect('clicked', self.redobutton_cb)
+self._edit_toolbar.copy.connect('clicked', self.copybutton_cb)
+self._edit_toolbar.paste.connect('clicked', self.pastebutton_cb)
+
 # The go button
 goicon_bw = gtk.Image()
 goicon_bw.set_from_file(%s/icons/run_bw.svg % os.getcwd())
@@ -241,7 +252,8 @@ class PippyActivity(ViewSourceActivity, 
groupthink.sugar_tools.GroupActivity):
 return self.hpane
 
 def when_shared(self):
-self.hpane.remove(self.hpane.get_child1())
+if not self.initiating:
+self.hpane.remove(self.hpane.get_child1())
 global text_buffer
 self.cloud.sharefield = 
groupthink.gtk_tools.TextBufferSharePoint(text_buffer)
 
@@ -297,6 +309,24 @@ class PippyActivity(ViewSourceActivity, 
groupthink.sugar_tools.GroupActivity):
 self._vte.grab_focus()
 self._vte.feed(\x1B[H\x1B[J\x1B[0;39m)
 
+def undobutton_cb(self, button):
+global text_buffer
+if text_buffer.can_undo():
+text_buffer.undo()
+
+def redobutton_cb(self, button):
+global text_buffer
+if text_buffer.can_redo():
+text_buffer.redo()
+
+def copybutton_cb(self, button):
+global text_buffer
+text_buffer.copy_clipboard(gtk.Clipboard())
+
+def pastebutton_cb(self, button):
+global text_buffer
+text_buffer.paste_clipboard(gtk.Clipboard(), None, True)
+
 def gobutton_cb(self, button):
 from shutil import copy2
 self.stopbutton_cb(button) # try stopping old code first.
@@ -501,7 +531,7 @@ PIPPY_DEFAULT_ICON = \
 
 def pippy_activity_version():
 Returns the version number of the generated activity bundle.
-return 34
+return 37
 def pippy_activity_extra_files():
 Returns a map of 'extra' files which should be included in the
 generated activity bundle.
-- 
1.7.0.4

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Enhancements to Pippy UI

2010-06-10 Thread Benjamin M. Schwartz
Looks good to me, though I haven't tested it.  A comment on if not
self.initiating, to explain the intent, might be nice.

--Ben



signature.asc
Description: OpenPGP digital signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Enhancements to Pippy UI

2010-06-10 Thread Anish Mangal
Point taken :)

Anish Mangal



On Fri, Jun 11, 2010 at 2:41 AM, Benjamin M. Schwartz
bmsch...@fas.harvard.edu wrote:
 Looks good to me, though I haven't tested it.  A comment on if not
 self.initiating, to explain the intent, might be nice.

 --Ben


___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel