[gnome-builder] app: track project file history
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] app: track project file history
- Date: Mon, 30 Mar 2015 22:59:58 +0000 (UTC)
commit e93086cbe0edade43f7aea4ce7b83f88c6043e3c
Author: Christian Hergert <christian hergert me>
Date: Mon Mar 30 15:59:06 2015 -0700
app: track project file history
Update project file history so that we can restore the last project at a
later time. Also, we can use this to sort previously loaded projects.
configure.ac | 1 +
data/gsettings.mk | 1 +
data/gsettings/org.gnome.builder.gschema.xml.in | 9 +++++
src/app/gb-application.c | 39 +++++++++++++++++++++++
4 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 725dc19..fb14a2e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,7 @@ AC_CONFIG_FILES([
src/util/gb-version.h
data/icons/Makefile
data/libide-1.0.pc
+ data/gsettings/org.gnome.builder.gschema.xml
data/gsettings/org.gnome.builder.editor.gschema.xml
data/gsettings/org.gnome.builder.editor.language.gschema.xml
data/gsettings/org.gnome.builder.experimental.gschema.xml
diff --git a/data/gsettings.mk b/data/gsettings.mk
index cb77de0..3526f5f 100644
--- a/data/gsettings.mk
+++ b/data/gsettings.mk
@@ -1,4 +1,5 @@
gsettingsschema_in_files = \
+ data/gsettings/org.gnome.builder.gschema.xml.in \
data/gsettings/org.gnome.builder.editor.gschema.xml.in \
data/gsettings/org.gnome.builder.editor.language.gschema.xml.in \
data/gsettings/org.gnome.builder.experimental.gschema.xml.in \
diff --git a/data/gsettings/org.gnome.builder.gschema.xml.in b/data/gsettings/org.gnome.builder.gschema.xml.in
new file mode 100644
index 0000000..c0b5c72
--- /dev/null
+++ b/data/gsettings/org.gnome.builder.gschema.xml.in
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema id="org.gnome.builder" path="/org/gnome/builder/" gettext-domain="gnome-builder">
+ <key name="project-history" type="as">
+ <default>[]</default>
+ <summary>Previously opened projects</summary>
+ <description>An array of project file paths denoting the recently opened projects</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index 3d1bf71..6492735 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -283,6 +283,43 @@ on_create_buffer (IdeBufferManager *buffer_manager,
}
static void
+gb_application_add_recent_project (GbApplication *self,
+ IdeContext *context)
+{
+ GPtrArray *ar;
+ GSettings *settings;
+ gchar **project_history;
+ GFile *project_file;
+ gchar *uri;
+ gsize i;
+
+ g_assert (GB_IS_APPLICATION (self));
+ g_assert (IDE_IS_CONTEXT (context));
+
+ project_file = ide_context_get_project_file (context);
+ uri = g_file_get_uri (project_file);
+
+ settings = g_settings_new ("org.gnome.builder");
+ project_history = g_settings_get_strv (settings, "project-history");
+
+ ar = g_ptr_array_new ();
+ g_ptr_array_add (ar, uri);
+ for (i = 0; project_history [i]; i++)
+ {
+ if (!g_str_equal (uri, project_history [i]))
+ g_ptr_array_add (ar, project_history [i]);
+ }
+ g_ptr_array_add (ar, NULL);
+
+ g_settings_set_strv (settings, "project-history", (const gchar * const *)ar->pdata);
+
+ g_ptr_array_free (ar, TRUE);
+ g_strfreev (project_history);
+ g_free (uri);
+ g_object_unref (settings);
+}
+
+static void
gb_application__context_new_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
@@ -314,6 +351,8 @@ gb_application__context_new_cb (GObject *object,
goto cleanup;
}
+ gb_application_add_recent_project (self, context);
+
{
IdeVcs *vcs;
GFile *workdir;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]