~ubuntu-branches/ubuntu/precise/evolution/precise

« back to all changes in this revision

Viewing changes to calendar/gui/e-week-view.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2011-09-08 09:38:57 UTC
  • mfrom: (1.1.84 upstream)
  • Revision ID: package-import@ubuntu.com-20110908093857-6lfl04ke2ns3kx2o
Tags: 3.1.91-0ubuntu1
* New upstream release. (LP: #843769)
* debian/control: bump e-d-s Build-Depends to 3.1.91. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
#define E_WEEK_VIEW_JUMP_BUTTON_NO_FOCUS -1
76
76
 
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
80
80
 
81
81
typedef struct {
236
236
}
237
237
 
238
238
static void
239
 
week_view_update_row (EWeekView *week_view, gint row)
 
239
week_view_update_row (EWeekView *week_view,
 
240
                      gint row)
240
241
{
241
242
        ECalModelComponent *comp_data;
242
243
        ECalModel *model;
384
385
        week_start_offset = (weekday + 7 - week_view->display_start_day) % 7;
385
386
 
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;
389
390
 
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);
394
395
 
411
412
        }
412
413
 
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) {
417
418
                GtkRange *range;
418
419
                GtkAdjustment *adjustment;
460
461
                return;
461
462
 
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);
854
855
 
855
856
        view = g_object_new (E_TYPE_WEEK_VIEW, "model", model, NULL);
856
857
 
857
 
        g_signal_connect (G_OBJECT (model), "timezone_changed",
858
 
                          G_CALLBACK (timezone_changed_cb), view);
 
858
        g_signal_connect (
 
859
                model, "timezone_changed",
 
860
                G_CALLBACK (timezone_changed_cb), view);
 
861
 
859
862
        return view;
860
863
}
861
864
 
923
926
}
924
927
 
925
928
static GdkColor
926
 
color_inc (GdkColor c, gint amount)
 
929
color_inc (GdkColor c,
 
930
           gint amount)
927
931
{
928
932
        #define dec(x)                          \
929
933
                if (x + amount >= 0             \
944
948
}
945
949
 
946
950
static void
947
 
e_week_view_set_colors (EWeekView *week_view, GtkWidget *widget)
 
951
e_week_view_set_colors (EWeekView *week_view,
 
952
                        GtkWidget *widget)
948
953
{
949
954
        GtkStyle *style;
950
955
 
988
993
}
989
994
 
990
995
static gint
991
 
get_string_width (PangoLayout *layout, const gchar *string)
 
996
get_string_width (PangoLayout *layout,
 
997
                  const gchar *string)
992
998
{
993
999
        gint width;
994
1000
 
1022
1028
}
1023
1029
 
1024
1030
static GdkColor
1025
 
e_week_view_get_text_color (EWeekView *week_view, EWeekViewEvent *event, GtkWidget *widget)
 
1031
e_week_view_get_text_color (EWeekView *week_view,
 
1032
                            EWeekViewEvent *event,
 
1033
                            GtkWidget *widget)
1026
1034
{
1027
1035
        GtkStyle *style;
1028
1036
        GdkColor bg_color;
1042
1050
 
1043
1051
        style = gtk_widget_get_style (widget);
1044
1052
 
1045
 
        if ((red/cc > 0.7) || (green/cc > 0.7) || (blue/cc > 0.7 ))
 
1053
        if ((red / cc > 0.7) || (green / cc > 0.7) || (blue / cc > 0.7 ))
1046
1054
                return style->black;
1047
1055
        else
1048
1056
                return style->white;
1050
1058
 
1051
1059
static void
1052
1060
e_week_view_style_set (GtkWidget *widget,
1053
 
                       GtkStyle  *previous_style)
 
1061
                       GtkStyle *previous_style)
1054
1062
{
1055
1063
        EWeekView *week_view;
1056
1064
        GtkStyle *style;
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);
1100
1108
 
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);
1115
1123
 
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. */
1118
1126
 
1119
1127
        max_day_width = 0;
1120
1128
        max_abbr_day_width = 0;
1169
1177
 
1170
1178
/* This recalculates the sizes of each column. */
1171
1179
static void
1172
 
e_week_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
 
1180
e_week_view_size_allocate (GtkWidget *widget,
 
1181
                           GtkAllocation *allocation)
1173
1182
{
1174
1183
        EWeekView *week_view;
1175
1184
        GtkAllocation canvas_allocation;
1195
1204
                        0, 0, new_x2, new_y2);
