Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucian Branescu Mihaila <lucian.branescu@gmail.com>2009-07-10 15:31:06 (GMT)
committer Lucian Branescu Mihaila <lucian.branescu@gmail.com>2009-07-10 15:31:06 (GMT)
commit10f59ff49c37bdbf85a675fbd0ce32f3c774c222 (patch)
treed3ee5cc9a484eaeeabe72f6ba38e8be1490e4c08
parent2a4c03a7c445b353f04053d6dfc85ccecc1079a3 (diff)
Adding (local) userscripts works.
-rw-r--r--usercode.py14
-rw-r--r--webactivity.py1
2 files changed, 11 insertions, 4 deletions
diff --git a/usercode.py b/usercode.py
index 39f2e9d..36690c3 100644
--- a/usercode.py
+++ b/usercode.py
@@ -117,7 +117,7 @@ class ScriptEditor(Dialog):
# layout
hbox = gtk.HBox()
- # file viewer
+ # file viewer, HACK
self.fileview = viewsource.FileViewer(self.scripts_path,
'test.user.js')
self.fileview.connect('file-selected', self._file_selected_cb)
@@ -174,6 +174,7 @@ class ScriptEditor(Dialog):
self.editor.file_path = self._get_selected_file()
def add_script(location):
+ #location = 'http://google.com/favicon.ico'
logging.debug('##### %s' % location)
cls = components.classes["@mozilla.org/network/io-service;1"]
@@ -182,9 +183,16 @@ def add_script(location):
cls = components.classes[ \
'@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
browser_persist = cls.getService(interfaces.nsIWebBrowserPersist)
-
+
location_uri = io_service.newURI(location, None, None)
- file_uri = io_service.newURI('file:///tmp/user.js', None, None)
+ file_name = os.path.basename(location_uri.path)
+
+ file_path = os.path.join(activity.get_activity_root(),
+ 'data/userscripts', file_name)
+
+ logging.debug('##### %s' % file_path)
+
+ file_uri = io_service.newURI('file://'+file_path, None, None)
browser_persist.saveURI(location_uri, None, None, None, None, file_uri)
diff --git a/webactivity.py b/webactivity.py
index 5b60b2f..52438d5 100644
--- a/webactivity.py
+++ b/webactivity.py
@@ -555,7 +555,6 @@ class WebActivity(activity.Activity):
self.remove_alert(alert)
if response_id is gtk.RESPONSE_OK:
- pass
usercode.add_script(alert._location)
def _userscript_inject_cb(self, listener, script_path):