diff options
author | Damon Chaplin <damon@ximian.com> | 2001-10-29 06:13:13 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2001-10-29 06:13:13 +0800 |
commit | d16418158d22a039e2a9a9665a5b337aed5f510a (patch) | |
tree | a266037935761cecd56a01901524dd0bfc91a560 /calendar/gui/calendar-config.c | |
parent | df39199fb04368c2bd25e7922edb7a83be382690 (diff) | |
download | gsoc2013-evolution-d16418158d22a039e2a9a9665a5b337aed5f510a.tar.gz gsoc2013-evolution-d16418158d22a039e2a9a9665a5b337aed5f510a.tar.zst gsoc2013-evolution-d16418158d22a039e2a9a9665a5b337aed5f510a.zip |
get the tasks directly from the CalendarModel, so we get the filtering &
2001-10-28 Damon Chaplin <damon@ximian.com>
* gui/print.c (print_todo_details): get the tasks directly from the
CalendarModel, so we get the filtering & sorting for free. Fixes
bug #10280. Hmm. This seems too easy. It isn't going to work is it...
* gui/gnome-cal.c (gnome_calendar_get_task_pad): new function to get
the TaskPad ECalendarTable, for printing.
* gui/calendar-model.c:
* gui/calendar-config.c (calendar_config_get_hide_completed_tasks_sexp):
split this out from calendar-model.c so we could use it for printing,
but ended up doing that a different way.
* gui/dialogs/task-page.c (init_widgets): removed a duplicated signal
connected to field_changed_cb().
svn path=/trunk/; revision=14302
Diffstat (limited to 'calendar/gui/calendar-config.c')
-rw-r--r-- | calendar/gui/calendar-config.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index f7c18942cd..aca14f5ed5 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -32,6 +32,7 @@ #include <libgnome/gnome-config.h> #include <libgnomeui/gnome-dialog.h> #include <widgets/e-timezone-dialog/e-timezone-dialog.h> +#include <cal-util/timeutil.h> #include "component-factory.h" #include "calendar-commands.h" #include "e-tasks.h" @@ -918,3 +919,64 @@ calendar_config_set_tasks_overdue_color (const char *color) g_free (config->tasks_overdue_color); config->tasks_overdue_color = g_strdup (color); } + + +/** + * calendar_config_get_hide_completed_tasks_sexp: + * + * Returns the subexpression to use to filter out completed tasks according + * to the config settings. The returned sexp should be freed. + **/ +char* +calendar_config_get_hide_completed_tasks_sexp (void) +{ + char *sexp = NULL; + + if (calendar_config_get_hide_completed_tasks ()) { + CalUnits units; + gint value; + + units = calendar_config_get_hide_completed_tasks_units (); + value = calendar_config_get_hide_completed_tasks_value (); + + if (value == 0) { + /* If the value is 0, we want to hide completed tasks + immediately, so we filter out all completed tasks.*/ + sexp = g_strdup ("(not is-completed?)"); + } else { + char *location, *isodate; + icaltimezone *zone; + struct icaltimetype tt; + time_t t; + + /* Get the current time, and subtract the appropriate + number of days/hours/minutes. */ + location = calendar_config_get_timezone (); + zone = icaltimezone_get_builtin_timezone (location); + tt = icaltime_current_time_with_zone (zone); + + switch (units) { + case CAL_DAYS: + icaltime_adjust (&tt, -value, 0, 0, 0); + break; + case CAL_HOURS: + icaltime_adjust (&tt, 0, -value, 0, 0); + break; + case CAL_MINUTES: + icaltime_adjust (&tt, 0, 0, -value, 0); + break; + default: + g_assert_not_reached (); + } + + t = icaltime_as_timet_with_zone (tt, zone); + + /* Convert the time to an ISO date string, and build + the query sub-expression. */ + isodate = isodate_from_time_t (t); + sexp = g_strdup_printf ("(not (completed-before? (make-time \"%s\")))", isodate); + } + } + + return sexp; +} |