[gnome-builder/wip/project-selector: 2/66] startup: stub out project window for startup



commit 0f2365382b5d03fbe4cce48eb8854a287b51e5b2
Author: Christian Hergert <christian hergert me>
Date:   Sun Mar 29 23:07:30 2015 -0700

    startup: stub out project window for startup
    
    If no files are specified, we will display the project selection window.

 data/ui/gb-project-window.ui              |   48 ++++++++++++++
 src/app/gb-application.c                  |   45 ++-----------
 src/gnome-builder.mk                      |    2 +
 src/resources/gnome-builder.gresource.xml |    1 +
 src/workbench/gb-project-window.c         |  100 +++++++++++++++++++++++++++++
 src/workbench/gb-project-window.h         |   34 ++++++++++
 6 files changed, 193 insertions(+), 37 deletions(-)
---
diff --git a/data/ui/gb-project-window.ui b/data/ui/gb-project-window.ui
new file mode 100644
index 0000000..549bbba
--- /dev/null
+++ b/data/ui/gb-project-window.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.15 -->
+  <template class="GbProjectWindow" parent="GtkApplicationWindow">
+    <child type="titlebar">
+      <object class="GtkHeaderBar">
+        <property name="show-close-button">true</property>
+        <property name="title" translatable="yes">Builder</property>
+        <property name="visible">true</property>
+        <child>
+          <object class="GtkToggleButton">
+            <property name="visible">true</property>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage">
+                <property name="icon-name">system-search-symbolic</property>
+                <property name="visible">true</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkBox">
+        <property name="vexpand">true</property>
+        <property name="orientation">vertical</property>
+        <property name="visible">true</property>
+        <child>
+          <object class="GtkScrolledWindow">
+            <property name="vexpand">true</property>
+            <property name="visible">true</property>
+            <child>
+              <object class="GtkListBox">
+                <property name="visible">true</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index 6492735..f5e7d2a 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -32,6 +32,7 @@
 #include "gb-editor-document.h"
 #include "gb-editor-workspace.h"
 #include "gb-glib.h"
+#include "gb-project-window.h"
 #include "gb-resources.h"
 #include "gb-workbench.h"
 
@@ -470,45 +471,15 @@ static void
 gb_application_activate (GApplication *application)
 {
   GbApplication *self = (GbApplication *)application;
-  const gchar *home_dir;
-  g_autofree gchar *current_dir = NULL;
-  g_autofree gchar *target_dir = NULL;
-  g_autoptr(GFile) directory = NULL;
-  g_autoptr(GTask) task = NULL;
+  GbProjectWindow *window;
 
-  g_return_if_fail (GB_IS_APPLICATION (self));
-
-  /*
-   * FIXME:
-   *
-   * This is a stop gap until we get the project selection window in place.
-   * That will allow us to select previous projects and such.
-   */
-
-  home_dir = g_get_home_dir ();
-  current_dir = g_get_current_dir ();
-
-  if (g_str_equal (home_dir, current_dir))
-    target_dir = g_build_filename (home_dir, "Projects", NULL);
-  else
-    target_dir = g_strdup (current_dir);
-
-  if (!g_file_test (target_dir, G_FILE_TEST_EXISTS))
-    {
-      g_free (target_dir);
-      target_dir = g_strdup (home_dir);
-    }
-
-  directory = g_file_new_for_path (target_dir);
-
-  task = g_task_new (self, NULL, NULL, NULL);
-  g_task_set_task_data (task, g_ptr_array_new (), (GDestroyNotify)g_ptr_array_unref);
+  g_assert (GB_IS_APPLICATION (self));
 
-  ide_context_new_async (directory,
-                         NULL,
-                         gb_application__context_new_cb,
-                         g_object_ref (task));
-  g_application_hold (application);
+  window = g_object_new (GB_TYPE_PROJECT_WINDOW,
+                         "application", self,
+                         NULL);
+  gtk_window_maximize (GTK_WINDOW (window));
+  gtk_window_present (GTK_WINDOW (window));
 }
 
 static void
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index a298b28..5246e04 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -132,6 +132,8 @@ libgnome_builder_la_SOURCES = \
        src/views/gb-view.h \
        src/vim/gb-vim.c \
        src/vim/gb-vim.h \
