static void cal_model_calendar_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) { ECalModelComponent *comp_data; ECalObjModType mod = E_CAL_OBJ_MOD_ALL; ECalComponent *comp; ECalModelCalendar *model = (ECalModelCalendar *) etm; g_return_if_fail (E_IS_CAL_MODEL_CALENDAR (model)); g_return_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST); g_return_if_fail (row >= 0 && row < e_table_model_row_count (etm)); if (col < E_CAL_MODEL_FIELD_LAST) { table_model_parent_interface->set_value_at (etm, col, row, value); return; } comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); if (!comp_data) return; comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (comp_data->icalcomp)); if (!comp) { return; } /* ask about mod type */ if (e_cal_component_is_instance (comp)) { if (!e_cal_dialogs_recur_component (comp_data->client, comp, &mod, NULL, FALSE)) { g_object_unref (comp); return; } } switch (col) { case E_CAL_MODEL_CALENDAR_FIELD_DTEND : set_dtend ((ECalModel *) model, comp_data, value); break; case E_CAL_MODEL_CALENDAR_FIELD_LOCATION : set_location (comp_data, value); break; case E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY : set_transparency (comp_data, value); break; } e_cal_model_modify_component (E_CAL_MODEL (model), comp_data, mod); g_object_unref (comp); }
static void memo_shell_content_model_row_changed_cb (EMemoShellContent *memo_shell_content, gint row, ETableModel *model) { ECalModelComponent *comp_data; EMemoTable *memo_table; const gchar *current_uid; const gchar *uid; current_uid = memo_shell_content->priv->current_uid; if (current_uid == NULL) return; comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); if (comp_data == NULL) return; uid = icalcomponent_get_uid (comp_data->icalcomp); if (g_strcmp0 (uid, current_uid) != 0) return; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); memo_shell_content_cursor_change_cb ( memo_shell_content, 0, E_TABLE (memo_table)); }
static gboolean cal_model_calendar_is_cell_editable (ETableModel *etm, gint col, gint row) { ECalModelCalendar *model = (ECalModelCalendar *) etm; g_return_val_if_fail (E_IS_CAL_MODEL_CALENDAR (model), FALSE); g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, FALSE); g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE); if (col < E_CAL_MODEL_FIELD_LAST) return table_model_parent_interface->is_cell_editable (etm, col, row); if (!e_cal_model_test_row_editable (E_CAL_MODEL (etm), row)) return FALSE; switch (col) { case E_CAL_MODEL_CALENDAR_FIELD_DTEND : case E_CAL_MODEL_CALENDAR_FIELD_LOCATION : case E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY : return TRUE; } return FALSE; }
static gpointer cal_model_calendar_value_at (ETableModel *etm, gint col, gint row) { ECalModelComponent *comp_data; ECalModelCalendar *model = (ECalModelCalendar *) etm; g_return_val_if_fail (E_IS_CAL_MODEL_CALENDAR (model), NULL); g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL); g_return_val_if_fail (row >= 0 && row < e_table_model_row_count (etm), NULL); if (col < E_CAL_MODEL_FIELD_LAST) return table_model_parent_interface->value_at (etm, col, row); comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); if (!comp_data) return (gpointer) ""; switch (col) { case E_CAL_MODEL_CALENDAR_FIELD_DTEND : return get_dtend (model, comp_data); case E_CAL_MODEL_CALENDAR_FIELD_LOCATION : return get_location (comp_data); case E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY : return get_transparency (comp_data); } return (gpointer) ""; }
static gchar * cal_model_calendar_value_to_string (ETableModel *etm, gint col, gconstpointer value) { g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, g_strdup ("")); if (col < E_CAL_MODEL_FIELD_LAST) return table_model_parent_interface->value_to_string (etm, col, value); switch (col) { case E_CAL_MODEL_CALENDAR_FIELD_DTEND : return e_cal_model_date_value_to_string (E_CAL_MODEL (etm), value); case E_CAL_MODEL_CALENDAR_FIELD_LOCATION : case E_CAL_MODEL_CALENDAR_FIELD_TRANSPARENCY : return g_strdup (value); } return g_strdup (""); }
static ECellDateEditValue * get_dtend (ECalModelCalendar *model, ECalModelComponent *comp_data) { struct icaltimetype tt_end; if (!comp_data->dtend) { icalproperty *prop; icaltimezone *zone = NULL, *model_zone = NULL; gboolean got_zone = FALSE; prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTEND_PROPERTY); if (!prop) return NULL; tt_end = icalproperty_get_dtend (prop); if (icaltime_get_tzid (tt_end) && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_end), &zone, NULL, NULL)) got_zone = TRUE; model_zone = e_cal_model_get_timezone (E_CAL_MODEL (model)); if (got_zone) { tt_end = icaltime_from_timet_with_zone (comp_data->instance_end, tt_end.is_date, zone); if (model_zone) icaltimezone_convert_time (&tt_end, zone, model_zone); } else { tt_end = icaltime_from_timet_with_zone ( comp_data->instance_end, tt_end.is_date, model_zone); } if (!icaltime_is_valid_time (tt_end) || icaltime_is_null_time (tt_end)) return NULL; if (tt_end.is_date && icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY)) { struct icaltimetype tt_start; icaltimezone *start_zone = NULL; gboolean got_start_zone = FALSE; tt_start = icalproperty_get_dtstart (prop); if (icaltime_get_tzid (tt_start) && e_cal_client_get_timezone_sync (comp_data->client, icaltime_get_tzid (tt_start), &start_zone, NULL, NULL)) got_start_zone = TRUE; if (got_start_zone) { tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, tt_start.is_date, start_zone); if (model_zone) icaltimezone_convert_time (&tt_start, start_zone, model_zone); } else { tt_start = icaltime_from_timet_with_zone ( comp_data->instance_start, tt_start.is_date, model_zone); } icaltime_adjust (&tt_start, 1, 0, 0, 0); /* Decrease by a day only if the DTSTART will still be before, or the same as, DTEND */ if (icaltime_compare (tt_start, tt_end) <= 0) icaltime_adjust (&tt_end, -1, 0, 0, 0); } comp_data->dtend = g_new0 (ECellDateEditValue, 1); comp_data->dtend->tt = tt_end; if (got_zone) comp_data->dtend->zone = zone; else comp_data->dtend->zone = NULL; } return e_cal_model_copy_cell_date_value (comp_data->dtend); }