[gnome-builder/wip/akskil/create-project: 30/30] create-project: stub out genesis addin for creating a project



commit f164b93222b8457dd658fe0f6c8812c1133307df
Author: Christian Hergert <christian hergert me>
Date:   Tue Mar 1 01:40:51 2016 -0800

    create-project: stub out genesis addin for creating a project

 plugins/create-project/Makefile.am                 |    4 +
 .../gbp-create-project-genesis-addin.c             |  187 ++++++++++++++++++++
 .../gbp-create-project-genesis-addin.h             |   32 ++++
 plugins/create-project/gbp-create-project-plugin.c |    4 +
 plugins/create-project/gbp-create-project-widget.c |   41 +++++
 plugins/create-project/gbp-create-project-widget.h |   32 ++++
 .../create-project/gbp-create-project-widget.ui    |   11 ++
 .../gbp-create-project.gresource.xml               |    1 +
 8 files changed, 312 insertions(+), 0 deletions(-)
---
diff --git a/plugins/create-project/Makefile.am b/plugins/create-project/Makefile.am
index 630cf56..9bf3ae3 100644
--- a/plugins/create-project/Makefile.am
+++ b/plugins/create-project/Makefile.am
@@ -10,9 +10,13 @@ plugin_LTLIBRARIES = libcreate-project-plugin.la
 dist_plugin_DATA = create-project.plugin
 
 libcreate_project_plugin_la_SOURCES = \
+       gbp-create-project-genesis-addin.c \
+       gbp-create-project-genesis-addin.h \
        gbp-create-project-plugin.c \
        gbp-create-project-tool.c \
        gbp-create-project-tool.h \
+       gbp-create-project-widget.c \
+       gbp-create-project-widget.h \
        $(NULL)
 
 nodist_libcreate_project_plugin_la_SOURCES = \
diff --git a/plugins/create-project/gbp-create-project-genesis-addin.c 
b/plugins/create-project/gbp-create-project-genesis-addin.c
new file mode 100644
index 0000000..8d51d57
--- /dev/null
+++ b/plugins/create-project/gbp-create-project-genesis-addin.c
@@ -0,0 +1,187 @@
+/* gbp-create-project-genesis-addin.c
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gbp-create-project-genesis-addin.h"
+#include "gbp-create-project-widget.h"
+
+static void genesis_addin_iface_init (IdeGenesisAddinInterface *iface);
+
+struct _GbpCreateProjectGenesisAddin
+{
+  GObject                 parent;
+
+  GbpCreateProjectWidget *widget;
+
+  guint                   is_ready : 1;
+};
+
+G_DEFINE_TYPE_EXTENDED (GbpCreateProjectGenesisAddin,
+                        gbp_create_project_genesis_addin,
+                        G_TYPE_OBJECT,
+                        0,
+                        G_IMPLEMENT_INTERFACE (IDE_TYPE_GENESIS_ADDIN,
+                                               genesis_addin_iface_init))
+
+enum {
+  PROP_0,
+  PROP_IS_READY,
+  N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+gbp_create_project_genesis_addin_finalize (GObject *object)
+{
+  GbpCreateProjectGenesisAddin *self = (GbpCreateProjectGenesisAddin *)object;
+
+  ide_clear_weak_pointer (&self->widget);
+
+  G_OBJECT_CLASS (gbp_create_project_genesis_addin_parent_class)->finalize (object);
+}
+
+static void
+gbp_create_project_genesis_addin_get_property (GObject    *object,
+                                               guint       prop_id,
+                                               GValue     *value,
+                                               GParamSpec *pspec)
+{
+  GbpCreateProjectGenesisAddin *self = GBP_CREATE_PROJECT_GENESIS_ADDIN (object);
+
+  switch (prop_id)
+    {
+    case PROP_IS_READY:
+      g_value_set_boolean (value, self->is_ready);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_create_project_genesis_addin_class_init (GbpCreateProjectGenesisAddinClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gbp_create_project_genesis_addin_finalize;
+  object_class->get_property = gbp_create_project_genesis_addin_get_property;
+
+  properties [PROP_IS_READY] =
+    g_param_spec_boolean ("is-ready",
+                          "Is Ready",
+                          "Is Ready",
+                          FALSE,
+                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+gbp_create_project_genesis_addin_init (GbpCreateProjectGenesisAddin *self)
+{
+}
+
+static GtkWidget *
+gbp_create_project_genesis_addin_get_widget (IdeGenesisAddin *addin)
+{
+  GbpCreateProjectGenesisAddin *self = (GbpCreateProjectGenesisAddin *)addin;
+
+  g_assert (GBP_IS_CREATE_PROJECT_GENESIS_ADDIN (self));
+
+  if (self->widget == NULL)
+    {
+      GbpCreateProjectWidget *widget;
+
+      widget = g_object_new (GBP_TYPE_CREATE_PROJECT_WIDGET,
+                             "visible", TRUE,
+                             NULL);
+      ide_set_weak_pointer (&self->widget, widget);
+
+      /*
+       * TODO: You need to watch for changes in the widget's entries, and when
+       *       the widget satisfies "valid input", you need to:
+       *
+       *       self->is_ready = TRUE;
+       *       g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_IS_READY]);
+       *
+       *       In the past, i've added an "is-ready" property to the widget
+       *       and just g_object_bind_property() to self. That would require
+       *       making the GbpCreateProjectGenesisAddin:is-ready property
+       *       writable though.
+       */
+    }
+
+  return GTK_WIDGET (self->widget);
+}
+
+static gchar *
+gbp_create_project_genesis_addin_get_icon_name (IdeGenesisAddin *addin)
+{
+  return g_strdup ("gtk-missing");
+}
+
+static gchar *
+gbp_create_project_genesis_addin_get_title (IdeGenesisAddin *addin)
+{
+  return g_strdup (_("From a project template"));
+}
+
+static void
+gbp_create_project_genesis_addin_run_async (IdeGenesisAddin     *addin,
+                                            GCancellable        *cancellable,
+                                            GAsyncReadyCallback  callback,
+                                            gpointer             user_data)
+{
+  GbpCreateProjectGenesisAddin *self = (GbpCreateProjectGenesisAddin *)addin;
+  g_autoptr(GTask) task = NULL;
+
+  g_assert (GBP_IS_CREATE_PROJECT_GENESIS_ADDIN (self));
+
+  task = g_task_new (self, cancellable, callback, user_data);
+
+  /*
+   * TODO: Generate the project from information found in the widget.
+   *       See gbp-create-project-tool.c for examples.
+   */
+
+  g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gbp_create_project_genesis_addin_run_finish (IdeGenesisAddin  *addin,
+                                             GAsyncResult     *result,
+                                             GError          **error)
+{
+  g_assert (GBP_IS_CREATE_PROJECT_GENESIS_ADDIN (addin));
+  g_assert (G_IS_TASK (result));
+
+  return g_task_propagate_boolean (G_TASK (result), error);
+}
+
+static void
+genesis_addin_iface_init (IdeGenesisAddinInterface *iface)
+{
+  iface->get_icon_name = gbp_create_project_genesis_addin_get_icon_name;
+  iface->get_title = gbp_create_project_genesis_addin_get_title;
+  iface->get_widget = gbp_create_project_genesis_addin_get_widget;
+  iface->run_async = gbp_create_project_genesis_addin_run_async;
+  iface->run_finish = gbp_create_project_genesis_addin_run_finish;
+}
diff --git a/plugins/create-project/gbp-create-project-genesis-addin.h 
b/plugins/create-project/gbp-create-project-genesis-addin.h
new file mode 100644
index 0000000..11fad87
--- /dev/null
+++ b/plugins/create-project/gbp-create-project-genesis-addin.h
@@ -0,0 +1,32 @@
+/* gbp-create-project-genesis-addin.h
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GBP_CREATE_PROJECT_GENESIS_ADDIN_H
+#define GBP_CREATE_PROJECT_GENESIS_ADDIN_H
+
+#include <ide.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_CREATE_PROJECT_GENESIS_ADDIN (gbp_create_project_genesis_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpCreateProjectGenesisAddin, gbp_create_project_genesis_addin, GBP, 
CREATE_PROJECT_GENESIS_ADDIN, GObject)
+
+G_END_DECLS
+
+#endif /* GBP_CREATE_PROJECT_GENESIS_ADDIN_H */
diff --git a/plugins/create-project/gbp-create-project-plugin.c 
b/plugins/create-project/gbp-create-project-plugin.c
index 70e02bb..4c5d6b8 100644
--- a/plugins/create-project/gbp-create-project-plugin.c
+++ b/plugins/create-project/gbp-create-project-plugin.c
@@ -19,6 +19,7 @@
 #include <ide.h>
 #include <libpeas/peas.h>
 
+#include "gbp-create-project-genesis-addin.h"
 #include "gbp-create-project-tool.h"
 
 void
@@ -27,4 +28,7 @@ peas_register_types (PeasObjectModule *module)
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_APPLICATION_TOOL,
                                               GBP_TYPE_CREATE_PROJECT_TOOL);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_GENESIS_ADDIN,
