From 3cb9af3b4457f5c6aec1eae2acf552aad8a3e6db Mon Sep 17 00:00:00 2001 From: keis Date: Sun, 23 Jan 2011 22:06:33 +0100 Subject: support quoted events in a few more places * downloads * on_event handlers --- examples/data/plugins/downloads.py | 18 +++++++++++++----- examples/data/plugins/on_event.py | 6 ++++++ 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'examples') 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: -- cgit v1.2.3