1196
1205
 
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);
1240
1249
 
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;
1248
1257
        offset = 0;
1286
1295
                                                  pango_context_get_language (pango_context));
1287
1296
 
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);
1314
1323
 
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];
1318
1327
 
1319
1328
        time_width = e_week_view_get_time_string_width (week_view);
1337
1346
}
1338
1347
 
1339
1348
static gint
1340
 
e_week_view_focus_in (GtkWidget *widget, GdkEventFocus *event)
 
1349
e_week_view_focus_in (GtkWidget *widget,
 
1350
                      GdkEventFocus *event)
1341
1351
{
1342
1352
        EWeekView *week_view;
1343
1353
 
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);
1368
1378
                }
1369
1379
        }
1374
1384
}
1375
1385
 
1376
1386
static gint
1377
 
e_week_view_focus_out (GtkWidget *widget, GdkEventFocus *event)
 
1387
e_week_view_focus_out (GtkWidget *widget,
 
1388
                       GdkEventFocus *event)
1378
1389
{
1379
1390
        EWeekView *week_view;
1380
1391
 
1406
1417
 **/
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)
1414
1425
{
1415
1426
        gint event_num;
1416
1427
 
1453
1464
}
1454
1465
 
1455
1466
static gboolean
1456
 
e_week_view_focus (GtkWidget *widget, GtkDirectionType direction)
 
1467
e_week_view_focus (GtkWidget *widget,
 
1468
                   GtkDirectionType direction)
1457
1469
{
1458
1470
        EWeekView *week_view;
1459
1471
        gint new_event_num;
1600
1612
}
1601
1613
 
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. */
1605
1617
static void
1606
 
e_week_view_set_selected_time_range     (ECalendarView  *cal_view,
1607
 
                                         time_t          start_time,
1608
 
                                         time_t          end_time)
 
1618
e_week_view_set_selected_time_range (ECalendarView *cal_view,
 
1619
                                     time_t start_time,
 
1620
                                     time_t end_time)
1609
1621
{
1610
1622
        GDate date, end_date;
1611
1623
        gint num_days;
1644
1656
                                              num_days);
1645
1657
 
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;
1659
1671
}
1660
1672
 
1661
1673
void
1662
 
e_week_view_set_selected_time_range_visible     (EWeekView      *week_view,
1663
 
                                                 time_t          start_time,
1664
 
                                                 time_t          end_time)
 
1674
e_week_view_set_selected_time_range_visible (EWeekView *week_view,
 
1675
                                             time_t start_time,
 
1676
                                             time_t end_time)
1665
1677
{
1666
1678
        GDate date, end_date;
1667
1679
        gint num_days;
1697
1709
 
1698
1710
/* Returns the selected time range. */
1699
1711
static gboolean
1700
 
e_week_view_get_selected_time_range     (ECalendarView  *cal_view,
1701
 
                                         time_t         *start_time,
1702
 
                                         time_t         *end_time)
 
1712
e_week_view_get_selected_time_range (ECalendarView *cal_view,
 
1713
                                     time_t *start_time,
 
1714
                                     time_t *end_time)
1703
1715
{
1704
1716
        gint start_day, end_day;
1705
1717
        EWeekView *week_view = E_WEEK_VIEW (cal_view);
1723
1735
 
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,
1727
 
                                         time_t         *start_time,
1728
 
                                         time_t         *end_time)
 
1738
e_week_view_get_visible_time_range (ECalendarView *cal_view,
 
1739
                                    time_t *start_time,
 
1740
                                    time_t *end_time)
1729
1741
{
1730
1742
        gint num_days;
1731
1743
        EWeekView *week_view = E_WEEK_VIEW (cal_view);
1743
1755
 
1744
1756
/* Note that the returned date may be invalid if no date has been set yet. */
1745
1757
void
1746
 
e_week_view_get_first_day_shown         (EWeekView      *week_view,
1747
 
                                         GDate          *date)
 
1758
e_week_view_get_first_day_shown (EWeekView *week_view,
 
1759
                                 GDate *date)
1748
1760
{
1749
1761
        *date = week_view->first_day_shown;
1750
1762
}
1751
1763
 
1752
1764
/* This sets the first day shown in the view. It will be rounded down to the
1753
 
   nearest week. */
 
1765
 * nearest week. */
1754
1766
void
1755
 
e_week_view_set_first_day_shown         (EWeekView      *week_view,
1756
 
                                         GDate          *date)
 
1767
e_week_view_set_first_day_shown (EWeekView *week_view,
 
1768
                                 GDate *date)
1757
1769
{
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;
1782
1794
 
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);
1787
1799
 
1809
1821
        }
1810
1822
 
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);
1829
1841
        }
