diff options
Diffstat (limited to 'calendar/cal-util')
-rw-r--r-- | calendar/cal-util/cal-util.c | 48 | ||||
-rw-r--r-- | calendar/cal-util/cal-util.h | 4 |
2 files changed, 52 insertions, 0 deletions
diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c index 1df57bacec..774b9aca11 100644 --- a/calendar/cal-util/cal-util.c +++ b/calendar/cal-util/cal-util.c @@ -22,6 +22,9 @@ #include <config.h> #include <stdlib.h> +#include <glib.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> #include "cal-util.h" @@ -400,3 +403,48 @@ cal_util_generate_alarms_for_list (GList *comps, return n; } + + +/* Converts an iCalendar PRIORITY value to a translated string. Any unknown + priority value (i.e. not 0-9) will be returned as "" (undefined). */ +char * +cal_util_priority_to_string (int priority) +{ + char *retval; + + if (priority <= 0) + retval = ""; + else if (priority <= 4) + retval = _("High"); + else if (priority == 5) + retval = _("Normal"); + else if (priority <= 9) + retval = _("Low"); + else + retval = ""; + + return retval; +} + + +/* Converts a translated priority string to an iCalendar priority value. + Returns -1 if the priority string is not valid. */ +int +cal_util_priority_from_string (const char *string) +{ + int priority; + + /* An empty string is the same as 'None'. */ + if (!string || !string[0] || !g_strcasecmp (string, _("Undefined"))) + priority = 0; + else if (!g_strcasecmp (string, _("High"))) + priority = 3; + else if (!g_strcasecmp (string, _("Normal"))) + priority = 5; + else if (!g_strcasecmp (string, _("Low"))) + priority = 7; + else + priority = -1; + + return priority; +} diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h index 362d9eaae5..9e7c7ce5e4 100644 --- a/calendar/cal-util/cal-util.h +++ b/calendar/cal-util/cal-util.h @@ -79,6 +79,10 @@ int cal_util_generate_alarms_for_list (GList *comps, icaltimezone *cal_util_resolve_tzid (const char *tzid, gpointer data); +char *cal_util_priority_to_string (int priority); +int cal_util_priority_from_string (const char *string); + + END_GNOME_DECLS #endif |