[gnome-builder] libide/core: add ide_action_muxer_get_group()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/core: add ide_action_muxer_get_group()
- Date: Wed, 27 Jul 2022 01:56:55 +0000 (UTC)
commit 35fb1e67066f2c6f4298b380b9ee0eb0b1eacc41
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 26 18:02:28 2022 -0700
libide/core: add ide_action_muxer_get_group()
This is nice from a readback perspective.
src/libide/core/ide-action-muxer.c | 34 ++++++++++++++++++++++++++++++++++
src/libide/core/ide-action-muxer.h | 3 +++
2 files changed, 37 insertions(+)
---
diff --git a/src/libide/core/ide-action-muxer.c b/src/libide/core/ide-action-muxer.c
index 558fcff8c..0ffd5a6b2 100644
--- a/src/libide/core/ide-action-muxer.c
+++ b/src/libide/core/ide-action-muxer.c
@@ -350,6 +350,40 @@ ide_action_muxer_remove_action_group (IdeActionMuxer *self,
ide_action_muxer_insert_action_group (self, prefix, NULL);
}
+/**
+ * ide_action_muxer_get_action_group:
+ * @self: a #IdeActionMuxer
+ * @prefix: the name of the inserted action group
+ *
+ * Locates the #GActionGroup inserted as @prefix.
+ *
+ * If no group was found matching @group, %NULL is returned.
+ *
+ * Returns: (transfer none) (nullable): a #GActionGroup matching @prefix if
+ * found, otherwise %NULL.
+ */
+GActionGroup *
+ide_action_muxer_get_action_group (IdeActionMuxer *self,
+ const char *prefix)
+{
+ g_autofree char *prefix_dot = NULL;
+
+ g_return_val_if_fail (IDE_IS_ACTION_MUXER (self), NULL);
+ g_return_val_if_fail (prefix!= NULL, NULL);
+
+ prefix_dot = g_strconcat (prefix, ".", NULL);
+
+ for (guint i = 0; i < self->action_groups->len; i++)
+ {
+ const PrefixedActionGroup *pag = g_ptr_array_index (self->action_groups, i);
+
+ if (g_strcmp0 (pag->prefix, prefix_dot) == 0)
+ return pag->action_group;
+ }
+
+ return NULL;
+}
+
static gboolean
ide_action_muxer_has_action (GActionGroup *group,
const char *action_name)
diff --git a/src/libide/core/ide-action-muxer.h b/src/libide/core/ide-action-muxer.h
index 2cf5c284c..0f95ce538 100644
--- a/src/libide/core/ide-action-muxer.h
+++ b/src/libide/core/ide-action-muxer.h
@@ -42,5 +42,8 @@ void ide_action_muxer_remove_action_group (IdeActionMuxer *self,
const char *prefix);
IDE_AVAILABLE_IN_ALL
char **ide_action_muxer_list_groups (IdeActionMuxer *self);
+IDE_AVAILABLE_IN_ALL
+GActionGroup *ide_action_muxer_get_action_group (IdeActionMuxer *self,
+ const char *prefix);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]