[gnome-builder/wip/tree-menu: 27/44] project-selector: start on open dialog



commit f17995f60093263fe646fdbc27196d80432b378c
Author: Christian Hergert <christian hergert me>
Date:   Thu Apr 2 18:23:37 2015 -0700

    project-selector: start on open dialog
    
    This dialog will cover the following (eventually):
    
     * create new project from template
     * open existing project on computer
     * open remote project (git clone)

 data/ui/gb-new-project-dialog.ui          |  301 +++++++++++++++++++++++++++++
 src/dialogs/gb-new-project-dialog.c       |  195 +++++++++++++++++++
 src/dialogs/gb-new-project-dialog.h       |   32 +++
 src/gnome-builder.mk                      |    3 +
 src/resources/gnome-builder.gresource.xml |    1 +
 src/workbench/gb-project-window.c         |   26 +++
 6 files changed, 558 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/gb-new-project-dialog.ui b/data/ui/gb-new-project-dialog.ui
new file mode 100644
index 0000000..e2d803c
--- /dev/null
+++ b/data/ui/gb-new-project-dialog.ui
@@ -0,0 +1,301 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.15 -->
+  <template class="GbNewProjectDialog" parent="GtkWindow">
+    <child type="titlebar">
+      <object class="GtkHeaderBar" id="header_bar">
+        <property name="show-close-button">false</property>
+        <property name="title" translatable="yes">New Project</property>
+        <property name="visible">true</property>
+        <child>
+          <object class="GtkButton" id="back_button">
+            <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>
+          <packing>
+            <property name="pack-type">start</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="cancel_button">
+            <property name="label" translatable="yes">_Cancel</property>
+            <property name="use-underline">true</property>
+            <property name="visible">true</property>
+            <style>
+              <class name="text-button"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack-type">start</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="create_button">
+            <property name="label" translatable="yes">_Continue</property>
+            <property name="use-underline">true</property>
+            <property name="visible">true</property>
+            <style>
+              <class name="text-button"/>
+              <class name="suggested-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkStack" id="stack">
+        <property name="expand">true</property>
+        <property name="homogeneous">true</property>
+        <property name="transition-type">slide-left-right</property>
+        <property name="visible">true</property>
+        <child>
+          <object class="GtkBox" id="page_open_project">
+            <property name="orientation">vertical</property>
+            <property name="visible">true</property>
+            <child>
+              <object class="GtkBox">
+                <property name="expand">true</property>
+                <property name="visible">true</property>
+                <child type="center">
+                  <object class="GbScrolledWindow">
+                    <property name="halign">center</property>
+                    <property name="hexpand">false</property>
+                    <property name="max-content-height">600</property>
+                    <property name="max-content-width">500</property>
+                    <property name="min-content-height">20</property>
+                    <property name="min-content-width">400</property>
+                    <property name="shadow-type">in</property>
+                    <property name="valign">center</property>
+                    <property name="vexpand">false</property>
+                    <property name="visible">true</property>
+                    <child>
+                      <object class="GtkListBox" id="open_list_box">
+                        <property name="selection-mode">none</property>
+                        <property name="visible">true</property>
+                        <child>
+                          <object class="GtkListBoxRow" id="row_open_local">
+                            <property name="visible">true</property>
+                            <child>
+                              <object class="GtkBox">
+                                <property name="orientation">horizontal</property>
+                                <property name="margin">12</property>
+                                <property name="spacing">12</property>
+                                <property name="visible">true</property>
+                                <child>
+                                  <object class="GtkImage">
+                                    <property name="icon-name">folder</property>
+                                    <property name="pixel-size">32</property>
+                                    <property name="visible">true</property>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="label" translatable="yes">From existing project on this 
computer</property>
+                                    <property name="hexpand">true</property>
+                                    <property name="visible">true</property>
+                                    <property name="xalign">0.0</property>
+                                    <style>
+                                      <class name="dim-label"/>
+                                    </style>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkListBoxRow" id="row_open_remove_project">
+                            <property name="visible">true</property>
+                            <child>
+                              <object class="GtkBox">
+                                <property name="orientation">horizontal</property>
+                                <property name="margin">12</property>
+                                <property name="spacing">12</property>
+                                <property name="visible">true</property>
+                                <child>
+                                  <object class="GtkImage">
+                                    <property name="icon-name">gitg</property>
+                                    <property name="pixel-size">32</property>
+                                    <property name="visible">true</property>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="label" translatable="yes">From remote source code 
repository</property>
+                                    <property name="hexpand">true</property>
+                                    <property name="visible">true</property>
+                                    <property name="xalign">0.0</property>
+                                    <style>
+                                      <class name="dim-label"/>
+                                    </style>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox" id="page_new_project">
+            <property name="orientation">horizontal</property>
+            <property name="expand">true</property>
+            <property name="spacing">12</property>
+            <property name="visible">true</property>
+            <child type="center">
+              <object class="GtkBox">
+                <property name="orientation">vertical</property>
+                <property name="spacing">12</property>
+                <property name="halign">center</property>
+                <property name="hexpand">false</property>
+                <property name="valign">center</property>
+                <property name="vexpand">false</property>
+                <property name="visible">true</property>
+                <child>
+                  <object class="GtkEntry" id="name_entry">
+                    <property name="hexpand">true</property>
+                    <property name="width-chars">35</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkFileChooserButton" id="location_button">
+                    <property name="action">select-folder</property>
+                    <property name="width-chars">35</property>
+                    <property name="hexpand">true</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkMenuButton" id="version_button">
+                    <property name="hexpand">true</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkMenuButton" id="language_button">
+                    <property name="hexpand">true</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkMenuButton" id="pattern_button">
+                    <property name="hexpand">true</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkBox">
+                <property name="orientation">vertical</property>
+                <property name="spacing">12</property>
+                <property name="hexpand">true</property>
+                <property name="vexpand">true</property>
+                <property name="valign">center</property>
+                <property name="halign">end</property>
+                <property name="visible">true</property>
+                <child>
+                  <object class="GtkLabel" id="name_label">
+                    <property name="label" translatable="yes">Name</property>
+                    <property name="visible">true</property>
+                    <property name="xalign">1.0</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="location_label">
+                    <property name="label" translatable="yes">Location</property>
+                    <property name="visible">true</property>
+                    <property name="xalign">1.0</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="version_label">
+                    <property name="label" translatable="yes">GNOME Version</property>
+                    <property name="visible">true</property>
+                    <property name="xalign">1.0</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="language_label">
+                    <property name="label" translatable="yes">Language</property>
+                    <property name="visible">true</property>
+                    <property name="xalign">1.0</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="pattern_label">
+                    <property name="label" translatable="yes">Pattern</property>
+                    <property name="visible">true</property>
+                    <property name="xalign">1.0</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="pack-type">start</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkFileChooserWidget" id="file_chooser">
+            <property name="action">select-folder</property>
+            <property name="local-only">false</property>
+            <property name="visible">true</property>
+            <property name="width-request">800</property>
+            <property name="height-request">500</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+  <object class="GtkSizeGroup">
+    <property name="mode">vertical</property>
+    <widgets>
+      <widget name="name_entry"/>
+      <widget name="name_label"/>
+      <widget name="location_button"/>
+      <widget name="location_label"/>
+      <widget name="version_button"/>
+      <widget name="version_label"/>
+      <widget name="language_button"/>
+      <widget name="language_label"/>
+      <widget name="pattern_button"/>
+      <widget name="pattern_label"/>
+    </widgets>
+  </object>
+</interface>
diff --git a/src/dialogs/gb-new-project-dialog.c b/src/dialogs/gb-new-project-dialog.c
new file mode 100644
index 0000000..95a4bc2
--- /dev/null
+++ b/src/dialogs/gb-new-project-dialog.c
@@ -0,0 +1,195 @@
+/* gb-new-project-dialog.c
+ *
+ * Copyright (C) 2015 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 "gb-new-project-dialog.h"
+#include "gb-widget.h"
+
+struct _GbNewProjectDialog
+{
+  GtkDialog  parent_instance;
+
+  GtkButton            *back_button;
+  GtkButton            *cancel_button;
+  GtkButton            *create_button;
+  GtkFileChooserWidget *file_chooser;
+  GtkListBox           *open_list_box;
+  GtkListBoxRow        *row_open_local;
+  GtkBox               *page_open_project;
+  GtkStack             *stack;
+};
+
+G_DEFINE_TYPE (GbNewProjectDialog, gb_new_project_dialog, GTK_TYPE_WINDOW)
+
+enum {
+  PROP_0,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+static void
+gb_new_project_dialog__back_button_clicked (GbNewProjectDialog *self,
+                                            GtkButton          *back_button)
+{
+  g_assert (GB_IS_NEW_PROJECT_DIALOG (self));
+  g_assert (GTK_IS_BUTTON (back_button));
+
+  gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->page_open_project));
+}
+
+static void
+gb_new_project_dialog__cancel_button_clicked (GbNewProjectDialog *self,
+                                              GtkButton          *cancel_button)
+{
+  g_assert (GB_IS_NEW_PROJECT_DIALOG (self));
+  g_assert (GTK_IS_BUTTON (cancel_button));
+
+  gtk_window_close (GTK_WINDOW (self));
+}
+
+static void
+gb_new_project_dialog__open_list_box_row_activated (GbNewProjectDialog *self,
+                                                    GtkListBoxRow      *row,
+                                                    GtkListBox         *list_box)
+{
+  g_assert (GB_IS_NEW_PROJECT_DIALOG (self));
+  g_assert (GTK_IS_LIST_BOX_ROW (row));
+  g_assert (GTK_IS_LIST_BOX (list_box));
+
+  if (row == self->row_open_local)
+    gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->file_chooser));
+}
+
+static void
+gb_new_project_dialog__stack_notify_visible_child (GbNewProjectDialog *self,
+                                                   GParamSpec         *pspec,
+                                                   GtkStack           *stack)
+{
+  GtkWidget *visible_child;
+
+  g_assert (GB_IS_NEW_PROJECT_DIALOG (self));
+  g_assert (GTK_IS_STACK (stack));
+
+  visible_child = gtk_stack_get_visible_child (stack);
+
+  if (visible_child == GTK_WIDGET (self->file_chooser))
+    {
+      gtk_widget_hide (GTK_WIDGET (self->cancel_button));
+      gtk_widget_show (GTK_WIDGET (self->back_button));
+      gtk_widget_set_sensitive (GTK_WIDGET (self->create_button), FALSE);
+    }
+  else if (visible_child == GTK_WIDGET (self->page_open_project))
+  {
+      gtk_widget_hide (GTK_WIDGET (self->back_button));
+      gtk_widget_show (GTK_WIDGET (self->cancel_button));
+      gtk_widget_set_sensitive (GTK_WIDGET (self->create_button), FALSE);
+  }
+}
+
+static void
+gb_new_project_dialog_finalize (GObject *object)
+{
+  GbNewProjectDialog *self = (GbNewProjectDialog *)object;
+
+  G_OBJECT_CLASS (gb_new_project_dialog_parent_class)->finalize (object);
+}
+
+static void
+gb_new_project_dialog_get_property (GObject    *object,
+                                    guint       prop_id,
+                                    GValue     *value,
+                                    GParamSpec *pspec)
+{
+  GbNewProjectDialog *self = GB_NEW_PROJECT_DIALOG (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_new_project_dialog_set_property (GObject      *object,
+                                    guint         prop_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)
+{
+  GbNewProjectDialog *self = GB_NEW_PROJECT_DIALOG (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_new_project_dialog_class_init (GbNewProjectDialogClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_new_project_dialog_finalize;
+  object_class->get_property = gb_new_project_dialog_get_property;
+  object_class->set_property = gb_new_project_dialog_set_property;
+
+  GB_WIDGET_CLASS_TEMPLATE (klass, "gb-new-project-dialog.ui");
+
+  GB_WIDGET_CLASS_BIND (klass, GbNewProjectDialog, back_button);
+  GB_WIDGET_CLASS_BIND (klass, GbNewProjectDialog, cancel_button);
+  GB_WIDGET_CLASS_BIND (klass, GbNewProjectDialog, create_button);
+  GB_WIDGET_CLASS_BIND (klass, GbNewProjectDialog, file_chooser);
+  GB_WIDGET_CLASS_BIND (klass, GbNewProjectDialog, open_list_box);
+  GB_WIDGET_CLASS_BIND (klass, GbNewProjectDialog, page_open_project);
+  GB_WIDGET_CLASS_BIND (klass, GbNewProjectDialog, row_open_local);
+  GB_WIDGET_CLASS_BIND (klass, GbNewProjectDialog, stack);
+}
+
+static void
+gb_new_project_dialog_init (GbNewProjectDialog *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+
+  g_signal_connect_object (self->stack,
+                           "notify::visible-child",
+                           G_CALLBACK (gb_new_project_dialog__stack_notify_visible_child),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (self->back_button,
+                           "clicked",
+                           G_CALLBACK (gb_new_project_dialog__back_button_clicked),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (self->cancel_button,
+                           "clicked",
+                           G_CALLBACK (gb_new_project_dialog__cancel_button_clicked),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (self->open_list_box,
+                           "row-activated",
+                           G_CALLBACK (gb_new_project_dialog__open_list_box_row_activated),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_object_notify (G_OBJECT (self->stack), "visible-child");
+}
diff --git a/src/dialogs/gb-new-project-dialog.h b/src/dialogs/gb-new-project-dialog.h
new file mode 100644
index 0000000..b46ed5d
--- /dev/null
+++ b/src/dialogs/gb-new-project-dialog.h
@@ -0,0 +1,32 @@
+/* gb-new-project-dialog.h
+ *
+ * Copyright (C) 2015 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 GB_NEW_PROJECT_DIALOG_H
+#define GB_NEW_PROJECT_DIALOG_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_NEW_PROJECT_DIALOG (gb_new_project_dialog_get_type())
+
+G_DECLARE_FINAL_TYPE (GbNewProjectDialog, gb_new_project_dialog, GB, NEW_PROJECT_DIALOG, GtkWindow)
+
+G_END_DECLS
+
+#endif /* GB_NEW_PROJECT_DIALOG_H */
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index aed13c4..493b7c4 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -35,6 +35,8 @@ libgnome_builder_la_SOURCES = \
        src/devhelp/gb-devhelp-document.h \
        src/devhelp/gb-devhelp-view.c \
        src/devhelp/gb-devhelp-view.h \
