[gnome-session] Make autostart overriding more flexible



commit 17b0b11985e9cc4c0023ddab75966a7ba516c4bb
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Sep 22 11:59:27 2012 -0400

    Make autostart overriding more flexible
    
    This patch changes the interpretation of --autostart.
    
    Previously, when specified on the commandline, no session file was
    loaded at all. With this patch, we make it just override the locations
    that we look for autostart files in, from the default
    /etc/xdg/autostart
    /usr/share/autostart
    /usr/share/gnome/autostart
    
    (we still consult those directories for fulfilling .session file
     requirements)
    
    The goal of this is to enable gdm to use autostart in the login
    session, so orca can be activated.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663721

 gnome-session/gsm-session-fill.c |   17 ---------------
 gnome-session/gsm-session-fill.h |    1 -
 gnome-session/gsm-util.c         |   43 ++++++++++++++++++++++++++++++++++++-
 gnome-session/gsm-util.h         |    1 +
 gnome-session/main.c             |    6 ++--
 5 files changed, 45 insertions(+), 23 deletions(-)
---
diff --git a/gnome-session/gsm-session-fill.c b/gnome-session/gsm-session-fill.c
index 9c45e54..a5ef5ef 100644
--- a/gnome-session/gsm-session-fill.c
+++ b/gnome-session/gsm-session-fill.c
@@ -238,7 +238,6 @@ load_standard_apps (GsmManager *manager,
 
                 autostart_dirs = gsm_util_get_autostart_dirs ();
 
-
                 maybe_load_saved_session_apps (manager);
 
                 for (i = 0; autostart_dirs[i]; i++) {
@@ -255,16 +254,6 @@ load_standard_apps (GsmManager *manager,
         g_debug ("fill: *** Done adding default providers");
 }
 
-static void
-load_override_apps (GsmManager *manager,
-                    char      **override_autostart_dirs)
-{
-        int i;
-        for (i = 0; override_autostart_dirs[i]; i++) {
-                gsm_manager_add_autostart_apps_from_dir (manager, override_autostart_dirs[i]);
-        }
-}
-
 static GKeyFile *
 get_session_keyfile_if_valid (const char *path)
 {
@@ -462,18 +451,12 @@ get_session_keyfile (const char *session,
 
 gboolean
 gsm_session_fill (GsmManager  *manager,
-                  char       **override_autostart_dirs,
                   const char  *session)
 {
         GKeyFile *keyfile;
         gboolean is_fallback;
         char *actual_session;
 
-        if (override_autostart_dirs != NULL) {
-                load_override_apps (manager, override_autostart_dirs);
-                return TRUE;
-        }
-
         keyfile = get_session_keyfile (session, &actual_session, &is_fallback);
 
         if (!keyfile)
diff --git a/gnome-session/gsm-session-fill.h b/gnome-session/gsm-session-fill.h
index 2a8ec08..608205c 100644
--- a/gnome-session/gsm-session-fill.h
+++ b/gnome-session/gsm-session-fill.h
@@ -27,7 +27,6 @@
 G_BEGIN_DECLS
 
 gboolean gsm_session_fill (GsmManager  *manager,
-                           char       **override_autostart_dirs,
                            const char  *session);
 
 G_END_DECLS
diff --git a/gnome-session/gsm-util.c b/gnome-session/gsm-util.c
index 38f6ddd..f5af61d 100644
--- a/gnome-session/gsm-util.c
+++ b/gnome-session/gsm-util.c
@@ -182,8 +182,16 @@ gsm_util_get_saved_session_dir (void)
         return _saved_session_dir;
 }
 
-char **
-gsm_util_get_autostart_dirs ()
+static char ** autostart_dirs;
+
+void
+gsm_util_set_autostart_dirs (char ** dirs)
+{
+        autostart_dirs = g_strdupv (dirs);
+}
+
+static char **
+gsm_util_get_standard_autostart_dirs ()
 {
         GPtrArray          *dirs;
         const char * const *system_config_dirs;
@@ -216,6 +224,16 @@ gsm_util_get_autostart_dirs ()
 }
 
 char **
+gsm_util_get_autostart_dirs ()
+{
+        if (autostart_dirs) {
+                return g_strdupv ((char **)autostart_dirs);
+        }
+
+        return gsm_util_get_standard_autostart_dirs ();
+}
+
+char **
 gsm_util_get_app_dirs ()
 {
         GPtrArray          *dirs;
@@ -248,6 +266,7 @@ gsm_util_get_desktop_dirs (gboolean include_saved_session,
 {
 	char **apps;
 	char **autostart;
+	char **standard_autostart;
 	char **result;
 	int    size;
 	int    i;
@@ -255,9 +274,18 @@ gsm_util_get_desktop_dirs (gboolean include_saved_session,
 	apps = gsm_util_get_app_dirs ();
 	autostart = gsm_util_get_autostart_dirs ();
 
+        /* Still, check the standard autostart dirs for things like fulfilling session reqs,
+         * if using a non-standard autostart dir for autostarting */
+        if (autostart_dirs != NULL)
+                standard_autostart = gsm_util_get_standard_autostart_dirs ();
+        else
+                standard_autostart = NULL;
+
 	size = 0;
 	for (i = 0; apps[i] != NULL; i++) { size++; }
 	for (i = 0; autostart[i] != NULL; i++) { size++; }
+        if (autostart_dirs != NULL)
+                for (i = 0; standard_autostart[i] != NULL; i++) { size++; }
         if (include_saved_session)
                 size += 1;
 
@@ -272,6 +300,11 @@ gsm_util_get_desktop_dirs (gboolean include_saved_session,
                 for (i = 0; autostart[i] != NULL; i++, size++) {
                         result[size] = autostart[i];
                 }
+                if (standard_autostart != NULL) {
+                        for (i = 0; standard_autostart[i] != NULL; i++, size++) {
+                                result[size] = standard_autostart[i];
+                        }
+                }
                 for (i = 0; apps[i] != NULL; i++, size++) {
                         result[size] = apps[i];
                 }
@@ -279,6 +312,11 @@ gsm_util_get_desktop_dirs (gboolean include_saved_session,
                 for (i = 0; apps[i] != NULL; i++, size++) {
                         result[size] = apps[i];
                 }
+                if (standard_autostart != NULL) {
+                        for (i = 0; standard_autostart[i] != NULL; i++, size++) {
+                                result[size] = standard_autostart[i];
+                        }
+                }
                 for (i = 0; autostart[i] != NULL; i++, size++) {
                         result[size] = autostart[i];
                 }
@@ -289,6 +327,7 @@ gsm_util_get_desktop_dirs (gboolean include_saved_session,
 
 	g_free (apps);
 	g_free (autostart);
+	g_free (standard_autostart);
 
 	result[size] = NULL;
 
diff --git a/gnome-session/gsm-util.h b/gnome-session/gsm-util.h
index 821706f..11e23ac 100644
--- a/gnome-session/gsm-util.h
+++ b/gnome-session/gsm-util.h
@@ -38,6 +38,7 @@ const char *gsm_util_get_saved_session_dir          (void);
 gchar**     gsm_util_get_app_dirs                   (void);
 
 gchar**     gsm_util_get_autostart_dirs             (void);
+void        gsm_util_set_autostart_dirs             (char **dirs);
 
 gchar **    gsm_util_get_desktop_dirs               (gboolean include_saved_session,
                                                      gboolean autostart_first);
diff --git a/gnome-session/main.c b/gnome-session/main.c
index b2c147f..1903381 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -371,9 +371,9 @@ main (int argc, char **argv)
         if (IS_STRING_EMPTY (session_name))
                 session_name = _gsm_manager_get_default_session (manager);
 
-        if (!gsm_session_fill (manager,
-                               override_autostart_dirs,
-                               session_name)) {
+        gsm_util_set_autostart_dirs (override_autostart_dirs);
+
+        if (!gsm_session_fill (manager, session_name)) {
                 gsm_util_init_error (TRUE, "Failed to load session \"%s\"", session_name ? session_name : "(null)");
         }
 



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