[libadwaita] action-row: Disallow activating row if activatable-widget is insensitive



commit df8e714aae22745979bd4a5c2873b15640b7d275
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Fri Feb 11 16:04:31 2022 +0530

    action-row: Disallow activating row if activatable-widget is insensitive
    
    If the contained activatable widget is insensitive, disallow activating the
    row.  It's a bit confusing when the row is activatable and no action is
    performed on row activate with the activatable widget insensitive.

 src/adw-action-row.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/adw-action-row.c b/src/adw-action-row.c
index 54d0ad86..c6acc5dc 100644
--- a/src/adw-action-row.c
+++ b/src/adw-action-row.c
@@ -65,6 +65,7 @@ typedef struct
   int title_lines;
   int subtitle_lines;
   GtkWidget *activatable_widget;
+  GBinding  *activatable_binding;
 } AdwActionRowPrivate;
 
 static void adw_action_row_buildable_init (GtkBuildableIface *iface);
@@ -550,6 +551,15 @@ adw_action_row_set_activatable_widget (AdwActionRow *self,
   if (priv->activatable_widget == widget)
     return;
 
+  g_clear_pointer (&priv->activatable_binding, g_binding_unbind);
+
+  if (widget) {
+    priv->activatable_binding = g_object_bind_property (widget, "sensitive",
+                                                        self, "activatable",
+                                                        G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+    g_object_ref (priv->activatable_binding);
+  }
+
   if (priv->activatable_widget)
     g_object_weak_unref (G_OBJECT (priv->activatable_widget),
                          activatable_widget_weak_notify,


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