summaryrefslogtreecommitdiff
path: root/core/app.vala
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2018-09-13 23:41:45 +0200
committerGitHub <noreply@github.com>2018-09-13 23:41:45 +0200
commitea3e9db92c2a79637c8f4a062e07327bd8ef2a8d (patch)
tree1d4c7346e0bd0e6565f70143526bfbc0ee106dbd /core/app.vala
parent0c9a056308e65327e933dc82c8c9469c64193af7 (diff)
downloadmidori-git-ea3e9db92c2a79637c8f4a062e07327bd8ef2a8d.tar.gz
Implement web app mode (#55)
The (web) app mode is a way to open a website like its own application via the `--app/ -a` switch. This change doesn't address creation of a launcher or management of data. Fixes: #48
Diffstat (limited to 'core/app.vala')
-rw-r--r--core/app.vala17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/app.vala b/core/app.vala
index 46b2baa5..fd2a2dff 100644
--- a/core/app.vala
+++ b/core/app.vala
@@ -18,12 +18,14 @@ namespace Midori {
public class App : Gtk.Application {
public File? exec_path { get; protected set; default = null; }
+ static string? app = null;
[CCode (array_length = false, array_null_terminated = true)]
static string[]? execute = null;
static bool help_execute = false;
public static bool incognito = false;
static bool version = false;
const OptionEntry[] options = {
+ { "app", 'a', 0, OptionArg.STRING, ref app, N_("Run ADDRESS as a web application"), N_("ADDRESS") },
{ "execute", 'e', 0, OptionArg.STRING_ARRAY, ref execute, N_("Execute the specified command"), null },
{ "help-execute", 0, 0, OptionArg.NONE, ref help_execute, N_("List available commands to execute with -e/ --execute"), null },
{ "private", 'p', 0, OptionArg.NONE, ref incognito, N_("Private browsing, no changes are saved"), null },
@@ -321,6 +323,7 @@ namespace Midori {
}
// Propagate options processed in the primary instance
+ options.insert_value ("app", app ?? "");
options.insert_value ("execute", execute);
options.insert_value ("help-execute", help_execute);
options.insert_value ("private", incognito);
@@ -332,6 +335,7 @@ namespace Midori {
// Retrieve values for options passed from another process
var options = command_line.get_options_dict ();
+ app = options.lookup_value ("app", VariantType.STRING).get_string ();
execute = options.lookup_value ("execute", VariantType.STRING_ARRAY).dup_strv ();
help_execute = options.lookup_value ("help-execute", VariantType.BOOLEAN).get_boolean ();
incognito = options.lookup_value ("private", VariantType.BOOLEAN).get_boolean ();
@@ -348,9 +352,20 @@ namespace Midori {
}
}
+ if (app != "") {
+ var browser = new Browser (this);
+ browser.is_locked = true;
+ var tab = new Tab (null, browser.web_context, app);
+ tab.pinned = true;
+ browser.add (tab);
+ browser.show ();
+ }
+
uint argc = command_line.get_arguments ().length;
if (argc <= 1) {
- activate ();
+ if (active_window == null) {
+ activate ();
+ }
} else {
var files = new File[argc - 1];
uint i = 0;