+       src/workbench/gb-project-window.c \
+       src/workbench/gb-project-window.h \
        src/workbench/gb-workbench-actions.c \
        src/workbench/gb-workbench-actions.h \
        src/workbench/gb-workbench-private.h \
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 94a47bc..bcad354 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -40,6 +40,7 @@
     <file 
alias="ui/gb-preferences-page-keybindings.ui">../../data/ui/gb-preferences-page-keybindings.ui</file>
     <file alias="ui/gb-preferences-page-language.ui">../../data/ui/gb-preferences-page-language.ui</file>
     <file alias="ui/gb-preferences-window.ui">../../data/ui/gb-preferences-window.ui</file>
+    <file alias="ui/gb-project-window.ui">../../data/ui/gb-project-window.ui</file>
     <file alias="ui/gb-search-box.ui">../../data/ui/gb-search-box.ui</file>
     <file alias="ui/gb-search-display-group.ui">../../data/ui/gb-search-display-group.ui</file>
     <file alias="ui/gb-search-display-row.ui">../../data/ui/gb-search-display-row.ui</file>
diff --git a/src/workbench/gb-project-window.c b/src/workbench/gb-project-window.c
new file mode 100644
index 0000000..20c35bb
--- /dev/null
+++ b/src/workbench/gb-project-window.c
@@ -0,0 +1,100 @@
+/* gb-project-window.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 "gb-project-window.h"
+#include "gb-widget.h"
+
+struct _GbProjectWindow
+{
+  GtkApplicationWindow parent_instance;
+
+  GtkListBox *listbox;
+};
+
+G_DEFINE_TYPE (GbProjectWindow, gb_project_window, GTK_TYPE_APPLICATION_WINDOW)
+
+enum {
+  PROP_0,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GbProjectWindow *
+gb_project_window_new (void)
+{
+  return g_object_new (GB_TYPE_PROJECT_WINDOW, NULL);
+}
+
+static void
+gb_project_window_finalize (GObject *object)
+{
+  GbProjectWindow *self = (GbProjectWindow *)object;
+
+  G_OBJECT_CLASS (gb_project_window_parent_class)->finalize (object);
+}
+
+static void
+gb_project_window_get_property (GObject    *object,
+                                guint       prop_id,
+                                GValue     *value,
+                                GParamSpec *pspec)
+{
+  GbProjectWindow *self = GB_PROJECT_WINDOW (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_project_window_set_property (GObject      *object,
+                                guint         prop_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  GbProjectWindow *self = GB_PROJECT_WINDOW (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_project_window_class_init (GbProjectWindowClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_project_window_finalize;
+  object_class->get_property = gb_project_window_get_property;
+  object_class->set_property = gb_project_window_set_property;
+
+  GB_WIDGET_CLASS_TEMPLATE (klass, "gb-project-window.ui");
+
+  GB_WIDGET_CLASS_BIND (klass, GbProjectWindow, listbox);
+}
+
+static void
+gb_project_window_init (GbProjectWindow *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/workbench/gb-project-window.h b/src/workbench/gb-project-window.h
new file mode 100644
index 0000000..2c88a55
--- /dev/null
+++ b/src/workbench/gb-project-window.h
@@ -0,0 +1,34 @@
+/* gb-project-window.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_PROJECT_WINDOW_H
+#define GB_PROJECT_WINDOW_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_PROJECT_WINDOW (gb_project_window_get_type())
+
+G_DECLARE_FINAL_TYPE (GbProjectWindow, gb_project_window, GB, PROJECT_WINDOW, GtkApplicationWindow)
+
+GbProjectWindow *gb_project_window_new (void);
+
+G_END_DECLS
+
+#endif /* GB_PROJECT_WINDOW_H */


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