Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@ghunt-desktop.(none)>2010-04-24 02:48:39 (GMT)
committer root <root@ghunt-desktop.(none)>2010-04-24 02:48:39 (GMT)
commitbb9a3b9a209185eeb96aca0876e9b5daa55d4f3d (patch)
treee7d61101307c8025aa94ab680cb393a27eb4aecb
parent95cd2eaaa965f3c3063a5617c5a8978847387312 (diff)
removing the dead files
-rw-r--r--HelloWorld.activity/HelloWorldActivity.py40
-rw-r--r--HelloWorld.activity/activity/activity-helloworld.svg8
-rwxr-xr-xHelloWorld.activity/setup.py3
-rwxr-xr-xbkuppydb3
-rwxr-xr-xbkuppydb.epa3
-rw-r--r--browser.pyobin2220 -> 0 bytes
-rw-r--r--datastoretree.pyobin8214 -> 0 bytes
-rw-r--r--dist/PyDebug-6.xobin12177780 -> 0 bytes
-rw-r--r--filetree.pyobin8071 -> 0 bytes
m---------git/pippy-activity0
-rw-r--r--help/ActivityBook/ActivitiesSugar.tar.gzbin2286490 -> 0 bytes
-rw-r--r--help_diff197
-rwxr-xr-xhelp_pd.pyobin8772 -> 0 bytes
-rw-r--r--help_pd.py~274
-rw-r--r--helpdiff2152
-rw-r--r--history17
-rw-r--r--ipy_user_conf.pyobin1079 -> 0 bytes
-rw-r--r--lib/python2.5/site-packages/sugar/graphics/colorbutton.py531
-rw-r--r--lib/python2.6/site-packages/browser.py229
-rw-r--r--lib/python2.6/site-packages/sugar.save/activity/activityshim.py60
-rw-r--r--lib/python2.6/site-packages/sugar.save/activity/olpcactivity.pth2
-rw-r--r--lib/python2.6/site-packages/terminal.py308
-rw-r--r--notebook.pyobin3183 -> 0 bytes
-rw-r--r--notebook.py~150
-rw-r--r--progresslistener.pyobin3470 -> 0 bytes
-rw-r--r--pydebug.pyobin68344 -> 0 bytes
-rw-r--r--pydebug.py~1517
-rw-r--r--pydebug_logging.pyobin963 -> 0 bytes
-rw-r--r--pytoolbar.pyobin6386 -> 0 bytes
-rw-r--r--pytoolbar.py~194
-rwxr-xr-xrsyncactivity3
-rw-r--r--sourceview_editor.pyobin23334 -> 0 bytes
-rw-r--r--sourceview_editor.py~636
-rw-r--r--terminal_pd.pyobin10061 -> 0 bytes
-rw-r--r--tmp.py4
35 files changed, 0 insertions, 4331 deletions
diff --git a/HelloWorld.activity/HelloWorldActivity.py b/HelloWorld.activity/HelloWorldActivity.py
deleted file mode 100644
index bf73963..0000000
--- a/HelloWorld.activity/HelloWorldActivity.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from sugar.activity import activity
-import logging
-
-import sys, os
-import gtk
-
-class HelloWorldActivity(activity.Activity):
- def hello(self, widget, data=None):
- logging.info('Hello World')
-
- def __init__(self, handle):
- print "running activity init", handle
- activity.Activity.__init__(self, handle)
- print "activity running"
-
- self.set_title('Hello World')
-
- # Creates the Toolbox. It contains the Activity Toolbar, which is the
- # bar that appears on every Sugar window and contains essential
- # functionalities, such as the 'Collaborate' and 'Close' buttons.
- toolbox = activity.ActivityToolbox(self)
- self.set_toolbox(toolbox)
- toolbox.show()
-
- # Creates a new button with the label "Hello World".
- self.button = gtk.Button("Hello World")
-
- # When the button receives the "clicked" signal, it will call the
- # function hello() passing it None as its argument. The hello()
- # function is defined above.
- self.button.connect("clicked", self.hello, None)
-
- # Set the button to be our canvas. The canvas is the main section of
- # every Sugar Window. It fills all the area below the toolbox.
- self.set_canvas(self.button)
-
- # The final step is to display this newly created widget.
- self.button.show()
-
- print "AT END OF THE CLASS"
diff --git a/HelloWorld.activity/activity/activity-helloworld.svg b/HelloWorld.activity/activity/activity-helloworld.svg
deleted file mode 100644
index b9278b0..0000000
--- a/HelloWorld.activity/activity/activity-helloworld.svg
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
- <!ENTITY fill_color "#FFFFFF">
- <!ENTITY stroke_color "#000000">
-]>
-<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
-<rect x="1" y="1" width="48" height="48" style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:2"/>
-</svg>
diff --git a/HelloWorld.activity/setup.py b/HelloWorld.activity/setup.py
deleted file mode 100755
index 6ea61a6..0000000
--- a/HelloWorld.activity/setup.py
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/python
-from sugar.activity import bundlebuilder
-bundlebuilder.start()
diff --git a/bkuppydb b/bkuppydb
deleted file mode 100755
index 5fec274..0000000
--- a/bkuppydb
+++ /dev/null
@@ -1,3 +0,0 @@
-#copy the remote pydebug tree to the git tree
-rsync -p -r root@10.4.75.99:/home/olpc/.sugar/default/org.laptop.PyDebug/data/pydebug/PyDebug.activity/ /home/ghunt/git/pydebug/PyDebug.activity
-
diff --git a/bkuppydb.epa b/bkuppydb.epa
deleted file mode 100755
index f790fd1..0000000
--- a/bkuppydb.epa
+++ /dev/null
@@ -1,3 +0,0 @@
-#copy the remote pydebug tree to the git tree
-rsync -p -r root@192.168.123.122:/home/olpc/Activities/PyDebug.activity/ /home/ghunt/git/pydebug/PyDebug.activity
-
diff --git a/browser.pyo b/browser.pyo
deleted file mode 100644
index 42bdaaf..0000000
--- a/browser.pyo
+++ /dev/null
Binary files differ
diff --git a/datastoretree.pyo b/datastoretree.pyo
deleted file mode 100644
index 26e8c95..0000000
--- a/datastoretree.pyo
+++ /dev/null
Binary files differ
diff --git a/dist/PyDebug-6.xo b/dist/PyDebug-6.xo
deleted file mode 100644
index f168632..0000000
--- a/dist/PyDebug-6.xo
+++ /dev/null
Binary files differ
diff --git a/filetree.pyo b/filetree.pyo
deleted file mode 100644
index 3a37fd7..0000000
--- a/filetree.pyo
+++ /dev/null
Binary files differ
diff --git a/git/pippy-activity b/git/pippy-activity
deleted file mode 160000
-Subproject 8e20319a883c8afb5ccfdddde326246e8961f0d
diff --git a/help/ActivityBook/ActivitiesSugar.tar.gz b/help/ActivityBook/ActivitiesSugar.tar.gz
deleted file mode 100644
index 8e8f625..0000000
--- a/help/ActivityBook/ActivitiesSugar.tar.gz
+++ /dev/null
Binary files differ
diff --git a/help_diff b/help_diff
deleted file mode 100644
index 28cdb9a..0000000
--- a/help_diff
+++ /dev/null
@@ -1,197 +0,0 @@
-14,19c14
-< #
-< #NOTE: The webview module shipped with FC11 does a get_Main_window.hide()
-< # which makes it unusable in the PyDebug application. A more recent git version
-< # toggles the visibility of the gecko engine and is more compatible.
-< # The browser.py and webview.py modules included are essential for PyDebug
-< #
----
->
-31d25
-< from zipfile import ZipFile, ZipInfo
-35,36c29,30
-< #import xpcom
-< #from xpcom.components import interfaces
----
-> import xpcom
-> from xpcom.components import interfaces
-40c34
-< #HOME = os.path.join(activity.get_bundle_path(), 'help/index.html')
----
-> HOME = os.path.join(activity.get_bundle_path(), 'help/XO_Introduction.html')
-43,57c37,64
-< # Initialize logging.
-< import logging
-< from sugar import logger
-< #Get the standard logging directory.
-< _logger = logging.getLogger('PyDebug')
-<
-< ZIP_SUFFIXES = ['.xol','.zip',]
-< sugar_activity_root = os.environ['SUGAR_ACTIVITY_ROOT']
-< help_notebook_pages = []
-<
-< class HelpToolbar(gtk.Toolbar):
-< def __init__(self, parent):
-< gtk.Toolbar.__init__(self)
-< self.help_toolbar_parent = parent
-< self.child_root = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],'tmp')
----
-> class HelpActivity(activity.Activity):
-> def __init__(self, handle):
-> activity.Activity.__init__(self, handle)
->
-> self.props.max_participants = 1
->
-> self._web_view = Browser()
->
-> toolbox = activity.ActivityToolbox(self)
-> self.set_toolbox(toolbox)
-> toolbox.show()
->
-> toolbar = Toolbar(self._web_view)
-> toolbox.add_toolbar(_('Navigation'), toolbar)
-> toolbar.show()
->
-> self.set_canvas(self._web_view)
-> self._web_view.show()
->
-> toolbox.set_current_toolbar(1)
->
-> self._web_view.load_uri(HOME)
->
-> class Toolbar(gtk.Toolbar):
-> def __init__(self, web_view):
-> gobject.GObject.__init__(self)
->
-> self._web_view = web_view
-62c69
-< self._back.connect('clicked', self.help_toolbar_parent._go_back_cb)
----
-> self._back.connect('clicked', self._go_back_cb)
-69c76
-< self._forward.connect('clicked', self.help_toolbar_parent._go_forward_cb)
----
-> self._forward.connect('clicked', self._go_forward_cb)
-75c82
-< home.connect('clicked', self.help_toolbar_parent._go_home_cb)
----
-> home.connect('clicked', self._go_home_cb)
-79,114d85
-< class Help():
-< current_url_prefix = ''
-< file_changed = False
-< current_web_view = None
-< web_view_list = []
-< def __init__(self, parent):
-< self.pydebug = parent
-< self.url_root = 'file://'+ self.sugar_bundle_path +"/"+_('help/PyDebug.htm')
-< self.help_toolbar = HelpToolbar(self.pydebug)
-< self.help_toolbar.show()
-< self.first_webview = self.new_tab(self.url_root)
-< self.web_view_list.append(self.first_webview)
-< self.current_web_view = self.first_webview
-< translation = self.translate_zip_url(self.url_root)
-< _logger.debug("this is url root: %s"%translation)
-< self.first_webview.load_uri(translation)
-<
-< def get_help_toolbar(self):
-< return self.help_toolbar
-<
-< def _get_help_canvas(self):
-< nb = gtk.Notebook()
-< nb.show()
-< nb.append_page(self.first_webview)
-< self.help_notebook = nb
-< return nb
-<
-< def new_tab(self,url = None):
-< if url == None:
-< url = self.url_root
-< self._web_view = Browser()
-< _logger.debug('loading new tab with url: %s' % url )
-< self._web_view.load_uri(url)
-< self._web_view.connect('destroy',self._web_view.hide)
-< self.current_url = url
-< self._web_view.show()
-120,127d90
-< return self._web_view
-<
-< def repaint(self):
-< self._web_view.load_uri(self.current_url)
-<
-< def get_first_webview(self):
-< return self.first_webview
-<
-129,131d91
-< myuri=''
-< myuri = str(uri)
-< _logger.debug('location changed callback %s'%(myuri))
-133,174d92
-< target = self.translate_zip_url(uri)
-< _logger.debug(' which translated to %s'%(target))
-< #self.current_webview.load_uri(target)
-< uri = target
-<
-< def translate_zip_url(self,uri): #string in, string returned
-< #if this file is already unzipped then allow normal processing
-< if os.path.isfile(uri[7:]): #don't want the leading 'file://'
-< return uri
-< #look for the zip suffixes in the uri
-< self.current_url_prefix = ''
-< for pattern in ZIP_SUFFIXES:
-< if uri.find(pattern) > -1:
-< self.current_url_prefix = uri[:uri.find(pattern)] + pattern
-< found_pattern = pattern
-< if self.current_url_prefix == '':
-< return uri
-< _logger.debug('pattern found:%s. Prefix: %s'%(found_pattern,self.current_url_prefix))
-<
-< #find the file in the zip, write it somewhere writeable, load this url instead
-< zipfile_name = self.current_url_prefix[7:] #clip off the leading "file:"
-< name_in_zip = uri[len(self.current_url_prefix)+1:]
-< try:
-< zf = ZipFile(zipfile_name,'r')
-< except:
-< _logger.debug('Opening Zip file failed: %s'%zipfile_name)
-< return uri
-< try: #first check to see if this location is already filled
-< dest = os.path.join(sugar_activity_root,'tmp')
-< write_zip_to_here = os.path.join(dest, name_in_zip)
-< if os.path.isfile(write_zip_to_here):
-< return write_zip_to_here
-< else:
-< zf.extract(name_in_zip,dest)
-< _logger.debug('Writing Zip file to %s '%(write_zip_to_here))
-< except:
-< _logger.debug('Extracting Zip file %s to %s failed'%(name_in_zip,dest))
-< #self.current_web_view.load_uri(dest)
-< self.last_file_unzipped = write_zip_to_here
-< url = 'file://' + self.last_file_unzipped
-< uri.replace(url)
-< return(url)
-180,181c98,99
-< can_go_back = self.current_web_view.web_navigation.canGoBack
-< self.help_toolbar._back.props.sensitive = can_go_back
----
-> can_go_back = self._web_view.web_navigation.canGoBack
-> self._back.props.sensitive = can_go_back
-183,184c101,102
-< can_go_forward = self.current_web_view.web_navigation.canGoForward
-< self.help_toolbar._forward.props.sensitive = can_go_forward
----
-> can_go_forward = self._web_view.web_navigation.canGoForward
-> self._forward.props.sensitive = can_go_forward
-187c105
-< self.current_web_view.web_navigation.goBack()
----
-> self._web_view.web_navigation.goBack()
-190c108
-< self.current_web_view.web_navigation.goForward()
----
-> self._web_view.web_navigation.goForward()
-193c111
-< self.current_web_view.load_uri(self.url_root)
----
-> self._web_view.load_uri(HOME)
-195d112
-<
diff --git a/help_pd.pyo b/help_pd.pyo
deleted file mode 100755
index c1813c2..0000000
--- a/help_pd.pyo
+++ /dev/null
Binary files differ
diff --git a/help_pd.py~ b/help_pd.py~
deleted file mode 100644
index c012538..0000000
--- a/help_pd.py~
+++ /dev/null
@@ -1,274 +0,0 @@
-# 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
-#
-#NOTE: The webview module shipped with FC11 does a get_Main_window.hide()
-# which makes it unusable in the PyDebug application. A more recent git version
-# toggles the visibility of the gecko engine and is more compatible.
-# The browser.py and webview.py modules included are essential for PyDebug
-#
-import os
-from subprocess import Popen, PIPE
-
-from gettext import gettext as _
-
-import gtk
-import gobject
-import glib
-import wnck
-from time import time
-from sugar import util
-
-from sugar.activity import activity
-from sugar.graphics.toolbox import Toolbox
-from sugar.activity.activityhandle import ActivityHandle
-from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.window import Window
-from sugar import wm
-#from IPython.Debugger import Tracer
-from pdb import *
-
-import hulahop
-hulahop.startup(os.path.join(activity.get_activity_root(), 'data/gecko'))
-import pytoolbar
-import notebook
-
-#from hulahop.webview import WebView
-from browser import Browser
-#import xpcom
-#from xpcom.components import interfaces
-
-gobject.threads_init()
-
-#HOME = os.path.join(activity.get_bundle_path(), 'help/index.html')
-#HOME = "http://website.com/something.html"
-HELP_PANE = 3
-
-# Initialize logging.
-import logging
-#from sugar import logger
-#Get the standard logging directory.
-_logger = logging.getLogger('PyDebug')
-
-
-sugar_activity_root = os.environ['SUGAR_ACTIVITY_ROOT']
-help_notebook_pages = []
-
-class HelpToolbar(gtk.Toolbar):
- def __init__(self, parent):
- gtk.Toolbar.__init__(self)
- self.help_toolbar_parent = parent
- self.child_root = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],'tmp')
-
- self._back = ToolButton('go-previous-paired')
- self._back.set_tooltip(_('Back'))
- self._back.props.sensitive = False
- self._back.connect('clicked', self.help_toolbar_parent._go_back_cb)
- self.insert(self._back, -1)
- self._back.show()
-
- self._forward = ToolButton('go-next-paired')
- self._forward.set_tooltip(_('Forward'))
- self._forward.props.sensitive = False
- self._forward.connect('clicked', self.help_toolbar_parent._go_forward_cb)
- self.insert(self._forward, -1)
- self._forward.show()
-
- home = ToolButton('zoom-home')
- home.set_tooltip(_('Home'))
- home.connect('clicked', self.help_toolbar_parent._go_home_cb)
- self.insert(home, -1)
- home.show()
-
-class Help(Window):
- current_url_prefix = ''
- file_changed = False
- current_web_view = None
- web_view_list = []
- pywin = None
- def __init__(self, parent):
- self.pydebug = parent
- self.handle = ActivityHandle()
- #self._forward.connect('clicked', self.help_toolbar_parent._go_forward_cb)
- self.handle.activity_id = util.unique_id()
- Window.__init__(self)
- self.parent_x11 = None
- self.url_root = 'file://'+ self.pydebug.sugar_bundle_path +"/"+_('help/PyDebug.htm')
-
- #set up tool box/menu buttonsself.help
- self.toolbox = Toolbox()
- self.toolbox.connect('current_toolbar_changed',self.goto_cb)
-
- activitybar = gtk.Toolbar()
- self.toolbox.add_toolbar(_('Activity'), activitybar)
- activitybar.show_all()
-
- editbar = gtk.Toolbar()
- self.toolbox.add_toolbar(_('Edit'), editbar)
- #editbar.connect('current_toolbar_changed', self.goto_cb,1)
- editbar.show_all()
-
- projectbar = gtk.Toolbar()
- self.toolbox.add_toolbar(_('Project'), projectbar)
- #projectbar.connect('current_toolbar_changed', self.goto_cb,2)
- projectbar.show_all()
-
- self.help_toolbar = HelpToolbar(self)
- self.help_toolbar.show()
- self.toolbox.add_toolbar(_('Help'), self.help_toolbar)
- self.toolbox._notebook.set_current_page(HELP_PANE)
-
-
- self.set_toolbox(self.toolbox)
- self.toolbox.show()
-
- self.first_webview = self.new_tab(self.url_root)
- self.web_view_list.append(self.first_webview)
- self.current_web_view = self.first_webview
- #self.first_webview.load_uri(self.url_root)
- self.set_canvas(self._get_help_notebook())
- self.connect('realize',self.realize_cb)
-
- #self.pywin = self.pydebug.window.window
-
-
- def realize_help(self):
- _logger.debug('realize help called')
- self.show_all()
- return self
-
- def realize_cb(self, window):
- self.help_id = util.unique_id()
- wm.set_activity_id(window.window, self.help_id)
-
- def activate_help(self):
- _logger.debug('activate_help called')
- window = self.get_wnck_window_from_activity_id(self.help_id)
- if window:
- window.activate(gtk.get_current_event_time())
-
- def command_line(self,cmd):
- _logger.debug('command_line cmd:%s'%cmd)
- p1 = Popen(cmd,stdout=PIPE, shell=True)
- output = p1.communicate()
- if p1.returncode != 0:
- self.alert(' command returned non zero\n'+output[0])
- return None
- return output[0]
-
- def sugar_version(self):
- cmd = '/bin/rpm -q sugar'
- reply = self.command_line(cmd)
- if reply and reply.find('sugar') > -1:
- version = reply.split('-')[1]
- version_chunks = version.split('.')
- major_minor = version_chunks[0] + '.' + version_chunks[1]
- return major_minor
- return None
-
- def get_wnck_window_from_activity_id(self, activity_id):
- """Use shell model to look up the wmck window associated with activity_id
- --the home_model code changed between .82 and .84 sugar
- --so do the lookup differently depending on sugar version
- """
- if self.sugar_version() >= .84:
- from jarabe.model import shell
- home_model = shell.get_model()
- activity = home_model.get_activity_by_id(activity_id)
- else:
- if not '/usr/share/sugar/shell/' in sys.path:
- sys.path.append('/usr/share/sugar/shell/')
- import shellmodel
- instance = shellmodel.get_instance()
- home_model = instance.get_home()
- activity = home_model._get_activity_by_id(activity_id)
- if activity:
- return activity.get_window()
- else:
- _logger.debug('wnck_window was none')
- return None
-
- def goto_cb(self, page, tab):
- _logger.debug('current_toolbar_changed event called goto_cb. tab: %s'%tab)
- if tab == HELP_PANE: return
- self.pydebug.set_toolbar(tab)
- self.pywin = self.get_wnck_window_from_activity_id(str(self.pydebug.handle.activity_id))
- if self.pywin:
- self.pywin.activate(gtk.get_current_event_time())
-
- def delay(self, msec):
- end = time() + msec / 1000.0
- while time() < end:
- glib.MainContext.iteration(may_block=False)
-
- def _get_help_canvas(self):
- nb = gtk.Notebook()
- nb.show()
- nb.append_page(self.first_webview)
- return nb
-
- def _get_help_notebook(self):
- nb = notebook.Notebook( can_close_tabs=True)
- nb.show()
- nb.append_page(self.first_webview)
- self.help_notebook = nb
- return nb
-
- def new_tab(self,url = None):
- if url == None:
- url = self.url_root
- self._web_view = Browser()
- _logger.debug('loading new tab with url: %s' % url )
- self._web_view.load_uri(url)
- self._web_view.connect('destroy',self._web_view.hide)
- self.current_url = url
- self._web_view.show()
- progress_listener = self._web_view.progress
- progress_listener.connect('location-changed',
- self._location_changed_cb)
- progress_listener.connect('loading-stop', self._loading_stop_cb)
-
- return self._web_view
-
- def get_help_toolbar(self):
- return self.help_toolbar
-
- def repaint(self):
- self._web_view.load_uri(self.current_url)
-
- def get_first_webview(self):
- return self.first_webview
-
- def _location_changed_cb(self, progress_listener, uri):
- self.update_navigation_buttons()
-
- def _loading_stop_cb(self, progress_listener):
- self.update_navigation_buttons()
-
- def update_navigation_buttons(self):
- can_go_back = self.current_web_view.web_navigation.canGoBack
- self.help_toolbar._back.props.sensitive = can_go_back
-
- can_go_forward = self.current_web_view.web_navigation.canGoForward
- self.help_toolbar._forward.props.sensitive = can_go_forward
-
- def _go_back_cb(self, button):
- self.current_web_view.web_navigation.goBack()
-
- def _go_forward_cb(self, button):
- self.current_web_view.web_navigation.goForward()
-
- def _go_home_cb(self, button):
- self.current_web_view.load_uri(self.url_root)
-
-
diff --git a/helpdiff2 b/helpdiff2
deleted file mode 100644
index 6a85458..0000000
--- a/helpdiff2
+++ /dev/null
@@ -1,152 +0,0 @@
-14,19c14
-< #
-< #NOTE: The webview module shipped with FC11 does a get_Main_window.hide()
-< # which makes it unusable in the PyDebug application. A more recent git version
-< # toggles the visibility of the gecko engine and is more compatible.
-< # The browser.py and webview.py modules included are essential for PyDebug
-< #
----
->
-31d25
-< from zipfile import ZipFile, ZipInfo
-35,36c29,30
-< #import xpcom
-< #from xpcom.components import interfaces
----
-> import xpcom
-> from xpcom.components import interfaces
-40c34
-< #HOME = os.path.join(activity.get_bundle_path(), 'help/index.html')
----
-> HOME = os.path.join(activity.get_bundle_path(), 'help/XO_Introduction.html')
-43,57c37,64
-< # Initialize logging.
-< import logging
-< from sugar import logger
-< #Get the standard logging directory.
-< _logger = logging.getLogger('PyDebug')
-<
-< ZIP_SUFFIXES = ['.xol','.zip',]
-< sugar_activity_root = os.environ['SUGAR_ACTIVITY_ROOT']
-< help_notebook_pages = []
-<
-< class HelpToolbar(gtk.Toolbar):
-< def __init__(self, parent):
-< gtk.Toolbar.__init__(self)
-< self.help_toolbar_parent = parent
-< self.child_root = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],'tmp')
----
-> class HelpActivity(activity.Activity):
-> def __init__(self, handle):
-> activity.Activity.__init__(self, handle)
->
-> self.props.max_participants = 1
->
-> self._web_view = Browser()
->
-> toolbox = activity.ActivityToolbox(self)
-> self.set_toolbox(toolbox)
-> toolbox.show()
->
-> toolbar = Toolbar(self._web_view)
-> toolbox.add_toolbar(_('Navigation'), toolbar)
-> toolbar.show()
->
-> self.set_canvas(self._web_view)
-> self._web_view.show()
->
-> toolbox.set_current_toolbar(1)
->
-> self._web_view.load_uri(HOME)
->
-> class Toolbar(gtk.Toolbar):
-> def __init__(self, web_view):
-> gobject.GObject.__init__(self)
->
-> self._web_view = web_view
-62c69
-< self._back.connect('clicked', self.help_toolbar_parent._go_back_cb)
----
-> self._back.connect('clicked', self._go_back_cb)
-69c76
-< self._forward.connect('clicked', self.help_toolbar_parent._go_forward_cb)
----
-> self._forward.connect('clicked', self._go_forward_cb)
-75c82
-< home.connect('clicked', self.help_toolbar_parent._go_home_cb)
----
-> home.connect('clicked', self._go_home_cb)
-79,112d85
-< class Help():
-< current_url_prefix = ''
-< file_changed = False
-< current_web_view = None
-< web_view_list = []
-< def __init__(self, parent):
-< self.pydebug = parent
-< self.url_root = 'file://'+ self.sugar_bundle_path +"/"+_('help/PyDebug.htm')
-< self.help_toolbar = HelpToolbar(self.pydebug)
-< self.help_toolbar.show()
-< self.first_webview = self.new_tab(self.url_root)
-< self.web_view_list.append(self.first_webview)
-< self.current_web_view = self.first_webview
-< self.first_webview.load_uri(self.url_root)
-<
-< def get_help_toolbar(self):
-< return self.help_toolbar
-<
-< def _get_help_canvas(self):
-< nb = gtk.Notebook()
-< nb.show()
-< nb.append_page(self.first_webview)
-< self.help_notebook = nb
-< return nb
-<
-< def new_tab(self,url = None):
-< if url == None:
-< url = self.url_root
-< self._web_view = Browser()
-< _logger.debug('loading new tab with url: %s' % url )
-< self._web_view.load_uri(url)
-< self._web_view.connect('destroy',self._web_view.hide)
-< self.current_url = url
-< self._web_view.show()
-118,125d90
-< return self._web_view
-<
-< def repaint(self):
-< self._web_view.load_uri(self.current_url)
-<
-< def get_first_webview(self):
-< return self.first_webview
-<
-128c93
-<
----
->
-133,134c98,99
-< can_go_back = self.current_web_view.web_navigation.canGoBack
-< self.help_toolbar._back.props.sensitive = can_go_back
----
-> can_go_back = self._web_view.web_navigation.canGoBack
-> self._back.props.sensitive = can_go_back
-136,137c101,102
-< can_go_forward = self.current_web_view.web_navigation.canGoForward
-< self.help_toolbar._forward.props.sensitive = can_go_forward
----
-> can_go_forward = self._web_view.web_navigation.canGoForward
-> self._forward.props.sensitive = can_go_forward
-140c105
-< self.current_web_view.web_navigation.goBack()
----
-> self._web_view.web_navigation.goBack()
-143c108
-< self.current_web_view.web_navigation.goForward()
----
-> self._web_view.web_navigation.goForward()
-146c111
-< self.current_web_view.load_uri(self.url_root)
----
-> self._web_view.load_uri(HOME)
-148d112
-<
diff --git a/history b/history
deleted file mode 100644
index 78a7ddf..0000000
--- a/history
+++ /dev/null
@@ -1,17 +0,0 @@
-?
-go
-__IP.magic('xmode' 'plain')
-dir(__IP)
-__IP.magic_xmode='plain'
-go
-__IP.magic_xmode='verbose'
-go
-__IP.magic_xmode
-__IP.magic_xmode='Verbose'
-go
-__IP.magic_xmode
-__IP.magic_xmode('plain')
-__IP.magic_xmode('verbose')
-go
-__IP
-go
diff --git a/ipy_user_conf.pyo b/ipy_user_conf.pyo
deleted file mode 100644
index 0681f19..0000000
--- a/ipy_user_conf.pyo
+++ /dev/null
Binary files differ
diff --git a/lib/python2.5/site-packages/sugar/graphics/colorbutton.py b/lib/python2.5/site-packages/sugar/graphics/colorbutton.py
deleted file mode 100644
index a5c7f0a..0000000
--- a/lib/python2.5/site-packages/sugar/graphics/colorbutton.py
+++ /dev/null
@@ -1,531 +0,0 @@
-# Copyright (C) 2007, Red Hat, Inc.
-# Copyright (C) 2008, Benjamin Berg <benjamin@sipsolutions.net>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-import gettext
-import gtk
-import gobject
-import struct
-import logging
-
-from sugar.graphics import style
-from sugar.graphics.icon import Icon
-from sugar.graphics.palette import Palette, ToolInvoker, WidgetInvoker
-
-_ = lambda msg: gettext.dgettext('sugar-toolkit', msg)
-
-def get_svg_color_string(color):
- return '#%.2X%.2X%.2X' % (color.red / 257, color.green / 257,
- color.blue / 257)
-
-class _ColorButton(gtk.Button):
- """This is a ColorButton for Sugar. It is similar to the gtk.ColorButton,
- but does not have any alpha support.
- Instead of a color selector dialog it will pop up a Sugar palette.
-
- As a preview an sugar.graphics.Icon is used. The fill color will be set to
- the current color, and the stroke color is set to the font color.
- """
-
- __gtype_name__ = 'SugarColorButton'
- __gsignals__ = { 'color-set' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- tuple())}
-
- def __init__(self, **kwargs):
- self._title = _('Choose a color')
- self._color = gtk.gdk.Color(0, 0, 0)
- self._has_palette = True
- self._has_invoker = True
- self._palette = None
- self._accept_drag = True
-
- self._preview = Icon(icon_name='color-preview',
- icon_size=gtk.ICON_SIZE_BUTTON)
-
- gobject.GObject.__init__(self, **kwargs)
-
- if self._accept_drag:
- self.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
- gtk.DEST_DEFAULT_HIGHLIGHT |
- gtk.DEST_DEFAULT_DROP,
- [('application/x-color', 0, 0)],
- gtk.gdk.ACTION_COPY)
- self.drag_source_set(gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK,
- [('application/x-color', 0, 0)],
- gtk.gdk.ACTION_COPY)
- self.connect('drag_data_received', self.__drag_data_received_cb)
- self.connect('drag_data_get', self.__drag_data_get_cb)
-
- self._preview.fill_color = get_svg_color_string(self._color)
- self._preview.stroke_color = \
- get_svg_color_string(self.style.fg[gtk.STATE_NORMAL])
- self.set_image(self._preview)
-
- if self._has_palette and self._has_invoker:
- self._invoker = WidgetInvoker(self)
- # FIXME: This is a hack.
- self._invoker.has_rectangle_gap = lambda : False
- self._invoker.palette = self._palette
-
- def create_palette(self):
- if self._has_palette:
- self._palette = _ColorPalette(color=self._color,
- primary_text=self._title)
- self._palette.connect('color-set', self.__palette_color_set_cb)
- self._palette.connect('notify::color', self.__palette_color_changed)
-
- return self._palette
-
- def __palette_color_set_cb(self, palette):
- self.emit('color-set')
-
- def __palette_color_changed(self, palette, pspec):
- self.color = self._palette.color
-
- def do_style_set(self, previous_style):
- self._preview.stroke_color = \
- get_svg_color_string(self.style.fg[gtk.STATE_NORMAL])
-
- def do_clicked(self):
- if self._palette:
- if not self._palette.is_up():
- self._palette.popup(immediate=True,
- state=self._palette.SECONDARY)
- else:
- self._palette.popdown(immediate=True)
- return True
-
- def set_color(self, color):
- assert isinstance(color, gtk.gdk.Color)
-
- if self._color.red == color.red and \
- self._color.green == color.green and \
- self._color.blue == color.blue:
- return
-
- self._color = gtk.gdk.Color(color.red, color.green, color.blue)
- self._preview.fill_color = get_svg_color_string(self._color)
- if self._palette:
- self._palette.props.color = self._color
- self.notify('color')
-
- def get_color(self):
- return self._color
-
- color = gobject.property(type=object, getter=get_color, setter=set_color)
-
- def set_icon_name(self, icon_name):
- self._preview.props.icon_name = icon_name
-
- def get_icon_name(self):
- return self._preview.props.icon_name
-
- icon_name = gobject.property(type=str,
- getter=get_icon_name, setter=set_icon_name)
-
- def set_icon_size(self, icon_size):
- self._preview.props.icon_size = icon_size
-
- def get_icon_size(self):
- return self._preview.props.icon_size
-
- icon_size = gobject.property(type=int,
- getter=get_icon_size, setter=set_icon_size)
-
- def set_title(self, title):
- self._title = title
- if self._palette:
- self._palette.primary_text = self._title
-
- def get_title(self):
- return self._title
-
- title = gobject.property(type=str, getter=get_title, setter=set_title)
-
- def _set_has_invoker(self, has_invoker):
- self._has_invoker = has_invoker
-
- def _get_has_invoker(self):
- return self._has_invoker
-
- has_invoker = gobject.property(type=bool, default=True,
- flags=gobject.PARAM_READWRITE |
- gobject.PARAM_CONSTRUCT_ONLY,
- getter=_get_has_invoker,
- setter=_set_has_invoker)
-
- def _set_has_palette(self, has_palette):
- self._has_palette = has_palette
-
- def _get_has_palette(self):
- return self._has_palette
-
- has_palette = gobject.property(type=bool, default=True,
- flags=gobject.PARAM_READWRITE |
- gobject.PARAM_CONSTRUCT_ONLY,
- getter=_get_has_palette,
- setter=_set_has_palette)
-
- def _set_accept_drag(self, accept_drag):
- self._accept_drag = accept_drag
-
- def _get_accept_drag(self):
- return self._accept_drag
-
- accept_drag = gobject.property(type=bool, default=True,
- flags=gobject.PARAM_READWRITE |
- gobject.PARAM_CONSTRUCT_ONLY,
- getter=_get_accept_drag,
- setter=_set_accept_drag)
-
- # Drag and Drop
- def __drag_begin_cb(self, widget, context):
- pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
- style.SMALL_ICON_SIZE,
- style.SMALL_ICON_SIZE)
-
- red = self._color.red / 257
- green = self._color.green / 257
- blue = self._color.blue / 257
-
- pixbuf.fill(red << 24 + green << 16 + blue << 8 + 0xff)
-
- context.set_icon_pixbuf(pixbuf)
-
- def __drag_data_get_cb(self, widget, context, selection_data, info, time):
- data = struct.pack('=HHHH', self._color.red, self._color.green,
- self._color.blue, 65535)
- selection_data.set(selection_data.target, 16, data)
-
- def __drag_data_received_cb(self, widget, context, x, y, selection_data, \
- info, time):
- if len(selection_data.data) != 8:
- return
-
- dropped = selection_data.data
- red = struct.unpack_from('=H', dropped, 0)[0]
- green = struct.unpack_from('=H', dropped, 2)[0]
- blue = struct.unpack_from('=H', dropped, 4)[0]
- # dropped[6] and dropped[7] is alpha, but we ignore the alpha channel
-
- color = gtk.gdk.Color(red, green, blue)
- self.set_color(color)
-
-
-class _ColorPalette(Palette):
- """This is a color picker palette. It will usually be used indirectly
- trough a sugar.graphics.ColorButton.
- """
- _RED = 0
- _GREEN = 1
- _BLUE = 2
-
- __gtype_name__ = 'SugarColorPalette'
- # The color-set signal is emitted when the user is finished selecting
- # a color.
- __gsignals__ = { 'color-set' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- tuple())}
-
- def __init__(self, **kwargs):
- self._color = gtk.gdk.Color(0, 0, 0)
- self._previous_color = self._color.copy()
- self._scales = None
-
- Palette.__init__(self, **kwargs)
-
- self.connect('popup', self.__popup_cb)
- self.connect('popdown', self.__popdown_cb)
-
- self._picker_hbox = gtk.HBox()
- self.set_content(self._picker_hbox)
-
- self._swatch_tray = gtk.Table()
-
- self._picker_hbox.pack_start(self._swatch_tray)
- self._picker_hbox.pack_start(gtk.VSeparator(),
- padding=style.DEFAULT_SPACING)
-
- self._chooser_table = gtk.Table(3, 2)
- self._chooser_table.set_col_spacing(0, style.DEFAULT_PADDING)
-
- self._scales = []
- self._scales.append(
- self._create_color_scale(_('Red'), self._RED, 0))
- self._scales.append(
- self._create_color_scale(_('Green'), self._GREEN, 1))
- self._scales.append(
- self._create_color_scale(_('Blue'), self._BLUE, 2))
-
- self._picker_hbox.add(self._chooser_table)
-
- self._picker_hbox.show_all()
-
- self._build_swatches()
-
- def _create_color_scale(self, text, color, row):
- label = gtk.Label(text)
- label.props.xalign = 1.0
- scale = gtk.HScale()
- scale.set_size_request(style.zoom(250), -1)
- scale.set_draw_value(False)
- scale.set_range(0, 1.0)
- scale.set_increments(0.1, 0.2)
-
- if color == self._RED:
- scale.set_value(self._color.red / 65535.0)
- elif color == self._GREEN:
- scale.set_value(self._color.green / 65535.0)
- elif color == self._BLUE:
- scale.set_value(self._color.blue / 65535.0)
-
- scale.connect('value-changed',
- self.__scale_value_changed_cb,
- color)
- self._chooser_table.attach(label, 0, 1, row, row + 1)
- self._chooser_table.attach(scale, 1, 2, row, row + 1)
-
- return scale
-
-
-
- def _build_swatches(self):
- for child in self._swatch_tray.get_children():
- child.destroy()
-
- # Use a hardcoded list of colors for now.
- colors = ['#ed2529', '#69bc47', '#3c54a3',
- '#f57f25', '#0b6b3a', '#00a0c6',
- '#f6eb1a', '#b93f94', '#5b4a9c',
- '#000000', '#919496', '#ffffff']
-
- # We want 3 rows of colors.
- rows = 3
- i = 0
- self._swatch_tray.props.n_rows = rows
- self._swatch_tray.props.n_columns = (len(colors) + rows - 1) / rows
- for color in colors:
- button = _ColorButton(has_palette=False,
- color=gtk.gdk.color_parse(color),
- accept_drag=False,
- icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
- button.set_relief(gtk.RELIEF_NONE)
- self._swatch_tray.attach(button,
- i % rows, i % rows + 1,
- i / rows, i / rows + 1,
- yoptions=0, xoptions=0)
- button.connect('clicked', self.__swatch_button_clicked_cb)
- i += 1
-
- self._swatch_tray.show_all()
-
- def __popup_cb(self, palette):
- self._previous_color = self._color.copy()
-
- def __popdown_cb(self, palette):
- self.emit('color-set')
-
- def __scale_value_changed_cb(self, widget, color):
- new_color = self._color.copy()
- if color == self._RED:
- new_color.red = int(65535 * widget.get_value())
- elif color == self._GREEN:
- new_color.green = int(65535 * widget.get_value())
- elif color == self._BLUE:
- new_color.blue = int(65535 * widget.get_value())
- self.color = new_color
-
- def do_key_press_event(self, event):
- if event.keyval == gtk.keysyms.Escape:
- self.props.color = self._previous_color
- self.popdown(immediate=True)
- return True
- elif event.keyval == gtk.keysyms.Return:
- self.popdown(immediate=True)
- return True
- return False
-
- def __swatch_button_clicked_cb(self, button):
- self.props.color = button.get_color()
-
- def set_color(self, color):
- assert isinstance(color, gtk.gdk.Color)
-
- if self._color.red == color.red and \
- self._color.green == color.green and \
- self._color.blue == color.blue:
- return
-
- self._color = color.copy()
-
- if self._scales:
- self._scales[self._RED].set_value(self._color.red / 65535.0)
- self._scales[self._GREEN].set_value(self._color.green / 65535.0)
- self._scales[self._BLUE].set_value(self._color.blue / 65535.0)
-
- self.notify('color')
-
- def get_color(self):
- return self._color
-
- color = gobject.property(type=object, getter=get_color, setter=set_color)
-
-
-
-def _add_accelerator(tool_button):
- if not tool_button.props.accelerator or not tool_button.get_toplevel() or \
- not tool_button.child:
- return
-
- # TODO: should we remove the accelerator from the prev top level?
-
- accel_group = tool_button.get_toplevel().get_data('sugar-accel-group')
- if not accel_group:
- logging.warning('No gtk.AccelGroup in the top level window.')
- return
-
- keyval, mask = gtk.accelerator_parse(tool_button.props.accelerator)
- # the accelerator needs to be set at the child, so the gtk.AccelLabel
- # in the palette can pick it up.
- tool_button.child.add_accelerator('clicked', accel_group, keyval, mask,
- gtk.ACCEL_LOCKED | gtk.ACCEL_VISIBLE)
-
-def _hierarchy_changed_cb(tool_button, previous_toplevel):
- _add_accelerator(tool_button)
-
-def setup_accelerator(tool_button):
- _add_accelerator(tool_button)
- tool_button.connect('hierarchy-changed', _hierarchy_changed_cb)
-
-# This not ideal. It would be better to subclass gtk.ToolButton, however
-# the python bindings do not seem to be powerfull enough for that.
-# (As we need to change a variable in the class structure.)
-class ColorToolButton(gtk.ToolItem):
- __gtype_name__ = 'SugarColorToolButton'
- __gsignals__ = { 'color-set' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- tuple())}
-
- def __init__(self, icon_name='color-preview', **kwargs):
- self._accelerator = None
- self._tooltip = None
- self._palette_invoker = ToolInvoker()
- self._palette = None
-
- gobject.GObject.__init__(self, **kwargs)
-
- # The gtk.ToolButton has already added a normal button.
- # Replace it with a ColorButton
- color_button = _ColorButton(icon_name=icon_name, has_invoker=False)
- self.add(color_button)
-
- # The following is so that the behaviour on the toolbar is correct.
- color_button.set_relief(gtk.RELIEF_NONE)
- color_button.icon_size = gtk.ICON_SIZE_LARGE_TOOLBAR
-
- self._palette_invoker.attach_tool(self)
-
- # This widget just proxies the following properties to the colorbutton
- color_button.connect('notify::color', self.__notify_change)
- color_button.connect('notify::icon-name', self.__notify_change)
- color_button.connect('notify::icon-size', self.__notify_change)
- color_button.connect('notify::title', self.__notify_change)
- color_button.connect('color-set', self.__color_set_cb)
- color_button.connect('can-activate-accel',
- self.__button_can_activate_accel_cb)
-
- def __button_can_activate_accel_cb(self, button, signal_id):
- # Accept activation via accelerators regardless of this widget's state
- return True
-
- def set_accelerator(self, accelerator):
- self._accelerator = accelerator
- setup_accelerator(self)
-
- def get_accelerator(self):
- return self._accelerator
-
- accelerator = gobject.property(type=str, setter=set_accelerator,
- getter=get_accelerator)
-
- def create_palette(self):
- self._palette = self.get_child().create_palette()
- return self._palette
-
- def get_palette_invoker(self):
- return self._palette_invoker
-
- def set_palette_invoker(self, palette_invoker):
- self._palette_invoker.detach()
- self._palette_invoker = palette_invoker
-
- palette_invoker = gobject.property(
- type=object, setter=set_palette_invoker, getter=get_palette_invoker)
-
- def set_color(self, color):
- self.get_child().props.color = color
-
- def get_color(self):
- return self.get_child().props.color
-
- color = gobject.property(type=object, getter=get_color, setter=set_color)
-
- def set_icon_name(self, icon_name):
- self.get_child().props.icon_name = icon_name
-
- def get_icon_name(self):
- return self.get_child().props.icon_name
-
- icon_name = gobject.property(type=str,
- getter=get_icon_name, setter=set_icon_name)
-
- def set_icon_size(self, icon_size):
- self.get_child().props.icon_size = icon_size
-
- def get_icon_size(self):
- return self.get_child().props.icon_size
-
- icon_size = gobject.property(type=int,
- getter=get_icon_size, setter=set_icon_size)
-
- def set_title(self, title):
- self.get_child().props.title = title
-
- def get_title(self):
- return self.get_child().props.title
-
- title = gobject.property(type=str, getter=get_title, setter=set_title)
-
- def do_expose_event(self, event):
- child = self.get_child()
- allocation = self.get_allocation()
- if self._palette and self._palette.is_up():
- invoker = self._palette.props.invoker
- invoker.draw_rectangle(event, self._palette)
- elif child.state == gtk.STATE_PRELIGHT:
- child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
- gtk.SHADOW_NONE, event.area,
- child, 'toolbutton-prelight',
- allocation.x, allocation.y,
- allocation.width, allocation.height)
-
- gtk.ToolButton.do_expose_event(self, event)
-
- def __notify_change(self, widget, pspec):
- self.notify(pspec.name)
-
- def __color_set_cb(self, widget):
- self.emit('color-set')
-
diff --git a/lib/python2.6/site-packages/browser.py b/lib/python2.6/site-packages/browser.py
deleted file mode 100644
index b0a7ae7..0000000
--- a/lib/python2.6/site-packages/browser.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# Copyright (C) 2006, Red Hat, Inc.
-# Copyright (C) 2007, One Laptop Per Child
-#
-# 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 os
-import time
-import logging
-from gettext import gettext as _
-
-import gobject
-import gtk
-import hulahop
-import xpcom
-from xpcom.nsError import *
-from xpcom import components
-from xpcom.components import interfaces
-from hulahop.webview import WebView
-
-from sugar.datastore import datastore
-from sugar import profile
-from sugar import env
-from sugar.activity import activity
-from sugar.graphics import style
-
-import sessionstore
-from palettes import ContentInvoker
-from sessionhistory import HistoryListener
-from progresslistener import ProgressListener
-
-_ZOOM_AMOUNT = 0.1
-
-class GetSourceListener(object):
- _com_interfaces_ = interfaces.nsIWebProgressListener
-
- def __init__(self, file_path, async_cb, async_err_cb):
- self._file_path = file_path
- self._async_cb = async_cb
- self._async_err_cb = async_err_cb
-
- def onStateChange(self, webProgress, request, stateFlags, status):
- if stateFlags & interfaces.nsIWebProgressListener.STATE_IS_REQUEST and \
- stateFlags & interfaces.nsIWebProgressListener.STATE_STOP:
- self._async_cb(self._file_path)
-
- def onProgressChange(self, progress, request, curSelfProgress,
- maxSelfProgress, curTotalProgress, maxTotalProgress):
- pass
-
- def onLocationChange(self, progress, request, location):
- pass
-
- def onStatusChange(self, progress, request, status, message):
- pass
-
- def onSecurityChange(self, progress, request, state):
- pass
-
-class CommandListener(object):
- _com_interfaces_ = interfaces.nsIDOMEventListener
- def __init__(self, window):
- self._window = window
-
- def handleEvent(self, event):
- if not event.isTrusted:
- return
-
- uri = event.originalTarget.ownerDocument.documentURI
- if not uri.startswith('about:neterror?e=nssBadCert'):
- return
-
- cls = components.classes['@sugarlabs.org/add-cert-exception;1']
- cert_exception = cls.createInstance(interfaces.hulahopAddCertException)
- cert_exception.showDialog(self._window)
-
-class Browser(WebView):
-
- AGENT_SHEET = os.path.join(activity.get_bundle_path(),
- 'agent-stylesheet.css')
- USER_SHEET = os.path.join(env.get_profile_path(), 'gecko',
- 'user-stylesheet.css')
-
- def __init__(self):
- WebView.__init__(self)
-
- self.history = HistoryListener()
- self.progress = ProgressListener()
-
- cls = components.classes["@mozilla.org/typeaheadfind;1"]
- self.typeahead = cls.createInstance(interfaces.nsITypeAheadFind)
-
- self._jobject = None
-
- io_service_class = components.classes[ \
- "@mozilla.org/network/io-service;1"]
- io_service = io_service_class.getService(interfaces.nsIIOService)
-
- # Use xpcom to turn off "offline mode" detection, which disables
- # access to localhost for no good reason. (Trac #6250.)
- io_service2 = io_service_class.getService(interfaces.nsIIOService2)
- io_service2.manageOfflineStatus = False
-
- cls = components.classes['@mozilla.org/content/style-sheet-service;1']
- style_sheet_service = cls.getService(interfaces.nsIStyleSheetService)
-
- if os.path.exists(Browser.AGENT_SHEET):
- agent_sheet_uri = io_service.newURI('file:///' +
- Browser.AGENT_SHEET,
- None, None)
- style_sheet_service.loadAndRegisterSheet(agent_sheet_uri,
- interfaces.nsIStyleSheetService.AGENT_SHEET)
-
- if os.path.exists(Browser.USER_SHEET):
- user_sheet_uri = io_service.newURI('file:///' + Browser.USER_SHEET,
- None, None)
- style_sheet_service.loadAndRegisterSheet(user_sheet_uri,
- interfaces.nsIStyleSheetService.USER_SHEET)
-
- def do_setup(self):
- WebView.do_setup(self)
-
- listener = xpcom.server.WrapObject(ContentInvoker(self),
- interfaces.nsIDOMEventListener)
- self.window_root.addEventListener('click', listener, False)
-
- listener = xpcom.server.WrapObject(CommandListener(self.dom_window),
- interfaces.nsIDOMEventListener)
- self.window_root.addEventListener('command', listener, False)
-
- self.progress.setup(self)
-
- self.history.setup(self.web_navigation)
-
- self.typeahead.init(self.doc_shell)
-
- def get_session(self):
- return sessionstore.get_session(self)
-
- def set_session(self, data):
- return sessionstore.set_session(self, data)
-
- def get_source(self, async_cb, async_err_cb):
- cls = components.classes[ \
- '@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
- persist = cls.createInstance(interfaces.nsIWebBrowserPersist)
- # get the source from the cache
- persist.persistFlags = \
- interfaces.nsIWebBrowserPersist.PERSIST_FLAGS_FROM_CACHE
-
- temp_path = os.path.join(activity.get_activity_root(), 'instance')
- file_path = os.path.join(temp_path, '%i' % time.time())
- cls = components.classes["@mozilla.org/file/local;1"]
- local_file = cls.createInstance(interfaces.nsILocalFile)
- local_file.initWithPath(file_path)
-
- progresslistener = GetSourceListener(file_path, async_cb, async_err_cb)
- persist.progressListener = xpcom.server.WrapObject(
- progresslistener, interfaces.nsIWebProgressListener)
-
- uri = self.web_navigation.currentURI
- persist.saveURI(uri, self.doc_shell, None, None, None, local_file)
-
- def zoom_in(self):
- contentViewer = self.doc_shell.queryInterface( \
- interfaces.nsIDocShell).contentViewer
- if contentViewer is not None:
- markupDocumentViewer = contentViewer.queryInterface( \
- interfaces.nsIMarkupDocumentViewer)
- markupDocumentViewer.fullZoom += _ZOOM_AMOUNT
-
- def zoom_out(self):
- contentViewer = self.doc_shell.queryInterface( \
- interfaces.nsIDocShell).contentViewer
- if contentViewer is not None:
- markupDocumentViewer = contentViewer.queryInterface( \
- interfaces.nsIMarkupDocumentViewer)
- markupDocumentViewer.fullZoom -= _ZOOM_AMOUNT
-
-class PopupDialog(gtk.Window):
- def __init__(self):
- gtk.Window.__init__(self)
-
- self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
-
- border = style.GRID_CELL_SIZE
- self.set_default_size(gtk.gdk.screen_width() - border * 2,
- gtk.gdk.screen_height() - border * 2)
-
- self.view = WebView()
- self.add(self.view)
- self.view.realize()
-
-class WindowCreator:
- _com_interfaces_ = interfaces.nsIWindowCreator
-
- def createChromeWindow(self, parent, flags):
- dialog = PopupDialog()
-
- parent_dom_window = parent.webBrowser.contentDOMWindow
- parent_view = hulahop.get_view_for_window(parent_dom_window)
- if parent_view:
- dialog.set_transient_for(parent_view.get_toplevel())
-
- browser = dialog.view.browser
-
- if flags & interfaces.nsIWebBrowserChrome.CHROME_OPENAS_CHROME:
- dialog.view.is_chrome = True
-
- item = browser.queryInterface(interfaces.nsIDocShellTreeItem)
- item.itemType = interfaces.nsIDocShellTreeItem.typeChromeWrapper
-
- return browser.containerWindow
-
-window_creator = WindowCreator()
-cls = components.classes['@mozilla.org/embedcomp/window-watcher;1']
-window_watcher = cls.getService(interfaces.nsIWindowWatcher)
-window_watcher.setWindowCreator(window_creator)
diff --git a/lib/python2.6/site-packages/sugar.save/activity/activityshim.py b/lib/python2.6/site-packages/sugar.save/activity/activityshim.py
deleted file mode 100644
index 5586162..0000000
--- a/lib/python2.6/site-packages/sugar.save/activity/activityshim.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright (C) 2006-2007 Red Hat, Inc.
-# Copyright (C) 2007-2009 One Laptop Per Child
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-import gettext
-import logging
-import os
-import time
-from hashlib import sha1
-import traceback
-import gconf
-
-import gtk
-import gobject
-import dbus
-import dbus.service
-import cjson
-
-from sugar import util
-from sugar.presence import presenceservice
-from sugar.activity.activityservice import ActivityService
-from sugar.activity.namingalert import NamingAlert
-from sugar.graphics import style
-from sugar.graphics.window import Window
-from sugar.graphics.toolbox import Toolbox
-from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.toolcombobox import ToolComboBox
-from sugar.graphics.alert import Alert
-from sugar.graphics.icon import Icon
-from sugar.graphics.xocolor import XoColor
-from sugar.datastore import datastore
-from sugar.session import XSMPClient
-from sugar import wm
-from sugar.activity.olpcactivity import ActivityShim
-
-class Activity(ActivityShim):
- def __init__(self,handle, create_jobject=True):
- ActivityShim.__init__(self, handle, create_jobject)
-
- #define any super class redefinitions here
- def set_canvas(self,canvas):
- #from the source we see that the activity._vbox is the top level container below the main window
- ActivityShim.set_canvas = self._vbox
- self.set_canvas(canvas)
-
-
diff --git a/lib/python2.6/site-packages/sugar.save/activity/olpcactivity.pth b/lib/python2.6/site-packages/sugar.save/activity/olpcactivity.pth
deleted file mode 100644
index 4d8bfdc..0000000
--- a/lib/python2.6/site-packages/sugar.save/activity/olpcactivity.pth
+++ /dev/null
@@ -1,2 +0,0 @@
-/usr/lib/python2.6/site-packages/sugar/activity/activity.py
-
diff --git a/lib/python2.6/site-packages/terminal.py b/lib/python2.6/site-packages/terminal.py
deleted file mode 100644
index dc52a13..0000000
--- a/lib/python2.6/site-packages/terminal.py
+++ /dev/null
@@ -1,308 +0,0 @@
-# Copyright (C) 2007, Eduardo Silva <edsiper@gmail.com>.
-# Copyright (C) 2008, One Laptop Per Child
-#
-# 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 os, os.path, simplejson, ConfigParser
-
-from gettext import gettext as _
-
-# Initialize logging.
-import logging
-log = logging.getLogger('PyDebug')
-log.setLevel(logging.DEBUG)
-logging.basicConfig()
-
-import gtk
-import vte
-import pango
-
-from sugar.graphics.toolbutton import ToolButton
-import sugar.graphics.toolbutton
-import sugar.activity.activity
-import sugar.env
-
-MASKED_ENVIRONMENT = [
- 'DBUS_SESSION_BUS_ADDRESS',
- 'PPID'
-]
-
-class Terminal():
-
- def __init__(self,handle):
- pass
-
- def _get_terminal_canvas(self):
- self.terminal_notebook = gtk.Notebook()
- self.terminal_notebook.set_property("tab-pos", gtk.POS_BOTTOM)
- self.terminal_notebook.set_scrollable(True)
- self.terminal_notebook.show()
- return self.terminal_notebook
-
- def _open_tab_cb(self, btn):
- index = self._create_tab(None)
- self.notebook.page = index
-
- def _close_tab_cb(self, btn):
- self._close_tab(self.notebook.props.page)
-
- def _prev_tab_cb(self, btn):
- if self.notebook.props.page == 0:
- self.notebook.props.page = self.notebook.get_n_pages() - 1
- else:
- self.notebook.props.page = self.notebook.props.page - 1
- vt = self.notebook.get_nth_page(self.notebook.get_current_page()).vt
- vt.grab_focus()
-
- def _next_tab_cb(self, btn):
- if self.notebook.props.page == self.notebook.get_n_pages() - 1:
- self.notebook.props.page = 0
- else:
- self.notebook.props.page = self.notebook.props.page + 1
- vt = self.notebook.get_nth_page(self.notebook.get_current_page()).vt
- vt.grab_focus()
-
- def _close_tab(self, index):
- self.notebook.remove_page(index)
- if self.notebook.get_n_pages() == 0:
- self.close()
-
- def _tab_child_exited_cb(self, vt):
- for i in range(self.notebook.get_n_pages()):
- if self.notebook.get_nth_page(i).vt == vt:
- self._close_tab(i)
- return
-
- def _tab_title_changed_cb(self, vt):
- for i in range(self.notebook.get_n_pages()):
- if self.notebook.get_nth_page(i).vt == vt:
- label = self.notebook.get_nth_page(i).label
- label.set_text(vt.get_window_title())
- return
-
- def _drag_data_received_cb(self, widget, context, x, y, selection, target, time):
- widget.feed_child(selection.data)
- context.finish(True, False, time)
- return True
-
- def _create_tab(self, tab_state):
- vt = vte.Terminal()
- vt.connect("child-exited", self._tab_child_exited_cb)
- vt.connect("window-title-changed", self._tab_title_changed_cb)
-
- vt.drag_dest_set(gtk.DEST_DEFAULT_MOTION|gtk.DEST_DEFAULT_DROP,
- [('text/plain', 0, 0), ('STRING', 0, 1)],
- gtk.gdk.ACTION_DEFAULT|
- gtk.gdk.ACTION_COPY)
- vt.connect('drag_data_received', self._drag_data_received_cb)
-
- self._configure_vt(vt)
-
- vt.show()
-
- label = gtk.Label()
-
- scrollbar = gtk.VScrollbar(vt.get_adjustment())
- scrollbar.show()
-
- box = gtk.HBox()
- box.pack_start(vt)
- box.pack_start(scrollbar)
-
- box.vt = vt
- box.label = label
-
- index = self.terminal_notebook.append_page(box, label)
- self.terminal_notebook.show_all()
-
- # Uncomment this to only show the tab bar when there is at least one tab.
- # I think it's useful to always see it, since it displays the 'window title'.
- #self.notebook.props.show_tabs = self.notebook.get_n_pages() > 1
-
- # Launch the default shell in the HOME directory.
- os.chdir(os.environ["HOME"])
-
- if tab_state:
- # Restore the environment.
- # This is currently not enabled.
- env = tab_state['env']
-
- filtered_env = []
- for e in env:
- var, sep, value = e.partition('=')
- if var not in MASKED_ENVIRONMENT:
- filtered_env.append(var + sep + value)
-
- # TODO: Make the shell restore these environment variables, then clear out TERMINAL_ENV.
- #os.environ['TERMINAL_ENV'] = '\n'.join(filtered_env)
-
- # Restore the working directory.
- if tab_state.has_key('cwd'):
- os.chdir(tab_state['cwd'])
-
- # Restore the scrollback buffer.
- for l in tab_state['scrollback']:
- vt.feed(l + '\r\n')
-
- box.pid = vt.fork_command()
-
- self.terminal_notebook.props.page = index
- vt.grab_focus()
-
- return index
-
- def _copy_cb(self, button):
- vt = self.terminal_notebook.get_nth_page(self.terminal_notebook.get_current_page()).vt
- if vt.get_has_selection():
- vt.copy_clipboard()
-
- def _paste_cb(self, button):
- vt = self.terminal_notebook.get_nth_page(self.terminal_notebook.get_current_page()).vt
- vt.paste_clipboard()
-
- def _become_root_cb(self, button):
- vt = self.terminal_notebook.get_nth_page(self.terminal_notebook.get_current_page()).vt
- vt.feed('\r\n')
- vt.fork_command("/bin/su", ('/bin/su', '-'))
-
- def _fullscreen_cb(self, btn):
- self.fullscreen()
-
- def _key_press_cb(self, window, event):
- # Escape keypresses are routed directly to the vte and then dropped.
- # This hack prevents Sugar from hijacking them and canceling fullscreen mode.
- if gtk.gdk.keyval_name(event.keyval) == 'Escape':
- vt = self.terminal_notebook.get_nth_page(self.terminal_notebook.get_current_page()).vt
- vt.event(event)
- return True
-
- return False
-
- def read_file(self, file_path):
- if self.metadata['mime_type'] != 'text/plain':
- return
-
- fd = open(file_path, 'r')
- text = fd.read()
- data = simplejson.loads(text)
- fd.close()
-
- data_file = file_path
-
- # Clean out any existing tabs.
- while self.terminal_notebook.get_n_pages():
- self.terminal_notebook.remove_page(0)
-
- # Create new tabs from saved state.
- for tab_state in data['tabs']:
- self._create_tab(tab_state)
-
- # Restore active tab.
- self.terminal_notebook.props.page = data['current-tab']
-
- # Create a blank one if this state had no terminals.
- if self.terminal_notebook.get_n_pages() == 0:
- self._create_tab(None)
-
- def write_file(self, file_path):
- if not self.metadata['mime_type']:
- self.metadata['mime_type'] = 'text/plain'
-
- data = {}
- data['current-tab'] = self.terminal_notebook.get_current_page()
- data['tabs'] = []
-
- for i in range(self.terminal_notebook.get_n_pages()):
- page = self.terminal_notebook.get_nth_page(i)
-
- def selected_cb(terminal, c, row, cb_data):
- return 1
- (scrollback_text, attrs) = page.vt.get_text(selected_cb, 1)
-
- scrollback_lines = scrollback_text.split('\n')
-
- # Note- this currently gets the child's initial environment rather than the current
- # environment, making it not very useful.
- environment = open('/proc/%d/environ' % page.pid, 'r').read().split('\0')
-
- cwd = os.readlink('/proc/%d/cwd' % page.pid)
-
- tab_state = { 'env': environment, 'cwd': cwd, 'scrollback': scrollback_lines }
-
- data['tabs'].append(tab_state)
-
- fd = open(file_path, 'w')
- text = simplejson.dumps(data)
- fd.write(text)
- fd.close()
-
- def _get_conf(self, conf, var, default):
- if conf.has_option('terminal', var):
- if isinstance(default, bool):
- return conf.getboolean('terminal', var)
- elif isinstance(default, int):
- return conf.getint('terminal', var)
- else:
- return conf.get('terminal', var)
- else:
- conf.set('terminal', var, default)
-
- return default
-
- def _configure_vt(self, vt):
- conf = ConfigParser.ConfigParser()
- conf_file = os.path.join(sugar.env.get_profile_path(), 'terminalrc')
-
- if os.path.isfile(conf_file):
- f = open(conf_file, 'r')
- conf.readfp(f)
- f.close()
- else:
- conf.add_section('terminal')
-
- font = self._get_conf(conf, 'font', 'Monospace')
- vt.set_font(pango.FontDescription(font))
-
- fg_color = self._get_conf(conf, 'fg_color', '#000000')
- bg_color = self._get_conf(conf, 'bg_color', '#FFFFFF')
- vt.set_colors(gtk.gdk.color_parse(fg_color), gtk.gdk.color_parse(bg_color), [])
-
- blink = self._get_conf(conf, 'cursor_blink', False)
- vt.set_cursor_blinks(blink)
-
- bell = self._get_conf(conf, 'bell', False)
- vt.set_audible_bell(bell)
-
- scrollback_lines = self._get_conf(conf, 'scrollback_lines', 1000)
- vt.set_scrollback_lines(scrollback_lines)
-
- vt.set_allow_bold(True)
-
- scroll_key = self._get_conf(conf, 'scroll_on_keystroke', True)
- vt.set_scroll_on_keystroke(scroll_key)
-
- scroll_output = self._get_conf(conf, 'scroll_on_output', False)
- vt.set_scroll_on_output(scroll_output)
-
- emulation = self._get_conf(conf, 'emulation', 'xterm')
- vt.set_emulation(emulation)
-
- visible_bell = self._get_conf(conf, 'visible_bell', False)
- vt.set_visible_bell(visible_bell)
-
- conf.write(open(conf_file, 'w'))
-
-
-
diff --git a/notebook.pyo b/notebook.pyo
deleted file mode 100644
index 02aa29f..0000000
--- a/notebook.pyo
+++ /dev/null
Binary files differ
diff --git a/notebook.py~ b/notebook.py~
deleted file mode 100644
index 6e68400..0000000
--- a/notebook.py~
+++ /dev/null
@@ -1,150 +0,0 @@
-# Copyright (C) 2007, Eduardo Silva (edsiper@gmail.com)
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-"""Notebook class
-
-This class create a gtk.Notebook() widget supporting
-a close button in every tab when the 'can-close-tabs' gproperty
-is enabled (True)
-
-STABLE.
-"""
-
-import gtk
-import gobject
-
-class Notebook(gtk.Notebook):
- __gtype_name__ = 'SugarNotebook'
-
- __gproperties__ = {
- 'can-close-tabs': (bool, None, None, False,
- gobject.PARAM_READWRITE |
- gobject.PARAM_CONSTRUCT_ONLY)
- }
-
- def __init__(self, **kwargs):
- # Initialise the Widget
- #
- # Side effects:
- # Set the 'can-close-tabs' property using **kwargs
- # Set True the scrollable notebook property
-
- gobject.GObject.__init__(self, **kwargs)
-
- self._can_close_tabs = None
-
- self.set_scrollable(True)
- self.show()
-
- def do_set_property(self, pspec, value):
- """
- Set notebook property
-
- Parameters
- ----------
- pspec :
- property for which the value will be set
-
- Returns
- -------
- None
-
- Raises
- ------
- AssertionError
-
- """
- if pspec.name == 'can-close-tabs':
- self._can_close_tabs = value
- else:
- raise AssertionError
-
- def _add_icon_to_button(self, button):
- icon_box = gtk.HBox()
- image = gtk.Image()
- image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
- gtk.Button.set_relief(button, gtk.RELIEF_NONE)
-
- settings = gtk.Widget.get_settings(button)
- w, h = gtk.icon_size_lookup_for_settings(settings, gtk.ICON_SIZE_MENU)
- gtk.Widget.set_size_request(button, w + 4, h + 4)
- image.show()
- icon_box.pack_start(image, True, False, 0)
- button.add(icon_box)
- icon_box.show()
-
- def _create_custom_tab(self, text, child):
- event_box = gtk.EventBox()
-
- tab_box = gtk.HBox(False, 2)
- self.tab_label = gtk.Label(text)
-
- tab_button = gtk.Button()
- tab_button.connect('clicked', self._close_page, child)
-
- # Add a picture on a button
- self._add_icon_to_button(tab_button)
-
- event_box.show()
- tab_button.show()
- self.tab_label.show()
-
- tab_box.pack_start(self.tab_label, True)
- tab_box.pack_start(tab_button, True)
-
- tab_box.show_all()
- event_box.add(tab_box)
-
- return event_box
-
- def add_page(self, text_label, widget):
- """
- Adds a page to the notebook.
-
- Parameters
- ----------
- text_label :
-
- widget :
-
- Returns
- -------
- #Boolean
- #Returns TRUE if the page is successfully added to th notebook.
-
- """
- # Add a new page to the notebook
- if self._can_close_tabs:
- eventbox = self._create_custom_tab(text_label, widget)
- self.append_page(widget, eventbox)
- else:
- self.append_page(widget, gtk.Label(text_label))
-
- pages = self.get_n_pages()
-
- # Set the new page
- self.set_current_page(pages - 1)
- self.show_all()
-
- return True
-
- def _close_page(self, button, child):
- # Remove a page from the notebook
- page = self.page_num(child)
-
- if page != -1:
- self.remove_page(page)
diff --git a/progresslistener.pyo b/progresslistener.pyo
deleted file mode 100644
index 70641ee..0000000
--- a/progresslistener.pyo
+++ /dev/null
Binary files differ
diff --git a/pydebug.pyo b/pydebug.pyo
deleted file mode 100644
index c95bb4b..0000000
--- a/pydebug.pyo
+++ /dev/null
Binary files differ
diff --git a/pydebug.py~ b/pydebug.py~
deleted file mode 100644
index afaa7ed..0000000
--- a/pydebug.py~
+++ /dev/null
@@ -1,1517 +0,0 @@
-# Copyright (C) 2009, George Hunt <georgejhunt@gmail.com>
-# Copyright (C) 2009, One Laptop Per Child
-#
-# 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
-from __future__ import with_statement
-import os, os.path, simplejson, ConfigParser, shutil, sys
-from subprocess import Popen
-
-from gettext import gettext as _
-
-#major packages
-import gtk
-import gtk.glade
-import vte
-import pango
-#import gconf
-#import glib
-import pickle
-import hashlib
-import time
-
-#sugar stuff
-from sugar.graphics.toolbutton import ToolButton
-import sugar.graphics.toolbutton
-
-import sugar.env
-from sugar.graphics.xocolor import XoColor
-from sugar.graphics.icon import Icon
-from sugar.graphics.objectchooser import ObjectChooser
-from sugar.datastore import datastore
-from sugar.graphics.alert import *
-import sugar.activity.bundlebuilder as bundlebuilder
-from sugar.bundle.activitybundle import ActivityBundle
-from sugar.activity import activityfactory
-#from jarabe.model import shell
-
-#application stuff
-from terminal_pd import Terminal
-#public api for ipython
-
-#from IPython.core import ipapi 0.11 requires this
-from IPython import ipapi
-
-#from sourceview import SourceViewPd
-import sourceview_editor
-from sugar.activity.activity import Activity
-from help_pd import Help
-
-#following taken from Rpyc module
-#import Rpyc
-from Rpyc.Utils.Serving import start_threaded_server, DEFAULT_PORT
-from Rpyc.Connection import *
-from Rpyc.Stream import *
-import select
-from filetree import FileTree
-from datastoretree import DataStoreTree
-import pytoolbar
-#from pytoolbar import ActivityToolBox
-
-import logging
-from pydebug_logging import _logger, log_environment
-
-MASKED_ENVIRONMENT = [
- 'DBUS_SESSION_BUS_ADDRESS',
- 'PPID'
-]
-#PANES = ['TERMINAL','EDITOR','CHILD','PROJECT','HELP']
-PANES = ['TERMINAL','EDITOR','PROJECT','HELP']
-
-#global module variable communicates to debugged programs
-pydebug_instance = None
-
-#following options taken from Develop_App
-class Options:
- def __init__(self, template = None, **kw):
- if template:
- self.__dict__ = template.__dict__.copy()
- else:
- self.__dict__ = {}
- self.__dict__.update(kw)
-
-class SearchOptions(Options):
- pass
-S_WHERE = sourceview_editor.S_WHERE
-
-class PyDebugActivity(Activity,Terminal):
- MIME_TYPE = 'application/vnd.olpc-sugar'
- DEPRECATED_MIME_TYPE = 'application/vnd.olpc-x-sugar'
- _zipped_extension = '.xo'
- _unzipped_extension = '.activity'
- dirty = False
-
- def __init__(self, handle):
- self.handle = handle
- _logger.debug('Activity id:%s.Object id: %s. uri:%s'%(handle.activity_id,
- handle.object_id, handle.uri))
- #Save a global poiinter so remote procedure calls can communicate with pydebug
- global pydebug_instance
- pydebug_instance = self
-
- #init variables
- self.make_paths()
-
- self.source_directory = None
- self.data_file = None
- self.help = None
- self.help_x11 = None
- self.project_dirty = False
- self.sock = None
- self.last_filename = None
- self.debug_dict = {}
- self.activity_dict = {}
- self.file_pane_is_activities = False
- self.manifest_treeview = None #set up to recognize an re-display of playpen
- self.set_title(_('PyDebug Activity'))
- self.ds = None #datastore pointer
- self._logger = _logger
- self.traceback = 'Context'
- self.abandon_changes = False
-
- # init the Classes we are subclassing
- Activity.__init__(self, handle, create_jobject = False)
- #Terminal has no needs for init
- #Help.__init__(self,self)
-
- # setup the search options
- self.s_opts = SearchOptions(where = S_WHERE.multifile,
- use_regex = False,
- ignore_caps = True,
- replace_all = False,
-
- #defaults to avoid creating
- #a new SearchOptions object for normal searches
- #should never be changed, just make a copy like:
- #SearchOptions(self.s_opts, forward=False)
- forward = True,
- stay = False
- )
- self.safe_to_replace = False
-
-
- #set up the PANES for the different functions of the debugger
- self.canvas_list = []
- self.panes = {}
- pane_index = 0
- pane_index = self.new_pane(self._get_terminal_canvas,pane_index)
- pane_index = self.new_pane(self._get_edit_canvas,pane_index)
- #pane_index = self.new_pane(self._get_child_canvas,pane_index)
- pane_index = self.new_pane(self._get_project_canvas,pane_index)
- pane_index = self.new_pane(self._get_help_canvas,pane_index)
-
- nb = gtk.Notebook()
- nb.show()
- nb.set_show_tabs(False)
-
- for c in self.canvas_list:
- nb.append_page(c)
-
- self.pydebug_notebook = nb
- #the following call to the activity code puts our notebook under the stock toolbar
- self.set_canvas(nb)
-
- #set up tool box/menu buttons
- self.toolbox = pytoolbar.ActivityToolbox(self)
- self.toolbox.connect('current_toolbar_changed',self._toolbar_changed_cb)
-
- activity_toolbar = self.toolbox.get_activity_toolbar()
- activity_toolbar.share.props.visible = True
- activity_toolbar.keep.props.visible = True
-
- separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- separator.show()
- activity_toolbar.insert(separator, 0)
-
- activity_go = ToolButton()
- activity_go.set_stock_id('gtk-media-forward')
- activity_go.set_icon_widget(None)
- activity_go.set_tooltip(_('Start Debugging'))
- activity_go.connect('clicked', self._read_file_cb)
- #activity_go.props.accelerator = '<Ctrl>O'
- activity_go.show()
- activity_toolbar.insert(activity_go, 0)
-
-
- activity_copy_tb = ToolButton('edit-copy')
- activity_copy_tb.set_tooltip(_('Copy'))
- activity_copy_tb.connect('clicked', self._copy_cb)
- #activity_copy_tb.props.accelerator = '<Ctrl>C'
- activity_toolbar.insert(activity_copy_tb, 3)
- activity_copy_tb.show()
-
- activity_paste_tb = ToolButton('edit-paste')
- activity_paste_tb.set_tooltip(_('Paste'))
- activity_paste_tb.connect('clicked', self._paste_cb)
- #activity_paste_tb.props.accelerator = '<Ctrl>V'
- activity_toolbar.insert(activity_paste_tb, 4)
- activity_paste_tb.show()
-
- activity_tab_tb = sugar.graphics.toolbutton.ToolButton('list-add')
- activity_tab_tb.set_tooltip(_("Open New Tab"))
- activity_tab_tb.props.accelerator = '<Ctrl>T'
- activity_tab_tb.show()
- activity_tab_tb.connect('clicked', self._open_tab_cb)
- activity_toolbar.insert(activity_tab_tb, 5)
-
- activity_tab_delete_tv = sugar.graphics.toolbutton.ToolButton('list-remove')
- activity_tab_delete_tv.set_tooltip(_("Close Tab"))
- activity_tab_delete_tv.props.accelerator = '<Ctrl><Shift>X'
- activity_tab_delete_tv.show()
- activity_tab_delete_tv.connect('clicked', self._close_tab_cb)
- activity_toolbar.insert(activity_tab_delete_tv, 6)
-
-
- activity_fullscreen_tb = sugar.graphics.toolbutton.ToolButton('view-fullscreen')
- activity_fullscreen_tb.set_tooltip(_("Fullscreen"))
- activity_fullscreen_tb.props.accelerator = '<Alt>Enter'
- activity_fullscreen_tb.connect('clicked', self._fullscreen_cb)
- activity_toolbar.insert(activity_fullscreen_tb, 7)
- activity_fullscreen_tb.hide()
-
- #Add editor functionality to the debugger
- editbar = gtk.Toolbar()
-
- editopen = ToolButton()
- editopen.set_stock_id('gtk-new')
- editopen.set_icon_widget(None)
- editopen.set_tooltip(_('New File'))
- editopen.connect('clicked', self._read_file_cb)
- #editopen.props.accelerator = '<Ctrl>O'
- editopen.show()
- editbar.insert(editopen, -1)
-
- editfile = ToolButton()
- editfile.set_stock_id('gtk-open')
- editfile.set_icon_widget(None)
- editfile.set_tooltip(_('Open File'))
- editfile.connect('clicked', self._read_file_cb)
- editfile.props.accelerator = '<Ctrl>O'
- editfile.show()
- editbar.insert(editfile, -1)
-
- editsave = ToolButton()
- editsave.set_stock_id('gtk-save')
- editsave.set_icon_widget(None)
- editsave.set_tooltip(_('Save File'))
- editsave.props.accelerator = '<Ctrl>S'
- editsave.connect('clicked', self.save_cb)
- editsave.show()
- editbar.insert(editsave, -1)
-
- editsaveas = ToolButton()
- editsaveas.set_stock_id('gtk-save-as')
- editsaveas.set_icon_widget(None)
- editsaveas.set_tooltip(_('Save As'))
- #editsaveas.props.accelerator = '<Ctrl>S'
- editsaveas.connect('clicked', self.save_file_cb)
- editsaveas.show()
- editbar.insert(editsaveas, -1)
-
-
- """
- editjournal = ToolButton(tooltip=_('Open Journal'))
- client = gconf.client_get_default()
- color = XoColor(client.get_string('/desktop/sugar/user/color'))
- journal_icon = Icon(icon_name='document-save', xo_color=color)
- editjournal.set_icon_widget(journal_icon)
- editjournal.connect('clicked', self._show_journal_object_picker_cb)
- editjournal.props.accelerator = '<Ctrl>J'
- editjournal.show()
- editbar.insert(editjournal, -1)
- """
-
- separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- separator.show()
- editbar.insert(separator, -1)
-
- editundo = ToolButton('undo')
- editundo.set_tooltip(_('Undo'))
- editundo.connect('clicked', self.editor.undo)
- editundo.props.accelerator = '<Ctrl>Z'
- editundo.show()
- editbar.insert(editundo, -1)
-
- editredo = ToolButton('redo')
- editredo.set_tooltip(_('Redo'))
- editredo.connect('clicked', self.editor.redo)
- editredo.props.accelerator = '<Ctrl>Y'
- editredo.show()
- editbar.insert(editredo, -1)
-
- separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- separator.show()
- editbar.insert(separator, -1)
-
- editcut = ToolButton()
- editcut.set_stock_id('gtk-cut')
- editcut.set_icon_widget(None)
- editcut.set_tooltip(_('Cut'))
- self.edit_cut_handler_id = editcut.connect('clicked', self.editor.cut)
- editcut.props.accelerator = '<Ctrl>X'
- editbar.insert(editcut, -1)
- editcut.show()
-
- editcopy = ToolButton('edit-copy')
- editcopy.set_tooltip(_('Copy'))
- self.edit_copy_handler_id = editcopy.connect('clicked', self.editor.copy)
- editcopy.props.accelerator = '<Ctrl>C'
- editbar.insert(editcopy, -1)
- editcopy.show()
-
- editpaste = ToolButton('edit-paste')
- editpaste.set_tooltip(_('Paste'))
- self.edit_paste_handler_id = editpaste.connect('clicked', self.editor.paste)
- editpaste.props.accelerator = '<Ctrl>V'
- editpaste.show()
- editbar.insert(editpaste, -1)
-
- separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- separator.show()
- editbar.insert(separator, -1)
-
- editfind = ToolButton('viewmag1')
- editfind.set_tooltip(_('Find and Replace'))
- editfind.connect('clicked', self.show_find)
- editfind.props.accelerator = '<Ctrl>F'
- editfind.show()
- editbar.insert(editfind, -1)
-
- separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- separator.show()
- editbar.insert(separator, -1)
-
- self.zoomout = ToolButton('zoom-out')
- self.zoomout.set_tooltip(_('Zoom out'))
- self.zoomout.connect('clicked', self.__zoomout_clicked_cb)
- editbar.insert(self.zoomout, -1)
- self.zoomout.show()
-
- self.zoomin = ToolButton('zoom-in')
- self.zoomin.set_tooltip(_('Zoom in'))
- self.zoomin.connect('clicked', self.__zoomin_clicked_cb)
- editbar.insert(self.zoomin, -1)
- self.zoomin.show()
-
- editbar.show_all()
- self.toolbox.add_toolbar(_('Edit'), editbar)
-
- #childbar = gtk.Toolbar()
- #childbar.show_all()
- #self.toolbox.add_toolbar(_('Your Program'), childbar)
-
- project_run = ToolButton()
- project_run.set_stock_id('gtk-media-forward')
- project_run.set_icon_widget(None)
- project_run.set_tooltip(_('Start Debugging'))
- project_run.connect('clicked', self.project_run_cb)
- #project_run.props.accelerator = '<Ctrl>C'
- project_run.show()
-
- projectbar = gtk.Toolbar()
- projectbar.show_all()
- projectbar.insert(project_run, -1)
- self.toolbox.add_toolbar(_('Project'), projectbar)
-
- self.help = Help(self)
- helpbar = self.help.get_help_toolbar()
- self.toolbox.add_toolbar(_('Help'), helpbar)
-
-
- self.set_toolbox(self.toolbox)
- self.toolbox.show()
-
- #set the default contents for edit
- self.font_size = self.debug_dict.get('font_size',8)
-
-
- self.get_config ()
-
- #set which PANE is visible initially
- self.set_visible_canvas(self.panes['PROJECT'])
- self.set_toolbar(self.panes['PROJECT'])
- self.non_blocking_server()
- #glib.idle_add(self.non_blocking_server)
- self.setup_project_page()
- _logger.debug('child path for program to be debugged is %r\nUser Id:%s'%(self.child_path,os.geteuid()))
-
- #create the terminal tabs, start up the socket between 1st and 2nd terminal instances
- self.setup_terminal()
-
-
- def __stop_clicked_cb(self,button):
- _logger('caught stop clicked call back')
- self.close(skip_save = True)
-
- def __zoomin_clicked_cb(self,button):
- self.font_size += 1
- self.editor.change_font_size(self.font_size)
- self.debug_dict['font_size'] = self.font_size
-
- def __zoomout_clicked_cb(self,botton):
- self.font_size -= 1
- self.editor.change_font_size(self.font_size)
- self.debug_dict['font_size'] = self.font_size
-
- #this code will probably be deleted
- def non_blocking_server(self):
- start_threaded_server()
- """
- if self.sock == None:
- self.sock = create_listener_socket(DEFAULT_PORT)
- self.sock.setblocking(0)
- rlist, wlist, slist = select.select([self.sock],[],[],0)
- try:
- if bool(rlist):
- self.conn = Connection(self.sock)
- self.conn.poll()
- self.conn.close()
- except:
- pass
- return True #continue the call backs
- """
-
- def new_pane(self,funct,i):
- self.panes[PANES[i]] = i
- self.canvas_list.append(funct())
- i += 1
- return i
- """
- def _get_debug_page(self):
- n = self.pydebug_notebook.get_current_page()
- return self.pydebug_notebook.get_nth_page(n)
- """
-
- def make_paths(self):
- self.pydebug_path = os.environ['SUGAR_BUNDLE_PATH']
- p_path = os.environ['SUGAR_BUNDLE_PATH']
- if not os.environ.get("PYTHONPATH",'') == '':
- p_path = p_path + ':'
- os.environ['PYTHONPATH'] = p_path + os.environ.get("PYTHONPATH",'')
- _logger.debug('sugar_bundle_path:%s\nsugar_activity_root:%s'%(os.environ['SUGAR_BUNDLE_PATH'],
- os.environ['SUGAR_ACTIVITY_ROOT']))
- self.debugger_home = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],'data')
-
- os.environ["HOME"]=self.debugger_home
- os.environ['PATH'] = os.path.join(self.pydebug_path,'bin:') + os.environ['PATH']
- self.storage = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],'data/pydebug')
- self.sugar_bundle_path = os.environ['SUGAR_BUNDLE_PATH']
- self.activity_playpen = os.path.join(self.storage,'playpen')
- if not os.path.isdir(self.activity_playpen):
- os.makedirs(self.activity_playpen)
- """
- loaded_list = os.listdir(self.activity_playpen)
- basename = []
- for f in loaded_list:
- if f.startswith('.'):continue
- if not f.endswith('.activity'):continue
- basename.append(f) #if more than one pick the last
- #when activity is loaded, child_path endswith '.activity' and is sub-dir of playpen
- if basename != '':
- self.child_path = os.path.join(self.activity_playpen,basename)
- else:
- self.child_path = None
- #os.chdir(self.activity_playpen)
- """
-
- def _get_edit_canvas(self):
- self.editor = sourceview_editor.GtkSourceview2Editor(self)
- return self.editor
-
- def setup_terminal(self):
- os.environ['IPYTHONDIR'] = self.pydebug_path
- _logger.debug('Set IPYTHONDIR to %s'%self.pydebug_path)
- self._create_tab({'cwd':self.sugar_bundle_path})
- self._create_tab({'cwd':self.sugar_bundle_path})
- #start the debugger user interface
- alias_cmd = 'alias go="%s"\n'%('./bin/ipython.py',)
- self.feed_virtual_terminal(0,alias_cmd)
-
- self.feed_virtual_terminal(0,'./bin/ipython.py \n')
- #cmd = 'run ' + os.path.join(self.sugar_bundle_path,'bin','start_debug.py') + '\n'
- #self.feed_virtual_terminal(0,cmd)
-
-
- def start_debugging(self): #check for a start up script in bundle root or bundle_root/bin
- command = self.activity_dict.get('command','')
- if command == '':
- self.alert('No Activity Loaded')
- return
- _logger.debug("Command to execute:%s."%command)
- self.editor.save_all()
-
- #try to restore a clean debugging environment
- #self.feed_virtual_terminal(0,'quit()\r\n\r\n')
-
- self.set_visible_canvas(self.panes['TERMINAL'])
- #change the menus
- self.toolbox.set_current_toolbar(self.panes['TERMINAL'])
- message = _('\n\n Use the HELP in the Ipython interpreter to learn to DEBUG your program.\n')
- self.message_terminal(0,message)
-
- #get the ipython shell object
- """ this works but is not needed now
- ip = ipapi.get()
- arg_str = 'run -d -b %s %s'%(self.pydebug_path,self.child_path)
- ip.user_ns['go'] = arg_str
- _logger.debug('about to use "%s" to start ipython debugger\n'%(arg_str))
- """
- self.feed_virtual_terminal(0,'go\n')
-
- def find_import(self,fn):
- _logger.debug('find_import in file %s'%fn)
- try_fn = os.path.join(self.child_path,fn)
- if not os.path.isfile(try_fn):
- try_fn += '.py'
- if not os.path.isfile(try_fn):
- _logger.debug('in find_import, failed to find file %s'%try_fn)
- return
- line_no = 0
- for line in open(try_fn,'r'):
- if line.startswith('import'):
- return line_no, try_fn
- line_no += 1
- return -1, None
-
- def _get_child_canvas(self):
- fr = gtk.Frame()
- label = gtk.Label("This page will be replaced with the \noutput from your program")
- label.show()
- fr.add(label)
- fr.show()
- return fr
-
-
- def _get_help_canvas(self):
- fr = gtk.Frame()
- label = gtk.Label(_("Loading Help Page"))
- label.show()
- fr.add(label)
- fr.show()
- return fr
-
- def get_icon_pixbuf(self, stock):
- return self.treeview.render_icon(stock_id=getattr(gtk, stock),
- size=gtk.ICON_SIZE_MENU,
- detail=None)
-
-
- """
- def _get_help_canvas(self):
- fr = gtk.Frame() #FIXME explore whether frame is still needed--was to fix webview problem
- fr.show()
- nb = gtk.Notebook()
- nb.show()
- fr.add(nb)
- nb.append_page(self.get_first_webview())
- self.help_notebook = nb
- return fr
- """
-
- def _child_cb(self,event):
- pass
-
- def _project_cb(self,event):
- pass
-
- #lots of state to change whenever one of the major tabs is clicked
- def set_visible_canvas(self,index): #track the toolbox tab clicks
- self.pydebug_notebook.set_current_page(index)
- if index == self.panes['TERMINAL']:
- self.set_terminal_focus()
- self.editor.save_all()
- elif index == self.panes['HELP']:
- self.help_selected()
- self.current_pd_page = index
-
- def _toolbar_changed_cb(self,widget,tab_no):
- _logger.debug('tool tab changed notification %d'%tab_no)
- self.set_visible_canvas(tab_no)
-
- def set_toolbar(self,page_no):
- self.toolbox.set_current_toolbar(page_no)
-
- def key_press_cb(self,widget,event):
- state = event.get_state()
- if state and gtk.gdk.SHIFT_MASK and gtk.gdk.CONTROL_MASK and gtk.gdk.MOD1_MASK == 0:
- self.file_changed = True
- #put a star in front of the filename
- return False
-
- ### following routines are copied from develop_app for use with sourceview_editor
- def _replace_cb(self, button=None):
- ftext = self._search_entry.props.text
- rtext = self._replace_entry.props.text
- _logger.debug('replace %s with %s usiing options %r'%(ftext,rtext,self.s_opts))
- replaced, found = self.editor.replace(ftext, rtext,
- self.s_opts)
- if found:
- self._replace_button.set_sensitive(True)
-
- def _search_entry_activated_cb(self, entry):
- text = self._search_entry.props.text
- if text:
- self._findnext_cb(None)
-
- def _search_entry_changed_cb(self, entry):
- self.safe_to_replace = False
- text = self._search_entry.props.text
- if not text:
- self._findprev.set_sensitive(False)
- self._findnext.set_sensitive(False)
- else:
- self._findprev.set_sensitive(True)
- self._findnext.set_sensitive(True)
- if not self.s_opts.use_regex: #do not do partial searches for regex
- if self.editor.find_next(text,
- SearchOptions(self.s_opts,
- stay=True,
- where=(self.s_opts.where if
- self.s_opts.where != S_WHERE.multifile
- else S_WHERE.file))):
- #no multifile, or focus gets grabbed
- self._replace_button.set_sensitive(True)
-
- def _replace_entry_changed_cb(self, entry):
- if self._replace_entry.props.text:
- self.safe_to_replace = True
-
- def _findprev_cb(self, button=None):
- ftext = self._search_entry.props.text
- if ftext:
- if self.editor.find_next(ftext,
- SearchOptions(self.s_opts,
- forward=False)):
- self._replace_button.set_sensitive(True)
-
- def _findnext_cb(self, button=None):
- ftext = self._search_entry.props.text
- _logger.debug('find next %s'%ftext)
- if ftext:
- if self.editor.find_next(ftext, self.s_opts):
- self._replace_button.set_sensitive(True)
- self.editor.set_focus()
-
-
- def show_find(self,button):
- self.find_window = self.wTree.get_widget("find")
- self.find_window.show()
- self.find_window.connect('destroy',self.close_find_window)
- self.find_connect()
- self.find_window.set_title(_('FIND OR REPLACE'))
- self.find_window.set_size_request(400, 200)
- self.find_window.set_decorated(True)
- self.find_window.set_resizable(True)
- self.find_window.set_modal(False)
- #self.find_window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
- self.find_window.set_border_width(10)
-
-
- def find_connect(self):
- mdict = {
- 'find_close_clicked_cb':self.close_find_window,
- 'find_entry_changed_cb':self.find_entry_changed_cb,
- 'replace_entry_changed_cb':self.replace_entry_changed_cb,
- 'find_previous_clicked_cb':self._findprev_cb,
- 'find_next_clicked_cb':self._findnext_cb,
- 'find_entry_changed_cb':self._search_entry_changed_cb,
- 'replace_entry_changed_cb':self._replace_entry_changed_cb,
- 'replace_clicked_cb':self._replace_cb,
- #'replace_all_clicked_cb':self._findprev_cb,
- }
- self.wTree.signal_autoconnect(mdict)
- self._findnext = self.wTree.get_widget("find_next")
- self._findprev = self.wTree.get_widget("find_previous")
- self._search_entry = self.wTree.get_widget("find_entry")
- self._replace_entry = self.wTree.get_widget("replace_entry")
- self._replace_button = self.wTree.get_widget("replace")
- #self.replace_all = self.wTree.get_widget("replace_all")
- self.find_where = self.wTree.get_widget("find_where")
-
-
- def close_find_window(self,button):
- self.find_window.hide()
-
- def delete_event(self,widget,event):
- if widget == self.find_window:
- self.find_window.hide()
- return True
-
- def find_entry_changed_cb(self,button):
- #self.editor.search_for =
- pass
- def replace_entry_changed_cb(self,button):
- #self.editor.search_for =
- pass
-
- def project_run_cb(self,button):
- _logger.debug('entered project_run_cb')
- """
- start_script = ['python','import sys','from Rpyc import *','from Rpyc.Utils import remote_interpreter',
- 'c = SocketConnection("localhost")','remote_interpreter(c)']
- for l in start_script:
- self.feed_virtual_terminal(0,l+'\r\n')
- """
- self.start_debugging()
-
-
-
-
- ###### SUGAR defined read and write routines -- do not let them overwrite what's on disk
-
- def read_file(self, file_path):
- interesting_keys = ['mtime','mime_type','package','checksum','title','timestamp','icon-color','uid']
- for key in interesting_keys:
- if self.metadata.has_key(key):
- self.activity_dict[key] = self.metadata[key]
- _logger.debug('RELOADING ACTIVITY DATA...Mime_type:%s. File_path:%s.'%(self.metadata['mime_type'],
- file_path))
- debugstr = ''
- for key in self.activity_dict.keys():
- debugstr += key + ':'+str(self.activity_dict[key]) + ', '
- _logger.debug ('In read_file: activity dictionary==> %s'%debugstr)
- return
-
- def write_file(self, file_path):
- """
- The paradigm designed into the XO, ie an automatic load from the Journal at activity startup
- does not make sense during a debugging session. An errant stack overflow can easily crash
- the system and require a reboot. For the session manager to overwrite the changes that are stored
- on disk, but not yet saved in the journal is highly undesireable. So we'll let the user save to
- the journal, and perhaps optionally to the sd card (because it is removable, should the system die)
- """
- _logger.debug('write file object_id: %s'%self.debug_dict['jobject_id'])
- self._jobject.metadata['title'] = 'PyDebug'
- datastore.write(self._jobject)
- self.write_activity_info()
- self.put_config()
- return
-
- def write_binary_to_datastore(self):
- """
- Check to see if there is a child loaded.
- Then copy the home directory data for this application into the bundle
- then bundle it up and write it to the journal
- lastly serialize the project information and write it to the journal
- """
- _logger.debug('Entered write_binary_to_datastore with child_path:%s'%self.child_path)
- if not (os.path.isdir(self.child_path) and self.child_path.split('.')[-1:][0] == 'activity'):
- self.alert(_('No Program loaded'))
- return
- dsobject = datastore.create()
- dsobject.metadata['mime_type'] = 'binary'
-
- #copy the home directory config stuff into the bundle
- home_dir = os.path.join(self.child_path,'HOME')
- try:
- os.rmtree(home_dir)
- except:
- pass
- try:
- os.mkdir(home_dir)
- except:
- pass
- source = self.debugger_home
- dest = os.path.join(self.child_path,'HOME')
- _logger.debug('writing HOME info from %s to %s.'%(source,dest))
- for f in os.listdir(self.debugger_home):
- if f == '.': continue
- if f == '..': continue
- if f == 'pydebug': continue
- if f == '.sugar': continue
- try:
- if os.path.isdir(f):
- shutil.copytree(f,dest)
- else:
- shutil.copy(f,dest)
- except:
- pass
-
- #create the manifest for the bundle
- try:
- os.remove(os.path.join(self.child_path,'MANIFEST'))
- except:
- pass
- dest = self.child_path
- _logger.debug('Writing manifest to %s.'%(dest))
- config = bundlebuilder.Config(dest)
- b = bundlebuilder.Builder(config)
- try:
- b.fix_manifest()
- except:
- _logger.debug('fix manifest error: ',sys.exc_type,sys.exc_info[0],sys.exc_info[1])
-
- #actually write the xo file
- packager = bundlebuilder.XOPackager(bundlebuilder.Builder(config))
- packager.package()
- source = os.path.join(self.child_path,'dist',str(config.xo_name))
- dest = os.path.join(self.get_activity_root(),'instance',str(config.xo_name))
- _logger.debug('writing to the journal from %s to %s.'%(source,dest))
- try:
- shutil.copy(source,dest)
- except IOError:
- _logger.debug('shutil.copy error %d: %s. ',IOError[0],IOError[1])
- #try:
- dsobject.metadata['package'] = config.xo_name
- dsobject.metadata['title'] = config.xo_name #_('PyDebug Zipped app')
- dsobject.metadata['mime_type'] = 'binary'
- dsobject.metadata['activity'] = 'org.laptop.PyDebug'
- dsobject.metadata['icon'] = self.debug_dict.get('icon','')
- #calculate and store the new md5sum
- self.debug_dict['tree_md5'] = self.md5sum_tree(self.child_path)
- dsobject.metadata['tree_md5'] = self.debug_dict['tree_md5']
- dsobject.set_file_path(dest)
-
- #actually make the call which writes to the journal
- datastore.write(dsobject,transfer_ownership=True)
- _logger.debug('succesfully wrote to the journal from %s.'%(dest))
- #update the project display
- self.journal_class = DataStoreTree(self,self.journal_treeview,self.wTree)
-
- def load_activity_to_playpen(self,file_path):
- """loads from a disk tree"""
- self._new_child_path = os.path.join(self.activity_playpen,os.path.basename(file_path))
- _logger.debug('copying file for %s to %s'%(file_path,self._new_child_path))
- self._load_playpen(file_path)
-
- def try_to_load_from_journal(self,object_id):
- """
- loads a zipped XO application file, asks whether it is ok to
- delete/overwrite path if the md5 has changed.
- """
- self.ds = datastore.get(object_id[0])
- if not self.ds:
- _logger.debug('failed to get datastore object with id:%s'%object_id[0])
- return
- dsdict=self.ds.get_metadata()
- file_name_from_ds = self.ds.get_file_path()
- project = dsdict.get('package','')
- if not project.endswith('.xo'):
- self.alert(_('This journal item does not appear to be a zipped activity. Package:%s.'%project))
- self.ds.destroy()
- self.ds = None
- return
- filestat = os.stat(file_name_from_ds)
- size = filestat.st_size
-
- _logger.debug('In try_to_load_from_journal. Object_id %s. File_path %s. Size:%s'%(object_id[0], file_name_from_ds, size))
- try:
- self._bundler = ActivityBundle(file_name_from_ds)
- except:
- self.alert('Error: Malformed Activity Bundle')
- self.ds.destroy()
- self.ds = None
- return
- self._new_child_path = os.path.join(self.activity_playpen,self._bundler.get_name()+'.activity')
- self._load_playpen(file_name_from_ds, iszip=True)
-
- def _load_playpen(self,source_fn, iszip = False):
- """entry point for both xo and file tree sources"""
- self.iszip = iszip
- self._load_to_playpen_source = source_fn
- if self.child_path and os.path.isdir(self.child_path):
- #check to see if it has been modified
- stored_hash = self.debug_dict.get('tree_md5','')
- if stored_hash != '' and stored_hash != self.md5sum_tree(self.child_path):
- self.confirmation_alert(_('The currently loaded %s project in the playpen has been changed.'%os.path.basename(self.child_path)),_('Ok to abandon changes?'),self._clear_playpen_cb)
- return
- self._clear_playpen_cb(None,None)
-
- def _clear_playpen_cb(self,alert, response):
- #if necessary clean up contents of playpen
- if alert != None: self.remove_alert(alert)
- if self.child_path and os.path.isdir(self.child_path):
- self.abandon_changes = True
- self.debug_dict['tree_md5'] = ''
- self.debug_dict['child_path'] = ''
- self.editor.remove_all()
- if self.child_path:
- shutil.rmtree(self.child_path)
- self.abandon_changes = False
- if self._load_to_playpen_source == None:
- #having done the clearing, just stop
- return
- if self.iszip:
- self._bundler.install(self.activity_playpen)
- if self.ds: self.ds.destroy()
- self.ds = None
- else:
- if os.path.isdir(self._new_child_path):
- shutil.rmtree(self._new_child_path)
- shutil.copytree(self._load_to_playpen_source,self._new_child_path)
- self.debug_dict['source_tree'] = self._load_to_playpen_source
- self.child_path = self._new_child_path
- self.setup_new_activity()
-
- def setup_new_activity(self):
- if self.child_path == None:
- return
- _logger.debug('child path before chdir:%s'%self.child_path)
- os.chdir(self.child_path)
- self.read_activity_info(self.child_path)
- self.display_current_project()
-
- #add the bin directory to path
- os.environ['PATH'] = os.path.join(self.child_path,'bin') + ':' + os.environ['PATH']
-
- #calculate and store the md5sum
- self.debug_dict['tree_md5'] = self.md5sum_tree(self.child_path)
-
- #find largest python files for editor
- list = [f for f in os.listdir(self.child_path) if f[0] <> '.']
- #list = self.manifest_class.get_filenames_list(self.child_path)
- if not list: return
- sizes = []
- for f in list:
- full_path = os.path.join(self.child_path,f)
- if not f.endswith('.py'):continue
- size = self.manifest_class.file_size(full_path)
- sizes.append((size,full_path,))
- #_logger.debug('python file "%s size %d'%(f,size))
- for s,f in sorted(sizes,reverse=True)[:5]:
- self.editor.load_object(f,os.path.basename(f))
- self.editor.set_current_page(0)
-
- ##################### ALERT ROUTINES ##################################
-
- def alert(self,msg,title=None):
- alert = NotifyAlert(10)
- if title != None:
- alert.props.title=_('There is no Activity file')
- alert.props.msg = msg
- alert.connect('response',self.no_file_cb)
- self.add_alert(alert)
-
- def no_file_cb(self,alert,response_id):
- self.remove_alert(alert)
-
- from sugar.graphics.alert import ConfirmationAlert
-
- def confirmation_alert(self,msg,title=None,confirmation_cb = None):
- alert = ConfirmationAlert()
- alert.props.title=title
- alert.props.msg = msg
- alert.pydebug_cb = confirmation_cb
- alert.connect('response', self._alert_response_cb)
- self.add_alert(alert)
-
- #### Method: _alert_response_cb, called when an alert object throws a
- #response event.
- def _alert_response_cb(self, alert, response_id):
- #remove the alert from the screen, since either a response button
- #was clicked or there was a timeout
- this_alert = alert #keep a reference to it
- self.remove_alert(alert)
- #Do any work that is specific to the type of button clicked.
- if response_id is gtk.RESPONSE_OK and this_alert.pydebug_cb != None:
- this_alert.pydebug_cb (this_alert, response_id)
-
-
- def _read_file_cb(self,widget):
- _logger.debug('Reading a file into editor')
- dialog = gtk.FileChooserDialog("Open..",
- None,
- gtk.FILE_CHOOSER_ACTION_OPEN,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OPEN, gtk.RESPONSE_OK))
- dialog.set_default_response(gtk.RESPONSE_OK)
- if self.last_filename == None:
- self.last_filename = self.child_path
- dialog.set_current_folder(os.path.dirname(self.last_filename))
-
- filter = gtk.FileFilter()
- filter.set_name("All files")
- filter.add_pattern("*")
- dialog.add_filter(filter)
-
- filter = gtk.FileFilter()
- filter.set_name("Python")
- filter.add_pattern("*.py")
- dialog.add_filter(filter)
-
- filter = gtk.FileFilter()
- filter.set_name("Activity")
- filter.add_pattern("*.xo")
- dialog.add_filter(filter)
-
- response = dialog.run()
- if response == gtk.RESPONSE_OK:
- _logger.debug(dialog.get_filename(), 'selected')
- fname = dialog.get_filename()
- self.last_filename = fname
- self.editor.load_object(fname,os.path.basename(fname))
- elif response == gtk.RESPONSE_CANCEL:
- _logger.debug( 'File chooseer closed, no files selected')
- dialog.destroy()
-
- def save_file_cb(self, button):
- chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_SAVE,
- buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,
- gtk.RESPONSE_OK))
- file_path = self.editor.get_full_path()
- _logger.debug('Saving file %s'%(file_path))
- chooser.set_filename(file_path)
- response = chooser.run()
- new_fn = chooser.get_filename()
- chooser.destroy()
- if response == gtk.RESPONSE_CANCEL:
- return
- if response == gtk.RESPONSE_OK:
- self.save_cb(None,new_fn)
-
- def save_cb(self,button,new_fn=None):
- if new_fn and not new_fn.startswith(self.child_root):
- self.alert(_('You can only write %s to subdirectories of %s'%(os.path.basename(new_fn),
- self.child_root,)))
- return
- page = self.editor._get_page()
- if new_fn:
- page.fullPath = new_fn
- page.save(skip_md5 = True)
- else:
- page.save()
- self.editor.clear_changed_star()
- page.save_hash()
-
- def set_dirty(self, dirty):
- self.dirty = dirty
-
- def md5sum_buffer(self, buffer, hash = None):
- if hash == None:
- hash = hashlib.md5()
- hash.update(buffer)
- return hash.hexdigest()
-
- def md5sum(self, filename, hash = None):
- h = self._md5sum(filename,hash)
- return h.hexdigest()
-
- def _md5sum(self, filename, hash = None):
- if hash == None:
- hash = hashlib.md5()
- try:
- fd = None
- fd = open(filename, 'rb')
- while True:
- block = fd.read(128)
- if not block: break
- hash.update(block)
- finally:
- if fd != None:
- fd.close()
- return hash
-
- def md5sum_tree(self,root):
- if not os.path.isdir(root):
- return None
- h = hashlib.md5()
- for dirpath, dirnames, filenames in os.walk(root):
- for filename in filenames:
- abs_path = os.path.join(dirpath, filename)
- h = self._md5sum(abs_path,h)
- #print abs_path
- return h.hexdigest()
-
-
-
- ############## Following code services the Project page #####################
-
- def _get_project_canvas(self):
- #initialize the link between program and the glade XML file
- self.wTree=gtk.glade.XML(os.path.join(self.sugar_bundle_path,"project.glade"))
- self.contents = self.wTree.get_widget("contents")
- self.contents.unparent()
- return self.contents
-
- def setup_project_page(self):
- self.activity_treeview = self.wTree.get_widget('file_system')
- self.activity_window = FileTree(self, self.activity_treeview,self.wTree)
- self.activity_window.set_file_sys_root('/home/olpc/Activities')
- self.examples_treeview = self.wTree.get_widget('examples')
- self.examples_window = FileTree(self, self.examples_treeview,self.wTree)
- self.examples_window.set_file_sys_root(os.path.join(self.sugar_bundle_path,'examples'))
- self.journal_treeview = self.wTree.get_widget('journal')
- self.journal_class = DataStoreTree(self,self.journal_treeview,self.wTree)
- self.connect_object() #make connections to signals from buttons
- self.activity_toggled_cb(None)
- if self.child_path and self.child_path.endswith('.activity') and \
- os.path.isdir(self.child_path):
- self.setup_new_activity()
-
- def display_current_project(self):
- self.manifest_treeview = self.wTree.get_widget('manifest')
- self.manifest_class = FileTree(self, self.manifest_treeview,self.wTree)
- if self.child_path:
- self.manifest_class.set_file_sys_root(self.child_path)
- else:
- self.manifest_class.set_file_sys_root(self.activity_playpen)
-
- self.wTree.get_widget('name').set_text(self.activity_dict.get('name',''))
- self.wTree.get_widget('version').set_text(self.activity_dict.get('version',''))
- self.wTree.get_widget('bundle_id').set_text(self.activity_dict.get('bundle_id',''))
- self.wTree.get_widget('class').set_text(self.activity_dict.get('class',''))
- self.wTree.get_widget('module').set_text(self.activity_dict.get('module',''))
- """
- self.wTree.get_widget('home_save').set_text(self.activity_dict.get('home_save',''))
- self.wTree.get_widget('host').set_text(self.debug_dict.get('host',''))
- self.wTree.get_widget('port').set_text(str(self.debug_dict.get('port','')))
- activity_size = os.system('du --max-depth=0')
- self.wTree.get_widget('activity_size').set_text(str(activity_size))
- self.wTree.get_widget('icon').set_text(self.activity_dict.get('icon','').split('/')[-1:][0])
- """
-
- def manifest_point_to(self,fullpath):
- if self.child_path:
- self.manifest_class.set_file_sys_root(self.child_path)
- else:
- self.manifest_class.set_file_sys_root(self.activity_playpen)
- self.manifest_class.position_to(fullpath)
-
- #first connect the glade xml file to the servicing call backs
- def connect_object(self, wTree=None):
- """if wTree:
- self.wTree=wTree
- if self.wTree:"""
- mdict = {
- 'name_changed_cb':self.name_changed_cb,
- 'bundle_id_changed_cb':self.bundle_id_changed_cb,
- 'class_changed_cb':self.class_changed_cb,
- 'icon_changed_cb':self.icon_changed_cb,
- 'version_changed_cb':self.version_changed_cb,
- 'file_toggle_clicked_cb':self.activity_toggled_cb,
- 'to_activities_clicked_cb':self.to_home_clicked_cb,
- 'from_activities_clicked_cb':self.from_home_clicked_cb,
- 'from_examples_clicked_cb':self.from_examples_clicked_cb,
- 'run_clicked_cb':self.project_run_cb,
- 'delete_file_clicked_cb':self.delete_file_cb,
- }
- self.wTree.signal_autoconnect(mdict)
- button = self.wTree.get_widget('file_toggle')
- button.set_tooltip_text(_('Switch views between the "Installed" Activities directory and your "home" storage directory'))
- button = self.wTree.get_widget('to_activities')
- button.set_tooltip_text(_('Copy the files in the debug workplace to your "home" storage directory'))
- button = self.wTree.get_widget('from_examples')
- button.set_tooltip_text(_('Load and modify these example programs. See the help Tutorials'))
-
-
- def name_changed_cb(self, widget):
- self.activity_dict['name'] = widget.get_text()
-
- def bundle_id_changed_cb(self,widget):
- self.activity_dict['bundle_id'] = widget.get_text()
-
- def class_changed_cb(self, widget):
- self.activity_dict['class'] = widget.get_text()
-
- def icon_changed_cb(self, widget):
- self.activity_dict['icon'] = widget.get_text()
-
- def version_changed_cb(self, widget):
- self.activity_dict['version'] = widget.get_text()
-
- def activity_toggled_cb(self, widget):
- _logger.debug('Entered activity_toggled_cb. Button: %r'%self.file_pane_is_activities)
- but = self.wTree.get_widget('to_activities')
- to_what = self.wTree.get_widget('file_toggle')
- window_label = self.wTree.get_widget('file_system_label')
- if self.file_pane_is_activities == True:
- to_what.set_label('Installed')
- but.show()
- display_label = self.storage[:18]+' . . . '+self.storage[-24:]
- self.activity_window.set_file_sys_root(self.storage)
- button = self.wTree.get_widget('from_activities')
- button.set_tooltip_text(_('Copy the selected directory from your "home" storage to the debug workplace'))
- window_label.set_text(display_label)
- else:
- to_what.set_label('home')
- but.hide()
- self.activity_window.set_file_sys_root('/home/olpc/Activities')
- button = self.wTree.get_widget('from_activities')
- button.set_tooltip_text(_('Copy the selected Activity to the debug workplace and start debugging'))
- window_label.set_text('/home/olpc/Activities')
- self.file_pane_is_activities = not self.file_pane_is_activities
-
- def to_home_clicked_cb(self,widget):
- _logger.debug('Entered to_home_clicked_cb')
- self._to_home_dest = os.path.join(self.storage,self.activity_dict['name']+'.activity')
- if os.path.isdir(self._to_home_dest):
- target_md5sum = self.md5sum_tree(self._to_home_dest)
- if target_md5sum != self.debug_dict.get('tree_md5',''):
- self.confirmation_alert(_('OK to delete/overwrite %s?'%self._to_home_dest),
- _('This destination has been changed by another application'),
- self._to_home_cb)
- return
- self._to_home_cb( None, gtk.RESPONSE_OK)
-
- def _to_home_cb(self, alert, response_id):
- if alert != None: self.remove_alert(alert)
- if response_id is gtk.RESPONSE_OK:
- cmd = ['rsync','-av',self.child_path,self._to_home_dest]
- _logger.debug('do to_home_cb with cmd:%s'%cmd)
- p1 = Popen(cmd,stdout=PIPE)
- output = p1.communicate()
- if p1.returncode != 0:
- self.alert('rsync command returned non zero\n'+output[0]+ 'COPY FAILURE')
- return
- #redraw the treeview
- self.activity_window.set_file_sys_root(self.storage)
-
- def from_home_clicked_cb(self,widget):
- _logger.debug('Entered from_home_clicked_cb')
- selection=self.activity_treeview.get_selection()
- (model,iter)=selection.get_selected()
- if iter == None:
- self.alert(_('Must select File or Directory item to Load'))
- return
- fullpath = model.get(iter,4)[0]
- if os.path.isdir(fullpath):
- if not fullpath.endswith('.activity'):
- self.alert(_('Use this button for Activities or Files'),
- _('ERROR: This folder name does not end with ".activity"'))
- return
- self.load_activity_to_playpen(fullpath)
- else:
- #selected is a file, just copy it into the current project
- basename = os.path.basename(fullpath)
- if os.path.isfile(os.path.join(self.child_path,basename)):
- #change name if necessary to prevent collision
- basename = self.non_conflicting(self.child_path,basename)
- shutil.copy(fullpath,os.path.join(self.child_path,basename))
- self.manifest_point_to(os.path.join(self.child_path,basename))
-
- def non_conflicting(self,root,basename):
- """
- create a non-conflicting filename by adding '-<number>' to a filename before extension
- """
- ext = ''
- basename = basename.split('.')
- word = basename[0]
- if len(basename) > 1:
- ext = basename[1]
- adder = ''
- index = 0
- while os.path.isfile(os.path.join(root,word+adder+'.'+ext)):
- index +=1
- adder = '-%s'%index
- return os.path.join(root,word+adder+'.'+ext)
-
- def from_examples_clicked_cb(self,widget):
- _logger.debug('Entered from_examples_clicked_cb')
- selection=self.examples_treeview.get_selection()
- (model,iter)=selection.get_selected()
- if iter == None:
- self.alert(_('Must select File or Directory item to Load'))
- return
- fullpath = model.get(iter,4)[0]
- if fullpath.endswith('.activity'):
- self.load_activity_to_playpen(fullpath)
- return
- self._load_to_playpen_source = fullpath
- try:
- self._bundler = ActivityBundle(fullpath)
- except:
- self.alert('Error: Malformed Activity Bundle')
- return
-
- self._new_child_path = os.path.join(self.activity_playpen,self._bundler._zip_root_dir)
- #check to see if current activity in playpen needs to be saved, and load new activity if save is ok
- self._load_playpen(fullpath, iszip=True)
-
- def filetree_activated(self):
- _logger.debug('entered pydebug filetree_activated')
-
- def read_activity_info(self, path):
- """
- Parses the ./activity/activity.info file
-
- filen = os.path.join(self.child_path,'activity','activity.info')
- try:
- fd = open(filen,'r')
- except:
- _logger.debug('failed to open %s'%filen)
- return
- for line in fd.readlines():
- if line.lstrip() == '': continue
- _logger.debug('activity line %s'%line)
- tokens = line.split('=')
-
- if len(tokens) > 1:
- keyword = tokens[0].lower().rstrip()
- rside = tokens[1].split()
- if keyword == 'class':
- if '.' in rside[0]:
- self.activity_dict['class'] = rside[0].split('.')[1]
- self.activity_dict['module'] = rside[0].split('.')[0]
- elif keyword == 'exec':
- if rside[0] == 'sugar-activity' and '.' in rside[1]:
- self.activity_dict['class'] = rside[1].split('.')[1]
- self.activity_dict['module'] = rside[1].split('.')[0]
- else:
- self.activity_dict['module'] = rside[0]
- elif keyword == 'bundle_id' or keyword == 'service_name':
- self.activity_dict['bundle_id'] = rside[0]
- elif keyword == 'activity_version':
- self.activity_dict['version'] = rside[0]
- elif keyword == 'name':
- self.activity_dict['name'] = rside[0]
- elif keyword == 'icon':
- self.activity_dict['icon'] = rside[0]
- fd.close()
-
- debugstr = ''
- for key in self.activity_dict.keys():
- debugstr += key + ':'+str(self.activity_dict[key]) + ', '
- _logger.debug ('In read_activity: activity dictionary==> %s'%debugstr)
- """
- try:
- bundle = ActivityBundle(path)
- except:
- msg = _('%s not recognized by ActivityBundle parser. Does activity/activity.info exist?'
- %os.path.basename(path))
- self.alert(msg)
- return #maybe should issue an alert here
- self.activity_dict['version'] = str(bundle.get_activity_version())
- self.activity_dict['name'] = bundle.get_name()
- self.activity_dict['bundle_id'] = bundle.get_bundle_id()
- self.activity_dict['command'] = bundle.get_command()
- cmd_args = activityfactory.get_command(bundle)
- mod_class = cmd_args[1]
- if '.' in mod_class:
- self.activity_dict['class'] = mod_class.split('.')[1]
- self.activity_dict['module'] = mod_class.split('.')[0]
- self.activity_dict['icon'] = bundle.get_icon()
-
- def write_activity_info(self):
- #write the activity.info file
- _logger.debug('entered write_actiity_info')
- if self.child_path == None: return
- filen = os.path.join(self.child_path,'activity','activity.info')
- #try:
- with open(filen,'r') as fd:
- #and also write to a new file
- filewr = os.path.join(self.child_path,'activity','activity.new')
- #try:
- with open(filewr,'w') as fdw:
- #write the required lines
- _logger.debug('writing activity info to %s'%filewr)
- fdw.write('[Activity]\n')
- fdw.write('name = %s\n'%self.activity_dict.get('name'))
- fdw.write('bundle_id = %s\n'%self.activity_dict.get('bundle_id'))
- fdw.write('activity_version = %s\n'%self.activity_dict.get('version'))
- icon = self.activity_dict.get('icon')[len(self.child_path)+10:-4]
- fdw.write('icon = %s\n'%icon)
- if self.activity_dict.get('class','') == '':
- fdw.write('exec = %s\n'%self.activity_dict.get('module'))
- else:
- fdw.write('class = %s.%s\n'%(self.activity_dict.get('module'),
- self.activity_dict.get('class')))
- #pass the rest of the input to the output
- passup = ('[activity]','exec','activity_version','name','bundle_id',
- 'service_name','icon','class')
- for line in fd.readlines():
- tokens = line.split('=')
- keyword = tokens[0].lower().rstrip()
- if keyword in passup: continue
- fdw.write(line)
- """
- except EnvironmentError:
- _logger.debug('failed to open %s for writing. msg:%s'%(filewr,EnvironmentError[1]))
-
- except EnvironmentError:
- _logger.debug('failed to open %s msg:%s'%(filen,EnvironmentError[1]))
- """
-
- def delete_file_cb(self,widget):
- selection=self.manifest_treeview.get_selection()
- (model,iter)=selection.get_selected()
- if iter == None:
- self.alert(_('Must select File delete'))
- return
- fullpath = model.get(iter,4)[0]
- _logger.debug(' delete_file_clicked_cb. File: %s'%os.path.basename(fullpath))
- self.delete_file_storage = fullpath
- if os.path.isdir(fullpath):
- self.alert(_('Use the terminal "rm -rf <directory> --CAREFULLY','Cannot delete Folders!'))
- return
- self.confirmation_alert(_('Would you like to continue deleting %s?'%os.path.basename(fullpath)),
- _('ABOUT TO DELETE A FILE!!'),self.do_delete)
-
- def do_delete(self, alert, response):
- _logger.debug('doing delete of: %s'%self.delete_file_storage)
- self.manifest_point_to(self.delete_file_storage)
- os.unlink(self.delete_file_storage)
- self.manifest_class.set_file_sys_root(self.child_path)
- self.manifest_class.position_recent()
-
-
- ################ Help routines
- def help_selected(self):
- """
- if help is not created in a gtk.mainwindow then create it
- else just switch to that viewport
- """
- if not self.help_x11:
- self.help_x11 = self.help.realize_help()
- #self.x11_window = self.get_x11()os.geteuid()
- else:
- self.help.activate_help()
- #self.help.reshow()
- #self.help.toolbox.set_current_page(self.panes['HELP']
- """
- def get_x11(self):
- home_model = shell.get_model()
- activity = home_model.get_active_activity()
- if activity and activity.get_window():
-
- return activity.get_window().activate(1)
- else:
- return None
- """
- ################ save config state from one invocation to another -- not activity state
- def get_config(self):
- try:
- fd = open(os.path.join(self.debugger_home,'pickl'),'rb')
- local = pickle.load(fd)
- self.debug_dict = local.copy()
- _logger.debug('unpickled successfully')
- """
- object_id = self.debug_dict.get('jobject_id','')
- if object_id != '':
- self._jobject = datastore.get(object_id)
- else:
- self._jobject = None
- """
- except:
- try:
- fd = open(os.path.join(self.debugger_home,'pickl'),'wb')
- self.debug_dict['host'] = 'localhost'
- self.debug_dict['port'] = 18812
- self.debug_dict['autosave'] = True
- self.debug_dict['child_path'] = ''
- local = self.debug_dict.copy()
- pickle.dump(local,fd,pickle.HIGHEST_PROTOCOL)
- except IOError:
- _logger.debug('get_config -- Error writing pickle file %s'
- %os.path.join(self.debugger_home,'pickl'))
- finally:
- fd.close()
- object_id = self.debug_dict.get('jobject_id','')
- if object_id == '':
- jobject = datastore.create()
- jobject.metadata['title'] = 'PyDebug'
- jobject.metadata['keep'] = '1'
- jobject.metadata['preview'] = ''
- self._jobject = jobject
- datastore.write(self._jobject)
- #self.metadata = jobject.metadata
- self.debug_dict['jobject_id'] = str(os.geteuid())
- _logger.debug('in get_config created jobject id:%s'%self.debug_dict['jobject_id'])
- else:
- self._jobject = datastore.get(object_id)
- self.child_path = self.debug_dict.get('child_path','')
- if self.child_path == '' or not os.path.isdir(self.child_path):
- self.child_path = None
- """
- debugstr = ''
- for key in self.debug_dict.keys():
- debugstr += key + ':'+str(self.debug_dict[key]) + ', '
- _logger.debug ('In get_config: debug dictionary==> %s'%debugstr)
- """
- if self.child_path and self.debug_dict.get('tree_md5',''):
- if self.debug_dict.get('tree_md5','') == self.md5sum_tree(self.child_path):
- self.setup_new_activity()
- #the tree is valid so take up where we left off
- else:
- self.confirmation_alert(_('Continue even though stored checksum does not match current checksum'),
- _('CAUTION: The program in the playpen may have been changed.'),
- self.startup_continue)
-
- def startup_continue(self,alert,response):
- self.setup_new_activity()
-
- def put_config(self):
- if self.child_path:
- self.debug_dict['tree_md5'] = self.md5sum_tree(self.child_path)
- self.debug_dict['child_path'] = self.child_path
- try:
- fd = open(os.path.join(self.debugger_home,'pickl'),'wb')
- local = self.debug_dict.copy()
- pickle.dump(local,fd,pickle.HIGHEST_PROTOCOL)
- except IOError:
- _logger.debug('put_config routine Error writing pickle file %s'
- %os.path.join(self.debugger_home,'pickl'))
- return
- finally:
- fd.close()
- debugstr = ''
- return
- for key in self.debug_dict.keys():
- debugstr += key + ':'+str(self.debug_dict[key]) + ', '
- _logger.debug ('In put_config: debug dictionary==> %s'%debugstr)
-
diff --git a/pydebug_logging.pyo b/pydebug_logging.pyo
deleted file mode 100644
index c9c1080..0000000
--- a/pydebug_logging.pyo
+++ /dev/null
Binary files differ
diff --git a/pytoolbar.pyo b/pytoolbar.pyo
deleted file mode 100644
index acd36f4..0000000
--- a/pytoolbar.pyo
+++ /dev/null
Binary files differ
diff --git a/pytoolbar.py~ b/pytoolbar.py~
deleted file mode 100644
index 04787e8..0000000
--- a/pytoolbar.py~
+++ /dev/null
@@ -1,194 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2009, George Hunt <georgejhunt@gmail.com>
-#
-# 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 gconf
-
-from sugar.graphics.toolbox import Toolbox
-from sugar.graphics.xocolor import XoColor
-from sugar.graphics.icon import Icon
-from sugar.graphics.toolcombobox import ToolComboBox
-from sugar.graphics.toolbutton import ToolButton
-from gettext import gettext as _
-
-class ActivityToolbar(gtk.Toolbar):
- """The Activity toolbar with the Journal entry title, sharing,
- Keep and Stop buttons
-
- All activities should have this toolbar. It is easiest to add it to your
- Activity by using the ActivityToolbox.
- """
- def __init__(self, activity):
- gtk.Toolbar.__init__(self)
-
- self._activity = activity
- self._updating_share = False
-
- activity.connect('shared', self.__activity_shared_cb)
- activity.connect('joined', self.__activity_shared_cb)
- activity.connect('notify::max_participants',
- self.__max_participants_changed_cb)
-
- #if activity.metadata:
- if True:
- self.title = gtk.Entry()
- self.title.set_size_request(int(gtk.gdk.screen_width() / 6), -1)
- if activity.metadata:
- self.title.set_text(activity.metadata['title'])
- activity.metadata.connect('updated', self.__jobject_updated_cb)
- self.title.connect('changed', self.__title_changed_cb)
- self._add_widget(self.title)
-
- """
- separator = gtk.SeparatorToolItem()
- separator.props.draw = False
- separator.set_expand(True)
- self.insert(separator, -1)
- separator.show()
- """
- self.share = ToolComboBox(label_text=_('Traceback:'))
- self.share.combo.connect('changed', self.__traceback_changed_cb)
- self.share.combo.append_item("traceback_plain", _('Plain'))
- self.share.combo.append_item('traceback_context', _('Context'))
- self.share.combo.append_item('traceback_verbose', _('Verbose'))
- self.insert(self.share, -1)
- self.share.show()
-
- self._update_share()
-
- self.keep = ToolButton(tooltip=_('Keep'))
- client = gconf.client_get_default()
- color = XoColor(client.get_string('/desktop/sugar/user/color'))
- keep_icon = Icon(icon_name='document-save', xo_color=color)
- self.keep.set_icon_widget(keep_icon)
- keep_icon.show()
- self.keep.props.accelerator = '<Ctrl>S'
- self.keep.connect('clicked', self.__keep_clicked_cb)
- self.insert(self.keep, -1)
- self.keep.show()
-
- self.stop = ToolButton('activity-stop', tooltip=_('Stop'))
- self.stop.props.accelerator = '<Ctrl>Q'
- self.stop.connect('clicked', self.__stop_clicked_cb)
- self.insert(self.stop, -1)
- self.stop.show()
-
- self._update_title_sid = None
-
- def _update_share(self):
- self._updating_share = True
-
- if self._activity.props.max_participants == 1:
- self.share.hide()
-
- if self._activity.get_shared():
- self.share.set_sensitive(False)
- self.share.combo.set_active(1)
- else:
- self.share.set_sensitive(True)
- self.share.combo.set_active(0)
-
- self._updating_share = False
-
- def __traceback_changed_cb(self, combo):
- model = self.share.combo.get_model()
- it = self.share.combo.get_active_iter()
- (scope, ) = model.get(it, 0)
- if scope == 'traceback_plain':
- self._activity.traceback = 'Plain'
- self._activity.debug_dict['traceback'] = 'plain'
- elif scope == 'traceback_context':
- self._activity.traceback = 'Context'
- self._activity.debug_dict['traceback'] = 'context'
- elif scope == 'traceback_verbose':
- self._activity.traceback = 'Verbose'
- self._activity.debug_dict['traceback'] = 'verbose'
-
- def __keep_clicked_cb(self, button):
- self._activity.copy()
-
- def __stop_clicked_cb(self, button):
- self._activity.close()
-
- def __jobject_updated_cb(self, jobject):
- self.title.set_text(jobject['title'])
-
- def __title_changed_cb(self, entry):
- if not self._update_title_sid:
- self._update_title_sid = gobject.timeout_add_seconds(
- 1, self.__update_title_cb)
-
- def __update_title_cb(self):
- title = self.title.get_text()
-
- self._activity.metadata['title'] = title
- self._activity.metadata['title_set_by_user'] = '1'
- self._activity.save()
-
- shared_activity = self._activity.get_shared_activity()
- if shared_activity:
- shared_activity.props.name = title
-
- self._update_title_sid = None
- return False
-
- def _add_widget(self, widget, expand=False):
- tool_item = gtk.ToolItem()
- tool_item.set_expand(expand)
-
- tool_item.add(widget)
- widget.show()
-
- self.insert(tool_item, -1)
- tool_item.show()
-
- def __activity_shared_cb(self, activity):
- self._update_share()
-
- def __max_participants_changed_cb(self, activity, pspec):
- self._update_share()
-
-class ActivityToolbox(Toolbox):
- """Creates the Toolbox for the Activity
-
- By default, the toolbox contains only the ActivityToolbar. After creating
- the toolbox, you can add your activity specific toolbars, for example the
- EditToolbar.
-
- To add the ActivityToolbox to your Activity in MyActivity.__init__() do:
-
- # Create the Toolbar with the ActivityToolbar:
- toolbox = activity.ActivityToolbox(self)
- ... your code, inserting all other toolbars you need, like EditToolbar
-
- # Add the toolbox to the activity frame:
- self.set_toolbox(toolbox)
- # And make it visible:
- toolbox.show()
- """
- def __init__(self, activity):
- Toolbox.__init__(self)
-
- self._activity_toolbar = ActivityToolbar(activity)
- self.add_toolbar(_('Activity'), self._activity_toolbar)
- self._activity_toolbar.show()
-
- def get_activity_toolbar(self):
- return self._activity_toolbar
-
-
diff --git a/rsyncactivity b/rsyncactivity
deleted file mode 100755
index b5ce057..0000000
--- a/rsyncactivity
+++ /dev/null
@@ -1,3 +0,0 @@
-#copy the remote pydebug tree to the git tree
-rsync -p -r -v root@192.168.123.119:/home/olpc/Activities/PyDebug.activity/ /home/ghunt/git/pydebug/PyDebug.activity
-
diff --git a/sourceview_editor.pyo b/sourceview_editor.pyo
deleted file mode 100644
index 415e084..0000000
--- a/sourceview_editor.pyo
+++ /dev/null
Binary files differ
diff --git a/sourceview_editor.py~ b/sourceview_editor.py~
deleted file mode 100644
index 0ecd004..0000000
--- a/sourceview_editor.py~
+++ /dev/null
@@ -1,636 +0,0 @@
-# Copyright 2008 Paul Swartz
-#
-# 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, gobject
-import pango
-import notebook
-import gtksourceview2
-import os.path
-import sys
-import re
-import mimetypes
-from exceptions import *
-import hashlib
-from gettext import gettext as _
-
-# Initialize logging.
-import logging
-from sugar import logger
-#Get the standard logging directory.
-std_log_dir = logger.get_logs_dir()
-_logger = logging.getLogger('PyDebug')
-
-_logger.setLevel(logging.DEBUG)
-
-class S_WHERE:
- selection, file, multifile = range(3) #an enum
-
-class GtkSourceview2Editor(notebook.Notebook):
- __gsignals__ = {
- 'changed': (gobject.SIGNAL_RUN_FIRST, None, [])
- }
-
- def __init__(self, activity):
- notebook.Notebook.__init__(self, can_close_tabs=True)
- self._can_close_tabs = True #redundant, but above call broken for some reason
- self.activity = activity
- self.set_size_request(900, 350)
- self.connect('page-removed', self._page_removed_cb)
- self.connect('switch-page', self._switch_page_cb)
-
- def _page_removed_cb(self, notebook, page, n):
- _logger.debug('removing page %d'%n)
- if self.interactive_close:
- self.interactive_close = False
- page.save(interactive_close=True)
- page.save()
-
- def _switch_page_cb(self, notebook, page_gptr, page_num):
- pass
- #self.activity.update_sidebar_to_page(self.get_nth_page(page_num))
-
- def set_to_page_like(self,eq_to_page):
- for n in range(self.get_n_pages()):
- page = self.get_nth_page(n)
- if page == eq_to_page:
- self.set_current_page(n)
- return True
- return False
-
- def load_object(self, fullPath, filename):
- if self.set_to_page_like(fullPath):
- return
- page = GtkSourceview2Page(fullPath, self.activity)
- label = filename
- page.text_buffer.connect('changed', self._changed_cb)
- self.add_page(label, page)
- #label object is passed back in Notebook object -- remember it
- page.label = self.tab_label
- _logger.debug('new label text: %s'%page.label.get_text())
- self.set_current_page(-1)
- self._changed_cb(page.text_buffer)
-
- def position_to(self, fullPath, line = 0, col = 0):
- self.load_object(fullPath, os.path.basename(fullPath))
- page = self._get_page()
- page._scroll_to_line(line)
-
-
- def _changed_cb(self, buffer):
- if not buffer.can_undo():
- buffer.set_modified(False)
- self.clear_changed_star()
- elif not self.activity.dirty:
- self.activity.set_dirty(True)
- self.emit('changed')
- if buffer.can_undo():
- self.set_changed_star()
-
- def _get_page(self):
- n = self.get_current_page()
- return self.get_nth_page(n)
-
- def get_full_path(self):
- page = self._get_page()
- return page.fullPath
-
- def set_changed_star(self, button = None):
- page = self._get_page()
- if page:
- current = page.label.get_text()
- if current.startswith('*'):return
- page.label.set_text('*' + current)
-
- def clear_changed_star(self, button = None):
- page = self._get_page()
- if page:
- current = os.path.basename(page.fullPath)
- page.label.set_text(current)
-
- def set_focus(self):
- page = self._get_page()
- if page:
- page.text_view.grab_focus()
-
-
- def can_undo_redo(self):
- page = self._get_page()
- if page is None:
- return (False, False)
- else:
- return page.can_undo_redo()
-
- def undo(self, button = None):
- page = self._get_page()
- if page:
- page.undo()
-
- def redo(self, button = None):
- page = self._get_page()
- if page:
- page.redo()
-
- def copy(self, button = None):
- page = self._get_page()
- if page:
- page.copy()
-
- def cut(self, button = None):
- page = self._get_page()
- if page:
- page.cut()
-
- def paste(self, button = None):
- page = self._get_page()
- if page:
- page.paste()
-
- def replace(self, ftext, rtext, s_opts):
- replaced = False
- if s_opts.use_regex and issubclass(type(ftext),basestring):
- ftext = re.compile(ftext)
- multifile = (s_opts.where == S_WHERE.multifile)
- if multifile and s_opts.replace_all:
- for n in range(self.get_n_pages()):
- page = self.get_nth_page(n)
- replaced = page.replace(ftext, rtext,
- s_opts) or replaced
- return (replaced, False) #not found-again
-
- page = self._get_page()
- if page:
- selection = s_opts.where == S_WHERE.selection
- replaced = page.replace(ftext, rtext, s_opts)
- if s_opts.replace_all:
- return (replaced, False)
- elif not selection:
- found = self.find_next(ftext,s_opts,page)
- return (replaced, found)
- else:
- #for replace-in-selection, leave selection unmodified
- return (replaced, replaced)
-
- def find_next(self, ftext, s_opts, page=None):
- if not page:
- page = self._get_page()
- if page:
- if s_opts.use_regex and issubclass(type(ftext),basestring):
- ftext = re.compile(ftext)
- if page.find_next(ftext,s_opts,
- wrap=(s_opts.where != S_WHERE.multifile)):
- return True
- else:
- if (s_opts.where == S_WHERE.multifile):
- current_page = self.get_current_page()
- n_pages = self.get_n_pages()
- for i in range(1,n_pages):
- page = self.get_nth_page((current_page + i) % n_pages)
- if isinstance(page,SearchablePage):
- if page.find_next(ftext,s_opts,
- wrap = True):
- self.set_current_page((current_page + i) %
- n_pages)
- return True
- return False
- else:
- return False #first file failed, not multifile
- else:
- return False #no open pages
-
- def get_all_filenames(self):
- for i in range(self.get_n_pages()):
- page = self.get_nth_page(i)
- if isinstance(page,GtkSourceview2Page):
- yield page.fullPath
-
- def save_all(self):
- _logger.info('save all %i Editor pages' % self.get_n_pages())
- #if self.activity.is_foreign_dir():
- #_logger.info('save all aborting, still viewing in place')
- #return
- for i in range(self.get_n_pages()):
- page = self.get_nth_page(i)
- if isinstance(page,GtkSourceview2Page):
- _logger.debug('%s' % page.fullPath)
- page.save()
-
- def remove_all(self):
- for i in range(self.get_n_pages(),0,-1):
- self.remove_page(i-1)
- """
- page = self.get_nth_page(i)
- if isinstance(page,GtkSourceview2Page):
- self._close_page(None,page
- """
- def reroot(self,olddir, newdir):
- _logger.info('reroot from %s to %s' % (olddir,newdir))
- for i in range(self.get_n_pages()):
- page = self.get_nth_page(i)
- if isinstance(page,GtkSourceview2Page):
- if page.reroot(olddir, newdir):
- _logger.info('rerooting page %s failed' %
- page.fullPath)
- else:
- _logger.info('rerooting page %s succeeded' %
- page.fullPath)
-
- def get_selected(self):
- return self._get_page().get_selected()
-
- def change_font_size(self,size):
- page = self._get_page()
- page.set_font_size(size)
-
-class SearchablePage(gtk.ScrolledWindow):
- def get_selected(self):
- try:
- start,end = self.text_buffer.get_selection_bounds()
- return self.text_buffer.get_slice(start,end)
- except ValueError:
- return 0
-
- def get_text(self):
- """
- Return the text that's currently being edited.
- """
- start, end = self.text_buffer.get_bounds()
- return self.text_buffer.get_text(start, end)
-
- def get_offset(self):
- """
- Return the current character position in the currnet file.
- """
- insert = self.text_buffer.get_insert()
- _iter = self.text_buffer.get_iter_at_mark(insert)
- return _iter.get_offset()
-
- def copy(self):
- """
- Copy the currently selected text to the clipboard.
- """
- self.text_buffer.copy_clipboard(gtk.Clipboard())
-
- def paste(self):
- """
- Cut the currently selected text the clipboard into the current file.
- """
- self.text_buffer.paste_clipboard(gtk.Clipboard(), None, True)
-
- def cut(self):
- """
- Paste from the clipboard.
- """
- self.text_buffer.cut_clipboard(gtk.Clipboard(), True)
-
- def _getMatches(self,buffertext,fpat,s_opts,offset):
- if s_opts.use_regex:
- while True:
- match = fpat.search(buffertext,re.I if s_opts.ignore_caps else 0)
- if match:
- start,end = match.span()
- yield (start+offset,end+offset,match)
- else:
- return
- buffertext, offset = buffertext[end:],offset+end
- else:
- while True:
- if s_opts.ignore_caps:
- #possible optimization: turn fpat into a regex by escaping,
- #then use re.i
- buffertext = buffertext.lower()
- fpat = fpat.lower()
- match = buffertext.find(fpat)
- if match >= 0:
- end = match+len(fpat)
- yield (offset + match, offset + end, None)
- else:
- return
- buffertext, offset = buffertext[end:], offset + end
-
- def _match(self, pattern, text, s_opts):
- if s_opts.use_regex:
- return pattern.match(text,re.I if s_opts.ignore_caps else 0)
- else:
- if s_opts.ignore_caps:
- pattern = pattern.lower()
- text = text.lower()
- return pattern == text
-
- def _find_in(self, text, fpat, offset, s_opts, offset_add = 0):
- if s_opts.forward:
- matches = self._getMatches(text[offset:],fpat,s_opts,
- offset+offset_add)
- try:
- return matches.next()
- except StopIteration:
- return ()
- else:
- if offset != 0:
- text = text[:offset]
- matches = list(self._getMatches(text,fpat,s_opts,
- offset_add))
- if matches:
- return matches[-1]
- else:
- return ()
-
- def find_next(self, ftext, s_opts, wrap=True):
- """
- Scroll to the next place where the string text appears.
- If stay is True and text is found at the current position, stay where we are.
- """
- if s_opts.where == S_WHERE.selection:
- try:
- selstart, selend = self.text_buffer.get_selection_bounds()
- except (ValueError,TypeError):
- return False
- offsetadd = selstart.get_offset()
- buffertext = self.text_buffer.get_slice(selstart,selend)
- print buffertext
- try:
- start, end, match = self._find_in(buffertext, ftext, 0,
- s_opts, offsetadd)
- except (ValueError,TypeError):
- return False
- else:
- offset = self.get_offset() + (not s_opts.stay) #add 1 if not stay.
- text = self.get_text()
- try:
- start,end,match = self._find_in(text, ftext, offset,
- s_opts, 0)
- except (ValueError,TypeError):
- #find failed.
- if wrap:
- try:
- start,end,match = self._find_in(text, ftext, 0,
- s_opts, 0)
- except (ValueError,TypeError):
- return False
- else:
- return False
- self._scroll_to_offset(start,end)
- self.text_view.grab_focus()
- return True
-
- def _scroll_to_offset(self, offset, bound):
- _iter = self.text_buffer.get_iter_at_offset(offset)
- _iter2 = self.text_buffer.get_iter_at_offset(bound)
- self.text_buffer.select_range(_iter,_iter2)
- self.text_view.scroll_mark_onscreen(self.text_buffer.get_insert())
-
- def _scroll_to_line(self,line):
- _iter = self.text_buffer.get_iter_at_line(line)
- self.text_buffer.select_range(_iter,_iter)
- self.text_view.scroll_mark_onscreen(self.text_buffer.get_insert())
-
-
- def __eq__(self,other):
- if isinstance(other,GtkSourceview2Page):
- return self.fullPath == other.fullPath
- #elif isinstance(other,type(self.fullPath)):
- # other = other.metadata['source']
- if isinstance(other,basestring):
- return other == self.fullPath
- else:
- return False
-
-class GtkSourceview2Page(SearchablePage):
-
- def __init__(self, fullPath, activity):
- """
- Do any initialization here.
- """
- gtk.ScrolledWindow.__init__(self)
-
- self.fullPath = fullPath
- self.activity = activity
-
- self.text_buffer = gtksourceview2.Buffer()
- self.text_view = gtksourceview2.View(self.text_buffer)
-
- self.text_view.set_size_request(900, 350)
- self.text_view.set_editable(True)
- self.text_view.set_cursor_visible(True)
- self.text_view.set_highlight_current_line(True)
- self.text_view.set_show_line_numbers(True)
- self.text_view.set_insert_spaces_instead_of_tabs(True)
- if hasattr(self.text_view, 'set_tabs_width'):
- self.text_view.set_tabs_width(4)
- else:
- self.text_view.set_tab_width(4)
- self.text_view.set_auto_indent(True)
-
- self.text_view.set_wrap_mode(gtk.WRAP_CHAR)
- #self.text_view.modify_font(pango.FontDescription("Monospace 6.5"))
- self.set_font_size(self.activity.font_size)
-
- # We could change the color theme here, if we want to.
- mgr = gtksourceview2.StyleSchemeManager()
- mgr.prepend_search_path(self.activity.pydebug_path)
- _logger.debug('search path for gtksourceview is %r'%mgr.get_search_path())
- style_scheme = mgr.get_scheme('vibrant')
- self.text_buffer.set_style_scheme(style_scheme)
-
- self.set_policy(gtk.POLICY_AUTOMATIC,
- gtk.POLICY_AUTOMATIC)
- self.add(self.text_view)
- self.text_view.show()
- self.load_text()
- self.show()
-
- def set_font_size(self,font_size=None):
- if font_size == None: font_size = self.activity.font_size
- self.text_view.modify_font(pango.FontDescription("Monospace %d"%font_size))
- _logger.debug('setting font size to %d'%font_size)
-
- def load_text(self, offset=None):
- """
- Load the text, and optionally scroll to the given offset in the file.
- """
- self.text_buffer.begin_not_undoable_action()
- _file = file(self.fullPath)
- self.text_buffer.set_text(_file.read())
- _file.close()
- self.save_hash()
- if offset is not None:
- self._scroll_to_offset(offset)
-
- if hasattr(self.text_buffer, 'set_highlight'):
- self.text_buffer.set_highlight(False)
- else:
- self.text_buffer.set_highlight_syntax(False)
- mime_type = mimetypes.guess_type(self.fullPath)[0]
- if mime_type:
- lang_manager = gtksourceview2.language_manager_get_default()
- if hasattr(lang_manager, 'list_languages'):
- langs = lang_manager.list_languages()
- else:
- lang_ids = lang_manager.get_language_ids()
- langs = [lang_manager.get_language(i) for i in lang_ids]
- for lang in langs:
- for m in lang.get_mime_types():
- if m == mime_type:
- self.text_buffer.set_language(lang)
- if hasattr(self.text_buffer, 'set_highlight'):
- self.text_buffer.set_highlight(True)
- else:
- self.text_buffer.set_highlight_syntax(True)
- self.text_buffer.end_not_undoable_action()
- self.text_buffer.set_modified(False)
- self.text_view.grab_focus()
-
- def save_hash(self):
- self.md5sum = self.activity.md5sum(self.fullPath)
-
- def remove(self):
- self.save()
-
- def save(self,skip_md5 = False, interactive_close=False):
- if not self.text_buffer.can_undo() or self.activity.abandon_changes:
- if not self.text_buffer.can_undo():
- _logger.debug('no changes for %s'%os.path.basename(self.fullPath))
- return #only save if there's something to save
- if not skip_md5:
- hash = self.activity.md5sum(self.fullPath)
- if self.md5sum != hash: #underlying file has changed
- _logger.warning('md5sum stored:%s. Calculated:%s'%(self.md5sum,hash))
- _logger.warning('md5sum changed outside editor for %s. Save file questioned'
- %os.path.basename(self.fullPath))
- self.activity.confirmation_alert(_('Would you like to overwrite the changes in %s?'%os.path.basename(self.fullPath)),
- _('The Underlying File Has Been Changed By Another Application'),
- self.continue_save)
- return
- if self.interactive_close and self.text_buffer.can_undo():
- self.activity.confirmation_alert(_('Would you to Save the file, or cancel the Save?',
- _('This File Has Been Changed'),self.continue_save))
-
- self.continue_save(None)
-
- def continue_save(self, alert, response = None):
- if not self.fullPath.startswith(self.activity.debugger_home):
- self.activity.alert(_('Can only save in locations under %s'%self.activity.debugger_home))
- _logger.debug('failed to save self.fullPath: %s, Checked for starting with %s'%(self.fullPath, self.activity.debugger_home))
- return
- _logger.debug('saving %s'%os.path.basename(self.fullPath))
- text = self.get_text()
- _file = file(self.fullPath, 'w')
- try:
- _file.write(text)
- _file.close()
- self.save_hash()
- self.label.set_text(os.path.basename(self.fullPath))
- self.text_buffer.set_modified(False)
- msg = _("File saved: %s md5sumn:%s"%(os.path.basename(self.fullPath),self.md5sum))
- _logger.debug(msg)
- except IOError as (errno, strerror):
- msg = _("I/O error({0}): {1}".format(errno, strerror))
- self.activity.alert(msg)
- except:
- msg = "Unexpected error:", sys.exc_info()[0]
- self.activity.alert(msg)
- if _file:
- _file.close()
-
- def underlying_change_cb(self,response):
- #remove the alert from the screen, since either a response button
- #was clicked or there was a timeout
- self.remove_alert(alert)
-
- #Do any work that is specific to the type of button clicked.
- if response_id is gtk.RESPONSE_OK:
- self.continue_save()
- elif response_id is gtk.RESPONSE_CANCEL:
- return
-
- def can_undo_redo(self):
- """
- Returns a two-tuple (can_undo, can_redo) with Booleans of those abilities.
- """
- return (self.text_buffer.can_undo(), self.text_buffer.can_redo())
-
- def undo(self):
- """
- Undo the last change in the file. If we can't do anything, ignore.
- """
- self.text_buffer.undo()
-
- def redo(self):
- """
- Redo the last change in the file. If we can't do anything, ignore.
- """
- self.text_buffer.redo()
-
- def replace(self, ftext, rtext, s_opts):
- """returns true if replaced (succeeded)"""
- selection = s_opts.where == S_WHERE.selection
- if s_opts.replace_all or selection:
- result = False
- if selection:
- try:
- selstart, selend = self.text_buffer.get_selection_bounds()
- except (ValueError,TypeError):
- return False
- offsetadd = selstart.get_offset()
- buffertext = self.text_buffer.get_slice(selstart,selend)
- else:
- offsetadd = 0
- buffertext = self.get_text()
- results = list(self._getMatches(buffertext,ftext,
- s_opts,offsetadd))
- if not s_opts.replace_all:
- results = [results[0]]
- else:
- results.reverse() #replace right-to-left so that
- #unreplaced indexes remain valid.
- self.text_buffer.begin_user_action()
- for start, end, match in results:
- start = self.text_buffer.get_iter_at_offset(start)
- end = self.text_buffer.get_iter_at_offset(end)
- self.text_buffer.delete(start,end)
- self.text_buffer.insert(start, self.makereplace(rtext,match,s_opts.use_regex))
- result = True
- self.text_buffer.end_user_action()
- return result
- else: #replace, the &find part handled by caller
- try:
- start,end = self.text_buffer.get_selection_bounds()
- except TypeError:
- return False
- match = self._match(ftext,
- self.text_buffer.get_slice(start,end),
- s_opts)
- if match:
- self.text_buffer.delete(start, end)
- rtext = self.makereplace(rtext,match,s_opts.use_regex)
- self.text_buffer.insert(start, rtext)
- return True
- else:
- return False
-
- def makereplace(self, rpat, match, use_regex):
- if use_regex:
- return match.expand(rpat)
- else:
- return rpat
-
- def reroot(self,olddir,newdir):
- """Returns False if it works"""
- oldpath = self.fullPath
- if oldpath.startswith(olddir):
- self.fullPath = os.path.join(newdir, oldpath[len(olddir):])
- return False
- else:
- return True
diff --git a/terminal_pd.pyo b/terminal_pd.pyo
deleted file mode 100644
index 2bf9341..0000000
--- a/terminal_pd.pyo
+++ /dev/null
Binary files differ
diff --git a/tmp.py b/tmp.py
deleted file mode 100644
index 200058a..0000000
--- a/tmp.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from Rpyc import *
-c = SocketConnection('localhost')
-print('instance %r'%c.modules.pydebug.pydebug_instance)
-print('pydebug home: %r'%c.modules.pydebug.pydebug_instance.pydebug_home) \ No newline at end of file