[gtk/stack-fixes] stack switcher: Don't allow unselection



commit 98040d8698dfd88490baf7aa0863f10fe1c16cd5
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 9 22:37:03 2019 -0500

    stack switcher: Don't allow unselection
    
    When the button is toggled off, we need to keep it
    selected.

 gtk/gtkstackswitcher.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index e7e8e8353e..354983cf71 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -108,16 +108,20 @@ on_button_toggled (GtkWidget        *button,
 {
   GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (self);
   gboolean active;
+  guint index;
 
   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+  index = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "child-index"));
 
   if (active)
     {
-      guint index;
-
-      index = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "child-index"));
       gtk_selection_model_select_item (priv->pages, index, TRUE);
     }
+  else
+    {
+      gboolean selected = gtk_selection_model_is_selected (priv->pages, index);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), selected);
+    }
 }
 
 static void


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