[gnome-shell/4948-replicate-gs-folders-c-from-the-gnome-software] main: Initialize app folders for the Applications grid on start



commit 6b93787f9490619b29263b8cc752e4b8d9031863
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jan 17 17:49:19 2022 +0100

    main: Initialize app folders for the Applications grid on start
    
    Set the default folders and applications for the Applications grid on start.
    The code used to be in gnome-software, but since the gnome-software does not
    edit the settings on its own anymore, the split between setting the defaults
    and using the settings keys only caused confusion.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4948

 src/main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
---
diff --git a/src/main.c b/src/main.c
index 3cd9e10a5b..02af8be75d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,6 +31,9 @@ extern GType gnome_shell_plugin_get_type (void);
 #define WM_NAME "GNOME Shell"
 #define GNOME_WM_KEYBINDINGS "Mutter,GNOME Shell"
 
+#define APP_FOLDER_SCHEMA       "org.gnome.desktop.app-folders"
+#define APP_FOLDER_CHILD_SCHEMA "org.gnome.desktop.app-folders.folder"
+
 static gboolean is_gdm_mode = FALSE;
 static char *session_mode = NULL;
 static int caught_signal = 0;
@@ -287,6 +290,83 @@ shell_init_debug (const char *debug_env)
                                        G_N_ELEMENTS (keys));
 }
 
+static void
+shell_folders_init (void)
+{
+  /* Ensure we have the default folders for Utilities and YaST.
+   * We can't do this as default values, since the schemas have
+   * no fixed path.
+   *
+   * The app lists come from gnome-menus: layout/gnome-applications.menu
+   */
+  g_autoptr(GSettings) settings = NULL;
+  g_auto(GStrv) ids = NULL;
+
+  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",
+        "YaST",
+        NULL
+      };
+      const gchar * const utilities_categories[] = {
+        "X-GNOME-Utilities",
+        NULL
+      };
+      const gchar * const utilities_apps[] = {
+        "gnome-abrt.desktop",
+        "gnome-system-log.desktop",
+        "nm-connection-editor.desktop",
+        "org.gnome.baobab.desktop",
+        "org.gnome.Connections.desktop",
+        "org.gnome.DejaDup.desktop",
+        "org.gnome.Dictionary.desktop",
+        "org.gnome.DiskUtility.desktop",
+        "org.gnome.eog.desktop",
+        "org.gnome.Evince.desktop",
+        "org.gnome.FileRoller.desktop",
+        "org.gnome.fonts.desktop",
+        "org.gnome.seahorse.Application.desktop",
+        "org.gnome.tweaks.desktop",
+        "org.gnome.Usage.desktop",
+        "vinagre.desktop",
+        NULL
+      };
+      const gchar * const yast_categories[] = {
+        "X-SuSE-YaST",
+        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", "X-GNOME-Utilities.directory");
+      g_settings_set_boolean (child, "translate", TRUE);
+      g_settings_set_strv (child, "categories", utilities_categories);
+      g_settings_set_strv (child, "apps", utilities_apps);
+
+      g_object_unref (child);
+      g_free (child_path);
+
+      child_path = g_strconcat (path, "folders/YaST/", NULL);
+      child = g_settings_new_with_path (APP_FOLDER_CHILD_SCHEMA, child_path);
+      g_settings_set_string (child, "name", "suse-yast.directory");
+      g_settings_set_boolean (child, "translate", TRUE);
+      g_settings_set_strv (child, "categories", yast_categories);
+
+      g_object_unref (child);
+      g_free (child_path);
+    }
+}
+
 static void
 default_log_handler (const char     *log_domain,
                      GLogLevelFlags  log_level,
@@ -532,6 +612,7 @@ main (int argc, char **argv)
   shell_perf_log_init ();
   shell_introspection_init ();
   shell_fonts_init ();
+  shell_folders_init ();
 
   g_log_set_default_handler (default_log_handler, NULL);
 


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