75
75
#define E_WEEK_VIEW_JUMP_BUTTON_NO_FOCUS -1
77
77
/* The timeout before we do a layout, so we don't do a layout for each event
78
we get from the server. */
78
* we get from the server. */
79
79
#define E_WEEK_VIEW_LAYOUT_TIMEOUT 100
384
385
week_start_offset = (weekday + 7 - week_view->display_start_day) % 7;
386
387
/* Set the day_offset to the result, so we move back to the
387
start of the week. */
388
* start of the week. */
388
389
day_offset = week_start_offset;
390
391
/* Calculate the base date, i.e. the first day shown when the
391
scrollbar adjustment value is 0. */
392
* scrollbar adjustment value is 0. */
392
393
base_date = date;
393
394
g_date_subtract_days (&base_date, day_offset);
413
414
/* Reset the adjustment value to 0 if the base address has changed.
414
Note that we do this after updating first_day_shown so that our
415
signal handler will not try to reload the events. */
415
* Note that we do this after updating first_day_shown so that our
416
* signal handler will not try to reload the events. */
416
417
if (update_adjustment_value) {
418
419
GtkAdjustment *adjustment;
462
463
/* Recalculate the new start of the first week. We just use exactly
463
the same time, but with the new timezone. */
464
* the same time, but with the new timezone. */
464
465
tt.year = g_date_get_year (&week_view->first_day_shown);
465
466
tt.month = g_date_get_month (&week_view->first_day_shown);
466
467
tt.day = g_date_get_day (&week_view->first_day_shown);
855
856
view = g_object_new (E_TYPE_WEEK_VIEW, "model", model, NULL);
857
g_signal_connect (G_OBJECT (model), "timezone_changed",
858
G_CALLBACK (timezone_changed_cb), view);
859
model, "timezone_changed",
860
G_CALLBACK (timezone_changed_cb), view);
1099
1107
week_view->row_height = MAX (week_view->row_height, E_WEEK_VIEW_ICON_HEIGHT + E_WEEK_VIEW_ICON_Y_PAD + E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2);
1101
1109
/* Check that the small font is smaller than the default font.
1102
If it isn't, we won't use it. */
1110
* If it isn't, we won't use it. */
1103
1111
if (week_view->small_font_desc) {
1104
1112
if (PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
1105
1113
PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics))
1114
1122
PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) + 5);
1116
1124
/* Save the sizes of various strings in the font, so we can quickly
1117
decide which date formats to use. */
1125
* decide which date formats to use. */
1119
1127
max_day_width = 0;
1120
1128
max_abbr_day_width = 0;
1170
1178
/* This recalculates the sizes of each column. */
1172
e_week_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
1180
e_week_view_size_allocate (GtkWidget *widget,
1181
GtkAllocation *allocation)
1174
1183
EWeekView *week_view;
1175
1184
GtkAllocation canvas_allocation;
1195
1204
0, 0, new_x2, new_y2);
1197
1206
/* Set the scroll region of the main canvas to its allocated width,
1198
but with the height depending on the number of rows needed. */
1207
* but with the height depending on the number of rows needed. */
1199
1208
gnome_canvas_get_scroll_region (
1200
1209
GNOME_CANVAS (week_view->main_canvas),
1201
1210
NULL, NULL, &old_x2, &old_y2);
1239
1248
gtk_widget_get_allocation (week_view->main_canvas, &allocation);
1241
1250
/* Calculate the column sizes, using floating point so that pixels
1242
get divided evenly. Note that we use one more element than the
1243
number of columns, to make it easy to get the column widths.
1244
We also add one to the width so that the right border of the last
1245
column is off the edge of the displayed area. */
1251
* get divided evenly. Note that we use one more element than the
1252
* number of columns, to make it easy to get the column widths.
1253
* We also add one to the width so that the right border of the last
1254
* column is off the edge of the displayed area. */
1246
1255
canvas_width = allocation.width + 1;
1247
1256
canvas_width /= week_view->columns;
1286
1295
pango_context_get_language (pango_context));
1288
1297
/* Calculate the number of rows of events in each cell, for the large
1289
cells and the compressed weekend cells. */
1298
* cells and the compressed weekend cells. */
1290
1299
if (week_view->multi_week_view) {
1291
1300
week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD +
1292
1301
+ PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics))
1313
1322
E_WEEK_VIEW_MAX_ROWS_PER_CELL);
1315
1324
/* Determine which time format to use, based on the width of the cells.
1316
We only allow the time to take up about half of the width. */
1325
* We only allow the time to take up about half of the width. */
1317
1326
width = week_view->col_widths[0];
1319
1328
time_width = e_week_view_get_time_string_width (week_view);
1363
1373
if (e_calendar_view_get_visible_time_range (E_CALENDAR_VIEW (week_view), &my_start, &my_end) &&
1364
1374
model_start == my_start && model_end == my_end) {
1365
1375
/* update only when the same time range is set in a view and in a model;
1366
otherwise time range change invokes also query update */
1376
* otherwise time range change invokes also query update */
1367
1377
e_week_view_update_query (week_view);
1407
1418
static gboolean
1408
1419
e_week_view_get_next_tab_event (EWeekView *week_view,
1409
GtkDirectionType direction,
1410
gint current_event_num,
1411
gint current_span_num,
1412
gint *next_event_num,
1413
gint *next_span_num)
1420
GtkDirectionType direction,
1421
gint current_event_num,
1422
gint current_span_num,
1423
gint *next_event_num,
1424
gint *next_span_num)
1415
1426
gint event_num;
1602
1614
/* This sets the selected time range. The EWeekView will show the corresponding
1603
month and the days between start_time and end_time will be selected.
1604
To select a single day, use the same value for start_time & end_time. */
1615
* month and the days between start_time and end_time will be selected.
1616
* To select a single day, use the same value for start_time & end_time. */
1606
e_week_view_set_selected_time_range (ECalendarView *cal_view,
1618
e_week_view_set_selected_time_range (ECalendarView *cal_view,
1610
1622
GDate date, end_date;
1646
1658
/* Reset the adjustment value to 0 if the base address has changed.
1647
Note that we do this after updating first_day_shown so that our
1648
signal handler will not try to reload the events. */
1659
* Note that we do this after updating first_day_shown so that our
1660
* signal handler will not try to reload the events. */
1649
1661
if (update_adjustment_value) {
1650
1662
GtkRange *range;
1651
1663
GtkAdjustment *adjustment;
1698
1710
/* Returns the selected time range. */
1699
1711
static gboolean
1700
e_week_view_get_selected_time_range (ECalendarView *cal_view,
1712
e_week_view_get_selected_time_range (ECalendarView *cal_view,
1704
1716
gint start_day, end_day;
1705
1717
EWeekView *week_view = E_WEEK_VIEW (cal_view);
1724
1736
/* Gets the visible time range. Returns FALSE if no time range has been set. */
1725
1737
static gboolean
1726
e_week_view_get_visible_time_range (ECalendarView *cal_view,
1738
e_week_view_get_visible_time_range (ECalendarView *cal_view,
1731
1743
EWeekView *week_view = E_WEEK_VIEW (cal_view);
1744
1756
/* Note that the returned date may be invalid if no date has been set yet. */
1746
e_week_view_get_first_day_shown (EWeekView *week_view,
1758
e_week_view_get_first_day_shown (EWeekView *week_view,
1749
1761
*date = week_view->first_day_shown;
1752
1764
/* This sets the first day shown in the view. It will be rounded down to the
1755
e_week_view_set_first_day_shown (EWeekView *week_view,
1767
e_week_view_set_first_day_shown (EWeekView *week_view,
1758
1770
GDate base_date;
1759
1771
gint weekday, day_offset, num_days;
1781
1793
day_offset = (weekday + 7 - week_view->display_start_day) % 7;
1783
1795
/* Calculate the base date, i.e. the first day shown when the
1784
scrollbar adjustment value is 0. */
1796
* scrollbar adjustment value is 0. */
1785
1797
base_date = *date;
1786
1798
g_date_subtract_days (&base_date, day_offset);
1811
1823
/* Try to keep the previous selection, but if it is no longer shown
1812
just select the first day. */
1824
* just select the first day. */
1813
1825
if (week_view->selection_start_day != -1) {
1814
1826
week_view->selection_start_day = old_selection_start_julian
1815
1827
- g_date_get_julian (&base_date);
1831
1843
/* Reset the adjustment value to 0 if the base address has changed.
1832
Note that we do this after updating first_day_shown so that our
1833
signal handler will not try to reload the events. */
1844
* Note that we do this after updating first_day_shown so that our
1845
* signal handler will not try to reload the events. */
1834
1846
if (update_adjustment_value) {
1835
1847
GtkRange *range;
1836
1848
GtkAdjustment *adjustment;
1867
month_scrol_by_week_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
1879
month_scrol_by_week_changed_cb (GConfClient *client,
1869
1884
EWeekView *week_view = user_data;
1889
e_week_view_set_multi_week_view (EWeekView *week_view,
1890
gboolean multi_week_view)
1904
e_week_view_set_multi_week_view (EWeekView *week_view,
1905
gboolean multi_week_view)
1892
1907
GtkRange *range;
1893
1908
GtkAdjustment *adjustment;
1949
e_week_view_set_update_base_date (EWeekView *week_view, gboolean update_base_date)
1964
e_week_view_set_update_base_date (EWeekView *week_view,
1965
gboolean update_base_date)
1951
1967
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
2031
2047
need_reload = e_week_view_recalc_display_start_day (week_view);
2033
2049
/* If the display_start_day has changed we need to recalculate the
2034
date range shown and reload all events, otherwise we only need to
2050
* date range shown and reload all events, otherwise we only need to
2036
2052
if (need_reload) {
2037
2053
/* Recalculate the days shown and reload if necessary. */
2038
2054
if (g_date_valid (&week_view->first_day_shown))
2088
2104
week_start_day = e_cal_model_get_week_start_day (model);
2090
2106
/* The display start day defaults to week_start_day, but we have
2091
to use Saturday if the weekend is compressed and week_start_day
2107
* to use Saturday if the weekend is compressed and week_start_day
2093
2109
display_start_day = week_start_day;
2095
2111
if (display_start_day == 6
2107
2123
/* Checks if the users participation status is NEEDS-ACTION and shows the summary as bold text */
2109
set_text_as_bold (EWeekViewEvent *event, EWeekViewEventSpan *span)
2125
set_text_as_bold (EWeekViewEvent *event,
2126
EWeekViewEventSpan *span)
2111
2128
ECalComponent *comp;
2112
2129
GSList *attendees = NULL, *l;
2133
2150
/* The attendee has not yet accepted the meeting, display the summary as bolded.
2134
If the attendee is not present, it might have come through a mailing list.
2135
In that case, we never show the meeting as bold even if it is unaccepted. */
2151
* If the attendee is not present, it might have come through a mailing list.
2152
* In that case, we never show the meeting as bold even if it is unaccepted. */
2136
2153
if (at && (at->status == ICAL_PARTSTAT_NEEDSACTION))
2137
2154
gnome_canvas_item_set (span->text_item, "bold", TRUE, NULL);
2144
2161
/* This calls a given function for each event instance that matches the given
2145
uid. Note that it is safe for the callback to remove the event (since we
2146
step backwards through the arrays). */
2162
* uid. Note that it is safe for the callback to remove the event (since we
2163
* step backwards through the arrays). */
2148
2165
e_week_view_foreach_event_with_uid (EWeekView *week_view,
2150
EWeekViewForeachEventCallback callback,
2167
EWeekViewForeachEventCallback callback,
2153
2170
EWeekViewEvent *event;
2154
2171
gint event_num;
2191
2208
/* If we were editing this event, set editing_event_num to -1 so
2192
on_editing_stopped doesn't try to update the event. */
2209
* on_editing_stopped doesn't try to update the event. */
2193
2210
if (week_view->editing_event_num == event_num)
2194
2211
week_view->editing_event_num = -1;
2203
2220
if (week_view->spans) {
2204
2221
/* We leave the span elements in the array, but set the canvas item
2205
pointers to NULL. */
2222
* pointers to NULL. */
2206
2223
for (span_num = 0; span_num < event->num_spans; span_num++) {
2207
2224
if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
2249
e_week_view_get_day_position (EWeekView *week_view,
2266
e_week_view_get_day_position (EWeekView *week_view,
2256
2273
gint cell_x, cell_y, cell_h;
2278
2295
/* Returns the bounding box for a span of an event. Usually this can easily
2279
be determined by the start & end days and row of the span, which are set in
2280
e_week_view_layout_event (). Though we need a special case for the weekends
2281
when they are compressed, since the span may not fit.
2282
The bounding box includes the entire width of the days in the view (but
2283
not the vertical line down the right of the last day), though the displayed
2284
event doesn't normally extend to the edges of the day.
2285
It returns FALSE if the span isn't visible. */
2296
* be determined by the start & end days and row of the span, which are set in
2297
* e_week_view_layout_event (). Though we need a special case for the weekends
2298
* when they are compressed, since the span may not fit.
2299
* The bounding box includes the entire width of the days in the view (but
2300
* not the vertical line down the right of the last day), though the displayed
2301
* event doesn't normally extend to the edges of the day.
2302
* It returns FALSE if the span isn't visible. */
2287
e_week_view_get_span_position (EWeekView *week_view,
2304
e_week_view_get_span_position (EWeekView *week_view,
2294
2311
EWeekViewEvent *event;
2295
2312
EWeekViewEventSpan *span;
2342
2359
static gboolean
2343
ewv_pass_gdkevent_to_etext (EWeekView *week_view, GdkEvent *gevent)
2360
ewv_pass_gdkevent_to_etext (EWeekView *week_view,
2345
2363
g_return_val_if_fail (week_view != NULL, FALSE);
2346
2364
g_return_val_if_fail (gevent != NULL, FALSE);
2554
2572
/* Converts a position in the canvas window to a day offset from the first
2555
day displayed. Returns -1 if the position is outside the grid. */
2573
* day displayed. Returns -1 if the position is outside the grid. */
2557
2575
e_week_view_convert_position_to_day (EWeekView *week_view,
2561
2579
gint col, row, grid_x = -1, grid_y = -1, week, day;
2562
2580
gint weekend_col;
2825
2843
e_week_view_event_sort_func (gconstpointer arg1,
2828
2846
EWeekViewEvent *event1, *event2;
2830
event1 = (EWeekViewEvent*) arg1;
2831
event2 = (EWeekViewEvent*) arg2;
2848
event1 = (EWeekViewEvent *) arg1;
2849
event2 = (EWeekViewEvent *) arg2;
2833
2851
if (event1->start < event2->start)
2935
tooltip_destroy (EWeekView *week_view, GnomeCanvasItem *item)
2955
tooltip_destroy (EWeekView *week_view,
2956
GnomeCanvasItem *item)
2937
2958
gint event_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
2938
2959
EWeekViewEvent *pevent;
2996
3017
pevent->tooltip = (GtkWidget *)g_object_get_data (G_OBJECT (view), "tooltip-window");
2998
3019
if (pevent->tooltip) {
2999
e_calendar_view_move_tip (pevent->tooltip, pevent->x+16, pevent->y+16);
3020
e_calendar_view_move_tip (pevent->tooltip, pevent->x + 16, pevent->y + 16);
3012
3033
static const gchar *
3013
get_comp_summary (ECalClient *client, icalcomponent *icalcomp, gboolean *free_text)
3034
get_comp_summary (ECalClient *client,
3035
icalcomponent *icalcomp,
3036
gboolean *free_text)
3015
3038
const gchar *my_summary, *location;
3016
3039
const gchar *summary;
3074
3097
one_day_event = e_week_view_is_one_day_event (week_view, event_num);
3076
3099
/* If the span will not be visible destroy the canvas items and
3078
3101
if (!e_week_view_get_span_position (week_view, event_num, span_num,
3079
3102
&span_x, &span_y, &span_w)) {
3080
3103
if (span->background_item)
3096
3119
layout = pango_layout_new (pango_context);
3098
3121
/* If we are editing a long event we don't show the icons and the EText
3099
item uses the maximum width available. */
3122
* item uses the maximum width available. */
3100
3123
if (!one_day_event && week_view->editing_event_num == event_num
3101
3124
&& week_view->editing_span_num == span_num) {
3102
3125
show_icons = FALSE;
3180
3203
/* Calculate the position of the text item.
3181
For events < 1 day it starts after the times & icons and ends at the
3182
right edge of the span.
3183
For events >= 1 day we need to determine whether times are shown at
3184
the start and end of the span, then try to center the text item with
3185
the icons in the middle, but making sure we don't go over the times.
3204
* For events < 1 day it starts after the times & icons and ends at the
3205
* right edge of the span.
3206
* For events >= 1 day we need to determine whether times are shown at
3207
* the start and end of the span, then try to center the text item with
3208
* the icons in the middle, but making sure we don't go over the times.
3188
3211
/* Calculate the space necessary to display a time, e.g. "13:00". */
3203
3226
if (one_day_event) {
3204
3227
/* Note that 1-day events don't have a border. Although we
3205
still use the border height to position the events
3206
vertically so they still line up neatly (see above),
3207
we don't use the border width or edge padding at all. */
3228
* still use the border height to position the events
3229
* vertically so they still line up neatly (see above),
3230
* we don't use the border width or edge padding at all. */
3208
3231
text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD;
3210
3233
switch (week_view->time_format) {
3211
3234
case E_WEEK_VIEW_TIME_BOTH_SMALL_MIN:
3212
3235
case E_WEEK_VIEW_TIME_BOTH:
3213
3236
/* These have 2 time strings with a small space between
3214
them and some space before the EText item. */
3237
* them and some space before the EText item. */
3215
3238
text_x += time_width * 2
3216
3239
+ E_WEEK_VIEW_EVENT_TIME_SPACING
3217
3240
+ E_WEEK_VIEW_EVENT_TIME_X_PAD;
3219
3242
case E_WEEK_VIEW_TIME_START_SMALL_MIN:
3220
3243
case E_WEEK_VIEW_TIME_START:
3221
3244
/* These have just 1 time string with some space
3222
before the EText item. */
3245
* before the EText item. */
3223
3246
text_x += time_width + E_WEEK_VIEW_EVENT_TIME_X_PAD;
3225
3248
case E_WEEK_VIEW_TIME_NONE:
3230
3253
text_x += icons_width;
3232
3255
/* The width of the EText item extends right to the edge of the
3233
event, just inside the border. */
3256
* event, just inside the border. */
3234
3257
text_w = span_x + span_w - E_WEEK_VIEW_EVENT_R_PAD - text_x;
3237
3260
if (use_max_width) {
3238
3261
/* When we are editing the event we use all the
3262
* available width. */
3240
3263
text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD
3241
3264
+ E_WEEK_VIEW_EVENT_BORDER_WIDTH
3242
3265
+ E_WEEK_VIEW_EVENT_EDGE_X_PAD;
3248
3271
/* Get the width of the text of the event. This is a
3249
bit of a hack. It would be better if EText could
3251
g_object_get (G_OBJECT (span->text_item), "text", &text, NULL);
3272
* bit of a hack. It would be better if EText could
3274
g_object_get (span->text_item, "text", &text, NULL);
3252
3275
text_width = 0;
3254
3277
/* It should only have one line of text in it.
3255
I'm not sure we need this any more. */
3278
* I'm not sure we need this any more. */
3256
3279
end_of_line = strchr (text, '\n');
3257
3280
if (end_of_line)
3258
3281
line_len = end_of_line - text;
3267
3290
/* Add on the width of the icons and find the default
3268
position, which centers the icons + text. */
3291
* position, which centers the icons + text. */
3269
3292
width = text_width + icons_width;
3270
3293
text_x = span_x + (span_w - width) / 2;
3272
3295
/* Now calculate the left-most valid position, and make
3273
sure we don't go to the left of that. */
3296
* sure we don't go to the left of that. */
3274
3297
min_text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD
3275
3298
+ E_WEEK_VIEW_EVENT_BORDER_WIDTH
3276
3299
+ E_WEEK_VIEW_EVENT_EDGE_X_PAD;
3277
3300
/* See if we will want to display the start time, and
3278
if so take that into account. */
3301
* if so take that into account. */
3279
3302
if (event->start > week_view->day_starts[span->start_day])
3280
3303
min_text_x += time_width
3281
3304
+ E_WEEK_VIEW_EVENT_TIME_X_PAD;
3283
3306
/* Now make sure we don't go to the left of the minimum
3285
3308
text_x = MAX (text_x, min_text_x);
3287
3310
/* Now calculate the largest valid width, using the
3288
calculated x position, and make sure we don't
3311
* calculated x position, and make sure we don't
3290
3313
max_text_w = span_x + span_w - E_WEEK_VIEW_EVENT_R_PAD
3291
3314
- E_WEEK_VIEW_EVENT_BORDER_WIDTH
3292
3315
- E_WEEK_VIEW_EVENT_EDGE_X_PAD - text_x;
3403
3426
span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num);
3405
3428
/* Try to move the cursor to the end of the text. */
3406
g_object_get (G_OBJECT (span->text_item), "event_processor", &event_processor, NULL);
3429
g_object_get (span->text_item, "event_processor", &event_processor, NULL);
3407
3430
if (event_processor) {
3408
3431
command.action = E_TEP_MOVE;
3409
3432
command.position = E_TEP_END_OF_BUFFER;
3459
3482
/* Reset the text to what was in the component */
3461
3484
summary = icalcomponent_get_summary (event->comp_data->icalcomp);
3462
g_object_set (G_OBJECT (span->text_item), "text", summary ? summary : "", NULL);
3485
g_object_set (span->text_item, "text", summary ? summary : "", NULL);
3464
3487
/* Stop editing */
3465
3488
e_week_view_stop_editing_event (week_view);
3486
3509
tooltip_destroy (week_view, item);
3487
3510
if (!E_TEXT (item)->preedit_len && gdkevent && gdkevent->key.keyval == GDK_KEY_Return) {
3488
3511
/* We set the keyboard focus to the EDayView, so the
3489
EText item loses it and stops the edit. */
3512
* EText item loses it and stops the edit. */
3490
3513
gtk_widget_grab_focus (GTK_WIDGET (week_view));
3492
3515
/* Stop the signal last or we will also stop any
3493
other events getting to the EText item. */
3516
* other events getting to the EText item. */
3494
3517
g_signal_stop_emission_by_name (G_OBJECT (item), "event");
3496
3519
} else if (gdkevent->key.keyval == GDK_KEY_Escape) {
3518
3541
/* if we started to editing new item on the canvas, then do not open editing dialog until it's saved,
3519
because the save of the event recalculates event numbers and you can edit different one */
3542
* because the save of the event recalculates event numbers and you can edit different one */
3520
3543
if (!is_icalcomp_on_the_server (event->comp_data->icalcomp, event->comp_data->client))
3552
3575
e_week_view_set_selected_time_range_visible (week_view, e->start, e->end);
3554
3577
e_week_view_show_popup_menu (week_view,
3555
(GdkEventButton*) gdkevent,
3578
(GdkEventButton *) gdkevent,
3558
3581
g_signal_stop_emission_by_name (G_OBJECT (item->canvas),
3603
3626
/* Stop the signal last or we will also stop any
3604
other events getting to the EText item. */
3627
* other events getting to the EText item. */
3605
3628
g_signal_stop_emission_by_name (G_OBJECT (item), "event");
3648
3671
pevent->tooltip = (GtkWidget *)g_object_get_data (G_OBJECT (week_view), "tooltip-window");
3650
3673
if (pevent->tooltip) {
3651
e_calendar_view_move_tip (pevent->tooltip, pevent->x+16, pevent->y+16);
3674
e_calendar_view_move_tip (pevent->tooltip, pevent->x + 16, pevent->y + 16);
3654
3677
case GDK_FOCUS_CHANGE:
3760
e_week_view_scroll_a_step (EWeekView *week_view, ECalViewMoveDirection direction)
3784
e_week_view_scroll_a_step (EWeekView *week_view,
3785
ECalViewMoveDirection direction)
3762
3787
GtkAdjustment *adjustment;
3763
3788
GtkRange *range;
3827
3855
client = event->comp_data->client;
3829
3857
/* We use a temporary shallow copy of the ico since we don't want to
3830
change the original ico here. Otherwise we would not detect that
3831
the event's time had changed in the "update_event" callback. */
3858
* change the original ico here. Otherwise we would not detect that
3859
* the event's time had changed in the "update_event" callback. */
3832
3860
comp = e_cal_component_new ();
3833
3861
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
3834
3862
date.value = &itt;
3835
3863
/* FIXME: Should probably keep the timezone of the original start
3837
3865
date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)));
3839
3867
*date.value = icaltime_from_timet_with_zone (start_dt, is_all_day,
3897
3925
week_view->editing_span_num = span_num;
3899
3927
/* We need to reshape long events so the whole width is used while
3901
3929
if (!e_week_view_is_one_day_event (week_view, event_num)) {
3902
3930
e_week_view_reshape_event_span (week_view, event_num,
3921
3949
gboolean on_server;
3923
3951
/* Note: the item we are passed here isn't reliable, so we just stop
3924
the edit of whatever item was being edited. We also receive this
3925
event twice for some reason. */
3952
* the edit of whatever item was being edited. We also receive this
3953
* event twice for some reason. */
3926
3954
event_num = week_view->editing_event_num;
3927
3955
span_num = week_view->editing_span_num;
3956
3984
g_object_set (span->text_item, "handle_popup", FALSE, NULL);
3957
g_object_get (G_OBJECT (span->text_item), "text", &text, NULL);
3985
g_object_get (span->text_item, "text", &text, NULL);
3959
3987
comp = e_cal_component_new ();
3960
3988
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
3980
4008
const gchar *summary;
3982
4010
summary = get_comp_summary (event->comp_data->client, event->comp_data->icalcomp, &free_text);
3983
g_object_set (G_OBJECT (span->text_item), "text", summary ? summary : "", NULL);
4011
g_object_set (span->text_item, "text", summary ? summary : "", NULL);
3986
4014
g_free ((gchar *) summary);
4131
4159
/* Finds the index of the event with the given uid.
4132
Returns TRUE if an event with the uid was found.
4133
Note that for recurring events there may be several EWeekViewEvents, one
4134
for each instance, all with the same iCalObject and uid. So only use this
4135
function if you know the event doesn't recur or you are just checking to
4136
see if any events with the uid exist. */
4160
* Returns TRUE if an event with the uid was found.
4161
* Note that for recurring events there may be several EWeekViewEvents, one
4162
* for each instance, all with the same iCalObject and uid. So only use this
4163
* function if you know the event doesn't recur or you are just checking to
4164
* see if any events with the uid exist. */
4137
4165
static gboolean
4138
e_week_view_find_event_from_uid (EWeekView *week_view,
4142
gint *event_num_return)
4166
e_week_view_find_event_from_uid (EWeekView *week_view,
4170
gint *event_num_return)
4144
4172
EWeekViewEvent *event;
4145
4173
gint event_num, num_events;
4314
4343
comp, e_calendar_view_get_default_category (E_CALENDAR_VIEW (week_view)));
4316
4345
/* We add the event locally and start editing it. We don't send it
4317
to the server until the user finishes editing it. */
4346
* to the server until the user finishes editing it. */
4318
4347
add_event_data.week_view = week_view;
4319
4348
add_event_data.comp_data = NULL;
4320
4349
e_week_view_add_event (comp, dtstart, dtend, TRUE, &add_event_data);
4478
e_week_view_get_adjust_days_for_move_left (EWeekView *week_view,gint current_day)
4510
e_week_view_get_adjust_days_for_move_left (EWeekView *week_view,
4484
e_week_view_get_adjust_days_for_move_right (EWeekView *week_view,gint current_day)
4517
e_week_view_get_adjust_days_for_move_right (EWeekView *week_view,
4489
4523
static gboolean
4490
e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
4524
e_week_view_key_press (GtkWidget *widget,
4492
4527
gboolean handled = FALSE;
4493
4528
handled = e_week_view_do_key_press (widget, event);
4596
4632
/* Converts an hour from 0-23 to the preferred time format, and returns the
4597
suffix to add and the width of it in the normal font. */
4633
* suffix to add and the width of it in the normal font. */
4599
e_week_view_convert_time_to_display (EWeekView *week_view,
4602
const gchar **suffix,
4635
e_week_view_convert_time_to_display (EWeekView *week_view,
4638
const gchar **suffix,
4605
4641
ECalModel *model;
4607
4643
model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
4609
4645
/* Calculate the actual hour number to display. For 12-hour
4610
format we convert 0-23 to 12-11am/12-11pm. */
4646
* format we convert 0-23 to 12-11am/12-11pm. */
4611
4647
*display_hour = hour;
4612
4648
if (e_cal_model_get_use_24_hour_format (model)) {
4694
e_week_view_is_jump_button_visible (EWeekView *week_view, gint day)
4730
e_week_view_is_jump_button_visible (EWeekView *week_view,
4696
4733
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);