1830
1842
 
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;
1847
1859
/* Recalculates the time_t corresponding to the start of each day. */
1848
1860
static void
1849
1861
e_week_view_recalc_day_starts (EWeekView *week_view,
1850
 
                               time_t lower)
 
1862
                               time_t lower)
1851
1863
{
1852
1864
        gint num_days, day;
1853
1865
        time_t tmp_time;
1864
1876
}
1865
1877
 
1866
1878
static void
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,
 
1880
                                guint cnxn_id,
 
1881
                                GConfEntry *entry,
 
1882
                                gpointer user_data)
1868
1883
{
1869
1884
        EWeekView *week_view = user_data;
1870
1885
 
1878
1893
}
1879
1894
 
1880
1895
gboolean
1881
 
e_week_view_get_multi_week_view (EWeekView      *week_view)
 
1896
e_week_view_get_multi_week_view (EWeekView *week_view)
1882
1897
{
1883
1898
        g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);
1884
1899
 
1886
1901
}
1887
1902
 
1888
1903
void
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)
1891
1906
{
1892
1907
        GtkRange *range;
1893
1908
        GtkAdjustment *adjustment;
1946
1961
}
1947
1962
 
1948
1963
void
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)
1950
1966
{
1951
1967
        g_return_if_fail (E_IS_WEEK_VIEW (week_view));
1952
1968
 
1954
1970
}
1955
1971
 
1956
1972
gint
1957
 
e_week_view_get_weeks_shown     (EWeekView      *week_view)
 
1973
e_week_view_get_weeks_shown (EWeekView *week_view)
1958
1974
{
1959
1975
        g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), 1);
1960
1976
 
1962
1978
}
1963
1979
 
1964
1980
void
1965
 
e_week_view_set_weeks_shown     (EWeekView      *week_view,
1966
 
                                 gint            weeks_shown)
 
1981
e_week_view_set_weeks_shown (EWeekView *week_view,
 
1982
                             gint weeks_shown)
1967
1983
{
1968
1984
        GtkRange *range;
1969
1985
        GtkAdjustment *adjustment;
2031
2047
        need_reload = e_week_view_recalc_display_start_day (week_view);
2032
2048
 
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
2035
 
           do a reshape. */
 
2050
         * date range shown and reload all events, otherwise we only need to
 
2051
         * do a reshape. */
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))
2078
2094
}
2079
2095
 
2080
2096
static gboolean
2081
 
e_week_view_recalc_display_start_day    (EWeekView      *week_view)
 
2097
e_week_view_recalc_display_start_day (EWeekView *week_view)
2082
2098
{
2083
2099
        ECalModel *model;
2084
2100
        gint week_start_day;
2088
2104
        week_start_day = e_cal_model_get_week_start_day (model);
2089
2105
 
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
2092
 
           is Sunday. */
 
2107
         * to use Saturday if the weekend is compressed and week_start_day
 
2108
         * is Sunday. */
2093
2109
        display_start_day = week_start_day;
2094
2110
 
2095
2111
        if (display_start_day == 6
2106
2122
 
2107
2123
/* Checks if the users participation status is NEEDS-ACTION and shows the summary as bold text */
2108
2124
static void
2109
 
set_text_as_bold (EWeekViewEvent *event, EWeekViewEventSpan *span)
 
2125
set_text_as_bold (EWeekViewEvent *event,
 
2126
                  EWeekViewEventSpan *span)
2110
2127
{
2111
2128
        ECalComponent *comp;
2112
2129
        GSList *attendees = NULL, *l;
2131
2148
        }
2132
2149
 
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);
2138
2155
 
2142
2159
}
2143
2160
 
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). */
2147
2164
static void
2148
2165
e_week_view_foreach_event_with_uid (EWeekView *week_view,
2149
 
                                    const gchar *uid,
2150
 
                                    EWeekViewForeachEventCallback callback,
2151
 
                                    gpointer data)
 
2166
                                    const gchar *uid,
 
2167
                                    EWeekViewForeachEventCallback callback,
 
2168
                                    gpointer data)
