gnome-session r4648 - in trunk: . data gnome-session
- From: lucasr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4648 - in trunk: . data gnome-session
- Date: Thu, 10 Apr 2008 20:30:32 +0100 (BST)
Author: lucasr
Date: Thu Apr 10 20:30:32 2008
New Revision: 4648
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4648&view=rev
Log:
2008-04-10 Lucas Rocha <lucasr gnome org>
Re-implemented the way we define the default session. Instead of a
directory full of .desktop files, we now get the list of default apps
from a gconf key. Then session manager then looks for those apps in
the standard applications and autostart directories. This way we don't
require default apps to export their .desktop files in a special
directory. #525157, Rob Bradford.
* data/gnome-session.schemas.in: added a new gconf key
/desktop/gnome/session/default-session which stores the list of
default session apps.
* gnome-session/Makefile.am: no need to define default-session
directory anymore.
* gnome-session/gsm.h: added new constant called
GSM_GCONF_DEFAULT_SESSION_KEY refering to new gconf key.
* gnome-session/session.c
(gsm_session_new, append_default_apps): new function to load default
apps from gconf key. The gconf key only stores the application names
and GsmSession looks for a respective .desktop file in some standard
application and autostart directories.
(get_autostart_dirs, get_app_dirs): new utility functions which return
all autostart and applications directories respectively.
Modified:
trunk/ChangeLog
trunk/data/gnome-session.schemas.in
trunk/gnome-session/Makefile.am
trunk/gnome-session/gsm.h
trunk/gnome-session/session.c
Modified: trunk/data/gnome-session.schemas.in
==============================================================================
--- trunk/data/gnome-session.schemas.in (original)
+++ trunk/data/gnome-session.schemas.in Thu Apr 10 20:30:32 2008
@@ -58,6 +58,18 @@
</schema>
<schema>
+ <key>/schemas/desktop/gnome/session/default-session</key>
+ <applyto>/desktop/gnome/session/default-session</applyto>
+ <owner>gnome</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <default>[gnome-settings-daemon,metacity,gnome-panel,nautilus]</default>
+ <locale name="C">
+ <short>Default session</short>
+ <long>List of applications that are part of the default session.</long>
+ </locale>
+ </schema>
+ <schema>
<key>/schemas/desktop/gnome/session/required-components</key>
<applyto>/desktop/gnome/session/required-components</applyto>
<owner>gnome</owner>
Modified: trunk/gnome-session/Makefile.am
==============================================================================
--- trunk/gnome-session/Makefile.am (original)
+++ trunk/gnome-session/Makefile.am Thu Apr 10 20:30:32 2008
@@ -8,8 +8,7 @@
-DLOCALE_DIR=\""$(datadir)/locale"\" \
-DDBUS_LAUNCH=\"dbus-launch\" \
-DGCONF_SANITY_CHECK=\""$(GCONF_SANITY_CHECK)"\" \
- -DGCONFTOOL_CMD=\"$(GCONFTOOL)\" \
- -DGSM_DEFAULT_SESSION_DIR=\""$(default_sessiondir)"\"
+ -DGCONFTOOL_CMD=\"$(GCONFTOOL)\"
LDADD = \
-lSM -lICE \
@@ -19,8 +18,6 @@
$(GCONF_LIBS) \
$(GTK_LIBS)
-default_sessiondir = $(datadir)/gnome/default-session
-
bin_PROGRAMS = \
gnome-session
Modified: trunk/gnome-session/gsm.h
==============================================================================
--- trunk/gnome-session/gsm.h (original)
+++ trunk/gnome-session/gsm.h Thu Apr 10 20:30:32 2008
@@ -3,6 +3,7 @@
void gsm_initialization_error (gboolean fatal, const char *format, ...);
+#define GSM_GCONF_DEFAULT_SESSION_KEY "/desktop/gnome/session/default-session"
#define GSM_GCONF_REQUIRED_COMPONENTS_DIRECTORY "/desktop/gnome/session/required-components"
extern GsmSession *global_session;
Modified: trunk/gnome-session/session.c
==============================================================================
--- trunk/gnome-session/session.c (original)
+++ trunk/gnome-session/session.c Thu Apr 10 20:30:32 2008
@@ -32,6 +32,9 @@
#include "session.h"
#include "xsmp.h"
+static void append_default_apps (GsmSession *session,
+ char **autostart_dirs);
+
static void append_autostart_apps (GsmSession *session,
const char *dir);
@@ -61,6 +64,9 @@
static void client_disconnected (GsmClient *client,
gpointer data);
+static char **get_autostart_dirs (void);
+static char **get_app_dirs (void);
+
struct _GsmSession {
/* Startup/resumed apps */
GSList *apps;
@@ -111,9 +117,7 @@
gsm_session_new (gboolean failsafe)
{
GsmSession *session = g_new0 (GsmSession, 1);
- const char * const *system_config_dirs;
- const char * const *system_data_dirs;
- char *dir;
+ char **autostart_dirs;
int i;
session->clients = NULL;
@@ -123,43 +127,27 @@
session->apps_by_name = g_hash_table_new (g_str_hash, g_str_equal);
- append_autostart_apps (session, GSM_DEFAULT_SESSION_DIR);
- if (failsafe)
- return session;
+ autostart_dirs = get_autostart_dirs ();
- /* fdo autostart dirs */
- system_config_dirs = g_get_system_config_dirs ();
- for (i = 0; system_config_dirs[i]; i++)
- {
- dir = g_build_filename (system_config_dirs[i], "autostart", NULL);
- append_autostart_apps (session, dir);
- g_free (dir);
- }
+ append_default_apps (session, autostart_dirs);
- /* legacy autostart dirs */
- system_data_dirs = g_get_system_data_dirs ();
- for (i = 0; system_data_dirs[i]; i++)
+ if (failsafe)
+ goto out;
+
+ for (i = 0; autostart_dirs[i]; i++)
{
- dir = g_build_filename (system_data_dirs[i], "gnome", "autostart", NULL);
- append_autostart_apps (session, dir);
- g_free (dir);
-
- dir = g_build_filename (system_data_dirs[i], "autostart", NULL);
- append_autostart_apps (session, dir);
- g_free (dir);
+ append_autostart_apps (session, autostart_dirs[i]);
}
- dir = g_build_filename (g_get_user_config_dir (), "autostart", NULL);
- append_autostart_apps (session, dir);
- g_free (dir);
-
append_saved_session_apps (session);
/* We don't do this in the failsafe case, because the default
- * session should include all requirements anyway.
- */
+ * session should include all requirements anyway. */
append_required_apps (session);
+out:
+ g_strfreev (autostart_dirs);
+
return session;
}
@@ -180,6 +168,146 @@
g_hash_table_insert (session->apps_by_name, g_strdup (basename), app);
}
+static char **
+get_autostart_dirs ()
+{
+ GPtrArray *dirs;
+ const char * const *system_config_dirs;
+ const char * const *system_data_dirs;
+ gint i;
+
+ dirs = g_ptr_array_new ();
+
+ system_data_dirs = g_get_system_data_dirs ();
+ for (i = 0; system_data_dirs[i]; i++)
+ {
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i],
+ "gnome", "autostart", NULL));
+
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i],
+ "autostart", NULL));
+ }
+
+ system_config_dirs = g_get_system_config_dirs ();
+ for (i = 0; system_config_dirs[i]; i++)
+ {
+ g_ptr_array_add (dirs,
+ g_build_filename (system_config_dirs[i],
+ "autostart", NULL));
+ }
+
+ g_ptr_array_add (dirs,
+ g_build_filename (g_get_user_config_dir (),
+ "autostart", NULL));
+
+ g_ptr_array_add (dirs, NULL);
+
+ return (char **) g_ptr_array_free (dirs, FALSE);
+}
+
+static char **
+get_app_dirs ()
+{
+ GPtrArray *dirs;
+ const char * const *system_data_dirs;
+ gint i;
+
+ dirs = g_ptr_array_new ();
+
+ system_data_dirs = g_get_system_data_dirs ();
+ for (i = 0; system_data_dirs[i]; i++)
+ {
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i], "applications",
+ NULL));
+
+ g_ptr_array_add (dirs,
+ g_build_filename (system_data_dirs[i], "gnome", "wm-properties",
+ NULL));
+ }
+
+ g_ptr_array_add (dirs, NULL);
+
+ return (char **) g_ptr_array_free (dirs, FALSE);
+}
+
+static void
+append_default_apps (GsmSession *session, char **autostart_dirs)
+{
+ GSList *default_apps, *a;
+ char **app_dirs;
+
+ g_debug ("append_default_apps ()");
+
+ app_dirs = get_app_dirs ();
+
+ default_apps =
+ gconf_client_get_list (gsm_gconf_get_client (),
+ GSM_GCONF_DEFAULT_SESSION_KEY,
+ GCONF_VALUE_STRING,
+ NULL);
+
+ for (a = default_apps; a; a = a->next)
+ {
+ GKeyFile *key_file;
+ char *app_path = NULL;
+ char *desktop_file;
+
+ key_file = g_key_file_new ();
+
+ if (!a->data)
+ continue;
+
+ desktop_file = g_strdup_printf ("%s.desktop", (char *) a->data);
+
+ g_debug ("Look for: %s", desktop_file);
+
+ g_key_file_load_from_dirs (key_file,
+ desktop_file,
+ (const gchar**) app_dirs,
+ &app_path,
+ G_KEY_FILE_NONE,
+ NULL);
+
+ if (!app_path)
+ g_key_file_load_from_dirs (key_file,
+ desktop_file,
+ (const gchar**) autostart_dirs,
+ &app_path,
+ G_KEY_FILE_NONE,
+ NULL);
+
+ if (app_path)
+ {
+ GsmApp *app;
+ char *client_id;
+
+ g_debug ("Found in: %s", app_path);
+
+ client_id = gsm_xsmp_generate_client_id ();
+ app = gsm_app_autostart_new (app_path, client_id);
+ g_free (client_id);
+ g_free (app_path);
+
+ if (app)
+ {
+ g_debug ("read %s\n", desktop_file);
+ append_app (session, app);
+ }
+ else
+ g_warning ("could not read %s\n", desktop_file);
+ }
+
+ g_free (desktop_file);
+ }
+
+ g_slist_foreach (default_apps, (GFunc) g_free, NULL);
+ g_slist_free (default_apps);
+ g_strfreev (app_dirs);
+}
+
static void
append_autostart_apps (GsmSession *session, const char *path)
{
@@ -330,7 +458,7 @@
for (r = required_components; r; r = r->next)
{
- entry = r->data;
+ entry = (GConfEntry *) r->data;
service = strrchr (entry->key, '/');
if (!service)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]