gnome-session r4658 - in trunk: . gnome-session
- From: lucasr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4658 - in trunk: . gnome-session
- Date: Sat, 19 Apr 2008 21:23:00 +0100 (BST)
Author: lucasr
Date: Sat Apr 19 20:23:00 2008
New Revision: 4658
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4658&view=rev
Log:
2008-04-19 Lucas Rocha <lucasr gnome org>
* gnome-session/app-autostart (file_condition_cb, is_disabled):
Separate callbacks for if-exists and unless-exists condition
to not need a condition_type private attribute.
Modified:
trunk/ChangeLog
trunk/gnome-session/app-autostart.c
Modified: trunk/gnome-session/app-autostart.c
==============================================================================
--- trunk/gnome-session/app-autostart.c (original)
+++ trunk/gnome-session/app-autostart.c Sat Apr 19 20:23:00 2008
@@ -28,12 +28,6 @@
#include "app-autostart.h"
#include "gconf.h"
-typedef enum {
- GSM_APP_CONDITION_TYPE_IF_EXISTS,
- GSM_APP_CONDITION_TYPE_UNLESS_EXISTS,
- GSM_APP_CONDITION_TYPE_GNOME
-} GsmAppConditionType;
-
enum {
CONDITION_CHANGED,
LAST_SIGNAL
@@ -41,7 +35,6 @@
struct _GsmAppAutostartPrivate {
GFileMonitor *monitor;
- GsmAppConditionType condition_type;
gboolean condition;
};
@@ -63,7 +56,6 @@
app->priv->monitor = NULL;
app->priv->condition = FALSE;
- app->priv->condition_type = -1;
}
static void
@@ -121,11 +113,11 @@
}
static void
-file_condition_cb (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event,
- GsmApp *app)
+unless_exists_condition_cb (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event,
+ GsmApp *app)
{
GsmAppAutostartPrivate *priv;
gboolean condition = FALSE;
@@ -133,14 +125,38 @@
priv = GSM_APP_AUTOSTART (app)->priv;
switch (event) {
- case G_FILE_MONITOR_EVENT_CREATED:
- if (priv->condition_type == GSM_APP_CONDITION_TYPE_IF_EXISTS)
- condition = TRUE;
+ case G_FILE_MONITOR_EVENT_DELETED:
+ condition = TRUE;
break;
- case G_FILE_MONITOR_EVENT_DELETED:
- if (priv->condition_type == GSM_APP_CONDITION_TYPE_UNLESS_EXISTS)
- condition = TRUE;
+ default:
+ /* Ignore any other monitor event */
+ return;
+ }
+
+ /* Emit only if the condition actually changed */
+ if (condition != priv->condition)
+ {
+ priv->condition = condition;
+ g_signal_emit (app, signals[CONDITION_CHANGED], 0, condition);
+ }
+}
+
+static void
+if_exists_condition_cb (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event,
+ GsmApp *app)
+{
+ GsmAppAutostartPrivate *priv;
+ gboolean condition = FALSE;
+
+ priv = GSM_APP_AUTOSTART (app)->priv;
+
+ switch (event) {
+ case G_FILE_MONITOR_EVENT_CREATED:
+ condition = TRUE;
break;
default:
@@ -249,8 +265,6 @@
{
char *file_path = g_build_filename (g_get_user_config_dir (), key, NULL);
- priv->condition_type = GSM_APP_CONDITION_TYPE_IF_EXISTS;
-
disabled = !g_file_test (file_path, G_FILE_TEST_EXISTS);
if (autorestart)
@@ -260,7 +274,7 @@
priv->monitor = g_file_monitor_file (file, 0, NULL, NULL);
g_signal_connect (priv->monitor, "changed",
- G_CALLBACK (file_condition_cb),
+ G_CALLBACK (if_exists_condition_cb),
app);
g_object_unref (file);
@@ -272,8 +286,6 @@
{
char *file_path = g_build_filename (g_get_user_config_dir (), key, NULL);
- priv->condition_type = GSM_APP_CONDITION_TYPE_UNLESS_EXISTS;
-
disabled = g_file_test (file_path, G_FILE_TEST_EXISTS);
if (autorestart)
@@ -283,7 +295,7 @@
priv->monitor = g_file_monitor_file (file, 0, NULL, NULL);
g_signal_connect (priv->monitor, "changed",
- G_CALLBACK (file_condition_cb),
+ G_CALLBACK (unless_exists_condition_cb),
app);
g_object_unref (file);
@@ -293,8 +305,6 @@
}
else if (!g_ascii_strncasecmp (condition, "GNOME", len))
{
- priv->condition_type = GSM_APP_CONDITION_TYPE_GNOME;
-
if (key)
{
GConfClient *client;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]