[gnome-session] gsm: Remember Provides defined in session definition but not in .desktop
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] gsm: Remember Provides defined in session definition but not in .desktop
- Date: Tue, 22 Mar 2011 12:47:17 +0000 (UTC)
commit 71b0fe1ddbb7d61c1e36ebd1c6c5d195b354a311
Author: Vincent Untz <vuntz gnome org>
Date: Tue Mar 22 13:45:50 2011 +0100
gsm: Remember Provides defined in session definition but not in .desktop
If a provider is defined in the session definition, it doesn't
necessarily have the Provides in the .desktop file. So we remember the
Provides from the session definition.
gnome-session/gsm-autostart-app.c | 57 ++++++++++++++++++++++++++++++++++--
gnome-session/gsm-autostart-app.h | 3 ++
gnome-session/gsm-manager.c | 3 ++
3 files changed, 59 insertions(+), 4 deletions(-)
---
diff --git a/gnome-session/gsm-autostart-app.c b/gnome-session/gsm-autostart-app.c
index eaf441b..9d8c117 100644
--- a/gnome-session/gsm-autostart-app.c
+++ b/gnome-session/gsm-autostart-app.c
@@ -58,6 +58,8 @@ struct _GsmAutostartAppPrivate {
char *startup_id;
EggDesktopFile *desktop_file;
+ /* provides defined in session definition */
+ GSList *session_provides;
/* desktop file state */
char *condition_string;
@@ -745,6 +747,11 @@ gsm_autostart_app_dispose (GObject *object)
priv->startup_id = NULL;
}
+ if (priv->session_provides) {
+ g_slist_free_full (priv->session_provides, g_free);
+ priv->session_provides = NULL;
+ }
+
if (priv->condition_string) {
g_free (priv->condition_string);
priv->condition_string = NULL;
@@ -1203,6 +1210,7 @@ gsm_autostart_app_provides (GsmApp *app,
char **provides;
gsize len;
gsize i;
+ GSList *l;
GsmAutostartApp *aapp;
g_return_val_if_fail (GSM_IS_APP (app), FALSE);
@@ -1213,6 +1221,11 @@ gsm_autostart_app_provides (GsmApp *app,
return FALSE;
}
+ for (l = aapp->priv->session_provides; l != NULL; l = l->next) {
+ if (!strcmp (l->data, service))
+ return TRUE;
+ }
+
provides = egg_desktop_file_get_string_list (aapp->priv->desktop_file,
GSM_AUTOSTART_APP_PROVIDES_KEY,
&len, NULL);
@@ -1228,13 +1241,20 @@ gsm_autostart_app_provides (GsmApp *app,
}
g_strfreev (provides);
+
return FALSE;
}
static char **
gsm_autostart_app_get_provides (GsmApp *app)
{
- GsmAutostartApp *aapp;
+ GsmAutostartApp *aapp;
+ char **provides;
+ gsize provides_len;
+ char **result;
+ gsize result_len;
+ int i;
+ GSList *l;
g_return_val_if_fail (GSM_IS_APP (app), NULL);
@@ -1244,9 +1264,38 @@ gsm_autostart_app_get_provides (GsmApp *app)
return NULL;
}
- return egg_desktop_file_get_string_list (aapp->priv->desktop_file,
- GSM_AUTOSTART_APP_PROVIDES_KEY,
- NULL, NULL);
+ provides = egg_desktop_file_get_string_list (aapp->priv->desktop_file,
+ GSM_AUTOSTART_APP_PROVIDES_KEY,
+ &provides_len, NULL);
+
+ if (!aapp->priv->session_provides)
+ return provides;
+
+ result_len = provides_len + g_slist_length (aapp->priv->session_provides);
+ result = g_new (char *, result_len + 1); /* including last NULL */
+
+ for (i = 0; provides[i] != NULL; i++)
+ result[i] = provides[i];
+ g_free (provides);
+
+ for (l = aapp->priv->session_provides; l != NULL; l = l->next, i++)
+ result[i] = g_strdup (l->data);
+
+ result[i] = NULL;
+
+ g_assert (i == result_len);
+
+ return result;
+}
+
+void
+gsm_autostart_app_add_provides (GsmAutostartApp *aapp,
+ const char *provides)
+{
+ g_return_if_fail (GSM_IS_AUTOSTART_APP (aapp));
+
+ aapp->priv->session_provides = g_slist_prepend (aapp->priv->session_provides,
+ g_strdup (provides));
}
static gboolean
diff --git a/gnome-session/gsm-autostart-app.h b/gnome-session/gsm-autostart-app.h
index 58101f2..2b6089f 100644
--- a/gnome-session/gsm-autostart-app.h
+++ b/gnome-session/gsm-autostart-app.h
@@ -59,6 +59,9 @@ GType gsm_autostart_app_get_type (void) G_GNUC_CONST;
GsmApp *gsm_autostart_app_new (const char *desktop_file);
+void gsm_autostart_app_add_provides (GsmAutostartApp *aapp,
+ const char *provides);
+
#define GSM_AUTOSTART_APP_ENABLED_KEY "X-GNOME-Autostart-enabled"
#define GSM_AUTOSTART_APP_PHASE_KEY "X-GNOME-Autostart-Phase"
#define GSM_AUTOSTART_APP_PROVIDES_KEY "X-GNOME-Provides"
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index d50c76d..47f11a0 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -3795,6 +3795,9 @@ add_autostart_app_internal (GsmManager *manager,
}
}
+ if (provides)
+ gsm_autostart_app_add_provides (GSM_AUTOSTART_APP (app), provides);
+
g_debug ("GsmManager: read %s", path);
append_app (manager, app, is_required);
g_object_unref (app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]