diff options
author | Damon Chaplin <damon@ximian.com> | 2001-08-22 03:06:17 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2001-08-22 03:06:17 +0800 |
commit | c8905eabfcb6120fbf7f4ba67043d1780396dc01 (patch) | |
tree | 2642e85770860b956abd09c6728e1e11cc9517cb /calendar | |
parent | a70082de9ea4f4558d6494efc5e130250ed99448 (diff) | |
download | gsoc2013-evolution-c8905eabfcb6120fbf7f4ba67043d1780396dc01.tar gsoc2013-evolution-c8905eabfcb6120fbf7f4ba67043d1780396dc01.tar.gz gsoc2013-evolution-c8905eabfcb6120fbf7f4ba67043d1780396dc01.tar.bz2 gsoc2013-evolution-c8905eabfcb6120fbf7f4ba67043d1780396dc01.tar.lz gsoc2013-evolution-c8905eabfcb6120fbf7f4ba67043d1780396dc01.tar.xz gsoc2013-evolution-c8905eabfcb6120fbf7f4ba67043d1780396dc01.tar.zst gsoc2013-evolution-c8905eabfcb6120fbf7f4ba67043d1780396dc01.zip |
added new e-sexp operator. We don't currently use it though.
2001-08-21 Damon Chaplin <damon@ximian.com>
* pcs/query.c (func_is_completed): added new e-sexp operator. We
don't currently use it though.
* gui/dialogs/cal-prefs-dialog.glade: Changed '_Overdue' to 'O_verdue'
since we have an '_Other' notebook tab. Added '_Hide' accel.
* gui/dialogs/cal-prefs-dialog.c: hooked up config options to dialog.
* gui/calendar-config.c: added config options for hiding completed
tasks.
* gui/e-week-view-event-item.c (e_week_view_event_item_draw):
* gui/e-day-view-top-item.c (e_day_view_top_item_draw_long_event):
* gui/e-day-view.c (e_day_view_reshape_long_event): added 2 pixels
extra space between icons and text for long events, and 1 pixel space
between icons in all events.
(e_day_view_realize): changed the background color to match the
EGrayBar in the shell.
svn path=/trunk/; revision=12347
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 21 | ||||
-rw-r--r-- | calendar/gui/calendar-config.c | 82 | ||||
-rw-r--r-- | calendar/gui/calendar-config.h | 32 | ||||
-rw-r--r-- | calendar/gui/calendar-model.c | 12 | ||||
-rw-r--r-- | calendar/gui/dialogs/cal-prefs-dialog.c | 69 | ||||
-rw-r--r-- | calendar/gui/dialogs/cal-prefs-dialog.glade | 4 | ||||
-rw-r--r-- | calendar/gui/e-day-view-top-item.c | 3 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 14 | ||||
-rw-r--r-- | calendar/gui/e-day-view.h | 7 | ||||
-rw-r--r-- | calendar/gui/e-week-view-event-item.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 6 | ||||
-rw-r--r-- | calendar/pcs/query.c | 43 |
12 files changed, 268 insertions, 27 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 7c4ab63228..5860b209c5 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,24 @@ +2001-08-21 Damon Chaplin <damon@ximian.com> + + * pcs/query.c (func_is_completed): added new e-sexp operator. We + don't currently use it though. + + * gui/dialogs/cal-prefs-dialog.glade: Changed '_Overdue' to 'O_verdue' + since we have an '_Other' notebook tab. Added '_Hide' accel. + + * gui/dialogs/cal-prefs-dialog.c: hooked up config options to dialog. + + * gui/calendar-config.c: added config options for hiding completed + tasks. + + * gui/e-week-view-event-item.c (e_week_view_event_item_draw): + * gui/e-day-view-top-item.c (e_day_view_top_item_draw_long_event): + * gui/e-day-view.c (e_day_view_reshape_long_event): added 2 pixels + extra space between icons and text for long events, and 1 pixel space + between icons in all events. + (e_day_view_realize): changed the background color to match the + EGrayBar in the shell. + 2001-08-21 Rodrigo Moya <rodrigo@ximian.com> * pcs/cal-backend-util.[ch]: new files to contain utility functions diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index fd95a573b0..33be9f2f02 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -62,6 +62,9 @@ typedef struct gboolean show_event_end; char *tasks_due_today_color; char *tasks_overdue_color; + gboolean hide_completed_tasks; + CalUnits hide_completed_tasks_units; + gint hide_completed_tasks_value; } CalendarConfig; @@ -102,6 +105,7 @@ config_read (void) { Bonobo_ConfigDatabase db; CORBA_Environment ev; + char *units; CORBA_exception_init (&ev); @@ -179,6 +183,23 @@ config_read (void) config->tasks_overdue_color = bonobo_config_get_string_with_default ( db, "/Calendar/Tasks/Colors/TasksOverdue", "red", NULL); + config->hide_completed_tasks = bonobo_config_get_boolean_with_default ( + db, "/Calendar/Tasks/HideCompletedTasks", FALSE, NULL); + + units = bonobo_config_get_string_with_default (db, + "/Calendar/Tasks/HideCompletedTasksUnits", "days", NULL); + + if (!strcmp (units, "minutes")) + config->hide_completed_tasks_units = CAL_MINUTES; + else if (!strcmp (units, "hours")) + config->hide_completed_tasks_units = CAL_HOURS; + else + config->hide_completed_tasks_units = CAL_DAYS; + + config->hide_completed_tasks_value = bonobo_config_get_long_with_default ( + db, "/Calendar/Tasks/HideCompletedTasksValue", 1, NULL); + + bonobo_object_release_unref (db, NULL); } @@ -188,7 +209,7 @@ calendar_config_write (void) { Bonobo_ConfigDatabase db; CORBA_Environment ev; - + char *units; CORBA_exception_init (&ev); @@ -232,6 +253,22 @@ calendar_config_write (void) bonobo_config_set_string (db, "/Calendar/Tasks/Colors/TasksOverdue", config->tasks_overdue_color, NULL); + bonobo_config_set_boolean (db, "/Calendar/Tasks/HideCompletedTasks", + config->hide_completed_tasks, NULL); + + if (config->hide_completed_tasks_units == CAL_MINUTES) + units = "minutes"; + else if (config->hide_completed_tasks_units == CAL_HOURS) + units = "hours"; + else + units = "days"; + bonobo_config_set_string (db, + "/Calendar/Tasks/HideCompletedTasksUnits", + units, NULL); + bonobo_config_set_long (db, + "/Calendar/Tasks/HideCompletedTasksValue", + config->hide_completed_tasks_value, NULL); + Bonobo_ConfigDatabase_sync (db, &ev); bonobo_object_release_unref (db, NULL); @@ -538,6 +575,49 @@ calendar_config_set_working_days (CalWeekdays days) } +/* Settings to hide completed tasks. */ +gboolean +calendar_config_get_hide_completed_tasks (void) +{ + return config->hide_completed_tasks; +} + + +void +calendar_config_set_hide_completed_tasks (gboolean hide) +{ + config->hide_completed_tasks = hide; +} + + +CalUnits +calendar_config_get_hide_completed_tasks_units (void) +{ + return config->hide_completed_tasks_units; +} + + +void +calendar_config_set_hide_completed_tasks_units (CalUnits units) +{ + config->hide_completed_tasks_units = units; +} + + +gint +calendar_config_get_hide_completed_tasks_value (void) +{ + return config->hide_completed_tasks_value; +} + + +void +calendar_config_set_hide_completed_tasks_value (gint value) +{ + config->hide_completed_tasks_value = value; +} + + /* This sets all the common config settings for an ECalendar widget. These are the week start day, and whether we show week numbers. */ void diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index 2979d07d91..83132267f9 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -51,6 +51,14 @@ typedef enum } CalWeekdays; +/* Units for settings. */ +typedef enum +{ + CAL_DAYS, + CAL_HOURS, + CAL_MINUTES +} CalUnits; + void calendar_config_init (void); void calendar_config_write (void); @@ -123,6 +131,23 @@ void calendar_config_set_month_hpane_pos (gfloat hpane_pos); gfloat calendar_config_get_month_vpane_pos (void); void calendar_config_set_month_vpane_pos (gfloat vpane_pos); +/* Colors for the task list */ +const char *calendar_config_get_tasks_due_today_color (void); +void calendar_config_set_tasks_due_today_color (const char *color); + +const char *calendar_config_get_tasks_overdue_color (void); +void calendar_config_set_tasks_overdue_color (const char *color); + +/* Settings to hide completed tasks. */ +gboolean calendar_config_get_hide_completed_tasks (void); +void calendar_config_set_hide_completed_tasks (gboolean hide); + +CalUnits calendar_config_get_hide_completed_tasks_units(void); +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); + /* Convenience functions to configure common properties of ECalendar, EDateEdit & ECalendarTable widgets, and the ECellDateEdit ETable cell. */ @@ -134,12 +159,5 @@ void calendar_config_configure_e_cell_date_edit (ECellDateEdit *ecde); /* Shows the timezone dialog if the user hasn't set a default timezone. */ void calendar_config_check_timezone_set (void); -/* Colors for the task list */ - -const char *calendar_config_get_tasks_due_today_color (void); -void calendar_config_set_tasks_due_today_color (const char *color); - -const char *calendar_config_get_tasks_overdue_color (void); -void calendar_config_set_tasks_overdue_color (const char *color); #endif /* _CALENDAR_CONFIG_H_ */ diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c index b7aca002ce..141d8e96c4 100644 --- a/calendar/gui/calendar-model.c +++ b/calendar/gui/calendar-model.c @@ -1807,6 +1807,7 @@ adjust_query_sexp (CalendarModel *model, const char *sexp) CalendarModelPrivate *priv; CalObjType type; char *type_sexp; + char *completed_sexp = ""; char *new_sexp; priv = model->priv; @@ -1822,9 +1823,18 @@ adjust_query_sexp (CalendarModel *model, const char *sexp) (type & CALOBJ_TYPE_TODO) ? "(= (get-vtype) \"VTODO\")" : "", (type & CALOBJ_TYPE_JOURNAL) ? "(= (get-vtype) \"VJOURNAL\")" : ""); - new_sexp = g_strdup_printf ("(and %s %s)", type_sexp, sexp); + /* FIXME: Use config setting eventually. */ +#if 0 + if (1) + completed_sexp = "(not is-completed?)"; +#endif + + new_sexp = g_strdup_printf ("(and %s %s %s)", type_sexp, + completed_sexp, sexp); g_free (type_sexp); + g_print ("Calendar mode sexp:\n%s\n", new_sexp); + return new_sexp; } diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 931ac12b73..0b1d14d55e 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -64,6 +64,10 @@ struct _CalPrefsDialogPrivate { /* Widgets for the task list options */ GtkWidget *tasks_due_today_color; GtkWidget *tasks_overdue_color; + + GtkWidget *tasks_hide_completed_checkbutton; + GtkWidget *tasks_hide_completed_spinbutton; + GtkWidget *tasks_hide_completed_optionmenu; }; static const int week_start_day_map[] = { @@ -74,6 +78,11 @@ static const int time_division_map[] = { 60, 30, 15, 10, 5, -1 }; +static const int hide_completed_units_map[] = { + CAL_MINUTES, CAL_HOURS, CAL_DAYS, -1 +}; + + static void cal_prefs_dialog_class_init (CalPrefsDialogClass *class); static void cal_prefs_dialog_init (CalPrefsDialog *prefs); static gboolean get_widgets (CalPrefsDialog *prefs); @@ -84,6 +93,8 @@ static void cal_prefs_dialog_button_clicked (GtkWidget *dialog, CalPrefsDialog *prefs); static void cal_prefs_dialog_use_24_hour_toggled(GtkWidget *button, CalPrefsDialog *prefs); +static void cal_prefs_dialog_hide_completed_tasks_toggled (GtkWidget *button, + CalPrefsDialog *prefs); static void cal_prefs_dialog_show_config (CalPrefsDialog *prefs); static void cal_prefs_dialog_update_config (CalPrefsDialog *prefs); @@ -224,6 +235,10 @@ get_widgets (CalPrefsDialog *prefs) priv->tasks_due_today_color = GW ("tasks_due_today_color"); priv->tasks_overdue_color = GW ("tasks_overdue_color"); + priv->tasks_hide_completed_checkbutton = GW ("tasks-hide-completed-checkbutton"); + priv->tasks_hide_completed_spinbutton = GW ("tasks-hide-completed-spinbutton"); + priv->tasks_hide_completed_optionmenu = GW ("tasks-hide-completed-optionmenu"); + #undef GW return (priv->dialog @@ -244,7 +259,12 @@ get_widgets (CalPrefsDialog *prefs) && priv->time_divisions && priv->show_end_times && priv->compress_weekend - && priv->dnav_show_week_no); + && priv->dnav_show_week_no + && priv->tasks_due_today_color + && priv->tasks_overdue_color + && priv->tasks_hide_completed_checkbutton + && priv->tasks_hide_completed_spinbutton + && priv->tasks_hide_completed_optionmenu); } @@ -335,6 +355,11 @@ cal_prefs_dialog_init_widgets (CalPrefsDialog *prefs) gtk_signal_connect (GTK_OBJECT (priv->use_24_hour), "toggled", GTK_SIGNAL_FUNC (cal_prefs_dialog_use_24_hour_toggled), prefs); + + gtk_signal_connect (GTK_OBJECT (priv->tasks_hide_completed_checkbutton), + "toggled", + GTK_SIGNAL_FUNC (cal_prefs_dialog_hide_completed_tasks_toggled), + prefs); } @@ -379,6 +404,23 @@ cal_prefs_dialog_use_24_hour_toggled (GtkWidget *button, use_24_hour); } +static void +cal_prefs_dialog_hide_completed_tasks_toggled (GtkWidget *button, + CalPrefsDialog *prefs) +{ + CalPrefsDialogPrivate *priv; + gboolean hide_completed_tasks; + + priv = prefs->priv; + + hide_completed_tasks = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->tasks_hide_completed_checkbutton)); + + gtk_widget_set_sensitive (priv->tasks_hide_completed_spinbutton, + hide_completed_tasks); + gtk_widget_set_sensitive (priv->tasks_hide_completed_optionmenu, + hide_completed_tasks); +} + /* Sets the color in a color picker from an X color spec */ static void set_color_picker (GtkWidget *picker, const char *spec) @@ -404,11 +446,32 @@ static void show_task_list_config (CalPrefsDialog *prefs) { CalPrefsDialogPrivate *priv; + CalUnits units; + gboolean hide_completed_tasks; priv = prefs->priv; set_color_picker (priv->tasks_due_today_color, calendar_config_get_tasks_due_today_color ()); set_color_picker (priv->tasks_overdue_color, calendar_config_get_tasks_overdue_color ()); + + /* Hide Completed Tasks. */ + hide_completed_tasks = calendar_config_get_hide_completed_tasks (); + e_dialog_toggle_set (priv->tasks_hide_completed_checkbutton, + hide_completed_tasks); + + /* Hide Completed Tasks Units. */ + units = calendar_config_get_hide_completed_tasks_units (); + e_dialog_option_menu_set (priv->tasks_hide_completed_optionmenu, + units, hide_completed_units_map); + + /* Hide Completed Tasks Value. */ + e_dialog_spin_set (priv->tasks_hide_completed_spinbutton, + calendar_config_get_hide_completed_tasks_value ()); + + gtk_widget_set_sensitive (priv->tasks_hide_completed_spinbutton, + hide_completed_tasks); + gtk_widget_set_sensitive (priv->tasks_hide_completed_optionmenu, + hide_completed_tasks); } /* Shows the current config settings in the dialog. */ @@ -503,6 +566,10 @@ update_task_list_config (CalPrefsDialog *prefs) calendar_config_set_tasks_due_today_color (spec_from_picker (priv->tasks_due_today_color)); calendar_config_set_tasks_overdue_color (spec_from_picker (priv->tasks_overdue_color)); + + calendar_config_set_hide_completed_tasks (e_dialog_toggle_get (priv->tasks_hide_completed_checkbutton)); + calendar_config_set_hide_completed_tasks_units (e_dialog_option_menu_get (priv->tasks_hide_completed_optionmenu, hide_completed_units_map)); + calendar_config_set_hide_completed_tasks_value (e_dialog_spin_get_int (priv->tasks_hide_completed_spinbutton)); } /* Updates the config values based on the settings in the dialog. */ diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade index 42ad66c1d7..ed301e805c 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.glade +++ b/calendar/gui/dialogs/cal-prefs-dialog.glade @@ -692,7 +692,7 @@ Sunday <widget> <class>GtkLabel</class> <name>label24</name> - <label>_Overdue tasks:</label> + <label>O_verdue tasks:</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0</xalign> @@ -778,7 +778,7 @@ Sunday <class>GtkCheckButton</class> <name>tasks-hide-completed-checkbutton</name> <can_focus>True</can_focus> - <label>Hide completed tasks after</label> + <label>_Hide completed tasks after</label> <active>False</active> <draw_indicator>True</draw_indicator> <child> diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c index 405ef31af0..121dacba03 100644 --- a/calendar/gui/e-day-view-top-item.c +++ b/calendar/gui/e-day-view-top-item.c @@ -554,7 +554,8 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, /* Draw the icons. */ icon_x_inc = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD; - icon_x = text_x - icon_x_inc - x; + icon_x = text_x - E_DAY_VIEW_LONG_EVENT_ICON_R_PAD + - icon_x_inc - x; icon_y = item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_ICON_Y_PAD - y; diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index ca5be3bd6f..4b11b89437 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -971,13 +971,13 @@ e_day_view_realize (GtkWidget *widget) day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED].green = 0 * 257; day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED].blue = 156 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].red = 32512; - day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].green = 32512; - day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].blue = 32512; + day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].red = 0x8000; + day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].green = 0x8000; + day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].blue = 0x8000; - day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].red = 32512; - day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].green = 32512; - day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].blue = 32512; + day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].red = 0x8000; + day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].green = 0x8000; + day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].blue = 0x8000; day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED].red = 65535; day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED].green = 65535; @@ -4650,7 +4650,7 @@ e_day_view_reshape_long_event (EDayView *day_view, the left edge of the available space. Finally we make sure we don't go off the right edge. */ icons_width = (E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD) - * num_icons; + * num_icons + E_DAY_VIEW_LONG_EVENT_ICON_R_PAD; time_width = e_day_view_get_time_string_width (day_view); if (use_max_width) { diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index d260f33980..1e57de4862 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -66,8 +66,11 @@ extern "C" { /* The size of the reminder & recurrence icons, and padding around them. */ #define E_DAY_VIEW_ICON_WIDTH 16 #define E_DAY_VIEW_ICON_HEIGHT 16 -#define E_DAY_VIEW_ICON_X_PAD 0 -#define E_DAY_VIEW_ICON_Y_PAD 0 +#define E_DAY_VIEW_ICON_X_PAD 1 +#define E_DAY_VIEW_ICON_Y_PAD 1 + +/* The space between the icons and the long event text. */ +#define E_DAY_VIEW_LONG_EVENT_ICON_R_PAD 1 /* The size of the border around the event. */ #define E_DAY_VIEW_EVENT_BORDER_WIDTH 1 diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index bf321b2bf3..09bacec50a 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -466,7 +466,7 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item, if (span->text_item && (week_view->editing_event_num != wveitem->event_num || week_view->editing_span_num != wveitem->span_num)) { - icon_x = span->text_item->x1 - x; + icon_x = span->text_item->x1 - E_WEEK_VIEW_ICON_R_PAD - x; e_week_view_event_item_draw_icons (wveitem, drawable, icon_x, icon_y, max_icon_x, TRUE); diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 84e113b1b5..07ff4770c3 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -47,9 +47,9 @@ extern "C" { the last icon, before the event text. */ #define E_WEEK_VIEW_ICON_WIDTH 16 #define E_WEEK_VIEW_ICON_HEIGHT 16 -#define E_WEEK_VIEW_ICON_X_PAD 0 -#define E_WEEK_VIEW_ICON_Y_PAD 0 -#define E_WEEK_VIEW_ICON_R_PAD 2 +#define E_WEEK_VIEW_ICON_X_PAD 1 +#define E_WEEK_VIEW_ICON_Y_PAD 1 +#define E_WEEK_VIEW_ICON_R_PAD 1 /* The space on the left & right outside of the event. (The triangle to indicate the event continues is displayed in this space). */ diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c index 7e9a712825..ae76ec9795 100644 --- a/calendar/pcs/query.c +++ b/calendar/pcs/query.c @@ -778,6 +778,46 @@ func_has_categories (ESExp *esexp, int argc, ESExpResult **argv, void *data) return result; } +/* (is-completed?) + * + * Returns a boolean indicating whether the component is completed (i.e. has + * a COMPLETED property. This is really only useful for TODO components. + */ +static ESExpResult * +func_is_completed (ESExp *esexp, int argc, ESExpResult **argv, void *data) +{ + Query *query; + QueryPrivate *priv; + CalComponent *comp; + ESExpResult *result; + struct icaltimetype *t; + gboolean complete = FALSE; + + query = QUERY (data); + priv = query->priv; + + g_assert (priv->next_comp != NULL); + comp = priv->next_comp; + + /* Check argument types */ + + if (argc != 0) { + e_sexp_fatal_error (esexp, _("is-completed? expects 0 arguments")); + return NULL; + } + + cal_component_get_completed (comp, &t); + if (t) { + complete = TRUE; + cal_component_free_icaltimetype (t); + } + + result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); + result->value.bool = complete; + + return result; +} + /* Adds a component to our the UIDs hash table and notifies the client */ @@ -895,7 +935,8 @@ static struct { { "get-vtype", func_get_vtype }, { "occur-in-time-range?", func_occur_in_time_range }, { "contains?", func_contains }, - { "has-categories?", func_has_categories } + { "has-categories?", func_has_categories }, + { "is-completed?", func_is_completed } }; /* Initializes a sexp by interning our own symbols */ |