gnome-session r4619 - in branches/new-gnome-session: . gnome-session
- From: lucasr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4619 - in branches/new-gnome-session: . gnome-session
- Date: Sun, 23 Mar 2008 20:14:24 +0000 (GMT)
Author: lucasr
Date: Sun Mar 23 20:14:24 2008
New Revision: 4619
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4619&view=rev
Log:
2008-03-23 Lucas Rocha <lucasr gnome org>
Fix relation between apps set with X-GNOME-Autorestart and
AutostartCondition.
* gnome-session/session.c
(app_condition_changed, client_disconnected): don't restart apps if
their condition are set to false.
* gnome-session/app-autostart.c (is_disabled): don't keep track of
condition in case the app is not set with X-GNOME-Autorestart.
Modified:
branches/new-gnome-session/ChangeLog
branches/new-gnome-session/gnome-session/app-autostart.c
branches/new-gnome-session/gnome-session/session.c
Modified: branches/new-gnome-session/gnome-session/app-autostart.c
==============================================================================
--- branches/new-gnome-session/gnome-session/app-autostart.c (original)
+++ branches/new-gnome-session/gnome-session/app-autostart.c Sun Mar 23 20:14:24 2008
@@ -106,12 +106,14 @@
is_disabled (GsmApp *app)
{
char *condition;
+ gboolean autorestart = FALSE;
- if (!egg_desktop_file_can_launch (app->desktop_file, "GNOME"))
+ if (egg_desktop_file_has_key (app->desktop_file,
+ "X-GNOME-AutoRestart", NULL))
{
- g_debug ("app %s is disabled by TryExec, OnlyShowIn, or NotShowIn",
- gsm_app_get_basename (app));
- return TRUE;
+ autorestart =
+ egg_desktop_file_get_boolean (app->desktop_file,
+ "X-GNOME-AutoRestart", NULL);
}
/* X-GNOME-Autostart-enabled key, used by old gnome-session */
@@ -167,7 +169,6 @@
if (key)
{
GConfClient *client;
- gchar *dir;
client = gsm_gconf_get_client ();
@@ -175,21 +176,24 @@
disabled = !gconf_client_get_bool (client, key, NULL);
- dir = g_path_get_dirname (key);
-
- g_debug ("DIR: %s", dir);
-
- /* Add key dir in order to be able to keep track
- * of changed in the key later */
- gconf_client_add_dir (client, dir,
- GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
-
- g_free (dir);
-
- gconf_client_notify_add (client,
- key,
- gconf_condition_cb,
- app, NULL, NULL);
+ if (autorestart)
+ {
+ gchar *dir;
+
+ dir = g_path_get_dirname (key);
+
+ /* Add key dir in order to be able to keep track
+ * of changed in the key later */
+ gconf_client_add_dir (client, dir,
+ GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
+
+ g_free (dir);
+
+ gconf_client_notify_add (client,
+ key,
+ gconf_condition_cb,
+ app, NULL, NULL);
+ }
}
else
disabled = FALSE;
Modified: branches/new-gnome-session/gnome-session/session.c
==============================================================================
--- branches/new-gnome-session/gnome-session/session.c (original)
+++ branches/new-gnome-session/gnome-session/session.c Sun Mar 23 20:14:24 2008
@@ -88,6 +88,10 @@
GSList *interact_clients;
GSList *phase2_clients;
+ /* List of clients which were disconnected due to disabled condition
+ * and shouldn't be automatically restarted */
+ GSList *condition_clients;
+
gint logout_response_id;
};
@@ -112,6 +116,9 @@
char *dir;
int i;
+ session->clients = NULL;
+ session->condition_clients = NULL;
+
session->logout_response_id = GTK_RESPONSE_NONE;
session->apps_by_name = g_hash_table_new (g_str_hash, g_str_equal);
@@ -382,17 +389,27 @@
app_condition_changed (GsmApp *app, gboolean condition, gpointer data)
{
GsmSession *session;
+ GsmClient *client = NULL;
+ GSList *cl = NULL;
g_return_if_fail (data != NULL);
session = (GsmSession *) data;
+ /* Check for an existing session client for this app */
+ for (cl = session->clients; cl; cl = cl->next)
+ {
+ GsmClient *c = GSM_CLIENT (cl->data);
+
+ if (!strcmp (app->client_id, gsm_client_get_client_id (c)))
+ client = c;
+ }
+
if (condition)
{
GError *error = NULL;
- /* FIXME: if this enough to check if app is running before launching it? */
- if (app->pid <= 0)
+ if (app->pid <= 0 && client == NULL)
gsm_app_launch (app, &error);
if (error != NULL)
@@ -405,21 +422,13 @@
}
else
{
- GSList *cl = NULL;
-
- for (cl = session->clients; cl; cl = cl->next)
- {
- GsmClient *client = GSM_CLIENT (cl->data);
-
- if (!strcmp (app->client_id,
- gsm_client_get_client_id (client)))
- {
- /* Kill client in case condition if false */
- gsm_client_die (client);
- app->pid = -1;
- break;
- }
- }
+ /* Kill client in case condition if false and make sure it won't
+ * be automatically restarted by adding the client to
+ * condition_clients */
+ session->condition_clients =
+ g_slist_prepend (session->condition_clients, client);
+ gsm_client_die (client);
+ app->pid = -1;
}
}
@@ -876,6 +885,7 @@
client_disconnected (GsmClient *client, gpointer data)
{
GsmSession *session = data;
+ gboolean is_condition_client = FALSE;
session->clients =
g_slist_remove (session->clients, client);
@@ -886,8 +896,17 @@
session->phase2_clients =
g_slist_remove (session->phase2_clients, client);
+ if (g_slist_find (session->condition_clients, client))
+ {
+ session->condition_clients =
+ g_slist_remove (session->condition_clients, client);
+
+ is_condition_client = TRUE;
+ }
+
if (session->phase != GSM_SESSION_PHASE_SHUTDOWN &&
- gsm_client_get_autorestart (client))
+ gsm_client_get_autorestart (client) &&
+ !is_condition_client)
{
GError *error = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]