diff options
Diffstat (limited to 'calendar/gui/alarm-notify')
-rw-r--r-- | calendar/gui/alarm-notify/.cvsignore | 7 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/Makefile.am | 58 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 248 |
3 files changed, 110 insertions, 203 deletions
diff --git a/calendar/gui/alarm-notify/.cvsignore b/calendar/gui/alarm-notify/.cvsignore index 5d0cf13a94..f6892abafa 100644 --- a/calendar/gui/alarm-notify/.cvsignore +++ b/calendar/gui/alarm-notify/.cvsignore @@ -8,5 +8,8 @@ evolution-calendar-skels.c evolution-calendar-common.c evolution-calendar.h evolution-alarm-notify -GNOME_Evolution_Calendar_AlarmNotify.server -GNOME_Evolution_Calendar_AlarmNotify.server.in +Evolution-Composer-common.c +Evolution-Composer-skels.c +Evolution-Composer-stubs.c +Evolution-Composer.h +GNOME_Evolution_Calendar_AlarmNotify.oaf diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am index a85e99a9cf..eedfb95040 100644 --- a/calendar/gui/alarm-notify/Makefile.am +++ b/calendar/gui/alarm-notify/Makefile.am @@ -1,21 +1,30 @@ -CORBA_GENERATED_H = \ - evolution-calendar.h -CORBA_GENERATED_C = \ +CORBA_GENERATED = \ + Evolution-Composer.h \ + Evolution-Composer-common.c \ + Evolution-Composer-skels.c \ + Evolution-Composer-stubs.c \ + evolution-calendar.h \ evolution-calendar-common.c \ evolution-calendar-skels.c \ evolution-calendar-stubs.c -CORBA_GENERATED = $(CORBA_GENERATED_C) $(CORBA_GENERATED_H) -idls = $(top_srcdir)/calendar/idl/evolution-calendar.idl -idl_flags = $(IDL_INCLUDES) +idls = \ + $(top_srcdir)/composer/Evolution-Composer.idl \ + $(top_srcdir)/calendar/idl/evolution-calendar.idl -$(CORBA_GENERATED_H): $(idls) +idl_flags = `$(GNOME_CONFIG) --cflags idl` -I $(datadir)/idl + +$(CORBA_GENERATED): $(idls) + $(ORBIT_IDL) $(idl_flags) $(srcdir)/../../../composer/Evolution-Composer.idl $(ORBIT_IDL) $(idl_flags) $(top_srcdir)/calendar/idl/evolution-calendar.idl -$(CORBA_GENERATED_C): $(CORBA_GENERATED_H) +bin_PROGRAMS = evolution-alarm-notify -privlibexec_PROGRAMS = evolution-alarm-notify +noinst_LIBRARIES = libalarm.a +libalarm_a_SOURCES = \ + alarm.c \ + alarm.h INCLUDES = \ -DG_LOG_DOMAIN=\"evolution-alarm-notify\" \ @@ -25,18 +34,22 @@ INCLUDES = \ -I$(top_srcdir)/libical/src/libical \ -I$(top_builddir)/libical/src/libical \ -I$(top_srcdir)/widgets \ + -I$(includedir) \ + -DEVOLUTION_DATADIR=\""$(datadir)"\" \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ + -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ $(EVOLUTION_CALENDAR_CFLAGS) +iconsdir = $(datadir)/images/evolution + +gladedir = $(datadir)/evolution/glade + glade_DATA = \ alarm-notify.glade evolution_alarm_notify_SOURCES = \ $(CORBA_GENERATED) \ - alarm.c \ - alarm.h \ alarm-notify.c \ alarm-notify.h \ alarm-notify-dialog.c \ @@ -50,22 +63,27 @@ evolution_alarm_notify_SOURCES = \ save.h evolution_alarm_notify_LDADD = \ + libalarm.a \ $(top_builddir)/calendar/cal-client/libcal-client.la \ $(top_builddir)/calendar/cal-util/libcal-util.la \ + $(top_builddir)/libical/src/libical/libical-evolution.la \ + $(top_builddir)/libwombat/libwombat.la \ + $(top_builddir)/e-util/libeutil.la \ $(EVOLUTION_CALENDAR_LIBS) -server_in_files = \ - GNOME_Evolution_Calendar_AlarmNotify.server.in.in +evolution_alarm_notify_LDFLAGS = -export-dynamic + +oafdir = $(datadir)/oaf +oaf_in_files = \ + GNOME_Evolution_Calendar_AlarmNotify.oaf.in -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@LIBEXECDIR\@|$(privlibexecdir)|" $< > $@ +oaf_DATA = $(oaf_in_files:.oaf.in=.oaf) -@INTLTOOL_SERVER_RULE@ +@XML_I18N_MERGE_OAF_RULE@ EXTRA_DIST = \ - $(server_DATA) \ - $(server_in_files) \ + $(oaf_DATA) \ + $(oaf_in_files) \ $(glade_DATA) BUILT_SOURCES = $(CORBA_GENERATED) diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index fc52172851..c24adc0ec3 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -22,20 +22,20 @@ #include <config.h> #endif -#include <string.h> #include <glib.h> -#include <bonobo-activation/bonobo-activation.h> +#include <liboaf/liboaf.h> #include <bonobo/bonobo-object.h> #include <gtk/gtksignal.h> #include <gtk/gtkbox.h> -#include <gtk/gtkdialog.h> #include <gtk/gtklabel.h> #include <gtk/gtkcheckbutton.h> -#include <gtk/gtkstock.h> +#include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-exec.h> #include <libgnome/gnome-sound.h> +#include <libgnomeui/gnome-dialog.h> #include <libgnomeui/gnome-dialog-util.h> +#include <libgnomeui/gnome-stock.h> #include <libgnomeui/gnome-uidefs.h> #include <cal-util/timeutil.h> #include "alarm.h" @@ -87,9 +87,6 @@ typedef struct { /* List of QueuedAlarm structures */ GSList *queued_alarms; - - /* Flags */ - gboolean expecting_update; } CompQueuedAlarms; /* Pair of a queued alarm ID and the alarm trigger instance it refers to */ @@ -196,8 +193,7 @@ lookup_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id) * the last one listed for the component, it removes the component itself. */ static void -remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, - gboolean free_object, gboolean remove_alarm) +remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id) { QueuedAlarm *qa; const char *uid; @@ -217,13 +213,6 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, cqa->queued_alarms = g_slist_remove_link (cqa->queued_alarms, l); g_slist_free_1 (l); - if (remove_alarm) { - cal_component_remove_alarm (cqa->alarms->comp, qa->instance->auid); - cqa->expecting_update = TRUE; - cal_client_update_object (cqa->parent_client->client, cqa->alarms->comp); - cqa->expecting_update = FALSE; - } - g_free (qa); /* If this was the last queued alarm for this component, remove the @@ -233,16 +222,14 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, if (cqa->queued_alarms != NULL) return; - if (free_object) { - cal_component_get_uid (cqa->alarms->comp, &uid); - g_hash_table_remove (cqa->parent_client->uid_alarms_hash, uid); - cqa->parent_client = NULL; - cal_component_alarms_free (cqa->alarms); - g_free (cqa); - } else { - cal_component_alarms_free (cqa->alarms); - cqa->alarms = NULL; - } + cal_component_get_uid (cqa->alarms->comp, &uid); + g_hash_table_remove (cqa->parent_client->uid_alarms_hash, uid); + cqa->parent_client = NULL; + + cal_component_alarms_free (cqa->alarms); + cqa->alarms = NULL; + + g_free (cqa); } /* Callback used when an alarm triggers */ @@ -319,7 +306,6 @@ add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms) cqa = g_new (CompQueuedAlarms, 1); cqa->parent_client = ca; cqa->alarms = alarms; - cqa->expecting_update = FALSE; cqa->queued_alarms = NULL; @@ -438,11 +424,22 @@ lookup_comp_queued_alarms (ClientAlarms *ca, const char *uid) return g_hash_table_lookup (ca->uid_alarms_hash, uid); } +/* Removes a component an its alarms */ static void -remove_alarms (CompQueuedAlarms *cqa, gboolean free_object) +remove_comp (ClientAlarms *ca, const char *uid) { + CompQueuedAlarms *cqa; GSList *l; + cqa = lookup_comp_queued_alarms (ca, uid); + if (!cqa) + return; + + /* If a component is present, then it means we must have alarms queued + * for it. + */ + g_assert (cqa->queued_alarms != NULL); + for (l = cqa->queued_alarms; l;) { QueuedAlarm *qa; @@ -455,28 +452,9 @@ remove_alarms (CompQueuedAlarms *cqa, gboolean free_object) l = l->next; alarm_remove (qa->alarm_id); - remove_queued_alarm (cqa, qa->alarm_id, free_object, FALSE); + remove_queued_alarm (cqa, qa->alarm_id); } -} - -/* Removes a component an its alarms */ -static void -remove_comp (ClientAlarms *ca, const char *uid) -{ - CompQueuedAlarms *cqa; - - cqa = lookup_comp_queued_alarms (ca, uid); - if (!cqa) - return; - - /* If a component is present, then it means we must have alarms queued - * for it. - */ - g_assert (cqa->queued_alarms != NULL); - - remove_alarms (cqa, TRUE); - /* The list should be empty now, and thus the queued component alarms * structure should have been freed and removed from the hash table. */ @@ -494,10 +472,11 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) CalComponentAlarms *alarms; gboolean found; icaltimezone *zone; - CompQueuedAlarms *cqa; ca = data; + remove_comp (ca, uid); + now = time (NULL); zone = config_data_get_timezone (); @@ -506,51 +485,10 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) found = cal_client_get_alarms_for_object (ca->client, uid, now, day_end, &alarms); - if (!found) { - remove_comp (ca, uid); + if (!found) return; - } - - cqa = lookup_comp_queued_alarms (ca, uid); - if (!cqa) - add_component_alarms (ca, alarms); - else { - GSList *l; - - /* if already in the list, just update it */ - remove_alarms (cqa, FALSE); - cqa->alarms = alarms; - cqa->queued_alarms = NULL; - - /* add the new alarms */ - for (l = cqa->alarms->alarms; l; l = l->next) { - CalAlarmInstance *instance; - gpointer alarm_id; - QueuedAlarm *qa; - - instance = l->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); - } - if (cqa->queued_alarms == NULL) { - if (!cqa->expecting_update) - remove_comp (ca, uid); - } else - cqa->queued_alarms = g_slist_reverse (cqa->queued_alarms); - } + add_component_alarms (ca, alarms); } /* Called when a calendar component is removed; we must delete its corresponding @@ -613,22 +551,24 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, int snooze_mins) /* Launches a component editor for a component */ static void -edit_component (CalClient *client, CalComponent *comp) +edit_component (CompQueuedAlarms *cqa) { + CalComponent *comp; const char *uid; const char *uri; CORBA_Environment ev; GNOME_Evolution_Calendar_CompEditorFactory factory; + comp = cqa->alarms->comp; cal_component_get_uid (comp, &uid); - uri = cal_client_get_uri (client); + uri = cal_client_get_uri (cqa->parent_client->client); /* Get the factory */ CORBA_exception_init (&ev); - factory = bonobo_activation_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_CompEditorFactory", - 0, NULL, &ev); + factory = oaf_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_CompEditorFactory", + 0, NULL, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_message ("edit_component(): Could not activate the component editor factory"); @@ -660,33 +600,8 @@ edit_component (CalClient *client, CalComponent *comp) struct notify_dialog_closure { CompQueuedAlarms *cqa; gpointer alarm_id; - CalClient *client; - CalComponent *comp; - gpointer dialog; }; -static void -on_dialog_obj_updated_cb (CalClient *client, const char *uid, gpointer data) -{ - struct notify_dialog_closure *c = data; -} - -static void -on_dialog_obj_removed_cb (CalClient *client, const char *uid, gpointer data) -{ - const char *our_uid; - struct notify_dialog_closure *c = data; - - cal_component_get_uid (c->comp, &our_uid); - g_return_if_fail (our_uid && *our_uid); - - if (!strcmp (uid, our_uid)) { - alarm_notify_dialog_disable_buttons (c->dialog); - c->cqa = NULL; - c->alarm_id = NULL; - } -} - /* Callback used from the alarm notify dialog */ static void notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data) @@ -695,18 +610,13 @@ notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data) c = data; - g_signal_handlers_disconnect_matched (c->client, G_SIGNAL_MATCH_FUNC, - 0, 0, NULL, on_dialog_obj_updated_cb, NULL); - g_signal_handlers_disconnect_matched (c->client, G_SIGNAL_MATCH_FUNC, - 0, 0, NULL, on_dialog_obj_removed_cb, NULL); - switch (result) { case ALARM_NOTIFY_SNOOZE: create_snooze (c->cqa, c->alarm_id, snooze_mins); break; case ALARM_NOTIFY_EDIT: - edit_component (c->client, c->comp); + edit_component (c->cqa); break; case ALARM_NOTIFY_CLOSE: @@ -717,10 +627,7 @@ notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data) g_assert_not_reached (); } - if (c->cqa != NULL) - remove_queued_alarm (c->cqa, c->alarm_id, TRUE, TRUE); - g_object_unref (c->comp); - g_object_unref (c->client); + remove_queued_alarm (c->cqa, c->alarm_id); g_free (c); } @@ -777,21 +684,12 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, c = g_new (struct notify_dialog_closure, 1); c->cqa = cqa; c->alarm_id = alarm_id; - c->comp = cal_component_clone (comp); - c->client = c->cqa->parent_client->client; - g_object_ref (c->client); - - if (!(c->dialog = alarm_notify_dialog (trigger, - qa->instance->occur_start, qa->instance->occur_end, - vtype, message, - notify_dialog_cb, c))) + + if (!alarm_notify_dialog (trigger, + qa->instance->occur_start, qa->instance->occur_end, + vtype, message, + notify_dialog_cb, c)) g_message ("display_notification(): Could not create the alarm notify dialog"); - else { - g_signal_connect (c->client, "obj_updated", - G_CALLBACK (on_dialog_obj_updated_cb), c); - g_signal_connect (c->client, "obj_removed", - G_CALLBACK (on_dialog_obj_removed_cb), c); - } } /* Performs notification of an audio alarm */ @@ -836,23 +734,16 @@ static void mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) { GtkWidget *dialog; - GtkWidget *label; /* FIXME */ display_notification (trigger, cqa, alarm_id, FALSE); - dialog = gtk_dialog_new_with_buttons (_("Warning"), - NULL, 0, - GTK_STOCK_OK, GTK_RESPONSE_CANCEL, - NULL); - label = gtk_label_new (_("Evolution does not support calendar reminders with\n" - "email notifications yet, but this reminder was\n" - "configured to send an email. Evolution will display\n" - "a normal reminder dialog box instead.")); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4); - - gtk_dialog_run (GTK_DIALOG (dialog)); + dialog = gnome_warning_dialog (_("Evolution does not support calendar reminders with\n" + "email notifications yet, but this reminder was\n" + "configured to send an email. Evolution will display\n" + "a normal reminder dialog box instead.")); + gnome_dialog_run (GNOME_DIALOG (dialog)); } /* Performs notification of a procedure alarm */ @@ -866,11 +757,10 @@ procedure_notification_dialog (const char *cmd, const char *url) if (is_blessed_program (url)) return TRUE; - dialog = gtk_dialog_new_with_buttons (_("Warning"), - NULL, 0, - GTK_STOCK_NO, GTK_RESPONSE_CANCEL, - GTK_STOCK_YES, GTK_RESPONSE_OK, - NULL); + dialog = gnome_dialog_new (_("Warning"), + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); str = g_strdup_printf (_("An Evolution Calendar reminder is about to trigger. " "This reminder is configured to run the following program:\n\n" @@ -881,21 +771,21 @@ procedure_notification_dialog (const char *cmd, const char *url) gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4); g_free (str); checkbox = gtk_check_button_new_with_label (_("Do not ask me about this program again.")); gtk_widget_show (checkbox); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), checkbox, TRUE, TRUE, 4); /* Run the dialog */ - btn = gtk_dialog_run (GTK_DIALOG (dialog)); - if (btn == GTK_RESPONSE_OK && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox))) + btn = gnome_dialog_run (GNOME_DIALOG (dialog)); + if (btn == GNOME_YES && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox))) save_blessed_program (url); - gtk_widget_destroy (dialog); + gnome_dialog_close (GNOME_DIALOG (dialog)); return (btn == GNOME_YES); } @@ -955,7 +845,7 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id if (result < 0) goto fallback; - remove_queued_alarm (cqa, alarm_id, TRUE, TRUE); + remove_queued_alarm (cqa, alarm_id); return; fallback: @@ -1045,7 +935,7 @@ alarm_queue_add_client (CalClient *client) ca = g_new (ClientAlarms, 1); ca->client = client; - g_object_ref (ca->client); + gtk_object_ref (GTK_OBJECT (ca->client)); ca->refcount = 1; g_hash_table_insert (client_alarms_hash, client, ca); @@ -1053,16 +943,13 @@ alarm_queue_add_client (CalClient *client) ca->uid_alarms_hash = g_hash_table_new (g_str_hash, g_str_equal); if (cal_client_get_load_state (client) != CAL_CLIENT_LOAD_LOADED) - g_signal_connect (client, "cal_opened", - G_CALLBACK (cal_opened_cb), - ca); + gtk_signal_connect (GTK_OBJECT (client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), ca); - g_signal_connect (client, "obj_updated", - G_CALLBACK (obj_updated_cb), - ca); - g_signal_connect (client, "obj_removed", - G_CALLBACK (obj_removed_cb), - ca); + gtk_signal_connect (GTK_OBJECT (client), "obj_updated", + GTK_SIGNAL_FUNC (obj_updated_cb), ca); + gtk_signal_connect (GTK_OBJECT (client), "obj_removed", + GTK_SIGNAL_FUNC (obj_removed_cb), ca); if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED) { load_alarms_for_today (ca); @@ -1138,10 +1025,9 @@ alarm_queue_remove_client (CalClient *client) /* Clean up */ - g_signal_handlers_disconnect_matched (ca->client, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, ca); + gtk_signal_disconnect_by_data (GTK_OBJECT (ca->client), ca); - g_object_unref (ca->client); + gtk_object_unref (GTK_OBJECT (ca->client)); ca->client = NULL; g_hash_table_destroy (ca->uid_alarms_hash); |