gnome-session r4591 - branches/new-gnome-session/gnome-session
- From: lucasr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4591 - branches/new-gnome-session/gnome-session
- Date: Tue, 4 Mar 2008 19:48:33 +0000 (GMT)
Author: lucasr
Date: Tue Mar 4 19:48:32 2008
New Revision: 4591
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4591&view=rev
Log:
GsmAppAutostart:
- Added condition-changed signal.
- Keep track of changed in gconf key referenced in AutostartCondition .desktop key.
GsmApp:
- Initialize pid attribute on init.
GsmSession:
- Connect to condition-changed signal and launch or kill autostart app depending
on the new condition state.
GdmClientXsmp:
- Removed useless debug message.
Modified:
branches/new-gnome-session/gnome-session/app-autostart.c
branches/new-gnome-session/gnome-session/app-autostart.h
branches/new-gnome-session/gnome-session/app.c
branches/new-gnome-session/gnome-session/client-xsmp.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 Tue Mar 4 19:48:32 2008
@@ -27,6 +27,13 @@
#include "app-autostart.h"
#include "gconf.h"
+enum {
+ CONDITION_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
static gboolean is_disabled (GsmApp *app);
G_DEFINE_TYPE (GsmAppAutostart, gsm_app_autostart, GSM_TYPE_APP)
@@ -40,9 +47,21 @@
static void
gsm_app_autostart_class_init (GsmAppAutostartClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GsmAppClass *app_class = GSM_APP_CLASS (klass);
app_class->is_disabled = is_disabled;
+
+ signals[CONDITION_CHANGED] =
+ g_signal_new ("condition-changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsmAppAutostartClass, condition_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_BOOLEAN);
}
GsmApp *
@@ -64,6 +83,25 @@
return app;
}
+static void
+gconf_condition_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
+{
+ GsmApp *app;
+ gboolean condition = FALSE;
+
+ g_return_if_fail (GSM_IS_APP (user_data));
+
+ app = GSM_APP (user_data);
+
+ if (entry->value != NULL && entry->value->type == GCONF_VALUE_BOOL)
+ condition = gconf_value_get_bool (entry->value);
+
+ g_signal_emit (app, signals[CONDITION_CHANGED], 0, condition);
+}
+
static gboolean
is_disabled (GsmApp *app)
{
@@ -118,7 +156,7 @@
disabled = !g_file_test (file, G_FILE_TEST_EXISTS);
g_free (file);
}
- else if (!g_ascii_strncasecmp (condition, "unless-exists ", len) && key)
+ else if (!g_ascii_strncasecmp (condition, "unless-exists", len) && key)
{
char *file = g_build_filename (g_get_user_config_dir (), key, NULL);
disabled = g_file_test (file, G_FILE_TEST_EXISTS);
@@ -128,8 +166,30 @@
{
if (key)
{
- disabled = !gconf_client_get_bool (gsm_gconf_get_client (),
- key, NULL);
+ GConfClient *client;
+ gchar *dir;
+
+ client = gsm_gconf_get_client ();
+
+ g_assert (GCONF_IS_CLIENT (client));
+
+ 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);
}
else
disabled = FALSE;
@@ -138,6 +198,7 @@
disabled = TRUE;
g_free (condition);
+
if (disabled)
{
g_debug ("app %s is disabled by AutostartCondition",
Modified: branches/new-gnome-session/gnome-session/app-autostart.h
==============================================================================
--- branches/new-gnome-session/gnome-session/app-autostart.h (original)
+++ branches/new-gnome-session/gnome-session/app-autostart.h Tue Mar 4 19:48:32 2008
@@ -46,6 +46,8 @@
{
GsmAppClass parent_class;
+ /* signals */
+ void (*condition_changed) (GsmApp *app, gboolean condition);
};
GType gsm_app_autostart_get_type (void) G_GNUC_CONST;
Modified: branches/new-gnome-session/gnome-session/app.c
==============================================================================
--- branches/new-gnome-session/gnome-session/app.c (original)
+++ branches/new-gnome-session/gnome-session/app.c Tue Mar 4 19:48:32 2008
@@ -56,7 +56,7 @@
static void
gsm_app_init (GsmApp *app)
{
- ;
+ app->pid = -1;
}
static void
Modified: branches/new-gnome-session/gnome-session/client-xsmp.c
==============================================================================
--- branches/new-gnome-session/gnome-session/client-xsmp.c (original)
+++ branches/new-gnome-session/gnome-session/client-xsmp.c Tue Mar 4 19:48:32 2008
@@ -589,8 +589,6 @@
delete_property (client, props[i]->name);
g_ptr_array_add (client->props, props[i]);
- g_debug ("TAMANHO DO ARRAY: %d", client->props->len);
-
debug_print_property (props[i]);
if (!strcmp (props[i]->name, SmProgram))
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 Tue Mar 4 19:48:32 2008
@@ -379,6 +379,51 @@
}
static void
+app_condition_changed (GsmApp *app, gboolean condition, gpointer data)
+{
+ GsmSession *session;
+
+ g_return_if_fail (data != NULL);
+
+ session = (GsmSession *) data;
+
+ if (condition)
+ {
+ GError *error = NULL;
+
+ /* FIXME: if this enough to check if app is running before launching it? */
+ if (app->pid <= 0)
+ gsm_app_launch (app, &error);
+
+ if (error != NULL)
+ {
+ g_warning ("Not able to launch autostart app from its condition: %s",
+ error->message);
+
+ g_error_free (error);
+ }
+ }
+ 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;
+ }
+ }
+ }
+}
+
+static void
app_registered (GsmApp *app, gpointer data)
{
GsmSession *session = data;
@@ -434,9 +479,15 @@
for (a = session->apps; a; a = a->next)
{
app = a->data;
+
if (gsm_app_get_phase (app) != session->phase)
continue;
+ /* Keep track of app autostart condition in order to react
+ * accordingly in the future. */
+ g_signal_connect (app, "condition-changed",
+ G_CALLBACK (app_condition_changed), session);
+
if (gsm_app_is_disabled (app))
continue;
@@ -453,7 +504,6 @@
if (session->phase < GSM_SESSION_PHASE_APPLICATION)
{
-
g_signal_connect (app, "registered",
G_CALLBACK (app_registered), session);
@@ -717,7 +767,7 @@
for (cl = session->clients; cl; cl = cl->next)
{
- GsmClient *client = cl->data;
+ GsmClient *client = GSM_CLIENT (cl->data);
session->shutdown_clients =
g_slist_prepend (session->shutdown_clients, client);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]