Commit f4a96ece authored by Jasper St. Pierre's avatar Jasper St. Pierre

gdm-session: Remove some code duplication

Move the keyfile loading to one place.
parent ed3625cd
......@@ -381,22 +381,13 @@ is_prog_in_path (const char *prog)
return ret;
}
static gboolean
get_session_command_for_file (const char *file,
char **command)
static GKeyFile *
load_key_file_for_file (const char *file)
{
GKeyFile *key_file;
GError *error;
char *exec;
gboolean ret;
gboolean res;
exec = NULL;
ret = FALSE;
if (command != NULL) {
*command = NULL;
}
key_file = g_key_file_new ();
g_debug ("GdmSession: looking for session file '%s'", file);
......@@ -411,9 +402,31 @@ get_session_command_for_file (const char *file,
if (! res) {
g_debug ("GdmSession: File '%s' not found: %s", file, error->message);
g_error_free (error);
if (command != NULL) {
*command = NULL;
}
g_key_file_free (key_file);
key_file = NULL;
}
return key_file;
}
static gboolean
get_session_command_for_file (const char *file,
char **command)
{
GKeyFile *key_file;
GError *error;
char *exec;
gboolean ret;
gboolean res;
exec = NULL;
ret = FALSE;
if (command != NULL) {
*command = NULL;
}
key_file = load_key_file_for_file (file);
if (key_file == NULL) {
goto out;
}
......@@ -2649,18 +2662,7 @@ gdm_session_bypasses_xsession (GdmSession *self)
filename = g_strdup_printf ("%s.desktop", get_session_name (self));
key_file = g_key_file_new ();
error = NULL;
res = g_key_file_load_from_dirs (key_file,
filename,
get_system_session_dirs (),
NULL,
G_KEY_FILE_NONE,
&error);
if (! res) {
g_debug ("GdmSession: File '%s' not found: %s", filename, error->message);
goto out;
}
key_file = load_key_file_for_file (filename);
error = NULL;
res = g_key_file_has_key (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-GDM-BypassXsession", NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment