[gnome-builder/wip/chergert/perspective] genesis: start on genesis addins for creating projects



commit 1a49f066a7d85b2ff1e6ab2283ec651f476420ad
Author: Christian Hergert <chergert redhat com>
Date:   Mon Nov 30 00:43:43 2015 -0800

    genesis: start on genesis addins for creating projects

 data/theme/shared.css                          |    1 +
 data/ui/ide-genesis-perspective.ui             |    3 +
 libide/Makefile.am                             |    4 +-
 libide/directory/ide-directory-genesis-addin.c |   68 +++++++++++++++++++
 libide/directory/ide-directory-genesis-addin.h |   32 +++++++++
 libide/directory/ide-directory-plugin.c        |    5 ++
 libide/genesis/ide-genesis-addin.c             |    2 +-
 libide/genesis/ide-genesis-perspective.c       |   83 ++++++++++++++++++++++++
 libide/ide.h                                   |    2 +
 plugins/git/Makefile.am                        |    2 +
 plugins/git/ide-git-genesis-addin.c            |   68 +++++++++++++++++++
 plugins/git/ide-git-genesis-addin.h            |   32 +++++++++
 plugins/git/ide-git-plugin.c                   |   10 ++-
 13 files changed, 308 insertions(+), 4 deletions(-)
---
diff --git a/data/theme/shared.css b/data/theme/shared.css
index 19049ba..ac73ec9 100644
--- a/data/theme/shared.css
+++ b/data/theme/shared.css
@@ -166,6 +166,7 @@ genesisperspective frame {
 }
 genesisperspective list row {
   border-bottom: 1px solid alpha(@borders, 0.2);
+  padding: 12px;
 }
 genesisperspective list row:last-child {
   border-bottom: none;
diff --git a/data/ui/ide-genesis-perspective.ui b/data/ui/ide-genesis-perspective.ui
index d67d102..b1eb27b 100644
--- a/data/ui/ide-genesis-perspective.ui
+++ b/data/ui/ide-genesis-perspective.ui
@@ -11,6 +11,7 @@
         <child>
           <object class="EggBox">
             <property name="halign">center</property>
+            <property name="width-request">550</property>
             <property name="max-width-request">550</property>
             <property name="valign">center</property>
             <property name="visible">true</property>
@@ -19,6 +20,8 @@
                 <property name="visible">true</property>
                 <child>
                   <object class="GtkListBox" id="list_box">
+                    <property name="hexpand">true</property>
+                    <property name="selection-mode">none</property>
                     <property name="visible">true</property>
                   </object>
                 </child>
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 6d56ffd..2e48de7 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -9,9 +9,11 @@ pkglib_LTLIBRARIES = libide-1.0.la
 libide_1_0_la_public_sources = \
        directory/ide-directory-build-system.c \
        directory/ide-directory-build-system.h \
+       directory/ide-directory-genesis-addin.c \
+       directory/ide-directory-genesis-addin.h \
+       directory/ide-directory-plugin.c \
        directory/ide-directory-vcs.c \
        directory/ide-directory-vcs.h \
-       directory/ide-directory-plugin.c \
        doap/ide-doap-person.c \
        doap/ide-doap-person.h \
        doap/ide-doap.c \
diff --git a/libide/directory/ide-directory-genesis-addin.c b/libide/directory/ide-directory-genesis-addin.c
new file mode 100644
index 0000000..67fa5d3
--- /dev/null
+++ b/libide/directory/ide-directory-genesis-addin.c
@@ -0,0 +1,68 @@
+/* ide-directory-genesis-addin.c
+ *
+ * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ *
+ * 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 "ide-directory-genesis-addin.h"
+#include "ide-genesis-addin.h"
+
+struct _IdeDirectoryGenesisAddin
+{
+  GObject parent_instance;
+};
+
+static void genesis_addin_iface_init (IdeGenesisAddinInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (IdeDirectoryGenesisAddin, ide_directory_genesis_addin, G_TYPE_OBJECT, 0,
+                        G_IMPLEMENT_INTERFACE (IDE_TYPE_GENESIS_ADDIN, genesis_addin_iface_init))
+
+static void
+ide_directory_genesis_addin_class_init (IdeDirectoryGenesisAddinClass *klass)
+{
+}
+
+static void
+ide_directory_genesis_addin_init (IdeDirectoryGenesisAddin *self)
+{
+}
+
+static gchar *
+ide_directory_genesis_addin_get_icon_name (IdeGenesisAddin *addin)
+{
+  return g_strdup ("folder-symbolic");
+}
+
+static gchar *
+ide_directory_genesis_addin_get_title (IdeGenesisAddin *addin)
+{
+  return g_strdup (_("From an existing project on this computer"));
+}
+
+static GtkWidget *
+ide_directory_genesis_addin_get_widget (IdeGenesisAddin *addin)
+{
+  return NULL;
+}
+
+static void
+genesis_addin_iface_init (IdeGenesisAddinInterface *iface)
+{
+  iface->get_title = ide_directory_genesis_addin_get_title;
+  iface->get_icon_name = ide_directory_genesis_addin_get_icon_name;
+  iface->get_widget = ide_directory_genesis_addin_get_widget;
+}
diff --git a/libide/directory/ide-directory-genesis-addin.h b/libide/directory/ide-directory-genesis-addin.h
new file mode 100644
index 0000000..a44f683
--- /dev/null
+++ b/libide/directory/ide-directory-genesis-addin.h
@@ -0,0 +1,32 @@
+/* ide-directory-genesis-addin.h
+ *
+ * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ *
+ * 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 IDE_DIRECTORY_GENESIS_ADDIN_H
+#define IDE_DIRECTORY_GENESIS_ADDIN_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_DIRECTORY_GENESIS_ADDIN (ide_directory_genesis_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeDirectoryGenesisAddin, ide_directory_genesis_addin, IDE, DIRECTORY_GENESIS_ADDIN, 
GObject)
+
+G_END_DECLS
+
+#endif /* IDE_DIRECTORY_GENESIS_ADDIN_H */
diff --git a/libide/directory/ide-directory-plugin.c b/libide/directory/ide-directory-plugin.c
index d24a7b7..a8ac19f 100644
--- a/libide/directory/ide-directory-plugin.c
+++ b/libide/directory/ide-directory-plugin.c
@@ -20,7 +20,9 @@
 
 #include "ide-build-system.h"
 #include "ide-directory-build-system.h"
+#include "ide-directory-genesis-addin.h"
 #include "ide-directory-vcs.h"
+#include "ide-genesis-addin.h"
 
 void
 ide_directory_register_types (PeasObjectModule *module)
@@ -29,6 +31,9 @@ ide_directory_register_types (PeasObjectModule *module)
                                               IDE_TYPE_BUILD_SYSTEM,
                                               IDE_TYPE_DIRECTORY_BUILD_SYSTEM);
   peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_GENESIS_ADDIN,
