[epiphany/wip/exalm/urlbar: 1/2] ephy-location-entry: Add hover state
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/urlbar: 1/2] ephy-location-entry: Add hover state
- Date: Tue, 29 Jan 2019 05:49:59 +0000 (UTC)
commit 98685ba8a2825722502e04d62522edcd016662d1
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Tue Jan 29 10:42:09 2019 +0500
ephy-location-entry: Add hover state
GTK+ 3.x cannot have hover state for entries, so listen to enter/leave
events and set widget state manually.
lib/widgets/ephy-location-entry.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
---
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index dc33e3d69..c7b06afd2 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -772,6 +772,22 @@ suggestion_selected (DzlSuggestionEntry *entry,
schedule_dns_prefetch (lentry, uri);
}
+static void
+enter_notify_cb (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_PRELIGHT, FALSE);
+}
+
+static void
+leave_notify_cb (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_PRELIGHT);
+}
+
static void
ephy_location_entry_construct_contents (EphyLocationEntry *entry)
{
@@ -797,6 +813,11 @@ ephy_location_entry_construct_contents (EphyLocationEntry *entry)
gtk_widget_show (GTK_WIDGET (entry->url_entry));
gtk_overlay_add_overlay (GTK_OVERLAY (entry), GTK_WIDGET (entry->url_entry));
+ /* Custom hover state. FIXME: Remove this for GTK4 */
+ gtk_widget_add_events (GTK_WIDGET (entry->url_entry), GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
+ g_signal_connect (G_OBJECT (entry->url_entry), "enter-notify-event", G_CALLBACK (enter_notify_cb), entry);
+ g_signal_connect (G_OBJECT (entry->url_entry), "leave-notify-event", G_CALLBACK (leave_notify_cb), entry);
+
/* Event box */
event = gtk_event_box_new ();
gtk_widget_set_halign (event, GTK_ALIGN_END);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]