Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 03 Dec 2012 16:33:03 UTC Commit: fefb46357efb2751fb2b78e77743f0c33bf27758 https://github.com/geany/geany-plugins/commit/fefb46357efb2751fb2b78e77743f0...
Log Message: ----------- WebHelper: Fix hovered link display when the mouse leaves the view
The web view doesn't emit an hovered link change when the mouse leaves the view area. So, handle the case ourselves.
Modified Paths: -------------- webhelper/src/gwh-browser.c
Modified: webhelper/src/gwh-browser.c 71 files changed, 64 insertions(+), 7 deletions(-) =================================================================== @@ -75,6 +75,8 @@ struct _GwhBrowserPrivate GtkToolItem *item_cancel; GtkToolItem *item_reload; GtkToolItem *item_inspector; + + gchar *hovered_link; };
enum { @@ -645,6 +647,7 @@ static void inspector_set_detached (GwhBrowser *self, g_object_unref (self->priv->default_icon); } g_object_unref (self->priv->settings); + g_free (self->priv->hovered_link);
G_OBJECT_CLASS (gwh_browser_parent_class)->finalize (object); } @@ -883,11 +886,8 @@ static void inspector_set_detached (GwhBrowser *self, return self->priv->inspector_window; }
-static void -on_web_view_hovering_over_link (WebKitWebView *view, - gchar *title, - gchar *uri, - GwhBrowser *self) +static guint +get_statusbar_context_id (GtkStatusbar *statusbar) { static guint id = 0;
@@ -896,13 +896,62 @@ static void inspector_set_detached (GwhBrowser *self, "gwh-browser-hovered-link"); }
- gtk_statusbar_pop (GTK_STATUSBAR (ui_widgets.statusbar), id); + return id; +} + +static void +on_web_view_hovering_over_link (WebKitWebView *view, + gchar *title, + gchar *uri, + GwhBrowser *self) +{ + GtkStatusbar *statusbar = GTK_STATUSBAR (ui_widgets.statusbar); + + if (self->priv->hovered_link) { + gtk_statusbar_pop (statusbar, get_statusbar_context_id (statusbar)); + g_free (self->priv->hovered_link); + self->priv->hovered_link = NULL; + } if (uri && *uri) { - gtk_statusbar_push (GTK_STATUSBAR (ui_widgets.statusbar), id, uri); + self->priv->hovered_link = g_strdup (uri); + gtk_statusbar_push (statusbar, get_statusbar_context_id (statusbar), + self->priv->hovered_link); } }
static void +on_web_view_leave_notify_event (GtkWidget *widget, + GdkEventCrossing *event, + GwhBrowser *self) +{ + if (self->priv->hovered_link) { + GtkStatusbar *statusbar = GTK_STATUSBAR (ui_widgets.statusbar); + + gtk_statusbar_pop (statusbar, get_statusbar_context_id (statusbar)); + } +} + +static void +on_web_view_enter_notify_event (GtkWidget *widget, + GdkEventCrossing *event, + GwhBrowser *self) +{ + if (self->priv->hovered_link) { + GtkStatusbar *statusbar = GTK_STATUSBAR (ui_widgets.statusbar); + + gtk_statusbar_push (statusbar, get_statusbar_context_id (statusbar), + self->priv->hovered_link); + } +} + +static void +on_web_view_realize (GtkWidget *widget, + GwhBrowser *self) +{ + gtk_widget_add_events (widget, GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK); +} + +static void gwh_browser_init (GwhBrowser *self) { GtkWidget *scrolled; @@ -947,6 +996,8 @@ static void inspector_set_detached (GwhBrowser *self, : self->priv->paned), self->priv->inspector_view);
+ self->priv->hovered_link = NULL; + g_signal_connect (self, "notify::orientation", G_CALLBACK (on_orientation_notify), self);
@@ -978,6 +1029,12 @@ static void inspector_set_detached (GwhBrowser *self, G_CALLBACK (on_web_view_scroll_event), self); g_signal_connect (G_OBJECT (self->priv->web_view), "hovering-over-link", G_CALLBACK (on_web_view_hovering_over_link), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "leave-notify-event", + G_CALLBACK (on_web_view_leave_notify_event), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "enter-notify-event", + G_CALLBACK (on_web_view_enter_notify_event), self); + g_signal_connect_after (self->priv->web_view, "realize", + G_CALLBACK (on_web_view_realize), self);
g_signal_connect (self->priv->web_view, "key-press-event", G_CALLBACK (gwh_keybindings_handle_event), self);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).