Implement FTP support in External Applications
For the moment 'gftp' is hardcoded for ftp://.
This commit is contained in:
parent
969c225c3b
commit
9241afa0db
2 changed files with 35 additions and 4 deletions
|
@ -10,12 +10,44 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using Gtk;
|
using Gtk;
|
||||||
|
using WebKit;
|
||||||
using Midori;
|
using Midori;
|
||||||
|
|
||||||
public class ExternalApplications : Midori.Extension {
|
public class ExternalApplications : Midori.Extension {
|
||||||
Dialog? dialog;
|
Dialog? dialog;
|
||||||
void tab_added (Widget tab) {
|
bool launch (string command, string uri) {
|
||||||
/* */
|
try {
|
||||||
|
var info = GLib.AppInfo.create_from_commandline (command, null, 0);
|
||||||
|
var uris = new List<string>();
|
||||||
|
uris.prepend (uri);
|
||||||
|
info.launch_uris (uris, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (GLib.Error error) {
|
||||||
|
var error_dialog = new Gtk.MessageDialog (null, 0,
|
||||||
|
Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
|
||||||
|
"Failed to launch external application.");
|
||||||
|
error_dialog.format_secondary_text (error.message);
|
||||||
|
error_dialog.response.connect ((dialog, response)
|
||||||
|
=> { dialog.destroy (); });
|
||||||
|
error_dialog.show ();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool navigating (WebFrame web_frame, NetworkRequest request,
|
||||||
|
WebNavigationAction action, WebPolicyDecision decision) {
|
||||||
|
string uri = request.get_uri ();
|
||||||
|
if (uri.has_prefix ("ftp://")) {
|
||||||
|
if (launch ("gftp", uri)) {
|
||||||
|
decision.ignore ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void tab_added (View tab) {
|
||||||
|
var web_view = tab.get_web_view ();
|
||||||
|
web_view.navigation_policy_decision_requested.connect (navigating);
|
||||||
}
|
}
|
||||||
void configure_external_applications () {
|
void configure_external_applications () {
|
||||||
if (dialog == null) {
|
if (dialog == null) {
|
||||||
|
@ -68,7 +100,7 @@ public Midori.Extension extension_init () {
|
||||||
extension.name = "External Applications";
|
extension.name = "External Applications";
|
||||||
extension.description = "Lalala";
|
extension.description = "Lalala";
|
||||||
extension.version = "0.1";
|
extension.version = "0.1";
|
||||||
extension.authors = "nobody";
|
extension.authors = "Christian Dywan <christian@twotoasts.de>";
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -966,7 +966,6 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TODO: Handle more external protocols */
|
|
||||||
view->special = FALSE;
|
view->special = FALSE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue