[gnome-builder] preferences: sometimes activate when selected row changes



commit 04e91a4852954f246ad3cae86b7f042622039df7
Author: Christian Hergert <chergert redhat com>
Date:   Sat Sep 17 12:14:25 2016 -0700

    preferences: sometimes activate when selected row changes
    
    When we have a "single" selection mode and we are navigating by the
    keyboard, we need to activate the row to cause changes to occur. I'd
    prefer to do this with a selected signal on the row, but we don't have
    that and this is easy enough to do.

 libide/preferences/ide-preferences-group.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/libide/preferences/ide-preferences-group.c b/libide/preferences/ide-preferences-group.c
index 33ee796..2ab71c6 100644
--- a/libide/preferences/ide-preferences-group.c
+++ b/libide/preferences/ide-preferences-group.c
@@ -70,6 +70,21 @@ ide_preferences_group_row_activated (IdePreferencesGroup *self,
     gtk_widget_activate (child);
 }
 
+static void
+ide_preferences_group_row_selected (IdePreferencesGroup *self,
+                                    GtkListBoxRow       *row,
+                                    GtkListBox          *list_box)
+{
+  g_assert (IDE_IS_PREFERENCES_GROUP (self));
+  g_assert (!row || GTK_IS_LIST_BOX_ROW (row));
+  g_assert (GTK_IS_LIST_BOX (list_box));
+
+  if (gtk_list_box_get_selection_mode (list_box) == GTK_SELECTION_SINGLE &&
+      GTK_IS_LIST_BOX_ROW (row) &&
+      gtk_list_box_row_get_activatable (row))
+    ide_preferences_group_row_activated (self, row, list_box);
+}
+
 const gchar *
 ide_preferences_group_get_title (IdePreferencesGroup *self)
 {
@@ -251,6 +266,12 @@ ide_preferences_group_init (IdePreferencesGroup *self)
                            G_CALLBACK (ide_preferences_group_row_activated),
                            self,
                            G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (self->list_box,
+                           "row-selected",
+                           G_CALLBACK (ide_preferences_group_row_selected),
+                           self,
+                           G_CONNECT_SWAPPED);
 }
 
 void


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