Permalink
Browse files

Make web/index.html the default uri, and remove any extra scraps of code

  • Loading branch information...
Luke Closs
Luke Closs committed Apr 26, 2008
1 parent 03a4281 commit a591f475f8c51e8805b231f2e3896c783e4fc1de
Showing with 14 additions and 17 deletions.
  1. BIN OnePageWikiActivity-1.xo
  2. +8 −14 OnePageWikiActivity.py
  3. +6 −3 XOCom.py
View
Binary file not shown.
View
@@ -1,34 +1,29 @@
from sugar.activity import activity
-from sugar.activity.activity import get_bundle_path
from sugar import env
-import logging
-import sys, os
+import os
import gtk
import gobject
-
import hulahop
hulahop.startup(os.path.join(env.get_profile_path(), 'gecko'))
-
from XOCom import XOCom
-# The XOCom object helps us communicate with the browser
-uri = 'file://' + get_bundle_path() + '/web/index.html';
-xocom = XOCom(uri)
-
class OnePageWikiActivity (activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self.set_title('OnePageWiki')
+ # The XOCom object helps us communicate with the browser
+ # This uses web/index.html as the default page to load
+ self.xocom = XOCom()
+
toolbox = activity.ActivityToolbox(self)
self.set_toolbox(toolbox)
toolbox.show()
- self.set_canvas( xocom.create_webview() )
+ self.set_canvas( self.xocom.create_webview() )
def write_file(self, filename):
- content = xocom.send_to_browser('write')
- print "write_file(%s): %s"%(filename, content)
+ content = self.xocom.send_to_browser('write')
if content:
fh = open(filename, 'w')
fh.write(content)
@@ -37,9 +32,8 @@ def write_file(self, filename):
def read_file(self, filename):
fh = open(filename, 'r')
content = fh.read()
- print "read_file(%s): %s"%(filename, content)
# We must delay this to give the browser time to start up
# It would be better if this send_to_browser was instead triggered
# once the browser had finished loading.
- gobject.timeout_add(2000, xocom.send_to_browser, 'read', content)
+ gobject.timeout_add(2000, self.xocom.send_to_browser, 'read', content)
View
@@ -1,11 +1,15 @@
+from sugar.activity.activity import get_bundle_path
from hulahop.webview import WebView
from xpcom import components
class XOCom:
# Constructor gives full XPCom access by default
# This should be improved for future apps that may not need/want full access
- def __init__(self, uri):
- self.uri = uri
+ def __init__(self, uri=None):
+ if uri:
+ self.uri = uri
+ else:
+ self.uri = 'file://' + get_bundle_path() + '/web/index.html';
self.give_full_xpcom_access()
# Give the browser permission to use XPCom interfaces
@@ -58,4 +62,3 @@ def send_to_browser(self, command, parameter=None):
result = result.QueryInterface(components.interfaces.nsISupportsString)
return result.toString()
return None
-

0 comments on commit a591f47

Please sign in to comment.