2152
2169
{
2153
2170
        EWeekViewEvent *event;
2154
2171
        gint event_num;
2174
2191
 
2175
2192
static gboolean
2176
2193
e_week_view_remove_event_cb (EWeekView *week_view,
2177
 
                             gint event_num,
2178
 
                             gpointer data)
 
2194
                             gint event_num,
 
2195
                             gpointer data)
2179
2196
{
2180
2197
        EWeekViewEvent *event;
2181
2198
        EWeekViewEventSpan *span;
2189
2206
                return TRUE;
2190
2207
 
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;
2195
2212
 
2202
2219
 
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))
2208
2225
                                break;
2246
2263
}
2247
2264
 
2248
2265
void
2249
 
e_week_view_get_day_position    (EWeekView      *week_view,
2250
 
                                 gint            day,
2251
 
                                 gint           *day_x,
2252
 
                                 gint           *day_y,
2253
 
                                 gint           *day_w,
2254
 
                                 gint           *day_h)
 
2266
e_week_view_get_day_position (EWeekView *week_view,
 
2267
                              gint day,
 
2268
                              gint *day_x,
 
2269
                              gint *day_y,
 
2270
                              gint *day_w,
 
2271
                              gint *day_h)
2255
2272
{
2256
2273
        gint cell_x, cell_y, cell_h;
2257
2274
 
2276
2293
}
2277
2294
 
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. */
2286
2303
gboolean
2287
 
e_week_view_get_span_position   (EWeekView      *week_view,
2288
 
                                 gint            event_num,
2289
 
                                 gint            span_num,
2290
 
                                 gint           *span_x,
2291
 
                                 gint           *span_y,
2292
 
                                 gint           *span_w)
 
2304
e_week_view_get_span_position (EWeekView *week_view,
 
2305
                               gint event_num,
 
2306
                               gint span_num,
 
2307
                               gint *span_x,
 
2308
                               gint *span_y,
 
2309
                               gint *span_w)
2293
2310
{
2294
2311
        EWeekViewEvent *event;
2295
2312
        EWeekViewEventSpan *span;
2340
2357
}
2341
2358
 
2342
2359
static gboolean
2343
 
ewv_pass_gdkevent_to_etext (EWeekView *week_view, GdkEvent *gevent)
 
2360
ewv_pass_gdkevent_to_etext (EWeekView *week_view,
 
2361
                            GdkEvent *gevent)
2344
2362
{
2345
2363
        g_return_val_if_fail (week_view != NULL, FALSE);
2346
2364
        g_return_val_if_fail (gevent != NULL, FALSE);
2370
2388
 
2371
2389
static gboolean
2372
2390
e_week_view_on_button_press (GtkWidget *widget,
2373
 
                             GdkEventButton *event,
2374
 
                             EWeekView *week_view)
 
2391
                             GdkEventButton *event,
 
2392
                             EWeekView *week_view)
2375
2393
{
2376
2394
        gint x, y, day;
2377
2395
 
2453
2471
 
2454
2472
static gboolean
2455
2473
e_week_view_on_button_release (GtkWidget *widget,
2456
 
                               GdkEventButton *event,
2457
 
                               EWeekView *week_view)
 
2474
                               GdkEventButton *event,
 
2475
                               EWeekView *week_view)
2458
2476
{
2459
2477
#if 0
2460
2478
        g_print ("In e_week_view_on_button_release\n");
2472
2490
 
2473
2491
static gboolean
2474
2492
e_week_view_on_scroll (GtkWidget *widget,
2475
 
                       GdkEventScroll *scroll,
2476
 
                       EWeekView *week_view)
 
2493
                       GdkEventScroll *scroll,
 
2494
                       EWeekView *week_view)
2477
2495
{
2478
2496
        GtkRange *range;
2479
2497
        GtkAdjustment *adjustment;
2525
2543
 
2526
2544
static gboolean
2527
2545
e_week_view_on_motion (GtkWidget *widget,
2528
 
                       GdkEventMotion *mevent,
2529
 
                       EWeekView *week_view)
 
2546
                       GdkEventMotion *mevent,
 
2547
                       EWeekView *week_view)
2530
2548
{
2531
2549
        gint x, y, day;
2532
2550
 
2552
2570
}
2553
2571
 
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. */
2556
2574
static gint
2557
2575
e_week_view_convert_position_to_day (EWeekView *week_view,
2558
 
                                     gint x,
2559
 
                                     gint y)
 
2576
                                     gint x,
 
2577
                                     gint y)
