[libadwaita/wip/exalm/dropdown-style: 1/5] combo-row: Have .has-open-popup style class as appropriate




commit 5cf3c63bce56c2c468b078b5748e64b1e118c000
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Oct 18 18:37:05 2021 +0500

    combo-row: Have .has-open-popup style class as appropriate

 src/adw-combo-row.c  | 12 ++++++++++++
 src/adw-combo-row.ui |  1 +
 2 files changed, 13 insertions(+)
---
diff --git a/src/adw-combo-row.c b/src/adw-combo-row.c
index 4bd31bb6..5a127e46 100644
--- a/src/adw-combo-row.c
+++ b/src/adw-combo-row.c
@@ -150,6 +150,17 @@ row_activated_cb (AdwComboRow *self)
   adw_combo_row_set_selected (self, gtk_single_selection_get_selected (GTK_SINGLE_SELECTION 
(priv->popup_selection)));
 }
 
+static void
+notify_popover_visible_cb (AdwComboRow *self)
+{
+  AdwComboRowPrivate *priv = adw_combo_row_get_instance_private (self);
+
+  if (gtk_widget_get_visible (GTK_WIDGET (priv->popover)))
+    gtk_widget_add_css_class (GTK_WIDGET (self), "has-open-popup");
+  else
+    gtk_widget_remove_css_class (GTK_WIDGET (self), "has-open-popup");
+}
+
 static void
 adw_combo_row_activate (AdwActionRow *row)
 {
@@ -517,6 +528,7 @@ adw_combo_row_class_init (AdwComboRowClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, AdwComboRow, list);
   gtk_widget_class_bind_template_child_private (widget_class, AdwComboRow, popover);
   gtk_widget_class_bind_template_callback (widget_class, row_activated_cb);
+  gtk_widget_class_bind_template_callback (widget_class, notify_popover_visible_cb);
 
   gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_COMBO_BOX);
 }
diff --git a/src/adw-combo-row.ui b/src/adw-combo-row.ui
index 29760efc..2e2ef1e1 100644
--- a/src/adw-combo-row.ui
+++ b/src/adw-combo-row.ui
@@ -29,6 +29,7 @@
         </child>
         <child>
           <object class="GtkPopover" id="popover">
+            <signal name="notify::visible" handler="notify_popover_visible_cb" swapped="true"/>
             <style>
               <class name="combo"/>
             </style>


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