aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-09-27 08:16:24 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-09-27 08:16:24 +0800
commit4be389206bca0035db6d8cf245c23a16c12e8fa1 (patch)
tree4407c9eeeee1a39807f8476f648df6a9ad094335 /calendar/gui
parent0d1f3b890ac279e56731656fafec7ba738300da6 (diff)
downloadgsoc2013-evolution-4be389206bca0035db6d8cf245c23a16c12e8fa1.tar
gsoc2013-evolution-4be389206bca0035db6d8cf245c23a16c12e8fa1.tar.gz
gsoc2013-evolution-4be389206bca0035db6d8cf245c23a16c12e8fa1.tar.bz2
gsoc2013-evolution-4be389206bca0035db6d8cf245c23a16c12e8fa1.tar.lz
gsoc2013-evolution-4be389206bca0035db6d8cf245c23a16c12e8fa1.tar.xz
gsoc2013-evolution-4be389206bca0035db6d8cf245c23a16c12e8fa1.tar.zst
gsoc2013-evolution-4be389206bca0035db6d8cf245c23a16c12e8fa1.zip
Fixes the GUI part of bug #7892.
2001-09-26 Federico Mena Quintero <federico@ximian.com> Fixes the GUI part of bug #7892. * gui/dialogs/alarm-page.c (get_alarm_duration_string): Return NULL if the duration is zero. (get_alarm_string): Handle duration of zero. Also, hopefully make the strings be more l10n-friendly. * gui/alarm-notify/alarm.c (alarm_ready_cb): I am a moron. Fix reversed test. svn path=/trunk/; revision=13182
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/alarm.c2
-rw-r--r--calendar/gui/dialogs/alarm-page.c124
2 files changed, 87 insertions, 39 deletions
diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c
index 0fa24f66ce..f750ed515c 100644
--- a/calendar/gui/alarm-notify/alarm.c
+++ b/calendar/gui/alarm-notify/alarm.c
@@ -106,7 +106,7 @@ alarm_ready_cb (gpointer data)
* re-entered and added an alarm of its own, so the timer will
* already be set up.
*/
- if (timeout_id != 0)
+ if (timeout_id == 0)
setup_timeout (now);
} else
g_assert (timeout_id == 0);
diff --git a/calendar/gui/dialogs/alarm-page.c b/calendar/gui/dialogs/alarm-page.c
index e140392d98..811760eb6f 100644
--- a/calendar/gui/dialogs/alarm-page.c
+++ b/calendar/gui/dialogs/alarm-page.c
@@ -293,41 +293,64 @@ clear_widgets (AlarmPage *apage)
gtk_clist_clear (GTK_CLIST (priv->list));
}
+/* Builds a string for the duration of the alarm. If the duration is zero, returns NULL. */
static char *
get_alarm_duration_string (struct icaldurationtype *duration)
{
GString *string = g_string_new (NULL);
char *ret;
+ gboolean have_something;
- if (duration->days > 1)
+ have_something = FALSE;
+
+ if (duration->days > 1) {
g_string_sprintf (string, _("%d days"), duration->days);
- else if (duration->days == 1)
+ have_something = TRUE;
+ } else if (duration->days == 1) {
g_string_append (string, _("1 day"));
+ have_something = TRUE;
+ }
- if (duration->weeks > 1)
+ if (duration->weeks > 1) {
g_string_sprintf (string, _("%d weeks"), duration->weeks);
- else if (duration->weeks == 1)
+ have_something = TRUE;
+ } else if (duration->weeks == 1) {
g_string_append (string, _("1 week"));
+ have_something = TRUE;
+ }
- if (duration->hours > 1)
+ if (duration->hours > 1) {
g_string_sprintf (string, _("%d hours"), duration->hours);
- else if (duration->hours == 1)
+ have_something = TRUE;
+ } else if (duration->hours == 1) {
g_string_append (string, _("1 hour"));
+ have_something = TRUE;
+ }
- if (duration->minutes > 1)
+ if (duration->minutes > 1) {
g_string_sprintf (string, _("%d minutes"), duration->minutes);
- else if (duration->minutes == 1)
+ have_something = TRUE;
+ } else if (duration->minutes == 1) {
g_string_append (string, _("1 minute"));
+ have_something = TRUE;
+ }
- if (duration->seconds > 1)
+ if (duration->seconds > 1) {
g_string_sprintf (string, _("%d seconds"), duration->seconds);
- else if (duration->seconds == 1)
+ have_something = TRUE;
+ } else if (duration->seconds == 1) {
g_string_append (string, _("1 second"));
+ have_something = TRUE;
+ }
- ret = string->str;
- g_string_free (string, FALSE);
-
- return ret;
+ if (have_something) {
+ ret = string->str;
+ g_string_free (string, FALSE);
+ return ret;
+ } else {
+ g_string_free (string, TRUE);
+ return NULL;
+ }
}
static char *
@@ -365,7 +388,7 @@ get_alarm_string (CalComponentAlarm *alarm)
case CAL_ALARM_NONE:
case CAL_ALARM_UNKNOWN:
default:
- base = _("Unknown");
+ base = _("Unknown action to be performed");
break;
}
@@ -375,33 +398,58 @@ get_alarm_string (CalComponentAlarm *alarm)
case CAL_ALARM_TRIGGER_RELATIVE_START:
dur = get_alarm_duration_string (&trigger.u.rel_duration);
- if (trigger.u.rel_duration.is_neg)
- str = g_strdup_printf ("%s %s %s", base, dur,
- _("before start of appointment"));
- else
- str = g_strdup_printf ("%s %s %s", base, dur,
- _("after start of appointment"));
+ if (dur) {
+ if (trigger.u.rel_duration.is_neg)
+ str = g_strdup_printf (_("%s %s before the start of the appointment"),
+ base, dur);
+ else
+ str = g_strdup_printf (_("%s %s after the start of the appointment"),
+ base, dur);
+
+ g_free (dur);
+ } else
+ str = g_strdup_printf (_("%s at the start of the appointment"), base);
- g_free (dur);
break;
case CAL_ALARM_TRIGGER_RELATIVE_END:
dur = get_alarm_duration_string (&trigger.u.rel_duration);
- if (trigger.u.rel_duration.is_neg)
- str = g_strdup_printf ("%s %s %s", base, dur,
- _("before end of appointment"));
- else
- str = g_strdup_printf ("%s %s %s", base, dur,
- _("after end of appointment"));
+ if (dur) {
+ if (trigger.u.rel_duration.is_neg)
+ str = g_strdup_printf (_("%s %s before the end of the appointment"),
+ base, dur);
+ else
+ str = g_strdup_printf (_("%s %s after the end of the appointment"),
+ base, dur);
+
+ g_free (dur);
+ } else
+ str = g_strdup_printf (_("%s at the end of the appointment"), base);
- g_free (dur);
break;
+
+ case CAL_ALARM_TRIGGER_ABSOLUTE: {
+ time_t t;
+ struct tm tm;
+ char *date;
+
+ t = icaltime_as_timet (trigger.u.abs_time);
+ if (t == -1)
+ date = g_strdup_printf (_("%s at an unknown time"), base);
+ else {
+ char buf[256];
+
+ tm = *localtime (&t);
+ strftime (buf, sizeof (buf), "%A %b %d %Y %H:%M", &tm);
+ date = g_strdup_printf (_("%s at %s"), base, buf);
+ }
+
+ break; }
+
case CAL_ALARM_TRIGGER_NONE:
- case CAL_ALARM_TRIGGER_ABSOLUTE:
default:
- str = g_strdup_printf ("%s %s", base,
- _("Unknown"));
+ str = g_strdup_printf (_("%s for an unknown trigger type"), base);
break;
}
@@ -441,7 +489,7 @@ alarm_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
GList *alarms, *l;
GtkCList *clist;
CompEditorPageDates dates;
-
+
apage = ALARM_PAGE (page);
priv = apage->priv;
@@ -536,7 +584,7 @@ alarm_page_set_summary (CompEditorPage *page, const char *summary)
AlarmPage *apage;
AlarmPagePrivate *priv;
gchar *s;
-
+
apage = ALARM_PAGE (page);
priv = apage->priv;
@@ -576,7 +624,7 @@ get_widgets (AlarmPage *apage)
gtk_widget_ref (priv->main);
gtk_widget_unparent (priv->main);
-
+
priv->summary = GW ("summary");
priv->date_time = GW ("date-time");
@@ -613,10 +661,10 @@ field_changed_cb (GtkWidget *widget, gpointer data)
{
AlarmPage *apage;
AlarmPagePrivate *priv;
-
+
apage = ALARM_PAGE (data);
priv = apage->priv;
-
+
if (!priv->updating)
comp_editor_page_notify_changed (COMP_EDITOR_PAGE (apage));
}
@@ -644,7 +692,7 @@ add_clicked_cb (GtkButton *button, gpointer data)
switch (e_dialog_option_menu_get (priv->value_units, value_map)) {
case MINUTES:
- trigger.u.rel_duration.minutes =
+ trigger.u.rel_duration.minutes =
e_dialog_spin_get_int (priv->interval_value);
break;