2560
2578
{
2561
2579
        gint col, row, grid_x = -1, grid_y = -1, week, day;
2562
2580
        gint weekend_col;
2612
2630
 
2613
2631
static void
2614
2632
e_week_view_update_selection (EWeekView *week_view,
2615
 
                              gint day)
 
2633
                              gint day)
2616
2634
{
2617
2635
        gint tmp_day;
2618
2636
        gboolean need_redraw = FALSE;
2704
2722
/* This adds one event to the view, adding it to the appropriate array. */
2705
2723
static gboolean
2706
2724
e_week_view_add_event (ECalComponent *comp,
2707
 
                       time_t     start,
2708
 
                       time_t     end,
2709
 
                       gboolean prepend,
2710
 
                       gpointer   data)
 
2725
                       time_t start,
 
2726
                       time_t end,
 
2727
                       gboolean prepend,
 
2728
                       gpointer data)
2711
2729
 
2712
2730
{
2713
2731
        AddEventData *add_event_data;
2823
2841
 
2824
2842
gint
2825
2843
e_week_view_event_sort_func (gconstpointer arg1,
2826
 
                             gconstpointer arg2)
 
2844
                             gconstpointer arg2)
2827
2845
{
2828
2846
        EWeekViewEvent *event1, *event2;
2829
2847
 
2830
 
        event1 = (EWeekViewEvent*) arg1;
2831
 
        event2 = (EWeekViewEvent*) arg2;
 
2848
        event1 = (EWeekViewEvent *) arg1;
 
2849
        event2 = (EWeekViewEvent *) arg2;
2832
2850
 
2833
2851
        if (event1->start < event2->start)
2834
2852
                return -1;
2919
2937
}
2920
2938
 
2921
2939
static EWeekViewEvent *
2922
 
tooltip_get_view_event (EWeekView *week_view, gint day, gint event_num)
 
2940
tooltip_get_view_event (EWeekView *week_view,
 
2941
                        gint day,
 
2942
                        gint event_num)
2923
2943
{
2924
2944
        EWeekViewEvent *pevent;
2925
2945
 
2932
2952
}
2933
2953
 
2934
2954
static void
2935
 
tooltip_destroy (EWeekView *week_view, GnomeCanvasItem *item)
 
2955
tooltip_destroy (EWeekView *week_view,
 
2956
                 GnomeCanvasItem *item)
2936
2957
{
2937
2958
        gint event_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
2938
2959
        EWeekViewEvent *pevent;
2957
2978
 
2958
2979
static gboolean
2959
2980
tooltip_event_cb (GnomeCanvasItem *item,
2960
 
                  GdkEvent *event,
2961
 
                  EWeekView *view)
 
2981
                  GdkEvent *event,
 
2982
                  EWeekView *view)
2962
2983
{
2963
2984
        gint event_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
2964
2985
        EWeekViewEvent *pevent;
2996
3017
                        pevent->tooltip = (GtkWidget *)g_object_get_data (G_OBJECT (view), "tooltip-window");
2997
3018
 
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);
3000
3021
                        }
3001
3022
 
3002
3023
                        return TRUE;
3010
3031
}
3011
3032
 
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)
3014
3037
{
3015
3038
        const gchar *my_summary, *location;
3016
3039
        const gchar *summary;
3037
3060
 
3038
3061
static void
3039
3062
e_week_view_reshape_event_span (EWeekView *week_view,
3040
 
                                gint event_num,
3041
 
                                gint span_num)
 
3063
                                gint event_num,
 
3064
                                gint span_num)
3042
3065
{
3043
3066
        EWeekViewEvent *event;
3044
3067
        EWeekViewEventSpan *span;
3074
3097
        one_day_event = e_week_view_is_one_day_event (week_view, event_num);
3075
3098
 
3076
3099
        /* If the span will not be visible destroy the canvas items and
3077
 
           return. */
 
3100
         * return. */
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);
3097
3120
 
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;
3178
3201
        }
3179
3202
 
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.
3186
3209
        */
3187
3210
 
3188
3211
        /* Calculate the space necessary to display a time, e.g. "13:00". */
3202
3225
 
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;
3209
3232
 
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;
3224
3247
                        break;
3225
3248
                case E_WEEK_VIEW_TIME_NONE:
3230
3253
                text_x += icons_width;
3231
3254
 
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;
3235
3258
 