+                                              IDE_TYPE_DIRECTORY_GENESIS_ADDIN);
+  peas_object_module_register_extension_type (module,
                                               IDE_TYPE_VCS,
                                               IDE_TYPE_DIRECTORY_VCS);
 }
diff --git a/libide/genesis/ide-genesis-addin.c b/libide/genesis/ide-genesis-addin.c
index 7dae40b..14a0b8e 100644
--- a/libide/genesis/ide-genesis-addin.c
+++ b/libide/genesis/ide-genesis-addin.c
@@ -44,7 +44,7 @@ ide_genesis_addin_get_icon_name (IdeGenesisAddin *self)
 /**
  * ide_genesis_addin_get_widget:
  *
- * Returns: (transfer full): A #GtkWidget.
+ * Returns: (transfer none): A #GtkWidget.
  */
 GtkWidget *
 ide_genesis_addin_get_widget (IdeGenesisAddin *self)
diff --git a/libide/genesis/ide-genesis-perspective.c b/libide/genesis/ide-genesis-perspective.c
index e4957ba..e62a7ae 100644
--- a/libide/genesis/ide-genesis-perspective.c
+++ b/libide/genesis/ide-genesis-perspective.c
@@ -45,11 +45,48 @@ ide_genesis_perspective_addin_added (PeasExtensionSet *set,
                                      gpointer          user_data)
 {
   IdeGenesisPerspective *self = user_data;
+  g_autofree gchar *icon_name = NULL;
+  g_autofree gchar *title = NULL;
+  GtkListBoxRow *row;
+  GtkBox *box;
+  GtkImage *image;
+  GtkLabel *label;
 
   g_assert (PEAS_IS_EXTENSION_SET (set));
   g_assert (plugin_info != NULL);
   g_assert (IDE_IS_GENESIS_ADDIN (exten));
   g_assert (IDE_IS_GENESIS_PERSPECTIVE (self));
+
+  icon_name = ide_genesis_addin_get_icon_name (IDE_GENESIS_ADDIN (exten));
+  title = ide_genesis_addin_get_title (IDE_GENESIS_ADDIN (exten));
+
+  row = g_object_new (GTK_TYPE_LIST_BOX_ROW,
+                      "visible", TRUE,
+                      NULL);
+  box = g_object_new (GTK_TYPE_BOX,
+                      "orientation", GTK_ORIENTATION_HORIZONTAL,
+                      "spacing", 12,
+                      "visible", TRUE,
+                      NULL);
+  image = g_object_new (GTK_TYPE_IMAGE,
+                        "hexpand", FALSE,
+                        "icon-name", icon_name,
+                        "pixel-size", 32,
+                        "visible", TRUE,
+                        NULL);
+  label = g_object_new (GTK_TYPE_LABEL,
+                        "label", title,
+                        "wrap", TRUE,
+                        "xalign", 0.0f,
+                        "visible", TRUE,
+                        NULL);
+
+  g_object_set_data (G_OBJECT (row), "IDE_GENESIS_ADDIN", exten);
+
+  gtk_container_add (GTK_CONTAINER (row), GTK_WIDGET (box));
+  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (image));
+  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (label));
+  gtk_container_add (GTK_CONTAINER (self->list_box), GTK_WIDGET (row));
 }
 
 static void
