4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
21 #include "evolution-config.h"
23 #include "e-month-view.h"
25 #define E_MONTH_VIEW_GET_PRIVATE(obj) \
26 (G_TYPE_INSTANCE_GET_PRIVATE \
27 ((obj), E_TYPE_MONTH_VIEW, EMonthViewPrivate))
29 struct _EMonthViewPrivate
{
33 G_DEFINE_TYPE (EMonthView
, e_month_view
, E_TYPE_WEEK_VIEW
)
36 month_view_cursor_key_up (EWeekView
*week_view
)
38 if (week_view
->selection_start_day
== -1)
41 if (week_view
->selection_start_day
< 7) {
42 /* No easy way to calculate new selection_start_day, so
43 * calculate a time_t value and set_selected_time_range. */
46 if (e_calendar_view_get_selected_time_range (
47 E_CALENDAR_VIEW (week_view
), ¤t
, NULL
)) {
49 current
= time_add_week (current
, -1);
50 e_week_view_scroll_a_step (
51 week_view
, E_CAL_VIEW_MOVE_PAGE_UP
);
52 e_week_view_set_selected_time_range_visible (
53 week_view
, current
, current
);
56 week_view
->selection_start_day
-= 7;
57 week_view
->selection_end_day
= week_view
->selection_start_day
;
60 g_signal_emit_by_name (week_view
, "selected-time-changed");
61 gtk_widget_queue_draw (week_view
->main_canvas
);
65 month_view_cursor_key_down (EWeekView
*week_view
)
69 if (week_view
->selection_start_day
== -1)
72 weeks_shown
= e_week_view_get_weeks_shown (week_view
);
74 if (week_view
->selection_start_day
>= (weeks_shown
- 1) * 7) {
75 /* No easy way to calculate new selection_start_day, so
76 * calculate a time_t value and set_selected_time_range. */
79 if (e_calendar_view_get_selected_time_range (
80 E_CALENDAR_VIEW (week_view
), ¤t
, NULL
)) {
82 current
= time_add_week (current
, 1);
83 e_week_view_scroll_a_step (
84 week_view
, E_CAL_VIEW_MOVE_PAGE_DOWN
);
85 e_week_view_set_selected_time_range_visible (
86 week_view
, current
, current
);
89 week_view
->selection_start_day
+= 7;
90 week_view
->selection_end_day
= week_view
->selection_start_day
;
93 g_signal_emit_by_name (week_view
, "selected-time-changed");
94 gtk_widget_queue_draw (week_view
->main_canvas
);
98 month_view_cursor_key_left (EWeekView
*week_view
)
100 if (week_view
->selection_start_day
== -1)
103 if (week_view
->selection_start_day
== 0) {
104 /* No easy way to calculate new selection_start_day, so
105 * calculate a time_t value and set_selected_time_range. */
108 if (e_calendar_view_get_selected_time_range (
109 E_CALENDAR_VIEW (week_view
), ¤t
, NULL
)) {
111 current
= time_add_day (current
, -1);
112 e_week_view_scroll_a_step (
113 week_view
, E_CAL_VIEW_MOVE_PAGE_UP
);
114 e_week_view_set_selected_time_range_visible (
115 week_view
, current
, current
);
118 week_view
->selection_start_day
--;
119 week_view
->selection_end_day
= week_view
->selection_start_day
;
122 g_signal_emit_by_name (week_view
, "selected-time-changed");
123 gtk_widget_queue_draw (week_view
->main_canvas
);
127 month_view_cursor_key_right (EWeekView
*week_view
)
131 if (week_view
->selection_start_day
== -1)
134 weeks_shown
= e_week_view_get_weeks_shown (week_view
);
136 if (week_view
->selection_start_day
== weeks_shown
* 7 - 1) {
137 /* No easy way to calculate new selection_start_day, so
138 * calculate a time_t value and set_selected_time_range. */
141 if (e_calendar_view_get_selected_time_range (
142 E_CALENDAR_VIEW (week_view
), ¤t
, NULL
)) {
144 current
= time_add_day (current
, 1);
145 e_week_view_scroll_a_step (
146 week_view
, E_CAL_VIEW_MOVE_PAGE_DOWN
);
147 e_week_view_set_selected_time_range_visible (
148 week_view
, current
, current
);
151 week_view
->selection_start_day
++;
152 week_view
->selection_end_day
= week_view
->selection_start_day
;
155 g_signal_emit_by_name (week_view
, "selected-time-changed");
156 gtk_widget_queue_draw (week_view
->main_canvas
);
160 e_month_view_class_init (EMonthViewClass
*class)
162 EWeekViewClass
*week_view_class
;
164 g_type_class_add_private (class, sizeof (EMonthViewPrivate
));
166 week_view_class
= E_WEEK_VIEW_CLASS (class);
167 week_view_class
->cursor_key_up
= month_view_cursor_key_up
;
168 week_view_class
->cursor_key_down
= month_view_cursor_key_down
;
169 week_view_class
->cursor_key_left
= month_view_cursor_key_left
;
170 week_view_class
->cursor_key_right
= month_view_cursor_key_right
;
174 e_month_view_init (EMonthView
*month_view
)
176 month_view
->priv
= E_MONTH_VIEW_GET_PRIVATE (month_view
);
180 e_month_view_new (ECalModel
*model
)
182 g_return_val_if_fail (E_IS_CAL_MODEL (model
), NULL
);
184 return g_object_new (E_TYPE_MONTH_VIEW
, "model", model
, NULL
);