[gnome-builder/wip/libide-merge] load workspace even if no files are loaded



commit d4b6cebb49defdf7384a252f1ab6547cceed491a
Author: Christian Hergert <christian hergert me>
Date:   Sun Mar 22 20:23:51 2015 -0700

    load workspace even if no files are loaded
    
    Long term, we are going to have a project selection window. But until
    then, this will get us through our first release.
    
    If the current directory is not the home dir, we use it. If the current
    directory is the home dir and ~/Projects exists, we use ~/Projects.
    Otherwise, we use the home directory.

 src/app/gb-application.c |   52 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 45 insertions(+), 7 deletions(-)
---
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index 6457f38..f40d916 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -269,12 +269,6 @@ gb_application_find_workbench_for_file (GbApplication *self,
   return NULL;
 }
 
-static void
-gb_application_activate (GApplication *application)
-{
-  g_warning ("TODO: Show project selection window");
-}
-
 static IdeBuffer *
 on_create_buffer (IdeBufferManager *buffer_manager,
                   IdeFile          *file,
@@ -309,7 +303,6 @@ gb_application__context_new_cb (GObject      *object,
 
   g_assert (GB_IS_APPLICATION (self));
   g_assert (ar);
-  g_assert (ar->len);
 
   context = ide_context_new_finish (result, &error);
 
@@ -431,6 +424,51 @@ gb_application_open (GApplication   *application,
 }
 
 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;
+
+  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);
+
+  ide_context_new_async (directory,
+                         NULL,
+                         gb_application__context_new_cb,
+                         g_object_ref (task));
+  g_application_hold (application);
+}
+
+static void
 gb_application_startup (GApplication *app)
 {
   GbApplication *self = (GbApplication *)app;


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