From b597fe284460110f74b30e225976ccf0590b4b9c Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Thu, 20 Sep 2001 02:35:36 +0000 Subject: Display a notification message always, in addition to playing the sound. 2001-09-19 Federico Mena Quintero * gui/alarm-notify/alarm-queue.c (audio_notification): Display a notification message always, in addition to playing the sound. (procedure_notification): Present a confirmation dialog before actually running the alarm's program. (procedure_notification): Use gnome_execute_shell() instead of gnome_execute_async() so that we handle multiple arguments properly. Plus, it is most likely what the user expects. (mail_notification): Display a message about unsupported email reminders instead of blindly dropping the alarm. * gui/dialogs/alarm-options.glade: Added an explanatory message about mail alarms not being supported. * gui/dialogs/alarm-page.glade: Removed the "Send an email" option. * gui/dialogs/alarm-page.c (action_map): Removed CAL_ALARM_EMAIL. svn path=/trunk/; revision=13004 --- calendar/gui/alarm-notify/alarm-queue.c | 76 +++++++++++++++++++++----------- calendar/gui/dialogs/alarm-options.glade | 4 +- calendar/gui/dialogs/alarm-page.c | 1 - calendar/gui/dialogs/alarm-page.glade | 1 - 4 files changed, 52 insertions(+), 30 deletions(-) (limited to 'calendar/gui') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 7b7903900d..c73f1a760b 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include #include #include #include "alarm.h" @@ -94,6 +97,7 @@ static gpointer midnight_refresh_id = NULL; static void display_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id, gboolean use_description); static void audio_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id); +static void mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id); static void procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id); @@ -251,8 +255,7 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) break; case CAL_ALARM_EMAIL: - /* FIXME: mail_notification (); */ - remove_queued_alarm (cqa, alarm_id); + mail_notification (trigger, cqa, alarm_id); break; case CAL_ALARM_PROCEDURE: @@ -646,7 +649,6 @@ audio_notification (time_t trigger, CompQueuedAlarms *cqa, CalComponent *comp; CalComponentAlarm *alarm; icalattach *attach; - const char *url; comp = cqa->alarms->comp; qa = lookup_queued_alarm (cqa, alarm_id); @@ -658,27 +660,37 @@ audio_notification (time_t trigger, CompQueuedAlarms *cqa, cal_component_alarm_get_attach (alarm, &attach); cal_component_alarm_free (alarm); - /* If the alarm has no attachment, simply display a notification dialog. */ - if (!attach) - goto fallback; + if (attach && icalattach_get_is_url (attach)) { + const char *url; - if (!icalattach_get_is_url (attach)) { - icalattach_unref (attach); - goto fallback; + url = icalattach_get_url (attach); + g_assert (url != NULL); + + gnome_sound_play (url); /* this sucks */ } - url = icalattach_get_url (attach); - g_assert (url != NULL); + if (attach) + icalattach_unref (attach); - gnome_sound_play (url); /* this sucks */ - icalattach_unref (attach); + /* We present a notification message in addition to playing the sound */ + display_notification (trigger, cqa, alarm_id, FALSE); +} - remove_queued_alarm (cqa, alarm_id); - return; +/* Performs notification of a mail alarm */ +static void +mail_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) +{ + GtkWidget *dialog; - fallback: + /* FIXME */ display_notification (trigger, cqa, alarm_id, FALSE); + + 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 */ @@ -691,6 +703,8 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id CalComponentText description; icalattach *attach; const char *url; + char *cmd, *str; + GtkWidget *dialog; int result; comp = cqa->alarms->comp; @@ -716,18 +730,28 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id url = icalattach_get_url (attach); g_assert (url != NULL); - if (description.value) { - char *argv[2]; + /* Ask for confirmation before executing the stuff */ - argv[0] = (char *) url; - argv[1] = (char *) description.value; - result = gnome_execute_async (NULL, 2, argv); - } else { - char *argv[1]; + if (description.value) + cmd = g_strconcat (url, " ", description.value, NULL); + else + cmd = (char *) url; - argv[0] = (char *) url; - result = gnome_execute_async (NULL, 1, argv); - } + str = g_strdup_printf (_("An Evolution Calendar reminder is about to trigger.\n" + "This reminder is configured to run the following program:\n\n" + " %s\n\n" + "Are you sure you want to run this program?"), + cmd); + + dialog = gnome_question_dialog_modal (str, NULL, NULL); + g_free (str); + + result = 0; + if (gnome_dialog_run (GNOME_DIALOG (dialog)) == GNOME_YES) + result = gnome_execute_shell (NULL, cmd); + + if (cmd != (char *) url) + g_free (cmd); icalattach_unref (attach); diff --git a/calendar/gui/dialogs/alarm-options.glade b/calendar/gui/dialogs/alarm-options.glade index ad0c181561..02c5d3f953 100644 --- a/calendar/gui/dialogs/alarm-options.glade +++ b/calendar/gui/dialogs/alarm-options.glade @@ -267,9 +267,9 @@ days GtkLabel malarm-group False - + GTK_JUSTIFY_CENTER - False + True 0.5 0.5 0 diff --git a/calendar/gui/dialogs/alarm-page.c b/calendar/gui/dialogs/alarm-page.c index 5ef9a2c15c..e140392d98 100644 --- a/calendar/gui/dialogs/alarm-page.c +++ b/calendar/gui/dialogs/alarm-page.c @@ -87,7 +87,6 @@ enum { static const int action_map[] = { CAL_ALARM_DISPLAY, CAL_ALARM_AUDIO, - CAL_ALARM_EMAIL, CAL_ALARM_PROCEDURE, -1 }; diff --git a/calendar/gui/dialogs/alarm-page.glade b/calendar/gui/dialogs/alarm-page.glade index c1e6010431..fad62dad70 100644 --- a/calendar/gui/dialogs/alarm-page.glade +++ b/calendar/gui/dialogs/alarm-page.glade @@ -198,7 +198,6 @@ True Display a message Play a sound -Send an email Run a program 0 -- cgit v1.2.3