aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar keis <keijser@gmail.com>2011-01-23 22:06:33 +0100
committerGravatar keis <keijser@gmail.com>2011-02-15 21:17:16 +0100
commit3cb9af3b4457f5c6aec1eae2acf552aad8a3e6db (patch)
tree1047f5046c84bc4c2728275d6d2e748a38c1be52 /examples
parent70b9ba7440c5164c90f61ddf4d988f32019a5ecc (diff)
support quoted events in a few more places
* downloads * on_event handlers
Diffstat (limited to 'examples')
-rw-r--r--examples/data/plugins/downloads.py18
-rw-r--r--examples/data/plugins/on_event.py6
2 files changed, 19 insertions, 5 deletions
diff --git a/examples/data/plugins/downloads.py b/examples/data/plugins/downloads.py
index 7bf32d7..8d796ce 100644
--- a/examples/data/plugins/downloads.py
+++ b/examples/data/plugins/downloads.py
@@ -31,7 +31,11 @@ def update_download_section(uzbl):
if uzbl.config.get('downloads', '') != result:
uzbl.config['downloads'] = result
-def download_started(uzbl, destination_path):
+def download_started(uzbl, args):
+ # parse the arguments
+ args = splitquoted(args)
+ destination_path = args[0]
+
# add to the list of active downloads
global ACTIVE_DOWNLOADS
ACTIVE_DOWNLOADS[destination_path] = (0.0,)
@@ -41,9 +45,9 @@ def download_started(uzbl, destination_path):
def download_progress(uzbl, args):
# parse the arguments
- s = args.rindex(' ')
- destination_path = args[:s]
- progress = float(args[s+1:])
+ args = splitquoted(args)
+ destination_path = args[0]
+ progress = float(args[1])
# update the progress
global ACTIVE_DOWNLOADS
@@ -52,7 +56,11 @@ def download_progress(uzbl, args):
# update the status bar variable
update_download_section(uzbl)
-def download_complete(uzbl, destination_path):
+def download_complete(uzbl, args):
+ # parse the arguments
+ args = splitquoted(args)
+ destination_path = args[0]
+
# remove from the list of active downloads
global ACTIVE_DOWNLOADS
del ACTIVE_DOWNLOADS[destination_path]
diff --git a/examples/data/plugins/on_event.py b/examples/data/plugins/on_event.py
index 5142275..32f09e2 100644
--- a/examples/data/plugins/on_event.py
+++ b/examples/data/plugins/on_event.py
@@ -24,6 +24,10 @@ def event_handler(uzbl, *args, **kargs):
'''This function handles all the events being watched by various
on_event definitions and responds accordingly.'''
+ # Could be connected to a EM internal event that can use anything as args
+ if len(args) == 1 and isinstance(args[0], basestring):
+ args = splitquoted(args[0])
+
events = uzbl.on_events
event = kargs['on_event']
if event not in events:
@@ -80,3 +84,5 @@ def cleanup(uzbl):
del handlers[:]
uzbl.on_events.clear()
+
+# vi: set et ts=4: