[gnome-builder] context: add ide_context_message()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] context: add ide_context_message()
- Date: Sat, 6 Jan 2018 05:04:41 +0000 (UTC)
commit 17d094a46711324cb08228a0fec69e0c63d0ba21
Author: Christian Hergert <chergert redhat com>
Date: Fri Jan 5 21:02:01 2018 -0800
context: add ide_context_message()
This is similar to ide_context_message() but for non error-like
messages.
src/libide/ide-context.c | 40 ++++++++++++++++++++++++++++++++++++++++
src/libide/ide-context.h | 4 ++++
2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/src/libide/ide-context.c b/src/libide/ide-context.c
index 3e5c4d3..4e73408 100644
--- a/src/libide/ide-context.c
+++ b/src/libide/ide-context.c
@@ -2346,6 +2346,46 @@ ide_context_get_configuration_manager (IdeContext *self)
}
/**
+ * ide_context_message:
+ * @self: a #IdeContext
+ * @format: a printf style format
+ * @...: parameters for @format
+ *
+ * Emits a log message for the context, which is useful so that
+ * messages may be displayed to the user in the workbench window.
+ *
+ * Thread-safety: you may call this from any thread, so long as the thread
+ * owns a reference to the context.
+ *
+ * Since: 3.28
+ */
+void
+ide_context_message (IdeContext *self,
+ const gchar *format,
+ ...)
+{
+ g_return_if_fail (IDE_IS_CONTEXT (self));
+ g_return_if_fail (format != NULL);
+
+ /*
+ * This may be called from a thread, so we proxy the message
+ * to the main thread using IdeBuildLog.
+ */
+
+ if (self->log != NULL)
+ {
+ g_autofree gchar *str = NULL;
+ va_list args;
+
+ va_start (args, format);
+ str = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ ide_build_log_observer (IDE_BUILD_LOG_STDOUT, str, -1, self->log);
+ }
+}
+
+/**
* ide_context_warning:
* @self: a #IdeContext
* @format: a printf style format
diff --git a/src/libide/ide-context.h b/src/libide/ide-context.h
index 147a121..cac30f3 100644
--- a/src/libide/ide-context.h
+++ b/src/libide/ide-context.h
@@ -114,6 +114,10 @@ void ide_context_hold_for_object (IdeContext
gpointer instance);
IDE_AVAILABLE_IN_ALL
void ide_context_release (IdeContext *self);
+IDE_AVAILABLE_IN_3_28
+void ide_context_message (IdeContext *self,
+ const gchar *format,
+ ...) G_GNUC_PRINTF (2, 3);
IDE_AVAILABLE_IN_ALL
void ide_context_warning (IdeContext *self,
const gchar *format,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]