listitem: Add a backwards compatibility workaround
authorBenjamin Otte <otte@redhat.com>
Sun, 26 Mar 2023 18:51:27 +0000 (20:51 +0200)
committerBenjamin Otte <otte@redhat.com>
Sat, 1 Apr 2023 18:49:40 +0000 (20:49 +0200)
I want to avoid turning the :focusable property into a tristate at all
costs, but that third state is what we had before the property.

gtk/gtklistitem.c
gtk/gtklistitemprivate.h

index 7aed3f410d66f7d00ac2ba03920989bc2f89ae38..59f450f97b3f2857b3d418359b04ad4ed57d78d0 100644 (file)
@@ -337,6 +337,12 @@ gtk_list_item_set_child (GtkListItem *self,
     {
       g_object_ref_sink (child);
       self->child = child;
+
+      /* Workaround that hopefully achieves good enough backwards
+       * compatibility with people using expanders.
+       */
+      if (!self->focusable_set)
+        gtk_list_item_set_focusable (self, !gtk_widget_get_focusable (child));
     }
 
   if (self->owner)
@@ -533,6 +539,8 @@ gtk_list_item_set_focusable (GtkListItem *self,
 {
   g_return_if_fail (GTK_IS_LIST_ITEM (self));
 
+  self->focusable_set = TRUE;
+
   if (self->focusable == focusable)
     return;
 
index 28ab8b5d63e9378f0904df0b72bfcdd232287259..99adbeee4c1477013c2c3608ab1c8934213b90b7 100644 (file)
@@ -22,6 +22,7 @@
 #include "gtklistitem.h"
 
 #include "gtklistitemwidgetprivate.h"
+#include "gtkversion.h"
 
 G_BEGIN_DECLS
 
@@ -36,6 +37,9 @@ struct _GtkListItem
   guint activatable : 1;
   guint selectable : 1;
   guint focusable : 1;
+#if !GTK_CHECK_VERSION (5, 0, 0)
+  guint focusable_set : 1;
+#endif
 };
 
 GtkListItem *   gtk_list_item_new                               (void);