3236
3259
        } else {
3237
3260
                if (use_max_width) {
3238
3261
                        /* When we are editing the event we use all the
3239
 
                           available width. */
 
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;
3246
3269
                } else {
3247
3270
                        text = NULL;
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
3250
 
                           tell us this. */
3251
 
                        g_object_get (G_OBJECT (span->text_item), "text", &text, NULL);
 
3272
                         * bit of a hack. It would be better if EText could
 
3273
                         * tell us this. */
 
3274
                        g_object_get (span->text_item, "text", &text, NULL);
3252
3275
                        text_width = 0;
3253
3276
                        if (text) {
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;
3265
3288
                        }
3266
3289
 
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;
3271
3294
 
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;
3282
3305
 
3283
3306
                        /* Now make sure we don't go to the left of the minimum
3284
 
                           position. */
 
3307
                         * position. */
3285
3308
                        text_x = MAX (text_x, min_text_x);
3286
3309
 
3287
3310
                        /* Now calculate the largest valid width, using the
3288
 
                           calculated x position, and make sure we don't
3289
 
                           exceed that. */
 
3311
                         * calculated x position, and make sure we don't
 
3312
                         * exceed that. */
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;
3319
3342
 
3320
3343
gboolean
3321
3344
e_week_view_start_editing_event (EWeekView *week_view,
3322
 
                                 gint       event_num,
3323
 
                                 gint       span_num,
3324
 
                                 gchar     *initial_text)
 
3345
                                 gint event_num,
 
3346
                                 gint span_num,
 
3347
                                 gchar *initial_text)
3325
3348
{
3326
3349
        EWeekViewEvent *event;
3327
3350
        EWeekViewEventSpan *span;
3403
3426
        span = &g_array_index (week_view->spans, EWeekViewEventSpan,  event->spans_index + span_num);
3404
3427
 
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 */
3460
3483
 
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);
3463
3486
 
3464
3487
        /* Stop editing */
3465
3488
        e_week_view_stop_editing_event (week_view);
3467
3490
 
3468
3491
static gboolean
3469
3492
e_week_view_on_text_item_event (GnomeCanvasItem *item,
3470
 
                                GdkEvent *gdkevent,
3471
 
                                EWeekView *week_view)
 
3493
                                GdkEvent *gdkevent,
 
3494
                                EWeekView *week_view)
3472
3495
{
3473
3496
        EWeekViewEvent *event;
3474
3497
        gint event_num, span_num;
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));
3491
3514
 
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");
3495
3518
                        return TRUE;
3496
3519
                } else if (gdkevent->key.keyval == GDK_KEY_Escape) {
3516
3539
                        return FALSE;
3517
3540
 
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))
3521
3544
                        return TRUE;
3522
3545
 
3552
3575
                        e_week_view_set_selected_time_range_visible (week_view, e->start, e->end);
3553
3576
 
3554
3577
                        e_week_view_show_popup_menu (week_view,
3555
 
                                                     (GdkEventButton*) gdkevent,
 
3578
                                                     (GdkEventButton *) gdkevent,
3556
3579
                                                     event_num);
3557
3580
 
3558
3581
                        g_signal_stop_emission_by_name (G_OBJECT (item->canvas),
3576
3599
                                g_warning ("No GdkEvent");
3577
3600
 
3578
3601
                        /* FIXME: Remember the day offset from the start of
3579
 
                           the event, for DnD. */
 
3602
                         * the event, for DnD. */
3580
3603
 
3581
3604
                        return TRUE;
3582
3605
                }
3601
3624
                        }
3602
3625
 
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");
3606
3629
                        return TRUE;
3607
3630
                }
3648
3671
                pevent->tooltip = (GtkWidget *)g_object_get_data (G_OBJECT (week_view), "tooltip-window");
3649
3672
 
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);
3652
3675
                }
3653
3676
                return TRUE;
3654
3677
        case GDK_FOCUS_CHANGE:
3746
3769
}
3747
3770
 
3748
3771
static gint
3749
 
e_week_view_get_day_offset_of_event (EWeekView *week_view, time_t event_time)
 
3772
e_week_view_get_day_offset_of_event (EWeekView *week_view,
 
3773
                                     time_t event_time)
3750
3774
{
3751
3775
        time_t first_day = week_view->day_starts[0];
3752
3776
 
3757
3781
}
3758
3782
 
3759
3783
void
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)
3761
3786
{
3762
3787
        GtkAdjustment *adjustment;
3763
3788
        GtkRange *range;
3799
3824
}
3800
3825
 
3801
3826
static void
3802
 
