[gnome-builder] libide/tweaks: implement basic navigate_to implementation
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/tweaks: implement basic navigate_to implementation
- Date: Sun, 21 Aug 2022 17:39:06 +0000 (UTC)
commit 5f9edcdef0355151cf126d7437ce9d264e3b0d88
Author: Christian Hergert <chergert redhat com>
Date: Fri Aug 19 23:38:15 2022 -0700
libide/tweaks: implement basic navigate_to implementation
Limited to the current panel list, but it's a start.
src/libide/tweaks/ide-tweaks-panel-list-private.h | 2 ++
src/libide/tweaks/ide-tweaks-panel-list.c | 26 +++++++++++++++++++++++
src/libide/tweaks/ide-tweaks-window.c | 12 ++++++++++-
3 files changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-panel-list-private.h
b/src/libide/tweaks/ide-tweaks-panel-list-private.h
index 74cd43783..68e0d2daa 100644
--- a/src/libide/tweaks/ide-tweaks-panel-list-private.h
+++ b/src/libide/tweaks/ide-tweaks-panel-list-private.h
@@ -33,6 +33,8 @@ G_DECLARE_FINAL_TYPE (IdeTweaksPanelList, ide_tweaks_panel_list, IDE, TWEAKS_PAN
GtkWidget *ide_tweaks_panel_list_new (IdeTweaksItem *item);
IdeTweaksItem *ide_tweaks_panel_list_get_item (IdeTweaksPanelList *self);
void ide_tweaks_panel_list_select_first (IdeTweaksPanelList *self);
+void ide_tweaks_panel_list_select_item (IdeTweaksPanelList *self,
+ IdeTweaksItem *item);
gboolean ide_tweaks_panel_list_get_search_mode (IdeTweaksPanelList *self);
void ide_tweaks_panel_list_set_search_mode (IdeTweaksPanelList *self,
gboolean search_mode);
diff --git a/src/libide/tweaks/ide-tweaks-panel-list.c b/src/libide/tweaks/ide-tweaks-panel-list.c
index 4dae8dc46..ca6d34b13 100644
--- a/src/libide/tweaks/ide-tweaks-panel-list.c
+++ b/src/libide/tweaks/ide-tweaks-panel-list.c
@@ -388,6 +388,32 @@ ide_tweaks_panel_list_select_first (IdeTweaksPanelList *self)
}
}
+void
+ide_tweaks_panel_list_select_item (IdeTweaksPanelList *self,
+ IdeTweaksItem *item)
+{
+ g_return_if_fail (IDE_IS_TWEAKS_PANEL_LIST (self));
+ g_return_if_fail (IDE_IS_TWEAKS_ITEM (item));
+
+ for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (self->list_box));
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ {
+ IdeTweaksPanelListRow *row;
+
+ if (!IDE_IS_TWEAKS_PANEL_LIST_ROW (child))
+ continue;
+
+ row = IDE_TWEAKS_PANEL_LIST_ROW (child);
+
+ if (item == ide_tweaks_panel_list_row_get_item (row))
+ {
+ gtk_widget_activate (child);
+ break;
+ }
+ }
+}
+
gboolean
ide_tweaks_panel_list_get_search_mode (IdeTweaksPanelList *self)
{
diff --git a/src/libide/tweaks/ide-tweaks-window.c b/src/libide/tweaks/ide-tweaks-window.c
index 0ee0b9059..282ae6a51 100644
--- a/src/libide/tweaks/ide-tweaks-window.c
+++ b/src/libide/tweaks/ide-tweaks-window.c
@@ -648,15 +648,25 @@ void
ide_tweaks_window_navigate_to (IdeTweaksWindow *self,
IdeTweaksItem *item)
{
+ IdeTweaksPanelList *list;
+
g_return_if_fail (IDE_IS_TWEAKS_WINDOW (self));
g_return_if_fail (!item || IDE_IS_TWEAKS_ITEM (item));
if (item == NULL)
item = IDE_TWEAKS_ITEM (self->tweaks);
- if (item == NULL)
+ if (!IDE_IS_TWEAKS_PAGE (item))
+ return;
+
+ /* We can only navigate to this page if it's in the current stack. To
+ * support beyond that would require walking up the stack and pushing
+ * each page into new panel lists.
+ */
+ if (!(list = ide_tweaks_window_get_current_list (self)))
return;
+ ide_tweaks_panel_list_select_item (list, item);
}
static IdeTweaksPanelList *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]