+       src/dialogs/gb-new-project-dialog.c \
+       src/dialogs/gb-new-project-dialog.h \
        src/documents/gb-document.c \
        src/documents/gb-document.h \
        src/editor/gb-editor-document.c \
@@ -172,6 +174,7 @@ libgnome_builder_la_CFLAGS = \
        -I$(top_srcdir)/src/app \
        -I$(top_srcdir)/src/commands \
        -I$(top_srcdir)/src/devhelp \
+       -I$(top_srcdir)/src/dialogs \
        -I$(top_srcdir)/src/documents \
        -I$(top_srcdir)/src/editor \
        -I$(top_srcdir)/src/gd \
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 35c0422..852bda3 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -35,6 +35,7 @@
     <file alias="ui/gb-editor-workspace.ui">../../data/ui/gb-editor-workspace.ui</file>
     <file alias="ui/gb-html-view.ui">../../data/ui/gb-html-view.ui</file>
     <file alias="ui/gb-initial-setup-dialog.ui">../../data/ui/gb-initial-setup-dialog.ui</file>
+    <file alias="ui/gb-new-project-dialog.ui">../../data/ui/gb-new-project-dialog.ui</file>
     <file alias="ui/gb-preferences-page-editor.ui">../../data/ui/gb-preferences-page-editor.ui</file>
     <file 
