URL tooltips when you hover over links. Closes #4672

This commit is contained in:
eric 2012-02-01 16:37:53 -08:00
parent 767997eeb7
commit f0ea6b3ceb
2 changed files with 21 additions and 0 deletions

View file

@ -102,6 +102,7 @@ public class MainWindow : Gtk.Window {
Gtk.ScrolledWindow message_viewer_scrolled = new Gtk.ScrolledWindow(null, null);
message_viewer_scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
message_viewer_scrolled.add(message_viewer);
message_viewer.link_hover.connect(on_link_hover);
// three-pane display: folder list on left and messages on right separated by grippable
folder_paned.pack1(folder_list_scrolled, false, false);
@ -122,5 +123,16 @@ public class MainWindow : Gtk.Window {
add(main_layout);
}
private void on_link_hover(string? link) {
tooltip_text = link;
trigger_tooltip_query();
}
public override bool query_tooltip(int x, int y, bool keyboard_tooltip, Gtk.Tooltip tooltip) {
tooltip.set_text(tooltip_text);
return true;
}
}

View file

@ -72,6 +72,9 @@ public class MessageViewer : WebKit.WebView {
// Fired when the user clicks a link.
public signal void link_selected(string link);
// Fired when the user hovers over or stops hovering over a link.
public signal void link_hover(string? link);
// List of emails in this view.
public Gee.LinkedList<Geary.Email> messages { get; private set; default =
new Gee.LinkedList<Geary.Email>(); }
@ -265,6 +268,7 @@ public class MessageViewer : WebKit.WebView {
// Copy the link the user is hovering over. Note that when the user mouses-out,
// this signal is called again with null for both parameters.
hover_url = url;
link_hover(hover_url);
}
private void on_copy_text() {
@ -319,6 +323,11 @@ public class MessageViewer : WebKit.WebView {
context_menu.popup(null, null, null, event.button, event.time);
}
public override bool query_tooltip(int x, int y, bool keyboard_tooltip, Gtk.Tooltip tooltip) {
// Disable tooltips from within WebKit itself.
return false;
}
public override void get_preferred_height (out int minimum_height, out int natural_height) {
minimum_height = height;
natural_height = height;