[gnome-builder] command-bar: attach command to object graph
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] command-bar: attach command to object graph
- Date: Sun, 4 Aug 2019 23:20:33 +0000 (UTC)
commit 5482fc9ebd59ee9b375bf14fbbfa5d459ed0f07b
Author: Christian Hergert <chergert redhat com>
Date: Sun Aug 4 16:20:24 2019 -0700
command-bar: attach command to object graph
We want to give the command access to the object graph when running, so
this takes care of that and destroys it afterwards.
src/plugins/command-bar/gbp-command-bar.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/command-bar/gbp-command-bar.c b/src/plugins/command-bar/gbp-command-bar.c
index 39a330a2e..bb54613fe 100644
--- a/src/plugins/command-bar/gbp-command-bar.c
+++ b/src/plugins/command-bar/gbp-command-bar.c
@@ -164,6 +164,24 @@ gbp_command_bar_child_revealed_cb (GbpCommandBar *self,
gtk_widget_hide (GTK_WIDGET (self));
}
+static void
+gbp_command_bar_run_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ IdeCommand *command = (IdeCommand *)object;
+ g_autoptr(GError) error = NULL;
+
+ g_assert (IDE_IS_COMMAND (command));
+ g_assert (G_IS_ASYNC_RESULT (result));
+ g_assert (user_data == NULL);
+
+ if (!ide_command_run_finish (command, result, &error))
+ ide_object_warning (command, "%s", error->message);
+
+ ide_object_destroy (IDE_OBJECT (command));
+}
+
static void
gbp_command_bar_activate_suggestion_cb (GbpCommandBar *self,
DzlSuggestionEntry *entry)
@@ -177,8 +195,12 @@ gbp_command_bar_activate_suggestion_cb (GbpCommandBar *self,
{
GbpCommandBarSuggestion *cbs = GBP_COMMAND_BAR_SUGGESTION (suggestion);
IdeCommand *command = gbp_command_bar_suggestion_get_command (cbs);
+ IdeContext *context = ide_widget_get_context (GTK_WIDGET (entry));
+
+ if (ide_object_is_root (IDE_OBJECT (command)))
+ ide_object_append (IDE_OBJECT (context), IDE_OBJECT (command));
- ide_command_run_async (command, NULL, NULL, NULL);
+ ide_command_run_async (command, NULL, gbp_command_bar_run_cb, NULL);
}
gbp_command_bar_dismiss (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]