30
33
#define GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), LIGHTDM_TYPE_SESSION, LightDMSessionPrivate)
35
static gboolean have_sessions = FALSE;
36
static GList *sessions = NULL;
39
update_sessions (void)
47
directory = g_dir_open (XSESSIONS_DIR, 0, &error);
49
g_warning ("Failed to open sessions directory: %s", error->message);
50
g_clear_error (&error);
56
const gchar *filename;
61
filename = g_dir_read_name (directory);
65
if (!g_str_has_suffix (filename, ".desktop"))
68
key = g_strndup (filename, strlen (filename) - strlen (".desktop"));
69
path = g_build_filename (XSESSIONS_DIR, filename, NULL);
70
g_debug ("Loading session %s", path);
72
key_file = g_key_file_new ();
73
result = g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &error);
75
g_warning ("Failed to load session file %s: %s:", path, error->message);
76
g_clear_error (&error);
78
if (result && !g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY, NULL))
80
gchar *domain, *name, *comment;
82
#ifdef G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN
83
domain = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN, NULL);
85
domain = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-Gettext-Domain", NULL);
87
name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, domain, NULL);
88
comment = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, domain, NULL);
90
comment = g_strdup ("");
93
g_debug ("Loaded session %s (%s, %s)", key, name, comment);
94
sessions = g_list_append (sessions, g_object_new (LIGHTDM_TYPE_SESSION, "key", key, "name", name, "comment", comment, NULL));
97
g_warning ("Invalid session %s: %s", path, error->message);
105
g_key_file_free (key_file);
108
g_dir_close (directory);
110
have_sessions = TRUE;
114
* lightdm_get_sessions:
116
* Get the available sessions.
118
* Return value: (element-type LightDMSession) (transfer none): A list of #LightDMSession
121
lightdm_get_sessions (void)
33
128
* lightdm_session_get_key
34
129
* @session: A #LightDMSession