[gnome-software] Create default app folders
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Create default app folders
- Date: Fri, 31 Jan 2014 02:29:43 +0000 (UTC)
commit 56dae32291695dbaefbe1922588f71f907d7f7f1
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 30 21:28:50 2014 -0500
Create default app folders
This is a one-time initialization - if there are no app folders,
we create the 'Utilities' and 'Sundry' folders that gnome-shell
defaulted to in 3.10.
src/gs-application.c | 2 +
src/gs-folders.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/gs-folders.h | 2 +
3 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 5d9382a..bf771f3 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -38,6 +38,7 @@
#include "gs-profile.h"
#include "gs-shell-search-provider.h"
#include "gs-offline-updates.h"
+#include "gs-folders.h"
struct _GsApplication {
@@ -429,6 +430,7 @@ gs_application_startup (GApplication *application)
gs_application_monitor_updates (GS_APPLICATION (application));
gs_application_provide_search (GS_APPLICATION (application));
gs_application_monitor_network (GS_APPLICATION (application));
+ gs_folders_convert ();
}
static void
diff --git a/src/gs-folders.c b/src/gs-folders.c
index 4aedf6f..7e6d3bf 100644
--- a/src/gs-folders.c
+++ b/src/gs-folders.c
@@ -546,4 +546,61 @@ gs_folders_revert (GsFolders *folders)
load (folders);
}
+/* Ensure we have the default folders for Utilities and Sundry.
+ * We can't do this as default values, since the schemas have
+ * no fixed path.
+ */
+void
+gs_folders_convert (void)
+{
+ GSettings *settings;
+ gchar **ids;
+
+ settings = g_settings_new (APP_FOLDER_SCHEMA);
+ ids = g_settings_get_strv (settings, "folder-children");
+ if (g_strv_length (ids) == 0) {
+ const gchar * const children[] = {
+ "Utilities",
+ "Sundry",
+ NULL
+ };
+ const gchar * const utility_categories[] = {
+ "Utilities",
+ NULL
+ };
+ const gchar * const sundry_categories[] = {
+ "X-GNOME-Sundry",
+ NULL
+ };
+ gchar *path;
+ gchar *child_path;
+ GSettings *child;
+
+ g_settings_set_strv (settings, "folder-children", children);
+ g_object_get (settings, "path", &path, NULL);
+
+ child_path = g_strconcat (path, "folders/Utilities/", NULL);
+ child = g_settings_new_with_path (APP_FOLDER_CHILD_SCHEMA, child_path);
+ g_settings_set_string (child, "name", "Utilities.directory");
+ g_settings_set_boolean (child, "translate", TRUE);
+ g_settings_set_strv (child, "categories", utility_categories);
+
+ g_object_unref (child);
+ g_free (child_path);
+
+ child_path = g_strconcat (path, "folders/Sundry/", NULL);
+ child = g_settings_new_with_path (APP_FOLDER_CHILD_SCHEMA, child_path);
+ g_settings_set_string (child, "name", "X-GNOME-Sundry.directory");
+ g_settings_set_boolean (child, "translate", TRUE);
+ g_settings_set_strv (child, "categories", sundry_categories);
+
+ g_object_unref (child);
+ g_free (child_path);
+
+ }
+
+ g_strfreev (ids);
+ g_object_unref (settings);
+}
+
/* vim: set noexpandtab: */
diff --git a/src/gs-folders.h b/src/gs-folders.h
index 03d1576..d154ad2 100644
--- a/src/gs-folders.h
+++ b/src/gs-folders.h
@@ -72,6 +72,8 @@ void gs_folders_set_app_folder (GsFolders *folders,
void gs_folders_save (GsFolders *folders);
void gs_folders_revert (GsFolders *folders);
+void gs_folders_convert (void);
+
G_END_DECLS
#endif /* __GS_FOLDERS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]