[gnome-builder/wip/chergert/perspective] genesis: start on genesis perspective for project creation



commit 06e7c8dcc12eff833d4abe6c2fa1307adaf02159
Author: Christian Hergert <chergert redhat com>
Date:   Sun Nov 29 23:44:16 2015 -0800

    genesis: start on genesis perspective for project creation

 data/theme/shared.css                    |   11 ++
 data/ui/ide-genesis-perspective.ui       |   58 ++++++++++++
 libide/Makefile.am                       |    5 +
 libide/genesis/ide-genesis-addin.c       |   55 +++++++++++
 libide/genesis/ide-genesis-addin.h       |   45 +++++++++
 libide/genesis/ide-genesis-perspective.c |  150 ++++++++++++++++++++++++++++++
 libide/genesis/ide-genesis-perspective.h |   32 +++++++
 libide/ide-workbench.c                   |    5 +
 libide/resources/libide.gresource.xml    |    1 +
 9 files changed, 362 insertions(+), 0 deletions(-)
---
diff --git a/data/theme/shared.css b/data/theme/shared.css
index 17674c4..19049ba 100644
--- a/data/theme/shared.css
+++ b/data/theme/shared.css
@@ -159,3 +159,14 @@ greeter list row {
 greeter list row:last-child {
   border-bottom: none;
 }
+
+
+genesisperspective frame {
+  border: 1px solid alpha(@borders, 0.4);
+}
+genesisperspective list row {
+  border-bottom: 1px solid alpha(@borders, 0.2);
+}
+genesisperspective list row:last-child {
+  border-bottom: none;
+}
diff --git a/data/ui/ide-genesis-perspective.ui b/data/ui/ide-genesis-perspective.ui
new file mode 100644
index 0000000..d67d102
--- /dev/null
+++ b/data/ui/ide-genesis-perspective.ui
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.18 -->
+  <template class="IdeGenesisPerspective" parent="GtkBin">
+    <child>
+      <object class="GtkStack" id="stack">
+        <property name="transition-duration">250</property>
+        <property name="transition-type">crossfade</property>
+        <property name="expand">true</property>
+        <property name="visible">true</property>
+        <child>
+          <object class="EggBox">
+            <property name="halign">center</property>
+            <property name="max-width-request">550</property>
+            <property name="valign">center</property>
+            <property name="visible">true</property>
+            <child>
+              <object class="GtkFrame">
+                <property name="visible">true</property>
+                <child>
+                  <object class="GtkListBox" id="list_box">
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+  <object class="GtkHeaderBar" id="header_bar">
+    <property name="show-close-button">true</property>
+    <property name="visible">true</property>
+    <child>
+      <object class="GtkButton">
+        <property name="action-name">win.perspective</property>
+        <property name="action-target">'greeter'</property>
+        <property name="visible">true</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage">
+            <property name="icon-name">go-previous-symbolic</property>
+            <property name="visible">true</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child type="title">
+      <object class="GtkLabel">
+        <property name="label" translatable="yes">New Project</property>
+        <property name="visible">true</property>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/libide/Makefile.am b/libide/Makefile.am
index dc30cf7..6d56ffd 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -22,6 +22,10 @@ libide_1_0_la_public_sources = \
        editor/ide-editor-view-addin.h \
        editor/ide-editor-view.c \
        editor/ide-editor-view.h \
+       genesis/ide-genesis-perspective.c \
+       genesis/ide-genesis-perspective.h \
+       genesis/ide-genesis-addin.c \
+       genesis/ide-genesis-addin.h \
        ide-application.c \
        ide-application.h \
        ide-application-addin.c \
@@ -399,6 +403,7 @@ libide_1_0_la_includes = \
        -I$(srcdir)/editor \
        -I$(srcdir)/editorconfig \
        -I$(srcdir)/greeter \
+       -I$(srcdir)/genesis \
        -I$(srcdir)/gsettings \
        -I$(srcdir)/local \
        -I$(srcdir)/modelines \
diff --git a/libide/genesis/ide-genesis-addin.c b/libide/genesis/ide-genesis-addin.c
new file mode 100644
index 0000000..7dae40b
--- /dev/null
+++ b/libide/genesis/ide-genesis-addin.c
@@ -0,0 +1,55 @@
+/* ide-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 "ide-genesis-addin.h"
+
+G_DEFINE_INTERFACE (IdeGenesisAddin, ide_genesis_addin, G_TYPE_OBJECT)
+
+static void
+ide_genesis_addin_default_init (IdeGenesisAddinInterface *iface)
+{
+}
+
+gchar *
+ide_genesis_addin_get_title (IdeGenesisAddin *self)
+{
+  g_return_val_if_fail (IDE_IS_GENESIS_ADDIN (self), NULL);
+
+  return IDE_GENESIS_ADDIN_GET_IFACE (self)->get_title (self);
+}
+
+gchar *
+ide_genesis_addin_get_icon_name (IdeGenesisAddin *self)
+{
+  g_return_val_if_fail (IDE_IS_GENESIS_ADDIN (self), NULL);
+
+  return IDE_GENESIS_ADDIN_GET_IFACE (self)->get_icon_name (self);
+}
+
+/**
+ * ide_genesis_addin_get_widget:
+ *
+ * Returns: (transfer full): A #GtkWidget.
+ */
+GtkWidget *
+ide_genesis_addin_get_widget (IdeGenesisAddin *self)
+{
+  g_return_val_if_fail (IDE_IS_GENESIS_ADDIN (self), NULL);
+
+  return IDE_GENESIS_ADDIN_GET_IFACE (self)->get_widget (self);
+}
diff --git a/libide/genesis/ide-genesis-addin.h b/libide/genesis/ide-genesis-addin.h
new file mode 100644
index 0000000..34d030c
--- /dev/null
+++ b/libide/genesis/ide-genesis-addin.h
@@ -0,0 +1,45 @@
+/* ide-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_GENESIS_ADDIN_H
+#define IDE_GENESIS_ADDIN_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_GENESIS_ADDIN (ide_genesis_addin_get_type())
+
+G_DECLARE_INTERFACE (IdeGenesisAddin, ide_genesis_addin, IDE, GENESIS_ADDIN, GObject)
+
+struct _IdeGenesisAddinInterface
+{
+  GTypeInterface parent_interface;
+
+  gchar     *(*get_title)     (IdeGenesisAddin *self);
+  gchar     *(*get_icon_name) (IdeGenesisAddin *self);
+  GtkWidget *(*get_widget)    (IdeGenesisAddin *self);
+};
+
+gchar     *ide_genesis_addin_get_title     (IdeGenesisAddin *self);
+gchar     *ide_genesis_addin_get_icon_name (IdeGenesisAddin *self);
+GtkWidget *ide_genesis_addin_get_widget    (IdeGenesisAddin *self);
+
+G_END_DECLS
+
+#endif /* IDE_GENESIS_ADDIN_H */
diff --git a/libide/genesis/ide-genesis-perspective.c b/libide/genesis/ide-genesis-perspective.c
new file mode 100644
index 0000000..e4957ba
--- /dev/null
+++ b/libide/genesis/ide-genesis-perspective.c
@@ -0,0 +1,150 @@
+/* ide-genesis-perspective.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 <libpeas/peas.h>
+
+#include "ide-genesis-addin.h"
+#include "ide-genesis-perspective.h"
+
+struct _IdeGenesisPerspective
+{
+  GtkBin            parent_instance;
+
+  PeasExtensionSet *addins;
+
+  GtkHeaderBar     *header_bar;
+  GtkListBox       *list_box;
+  GtkStack         *stack;
+};
+
+static void perspective_iface_init (IdePerspectiveInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (IdeGenesisPerspective, ide_genesis_perspective, GTK_TYPE_BIN, 0,
+                        G_IMPLEMENT_INTERFACE (IDE_TYPE_PERSPECTIVE, perspective_iface_init))
+
+static void
+ide_genesis_perspective_addin_added (PeasExtensionSet *set,
+                                     PeasPluginInfo   *plugin_info,
+                                     PeasExtension    *exten,
+                                     gpointer          user_data)
+{
+  IdeGenesisPerspective *self = user_data;
+
+  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));
+}
+
+static void
+ide_genesis_perspective_addin_removed (PeasExtensionSet *set,
+                                       PeasPluginInfo   *plugin_info,
+                                       PeasExtension    *exten,
+                                       gpointer          user_data)
+{
+  IdeGenesisPerspective *self = user_data;
+
+  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));
+}
+
+static void
+ide_genesis_perspective_constructed (GObject *object)
+{
+  IdeGenesisPerspective *self = (IdeGenesisPerspective *)object;
+
+  G_OBJECT_CLASS (ide_genesis_perspective_parent_class)->constructed (object);
+
+  self->addins = peas_extension_set_new (peas_engine_get_default (),
+                                         IDE_TYPE_GENESIS_ADDIN,
+                                         NULL);
+
+  peas_extension_set_foreach (self->addins, ide_genesis_perspective_addin_added, self);
+
+  g_signal_connect (self->addins,
+                    "extension-added",
+                    G_CALLBACK (ide_genesis_perspective_addin_added),
+                    self);
+  g_signal_connect (self->addins,
+                    "extension-rmeoved",
+                    G_CALLBACK (ide_genesis_perspective_addin_removed),
+                    self);
+}
+
+static void
+ide_genesis_perspective_finalize (GObject *object)
+{
+  IdeGenesisPerspective *self = (IdeGenesisPerspective *)object;
+
+  g_clear_object (&self->addins);
+
+  G_OBJECT_CLASS (ide_genesis_perspective_parent_class)->finalize (object);
+}
+
+static void
+ide_genesis_perspective_class_init (IdeGenesisPerspectiveClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  object_class->constructed = ide_genesis_perspective_constructed;
+  object_class->finalize = ide_genesis_perspective_finalize;
+
+  gtk_widget_class_set_css_name (widget_class, "genesisperspective");
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/ui/ide-genesis-perspective.ui");
+  gtk_widget_class_bind_template_child (widget_class, IdeGenesisPerspective, list_box);
+  gtk_widget_class_bind_template_child (widget_class, IdeGenesisPerspective, stack);
+  gtk_widget_class_bind_template_child (widget_class, IdeGenesisPerspective, header_bar);
+}
+
+static void
+ide_genesis_perspective_init (IdeGenesisPerspective *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static gchar *
+ide_genesis_perspective_get_id (IdePerspective *perspective)
+{
+  return g_strdup ("genesis");
+}
+
+static gboolean
+ide_genesis_perspective_is_early (IdePerspective *perspective)
+{
+  return TRUE;
+}
+
+static GtkWidget *
+ide_genesis_perspective_get_titlebar (IdePerspective *perspective)
+{
+  g_return_val_if_fail (IDE_IS_GENESIS_PERSPECTIVE (perspective), NULL);
+
+  return GTK_WIDGET (IDE_GENESIS_PERSPECTIVE (perspective)->header_bar);
+}
+
+static void
+perspective_iface_init (IdePerspectiveInterface *iface)
+{
+  iface->get_id = ide_genesis_perspective_get_id;
+  iface->is_early = ide_genesis_perspective_is_early;
+  iface->get_titlebar = ide_genesis_perspective_get_titlebar;
+}
diff --git a/libide/genesis/ide-genesis-perspective.h b/libide/genesis/ide-genesis-perspective.h
new file mode 100644
index 0000000..4c77392
--- /dev/null
+++ b/libide/genesis/ide-genesis-perspective.h
@@ -0,0 +1,32 @@
+/* ide-genesis-perspective.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_GENESIS_PERSPECTIVE_H
+#define IDE_GENESIS_PERSPECTIVE_H
+
+#include "ide-perspective.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_GENESIS_PERSPECTIVE (ide_genesis_perspective_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeGenesisPerspective, ide_genesis_perspective, IDE, GENESIS_PERSPECTIVE, GtkBin)
+
+G_END_DECLS
+
+#endif /* IDE_GENESIS_PERSPECTIVE_H */
diff --git a/libide/ide-workbench.c b/libide/ide-workbench.c
index 505b17f..66b0140 100644
--- a/libide/ide-workbench.c
+++ b/libide/ide-workbench.c
@@ -19,6 +19,7 @@
 #define G_LOG_DOMAIN "ide-workbench"
 
 #include "ide-debug.h"
+#include "ide-genesis-perspective.h"
 #include "ide-greeter-perspective.h"
 #include "ide-gtk.h"
 #include "ide-macros.h"
@@ -271,6 +272,10 @@ ide_workbench_init (IdeWorkbench *self)
                                                "visible", TRUE,
                                                NULL));
   ide_workbench_add_perspective (self,
+                                 g_object_new (IDE_TYPE_GENESIS_PERSPECTIVE,
+                                               "visible", TRUE,
+                                               NULL));
+  ide_workbench_add_perspective (self,
                                  g_object_new (IDE_TYPE_PREFERENCES_PERSPECTIVE,
                                                "visible", TRUE,
                                                NULL));
diff --git a/libide/resources/libide.gresource.xml b/libide/resources/libide.gresource.xml
index 2a3b78b..afb9ee5 100644
--- a/libide/resources/libide.gresource.xml
+++ b/libide/resources/libide.gresource.xml
@@ -44,6 +44,7 @@
     <file alias="ide-editor-frame.ui">../../data/ui/ide-editor-frame.ui</file>
     <file alias="ide-editor-tweak-widget.ui">../../data/ui/ide-editor-tweak-widget.ui</file>
     <file alias="ide-editor-view.ui">../../data/ui/ide-editor-view.ui</file>
+    <file alias="ide-genesis-perspective.ui">../../data/ui/ide-genesis-perspective.ui</file>
     <file alias="ide-greeter-perspective.ui">../../data/ui/ide-greeter-perspective.ui</file>
     <file alias="ide-greeter-project-row.ui">../../data/ui/ide-greeter-project-row.ui</file>
     <file alias="ide-layout.ui">../../data/ui/ide-layout.ui</file>


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