diff options
author | Christian Dywan <christian@twotoasts.de> | 2018-11-07 11:22:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-07 11:22:44 +0100 |
commit | 9d58178edb0f9ecee73fc77ccd28abac0e0f0d40 (patch) | |
tree | 8900f6f5117a482a886920c13d3b56f52fafa0ec | |
parent | 147bf6f4af1e68c29988fc7fd82d08b2733491f3 (diff) | |
download | midori-git-9d58178edb0f9ecee73fc77ccd28abac0e0f0d40.tar.gz |
Show tab popover relative to urlbar with no opacity changes (#164)
Popovers really don't work well unless they're given an explicit
position. So for a tab that may be the tab itself or better yet
the urlbar of the containing browser.
With some themes the entire tabs goes blank due to opacity
changes, and even if it doesn't the translucency may leave
the user unclear as to what's happening. So let's not do this.
Fixes: #163
Also use the popover to re-implement permission requests.
Fixes: #158
-rw-r--r-- | core/browser.vala | 1 | ||||
-rw-r--r-- | core/tab.vala | 29 | ||||
-rw-r--r-- | ui/tab.ui | 1 |
3 files changed, 25 insertions, 6 deletions
diff --git a/core/browser.vala b/core/browser.vala index 8c84c9e3..e108ddcc 100644 --- a/core/browser.vala +++ b/core/browser.vala @@ -521,6 +521,7 @@ namespace Midori { } public new void add (Tab tab) { + tab.popover.relative_to = navigationbar.urlbar; tab.create.connect ((action) => { var new_tab = new Tab (tab, web_context); new_tab.hide (); diff --git a/core/tab.vala b/core/tab.vala index 715ee865..8dc8b914 100644 --- a/core/tab.vala +++ b/core/tab.vala @@ -31,7 +31,7 @@ namespace Midori { public string link_uri { get; protected set; } [GtkChild] - Gtk.Popover popover; + internal Gtk.Popover popover; [GtkChild] Gtk.Label message; [GtkChild] @@ -296,17 +296,14 @@ namespace Midori { public override bool script_dialog (WebKit.ScriptDialog dialog) { message.label = dialog.get_message (); - // Render inactive without setting sensitive which affects the popover - opacity = 0.3; - popover.closed.connect (() => { - opacity = 1.0; - }); switch (dialog.get_dialog_type ()) { case WebKit.ScriptDialogType.ALERT: + confirm.hide (); break; case WebKit.ScriptDialogType.CONFIRM: case WebKit.ScriptDialogType.BEFORE_UNLOAD_CONFIRM: + confirm.label = _("_Confirm"); confirm.visible = true; popover.closed.connect (() => { dialog.confirm_set_confirmed (false); @@ -318,6 +315,7 @@ namespace Midori { case WebKit.ScriptDialogType.PROMPT: entry.placeholder_text = dialog.prompt_get_default_text (); entry.visible = true; + confirm.label = _("_Confirm"); confirm.visible = true; popover.closed.connect (() => { dialog.prompt_set_text (""); @@ -331,6 +329,25 @@ namespace Midori { return true; } + public override bool permission_request (WebKit.PermissionRequest permission) { + if (permission is WebKit.GeolocationPermissionRequest) { + string hostname = new Soup.URI (uri).host; + message.label = _("%s wants to know your location.").printf (hostname); + } else { + message.label = permission.get_type ().name (); + } + confirm.label = _("_Allow"); + confirm.show (); + confirm.clicked.connect (() => { + permission.allow (); + }); + popover.closed.connect (() => { + permission.deny (); + }); + popover.show (); + return true; + } + public override bool decide_policy (WebKit.PolicyDecision decision, WebKit.PolicyDecisionType type) { switch (type) { case WebKit.PolicyDecisionType.NAVIGATION_ACTION: @@ -2,6 +2,7 @@ <object class="GtkPopover" id="popover"> <property name="modal">yes</property> <property name="position">bottom</property> + <property name="relative-to">MidoriTab</property> <child> <object class="GtkBox"> <property name="orientation">vertical</property> |