[gnome-builder] start on build command
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] start on build command
- Date: Tue, 24 Mar 2015 00:30:38 +0000 (UTC)
commit 36c66af6a9b63b011f78d85f7def71ee26aea38a
Author: Christian Hergert <christian hergert me>
Date: Fri Mar 20 02:45:47 2015 -0700
start on build command
src/app/gb-application.c | 12 +++++
src/workbench/gb-workbench-actions.c | 80 ++++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+), 0 deletions(-)
---
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index fc19763..08639a8 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -306,6 +306,18 @@ gb_application__context_new_cb (GObject *object,
goto cleanup;
}
+ {
+ IdeVcs *vcs;
+ GFile *workdir;
+ g_autofree gchar *path = NULL;
+
+ vcs = ide_context_get_vcs (context);
+ workdir = ide_vcs_get_working_directory (vcs);
+ path = g_file_get_path (workdir);
+
+ g_debug ("Project working directory: %s", path);
+ }
+
bufmgr = ide_context_get_buffer_manager (context);
g_signal_connect (bufmgr, "create-buffer", G_CALLBACK (on_create_buffer), NULL);
diff --git a/src/workbench/gb-workbench-actions.c b/src/workbench/gb-workbench-actions.c
index 0ee68ca..2c17193 100644
--- a/src/workbench/gb-workbench-actions.c
+++ b/src/workbench/gb-workbench-actions.c
@@ -18,15 +18,95 @@
#define G_LOG_DOMAIN "gb-workbench-actions"
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
#include "gb-workbench.h"
#include "gb-workbench-actions.h"
#include "gb-workbench-private.h"
static void
+gb_workbench_actions__build_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ g_autoptr(GbWorkbench) workbench = user_data;
+ g_autoptr(IdeBuildResult) build_result = NULL;
+ g_autoptr(GError) error = NULL;
+ IdeBuilder *builder = (IdeBuilder *)object;
+
+ g_assert (GB_IS_WORKBENCH (workbench));
+
+ build_result = ide_builder_build_finish (builder, result, &error);
+
+ if (error)
+ {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (workbench),
+ GTK_DIALOG_MODAL | GTK_DIALOG_USE_HEADER_BAR,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Build Failure"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_window_present (GTK_WINDOW (dialog));
+ }
+}
+
+static void
gb_workbench_actions_build (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
+ GbWorkbench *workbench = user_data;
+ IdeDeviceManager *device_manager;
+ IdeBuildSystem *build_system;
+ IdeContext *context;
+ IdeDevice *device;
+ g_autoptr(IdeBuilder) builder = NULL;
+ g_autoptr(GKeyFile) config = NULL;
+ g_autoptr(GError) error = NULL;
+
+ /*
+ * TODO: We want to have the ability to choose the device we want to build for. The simple answer
+ * here is to just have a combo of sorts to choose the target device. But that is going to be left
+ * to the designers to figure out the right way to go about it.
+ *
+ * For now, we will just automatically build with the "local" device.
+ */
+
+ g_assert (GB_IS_WORKBENCH (workbench));
+
+ context = gb_workbench_get_context (workbench);
+ device_manager = ide_context_get_device_manager (context);
+ device = ide_device_manager_get_device (device_manager, "local");
+ build_system = ide_context_get_build_system (context);
+ config = g_key_file_new ();
+ builder = ide_build_system_get_builder (build_system, config, device, &error);
+
+ if (builder == NULL)
+ {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (workbench),
+ GTK_DIALOG_MODAL | GTK_DIALOG_USE_HEADER_BAR,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Project build system does not support building"));
+ if (error && error->message)
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", error->message);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_window_present (GTK_WINDOW (dialog));
+ return;
+ }
+
+ ide_builder_build_async (builder,
+ NULL,
+ NULL, /* todo: cancellable */
+ gb_workbench_actions__build_cb,
+ g_object_ref (workbench));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]