summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2018-09-12 14:05:46 +0200
committerChristian Dywan <christian@twotoasts.de>2018-09-12 14:23:53 +0200
commitba3c495e5708e837e38a21c2131f1958afc02496 (patch)
treebcaa7762dab13d62cf98c40b03c0bbd99227a650
parent1245e9cd5603d0fe6e27c84d4a386bd5c47c9e0f (diff)
downloadmidori-git-app.tar.gz
Implement web app modeapp
Fixes: #48
-rw-r--r--core/app.vala17
-rw-r--r--core/browser.vala12
-rw-r--r--core/tab.vala5
-rw-r--r--core/tally.vala5
-rw-r--r--ui/browser.ui4
5 files changed, 40 insertions, 3 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;
diff --git a/core/browser.vala b/core/browser.vala
index 182a4eaf..057baf7d 100644
--- a/core/browser.vala
+++ b/core/browser.vala
@@ -22,6 +22,7 @@ namespace Midori {
public Tab? tab { get; protected set; }
public ListStore trash { get; protected set; }
public bool is_fullscreen { get; protected set; default = false; }
+ public bool is_locked { get; set; default = false; }
const ActionEntry[] actions = {
{ "tab-new", tab_new_activated },
@@ -55,6 +56,10 @@ namespace Midori {
[GtkChild]
DownloadButton downloads;
[GtkChild]
+ Gtk.Button tab_new;
+ [GtkChild]
+ Gtk.Button toggle_fullscreen;
+ [GtkChild]
Gtk.MenuButton app_menu;
[GtkChild]
Navigationbar navigationbar;
@@ -143,6 +148,8 @@ namespace Midori {
trash = new ListStore (typeof (DatabaseItem));
+ bind_property ("is-locked", tab_new, "visible", BindingFlags.INVERT_BOOLEAN);
+ bind_property ("is-locked", toggle_fullscreen, "visible", BindingFlags.INVERT_BOOLEAN);
navigationbar.urlbar.notify["uri"].connect ((pspec) => {
string uri = navigationbar.urlbar.uri;
if (uri.has_prefix ("javascript:")) {
@@ -216,6 +223,7 @@ namespace Midori {
set_titlebar (null);
panelbar.show_close_button = false;
tabbar.show_close_button = false;
+ bind_property ("is-locked", tabbar, "visible", BindingFlags.INVERT_BOOLEAN);
var box = (get_child () as Gtk.Box);
box.add (titlebar);
box.reorder_child (titlebar, 0);
@@ -262,6 +270,10 @@ namespace Midori {
}
public override bool key_press_event (Gdk.EventKey event) {
+ // No keyboard shortcuts in locked state
+ if (is_locked) {
+ return true;
+ }
// Give key handling in widgets precedence over actions
// eg. Backspace in textfields should delete rather than go back
if (propagate_key_event (event)) {
diff --git a/core/tab.vala b/core/tab.vala
index 9bdf87e0..558f7166 100644
--- a/core/tab.vala
+++ b/core/tab.vala
@@ -203,6 +203,11 @@ namespace Midori {
public override bool context_menu (WebKit.ContextMenu menu,
Gdk.Event event, WebKit.HitTestResult hit) {
+ // No context menu for pinned tabs
+ if (pinned) {
+ return true;
+ }
+
if (hit.context_is_editable ()) {
return false;
}
diff --git a/core/tally.vala b/core/tally.vala
index 7efa8d66..4ea720f9 100644
--- a/core/tally.vala
+++ b/core/tally.vala
@@ -97,6 +97,11 @@ namespace Midori {
}
protected override bool button_press_event (Gdk.EventButton event) {
+ // No context menu for a single tab
+ if (!show_close) {
+ return false;
+ }
+
switch (event.button) {
case Gdk.BUTTON_SECONDARY:
((SimpleAction)group.lookup_action ("pin")).set_enabled (!tab.pinned);
diff --git a/ui/browser.ui b/ui/browser.ui
index 669b918b..c90bfa3e 100644
--- a/ui/browser.ui
+++ b/ui/browser.ui
@@ -55,7 +55,7 @@
</object>
</child>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="toggle_fullscreen">
<property name="focus-on-click">no</property>
<property name="valign">center</property>
<property name="action-name">win.fullscreen</property>
@@ -109,7 +109,7 @@
</packing>
</child>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="tab_new">
<property name="focus-on-click">no</property>
<property name="valign">center</property>
<property name="action-name">win.tab-new</property>