Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Ortiz <rafael@activitycentral.com>2012-06-30 06:57:01 (GMT)
committer Rafael Ortiz <rafael@activitycentral.com>2012-06-30 06:57:01 (GMT)
commitddb636e728a19f7e1b0c21f3ee6222f593dd1b6e (patch)
tree247c44aa61c1dfcfadc925ef8d725e341cf39822
parentebae32267a9369ed9cdf389571581f43c871b38c (diff)
Various fixes to gtk3 port, by (flavio danesse
fdanesse@activitycentral.com) and (rafael ortiz rafael@activitycentral.com)
-rwxr-xr-xactivity.py47
-rw-r--r--groupthink/gtk_tools.py12
-rw-r--r--groupthink/sugar_tools.py69
-rw-r--r--library/pippy/query.py2
-rwxr-xr-xlibrary/pippy/sound.py4
-rw-r--r--pippy_app.py139
6 files changed, 150 insertions, 123 deletions
diff --git a/activity.py b/activity.py
index c845edc..f08f302 100755
--- a/activity.py
+++ b/activity.py
@@ -17,14 +17,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""Pippy activity helper classes."""
-
-import gi
-from gi.repository import Gtk
-from gi.repository import Gdk
-from gi.repository import Pango
-from gi.repository import GObject
from sugar3.activity import activity
+
class ViewSourceActivity(activity.Activity):
"""Activity subclass which handles the 'view source' key."""
def __init__(self, handle, **kwargs):
@@ -33,6 +28,7 @@ class ViewSourceActivity(activity.Activity):
self.connect('key-press-event', self._key_press_cb)
def _key_press_cb(self, widget, event):
+ from gi.repository import Gdk
if Gdk.keyval_name(event.keyval) == 'XF86Start':
self.view_source()
return True
@@ -44,11 +40,10 @@ class ViewSourceActivity(activity.Activity):
if self.__source_object_id is None:
from sugar3 import profile
from sugar3.datastore import datastore
- from sugar3.activity.activity import get_bundle_name
- from sugar3.activity.activity import get_bundle_path
+ from sugar3.activity.activity \
+ import get_bundle_name, get_bundle_path
from gettext import gettext as _
import os.path
-
jobject = datastore.create()
metadata = {
'title': _('%s Source') % get_bundle_name(),
@@ -76,10 +71,14 @@ class ViewSourceActivity(activity.Activity):
TARGET_TYPE_TEXT = 80
+
class VteActivity(ViewSourceActivity):
"""Activity subclass built around the Vte terminal widget."""
def __init__(self, handle):
+ from gi.repository import Gtk
+ from gi.repository import Pango
from gi.repository import Vte
+ from gi.repository import GLib
from sugar3.graphics.toolbutton import ToolButton
from gettext import gettext as _
super(VteActivity, self).__init__(handle)
@@ -109,21 +108,23 @@ class VteActivity(ViewSourceActivity):
Gdk.color_parse('#E7E7E7'),
[])
self._vte.connect('selection-changed', self._on_selection_changed_cb)
- self._vte.drag_dest_set(Gtk.DEST_DEFAULT_ALL,
+ # FIXME It does not work because it expects and receives StructMeta Gtk.TargetEntry
+ '''
+ self._vte.drag_dest_set(Gtk.DestDefaults.ALL,
[("text/plain", 0, TARGET_TYPE_TEXT)],
- Gdk.DragAction.COPY)
+ Gdk.DragAction.COPY)'''
self._vte.connect('drag_data_received', self._on_drop_cb)
# ...and its scrollbar
- vtebox = Gtk.HBox()
+ vtebox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
vtebox.pack_start(self._vte, True, True, 0)
- vtesb = Gtk.VScrollbar(self._vte.get_adjustment())
+ vtesb = Gtk.Scrollbar(orientation=Gtk.Orientation.VERTICAL)
+ vtesb.set_adjustment(self._vte.get_adjustment())
vtesb.show()
vtebox.pack_start(vtesb, False, False, 0)
self.set_canvas(vtebox)
self.show_all()
# hide the buttons we don't use.
toolbar.share.hide() # this should share bundle.
- toolbar.keep.hide()
edittoolbar.undo.hide()
edittoolbar.redo.hide()
edittoolbar.separator.hide()
@@ -134,12 +135,14 @@ class VteActivity(ViewSourceActivity):
bundle_path = activity.get_bundle_path()
# the 'sleep 1' works around a bug with the command dying before
# the vte widget manages to snarf the last bits of its output
- self._pid = self._vte.fork_command(
- command='/bin/sh',
- argv=['/bin/sh', '-c',
- 'python %s/pippy_app.py; sleep 1' % bundle_path],
- envv=["PYTHONPATH=%s/library" % bundle_path],
- directory=bundle_path)
+ self._pid = self._vte.fork_command_full(
+ Vte.PtyFlags.DEFAULT,
+ bundle_path,
+ ['/bin/sh', '-c', 'python %s/pippy_app.py; sleep 1' % bundle_path],
+ ["PYTHONPATH=%s/library" % bundle_path],
+ GLib.SpawnFlags.DO_NOT_REAP_CHILD,
+ None,
+ None,)
def _on_copy_clicked_cb(self, widget):
if self._vte.get_has_selection():
@@ -159,6 +162,7 @@ class VteActivity(ViewSourceActivity):
"""This method is invoked when the user's script exits."""
pass # override in subclass
+
class PyGameActivity(ViewSourceActivity):
"""Activity wrapper for a pygame."""
def __init__(self, handle):
@@ -179,6 +183,8 @@ class PyGameActivity(ViewSourceActivity):
execfile(pippy_app_path, g, g) # start pygame
sys.exit(0)
super(PyGameActivity, self).__init__(handle)
+ from gi.repository import GObject
+ from gi.repository import Gtk
toolbox = activity.ActivityToolbox(self)
toolbar = toolbox.get_activity_toolbar()
self.set_toolbox(toolbox)
@@ -195,6 +201,7 @@ class PyGameActivity(ViewSourceActivity):
toolbar.share.hide() # this should share bundle.
toolbar.keep.hide()
+
def _main():
"""Launch this activity from the command line."""
from sugar3.activity import activityfactory
diff --git a/groupthink/gtk_tools.py b/groupthink/gtk_tools.py
index 2b74276..3bf4772 100644
--- a/groupthink/gtk_tools.py
+++ b/groupthink/gtk_tools.py
@@ -1,8 +1,4 @@
-import gi
from gi.repository import Gtk
-from gi.repository import Gdk
-from gi.repository import GObject
-
import groupthink_base as groupthink
import logging
import stringtree
@@ -36,8 +32,7 @@ class RecentEntry(groupthink.UnorderedHandlerAcceptor, Gtk.Entry):
self.set_text(text)
self.handler_unblock(self._text_changed_handler)
-'''
-class SharedTreeStore(groupthink.CausalHandlerAcceptor, Gtk.GenericTreeModel):
+class SharedTreeStore(groupthink.CausalHandlerAcceptor, Gtk.TreeStore):
def __init__(self, columntypes=(), translators=()):
self._columntypes = columntypes
self._causaltree = groupthink.CausalTree()
@@ -288,7 +283,7 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, Gtk.GenericTreeModel):
def move(self, it, newparent):
node = self.get_user_data(row)
p = self.get_user_data(newparent)
- self._causaltree.change_parent(node,p)'''
+ self._causaltree.change_parent(node,p)
class TextBufferUnorderedStringLinker:
def __init__(self,tb,us):
@@ -325,9 +320,10 @@ class TextBufferUnorderedStringLinker:
self._tb.handler_unblock(self._insert_handler)
self._tb.handler_unblock(self._delete_handler)
+
class TextBufferSharePoint(groupthink.UnorderedHandlerAcceptor):
def __init__(self, buff):
- self._us = groupthink.UnorderedString(buff.get_text(buff.get_start_iter(), buff.get_end_iter()))
+ self._us = groupthink.UnorderedString(buff.get_text(buff.get_start_iter(), buff.get_end_iter(), True))
self._linker = TextBufferUnorderedStringLinker(buff, self._us)
def set_handler(self, handler):
diff --git a/groupthink/sugar_tools.py b/groupthink/sugar_tools.py
index cb651c6..e0fe82b 100644
--- a/groupthink/sugar_tools.py
+++ b/groupthink/sugar_tools.py
@@ -16,17 +16,21 @@
import logging
import telepathy
-import gi
-from gi.repository import Gtk
-from gi.repository import Gdk
-from gi.repository import GObject
+
from sugar3.activity.activity import Activity
from sugar3.presence import presenceservice
+
from sugar3.presence.tubeconn import TubeConnection
from sugar3.graphics.window import Window
+
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
+
+import groupthink_base as groupthink
+
from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
from sugar3.activity.widgets import ActivityToolbarButton
-import groupthink_base as groupthink
def exhaust_event_loop():
while Gtk.events_pending():
@@ -58,24 +62,27 @@ class GroupActivity(Activity):
self._handle = handle
+ # HACK = self._shared_activity: attribute does not exist
+ self._shared_activity = None
+
##GObject.threads_init()
-
- #self._sharing_completed = not self._shared_activity
+
+ self._sharing_completed = not self._shared_activity
self._readfile_completed = not handle.object_id
- #if self._shared_activity:
- # self.message = self.message_joining
- #elif handle.object_id:
- # self.message = self.message_loading
- #else:
- # self.message = self.message_preparing
- self.message = "Shared No Funciona"
+
+ if self._shared_activity:
+ self.message = self.message_joining
+ elif handle.object_id:
+ self.message = self.message_loading
+ else:
+ self.message = self.message_preparing
toolbar_box = ToolbarBox()
self.activity_button = ActivityToolbarButton(self)
toolbar_box.toolbar.insert(self.activity_button, 0)
self.set_toolbar_box(toolbar_box)
- v = Gtk.VBox()
+ v = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.startup_label = Gtk.Label(label=self.message)
v.pack_start(self.startup_label, True, True, 0)
Window.set_canvas(self,v)
@@ -105,13 +112,13 @@ class GroupActivity(Activity):
owner = self.pservice.get_owner()
self.owner = owner
- #self.connect('shared', self._shared_cb)
- #self.connect('joined', self._joined_cb)
- #if self.get_shared():
- # if self.initiating:
- # self._shared_cb(self)
- # else:
- # self._joined_cb(self)
+ self.connect('shared', self._shared_cb)
+ self.connect('joined', self._joined_cb)
+ if self.get_shared():
+ if self.initiating:
+ self._shared_cb(self)
+ else:
+ self._joined_cb(self)
self.add_events(Gdk.EventMask.VISIBILITY_NOTIFY_MASK)
self.connect("visibility-notify-event", self._visible_cb)
@@ -119,8 +126,8 @@ class GroupActivity(Activity):
if not self._readfile_completed:
self.read_file(self._jobject.file_path)
- #elif not self._shared_activity:
- # GObject.idle_add(self._initialize_cleanstart)
+ elif not self._shared_activity:
+ GObject.idle_add(self._initialize_cleanstart)
def _initialize_cleanstart(self):
self.initialize_cleanstart()
@@ -142,19 +149,19 @@ class GroupActivity(Activity):
main_widget = self.initialize_display()
Window.set_canvas(self, main_widget)
self.initialized = True
- '''
+
if self._shared_activity and not self._processed_share:
# We are joining a shared activity, but when_shared has not yet
# been called
self.when_shared()
- self._processed_share = True'''
+ self._processed_share = True
self.show_all()
def initialize_display(self):
"""All subclasses must override this method, in order to display
their GUI using self.set_canvas()"""
raise NotImplementedError
- '''
+
def share(self, private=False):
"""The purpose of this function is solely to permit us to determine
whether share() has been called. This is necessary because share() may
@@ -227,15 +234,13 @@ class GroupActivity(Activity):
self.tubebox.insert_tube(tube_conn, self.initiating)
self._sharing_completed = True
if self._readfile_completed and not self.initialized:
- self._initialize_display()'''
+ self._initialize_display()
def read_file(self, file_path):
self.cloud.loads(self.load_from_journal(file_path))
self._readfile_completed = True
- #if self._sharing_completed and not self.initialized:
- # self._initialize_display()
- self._initialize_display()
- pass
+ if self._sharing_completed and not self.initialized:
+ self._initialize_display()
def load_from_journal(self, file_path):
"""This implementation of load_from_journal simply returns the contents
diff --git a/library/pippy/query.py b/library/pippy/query.py
index 1260c98..4053197 100644
--- a/library/pippy/query.py
+++ b/library/pippy/query.py
@@ -19,7 +19,7 @@ import logging
import dbus
import gobject
-from sugar3.datastore import datastore
+from sugar.datastore import datastore
DS_DBUS_SERVICE = 'org.laptop.sugar.DataStore'
DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore'
diff --git a/library/pippy/sound.py b/library/pippy/sound.py
index 7124cfe..27a63ed 100755
--- a/library/pippy/sound.py
+++ b/library/pippy/sound.py
@@ -18,9 +18,9 @@
import errno
import os
import sys
-import sugar3.env
+import sugar.env
from gettext import gettext as _
-from sugar3.activity import activity
+from sugar.activity import activity
path = activity.get_bundle_path()
path = path.split("/")[0:-1]
diff --git a/pippy_app.py b/pippy_app.py
index 4632df5..2ef1762 100644
--- a/pippy_app.py
+++ b/pippy_app.py
@@ -18,42 +18,46 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""Pippy Activity: A simple Python programming activity ."""
-
+from __future__ import with_statement
import logging
import re
import os
import time
-from signal import SIGTERM
-from gettext import gettext as _
-import gi
from gi.repository import Gtk
from gi.repository import Gdk
+from gi.repository import GLib
from gi.repository import Pango
-from gi.repository import GObject
from gi.repository import Vte
+from gi.repository import GObject
-from sugar3.activity import activity
+from port.style import font_zoom
+from signal import SIGTERM
+from gettext import gettext as _
-from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
-from sugar3.activity.widgets import EditToolbar, StopButton
+from sugar3.activity import activity
+from sugar3.activity.widgets import EditToolbar
+from sugar3.activity.widgets import StopButton
from sugar3.activity.activity import get_bundle_path
from sugar3.activity.activity import get_bundle_name
from sugar3.graphics import style
-from sugar3.graphics.toolbutton import ToolButton
-from port.style import font_zoom
+
+from activity import ViewSourceActivity
+from activity import TARGET_TYPE_TEXT
+
import groupthink.sugar_tools
import groupthink.gtk_tools
-from activity import ViewSourceActivity, TARGET_TYPE_TEXT # activity.py local
-
text_buffer = None
# magic prefix to use utf-8 source encoding
PYTHON_PREFIX = """#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
-#from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
-#from sugar3.activity.widgets import StopButton
+
+from sugar3.graphics.toolbarbox import ToolbarBox
+from sugar3.graphics.toolbarbox import ToolbarButton
+from sugar3.graphics.toolbutton import ToolButton
+from sugar3.activity.widgets import ActivityToolbarButton
# get screen sizes
SIZE_X = Gdk.Screen.width()
@@ -61,6 +65,7 @@ SIZE_Y = Gdk.Screen.height()
groupthink_mimetype = 'pickle/groupthink-pippy'
+
class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
"""Pippy Activity as specified in activity.info"""
def early_setup(self):
@@ -72,10 +77,9 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
self._logger = logging.getLogger('pippy-activity')
# Activity toolbar with title input, share button and export buttons:
- activity_toolbar = self.activity_button.page
+ # FIXME the toolbar is being painted twice.
- # Hide keep button for Sugar versions prior to 0.94:
- #activity_toolbar.keep.hide()
+ activity_toolbar = self.activity_button.page
separator = Gtk.SeparatorToolItem()
separator.show()
@@ -121,10 +125,10 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
goicon_bw.set_from_file("%s/icons/run_bw.svg" % os.getcwd())
goicon_color = Gtk.Image()
goicon_color.set_from_file("%s/icons/run_color.svg" % os.getcwd())
- gobutton = ToolButton(label=_("_Run!"))
+ gobutton = ToolButton(label=_("Run!"))
gobutton.props.accelerator = _('<alt>r')
gobutton.set_icon_widget(goicon_bw)
- gobutton.set_tooltip(_("_Run!"))
+ gobutton.set_tooltip(_("Run!"))
gobutton.connect('clicked', self.flash_cb, dict({'bw': goicon_bw,
'color': goicon_color}))
gobutton.connect('clicked', self.gobutton_cb)
@@ -135,13 +139,13 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
stopicon_bw.set_from_file("%s/icons/stopit_bw.svg" % os.getcwd())
stopicon_color = Gtk.Image()
stopicon_color.set_from_file("%s/icons/stopit_color.svg" % os.getcwd())
- stopbutton = ToolButton(label=_("_Stop"))
+ stopbutton = ToolButton(label=_("Stop"))
stopbutton.props.accelerator = _('<alt>s')
stopbutton.set_icon_widget(stopicon_bw)
stopbutton.connect('clicked', self.flash_cb, dict({'bw': stopicon_bw,
'color': stopicon_color}))
stopbutton.connect('clicked', self.stopbutton_cb)
- stopbutton.set_tooltip(_("_Stop"))
+ stopbutton.set_tooltip(_("Stop"))
actions_toolbar.insert(stopbutton, -1)
# The "clear" button
@@ -150,13 +154,13 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
clearicon_color = Gtk.Image()
clearicon_color.set_from_file("%s/icons/eraser_color.svg" %
os.getcwd())
- clearbutton = ToolButton(label=_("_Clear"))
+ clearbutton = ToolButton(label=_("Clear"))
clearbutton.props.accelerator = _('<alt>c')
clearbutton.set_icon_widget(clearicon_bw)
clearbutton.connect('clicked', self.clearbutton_cb)
clearbutton.connect('clicked', self.flash_cb, dict({'bw': clearicon_bw,
'color': clearicon_color}))
- clearbutton.set_tooltip(_("_Clear"))
+ clearbutton.set_tooltip(_("Clear"))
actions_toolbar.insert(clearbutton, -1)
activity_toolbar.show()
@@ -171,18 +175,20 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
self.get_toolbar_box().toolbar.insert(stop, -1)
# Main layout.
- self.hpane = Gtk.HPaned()
- self.vpane = Gtk.VPaned()
+ self.hpane = Gtk.Paned.new(orientation=Gtk.Orientation.HORIZONTAL)
+ self.hpane.set_position(300) # setting initial position
+ self.vpane = Gtk.Paned.new(orientation=Gtk.Orientation.VERTICAL)
+ self.vpane.set_position(400) # setting initial position
# The sidebar.
- self.sidebar = Gtk.VBox()
+ self.sidebar = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.model = Gtk.TreeStore(GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
treeview = Gtk.TreeView(self.model)
cellrenderer = Gtk.CellRendererText()
treecolumn = Gtk.TreeViewColumn(_("Examples"), cellrenderer, text=1)
treeview.get_selection().connect("changed", self.selection_cb)
treeview.append_column(treecolumn)
- treeview.set_size_request(int(SIZE_X * 0.3), SIZE_Y)
+ treeview.set_size_request(int(SIZE_X * 0.3), int(SIZE_Y * 0.3))
# Create scrollbars around the view.
scrolled = Gtk.ScrolledWindow()
@@ -200,6 +206,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
self.model.set_value(olditer, 0, direntry)
self.model.set_value(olditer, 1, direntry["name"])
+
for _file in sorted(os.listdir(os.path.join(root, d))):
if _file.endswith('~'):
continue # skip emacs backups
@@ -271,10 +278,9 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
self.vpane.add1(codesw)
# An hbox to hold the vte window and its scrollbar.
- outbox = Gtk.HBox()
+ outbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
# The vte python window
-
self._vte = Vte.Terminal()
self._vte.set_encoding('utf-8')
self._vte.set_size(30, 5)
@@ -285,14 +291,18 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
[])
self._vte.connect('child_exited', self.child_exited_cb)
self._child_exited_handler = None
- #self._vte.drag_dest_set(Gtk.DEST_DEFAULT_ALL,
+
+ # FIXME It does not work because it expects and receives StructMeta Gtk.TargetEntry
+ #
+ # self._vte.drag_dest_set(Gtk.DestDefaults.ALL,
# [("text/plain", 0, TARGET_TYPE_TEXT)],
# Gdk.DragAction.COPY)
+
self._vte.connect('drag_data_received', self.vte_drop_cb)
outbox.pack_start(self._vte, True, True, 0)
- #outsb = Gtk.VScrollbar(self._vte.get_adjustment())
- outsb = Gtk.VScrollbar()
+ outsb = Gtk.Scrollbar(orientation=Gtk.Orientation.VERTICAL)
+ outsb.set_adjustment(self._vte.get_vadjustment())
outsb.show()
outbox.pack_start(outsb, False, False, 0)
self.vpane.add2(outbox)
@@ -350,7 +360,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
def _write_text_buffer(self, filename):
global text_buffer
start, end = text_buffer.get_bounds()
- text = text_buffer.get_text(start, end)
+ text = text_buffer.get_text(start, end, True)
with open(filename, 'w') as f:
# write utf-8 coding prefix if there's not already one
@@ -396,13 +406,17 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
copy2('%s/activity.py' % get_bundle_path(),
'%s/tmp/activity.py' % self.get_activity_root())
- self._pid = self._vte.fork_command(
- command="/bin/sh",
- argv=["/bin/sh", "-c",
- "python %s; sleep 1" % pippy_app_name],
- envv=["PYTHONPATH=%s/library:%s" % (get_bundle_path(),
- os.getenv("PYTHONPATH", ""))],
- directory=get_bundle_path())
+ self._pid = self._vte.fork_command_full(
+ Vte.PtyFlags.DEFAULT,
+ get_bundle_path(),
+ ["/bin/sh", "-c", "python %s; sleep 1" % pippy_app_name,
+ "PYTHONPATH=%s/library:%s" % (get_bundle_path(),
+ os.getenv("PYTHONPATH", ""))],
+ ["PYTHONPATH=%s/library:%s" % (get_bundle_path(),
+ os.getenv("PYTHONPATH", ""))],
+ GLib.SpawnFlags.DO_NOT_REAP_CHILD,
+ None,
+ None,)
def stopbutton_cb(self, button):
try:
@@ -448,14 +462,16 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
self._child_exited_handler = \
lambda: self.bundle_cb(title, app_temp)
# invoke bundle builder
- self._pid = self._vte.fork_command(
- command="/usr/bin/python",
- argv=["/usr/bin/python",
- "%s/pippy_app.py" % get_bundle_path(),
- '-p', '%s/library' % get_bundle_path(),
- '-d', app_temp,
- title, sourcefile],
- directory=app_temp)
+ self._pid = self._vte.fork_command_full(
+ Vte.PtyFlags.DEFAULT,
+ app_temp,
+ "/usr/bin/python",
+ ["/usr/bin/python", "%s/pippy_app.py" % get_bundle_path(),
+ '-p', '%s/library' % get_bundle_path(),
+ '-d', app_temp, title, sourcefile],
+ GLib.SpawnFlags.DO_NOT_REAP_CHILD,
+ None,
+ None)
except:
rmtree(app_temp, ignore_errors=True) # clean up!
raise
@@ -493,6 +509,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
self._vte.feed(_("Saved as example."))
self._vte.feed("\r\n")
self.add_to_example_list(local_file)
+
def child_exited_cb(self, *args):
"""Called whenever a child exits. If there's a handler, run it."""
@@ -538,6 +555,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
def dismiss_alert_cb(self, alert, response_id):
self.remove_alert(alert)
+
def confirmation_alert_cb(self, alert, response_id, local_file): #callback for conf alert
self.remove_alert(alert)
@@ -555,20 +573,21 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
_iter = self.model.insert_before(self.example_iter, None)
self.model.set_value(_iter, 0, entry)
self.model.set_value(_iter, 1, entry["name"])
+
def save_to_journal(self, file_path, cloudstring):
- _file = open(file_path, 'w')
- self.metadata['mime_type'] = 'text/x-python'
- '''
- if not self._shared_activity:
- self.metadata['mime_type'] = 'text/x-python'
- global text_buffer
- start, end = text_buffer.get_bounds()
- text = text_buffer.get_text(start, end)
- _file.write(text)
- else:
- self.metadata['mime_type'] = groupthink_mimetype
- _file.write(cloudstring)'''
+ # FIXME When saving in the journal, it throws an error
+ #_file = open(file_path, 'w')
+ #if not self._shared_activity:
+ # self.metadata['mime_type'] = 'text/x-python'
+ # global text_buffer
+ # start, end = text_buffer.get_bounds()
+ # text = text_buffer.get_text(start, end, True)
+ # _file.write(text)
+ #else:
+ # self.metadata['mime_type'] = groupthink_mimetype
+ # _file.write(cloudstring)
+ pass
def load_from_journal(self, file_path):
if self.metadata['mime_type'] == 'text/x-python':