[gnome-builder] app: create projects directory on startup



commit e053ce5ffbc22e82df14d57ff63f0fa0812d0283
Author: Christian Hergert <christian hergert me>
Date:   Sat Apr 30 16:48:28 2016 -0700

    app: create projects directory on startup
    
    If the projects directory does not exist, create it upon startup. This
    fixes first run behavior where lots of GtkFileChooserButton widgets contain
    "(None)" for the directory, as it is missing.
    
    If you don't want this behavior, just set your projects directory to
    $HOME or something like that.

 libide/ide-application.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-application.c b/libide/ide-application.c
index 47e3177..bd47951 100644
--- a/libide/ide-application.c
+++ b/libide/ide-application.c
@@ -54,6 +54,8 @@ G_DEFINE_TYPE (IdeApplication, ide_application, GTK_TYPE_APPLICATION)
 static void
 ide_application_make_skeleton_dirs (IdeApplication *self)
 {
+  g_autoptr(GSettings) settings = NULL;
+  g_autofree gchar *projects_dir = NULL;
   gchar *path;
 
   IDE_ENTRY;
@@ -72,6 +74,19 @@ ide_application_make_skeleton_dirs (IdeApplication *self)
   g_mkdir_with_parents (path, 0750);
   g_free (path);
 
+  settings = g_settings_new ("org.gnome.builder");
+  projects_dir = g_settings_get_string (settings, "projects-directory");
+
+  if (!g_path_is_absolute (projects_dir))
+    {
+      g_autofree gchar *tmp = projects_dir;
+
+      projects_dir = g_build_path (g_get_home_dir (), tmp, NULL);
+    }
+
+  if (!g_file_test (projects_dir, G_FILE_TEST_IS_DIR))
+    g_mkdir_with_parents (projects_dir, 0750);
+
   IDE_EXIT;
 }
 


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