summaryrefslogtreecommitdiff
path: root/liblightdm-gobject
diff options
context:
space:
mode:
authorMichael Terry <michael.terry@canonical.com>2012-08-17 12:13:57 -0400
committerMichael Terry <michael.terry@canonical.com>2012-08-17 12:13:57 -0400
commit902617f00b428cef10c524839e7d6940a03297d9 (patch)
treeb9b6ad352083a4a90dcc2a8c2296ed25ecc7cf89 /liblightdm-gobject
parent70f4fd01ce49b9032e75302c2f4d90d78046a7db (diff)
parent4fb3abf0fe3c541d9d42183bf62029731bf4b027 (diff)
downloadlightdm-902617f00b428cef10c524839e7d6940a03297d9.tar.gz
merge from trunk
Diffstat (limited to 'liblightdm-gobject')
-rw-r--r--liblightdm-gobject/Makefile.am1
-rw-r--r--liblightdm-gobject/session.c50
-rw-r--r--liblightdm-gobject/user.c19
3 files changed, 57 insertions, 13 deletions
diff --git a/liblightdm-gobject/Makefile.am b/liblightdm-gobject/Makefile.am
index 93f190b8..8c0ce526 100644
--- a/liblightdm-gobject/Makefile.am
+++ b/liblightdm-gobject/Makefile.am
@@ -4,6 +4,7 @@ liblightdm_gobject_1_la_LDFLAGS = -export-symbols-regex \^lightdm_.*
liblightdm_gobject_1_la_LIBADD = $(LIBLIGHTDM_GOBJECT_LIBS)
liblightdm_gobject_1_la_CFLAGS = $(LIBLIGHTDM_GOBJECT_CFLAGS) \
$(WARN_CFLAGS) \
+ -DCONFIG_DIR=\"$(sysconfdir)/lightdm\" \
-DXSESSIONS_DIR=\"$(datadir)/xsessions\"
mainheader_HEADERS = lightdm.h
diff --git a/liblightdm-gobject/session.c b/liblightdm-gobject/session.c
index 3ebb8ce4..603ddb7f 100644
--- a/liblightdm-gobject/session.c
+++ b/liblightdm-gobject/session.c
@@ -78,6 +78,7 @@ load_session (GKeyFile *key_file, const gchar *key)
if (!full_path)
{
+ g_free (name);
g_free (domain);
return NULL;
}
@@ -109,17 +110,43 @@ static void
update_sessions (void)
{
GDir *directory;
+ gboolean result;
GError *error = NULL;
+ GKeyFile *config_key_file = NULL;
+ gchar *config_path = NULL;
+ gchar *xsessions_dir = g_strdup (XSESSIONS_DIR);
+
if (have_sessions)
return;
- directory = g_dir_open (XSESSIONS_DIR, 0, &error);
+ config_path = g_build_filename (CONFIG_DIR, "lightdm.conf", NULL);
+ config_key_file = g_key_file_new ();
+ result = g_key_file_load_from_file (config_key_file, config_path, G_KEY_FILE_NONE, &error);
+ if (error)
+ g_warning ("Failed to open configuration file: %s", error->message);
+ g_clear_error (&error);
+ if (result)
+ {
+ gchar *xd_value = g_key_file_get_string (config_key_file, "LightDM", "xsessions-directory", NULL);
+ if (xd_value)
+ {
+ g_free (xsessions_dir);
+ xsessions_dir = xd_value;
+ }
+ }
+ g_key_file_free (config_key_file);
+ g_free (config_path);
+
+ directory = g_dir_open (xsessions_dir, 0, &error);
if (error)
g_warning ("Failed to open sessions directory: %s", error->message);
g_clear_error (&error);
if (!directory)
+ {
+ g_free (xsessions_dir);
return;
+ }
while (TRUE)
{
@@ -135,7 +162,7 @@ update_sessions (void)
if (!g_str_has_suffix (filename, ".desktop"))
continue;
- path = g_build_filename (XSESSIONS_DIR, filename, NULL);
+ path = g_build_filename (xsessions_dir, filename, NULL);
key_file = g_key_file_new ();
result = g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &error);
@@ -162,6 +189,7 @@ update_sessions (void)
}
g_dir_close (directory);
+ g_free (xsessions_dir);
have_sessions = TRUE;
}
@@ -181,7 +209,7 @@ lightdm_get_sessions (void)
}
/**
- * lightdm_session_get_key
+ * lightdm_session_get_key:
* @session: A #LightDMSession
*
* Get the key for a session
@@ -196,7 +224,7 @@ lightdm_session_get_key (LightDMSession *session)
}
/**
- * lightdm_session_get_name
+ * lightdm_session_get_name:
* @session: A #LightDMSession
*
* Get the name for a session
@@ -211,7 +239,7 @@ lightdm_session_get_name (LightDMSession *session)
}
/**
- * lightdm_session_get_comment
+ * lightdm_session_get_comment:
* @session: A #LightDMSession
*
* Get the comment for a session
@@ -266,6 +294,17 @@ lightdm_session_get_property (GObject *object,
}
static void
+lightdm_session_finalize (GObject *object)
+{
+ LightDMSession *self = LIGHTDM_SESSION (object);
+ LightDMSessionPrivate *priv = GET_PRIVATE (self);
+
+ g_free (priv->key);
+ g_free (priv->name);
+ g_free (priv->comment);
+}
+
+static void
lightdm_session_class_init (LightDMSessionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -274,6 +313,7 @@ lightdm_session_class_init (LightDMSessionClass *klass)
object_class->set_property = lightdm_session_set_property;
object_class->get_property = lightdm_session_get_property;
+ object_class->finalize = lightdm_session_finalize;
g_object_class_install_property (object_class,
PROP_KEY,
diff --git a/liblightdm-gobject/user.c b/liblightdm-gobject/user.c
index f531a560..3b0741ff 100644
--- a/liblightdm-gobject/user.c
+++ b/liblightdm-gobject/user.c
@@ -1120,7 +1120,8 @@ load_dmrc (LightDMUser *user)
gchar *path;
//gboolean have_dmrc;
- priv->dmrc_file = g_key_file_new ();
+ if (!priv->dmrc_file)
+ priv->dmrc_file = g_key_file_new ();
/* Load from the user directory */
path = g_build_filename (priv->home_directory, ".dmrc", NULL);
@@ -1308,19 +1309,21 @@ load_accounts_service (LightDMUser *user)
static void
load_user_values (LightDMUser *user)
{
+ LightDMUserPrivate *priv = GET_USER_PRIVATE (user);
+
load_dmrc (user);
load_accounts_service (user); // overrides dmrc values
/* Ensure a few guarantees */
- if (GET_USER_PRIVATE (user)->layouts == NULL)
+ if (priv->layouts == NULL)
{
- GET_USER_PRIVATE (user)->layouts = g_malloc (sizeof (gchar));
- GET_USER_PRIVATE (user)->layouts[0] = NULL;
+ priv->layouts = g_malloc (sizeof (gchar *) * 1);
+ priv->layouts[0] = NULL;
}
}
/**
- * lightdm_user_get_language
+ * lightdm_user_get_language:
* @user: A #LightDMUser
*
* Get the language for a user.
@@ -1336,7 +1339,7 @@ lightdm_user_get_language (LightDMUser *user)
}
/**
- * lightdm_user_get_layout
+ * lightdm_user_get_layout:
* @user: A #LightDMUser
*
* Get the keyboard layout for a user.
@@ -1352,7 +1355,7 @@ lightdm_user_get_layout (LightDMUser *user)
}
/**
- * lightdm_user_get_layouts
+ * lightdm_user_get_layouts:
* @user: A #LightDMUser
*
* Get the configured keyboard layouts for a user.
@@ -1368,7 +1371,7 @@ lightdm_user_get_layouts (LightDMUser *user)
}
/**
- * lightdm_user_get_session
+ * lightdm_user_get_session:
* @user: A #LightDMUser
*
* Get the session for a user.