[Xfce4-commits] <midori:master> External Download manager extension for Steadyflow
Christian Dywan
noreply at xfce.org
Fri Mar 16 00:14:03 CET 2012
Updating branch refs/heads/master
to f92fa1a33f1a98745662ef59d0bfe8e7f01797fe (commit)
from d93c96daf368ff6b1f4de044dc6a79937bf2c551 (commit)
commit f92fa1a33f1a98745662ef59d0bfe8e7f01797fe
Author: André Stösel <andre at stoesel.de>
Date: Thu Mar 15 23:07:02 2012 +0100
External Download manager extension for Steadyflow
As it is activated, the Save button uses Steadyflow.
extensions/external-download-manager.vala | 91 +++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/extensions/external-download-manager.vala b/extensions/external-download-manager.vala
new file mode 100644
index 0000000..1dc5685
--- /dev/null
+++ b/extensions/external-download-manager.vala
@@ -0,0 +1,91 @@
+/*
+ Copyright (C) 2012 André Stösel <andre at stoesel.de>
+
+ 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.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+using Gtk;
+using WebKit;
+using Midori;
+
+namespace EDM {
+ [DBus (name = "net.launchpad.steadyflow.App")]
+ interface SteadyflowInterface : GLib.Object {
+ public abstract void AddFile (string url) throws IOError;
+ }
+
+ private class Manager : Midori.Extension {
+ public bool download_requested (Midori.View view,
+ WebKit.Download download, Midori.Browser browser) {
+ if (download.get_data<void*> ("save-as-download") == null
+ && download.get_data<void*> ("open-download") == null) {
+ try {
+ SteadyflowInterface db = Bus.get_proxy_sync (
+ BusType.SESSION,
+ "net.launchpad.steadyflow.App",
+ "/net/launchpad/steadyflow/app");
+ db.AddFile (download.get_uri ());
+ return true;
+ } catch (Error e) {
+ stderr.printf("Error: %s\n", e.message);
+ }
+ }
+ return false;
+ }
+
+ public void tab_added (Midori.Browser browser, Midori.View view) {
+ view.download_requested.connect (download_requested);
+ }
+
+ public void tab_removed (Midori.Browser browser, Midori.View view) {
+ view.download_requested.disconnect(download_requested);
+ }
+
+ public void browser_added (Midori.Browser browser) {
+ foreach (var tab in browser.get_tabs ())
+ tab_added (browser, tab);
+ browser.add_tab.connect (tab_added);
+ browser.remove_tab.connect (tab_removed);
+ }
+
+ public void browser_removed (Midori.Browser browser) {
+ foreach (var tab in browser.get_tabs ())
+ tab_removed (browser, tab);
+ browser.add_tab.disconnect (tab_added);
+ browser.remove_tab.disconnect (tab_removed);
+ }
+
+ public void activated (Midori.App app) {
+ foreach (var browser in app.get_browsers ())
+ browser_added (browser);
+ app.add_browser.connect (browser_added);
+ }
+
+ public void deactivated () {
+ var app = get_app ();
+ foreach (var browser in app.get_browsers ())
+ browser_removed (browser);
+ app.add_browser.disconnect (browser_added);
+ }
+
+ internal Manager () {
+ GLib.Object (name: _("External Download Manager"),
+ description: _("Download files with SteadyFlow"),
+ version: "0.1" + Midori.VERSION_SUFFIX,
+ authors: "André Stösel <andre at stoesel.de>");
+
+ this.activate.connect (activated);
+ this.deactivate.connect (deactivated);
+ }
+ }
+}
+
+public Midori.Extension extension_init () {
+ return new EDM.Manager ();
+}
+
More information about the Xfce4-commits
mailing list