[libadwaita/wip/exalm/tab-hover: 31/32] tab: Show close button on enter as well




commit 0858bc558f43467d905f316d173c7deb8bf8ba39
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Oct 24 01:27:24 2021 +0500

    tab: Show close button on enter as well
    
    If one moves a pointer to a position where a tab would be, then alt-tabs to
    the libadwaita demo window, the close button won't show up until you move
    the poitner again. Fix that.

 src/adw-tab.c  | 12 ++++++++++++
 src/adw-tab.ui |  1 +
 2 files changed, 13 insertions(+)
---
diff --git a/src/adw-tab.c b/src/adw-tab.c
index 16d24e5b..89f4a160 100644
--- a/src/adw-tab.c
+++ b/src/adw-tab.c
@@ -275,6 +275,17 @@ indicator_clicked_cb (AdwTab *self)
   g_signal_emit_by_name (self->view, "indicator-activated", self->page);
 }
 
+static void
+enter_cb (AdwTab             *self,
+          double              x,
+          double              y,
+          GtkEventController *controller)
+{
+  self->hovering = TRUE;
+
+  update_state (self);
+}
+
 static void
 motion_cb (AdwTab             *self,
            double              x,
@@ -824,6 +835,7 @@ adw_tab_class_init (AdwTabClass *klass)
   gtk_widget_class_bind_template_child (widget_class, AdwTab, drop_target);
   gtk_widget_class_bind_template_callback (widget_class, close_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, indicator_clicked_cb);
+  gtk_widget_class_bind_template_callback (widget_class, enter_cb);
   gtk_widget_class_bind_template_callback (widget_class, motion_cb);
   gtk_widget_class_bind_template_callback (widget_class, leave_cb);
   gtk_widget_class_bind_template_callback (widget_class, drop_cb);
diff --git a/src/adw-tab.ui b/src/adw-tab.ui
index 9e868cd6..7364b303 100644
--- a/src/adw-tab.ui
+++ b/src/adw-tab.ui
@@ -6,6 +6,7 @@
     <property name="overflow">hidden</property>
     <child>
       <object class="GtkEventControllerMotion">
+        <signal name="enter" handler="enter_cb" swapped="true"/>
         <signal name="motion" handler="motion_cb" swapped="true"/>
         <signal name="leave" handler="leave_cb" swapped="true"/>
       </object>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]