e_week_view_change_event_time (EWeekView *week_view, time_t start_dt, time_t end_dt, gboolean is_all_day)
 
3827
e_week_view_change_event_time (EWeekView *week_view,
 
3828
                               time_t start_dt,
 
3829
                               time_t end_dt,
 
3830
                               gboolean is_all_day)
3803
3831
{
3804
3832
        EWeekViewEvent *event;
3805
3833
        gint event_num;
3827
3855
        client = event->comp_data->client;
3828
3856
 
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
3836
 
           and end times. */
 
3864
         * and end times. */
3837
3865
        date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)));
3838
3866
 
3839
3867
        *date.value = icaltime_from_timet_with_zone (start_dt, is_all_day,
3881
3909
 
3882
3910
static void
3883
3911
e_week_view_on_editing_started (EWeekView *week_view,
3884
 
                                GnomeCanvasItem *item)
 
3912
                                GnomeCanvasItem *item)
3885
3913
{
3886
3914
        gint event_num, span_num;
3887
3915
 
3897
3925
        week_view->editing_span_num = span_num;
3898
3926
 
3899
3927
        /* We need to reshape long events so the whole width is used while
3900
 
           editing. */
 
3928
         * editing. */
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,
3903
3931
                                                span_num);
3908
3936
 
3909
3937
static void
3910
3938
e_week_view_on_editing_stopped (EWeekView *week_view,
3911
 
                                GnomeCanvasItem *item)
 
3939
                                GnomeCanvasItem *item)
3912
3940
{
3913
3941
        gint event_num, span_num;
3914
3942
        EWeekViewEvent *event;
3921
3949
        gboolean on_server;
3922
3950
 
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;
3928
3956
 
3954
3982
 
3955
3983
        text = NULL;
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);
3958
3986
 
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;
3981
4009
 
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);
3984
4012
 
3985
4013
                if (free_text)
3986
4014
                        g_free ((gchar *) summary);
4097
4125
}
4098
4126
 
4099
4127
gboolean
4100
 
e_week_view_find_event_from_item (EWeekView       *week_view,
4101
 
                                  GnomeCanvasItem *item,
4102
 
                                  gint            *event_num_return,
4103
 
                                  gint            *span_num_return)
 
4128
e_week_view_find_event_from_item (EWeekView *week_view,
 
4129
                                  GnomeCanvasItem *item,
 
4130
                                  gint *event_num_return,
 
4131
                                  gint *span_num_return)
4104
4132
{
4105
4133
        EWeekViewEvent *event;
4106
4134
        EWeekViewEventSpan *span;
4129
4157
}
4130
4158
 
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,
4139
 
                                 ECalClient       *client,
4140
 
                                 const gchar      *uid,
4141
 
                                 const gchar      *rid,
4142
 
                                 gint             *event_num_return)
 
4166
e_week_view_find_event_from_uid (EWeekView *week_view,
 
4167
                                 ECalClient *client,
 
4168
                                 const gchar *uid,
 
4169
                                 const gchar *rid,
 
4170
                                 gint *event_num_return)
4143
4171
{
4144
4172
        EWeekViewEvent *event;
4145
4173
        gint event_num, num_events;
4184
4212
}
4185
4213
 
4186
4214
gboolean
4187
 
e_week_view_is_one_day_event    (EWeekView      *week_view,
4188
 
                                 gint            event_num)
 
4215
e_week_view_is_one_day_event (EWeekView *week_view,
 
4216
                              gint event_num)
4189
4217
{
4190
4218
        EWeekViewEvent *event;
4191
4219
        EWeekViewEventSpan *span;
4260
4288
}
4261
4289
 
4262
4290
static gboolean
4263
 
e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar *initial_text)
 
4291
e_week_view_add_new_event_in_selected_range (EWeekView *week_view,
 
4292
                                             const gchar *initial_text)
4264
4293
{
4265
4294
        ECalClient *client;
4266
4295
        ECalModel *model;
4314
4343
                comp, e_calendar_view_get_default_category (E_CALENDAR_VIEW (week_view)));
4315
4344
 
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);
4356
4385
}
4357
4386
 
4358
4387
static gboolean
4359
 
e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
 
4388
e_week_view_do_key_press (GtkWidget *widget,
 
4389
                          GdkEventKey *event)