alias="ui/gb-preferences-page-experimental.ui">../../data/ui/gb-preferences-page-experimental.ui</file>
     <file alias="ui/gb-preferences-page-git.ui">../../data/ui/gb-preferences-page-git.ui</file>
diff --git a/src/workbench/gb-project-window.c b/src/workbench/gb-project-window.c
index 503004f..fc3629c 100644
--- a/src/workbench/gb-project-window.c
+++ b/src/workbench/gb-project-window.c
@@ -27,6 +27,7 @@
 
 #include "gb-editor-document.h"
 #include "gb-glib.h"
+#include "gb-new-project-dialog.h"
 #include "gb-project-window.h"
 #include "gb-scrolled-window.h"
 #include "gb-string.h"
@@ -606,6 +607,25 @@ gb_project_window__search_entry_changed (GbProjectWindow *self,
 }
 
 static void
+gb_project_window__new_button_clicked (GbProjectWindow *self,
+                                       GtkButton       *new_button)
+{
+  GtkWindow *window;
+
+  g_assert (GB_IS_PROJECT_WINDOW (self));
+  g_assert (GTK_IS_BUTTON (new_button));
+
+  window = g_object_new (GB_TYPE_NEW_PROJECT_DIALOG,
+                         "destroy-with-parent", TRUE,
+                         "modal", TRUE,
+                         "transient-for", self,
+                         "type-hint", GDK_WINDOW_TYPE_HINT_DIALOG,
+                         "visible", TRUE,
+                         NULL);
+  gtk_window_present (window);
+}
+
+static void
 gb_project_window_constructed (GObject *object)
 {
   GbProjectWindow *self = (GbProjectWindow *)object;
@@ -649,6 +669,12 @@ gb_project_window_constructed (GObject *object)
                            self,
                            G_CONNECT_SWAPPED);
 
+  g_signal_connect_object (self->new_button,
+                           "clicked",
+                           G_CALLBACK (gb_project_window__new_button_clicked),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   gtk_list_box_set_header_func (self->listbox,
                                 gb_project_window__listbox_header_cb,
                                 NULL, NULL);


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