Commit 34592e9f authored by Vincent Untz's avatar Vincent Untz Committed by Vincent Untz

use gsm_util_get_desktop_dirs() instead of just gsm_util_get_app_dirs().

2009-03-24  Vincent Untz  <vuntz@gnome.org>

	* gnome-session/gsm-inhibit-dialog.c: (add_inhibitor): use
	gsm_util_get_desktop_dirs() instead of just gsm_util_get_app_dirs().
	Also try to handle desktop filenames that are an absolute path the best
	way possible (this happens with OpenOffice.org).
	* gnome-session/gsm-util.[ch]: (gsm_util_get_desktop_dirs): new
	function, to return all the directories where we look up for the
	desktop files.

svn path=/trunk/; revision=5349
parent 22c8372d
2009-03-24 Vincent Untz <vuntz@gnome.org>
* gnome-session/gsm-inhibit-dialog.c: (add_inhibitor): use
gsm_util_get_desktop_dirs() instead of just gsm_util_get_app_dirs().
Also try to handle desktop filenames that are an absolute path the best
way possible (this happens with OpenOffice.org).
* gnome-session/gsm-util.[ch]: (gsm_util_get_desktop_dirs): new
function, to return all the directories where we look up for the
desktop files.
2009-03-24 Vincent Untz <vuntz@gnome.org>
* gnome-session/gsm-inhibit-dialog.c: (add_inhibitor): handle NULL
......
......@@ -521,13 +521,36 @@ add_inhibitor (GsmInhibitDialog *dialog,
}
if (desktop_filename != NULL) {
/* FIXME: maybe also append the autostart dirs ? */
search_dirs = gsm_util_get_app_dirs ();
search_dirs = gsm_util_get_desktop_dirs ();
error = NULL;
desktop_file = egg_desktop_file_new_from_dirs (desktop_filename,
(const char **)search_dirs,
&error);
if (g_path_is_absolute (desktop_filename)) {
char *basename;
error = NULL;
desktop_file = egg_desktop_file_new (desktop_filename,
&error);
if (desktop_file == NULL) {
if (error) {
g_warning ("Unable to load desktop file '%s': %s",
desktop_filename, error->message);
g_error_free (error);
} else {
g_warning ("Unable to load desktop file '%s'",
desktop_filename);
}
basename = g_path_get_basename (desktop_filename);
g_free (desktop_filename);
desktop_filename = basename;
}
}
if (desktop_file == NULL) {
error = NULL;
desktop_file = egg_desktop_file_new_from_dirs (desktop_filename,
(const char **)search_dirs,
&error);
}
/* look for a file with a vendor prefix */
if (desktop_file == NULL) {
......
......@@ -232,6 +232,43 @@ gsm_util_get_app_dirs ()
return (char **) g_ptr_array_free (dirs, FALSE);
}
char **
gsm_util_get_desktop_dirs ()
{
char **apps;
char **autostart;
char **result;
int size;
int i;
apps = gsm_util_get_app_dirs ();
autostart = gsm_util_get_autostart_dirs ();
size = 0;
for (i = 0; apps[i] != NULL; i++) { size++; }
for (i = 0; autostart[i] != NULL; i++) { size++; }
size += 2; /* saved session + last NULL */
result = g_new (char *, size + 1);
for (i = 0; apps[i] != NULL; i++) {
result[i] = apps[i];
}
g_free (apps);
size = i;
for (i = 0; autostart[i] != NULL; i++) {
result[size + i] = autostart[i];
}
g_free (autostart);
size = size + i;
result[size] = g_strdup (gsm_util_get_saved_session_dir ());
result[size + 1] = NULL;
return result;
}
gboolean
gsm_util_text_is_blank (const char *str)
{
......
......@@ -33,6 +33,8 @@ gchar** gsm_util_get_app_dirs (void);
gchar** gsm_util_get_autostart_dirs (void);
gchar ** gsm_util_get_desktop_dirs (void);
gboolean gsm_util_text_is_blank (const char *str);
void gsm_util_init_error (gboolean fatal,
......
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