@@ -59,11 +96,51 @@ ide_genesis_perspective_addin_removed (PeasExtensionSet *set,
                                        gpointer          user_data)
 {
   IdeGenesisPerspective *self = user_data;
+  GList *children;
+  GList *iter;
 
   g_assert (PEAS_IS_EXTENSION_SET (set));
   g_assert (plugin_info != NULL);
   g_assert (IDE_IS_GENESIS_ADDIN (exten));
   g_assert (IDE_IS_GENESIS_PERSPECTIVE (self));
+
+  children = gtk_container_get_children (GTK_CONTAINER (self->list_box));
+
+  for (iter = children; iter; iter = iter->next)
+    {
+      gpointer data = g_object_get_data (iter->data, "IDE_GENESIS_ADDIN");
+
+      if (data == (gpointer)exten)
+        {
+          gtk_container_remove (GTK_CONTAINER (self->list_box), iter->data);
+          break;
+        }
+    }
+
+  g_list_free (children);
+}
+
+static void
+ide_genesis_perspective_row_activated (IdeGenesisPerspective *self,
+                                       GtkListBoxRow         *row,
+                                       GtkListBox            *list_box)
+{
+  IdeGenesisAddin *addin;
+  GtkWidget *child;
+
+  g_assert (GTK_IS_LIST_BOX (list_box));
+  g_assert (GTK_IS_LIST_BOX_ROW (row));
+  g_assert (IDE_IS_GENESIS_PERSPECTIVE (self));
+
+  addin = g_object_get_data (G_OBJECT (row), "IDE_GENESIS_ADDIN");
+  if (addin == NULL)
+    return;
+
+  child = ide_genesis_addin_get_widget (addin);
+  if (child == NULL)
+    return;
+
+  gtk_stack_set_visible_child (self->stack, child);
 }
 
 static void
@@ -119,6 +196,12 @@ static void
 ide_genesis_perspective_init (IdeGenesisPerspective *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
+
+  g_signal_connect_object (self->list_box,
+                           "row-activated",
+                           G_CALLBACK (ide_genesis_perspective_row_activated),
+                           self,
+                           G_CONNECT_SWAPPED);
 }
 
 static gchar *
diff --git a/libide/ide.h b/libide/ide.h
index e279b9a..387859e 100644
--- a/libide/ide.h
+++ b/libide/ide.h
@@ -116,6 +116,8 @@ G_BEGIN_DECLS
 #include "editor/ide-editor-view.h"
 #include "editor/ide-editor-view-addin.h"
 
