No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-month-view.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-month-view.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-month-view.c
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with the program; if not, see <http://www.gnu.org/licenses/>
16 *
17 *
18 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
19 *
20 */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include "e-month-view.h"
27
28 #define E_MONTH_VIEW_GET_PRIVATE(obj) \
29 (G_TYPE_INSTANCE_GET_PRIVATE \
30 ((obj), E_TYPE_MONTH_VIEW, EMonthViewPrivate))
31
32 struct _EMonthViewPrivate {
33 gint placeholder;
34 };
35
36 G_DEFINE_TYPE (EMonthView, e_month_view, E_TYPE_WEEK_VIEW)
37
38 static void
39 month_view_cursor_key_up (EWeekView *week_view)
40 {
41 if (week_view->selection_start_day == -1)
42 return;
43
44 if (week_view->selection_start_day < 7) {
45 /* No easy way to calculate new selection_start_day, so
46 * calculate a time_t value and set_selected_time_range. */
47 time_t current;
48
49 if (e_calendar_view_get_selected_time_range (
50 E_CALENDAR_VIEW (week_view), ¤t, NULL)) {
51
52 current = time_add_week (current, -1);
53 e_week_view_scroll_a_step (
54 week_view, E_CAL_VIEW_MOVE_PAGE_UP);
55 e_week_view_set_selected_time_range_visible (
56 week_view, current, current);
57 }
58 } else {
59 week_view->selection_start_day -= 7;
60 week_view->selection_end_day = week_view->selection_start_day;
61 }
62
63 g_signal_emit_by_name (week_view, "selected-time-changed");
64 gtk_widget_queue_draw (week_view->main_canvas);
65 }
66
67 static void
68 month_view_cursor_key_down (EWeekView *week_view)
69 {
70 gint weeks_shown;
71
72 if (week_view->selection_start_day == -1)
73 return;
74
75 weeks_shown = e_week_view_get_weeks_shown (week_view);
76
77 if (week_view->selection_start_day >= (weeks_shown - 1) * 7) {
78 /* No easy way to calculate new selection_start_day, so
79 * calculate a time_t value and set_selected_time_range. */
80 time_t current;
81
82 if (e_calendar_view_get_selected_time_range (
83 E_CALENDAR_VIEW (week_view), ¤t, NULL)) {
84
85 current = time_add_week (current, -1);
86 e_week_view_scroll_a_step (
87 week_view, E_CAL_VIEW_MOVE_PAGE_DOWN);
88 e_week_view_set_selected_time_range_visible (
89 week_view, current, current);
90 }
91 } else {
92 week_view->selection_start_day += 7;
93 week_view->selection_end_day = week_view->selection_start_day;
94 }
95
96 g_signal_emit_by_name (week_view, "selected-time-changed");
97 gtk_widget_queue_draw (week_view->main_canvas);
98 }
99
100 static void
101 month_view_cursor_key_left (EWeekView *week_view)
102 {
103 if (week_view->selection_start_day == -1)
104 return;
105
106 if (week_view->selection_start_day == 0) {
107 /* No easy way to calculate new selection_start_day, so
108 * calculate a time_t value and set_selected_time_range. */
109 time_t current;
110
111 if (e_calendar_view_get_selected_time_range (
112 E_CALENDAR_VIEW (week_view), ¤t, NULL)) {
113
114 current = time_add_day (current, -1);
115 e_week_view_scroll_a_step (
116 week_view, E_CAL_VIEW_MOVE_PAGE_UP);
117 e_week_view_set_selected_time_range_visible (
118 week_view, current, current);
119 }
120 } else {
121 week_view->selection_start_day--;
122 week_view->selection_end_day = week_view->selection_start_day;
123 }
124
125 g_signal_emit_by_name (week_view, "selected-time-changed");
126 gtk_widget_queue_draw (week_view->main_canvas);
127 }
128
129 static void
130 month_view_cursor_key_right (EWeekView *week_view)
131 {
132 gint weeks_shown;
133
134 if (week_view->selection_start_day == -1)
135 return;
136
137 weeks_shown = e_week_view_get_weeks_shown (week_view);
138
139 if (week_view->selection_start_day == weeks_shown * 7 - 1) {
140 /* No easy way to calculate new selection_start_day, so
141 * calculate a time_t value and set_selected_time_range. */
142 time_t current;
143
144 if (e_calendar_view_get_selected_time_range (
145 E_CALENDAR_VIEW (week_view), ¤t, NULL)) {
146
147 current = time_add_day (current, 1);
148 e_week_view_scroll_a_step (
149 week_view, E_CAL_VIEW_MOVE_PAGE_DOWN);
150 e_week_view_set_selected_time_range_visible (
151 week_view, current, current);
152 }
153 } else {
154 week_view->selection_start_day++;
155 week_view->selection_end_day = week_view->selection_start_day;
156 }
157
158 g_signal_emit_by_name (week_view, "selected-time-changed");
159 gtk_widget_queue_draw (week_view->main_canvas);
160 }
161
162 static void
163 e_month_view_class_init (EMonthViewClass *class)
164 {
165 EWeekViewClass *week_view_class;
166
167 g_type_class_add_private (class, sizeof (EMonthViewPrivate));
168
169 week_view_class = E_WEEK_VIEW_CLASS (class);
170 week_view_class->cursor_key_up = month_view_cursor_key_up;
171 week_view_class->cursor_key_down = month_view_cursor_key_down;
172 week_view_class->cursor_key_left = month_view_cursor_key_left;
173 week_view_class->cursor_key_right = month_view_cursor_key_right;
174 }
175
176 static void
177 e_month_view_init (EMonthView *month_view)
178 {
179 month_view->priv = E_MONTH_VIEW_GET_PRIVATE (month_view);
180 }
181
182 ECalendarView *
183 e_month_view_new (ECalModel *model)
184 {
185 g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
186
187 return g_object_new (E_TYPE_MONTH_VIEW, "model", model, NULL);
188 }