4360
4390
{
4361
4391
        EWeekView *week_view;
4362
4392
        gchar *initial_text;
4437
4467
                return FALSE;
4438
4468
 
4439
4469
        /* We only want to start an edit with a return key or a simple
4440
 
           character. */
 
4470
         * character. */
4441
4471
        if (event->keyval == GDK_KEY_Return) {
4442
4472
                initial_text = NULL;
4443
4473
        } else if (((event->keyval >= 0x20) && (event->keyval <= 0xFF)
4457
4487
}
4458
4488
 
4459
4489
static gint
4460
 
e_week_view_get_adjust_days_for_move_up (EWeekView *week_view,gint current_day)
 
4490
e_week_view_get_adjust_days_for_move_up (EWeekView *week_view,
 
4491
                                         gint current_day)
4461
4492
{
4462
4493
       if (week_view->multi_week_view)
4463
4494
               return -7;
4466
4497
}
4467
4498
 
4468
4499
static gint
4469
 
e_week_view_get_adjust_days_for_move_down (EWeekView *week_view,gint current_day)
 
4500
e_week_view_get_adjust_days_for_move_down (EWeekView *week_view,
 
4501
                                           gint current_day)
4470
4502
{
4471
4503
       if (week_view->multi_week_view)
4472
4504
               return 7;
4475
4507
}
4476
4508
 
4477
4509
static gint
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,
 
4511
                                           gint current_day)
4479
4512
{
4480
4513
        return -1;
4481
4514
}
4482
4515
 
4483
4516
static gint
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,
 
4518
                                            gint current_day)
4485
4519
{
4486
4520
        return 1;
4487
4521
}
4488
4522
 
4489
4523
static gboolean
4490
 
e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
 
4524
e_week_view_key_press (GtkWidget *widget,
 
4525
                       GdkEventKey *event)
4491
4526
{
4492
4527
        gboolean handled = FALSE;
4493
4528
        handled = e_week_view_do_key_press (widget, event);
4499
4534
}
4500
4535
 
4501
4536
void
4502
 
e_week_view_show_popup_menu (EWeekView       *week_view,
4503
 
                             GdkEventButton  *bevent,
4504
 
                             gint             event_num)
 
4537
e_week_view_show_popup_menu (EWeekView *week_view,
 
4538
                             GdkEventButton *bevent,
 
4539
                             gint event_num)
4505
4540
{
4506
4541
        week_view->popup_event_num = event_num;
4507
4542
 
4518
4553
}
4519
4554
 
4520
4555
void
4521
 
e_week_view_jump_to_button_item (EWeekView *week_view, GnomeCanvasItem *item)
 
4556
e_week_view_jump_to_button_item (EWeekView *week_view,
 
4557
                                 GnomeCanvasItem *item)
4522
4558
{
4523
4559
        gint day;
4524
4560
        GnomeCalendar *calendar;
4539
4575
 
4540
4576
static gboolean
4541
4577
e_week_view_on_jump_button_event (GnomeCanvasItem *item,
4542
 
                                  GdkEvent *event,
4543
 
                                  EWeekView *week_view)
 
4578
                                  GdkEvent *event,
 
4579
                                  EWeekView *week_view)
4544
4580
{
4545
4581
        gint day;
4546
4582
 
4594
4630
}
4595
4631
 
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. */
4598
4634
void
4599
 
e_week_view_convert_time_to_display     (EWeekView      *week_view,
4600
 
                                         gint            hour,
4601
 
                                         gint           *display_hour,
4602
 
                                         const gchar    **suffix,
4603
 
                                         gint           *suffix_width)
 
4635
e_week_view_convert_time_to_display (EWeekView *week_view,
 
4636
                                     gint hour,
 
4637
                                     gint *display_hour,
 
4638
                                     const gchar **suffix,
 
4639
                                     gint *suffix_width)
4604
4640
{
4605
4641
        ECalModel *model;
4606
4642
 
4607
4643
        model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
4608
4644
 
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)) {
4613
4649
                *suffix = "";
4629
4665
}
4630
4666
 
4631
4667
gint
4632
 
e_week_view_get_time_string_width       (EWeekView      *week_view)
 
4668
e_week_view_get_time_string_width (EWeekView *week_view)
4633
4669
{
4634
4670
        ECalModel *model;
4635
4671
        gint time_width;
4691
4727
}
4692
4728
 
4693
4729
gboolean
4694
 
e_week_view_is_jump_button_visible (EWeekView *week_view, gint day)
 
4730
e_week_view_is_jump_button_visible (EWeekView *week_view,
 
4731
                                    gint day)
4695
4732
{
4696
4733
        g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE);
4697
4734