aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify/alarm-notify-dialog.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-07-11 07:57:55 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-07-11 07:57:55 +0800
commit39e7268930b5d5cbc6f9128ebf1a8055ed007cc6 (patch)
tree597c5878fb740534c1716ef293cb14bc113d460b /calendar/gui/alarm-notify/alarm-notify-dialog.c
parentee250cad8e32e0aaa9d9a57c4154ea7728b7c4f2 (diff)
downloadgsoc2013-evolution-39e7268930b5d5cbc6f9128ebf1a8055ed007cc6.tar.gz
gsoc2013-evolution-39e7268930b5d5cbc6f9128ebf1a8055ed007cc6.tar.zst
gsoc2013-evolution-39e7268930b5d5cbc6f9128ebf1a8055ed007cc6.zip
Handle the different alarm actions. (display_notification): Do the alarm
2001-07-10 Federico Mena Quintero <federico@ximian.com> * gui/alarm-notify/alarm-queue.c (alarm_trigger_cb): Handle the different alarm actions. (display_notification): Do the alarm notification dialog here. * gui/alarm-notify/alarm-notify-dialog.c (make_heading): Take in a CalComponentVType, not a whole component. (alarm_notify_dialog): Take in a CalComponentVType and the final message instead of generating it ourselves. svn path=/trunk/; revision=10978
Diffstat (limited to 'calendar/gui/alarm-notify/alarm-notify-dialog.c')
-rw-r--r--calendar/gui/alarm-notify/alarm-notify-dialog.c69
1 files changed, 25 insertions, 44 deletions
diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c
index 219bf7b102..2a11026f23 100644
--- a/calendar/gui/alarm-notify/alarm-notify-dialog.c
+++ b/calendar/gui/alarm-notify/alarm-notify-dialog.c
@@ -28,6 +28,7 @@
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
+#include <gal/widgets/e-unicode.h>
#include "alarm-notify-dialog.h"
@@ -41,7 +42,7 @@ typedef struct {
GtkWidget *snooze;
GtkWidget *edit;
GtkWidget *heading;
- GtkWidget *summary;
+ GtkWidget *message;
GtkWidget *snooze_time;
AlarmNotifyFunc func;
@@ -122,14 +123,11 @@ edit_clicked_cb (GtkWidget *widget, gpointer data)
/* Creates a heading for the alarm notification dialog */
static char *
-make_heading (CalComponent *comp, time_t occur_start, time_t occur_end)
+make_heading (CalComponentVType vtype, time_t occur_start, time_t occur_end)
{
- CalComponentVType vtype;
char *buf;
char s[128], e[128];
- vtype = cal_component_get_vtype (comp);
-
if (occur_start != -1) {
struct tm tm;
@@ -187,29 +185,11 @@ make_heading (CalComponent *comp, time_t occur_start, time_t occur_end)
}
break;
- case CAL_COMPONENT_JOURNAL:
- if (occur_start != -1) {
- if (occur_end != -1)
- buf = g_strdup_printf (_("Notification about your journal entry "
- "starting on %s and ending on %s"),
- s, e);
- else
- buf = g_strdup_printf (_("Notification about your journal entry "
- "starting on %s"),
- s);
- } else {
- if (occur_end != -1)
- buf = g_strdup_printf (_("Notification about your journal entry "
- "ending on %s"),
- e);
- else
- buf = g_strdup_printf (_("Notification about your journal entry"));
- }
- break;
-
default:
- g_assert_not_reached();
- return NULL;
+ /* Only VEVENTs and VTODOs can have alarms */
+ g_assert_not_reached ();
+ buf = NULL;
+ break;
}
return buf;
@@ -220,7 +200,8 @@ make_heading (CalComponent *comp, time_t occur_start, time_t occur_end)
* @trigger: Trigger time for the alarm.
* @occur_start: Start of occurrence time for the event.
* @occur_end: End of occurrence time for the event.
- * @comp: Calendar component object which corresponds to the alarm.
+ * @vtype: Type of the component which corresponds to the alarm.
+ * @message; Message to display in the dialog; usually comes from the component.
* @func: Function to be called when a dialog action is invoked.
* @func_data: Closure data for @func.
*
@@ -231,18 +212,20 @@ make_heading (CalComponent *comp, time_t occur_start, time_t occur_end)
**/
gboolean
alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
- CalComponent *comp,
+ CalComponentVType vtype, const char *message,
AlarmNotifyFunc func, gpointer func_data)
{
AlarmNotify *an;
char buf[256];
char *heading;
+ char *msg;
struct tm tm_trigger;
- CalComponentText summary;
g_return_val_if_fail (trigger != -1, FALSE);
- g_return_val_if_fail (comp != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE);
+
+ /* Only VEVENTs or VTODOs can have alarms */
+ g_return_val_if_fail (vtype == CAL_COMPONENT_EVENT || vtype == CAL_COMPONENT_TODO, FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
g_return_val_if_fail (func != NULL, FALSE);
an = g_new0 (AlarmNotify, 1);
@@ -262,10 +245,10 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
an->snooze = glade_xml_get_widget (an->xml, "snooze");
an->edit = glade_xml_get_widget (an->xml, "edit");
an->heading = glade_xml_get_widget (an->xml, "heading");
- an->summary = glade_xml_get_widget (an->xml, "summary");
+ an->message = glade_xml_get_widget (an->xml, "message");
an->snooze_time = glade_xml_get_widget (an->xml, "snooze-time");
- if (!(an->dialog && an->close && an->snooze && an->edit && an->heading && an->summary
+ if (!(an->dialog && an->close && an->snooze && an->edit && an->heading && an->message
&& an->snooze_time)) {
g_message ("alarm_notify_dialog(): Could not find all widgets in Glade file!");
gtk_object_unref (GTK_OBJECT (an->xml));
@@ -279,26 +262,24 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
/* Title */
- /* FIXME: use am_pm_flag or 24-hour time */
-
tm_trigger = *localtime (&trigger);
strftime (buf, sizeof (buf), _("Alarm on %A %b %d %Y %H:%M"), &tm_trigger);
gtk_window_set_title (GTK_WINDOW (an->dialog), buf);
/* Heading */
- heading = make_heading (comp, occur_start, occur_end);
+ heading = make_heading (vtype, occur_start, occur_end);
gtk_label_set_text (GTK_LABEL (an->heading), heading);
g_free (heading);
- /* Summary */
-
- cal_component_get_summary (comp, &summary);
+ /* Message */
- if (summary.value)
- gtk_label_set_text (GTK_LABEL (an->summary), summary.value);
- else
- gtk_label_set_text (GTK_LABEL (an->summary), _("No summary available."));
+ msg = e_utf8_to_gtk_string (an->message, message);
+ if (msg) {
+ gtk_label_set_text (GTK_LABEL (an->message), msg);
+ g_free (msg);
+ } else
+ g_message ("Could not convert the alarm message from UTF8");
/* Connect actions */