diff options
author | Srinivasa Ragavan <sragavan@novell.com> | 2005-11-23 16:19:00 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2005-11-23 16:19:00 +0800 |
commit | a722e3281e5404a902eefe0f20005f59b5b2d813 (patch) | |
tree | c589fa71f218ee0c0e17f86bf066f2866ca1ee41 /calendar/gui/misc.c | |
parent | 80f4fd336fed8066ba8db8dd398c5023b0ff4ff7 (diff) | |
download | gsoc2013-evolution-a722e3281e5404a902eefe0f20005f59b5b2d813.tar.gz gsoc2013-evolution-a722e3281e5404a902eefe0f20005f59b5b2d813.tar.zst gsoc2013-evolution-a722e3281e5404a902eefe0f20005f59b5b2d813.zip |
Added a function to get tooltip tooltip widget
2005-11-23 Srinivasa Ragavan <sragavan@novell.com>
* gui/e-calendar-view.c (tooltip_grab), (get_label),
(e_calendar_view_get_tooltips): Added a function to get tooltip
tooltip widget
* gui/e-calendar-view.h:
* gui/e-day-view.c (e_day_view_add_event),
(e_day_view_reshape_long_event), (e_day_view_reshape_day_event),
(e_day_view_on_text_item_event): Added tooltip for day/work week
view.
* gui/e-week-view.c (e_week_view_add_event), (tooltip_event_cb),
(e_week_view_reshape_event_span), (e_week_view_on_text_item_event):
Added tooltip for week/month view.
* gui/e-week-view.h:
* gui/misc.c (get_position_in_array), (calculate_time): Added a
function for converting time to string.
* gui/misc.h:
svn path=/trunk/; revision=30648
Diffstat (limited to 'calendar/gui/misc.c')
-rw-r--r-- | calendar/gui/misc.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/calendar/gui/misc.c b/calendar/gui/misc.c index 026cd8417e..5ab2739525 100644 --- a/calendar/gui/misc.c +++ b/calendar/gui/misc.c @@ -24,7 +24,10 @@ #endif #include <ctype.h> +#include <time.h> #include <libedataserver/e-url.h> +#include "e-util/e-i18n.h" + #include "misc.h" @@ -91,3 +94,52 @@ get_position_in_array (GPtrArray *objects, gpointer item) return -1; } + +char * +calculate_time (time_t start, time_t end) +{ + time_t difference = end - start; + char *str; + + if (difference < 60) {/* Can't be zero */ + str = g_strdup_printf (_("(%d seconds)"), difference); + } else if (difference > 60 && difference < 3600) { /* It will be x minutes y seconds*/ + int minutes, seconds; + minutes = difference / 60; + seconds = difference % 60; + if (seconds) + str = g_strdup_printf (_("(%d %s %d %s)"), minutes, ngettext(_("minute"), _("minutes"), minutes), seconds, ngettext(_("second"), _("seconds"), seconds)); + else + str = g_strdup_printf (_("(%d %s)"), minutes, ngettext(_("minute"), _("minutes"), minutes)); + } else { + guint hours, minutes, seconds; + char *s_hours = NULL, *s_minutes = NULL, *s_seconds = NULL; + + hours = difference / 3600; + minutes = (difference % 3600)/60; + seconds = difference % 60; + + + if (seconds) + s_seconds = g_strdup_printf (ngettext(_(" %u second"), _(" %u seconds"), seconds), seconds); + if (minutes) + s_minutes = g_strdup_printf (ngettext(_(" %u minute"), _(" %u minutes"), minutes), minutes); + if (hours) + s_hours = g_strdup_printf (ngettext(_("%u hour"),_("%u hours"), hours), hours); + + if (s_minutes && s_seconds) + str = g_strconcat ("(", s_hours, s_minutes, s_seconds, ")", NULL); + else if (s_minutes) + str = g_strconcat ("(", s_hours, s_minutes, ")", NULL); + else if (s_seconds) + str = g_strconcat ("(", s_hours, s_seconds, ")", NULL); + else + str = g_strconcat ("(", s_hours, ")", NULL); + + g_free (s_hours); + g_free (s_minutes); + g_free (s_seconds); + } + + return g_strchug(str); +} |