diff options
author | Christian Dywan <christian@twotoasts.de> | 2019-08-09 02:25:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-09 02:25:28 +0200 |
commit | c22ee23b62aa5eea980a05d743142f92b5aa18ab (patch) | |
tree | 1a03b9091ffc4aaf9d295e37c5f61ba6d279bdb7 | |
parent | 7ac8cbaafa9fba439e1d285627e8b440020daf02 (diff) | |
download | midori-git-c22ee23b62aa5eea980a05d743142f92b5aa18ab.tar.gz |
Show source in a tab if no editor is available (#350)
-rw-r--r-- | core/browser.vala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/core/browser.vala b/core/browser.vala index 119df4c9..3ce21e40 100644 --- a/core/browser.vala +++ b/core/browser.vala @@ -631,6 +631,16 @@ namespace Midori { async void view_source (Tab tab) { string uri = tab.display_uri; try { + var info = AppInfo.get_default_for_type ("text/plain", false); + // No editor available? Show source in a tab + if (info == null) { + var new_tab = new Tab (tab, web_context, uri, tab.display_title); + new_tab.load_plain_text (((string)(yield tab.get_main_resource ().get_data (null)))); + new_tab.set_data<bool> ("foreground", true); + add (new_tab); + return; + } + var file = File.new_for_uri (uri); if (!uri.has_prefix ("file:///")) { FileIOStream stream; @@ -641,7 +651,6 @@ namespace Midori { } var files = new List<File> (); files.append (file); - var info = AppInfo.get_default_for_type ("text/plain", false); info.launch (files, get_display ().get_app_launch_context ()); } catch (Error error) { critical ("Failed to open %s in editor: %s", uri, error.message); |