aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-10-29 06:13:13 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-10-29 06:13:13 +0800
commitd16418158d22a039e2a9a9665a5b337aed5f510a (patch)
treea266037935761cecd56a01901524dd0bfc91a560 /calendar/gui
parentdf39199fb04368c2bd25e7922edb7a83be382690 (diff)
downloadgsoc2013-evolution-d16418158d22a039e2a9a9665a5b337aed5f510a.tar
gsoc2013-evolution-d16418158d22a039e2a9a9665a5b337aed5f510a.tar.gz
gsoc2013-evolution-d16418158d22a039e2a9a9665a5b337aed5f510a.tar.bz2
gsoc2013-evolution-d16418158d22a039e2a9a9665a5b337aed5f510a.tar.lz
gsoc2013-evolution-d16418158d22a039e2a9a9665a5b337aed5f510a.tar.xz
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')
-rw-r--r--calendar/gui/calendar-config.c62
-rw-r--r--calendar/gui/calendar-config.h2
-rw-r--r--calendar/gui/calendar-model.c56
-rw-r--r--calendar/gui/dialogs/task-page.c2
-rw-r--r--calendar/gui/gnome-cal.c9
-rw-r--r--calendar/gui/gnome-cal.h3
-rw-r--r--calendar/gui/print.c46
7 files changed, 96 insertions, 84 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;
+}
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index a28181a37d..b5992e4c81 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -147,6 +147,8 @@ void calendar_config_set_hide_completed_tasks_units(CalUnits units);
gint calendar_config_get_hide_completed_tasks_value(void);
void calendar_config_set_hide_completed_tasks_value(gint value);
+char* calendar_config_get_hide_completed_tasks_sexp (void);
+
/* Confirmation options */
gboolean calendar_config_get_confirm_delete (void);
void calendar_config_set_confirm_delete (gboolean confirm);
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index 7e8cc5665b..f039a3d7e1 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -1897,8 +1897,7 @@ adjust_query_sexp (CalendarModel *model, const char *sexp)
CalendarModelPrivate *priv;
CalObjType type;
char *type_sexp;
- char *completed_sexp = "";
- gboolean free_completed_sexp = FALSE;
+ char *completed_sexp;
char *new_sexp;
priv = model->priv;
@@ -1916,58 +1915,13 @@ adjust_query_sexp (CalendarModel *model, const char *sexp)
/* Create a sub-expression for filtering out completed tasks, based on
the config settings. */
- 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.*/
- completed_sexp = "(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);
- completed_sexp = g_strdup_printf ("(not (completed-before? (make-time \"%s\")))", isodate);
- free_completed_sexp = TRUE;
- }
- }
+ completed_sexp = calendar_config_get_hide_completed_tasks_sexp ();
new_sexp = g_strdup_printf ("(and %s %s %s)", type_sexp,
- completed_sexp, sexp);
+ completed_sexp ? completed_sexp : "",
+ sexp);
g_free (type_sexp);
- if (free_completed_sexp)
- g_free (completed_sexp);
+ g_free (completed_sexp);
#if 0
g_print ("Calendar model sexp:\n%s\n", new_sexp);
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index a95341e472..00b80241ff 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -831,8 +831,6 @@ init_widgets (TaskPage *tpage)
GTK_SIGNAL_FUNC (field_changed_cb), tpage);
/* Classification */
- gtk_signal_connect (GTK_OBJECT (priv->description), "changed",
- GTK_SIGNAL_FUNC (field_changed_cb), tpage);
gtk_signal_connect (GTK_OBJECT (priv->classification_public),
"toggled",
GTK_SIGNAL_FUNC (field_changed_cb), tpage);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 12ec9609c7..4ce38ab750 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -42,7 +42,6 @@
#include "widgets/menus/gal-view-menus.h"
#include "dialogs/event-editor.h"
#include "dialogs/task-editor.h"
-#include "e-calendar-table.h"
#include "e-day-view.h"
#include "e-week-view.h"
#include "evolution-calendar.h"
@@ -2600,3 +2599,11 @@ gnome_calendar_delete_event (GnomeCalendar *gcal)
}
+ECalendarTable*
+gnome_calendar_get_task_pad (GnomeCalendar *gcal)
+{
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
+
+ return E_CALENDAR_TABLE (gcal->priv->todo);
+}
+
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 948557455a..620dbc3553 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -31,6 +31,7 @@
#include <bonobo/bonobo-ui-component.h>
#include <widgets/misc/e-calendar.h>
#include <cal-client/cal-client.h>
+#include "e-calendar-table.h"
BEGIN_GNOME_DECLS
@@ -76,6 +77,8 @@ GtkWidget *gnome_calendar_construct (GnomeCalendar *gcal);
GtkWidget *gnome_calendar_new (void);
+ECalendarTable *gnome_calendar_get_task_pad (GnomeCalendar *gcal);
+
CalClient *gnome_calendar_get_cal_client (GnomeCalendar *gcal);
CalClient *gnome_calendar_get_task_pad_cal_client(GnomeCalendar *gcal);
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index ba96781ccf..253c23c0c0 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -1702,18 +1702,26 @@ print_month_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence,
left, right, top, bottom);
}
+
static void
print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal,
time_t start, time_t end,
double left, double right, double top, double bottom)
{
CalClient *client;
- GList *uids;
- GList *l;
GnomeFont *font_summary;
double y, yend, x, xend;
struct icaltimetype *tt;
-
+ ECalendarTable *task_pad;
+ ETable *table;
+ CalendarModel *model;
+ gint rows, row;
+
+ /* We get the tasks directly from the TaskPad ETable. This means we
+ get them filtered & sorted for free. */
+ task_pad = gnome_calendar_get_task_pad (gcal);
+ table = e_calendar_table_get_table (task_pad);
+ model = e_calendar_table_get_model (task_pad);
client = gnome_calendar_get_task_pad_cal_client (gcal);
font_summary = gnome_font_new_closest ("Times", GNOME_FONT_BOOK,
@@ -1728,34 +1736,14 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal,
y = top - 3;
yend = bottom - 2;
- uids = cal_client_get_uids (client, CALOBJ_TYPE_TODO);
-
- for (l = uids; l; l = l->next) {
- char *uid;
+ rows = e_table_model_row_count (E_TABLE_MODEL (model));
+ for (row = 0; row < rows; row++) {
CalComponent *comp;
- CalClientGetStatus status;
CalComponentText summary;
+ int model_row;
- uid = l->data;
-
- status = cal_client_get_object (client, uid, &comp);
-
- switch (status) {
- case CAL_CLIENT_GET_SUCCESS:
- break;
-
- case CAL_CLIENT_GET_NOT_FOUND:
- /* Nothing: the object may have been removed from the server */
- continue;
-
- case CAL_CLIENT_GET_SYNTAX_ERROR:
- g_message ("print_todo_details(): Syntax error while getting object `%s'",
- uid);
- continue;
-
- default:
- g_assert_not_reached ();
- }
+ model_row = e_table_view_to_model_row (table, row);
+ comp = calendar_model_get_component (model, model_row);
cal_component_get_summary (comp, &summary);
@@ -1793,8 +1781,6 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal,
y -= 3;
}
- cal_obj_uid_list_free (uids);
-
gtk_object_unref (GTK_OBJECT (font_summary));
}