+                                              GBP_TYPE_CREATE_PROJECT_GENESIS_ADDIN);
 }
diff --git a/plugins/create-project/gbp-create-project-widget.c 
b/plugins/create-project/gbp-create-project-widget.c
new file mode 100644
index 0000000..90b1bff
--- /dev/null
+++ b/plugins/create-project/gbp-create-project-widget.c
@@ -0,0 +1,41 @@
+/* gbp-create-project-widget.c
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gbp-create-project-widget.h"
+
+struct _GbpCreateProjectWidget
+{
+  GtkBin parent;
+};
+
+G_DEFINE_TYPE (GbpCreateProjectWidget, gbp_create_project_widget, GTK_TYPE_BIN)
+
+static void
+gbp_create_project_widget_class_init (GbpCreateProjectWidgetClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class,
+                                               
"/org/gnome/builder/plugins/create-project-plugin/gbp-create-project-widget.ui");
+}
+
+static void
+gbp_create_project_widget_init (GbpCreateProjectWidget *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/plugins/create-project/gbp-create-project-widget.h 
b/plugins/create-project/gbp-create-project-widget.h
new file mode 100644
index 0000000..4809bbc
--- /dev/null
+++ b/plugins/create-project/gbp-create-project-widget.h
@@ -0,0 +1,32 @@
+/* gbp-create-project-widget.h
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GBP_CREATE_PROJECT_WIDGET_H
+#define GBP_CREATE_PROJECT_WIDGET_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_CREATE_PROJECT_WIDGET (gbp_create_project_widget_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpCreateProjectWidget, gbp_create_project_widget, GBP, CREATE_PROJECT_WIDGET, GtkBin)
+
+G_END_DECLS
+
+#endif /* GBP_CREATE_PROJECT_WIDGET_H */
diff --git a/plugins/create-project/gbp-create-project-widget.ui 
b/plugins/create-project/gbp-create-project-widget.ui
new file mode 100644
index 0000000..ca74c32
--- /dev/null
+++ b/plugins/create-project/gbp-create-project-widget.ui
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GbpCreateProjectWidget" parent="GtkBin">
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <property name="visible">true</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/plugins/create-project/gbp-create-project.gresource.xml 
b/plugins/create-project/gbp-create-project.gresource.xml
index 7c5c913..c54dfca 100644
--- a/plugins/create-project/gbp-create-project.gresource.xml
+++ b/plugins/create-project/gbp-create-project.gresource.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/builder/plugins/create-project-plugin">
+    <file>gbp-create-project-widget.ui</file>
   </gresource>
 </gresources>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]