[gnome-builder] plugins/symbol-tree: add helper to get underlying tree model
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/symbol-tree: add helper to get underlying tree model
- Date: Tue, 19 Jul 2022 22:29:33 +0000 (UTC)
commit 406d91ce5db75c6d22ca6bb498462fb5ec8a328a
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 19 14:29:09 2022 -0700
plugins/symbol-tree: add helper to get underlying tree model
This can be useful so that we can use the tree model from other locations
for things like symbol search via global search (ctrl+enter) rather than
the symbol tree (ctrl+shift+k).
src/plugins/symbol-tree/gbp-symbol-popover.c | 15 +++++++++++++++
src/plugins/symbol-tree/gbp-symbol-popover.h | 1 +
src/plugins/symbol-tree/gbp-symbol-workspace-addin.c | 11 +++++++++++
src/plugins/symbol-tree/gbp-symbol-workspace-addin.h | 2 ++
4 files changed, 29 insertions(+)
---
diff --git a/src/plugins/symbol-tree/gbp-symbol-popover.c b/src/plugins/symbol-tree/gbp-symbol-popover.c
index 87c231f37..cceb8c87b 100644
--- a/src/plugins/symbol-tree/gbp-symbol-popover.c
+++ b/src/plugins/symbol-tree/gbp-symbol-popover.c
@@ -431,3 +431,18 @@ gbp_symbol_popover_set_symbol_tree (GbpSymbolPopover *self,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SYMBOL_TREE]);
}
}
+
+GListModel *
+gbp_symbol_popover_get_model (GbpSymbolPopover *self)
+{
+ GtkSelectionModel *selection;
+
+ g_return_val_if_fail (GBP_IS_SYMBOL_POPOVER (self), NULL);
+
+ if (self->list_view == NULL ||
+ !(selection = gtk_list_view_get_model (self->list_view)) ||
+ !GTK_IS_SINGLE_SELECTION (selection))
+ return NULL;
+
+ return gtk_single_selection_get_model (GTK_SINGLE_SELECTION (selection));
+}
diff --git a/src/plugins/symbol-tree/gbp-symbol-popover.h b/src/plugins/symbol-tree/gbp-symbol-popover.h
index 3ccb30074..600d6dc99 100644
--- a/src/plugins/symbol-tree/gbp-symbol-popover.h
+++ b/src/plugins/symbol-tree/gbp-symbol-popover.h
@@ -34,5 +34,6 @@ GtkWidget *gbp_symbol_popover_new (void);
IdeSymbolTree *gbp_symbol_popover_get_symbol_tree (GbpSymbolPopover *self);
void gbp_symbol_popover_set_symbol_tree (GbpSymbolPopover *self,
IdeSymbolTree *symbol_tree);
+GListModel *gbp_symbol_popover_get_model (GbpSymbolPopover *self);
G_END_DECLS
diff --git a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
index 1d99a5a44..cfb9d78db 100644
--- a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
+++ b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
@@ -473,3 +473,14 @@ gbp_symbol_workspace_addin_init (GbpSymbolWorkspaceAddin *self)
G_CONNECT_SWAPPED);
}
+
+GListModel *
+gbp_symbol_workspace_addin_get_model (GbpSymbolWorkspaceAddin *self)
+{
+ g_return_val_if_fail (GBP_IS_SYMBOL_WORKSPACE_ADDIN (self), NULL);
+
+ if (self->popover == NULL)
+ return NULL;
+
+ return gbp_symbol_popover_get_model (self->popover);
+}
diff --git a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.h
b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.h
index e0cd9e580..977b1702f 100644
--- a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.h
+++ b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.h
@@ -28,4 +28,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpSymbolWorkspaceAddin, gbp_symbol_workspace_addin, GBP, SYMBOL_WORKSPACE_ADDIN,
GObject)
+GListModel *gbp_symbol_workspace_addin_get_model (GbpSymbolWorkspaceAddin *self);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]