aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorJP Rosevear <jpr@novell.com>2004-05-18 21:33:40 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-05-18 21:33:40 +0800
commit8f8ecd25e13165724e6e4cc71af09a383d44d727 (patch)
treed0ef937163862fb6bab7b79c4a4ac8202fee6a05 /calendar
parenta2a2f0b03919f44d467d5a3ef30bda33d7ed28e8 (diff)
downloadgsoc2013-evolution-8f8ecd25e13165724e6e4cc71af09a383d44d727.tar
gsoc2013-evolution-8f8ecd25e13165724e6e4cc71af09a383d44d727.tar.gz
gsoc2013-evolution-8f8ecd25e13165724e6e4cc71af09a383d44d727.tar.bz2
gsoc2013-evolution-8f8ecd25e13165724e6e4cc71af09a383d44d727.tar.lz
gsoc2013-evolution-8f8ecd25e13165724e6e4cc71af09a383d44d727.tar.xz
gsoc2013-evolution-8f8ecd25e13165724e6e4cc71af09a383d44d727.tar.zst
gsoc2013-evolution-8f8ecd25e13165724e6e4cc71af09a383d44d727.zip
just set up the alarm notify object
2004-05-18 JP Rosevear <jpr@novell.com> * gui/alarm-notify/notify-main.c (init_alarm_service): just set up the alarm notify object * gui/alarm-notify/alarm-notify.h: update proto * gui/alarm-notify/alarm-notify.c (process_removal_in_hash): process removals using the source list (list_changed_cb): when the list changes, update (load_calendars): initially load the calendars (alarm_notify_init): load the calendars here and don't listen for a selection notification (alarm_notify_add_calendar): get the source type when adding a calendar * gui/alarm-notify/notify-main.c (main): no need to init/shutdown gnome vfs * gui/alarm-notify/config-data.h: new proto * gui/alarm-notify/config-data.c (config_data_get_notify_with_tray): routine to get schema value * gui/alarm-notify/alarm.c (alarm_ready_cb): no timeout checking here, setup_timeout does that (queue_alarm): ditto (setup_timeout): calculate the timeout better * gui/alarm-notify/alarm-queue.c (query_objects_changed_cb): tidy (edit_component): clean up exception handling (display_notification): don't show the tray icon if we aren't notifying with the tray * gui/apps_evolution_calendar.schemas.in.in: add notify_with_tray option svn path=/trunk/; revision=25958
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog37
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c158
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.h2
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c115
-rw-r--r--calendar/gui/alarm-notify/alarm.c77
-rw-r--r--calendar/gui/alarm-notify/config-data.c45
-rw-r--r--calendar/gui/alarm-notify/config-data.h2
-rw-r--r--calendar/gui/alarm-notify/notify-main.c37
-rw-r--r--calendar/gui/apps_evolution_calendar.schemas.in.in11
9 files changed, 251 insertions, 233 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 6380cd16b5..779b0b02c5 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,40 @@
+2004-05-18 JP Rosevear <jpr@novell.com>
+
+ * gui/alarm-notify/notify-main.c (init_alarm_service): just set up
+ the alarm notify object
+
+ * gui/alarm-notify/alarm-notify.h: update proto
+
+ * gui/alarm-notify/alarm-notify.c (process_removal_in_hash):
+ process removals using the source list
+ (list_changed_cb): when the list changes, update
+ (load_calendars): initially load the calendars
+ (alarm_notify_init): load the calendars here and don't listen for
+ a selection notification
+ (alarm_notify_add_calendar): get the source type when adding a
+ calendar
+
+ * gui/alarm-notify/notify-main.c (main): no need to init/shutdown
+ gnome vfs
+
+ * gui/alarm-notify/config-data.h: new proto
+
+ * gui/alarm-notify/config-data.c
+ (config_data_get_notify_with_tray): routine to get schema value
+
+ * gui/alarm-notify/alarm.c (alarm_ready_cb): no timeout checking
+ here, setup_timeout does that
+ (queue_alarm): ditto
+ (setup_timeout): calculate the timeout better
+
+ * gui/alarm-notify/alarm-queue.c (query_objects_changed_cb): tidy
+ (edit_component): clean up exception handling
+ (display_notification): don't show the tray icon if we aren't
+ notifying with the tray
+
+ * gui/apps_evolution_calendar.schemas.in.in: add notify_with_tray
+ option
+
2004-05-18 Kidd Wang <kidd.wang@sun.com>
* gui/e-week-view.c: (e_week_view_do_cursor_key_up),
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index cfcf446ff8..2413e3fbb7 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -38,8 +38,7 @@ struct _AlarmNotifyPrivate {
/* Mapping from EUri's to LoadedClient structures */
GHashTable *uri_client_hash;
- /* ID of GConf notification listener */
- guint notification_id;
+ ESourceList *source_lists [E_CAL_SOURCE_TYPE_LAST];
};
@@ -70,79 +69,125 @@ alarm_notify_class_init (AlarmNotifyClass *klass)
typedef struct {
AlarmNotify *an;
- GPtrArray *cals;
+ ESourceList *source_list;
} ProcessRemovalsData;
static void
-process_removal_in_hash (gpointer key, gpointer value, gpointer user_data)
+process_removal_in_hash (gpointer key, gpointer value, gpointer data)
{
- int i;
char *uri = key;
- ProcessRemovalsData *prd = user_data;
+ ProcessRemovalsData *prd = data;
+ GSList *groups, *sources, *p, *q;
+ gboolean found = FALSE;
/* search the list of selected calendars */
- for (i = 0; i < prd->cals->len; i++) {
- ESource *source;
- char *source_uri;
- gboolean found = FALSE;
-
- source = prd->cals->pdata[i];
- source_uri = e_source_get_uri (source);
- if (strcmp (source_uri, uri) == 0)
- found = TRUE;
-
- g_free (source_uri);
- if (found)
- return;
+ groups = e_source_list_peek_groups (prd->source_list);
+ for (p = groups; p != NULL; p = p->next) {
+ ESourceGroup *group = E_SOURCE_GROUP (p->data);
+
+ sources = e_source_group_peek_sources (group);
+ for (q = sources; q != NULL; q = q->next) {
+ ESource *source = E_SOURCE (q->data);
+ char *source_uri;
+
+ source_uri = e_source_get_uri (source);
+ if (strcmp (source_uri, uri) == 0)
+ found = TRUE;
+ g_free (uri);
+
+ if (found)
+ return;
+ }
}
/* not found, so remove it */
+ g_message ("Removing %s", uri);
alarm_notify_remove_calendar (prd->an, uri);
}
static void
-conf_changed_cb (GConfClient *conf_client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+list_changed_cb (ESourceList *source_list, gpointer data)
{
- AlarmNotify *an;
+ AlarmNotify *an = data;
AlarmNotifyPrivate *priv;
- GPtrArray *cals;
- const char *key_name;
- int i;
+ GSList *groups, *sources, *p, *q;
+ ECalSourceType source_type = E_CAL_SOURCE_TYPE_LAST;
ProcessRemovalsData prd;
-
- an = ALARM_NOTIFY (user_data);
+ int i;
+
priv = an->priv;
- key_name = gconf_entry_get_key (entry);
- if (!key_name ||
- (key_name && strcmp (key_name, "/apps/evolution/calendar/sources") != 0) ||
- (key_name && strcmp (key_name, "/apps/evolution/tasks/sources") != 0))
- return;
-
- cals = config_data_get_calendars_to_load ();
- if (!cals)
+ /* Figure out the source type */
+ for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+ if (source_list == priv->source_lists[i]) {
+ source_type = i;
+ break;
+ }
+ }
+ if (source_type == E_CAL_SOURCE_TYPE_LAST)
return;
-
+
/* process the additions */
- for (i = 0; i < cals->len; i++) {
- ESource *source;
- char *uri;
-
- source = cals->pdata[i];
-
- uri = e_source_get_uri (source);
- if (!g_hash_table_lookup (priv->uri_client_hash, uri))
- alarm_notify_add_calendar (an, uri, FALSE);
-
- g_free (uri);
+ groups = e_source_list_peek_groups (source_list);
+ for (p = groups; p != NULL; p = p->next) {
+ ESourceGroup *group = E_SOURCE_GROUP (p->data);
+
+ sources = e_source_group_peek_sources (group);
+ for (q = sources; q != NULL; q = q->next) {
+ ESource *source = E_SOURCE (q->data);
+ char *uri;
+
+ uri = e_source_get_uri (source);
+ if (!g_hash_table_lookup (priv->uri_client_hash, uri)) {
+ g_message ("Adding %s", uri);
+ alarm_notify_add_calendar (an, source_type, uri, FALSE);
+ }
+ g_free (uri);
+ }
}
/* process the removals */
prd.an = an;
- prd.cals = cals;
+ prd.source_list = priv->source_lists[source_type];
g_hash_table_foreach (priv->uri_client_hash, (GHFunc) process_removal_in_hash, &prd);
+}
- g_ptr_array_free (cals, TRUE);
+/* Loads the calendars that the alarm daemon has been told to load in the past */
+static void
+load_calendars (AlarmNotify *an, ECalSourceType source_type)
+{
+ AlarmNotifyPrivate *priv;
+ ESourceList *source_list;
+ GSList *groups, *sources, *p, *q;
+
+ priv = an->priv;
+
+ if (!e_cal_get_sources (&source_list, source_type, NULL)) {
+ g_message (G_STRLOC ": Could not get the list of sources to load");
+ priv->source_lists[source_type] = NULL;
+
+ return;
+ }
+
+ groups = e_source_list_peek_groups (source_list);
+ for (p = groups; p != NULL; p = p->next) {
+ ESourceGroup *group = E_SOURCE_GROUP (p->data);
+
+ sources = e_source_group_peek_sources (group);
+ for (q = sources; q != NULL; q = q->next) {
+ ESource *source = E_SOURCE (q->data);
+ char *uri;
+
+ uri = e_source_get_uri (source);
+ g_message ("Loading %s", uri);
+ alarm_notify_add_calendar (an, source_type, uri, FALSE);
+ g_free (uri);
+
+ }
+ }
+
+ g_signal_connect_object (source_list, "changed", G_CALLBACK (list_changed_cb), an, 0);
+ priv->source_lists[source_type] = source_list;
}
/* Object initialization function for the alarm notify system */
@@ -150,19 +195,17 @@ static void
alarm_notify_init (AlarmNotify *an, AlarmNotifyClass *klass)
{
AlarmNotifyPrivate *priv;
- GConfClient *conf_client;
+ int i;
priv = g_new0 (AlarmNotifyPrivate, 1);
an->priv = priv;
priv->uri_client_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- /* setup listener for getting changes in selected calendars */
- conf_client = config_data_get_conf_client ();
- gconf_client_add_dir (conf_client, "/apps/evolution", GCONF_CLIENT_PRELOAD_NONE, NULL);
+ alarm_queue_init ();
- priv->notification_id = gconf_client_notify_add (conf_client, "/apps/evolution",
- (GConfClientNotifyFunc) conf_changed_cb, an, NULL, NULL);
+ for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++)
+ load_calendars (an, i);
}
static void
@@ -186,9 +229,6 @@ alarm_notify_finalize (GObject *object)
an = ALARM_NOTIFY (object);
priv = an->priv;
- gconf_client_notify_remove (config_data_get_conf_client (), priv->notification_id);
- priv->notification_id = -1;
-
g_hash_table_foreach (priv->uri_client_hash, dequeue_client, NULL);
g_hash_table_destroy (priv->uri_client_hash);
@@ -247,7 +287,7 @@ cal_opened_cb (ECal *client, ECalendarStatus status, gpointer user_data)
* that it can be loaded in the future when the alarm daemon starts up.
**/
void
-alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_afterwards)
+alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, const char *str_uri, gboolean load_afterwards)
{
AlarmNotifyPrivate *priv;
ECal *client;
@@ -262,7 +302,7 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
if (g_hash_table_lookup (priv->uri_client_hash, str_uri))
return;
- client = auth_new_cal_from_uri (str_uri, E_CAL_SOURCE_TYPE_EVENT);
+ client = auth_new_cal_from_uri (str_uri, source_type);
if (client) {
g_hash_table_insert (priv->uri_client_hash, g_strdup (str_uri), client);
diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h
index c4a351d818..f64452d450 100644
--- a/calendar/gui/alarm-notify/alarm-notify.h
+++ b/calendar/gui/alarm-notify/alarm-notify.h
@@ -55,7 +55,7 @@ GType alarm_notify_get_type (void);
AlarmNotify *alarm_notify_new (void);
-void alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_afterwards);
+void alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, const char *str_uri, gboolean load_afterwards);
void alarm_notify_remove_calendar (AlarmNotify *an, const char *str_uri);
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index b00e979ad6..1258324d0e 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -26,6 +26,7 @@
#include <glib.h>
#include <bonobo-activation/bonobo-activation.h>
#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-exception.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkbox.h>
#include <gtk/gtkdialog.h>
@@ -328,6 +329,7 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms)
/* No alarms? */
if (alarms == NULL || alarms->alarms == NULL) {
+ g_message ("No alarms to add");
if (alarms)
e_cal_component_alarms_free (alarms);
return;
@@ -347,6 +349,7 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms)
instance = l->data;
+ g_message ("Adding alarm at %lu (%lu)", instance->trigger, time (NULL));
alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL);
if (!alarm_id) {
g_message ("add_component_alarms(): Could not schedule a trigger for "
@@ -415,6 +418,7 @@ load_alarms_for_today (ClientAlarms *ca)
zone = config_data_get_timezone ();
+ g_message ("Loading alarms for today");
day_end = time_day_end_with_zone (now, zone);
load_alarms (ca, now, day_end);
}
@@ -530,61 +534,64 @@ query_objects_changed_cb (ECal *client, GList *objects, gpointer data)
zone = config_data_get_timezone ();
day_end = time_day_end_with_zone (time (NULL), zone);
-
+ g_message ("Query response for alarms");
for (l = objects; l != NULL; l = l->next) {
const char *uid;
+ GSList *sl;
uid = icalcomponent_get_uid (l->data);
found = e_cal_get_alarms_for_object (ca->client, uid, from, day_end, &alarms);
if (!found) {
+ g_message ("No alarms found on object");
remove_comp (ca, uid);
continue;
}
cqa = lookup_comp_queued_alarms (ca, uid);
- if (!cqa)
+ if (!cqa) {
+ g_message ("No currently queue alarms");
add_component_alarms (ca, alarms);
- else {
- GSList *sl;
+ continue;
+ }
- /* if the alarms or the alarms list is empty, just remove it */
- if (alarms == NULL || alarms->alarms == NULL) {
- if (alarms)
- e_cal_component_alarms_free (alarms);
- }
- else {
- /* if already in the list, just update it */
- remove_alarms (cqa, FALSE);
- cqa->alarms = alarms;
- cqa->queued_alarms = NULL;
-
- /* add the new alarms */
- for (sl = cqa->alarms->alarms; sl; sl = sl->next) {
- ECalComponentAlarmInstance *instance;
- gpointer alarm_id;
- QueuedAlarm *qa;
-
- instance = sl->data;
-
- alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL);
- if (!alarm_id) {
- g_message ("obj_updated_cb(): Could not schedule a trigger for "
- "%ld, discarding...", (long) instance->trigger);
- continue;
- }
-
- qa = g_new (QueuedAlarm, 1);
- qa->alarm_id = alarm_id;
- qa->instance = instance;
- qa->snooze = FALSE;
-
- cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa);
- }
-
- cqa->queued_alarms = g_slist_reverse (cqa->queued_alarms);
+ g_message ("Already existing alarms");
+ /* if the alarms or the alarms list is empty, just remove it */
+ if (alarms == NULL || alarms->alarms == NULL) {
+ if (alarms)
+ e_cal_component_alarms_free (alarms);
+ continue;
+ }
+
+ /* if already in the list, just update it */
+ remove_alarms (cqa, FALSE);
+ cqa->alarms = alarms;
+ cqa->queued_alarms = NULL;
+
+ /* add the new alarms */
+ for (sl = cqa->alarms->alarms; sl; sl = sl->next) {
+ ECalComponentAlarmInstance *instance;
+ gpointer alarm_id;
+ QueuedAlarm *qa;
+
+ instance = sl->data;
+
+ alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL);
+ if (!alarm_id) {
+ g_message (G_STRLOC ": Could not schedule a trigger for "
+ "%ld, discarding...", (long) instance->trigger);
+ continue;
}
+
+ qa = g_new (QueuedAlarm, 1);
+ qa->alarm_id = alarm_id;
+ qa->instance = instance;
+ qa->snooze = FALSE;
+
+ cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa);
}
+
+ cqa->queued_alarms = g_slist_reverse (cqa->queued_alarms);
}
}
@@ -655,31 +662,22 @@ edit_component (ECal *client, ECalComponent *comp)
factory = bonobo_activation_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_CompEditorFactory:" BASE_VERSION,
0, NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("edit_component(): Could not activate the component editor factory");
+ if (BONOBO_EX (&ev)) {
+ g_message (G_STRLOC ": Could not activate the component editor factory");
CORBA_exception_free (&ev);
return;
}
- CORBA_exception_free (&ev);
/* Edit the component */
-
- CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_CompEditorFactory_editExisting (factory, uri, (char *) uid, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("edit_component(): Exception while editing the component");
+ if (BONOBO_EX (&ev))
+ g_message (G_STRLOC ": Exception while editing the component");
CORBA_exception_free (&ev);
/* Get rid of the factory */
-
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (factory, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("edit_component(): Could not unref the calendar component factory");
-
- CORBA_exception_free (&ev);
+ bonobo_object_release_unref (factory, NULL);
}
typedef struct {
@@ -909,7 +907,6 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
{
QueuedAlarm *qa;
ECalComponent *comp;
- ECalComponentVType vtype;
const char *message;
ECalComponentAlarm *alarm;
GtkWidget *tray_icon, *image, *ebox;
@@ -924,9 +921,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
qa = lookup_queued_alarm (cqa, alarm_id);
if (!qa)
return;
-
- vtype = e_cal_component_get_vtype (comp);
-
+
/* get a sensible description for the event */
alarm = e_cal_component_get_alarm (comp, qa->instance->auid);
g_assert (alarm != NULL);
@@ -1000,7 +995,11 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
tray_data->blink_id = g_timeout_add (500, tray_icon_blink_cb, tray_data);
- gtk_widget_show (tray_icon);
+ if (!config_data_get_notify_with_tray ()) {
+ open_alarm_dialog (tray_data);
+ } else {
+ gtk_widget_show (tray_icon);
+ }
}
/* Performs notification of an audio alarm */
diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c
index 8c6c4c59cd..3054cfa8f5 100644
--- a/calendar/gui/alarm-notify/alarm.c
+++ b/calendar/gui/alarm-notify/alarm.c
@@ -45,7 +45,7 @@ typedef struct {
AlarmDestroyNotify destroy_notify_fn;
} AlarmRecord;
-static void setup_timeout (time_t now);
+static void setup_timeout (void);
@@ -78,6 +78,7 @@ alarm_ready_cb (gpointer data)
now = time (NULL);
+ g_message ("Alarm callback!");
while (alarms) {
AlarmRecord *notify_id, *ar;
AlarmRecord ar_copy;
@@ -87,6 +88,7 @@ alarm_ready_cb (gpointer data)
if (ar->trigger > now)
break;
+ g_message ("Process alarm with trigger %lu", ar->trigger);
notify_id = ar;
ar_copy = *ar;
@@ -100,15 +102,12 @@ alarm_ready_cb (gpointer data)
(* ar->destroy_notify_fn) (notify_id, ar->data);
}
- if (alarms) {
- /* We need this check because one of the alarm_fn above may have
- * re-entered and added an alarm of its own, so the timer will
- * already be set up.
- */
- if (timeout_id == 0)
- setup_timeout (now);
- } else
- g_assert (timeout_id == 0);
+ /* We need this check because one of the alarm_fn above may have
+ * re-entered and added an alarm of its own, so the timer will
+ * already be set up.
+ */
+ if (alarms)
+ setup_timeout ();
return FALSE;
}
@@ -117,24 +116,30 @@ alarm_ready_cb (gpointer data)
* timezones here, as this is just a periodic check on the alarm queue.
*/
static void
-setup_timeout (time_t now)
+setup_timeout (void)
{
- time_t next, diff;
- struct tm tm;
-
- g_assert (timeout_id == 0);
+ const AlarmRecord *ar;
+ guint diff;
+ time_t now;
g_assert (alarms != NULL);
- tm = *localtime (&now);
- tm.tm_sec = 0;
- tm.tm_min++; /* next minute */
-
- next = mktime (&tm);
- g_assert (next != -1);
+ ar = alarms->data;
- diff = next - now;
+ /* Remove the existing time out */
+ if (timeout_id != 0) {
+ g_source_remove (timeout_id);
+ timeout_id = 0;
+ }
- g_assert (diff >= 0);
+ /* Ensure that if the trigger managed to get behind the
+ * current time we timeout immediately */
+ diff = MAX (0, ar->trigger - time (NULL));
+ now = time (NULL);
+
+ /* Add the time out */
+ g_message ("Setting timeout for %d %lu %lu", diff, ar->trigger, now);
+ g_message (" %s", ctime (&ar->trigger));
+ g_message (" %s", ctime (&now));
timeout_id = g_timeout_add (diff * 1000, alarm_ready_cb, NULL);
}
@@ -154,30 +159,20 @@ compare_alarm_by_time (gconstpointer a, gconstpointer b)
static void
queue_alarm (AlarmRecord *ar)
{
- time_t now;
- AlarmRecord *old_head;
-
- if (alarms) {
- g_assert (timeout_id != 0);
-
- old_head = alarms->data;
- } else {
- g_assert (timeout_id == 0);
+ GList *old_head;
- old_head = NULL;
- }
+ /* Track the current head of the list in case there are changes */
+ old_head = alarms;
+ /* Insert the new alarm in order */
alarms = g_list_insert_sorted (alarms, ar, compare_alarm_by_time);
- if (old_head == alarms->data)
+ /* If there first item on the list didn't change, the time out is fine */
+ if (old_head == alarms)
return;
/* Set the timer for removal upon activation */
-
- if (!old_head) {
- now = time (NULL);
- setup_timeout (now);
- }
+ setup_timeout ();
}
@@ -235,7 +230,7 @@ alarm_remove (gpointer alarm)
l = g_list_find (alarms, ar);
if (!l) {
- g_message ("alarm_remove(): Requested removal of nonexistent alarm!");
+ g_message (G_STRLOC ": Requested removal of nonexistent alarm!");
return;
}
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c
index bbc508577b..cd3f7ed885 100644
--- a/calendar/gui/alarm-notify/config-data.c
+++ b/calendar/gui/alarm-notify/config-data.c
@@ -138,49 +138,14 @@ config_data_get_24_hour_format (void)
return TRUE;
}
-GPtrArray *
-config_data_get_calendars_to_load (void)
+gboolean
+config_data_get_notify_with_tray (void)
{
- GPtrArray *cals;
- GSList *uids_selected, *l;
- ESource *source;
-
ensure_inited ();
- /* create the array to be returned */
- cals = g_ptr_array_new ();
-
- /* get selected calendars */
- uids_selected = gconf_client_get_list (conf_client, "/apps/evolution/calendar/display/selected_calendars",
- GCONF_VALUE_STRING, NULL);
- for (l = uids_selected; l != NULL; l = l->next) {
- char *uid = l->data;
-
- source = e_source_list_peek_source_by_uid (calendar_source_list, uid);
- if (source)
- g_ptr_array_add (cals, source);
-
- g_free (uid);
- }
-
- g_slist_free (uids_selected);
-
- /* get selected tasks */
- uids_selected = gconf_client_get_list (conf_client, "/apps/evolution/calendar/tasks/selected_tasks",
- GCONF_VALUE_STRING, NULL);
- for (l = uids_selected; l != NULL; l = l->next) {
- char *uid = l->data;
-
- source = e_source_list_peek_source_by_uid (calendar_source_list, uid);
- if (source)
- g_ptr_array_add (cals, source);
-
- g_free (uid);
- }
-
- g_slist_free (uids_selected);
-
- return cals;
+ return gconf_client_get_bool (conf_client,
+ "/apps/evolution/calendar/notify/notify_with_tray",
+ NULL);
}
/**
diff --git a/calendar/gui/alarm-notify/config-data.h b/calendar/gui/alarm-notify/config-data.h
index f5af885653..e5b2c3d689 100644
--- a/calendar/gui/alarm-notify/config-data.h
+++ b/calendar/gui/alarm-notify/config-data.h
@@ -29,7 +29,7 @@ GConfClient *config_data_get_conf_client (void);
icaltimezone *config_data_get_timezone (void);
gboolean config_data_get_24_hour_format (void);
-GPtrArray *config_data_get_calendars_to_load (void);
+gboolean config_data_get_notify_with_tray (void);
void config_data_set_last_notification_time (time_t t);
time_t config_data_get_last_notification_time (void);
void config_data_save_blessed_program (const char *program);
diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c
index d6004ba5e9..91fc0c0bfe 100644
--- a/calendar/gui/alarm-notify/notify-main.c
+++ b/calendar/gui/alarm-notify/notify-main.c
@@ -113,40 +113,15 @@ alarm_notify_factory_fn (BonoboGenericFactory *factory, const char *component_id
return BONOBO_OBJECT (alarm_notify_service);
}
-/* Loads the calendars that the alarm daemon has been told to load in the past */
+/* Creates the alarm notifier */
static gboolean
-load_calendars (gpointer user_data)
+init_alarm_service (gpointer user_data)
{
- GPtrArray *cals;
- int i;
-
- alarm_queue_init ();
-
- /* create the alarm notification service */
if (!alarm_notify_service) {
alarm_notify_service = alarm_notify_new ();
g_assert (alarm_notify_service != NULL);
}
-
- cals = config_data_get_calendars_to_load ();
- if (!cals) {
- g_message ("load_calendars(): Could not get the list of calendars to load");
- return TRUE; /* should we continue retrying? */;
- }
-
- for (i = 0; i < cals->len; i++) {
- ESource *source;
- char *uri;
-
- source = cals->pdata[i];
-
- uri = e_source_get_uri (source);
- alarm_notify_add_calendar (alarm_notify_service, uri, FALSE);
- g_free (uri);
- }
-
- g_ptr_array_free (cals, TRUE);
-
+
return FALSE;
}
@@ -163,9 +138,6 @@ main (int argc, char **argv)
CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
g_error (_("Could not initialize Bonobo"));
- if (!gnome_vfs_init ())
- g_error (_("Could not initialize gnome-vfs"));
-
glade_init ();
gnome_sound_init ("localhost");
@@ -179,7 +151,7 @@ main (int argc, char **argv)
init_session ();
- g_idle_add ((GSourceFunc) load_calendars, NULL);
+ g_idle_add ((GSourceFunc) init_alarm_service, NULL);
bonobo_main ();
@@ -194,7 +166,6 @@ main (int argc, char **argv)
e_passwords_shutdown ();
gnome_sound_shutdown ();
- gnome_vfs_shutdown ();
return 0;
}
diff --git a/calendar/gui/apps_evolution_calendar.schemas.in.in b/calendar/gui/apps_evolution_calendar.schemas.in.in
index 03dbe29296..1939dcfeab 100644
--- a/calendar/gui/apps_evolution_calendar.schemas.in.in
+++ b/calendar/gui/apps_evolution_calendar.schemas.in.in
@@ -344,6 +344,17 @@
<short>Programs that can run as part of alarms</short>
</locale>
</schema>
+
+ <schema>
+ <key>/schemas/apps/evolution/calendar/notify/notify_with_tray</key>
+ <applyto>/apps/evolution/calendar/notify/notify_with_tray</applyto>
+ <owner>evolution-calendar</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Whether or not to use the notification tray for display alarms</short>
+ </locale>
+ </schema>
<schema>
<key>/schemas/apps/evolution/calendar/publish/uris</key>