[gnome-builder] libide/core: attach IdeActionMuxer to context
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/core: attach IdeActionMuxer to context
- Date: Wed, 27 Jul 2022 00:15:43 +0000 (UTC)
commit 98652f293ce1bd18fd5183d77d3c0ea77348cba9
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 26 16:50:44 2022 -0700
libide/core: attach IdeActionMuxer to context
The goal here is for us to be able to have a joined muxer for a lot of
things within the project context that would otherwise be annoying to
connect and maintain everywhere.
src/libide/core/ide-context.c | 32 ++++++++++++++++++++
src/libide/core/ide-context.h | 69 ++++++++++++++++++++++---------------------
src/libide/core/libide-core.h | 1 +
src/libide/core/meson.build | 4 +--
4 files changed, 71 insertions(+), 35 deletions(-)
---
diff --git a/src/libide/core/ide-context.c b/src/libide/core/ide-context.c
index 18f0a24ad..2f15f48ed 100644
--- a/src/libide/core/ide-context.c
+++ b/src/libide/core/ide-context.c
@@ -46,6 +46,7 @@ struct _IdeContext
char *project_id;
char *title;
GFile *workdir;
+ IdeActionMuxer *action_muxer;
guint project_loaded : 1;
};
@@ -94,6 +95,13 @@ ide_context_destroy (IdeObject *object)
g_assert (IDE_IS_OBJECT (object));
+ if (self->action_muxer)
+ {
+ g_auto(GStrv) groups = ide_action_muxer_list_groups (self->action_muxer);
+
+ for (guint i = 0; groups[i]; i++)
+ ide_action_muxer_remove_action_group (self->action_muxer, groups[i]);
+ }
IDE_OBJECT_CLASS (ide_context_parent_class)->destroy (object);
}
@@ -103,6 +111,7 @@ ide_context_finalize (GObject *object)
{
IdeContext *self = (IdeContext *)object;
+ g_clear_object (&self->action_muxer);
g_clear_object (&self->workdir);
g_clear_pointer (&self->project_id, g_free);
g_clear_pointer (&self->title, g_free);
@@ -258,6 +267,7 @@ ide_context_init (IdeContext *self)
self->workdir = g_file_new_for_path (g_get_home_dir ());
self->project_id = g_strdup ("empty");
self->title = g_strdup (_("Untitled"));
+ self->action_muxer = ide_action_muxer_new ();
notifs = ide_notifications_new ();
ide_object_append (IDE_OBJECT (self), IDE_OBJECT (notifs));
@@ -729,3 +739,25 @@ _ide_context_set_has_project (IdeContext *self)
self->project_loaded = TRUE;
ide_object_unlock (IDE_OBJECT (self));
}
+
+/**
+ * ide_context_ref_action_muxer:
+ * @self: a #IdeContext
+ *
+ * Gets the action muxer for the context.
+ *
+ * Returns: (transfer full): an #IdeActionMuxer
+ */
+IdeActionMuxer *
+ide_context_ref_action_muxer (IdeContext *self)
+{
+ IdeActionMuxer *ret = NULL;
+
+ g_return_val_if_fail (IDE_IS_CONTEXT (self), NULL);
+
+ ide_object_lock (IDE_OBJECT (self));
+ g_set_object (&ret, self->action_muxer);
+ ide_object_unlock (IDE_OBJECT (self));
+
+ return g_steal_pointer (&ret);
+}
diff --git a/src/libide/core/ide-context.h b/src/libide/core/ide-context.h
index 40e10bc03..f6ce820f8 100644
--- a/src/libide/core/ide-context.h
+++ b/src/libide/core/ide-context.h
@@ -24,6 +24,7 @@
# error "Only <libide-core.h> can be included directly."
#endif
+#include "ide-action-muxer.h"
#include "ide-object.h"
G_BEGIN_DECLS
@@ -34,56 +35,58 @@ IDE_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (IdeContext, ide_context, IDE, CONTEXT, IdeObject)
IDE_AVAILABLE_IN_ALL
-IdeContext *ide_context_new (void);
+IdeContext *ide_context_new (void);
IDE_AVAILABLE_IN_ALL
-gboolean ide_context_has_project (IdeContext *self);
+gboolean ide_context_has_project (IdeContext *self);
IDE_AVAILABLE_IN_ALL
-gpointer ide_context_peek_child_typed (IdeContext *self,
- GType type);
+gpointer ide_context_peek_child_typed (IdeContext *self,
+ GType type);
IDE_AVAILABLE_IN_ALL
-gchar *ide_context_dup_project_id (IdeContext *self);
+gchar *ide_context_dup_project_id (IdeContext *self);
IDE_AVAILABLE_IN_ALL
-void ide_context_set_project_id (IdeContext *self,
- const gchar *project_id);
+void ide_context_set_project_id (IdeContext *self,
+ const gchar *project_id);
IDE_AVAILABLE_IN_ALL
-gchar *ide_context_dup_title (IdeContext *self);
+gchar *ide_context_dup_title (IdeContext *self);
IDE_AVAILABLE_IN_ALL
-void ide_context_set_title (IdeContext *self,
- const gchar *title);
+void ide_context_set_title (IdeContext *self,
+ const gchar *title);
IDE_AVAILABLE_IN_ALL
-GFile *ide_context_ref_workdir (IdeContext *self);
+GFile *ide_context_ref_workdir (IdeContext *self);
IDE_AVAILABLE_IN_ALL
-void ide_context_set_workdir (IdeContext *self,
- GFile *workdir);
+void ide_context_set_workdir (IdeContext *self,
+ GFile *workdir);
IDE_AVAILABLE_IN_ALL
-GFile *ide_context_build_file (IdeContext *self,
- const gchar *path);
+GFile *ide_context_build_file (IdeContext *self,
+ const gchar *path);
IDE_AVAILABLE_IN_ALL
-gchar *ide_context_build_filename (IdeContext *self,
- const gchar *first_part,
- ...) G_GNUC_NULL_TERMINATED;
+gchar *ide_context_build_filename (IdeContext *self,
+ const gchar *first_part,
+ ...) G_GNUC_NULL_TERMINATED;
IDE_AVAILABLE_IN_ALL
-GFile *ide_context_cache_file (IdeContext *self,
- const gchar *first_part,
- ...) G_GNUC_NULL_TERMINATED;
+GFile *ide_context_cache_file (IdeContext *self,
+ const gchar *first_part,
+ ...) G_GNUC_NULL_TERMINATED;
IDE_AVAILABLE_IN_ALL
-gchar *ide_context_cache_filename (IdeContext *self,
- const gchar *first_part,
- ...) G_GNUC_NULL_TERMINATED;
+gchar *ide_context_cache_filename (IdeContext *self,
+ const gchar *first_part,
+ ...) G_GNUC_NULL_TERMINATED;
IDE_AVAILABLE_IN_ALL
-GSettings *ide_context_ref_project_settings (IdeContext *self);
+GSettings *ide_context_ref_project_settings (IdeContext *self);
IDE_AVAILABLE_IN_ALL
-IdeContext *ide_object_ref_context (IdeObject *self);
+IdeContext *ide_object_ref_context (IdeObject *self);
IDE_AVAILABLE_IN_ALL
-IdeContext *ide_object_get_context (IdeObject *object);
+IdeContext *ide_object_get_context (IdeObject *object);
IDE_AVAILABLE_IN_ALL
-void ide_object_set_context (IdeObject *object,
- IdeContext *context);
+void ide_object_set_context (IdeObject *object,
+ IdeContext *context);
IDE_AVAILABLE_IN_ALL
-void ide_context_log (IdeContext *self,
- GLogLevelFlags level,
- const gchar *domain,
- const gchar *message);
+void ide_context_log (IdeContext *self,
+ GLogLevelFlags level,
+ const gchar *domain,
+ const gchar *message);
+IDE_AVAILABLE_IN_ALL
+IdeActionMuxer *ide_context_ref_action_muxer (IdeContext *self);
#ifdef __cplusplus
#define ide_context_warning(instance, format, ...) \
diff --git a/src/libide/core/libide-core.h b/src/libide/core/libide-core.h
index 4b6eb004f..4164256b8 100644
--- a/src/libide/core/libide-core.h
+++ b/src/libide/core/libide-core.h
@@ -25,6 +25,7 @@
#define IDE_CORE_INSIDE
#include "ide-action-group.h"
+#include "ide-action-muxer.h"
#include "ide-binding-group.h"
#include "ide-context.h"
#include "ide-debug.h"
diff --git a/src/libide/core/meson.build b/src/libide/core/meson.build
index 8f2ca16ab..f4859b3bc 100644
--- a/src/libide/core/meson.build
+++ b/src/libide/core/meson.build
@@ -53,6 +53,7 @@ libide_core_generated_headers += [libide_debug_h]
#
libide_core_public_headers = [
+ 'ide-action-muxer.h',
'ide-action-group.h',
'ide-binding-group.h',
'ide-context.h',
@@ -73,7 +74,6 @@ libide_core_public_headers = [
]
libide_core_private_headers = [
- 'ide-action-muxer.h',
'ide-layered-settings-private.h',
'ide-transfer-manager-private.h',
]
@@ -85,6 +85,7 @@ install_headers(libide_core_public_headers, subdir: libide_core_header_subdir)
#
libide_core_public_sources = [
+ 'ide-action-muxer.c',
'ide-binding-group.c',
'ide-context.c',
'ide-global.c',
@@ -102,7 +103,6 @@ libide_core_public_sources = [
]
libide_core_private_sources = [
- 'ide-action-muxer.c',
'ide-layered-settings.c',
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]