+#include "genesis/ide-genesis-addin.h"
+
 #include "doap/ide-doap-person.h"
 #include "doap/ide-doap.h"
 #include "local/ide-local-device.h"
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index 6a16fad..e97d9bf 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -12,6 +12,8 @@ dist_plugin_DATA = git.plugin
 libgit_plugin_la_SOURCES = \
        ide-git-buffer-change-monitor.c \
        ide-git-buffer-change-monitor.h \
+       ide-git-genesis-addin.c \
+       ide-git-genesis-addin.h \
        ide-git-plugin.c \
        ide-git-remote-callbacks.c \
        ide-git-remote-callbacks.h \
diff --git a/plugins/git/ide-git-genesis-addin.c b/plugins/git/ide-git-genesis-addin.c
new file mode 100644
index 0000000..eb595f1
--- /dev/null
+++ b/plugins/git/ide-git-genesis-addin.c
@@ -0,0 +1,68 @@
+/* ide-git-genesis-addin.c
+ *
+ * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ *
+ * 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 <ide.h>
+
+#include "ide-git-genesis-addin.h"
+
+struct _IdeGitGenesisAddin
+{
+  GObject parent_instance;
+};
+
+static void genesis_addin_iface_init (IdeGenesisAddinInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (IdeGitGenesisAddin, ide_git_genesis_addin, G_TYPE_OBJECT, 0,
+                        G_IMPLEMENT_INTERFACE (IDE_TYPE_GENESIS_ADDIN, genesis_addin_iface_init))
+
+static void
+ide_git_genesis_addin_class_init (IdeGitGenesisAddinClass *klass)
+{
+}
+
+static void
+ide_git_genesis_addin_init (IdeGitGenesisAddin *self)
+{
+}
+
+static gchar *
+ide_git_genesis_addin_get_icon_name (IdeGenesisAddin *addin)
+{
+  return g_strdup ("gitg-symbolic");
+}
+
+static gchar *
+ide_git_genesis_addin_get_title (IdeGenesisAddin *addin)
+{
+  return g_strdup (_("From a Git source code repository"));
+}
+
+static GtkWidget *
+ide_git_genesis_addin_get_widget (IdeGenesisAddin *addin)
+{
+  return NULL;
+}
+
+static void
+genesis_addin_iface_init (IdeGenesisAddinInterface *iface)
+{
+  iface->get_title = ide_git_genesis_addin_get_title;
+  iface->get_icon_name = ide_git_genesis_addin_get_icon_name;
+  iface->get_widget = ide_git_genesis_addin_get_widget;
+}
diff --git a/plugins/git/ide-git-genesis-addin.h b/plugins/git/ide-git-genesis-addin.h
new file mode 100644
index 0000000..c31fa13
--- /dev/null
+++ b/plugins/git/ide-git-genesis-addin.h
@@ -0,0 +1,32 @@
+/* ide-git-genesis-addin.h
+ *
+ * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ *
+ * 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 IDE_GIT_GENESIS_ADDIN_H
+#define IDE_GIT_GENESIS_ADDIN_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_GIT_GENESIS_ADDIN (ide_git_genesis_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeGitGenesisAddin, ide_git_genesis_addin, IDE, GIT_GENESIS_ADDIN, GObject)
+
+G_END_DECLS
+
+#endif /* IDE_GIT_GENESIS_ADDIN_H */
diff --git a/plugins/git/ide-git-plugin.c b/plugins/git/ide-git-plugin.c
index edd1f58..97c9419 100644
--- a/plugins/git/ide-git-plugin.c
+++ b/plugins/git/ide-git-plugin.c
@@ -17,12 +17,18 @@
  */
 
 #include <libpeas/peas.h>
+#include <ide.h>
 
+#include "ide-git-genesis-addin.h"
 #include "ide-git-vcs.h"
-#include "ide-vcs.h"
 
 void
 peas_register_types (PeasObjectModule *module)
 {
-  peas_object_module_register_extension_type (module, IDE_TYPE_VCS, IDE_TYPE_GIT_VCS);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_VCS,
+                                              IDE_TYPE_GIT_VCS);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_GENESIS_ADDIN,
+                                              IDE_TYPE_GIT_GENESIS_ADDIN);
 }


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