[gnome-builder] libide/tweaks: select first row after loading



commit d5383ad89ac343ba5850665354b1edce38c29529
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 2 21:25:26 2022 -0700

    libide/tweaks: select first row after loading

 src/libide/tweaks/ide-tweaks-panel-list-private.h |  9 +++++----
 src/libide/tweaks/ide-tweaks-panel-list.c         | 17 +++++++++++++++++
 src/libide/tweaks/ide-tweaks-window.c             |  1 +
 3 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-panel-list-private.h 
b/src/libide/tweaks/ide-tweaks-panel-list-private.h
index 75840b815..efaa3e171 100644
--- a/src/libide/tweaks/ide-tweaks-panel-list-private.h
+++ b/src/libide/tweaks/ide-tweaks-panel-list-private.h
@@ -30,9 +30,10 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (IdeTweaksPanelList, ide_tweaks_panel_list, IDE, TWEAKS_PANEL_LIST, AdwBin)
 
-GtkWidget     *ide_tweaks_panel_list_new      (void);
-IdeTweaksItem *ide_tweaks_panel_list_get_item (IdeTweaksPanelList *self);
-void           ide_tweaks_panel_list_set_item (IdeTweaksPanelList *self,
-                                               IdeTweaksItem      *item);
+GtkWidget     *ide_tweaks_panel_list_new          (void);
+IdeTweaksItem *ide_tweaks_panel_list_get_item     (IdeTweaksPanelList *self);
+void           ide_tweaks_panel_list_set_item     (IdeTweaksPanelList *self,
+                                                   IdeTweaksItem      *item);
+void           ide_tweaks_panel_list_select_first (IdeTweaksPanelList *self);
 
 G_END_DECLS
diff --git a/src/libide/tweaks/ide-tweaks-panel-list.c b/src/libide/tweaks/ide-tweaks-panel-list.c
index d0a72fa37..30ebeec44 100644
--- a/src/libide/tweaks/ide-tweaks-panel-list.c
+++ b/src/libide/tweaks/ide-tweaks-panel-list.c
@@ -226,3 +226,20 @@ ide_tweaks_panel_list_set_item (IdeTweaksPanelList *self,
       g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ITEM]);
     }
 }
+
+void
+ide_tweaks_panel_list_select_first (IdeTweaksPanelList *self)
+{
+  g_return_if_fail (IDE_IS_TWEAKS_PANEL_LIST (self));
+
+  for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->list_box));
+       child != NULL;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      if (GTK_IS_LIST_BOX_ROW (child))
+        {
+          gtk_widget_activate (GTK_WIDGET (child));
+          break;
+        }
+    }
+}
diff --git a/src/libide/tweaks/ide-tweaks-window.c b/src/libide/tweaks/ide-tweaks-window.c
index 10aa8e09e..89c2690af 100644
--- a/src/libide/tweaks/ide-tweaks-window.c
+++ b/src/libide/tweaks/ide-tweaks-window.c
@@ -75,6 +75,7 @@ ide_tweaks_window_rebuild (IdeTweaksWindow *self)
   gtk_stack_add_named (self->panel_list_stack,
                        list,
                        ide_tweaks_item_get_id (IDE_TWEAKS_ITEM (self->tweaks)));
+  ide_tweaks_panel_list_select_first (IDE_TWEAKS_PANEL_LIST (list));
 }
 
 static void


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