diff options
Diffstat (limited to 'meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcalendar.c.diff')
-rw-r--r-- | meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcalendar.c.diff | 2464 |
1 files changed, 2464 insertions, 0 deletions
diff --git a/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcalendar.c.diff b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcalendar.c.diff new file mode 100644 index 0000000000..e32c05452d --- /dev/null +++ b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcalendar.c.diff | |||
@@ -0,0 +1,2464 @@ | |||
1 | --- gtk+-2.6.4/gtk/gtkcalendar.c 2004-11-12 19:51:58.000000000 +0200 | ||
2 | +++ gtk+-2.6.4/gtk/gtkcalendar.c 2005-04-06 16:19:36.267024936 +0300 | ||
3 | @@ -169,14 +169,23 @@ | ||
4 | |||
5 | /*** END OF lib_date routines ********************************************/ | ||
6 | |||
7 | +/* HILDON: Spacings modified */ | ||
8 | + | ||
9 | +#define HILDON_ARROW_WIDTH 20 | ||
10 | +#define HILDON_ARROW_HEIGHT 27 | ||
11 | +#define HILDON_ARROW_SEP 5 /* Space between arrows and data */ | ||
12 | + | ||
13 | +#define HILDON_DAY_WIDTH 26 | ||
14 | +#define HILDON_DAY_HEIGHT 25 | ||
15 | + | ||
16 | /* Spacing around day/week headers and main area, inside those windows */ | ||
17 | #define CALENDAR_MARGIN 0 | ||
18 | /* Spacing around day/week headers and main area, outside those windows */ | ||
19 | -#define INNER_BORDER 4 | ||
20 | +#define INNER_BORDER 0 /* 4 */ | ||
21 | /* Separation between day headers and main area */ | ||
22 | -#define CALENDAR_YSEP 4 | ||
23 | +#define CALENDAR_YSEP 3 /* 4 */ | ||
24 | /* Separation between week headers and main area */ | ||
25 | -#define CALENDAR_XSEP 4 | ||
26 | +#define CALENDAR_XSEP 6 /* 4 */ | ||
27 | |||
28 | #define DAY_XSEP 0 /* not really good for small calendar */ | ||
29 | #define DAY_YSEP 0 /* not really good for small calendar */ | ||
30 | @@ -193,6 +202,10 @@ | ||
31 | #define BACKGROUND_COLOR(widget) (& (widget)->style->base[GTK_WIDGET_STATE (widget)]) | ||
32 | #define HIGHLIGHT_BACK_COLOR(widget) (& (widget)->style->mid[GTK_WIDGET_STATE (widget)]) | ||
33 | |||
34 | +/* Default Min/Max years for hildon calendar */ | ||
35 | +#define HILDON_MIN_YEAR 0 | ||
36 | +#define HILDON_MAX_YEAR 2999 | ||
37 | + | ||
38 | enum { | ||
39 | ARROW_YEAR_LEFT, | ||
40 | ARROW_YEAR_RIGHT, | ||
41 | @@ -214,6 +227,8 @@ | ||
42 | NEXT_MONTH_SIGNAL, | ||
43 | PREV_YEAR_SIGNAL, | ||
44 | NEXT_YEAR_SIGNAL, | ||
45 | + ERRONEOUS_DATE_SIGNAL, | ||
46 | + SELECTED_DATE_SIGNAL, | ||
47 | LAST_SIGNAL | ||
48 | }; | ||
49 | |||
50 | @@ -238,16 +253,19 @@ | ||
51 | struct _GtkCalendarPrivateData | ||
52 | { | ||
53 | GdkWindow *header_win; | ||
54 | + GdkWindow *footer_win; /* HILDON: Added below calendar */ | ||
55 | GdkWindow *day_name_win; | ||
56 | GdkWindow *main_win; | ||
57 | GdkWindow *week_win; | ||
58 | GdkWindow *arrow_win[4]; | ||
59 | |||
60 | + gint year_before; | ||
61 | guint header_h; | ||
62 | guint day_name_h; | ||
63 | guint main_h; | ||
64 | |||
65 | guint arrow_state[4]; | ||
66 | + /* guint arrow_width; This is now defined constant. Even normal Gtk don't allow to change this */ | ||
67 | guint arrow_width; | ||
68 | guint max_month_width; | ||
69 | guint max_year_width; | ||
70 | @@ -271,7 +289,7 @@ | ||
71 | guint dirty_main : 1; | ||
72 | guint dirty_week : 1; | ||
73 | |||
74 | - guint year_before : 1; | ||
75 | +/* guint year_before : 1;*/ | ||
76 | |||
77 | guint need_timer : 1; | ||
78 | |||
79 | @@ -281,6 +299,27 @@ | ||
80 | guint32 timer; | ||
81 | gint click_child; | ||
82 | |||
83 | + /* Following variables are for current date */ | ||
84 | + guint current_day; | ||
85 | + guint current_month; | ||
86 | + guint current_year; | ||
87 | + | ||
88 | + /* Keep track of day and month | ||
89 | + * where mouse button was pressed | ||
90 | + */ | ||
91 | + guint pressed_day; | ||
92 | + guint pressed_month; | ||
93 | + | ||
94 | + /* Boolean value to indicate if | ||
95 | + * out of bound day was selected | ||
96 | + */ | ||
97 | + gboolean is_bad_day; | ||
98 | + | ||
99 | + /* Must check if we are sliding stylus */ | ||
100 | + gboolean slide_stylus; | ||
101 | + gint prev_row; | ||
102 | + gint prev_col; | ||
103 | + | ||
104 | gint week_start; | ||
105 | |||
106 | gint drag_start_x; | ||
107 | @@ -336,6 +375,8 @@ | ||
108 | static void gtk_calendar_style_set (GtkWidget *widget, | ||
109 | GtkStyle *previous_style); | ||
110 | static void gtk_calendar_paint_header (GtkWidget *widget); | ||
111 | +static void gtk_calendar_paint_footer (GtkWidget *widget); | ||
112 | + | ||
113 | static void gtk_calendar_paint_day_names (GtkWidget *widget); | ||
114 | static void gtk_calendar_paint_week_numbers (GtkWidget *widget); | ||
115 | static void gtk_calendar_paint_main (GtkWidget *widget); | ||
116 | @@ -381,7 +422,13 @@ | ||
117 | gint x, | ||
118 | gint y, | ||
119 | guint time); | ||
120 | - | ||
121 | + | ||
122 | +/* This function was added because we need to mark current day according to | ||
123 | + * specifications | ||
124 | + */ | ||
125 | +static void | ||
126 | +gtk_calendar_check_current_date (GtkCalendar *calendar, gint x, gint y); | ||
127 | + | ||
128 | static char *default_abbreviated_dayname[7]; | ||
129 | static char *default_monthname[12]; | ||
130 | |||
131 | @@ -461,6 +508,8 @@ | ||
132 | class->next_month = NULL; | ||
133 | class->prev_year = NULL; | ||
134 | class->next_year = NULL; | ||
135 | + class->erroneous_date = NULL; | ||
136 | + class->selected_date = NULL; | ||
137 | |||
138 | g_object_class_install_property (gobject_class, | ||
139 | PROP_YEAR, | ||
140 | @@ -543,6 +592,31 @@ | ||
141 | FALSE, | ||
142 | G_PARAM_READWRITE)); | ||
143 | |||
144 | + gtk_widget_class_install_style_property (widget_class, | ||
145 | + g_param_spec_int ("min-year", | ||
146 | + P_("Minimum year for calendar"), | ||
147 | + P_("Set minimum year calendar accepts"), | ||
148 | + 0, | ||
149 | + G_MAXINT, | ||
150 | + HILDON_MIN_YEAR, | ||
151 | + G_PARAM_READWRITE)); | ||
152 | + | ||
153 | + gtk_widget_class_install_style_property (widget_class, | ||
154 | + g_param_spec_int ("max-year", | ||
155 | + P_("Maximum year for calendar"), | ||
156 | + P_("Set max year that calendar accepts"), | ||
157 | + 0, | ||
158 | + G_MAXINT, | ||
159 | + HILDON_MAX_YEAR, | ||
160 | + G_PARAM_READWRITE)); | ||
161 | + | ||
162 | + gtk_widget_class_install_style_property (widget_class, | ||
163 | + g_param_spec_boolean ("hildonlike", | ||
164 | + _("Size request"), | ||
165 | + _("Size allocate"), | ||
166 | + FALSE, | ||
167 | + G_PARAM_READABLE)); | ||
168 | + | ||
169 | gtk_calendar_signals[MONTH_CHANGED_SIGNAL] = | ||
170 | g_signal_new ("month_changed", | ||
171 | G_OBJECT_CLASS_TYPE (gobject_class), | ||
172 | @@ -599,6 +673,22 @@ | ||
173 | NULL, NULL, | ||
174 | _gtk_marshal_VOID__VOID, | ||
175 | G_TYPE_NONE, 0); | ||
176 | + gtk_calendar_signals[ERRONEOUS_DATE_SIGNAL] = | ||
177 | + g_signal_new ("erroneous_date", | ||
178 | + G_OBJECT_CLASS_TYPE(gobject_class), | ||
179 | + G_SIGNAL_RUN_FIRST, | ||
180 | + G_STRUCT_OFFSET (GtkCalendarClass, erroneous_date), | ||
181 | + NULL, NULL, | ||
182 | + _gtk_marshal_VOID__VOID, | ||
183 | + G_TYPE_NONE, 0); | ||
184 | + gtk_calendar_signals[SELECTED_DATE_SIGNAL] = | ||
185 | + g_signal_new ("selected_date", | ||
186 | + G_OBJECT_CLASS_TYPE(gobject_class), | ||
187 | + G_SIGNAL_RUN_FIRST, | ||
188 | + G_STRUCT_OFFSET (GtkCalendarClass, selected_date), | ||
189 | + NULL, NULL, | ||
190 | + _gtk_marshal_VOID__VOID, | ||
191 | + G_TYPE_NONE, 0); | ||
192 | } | ||
193 | |||
194 | static void | ||
195 | @@ -611,8 +701,10 @@ | ||
196 | time_t tmp_time; | ||
197 | GtkWidget *widget; | ||
198 | GtkCalendarPrivateData *private_data; | ||
199 | - gchar *year_before; | ||
200 | +/* gchar *year_before;*/ | ||
201 | gchar *week_start; | ||
202 | +/* gint row; | ||
203 | + gint col; */ | ||
204 | |||
205 | widget = GTK_WIDGET (calendar); | ||
206 | GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); | ||
207 | @@ -645,16 +737,29 @@ | ||
208 | for (i=0;i<31;i++) | ||
209 | calendar->marked_date[i] = FALSE; | ||
210 | calendar->num_marked_dates = 0; | ||
211 | - calendar->selected_day = tm->tm_mday; | ||
212 | - | ||
213 | + calendar->selected_day = tm->tm_mday; | ||
214 | + | ||
215 | calendar->display_flags = ( GTK_CALENDAR_SHOW_HEADING | | ||
216 | GTK_CALENDAR_SHOW_DAY_NAMES ); | ||
217 | |||
218 | + /* Hildon: we should mark current day and we need to store current date */ | ||
219 | + private_data->current_day = tm->tm_mday; | ||
220 | + private_data->current_month = tm->tm_mon; | ||
221 | + private_data->current_year = tm->tm_year + 1900; | ||
222 | + | ||
223 | + /* Hildon: following lines are for stylus sliding */ | ||
224 | + private_data->slide_stylus = FALSE; | ||
225 | + private_data->prev_row = -1; | ||
226 | + private_data->prev_col = -1; | ||
227 | + | ||
228 | + /* Hildon: is_bad_day indicate if day was selected out of legal range */ | ||
229 | + private_data->is_bad_day = FALSE; | ||
230 | + | ||
231 | calendar->highlight_row = -1; | ||
232 | - calendar->highlight_col = -1; | ||
233 | + calendar->highlight_col = -1; | ||
234 | |||
235 | calendar->focus_row = -1; | ||
236 | - calendar->focus_col = -1; | ||
237 | + calendar->focus_col = -1; | ||
238 | calendar->xor_gc = NULL; | ||
239 | |||
240 | private_data->max_year_width = 0; | ||
241 | @@ -667,7 +772,7 @@ | ||
242 | private_data->max_label_char_ascent = 0; | ||
243 | private_data->max_label_char_descent = 0; | ||
244 | |||
245 | - private_data->arrow_width = 10; | ||
246 | +/* private_data->arrow_width = 10;*/ | ||
247 | |||
248 | private_data->freeze_count = 0; | ||
249 | |||
250 | @@ -686,6 +791,7 @@ | ||
251 | gtk_drag_dest_set (widget, 0, NULL, 0, GDK_ACTION_COPY); | ||
252 | gtk_drag_dest_add_text_targets (widget); | ||
253 | |||
254 | +#if 0 | ||
255 | private_data->year_before = 0; | ||
256 | |||
257 | /* Translate to calendar:YM if you want years to be displayed | ||
258 | @@ -702,11 +808,13 @@ | ||
259 | private_data->year_before = 1; | ||
260 | else if (strcmp (year_before, "calendar:MY") != 0) | ||
261 | g_warning ("Whoever translated calendar:MY did so wrongly.\n"); | ||
262 | +#endif | ||
263 | |||
264 | /* Translate to calendar:week_start:0 if you want Sunday to be the | ||
265 | * first day of the week to calendar:week_start:1 if you want Monday | ||
266 | * to be the first day of the week, and so on. | ||
267 | */ | ||
268 | + | ||
269 | week_start = _("calendar:week_start:0"); | ||
270 | |||
271 | if (strncmp (week_start, "calendar:week_start:", 20) == 0) | ||
272 | @@ -752,7 +860,7 @@ | ||
273 | |||
274 | return column; | ||
275 | } | ||
276 | - | ||
277 | +#if 0 | ||
278 | static gint | ||
279 | row_height (GtkCalendar *calendar) | ||
280 | { | ||
281 | @@ -760,7 +868,7 @@ | ||
282 | - ((calendar->display_flags & GTK_CALENDAR_SHOW_DAY_NAMES) | ||
283 | ? CALENDAR_YSEP : CALENDAR_MARGIN)) / 6; | ||
284 | } | ||
285 | - | ||
286 | +#endif | ||
287 | |||
288 | /* row_from_y: returns the row 0-5 that the | ||
289 | * y pixel of the xwindow is in */ | ||
290 | @@ -769,16 +877,15 @@ | ||
291 | gint event_y) | ||
292 | { | ||
293 | gint r, row; | ||
294 | - gint height; | ||
295 | + /*gint height;*/ | ||
296 | gint y_top, y_bottom; | ||
297 | |||
298 | - height = row_height (calendar); | ||
299 | row = -1; | ||
300 | |||
301 | for (r = 0; r < 6; r++) | ||
302 | { | ||
303 | y_top = top_y_for_row (calendar, r); | ||
304 | - y_bottom = y_top + height; | ||
305 | + y_bottom = y_top + HILDON_DAY_HEIGHT /*height*/; | ||
306 | |||
307 | if (event_y >= y_top && event_y < y_bottom) | ||
308 | { | ||
309 | @@ -796,16 +903,16 @@ | ||
310 | { | ||
311 | gint width; | ||
312 | gint x_left; | ||
313 | - | ||
314 | + | ||
315 | if (gtk_widget_get_direction (GTK_WIDGET (calendar)) == GTK_TEXT_DIR_RTL) | ||
316 | column = 6 - column; | ||
317 | - | ||
318 | + | ||
319 | width = GTK_CALENDAR_PRIVATE_DATA (calendar)->day_width; | ||
320 | if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS) | ||
321 | x_left = CALENDAR_XSEP + (width + DAY_XSEP) * column; | ||
322 | else | ||
323 | x_left = CALENDAR_MARGIN + (width + DAY_XSEP) * column; | ||
324 | - | ||
325 | + | ||
326 | return x_left; | ||
327 | } | ||
328 | |||
329 | @@ -818,25 +925,41 @@ | ||
330 | |||
331 | return (GTK_CALENDAR_PRIVATE_DATA (calendar)->main_h | ||
332 | - (CALENDAR_MARGIN + (6 - row) | ||
333 | - * row_height (calendar))); | ||
334 | + * HILDON_DAY_HEIGHT)); | ||
335 | } | ||
336 | |||
337 | static void | ||
338 | gtk_calendar_set_month_prev (GtkCalendar *calendar) | ||
339 | { | ||
340 | gint month_len; | ||
341 | - | ||
342 | + gint min_year; | ||
343 | + gboolean hildonlike; | ||
344 | + | ||
345 | + gtk_widget_style_get (GTK_WIDGET (calendar), "hildonlike", &hildonlike, | ||
346 | + "min-year", &min_year, NULL); | ||
347 | + | ||
348 | if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE) | ||
349 | return; | ||
350 | |||
351 | if (calendar->month == 0) | ||
352 | - { | ||
353 | - calendar->month = 11; | ||
354 | - calendar->year--; | ||
355 | - } | ||
356 | - else | ||
357 | - calendar->month--; | ||
358 | - | ||
359 | + { | ||
360 | + if (hildonlike) | ||
361 | + { | ||
362 | + if (calendar->year > min_year) | ||
363 | + { | ||
364 | + calendar->month = 11; | ||
365 | + calendar->year--; | ||
366 | + } | ||
367 | + } | ||
368 | + else | ||
369 | + { | ||
370 | + calendar->month = 11; | ||
371 | + calendar->year--; | ||
372 | + } | ||
373 | + } | ||
374 | + else | ||
375 | + calendar->month--; | ||
376 | + | ||
377 | month_len = month_length[leap (calendar->year)][calendar->month + 1]; | ||
378 | |||
379 | gtk_calendar_freeze (calendar); | ||
380 | @@ -870,17 +993,32 @@ | ||
381 | gtk_calendar_set_month_next (GtkCalendar *calendar) | ||
382 | { | ||
383 | gint month_len; | ||
384 | + gint max_year; | ||
385 | + gboolean hildonlike; | ||
386 | |||
387 | g_return_if_fail (GTK_IS_WIDGET (calendar)); | ||
388 | |||
389 | + gtk_widget_style_get (GTK_WIDGET (calendar), "hildonlike", &hildonlike, | ||
390 | + "max-year", &max_year, NULL); | ||
391 | + | ||
392 | if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE) | ||
393 | return; | ||
394 | |||
395 | - | ||
396 | if (calendar->month == 11) | ||
397 | { | ||
398 | - calendar->month = 0; | ||
399 | - calendar->year++; | ||
400 | + if (hildonlike) | ||
401 | + { | ||
402 | + if (calendar->year < max_year) | ||
403 | + { | ||
404 | + calendar->month = 0; | ||
405 | + calendar->year++; | ||
406 | + } | ||
407 | + } | ||
408 | + else | ||
409 | + { | ||
410 | + calendar->month = 0; | ||
411 | + calendar->year++; | ||
412 | + } | ||
413 | } | ||
414 | else | ||
415 | calendar->month++; | ||
416 | @@ -912,10 +1050,22 @@ | ||
417 | gtk_calendar_set_year_prev (GtkCalendar *calendar) | ||
418 | { | ||
419 | gint month_len; | ||
420 | - | ||
421 | + gint min_year; | ||
422 | + gboolean hildonlike; | ||
423 | + | ||
424 | g_return_if_fail (GTK_IS_WIDGET (calendar)); | ||
425 | |||
426 | - calendar->year--; | ||
427 | + gtk_widget_style_get (GTK_WIDGET (calendar), "hildonlike", &hildonlike, | ||
428 | + "min-year", &min_year, NULL); | ||
429 | + | ||
430 | + if (hildonlike) | ||
431 | + { | ||
432 | + if (calendar->year > min_year) | ||
433 | + calendar->year--; | ||
434 | + } | ||
435 | + else | ||
436 | + calendar->year--; | ||
437 | + | ||
438 | gtk_calendar_freeze (calendar); | ||
439 | gtk_calendar_compute_days (calendar); | ||
440 | g_signal_emit (calendar, | ||
441 | @@ -944,14 +1094,26 @@ | ||
442 | { | ||
443 | gint month_len; | ||
444 | GtkWidget *widget; | ||
445 | + gint max_year; | ||
446 | + gboolean hildonlike; | ||
447 | |||
448 | g_return_if_fail (GTK_IS_WIDGET (calendar)); | ||
449 | |||
450 | widget = GTK_WIDGET (calendar); | ||
451 | + | ||
452 | + gtk_widget_style_get(widget, "hildonlike", &hildonlike, | ||
453 | + "max-year", &max_year, NULL); | ||
454 | |||
455 | gtk_calendar_freeze (calendar); | ||
456 | |||
457 | - calendar->year++; | ||
458 | + if (hildonlike) | ||
459 | + { | ||
460 | + if (calendar->year < max_year) | ||
461 | + calendar->year++; | ||
462 | + } | ||
463 | + else | ||
464 | + calendar->year++; | ||
465 | + | ||
466 | gtk_calendar_compute_days (calendar); | ||
467 | g_signal_emit (calendar, | ||
468 | gtk_calendar_signals[NEXT_YEAR_SIGNAL], | ||
469 | @@ -969,7 +1131,6 @@ | ||
470 | } | ||
471 | else | ||
472 | gtk_calendar_select_day (calendar, calendar->selected_day); | ||
473 | - | ||
474 | gtk_widget_queue_draw (GTK_WIDGET (calendar)); | ||
475 | gtk_calendar_thaw (calendar); | ||
476 | } | ||
477 | @@ -984,6 +1145,8 @@ | ||
478 | gint row, col; | ||
479 | gint day_month; | ||
480 | gint day; | ||
481 | + gint max_year, min_year; | ||
482 | + gboolean hildonlike; | ||
483 | |||
484 | calendar = GTK_CALENDAR (widget); | ||
485 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
486 | @@ -997,20 +1160,36 @@ | ||
487 | /* If row or column isn't found, just return. */ | ||
488 | if (row == -1 || col == -1) | ||
489 | return; | ||
490 | - | ||
491 | - day_month = calendar->day_month[row][col]; | ||
492 | |||
493 | - if (event->type == GDK_BUTTON_PRESS) | ||
494 | + gtk_widget_style_get (GTK_WIDGET (calendar), "hildonlike", &hildonlike, | ||
495 | + "max-year", &max_year, "min-year", &min_year, NULL); | ||
496 | + day_month = calendar->day_month[row][col]; | ||
497 | + | ||
498 | + if (hildonlike) | ||
499 | + { | ||
500 | + if ((calendar->year == min_year && calendar->month == 0 && day_month == MONTH_PREV) | ||
501 | + || (calendar->year == max_year && calendar->month == 11 && day_month == MONTH_NEXT)) | ||
502 | + { | ||
503 | + private_data->is_bad_day = TRUE; | ||
504 | + g_signal_emit (calendar, gtk_calendar_signals[ERRONEOUS_DATE_SIGNAL], 0); | ||
505 | + return; | ||
506 | + } | ||
507 | + } | ||
508 | + if (event->type == (hildonlike ? GDK_BUTTON_RELEASE : GDK_BUTTON_PRESS)) | ||
509 | { | ||
510 | day = calendar->day[row][col]; | ||
511 | |||
512 | if (day_month == MONTH_PREV) | ||
513 | - gtk_calendar_set_month_prev (calendar); | ||
514 | + { | ||
515 | + gtk_calendar_set_month_prev (calendar); | ||
516 | + } | ||
517 | else if (day_month == MONTH_NEXT) | ||
518 | - gtk_calendar_set_month_next (calendar); | ||
519 | + { | ||
520 | + gtk_calendar_set_month_next (calendar); | ||
521 | + } | ||
522 | |||
523 | if (!GTK_WIDGET_HAS_FOCUS (widget)) | ||
524 | - gtk_widget_grab_focus (widget); | ||
525 | + gtk_widget_grab_focus (widget); | ||
526 | |||
527 | if (event->button == 1) | ||
528 | { | ||
529 | @@ -1025,9 +1204,8 @@ | ||
530 | { | ||
531 | private_data->in_drag = 0; | ||
532 | if (day_month == MONTH_CURRENT) | ||
533 | - g_signal_emit (calendar, | ||
534 | - gtk_calendar_signals[DAY_SELECTED_DOUBLE_CLICK_SIGNAL], | ||
535 | - 0); | ||
536 | + g_signal_emit (calendar, | ||
537 | + gtk_calendar_signals[DAY_SELECTED_DOUBLE_CLICK_SIGNAL], 0); | ||
538 | } | ||
539 | } | ||
540 | |||
541 | @@ -1039,18 +1217,18 @@ | ||
542 | GdkWindowAttr attributes; | ||
543 | gint attributes_mask; | ||
544 | gint i; | ||
545 | - gboolean year_left; | ||
546 | + /*gboolean year_left;*/ | ||
547 | |||
548 | g_return_if_fail (GTK_IS_CALENDAR (widget)); | ||
549 | |||
550 | calendar = GTK_CALENDAR (widget); | ||
551 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
552 | - | ||
553 | +/* | ||
554 | if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) | ||
555 | year_left = private_data->year_before; | ||
556 | else | ||
557 | year_left = !private_data->year_before; | ||
558 | - | ||
559 | +*/ | ||
560 | /* Arrow windows ------------------------------------- */ | ||
561 | if (! (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE) | ||
562 | && (calendar->display_flags & GTK_CALENDAR_SHOW_HEADING)) | ||
563 | @@ -1063,10 +1241,26 @@ | ||
564 | | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | ||
565 | | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); | ||
566 | attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; | ||
567 | - attributes.y = 3; | ||
568 | - attributes.width = private_data->arrow_width; | ||
569 | - attributes.height = private_data->header_h - 7; | ||
570 | - for (i = 0; i < 4; i++) | ||
571 | + attributes.y = 0; | ||
572 | + attributes.width = HILDON_ARROW_WIDTH; | ||
573 | + attributes.height = HILDON_ARROW_HEIGHT; | ||
574 | + | ||
575 | + attributes.x = (widget->allocation.width - private_data->max_year_width) / 2 - HILDON_ARROW_WIDTH - HILDON_ARROW_SEP; | ||
576 | + private_data->arrow_win[ARROW_YEAR_LEFT] = gdk_window_new (private_data->header_win, | ||
577 | + &attributes, attributes_mask); | ||
578 | + | ||
579 | + attributes.x = (widget->allocation.width + private_data->max_year_width) / 2 + HILDON_ARROW_SEP; | ||
580 | + private_data->arrow_win[ARROW_YEAR_RIGHT] = gdk_window_new (private_data->header_win, | ||
581 | + &attributes, attributes_mask); | ||
582 | + attributes.x = (widget->allocation.width - private_data->max_month_width) / 2 - HILDON_ARROW_WIDTH - HILDON_ARROW_SEP; | ||
583 | + private_data->arrow_win[ARROW_MONTH_LEFT] = gdk_window_new (private_data->footer_win, | ||
584 | + &attributes, attributes_mask); | ||
585 | + attributes.x = (widget->allocation.width + private_data->max_month_width) / 2 + HILDON_ARROW_SEP; | ||
586 | + private_data->arrow_win[ARROW_MONTH_RIGHT] = gdk_window_new (private_data->footer_win, | ||
587 | + &attributes, attributes_mask); | ||
588 | + | ||
589 | +/* | ||
590 | +for (i = 0; i < 4; i++) | ||
591 | { | ||
592 | switch (i) | ||
593 | { | ||
594 | @@ -1105,7 +1299,10 @@ | ||
595 | } | ||
596 | private_data->arrow_win[i] = gdk_window_new (private_data->header_win, | ||
597 | &attributes, | ||
598 | - attributes_mask); | ||
599 | + attributes_mask);*/ | ||
600 | + | ||
601 | + for (i = 0; i < 4; i++) | ||
602 | + { | ||
603 | if (GTK_WIDGET_IS_SENSITIVE (widget)) | ||
604 | private_data->arrow_state[i] = GTK_STATE_NORMAL; | ||
605 | else | ||
606 | @@ -1145,23 +1342,33 @@ | ||
607 | attributes.colormap = gtk_widget_get_colormap (widget); | ||
608 | attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; | ||
609 | attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; | ||
610 | - attributes.x = widget->style->xthickness; | ||
611 | - attributes.y = widget->style->ythickness; | ||
612 | - attributes.width = widget->allocation.width - 2 * attributes.x; | ||
613 | - attributes.height = private_data->header_h - 2 * attributes.y; | ||
614 | + attributes.x = 0 /*widget->style->xthickness*/; | ||
615 | + attributes.y = 0 /*widget->style->ythickness*/; | ||
616 | + attributes.width = widget->allocation.width; /* - 2 * attributes.x */; | ||
617 | + attributes.height = HILDON_ARROW_HEIGHT /*private_data->header_h - 2 * attributes.y*/; | ||
618 | private_data->header_win = gdk_window_new (widget->window, | ||
619 | &attributes, attributes_mask); | ||
620 | - | ||
621 | + | ||
622 | + attributes.y = HILDON_ARROW_HEIGHT + 2 * CALENDAR_YSEP + private_data->main_h + private_data->day_name_h; | ||
623 | + | ||
624 | + private_data->footer_win = gdk_window_new(widget->window, | ||
625 | + &attributes, attributes_mask); | ||
626 | + | ||
627 | gdk_window_set_background (private_data->header_win, | ||
628 | - HEADER_BG_COLOR (GTK_WIDGET (calendar))); | ||
629 | + HEADER_BG_COLOR (widget)); | ||
630 | + gdk_window_set_background (private_data->footer_win, | ||
631 | + HEADER_BG_COLOR (widget)); | ||
632 | + | ||
633 | gdk_window_show (private_data->header_win); | ||
634 | + gdk_window_show (private_data->footer_win); | ||
635 | gdk_window_set_user_data (private_data->header_win, widget); | ||
636 | - | ||
637 | + gdk_window_set_user_data (private_data->footer_win, widget); | ||
638 | } | ||
639 | else | ||
640 | { | ||
641 | private_data->header_win = NULL; | ||
642 | - } | ||
643 | + private_data->footer_win = NULL; | ||
644 | + } | ||
645 | gtk_calendar_realize_arrows (widget); | ||
646 | } | ||
647 | |||
648 | @@ -1172,7 +1379,7 @@ | ||
649 | GtkCalendarPrivateData *private_data; | ||
650 | GdkWindowAttr attributes; | ||
651 | gint attributes_mask; | ||
652 | - | ||
653 | + | ||
654 | g_return_if_fail (GTK_IS_CALENDAR (widget)); | ||
655 | |||
656 | calendar = GTK_CALENDAR (widget); | ||
657 | @@ -1187,18 +1394,16 @@ | ||
658 | attributes.colormap = gtk_widget_get_colormap (widget); | ||
659 | attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; | ||
660 | attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; | ||
661 | - attributes.x = (widget->style->xthickness + INNER_BORDER); | ||
662 | - attributes.y = private_data->header_h + (widget->style->ythickness | ||
663 | - + INNER_BORDER); | ||
664 | - attributes.width = (widget->allocation.width | ||
665 | - - (widget->style->xthickness + INNER_BORDER) | ||
666 | - * 2); | ||
667 | + attributes.x = /*private_data->week_width*/ (widget->style->xthickness + INNER_BORDER); | ||
668 | + attributes.y = private_data->header_h; | ||
669 | + attributes.width = widget->allocation.width - attributes.x; | ||
670 | attributes.height = private_data->day_name_h; | ||
671 | private_data->day_name_win = gdk_window_new (widget->window, | ||
672 | &attributes, | ||
673 | attributes_mask); | ||
674 | gdk_window_set_background (private_data->day_name_win, | ||
675 | - BACKGROUND_COLOR ( GTK_WIDGET ( calendar))); | ||
676 | + BACKGROUND_COLOR ( GTK_WIDGET (calendar))); | ||
677 | + | ||
678 | gdk_window_show (private_data->day_name_win); | ||
679 | gdk_window_set_user_data (private_data->day_name_win, widget); | ||
680 | } | ||
681 | @@ -1215,7 +1420,7 @@ | ||
682 | GtkCalendarPrivateData *private_data; | ||
683 | GdkWindowAttr attributes; | ||
684 | gint attributes_mask; | ||
685 | - | ||
686 | + | ||
687 | g_return_if_fail (GTK_IS_CALENDAR (widget)); | ||
688 | |||
689 | calendar = GTK_CALENDAR (widget); | ||
690 | @@ -1231,15 +1436,15 @@ | ||
691 | attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; | ||
692 | |||
693 | attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; | ||
694 | - attributes.x = widget->style->xthickness + INNER_BORDER; | ||
695 | - attributes.y = (private_data->header_h + private_data->day_name_h | ||
696 | - + (widget->style->ythickness + INNER_BORDER)); | ||
697 | - attributes.width = private_data->week_width; | ||
698 | - attributes.height = private_data->main_h; | ||
699 | + attributes.x = 0 /*widget->style->xthickness + INNER_BORDER*/; | ||
700 | + attributes.y = private_data->header_h; | ||
701 | + /*+ (widget->style->ythickness + INNER_BORDER))*/; | ||
702 | + attributes.width = HILDON_DAY_WIDTH; | ||
703 | + attributes.height = private_data->main_h + private_data->day_name_h; | ||
704 | private_data->week_win = gdk_window_new (widget->window, | ||
705 | - &attributes, attributes_mask); | ||
706 | + &attributes, attributes_mask); | ||
707 | gdk_window_set_background (private_data->week_win, | ||
708 | - BACKGROUND_COLOR (GTK_WIDGET (calendar))); | ||
709 | + BACKGROUND_COLOR (GTK_WIDGET (calendar))); | ||
710 | gdk_window_show (private_data->week_win); | ||
711 | gdk_window_set_user_data (private_data->week_win, widget); | ||
712 | } | ||
713 | @@ -1318,7 +1523,6 @@ | ||
714 | GDK_GC_FOREGROUND | | ||
715 | GDK_GC_FUNCTION); | ||
716 | } | ||
717 | - | ||
718 | static void | ||
719 | gtk_calendar_unrealize (GtkWidget *widget) | ||
720 | { | ||
721 | @@ -1343,7 +1547,10 @@ | ||
722 | gdk_window_set_user_data (private_data->header_win, NULL); | ||
723 | gdk_window_destroy (private_data->header_win); | ||
724 | private_data->header_win = NULL; | ||
725 | - } | ||
726 | + gdk_window_set_user_data (private_data->footer_win, NULL); | ||
727 | + gdk_window_destroy (private_data->footer_win); | ||
728 | + private_data->footer_win = NULL; | ||
729 | + } | ||
730 | |||
731 | if (private_data->week_win) | ||
732 | { | ||
733 | @@ -1382,10 +1589,10 @@ | ||
734 | PangoLayout *layout; | ||
735 | PangoRectangle logical_rect; | ||
736 | |||
737 | - gint height; | ||
738 | + /*gint height;*/ | ||
739 | gint i; | ||
740 | gchar buffer[255]; | ||
741 | - gint calendar_margin = CALENDAR_MARGIN; | ||
742 | + /*gint calendar_margin = CALENDAR_MARGIN;*/ | ||
743 | gint header_width, main_width; | ||
744 | gint max_header_height = 0; | ||
745 | gint focus_width; | ||
746 | @@ -1401,20 +1608,20 @@ | ||
747 | layout = gtk_widget_create_pango_layout (widget, NULL); | ||
748 | |||
749 | /* | ||
750 | - * Calculate the requisition width for the widget. | ||
751 | + * Calculate the requisition width for the widget. | ||
752 | */ | ||
753 | |||
754 | /* Header width */ | ||
755 | - | ||
756 | + | ||
757 | if (calendar->display_flags & GTK_CALENDAR_SHOW_HEADING) | ||
758 | - { | ||
759 | + { | ||
760 | private_data->max_month_width = 0; | ||
761 | for (i = 0; i < 12; i++) | ||
762 | { | ||
763 | pango_layout_set_text (layout, default_monthname[i], -1); | ||
764 | pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
765 | private_data->max_month_width = MAX (private_data->max_month_width, | ||
766 | - logical_rect.width + 8); | ||
767 | + logical_rect.width +8 ); | ||
768 | max_header_height = MAX (max_header_height, logical_rect.height); | ||
769 | } | ||
770 | private_data->max_year_width = 0; | ||
771 | @@ -1427,13 +1634,13 @@ | ||
772 | logical_rect.width + 8); | ||
773 | max_header_height = MAX (max_header_height, logical_rect.height); | ||
774 | } | ||
775 | - } | ||
776 | + } | ||
777 | else | ||
778 | { | ||
779 | private_data->max_month_width = 0; | ||
780 | private_data->max_year_width = 0; | ||
781 | } | ||
782 | - | ||
783 | + | ||
784 | if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE) | ||
785 | header_width = (private_data->max_month_width | ||
786 | + private_data->max_year_width | ||
787 | @@ -1494,45 +1701,30 @@ | ||
788 | + (private_data->max_week_char_width | ||
789 | ? private_data->max_week_char_width * 2 + (focus_padding + focus_width) * 2 + CALENDAR_XSEP * 2 | ||
790 | : 0)); | ||
791 | - | ||
792 | - | ||
793 | + | ||
794 | requisition->width = MAX (header_width, main_width + INNER_BORDER * 2) + widget->style->xthickness * 2; | ||
795 | + /* FIXME: header_width is broken, when Calendar is themed ! | ||
796 | + * Next line is workaround for this bug | ||
797 | + */ | ||
798 | + requisition->width = (main_width + INNER_BORDER * 2) + widget->style->xthickness * 2; | ||
799 | |||
800 | /* | ||
801 | * Calculate the requisition height for the widget. | ||
802 | + * This is Hildon calculation | ||
803 | */ | ||
804 | - | ||
805 | + | ||
806 | if (calendar->display_flags & GTK_CALENDAR_SHOW_HEADING) | ||
807 | - { | ||
808 | - private_data->header_h = (max_header_height + CALENDAR_YSEP * 2); | ||
809 | - } | ||
810 | + private_data->header_h = HILDON_ARROW_HEIGHT + CALENDAR_YSEP; | ||
811 | else | ||
812 | - { | ||
813 | private_data->header_h = 0; | ||
814 | - } | ||
815 | - | ||
816 | + | ||
817 | if (calendar->display_flags & GTK_CALENDAR_SHOW_DAY_NAMES) | ||
818 | - { | ||
819 | - private_data->day_name_h = (private_data->max_label_char_ascent | ||
820 | - + private_data->max_label_char_descent | ||
821 | - + 2 * (focus_padding + focus_width) + calendar_margin); | ||
822 | - calendar_margin = CALENDAR_YSEP; | ||
823 | - } | ||
824 | + private_data->day_name_h = HILDON_DAY_HEIGHT; | ||
825 | else | ||
826 | - { | ||
827 | private_data->day_name_h = 0; | ||
828 | - } | ||
829 | |||
830 | - private_data->main_h = (CALENDAR_MARGIN + calendar_margin | ||
831 | - + 6 * (private_data->max_day_char_ascent | ||
832 | - + private_data->max_day_char_descent | ||
833 | - + 2 * (focus_padding + focus_width)) | ||
834 | - + DAY_YSEP * 5); | ||
835 | - | ||
836 | - height = (private_data->header_h + private_data->day_name_h | ||
837 | - + private_data->main_h); | ||
838 | - | ||
839 | - requisition->height = height + (widget->style->ythickness + INNER_BORDER) * 2; | ||
840 | + private_data->main_h = 6 * HILDON_DAY_HEIGHT; | ||
841 | + requisition->height = 2 * private_data->header_h + private_data->day_name_h + private_data->main_h; | ||
842 | |||
843 | g_object_unref (layout); | ||
844 | } | ||
845 | @@ -1544,7 +1736,7 @@ | ||
846 | GtkCalendar *calendar; | ||
847 | GtkCalendarPrivateData *private_data; | ||
848 | gint xthickness = widget->style->xthickness; | ||
849 | - gint ythickness = widget->style->xthickness; | ||
850 | + /*gint ythickness = widget->style->xthickness;*/ | ||
851 | gboolean year_left; | ||
852 | |||
853 | widget->allocation = *allocation; | ||
854 | @@ -1569,58 +1761,24 @@ | ||
855 | } | ||
856 | else | ||
857 | { | ||
858 | - private_data->day_width = (allocation->width | ||
859 | + private_data->day_width = (allocation->width | ||
860 | - (xthickness + INNER_BORDER) * 2 | ||
861 | - (CALENDAR_MARGIN * 2) | ||
862 | - (DAY_XSEP * 6))/7; | ||
863 | private_data->week_width = 0; | ||
864 | } | ||
865 | - | ||
866 | + | ||
867 | if (GTK_WIDGET_REALIZED (widget)) | ||
868 | { | ||
869 | gdk_window_move_resize (widget->window, | ||
870 | - allocation->x, allocation->y, | ||
871 | - allocation->width, allocation->height); | ||
872 | + widget->allocation.x, widget->allocation.y, | ||
873 | + widget->allocation.width, widget->allocation.height); | ||
874 | if (private_data->header_win) | ||
875 | gdk_window_move_resize (private_data->header_win, | ||
876 | - xthickness, ythickness, | ||
877 | - allocation->width - 2 * xthickness, private_data->header_h); | ||
878 | - if (private_data->arrow_win[ARROW_MONTH_LEFT]) | ||
879 | - { | ||
880 | - if (year_left) | ||
881 | - gdk_window_move_resize (private_data->arrow_win[ARROW_MONTH_LEFT], | ||
882 | - (allocation->width - 2 * xthickness | ||
883 | - - (3 + 2*private_data->arrow_width | ||
884 | - + private_data->max_month_width)), | ||
885 | - 3, | ||
886 | - private_data->arrow_width, | ||
887 | - private_data->header_h - 7); | ||
888 | - else | ||
889 | - gdk_window_move_resize (private_data->arrow_win[ARROW_MONTH_LEFT], | ||
890 | - 3, 3, | ||
891 | - private_data->arrow_width, | ||
892 | - private_data->header_h - 7); | ||
893 | - } | ||
894 | - if (private_data->arrow_win[ARROW_MONTH_RIGHT]) | ||
895 | - { | ||
896 | - if (year_left) | ||
897 | - gdk_window_move_resize (private_data->arrow_win[ARROW_MONTH_RIGHT], | ||
898 | - (allocation->width - 2 * xthickness | ||
899 | - - 3 - private_data->arrow_width), | ||
900 | - 3, | ||
901 | - private_data->arrow_width, | ||
902 | - private_data->header_h - 7); | ||
903 | - else | ||
904 | - gdk_window_move_resize (private_data->arrow_win[ARROW_MONTH_RIGHT], | ||
905 | - (private_data->arrow_width | ||
906 | - + private_data->max_month_width), | ||
907 | - 3, | ||
908 | - private_data->arrow_width, | ||
909 | - private_data->header_h - 7); | ||
910 | - } | ||
911 | + 0, 0, widget->allocation.width, HILDON_ARROW_HEIGHT); | ||
912 | if (private_data->arrow_win[ARROW_YEAR_LEFT]) | ||
913 | { | ||
914 | - if (year_left) | ||
915 | + /* if (year_left) | ||
916 | gdk_window_move_resize (private_data->arrow_win[ARROW_YEAR_LEFT], | ||
917 | 3, 3, | ||
918 | private_data->arrow_width, | ||
919 | @@ -1632,11 +1790,14 @@ | ||
920 | + private_data->max_year_width)), | ||
921 | 3, | ||
922 | private_data->arrow_width, | ||
923 | - private_data->header_h - 7); | ||
924 | + private_data->header_h - 7);*/ | ||
925 | + | ||
926 | + gdk_window_move (private_data->arrow_win[ARROW_YEAR_LEFT], | ||
927 | + (widget->allocation.width - private_data->max_year_width) / 2 - HILDON_ARROW_WIDTH - HILDON_ARROW_SEP, 0); | ||
928 | } | ||
929 | if (private_data->arrow_win[ARROW_YEAR_RIGHT]) | ||
930 | { | ||
931 | - if (year_left) | ||
932 | +/* if (year_left) | ||
933 | gdk_window_move_resize (private_data->arrow_win[ARROW_YEAR_RIGHT], | ||
934 | (private_data->arrow_width | ||
935 | + private_data->max_year_width), | ||
936 | @@ -1649,55 +1810,102 @@ | ||
937 | - 3 - private_data->arrow_width), | ||
938 | 3, | ||
939 | private_data->arrow_width, | ||
940 | + private_data->header_h - 7);*/ | ||
941 | + gdk_window_move (private_data->arrow_win[ARROW_YEAR_RIGHT], | ||
942 | + (widget->allocation.width + private_data->max_year_width) / 2 + HILDON_ARROW_SEP, 0); | ||
943 | + } | ||
944 | + if (private_data->footer_win) | ||
945 | + gdk_window_move_resize (private_data->footer_win, | ||
946 | + 0, private_data->header_h + private_data->day_name_h + private_data->main_h + CALENDAR_YSEP, | ||
947 | + widget->allocation.width, HILDON_ARROW_HEIGHT); | ||
948 | + | ||
949 | + if (private_data->arrow_win[ARROW_MONTH_LEFT]) | ||
950 | + { | ||
951 | +/* if (year_left) | ||
952 | + gdk_window_move_resize (private_data->arrow_win[ARROW_MONTH_LEFT], | ||
953 | + (allocation->width - 2 * xthickness | ||
954 | + - (3 + 2*private_data->arrow_width | ||
955 | + + private_data->max_month_width)), | ||
956 | + 3, | ||
957 | + private_data->arrow_width, | ||
958 | private_data->header_h - 7); | ||
959 | + else | ||
960 | + gdk_window_move_resize (private_data->arrow_win[ARROW_MONTH_LEFT], | ||
961 | + 3, 3, | ||
962 | + private_data->arrow_width, | ||
963 | + private_data->header_h - 7); | ||
964 | +*/ | ||
965 | + | ||
966 | + gdk_window_move (private_data->arrow_win[ARROW_MONTH_LEFT], | ||
967 | + (widget->allocation.width - private_data->max_month_width) / 2 - HILDON_ARROW_WIDTH - HILDON_ARROW_SEP, 0); | ||
968 | + } | ||
969 | + if (private_data->arrow_win[ARROW_MONTH_RIGHT]) | ||
970 | + { | ||
971 | +/* if (year_left) | ||
972 | + gdk_window_move_resize (private_data->arrow_win[ARROW_MONTH_RIGHT], | ||
973 | + (allocation->width - 2 * xthickness | ||
974 | + - 3 - private_data->arrow_width), | ||
975 | + 3, | ||
976 | + private_data->arrow_width, | ||
977 | + private_data->header_h - 7); | ||
978 | + else | ||
979 | + gdk_window_move_resize (private_data->arrow_win[ARROW_MONTH_RIGHT], | ||
980 | + (private_data->arrow_width | ||
981 | + + private_data->max_month_width), | ||
982 | + 3, | ||
983 | + private_data->arrow_width, | ||
984 | + private_data->header_h - 7);*/ | ||
985 | + gdk_window_move (private_data->arrow_win[ARROW_MONTH_RIGHT], | ||
986 | + (widget->allocation.width + private_data->max_month_width) / 2 + HILDON_ARROW_SEP, 0); | ||
987 | } | ||
988 | + | ||
989 | + | ||
990 | if (private_data->day_name_win) | ||
991 | gdk_window_move_resize (private_data->day_name_win, | ||
992 | - xthickness + INNER_BORDER, | ||
993 | - private_data->header_h + (widget->style->ythickness + INNER_BORDER), | ||
994 | - allocation->width - (xthickness + INNER_BORDER) * 2, | ||
995 | + private_data->week_width, /*xthickness + INNER_BORDER*/ | ||
996 | + private_data->header_h /*+ (widget->style->ythickness + INNER_BORDER)*/, | ||
997 | + widget->allocation.width - private_data->week_width /*- (xthickness + INNER_BORDER) * 2*/, | ||
998 | private_data->day_name_h); | ||
999 | if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) | ||
1000 | { | ||
1001 | if (private_data->week_win) | ||
1002 | gdk_window_move_resize (private_data->week_win, | ||
1003 | - (xthickness + INNER_BORDER), | ||
1004 | - private_data->header_h + private_data->day_name_h | ||
1005 | - + (widget->style->ythickness + INNER_BORDER), | ||
1006 | - private_data->week_width, | ||
1007 | - private_data->main_h); | ||
1008 | + 0 /*(xthickness + INNER_BORDER)*/, | ||
1009 | + private_data->header_h /*+ (widget->style->ythickness + INNER_BORDER)*/, | ||
1010 | + HILDON_DAY_WIDTH, | ||
1011 | + private_data->main_h + private_data->day_name_h); | ||
1012 | gdk_window_move_resize (private_data->main_win, | ||
1013 | - private_data->week_width + (xthickness + INNER_BORDER), | ||
1014 | + private_data->week_width /* + (xthickness + INNER_BORDER)*/, | ||
1015 | private_data->header_h + private_data->day_name_h | ||
1016 | - + (widget->style->ythickness + INNER_BORDER), | ||
1017 | - allocation->width | ||
1018 | - - private_data->week_width | ||
1019 | - - (xthickness + INNER_BORDER) * 2, | ||
1020 | + /*+ (widget->style->ythickness + INNER_BORDER)*/, | ||
1021 | + widget->allocation.width - private_data->week_width | ||
1022 | + /*- (xthickness + INNER_BORDER) * 2*/, | ||
1023 | private_data->main_h); | ||
1024 | } | ||
1025 | else | ||
1026 | { | ||
1027 | gdk_window_move_resize (private_data->main_win, | ||
1028 | - (xthickness + INNER_BORDER), | ||
1029 | + 0 /*(xthickness + INNER_BORDER)*/, | ||
1030 | private_data->header_h + private_data->day_name_h | ||
1031 | - + (widget->style->ythickness + INNER_BORDER), | ||
1032 | - allocation->width | ||
1033 | + /*+ (widget->style->ythickness + INNER_BORDER)*/, | ||
1034 | + widget->allocation.width | ||
1035 | - private_data->week_width | ||
1036 | - - (xthickness + INNER_BORDER) * 2, | ||
1037 | + /*- (xthickness + INNER_BORDER) * 2*/, | ||
1038 | private_data->main_h); | ||
1039 | if (private_data->week_win) | ||
1040 | gdk_window_move_resize (private_data->week_win, | ||
1041 | - allocation->width | ||
1042 | + widget->allocation.width | ||
1043 | - private_data->week_width | ||
1044 | - - (xthickness + INNER_BORDER), | ||
1045 | + /*- (xthickness + INNER_BORDER)*/, | ||
1046 | private_data->header_h + private_data->day_name_h | ||
1047 | - + (widget->style->ythickness + INNER_BORDER), | ||
1048 | + /*+ (widget->style->ythickness + INNER_BORDER)*/, | ||
1049 | private_data->week_width, | ||
1050 | private_data->main_h); | ||
1051 | } | ||
1052 | } | ||
1053 | } | ||
1054 | |||
1055 | + | ||
1056 | static gboolean | ||
1057 | gtk_calendar_expose (GtkWidget *widget, | ||
1058 | GdkEventExpose *event) | ||
1059 | @@ -1711,22 +1919,24 @@ | ||
1060 | if (GTK_WIDGET_DRAWABLE (widget)) | ||
1061 | { | ||
1062 | if (event->window == private_data->main_win) | ||
1063 | - gtk_calendar_paint_main (widget); | ||
1064 | + gtk_calendar_paint_main (widget); | ||
1065 | |||
1066 | if (event->window == private_data->header_win) | ||
1067 | - gtk_calendar_paint_header (widget); | ||
1068 | - | ||
1069 | - if (event->window == private_data->day_name_win) | ||
1070 | - gtk_calendar_paint_day_names (widget); | ||
1071 | - | ||
1072 | - if (event->window == private_data->week_win) | ||
1073 | - gtk_calendar_paint_week_numbers (widget); | ||
1074 | - if (event->window == widget->window) | ||
1075 | + gtk_calendar_paint_header (widget); | ||
1076 | + if (event->window == private_data->footer_win) | ||
1077 | + gtk_calendar_paint_footer(widget); | ||
1078 | + | ||
1079 | + if (event->window == private_data->day_name_win) | ||
1080 | + gtk_calendar_paint_day_names (widget); | ||
1081 | + | ||
1082 | + if (event->window == private_data->week_win) | ||
1083 | + gtk_calendar_paint_week_numbers (widget); | ||
1084 | +/* if (event->window == widget->window) | ||
1085 | { | ||
1086 | gtk_paint_shadow (widget->style, widget->window, GTK_WIDGET_STATE (widget), | ||
1087 | GTK_SHADOW_IN, NULL, widget, "calendar", | ||
1088 | 0, 0, widget->allocation.width, widget->allocation.height); | ||
1089 | - } | ||
1090 | + }*/ | ||
1091 | } | ||
1092 | |||
1093 | return FALSE; | ||
1094 | @@ -1740,12 +1950,12 @@ | ||
1095 | char buffer[255]; | ||
1096 | int x, y; | ||
1097 | gint header_width, cal_height; | ||
1098 | - gint max_month_width; | ||
1099 | +/* gint max_month_width;*/ | ||
1100 | gint max_year_width; | ||
1101 | GtkCalendarPrivateData *private_data; | ||
1102 | PangoLayout *layout; | ||
1103 | PangoRectangle logical_rect; | ||
1104 | - gboolean year_left; | ||
1105 | +/* gboolean year_left;*/ | ||
1106 | |||
1107 | calendar = GTK_CALENDAR (widget); | ||
1108 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1109 | @@ -1755,29 +1965,29 @@ | ||
1110 | private_data->dirty_header = 1; | ||
1111 | return; | ||
1112 | } | ||
1113 | - | ||
1114 | +/* | ||
1115 | if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) | ||
1116 | year_left = private_data->year_before; | ||
1117 | else | ||
1118 | year_left = !private_data->year_before; | ||
1119 | - | ||
1120 | +*/ | ||
1121 | private_data->dirty_header = 0; | ||
1122 | gc = calendar->gc; | ||
1123 | |||
1124 | /* Clear window */ | ||
1125 | gdk_window_clear (private_data->header_win); | ||
1126 | |||
1127 | - header_width = widget->allocation.width - 2 * widget->style->xthickness; | ||
1128 | + header_width = widget->allocation.width /*- 2 * widget->style->xthickness*/; | ||
1129 | cal_height = widget->allocation.height; | ||
1130 | |||
1131 | - max_month_width = private_data->max_month_width; | ||
1132 | + /*max_month_width = private_data->max_month_width;*/ | ||
1133 | max_year_width = private_data->max_year_width; | ||
1134 | |||
1135 | - gdk_gc_set_foreground (gc, BACKGROUND_COLOR (GTK_WIDGET (calendar))); | ||
1136 | - gtk_paint_shadow (widget->style, private_data->header_win, | ||
1137 | +/* gdk_gc_set_foreground (gc, BACKGROUND_COLOR (GTK_WIDGET (calendar)));*/ | ||
1138 | + /*gtk_paint_shadow (widget->style, private_data->header_win, | ||
1139 | GTK_STATE_NORMAL, GTK_SHADOW_OUT, | ||
1140 | NULL, widget, "calendar", | ||
1141 | - 0, 0, header_width, private_data->header_h); | ||
1142 | + 0, 0, header_width, private_data->header_h);*/ | ||
1143 | |||
1144 | |||
1145 | g_snprintf (buffer, sizeof (buffer), "%d", calendar->year); | ||
1146 | @@ -1785,55 +1995,118 @@ | ||
1147 | pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1148 | |||
1149 | /* Draw title */ | ||
1150 | - y = (private_data->header_h - logical_rect.height) / 2; | ||
1151 | - | ||
1152 | + y = (HILDON_ARROW_HEIGHT /*private_data->header_h*/ - logical_rect.height) / 2; | ||
1153 | + x = (widget->allocation.width - logical_rect.width) / 2; | ||
1154 | + | ||
1155 | /* Draw year and its arrows */ | ||
1156 | - | ||
1157 | +#if 0 | ||
1158 | if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE) | ||
1159 | - if (year_left) | ||
1160 | - x = 3 + (max_year_width - logical_rect.width)/2; | ||
1161 | - else | ||
1162 | +/* if (year_left) */ | ||
1163 | + x = /*3+*/(widget->allocation.width - logical_rect.width)/2; | ||
1164 | +/* else | ||
1165 | x = header_width - (3 + max_year_width | ||
1166 | - - (max_year_width - logical_rect.width)/2); | ||
1167 | + - (max_year_width - logical_rect.width)/2);*/ | ||
1168 | else | ||
1169 | - if (year_left) | ||
1170 | - x = 3 + private_data->arrow_width + (max_year_width - logical_rect.width)/2; | ||
1171 | - else | ||
1172 | +/* if (year_left)*/ | ||
1173 | + x = 3 + HILDON_ARROW_WIDTH /*private_data->arrow_width*/ + (max_year_width - logical_rect.width)/2; | ||
1174 | + /* else | ||
1175 | x = header_width - (3 + private_data->arrow_width + max_year_width | ||
1176 | - (max_year_width - logical_rect.width)/2); | ||
1177 | + */ | ||
1178 | + #endif | ||
1179 | + gdk_gc_set_foreground (gc, HEADER_FG_COLOR (GTK_WIDGET (calendar))); | ||
1180 | + gdk_draw_layout (private_data->header_win, gc, x, y, layout); | ||
1181 | + | ||
1182 | + gtk_calendar_paint_arrow (widget, ARROW_YEAR_LEFT); | ||
1183 | + gtk_calendar_paint_arrow (widget, ARROW_YEAR_RIGHT); | ||
1184 | + | ||
1185 | + g_object_unref (layout); | ||
1186 | +} | ||
1187 | + | ||
1188 | +static void | ||
1189 | +gtk_calendar_paint_footer (GtkWidget *widget) | ||
1190 | +{ | ||
1191 | +GtkCalendar *calendar; | ||
1192 | + GdkGC *gc; | ||
1193 | + char buffer[255]; | ||
1194 | + int x, y; | ||
1195 | + gint header_width, cal_height; | ||
1196 | +/* gint max_month_width; | ||
1197 | + gint max_year_width;*/ | ||
1198 | + GtkCalendarPrivateData *private_data; | ||
1199 | + PangoLayout *layout; | ||
1200 | + PangoRectangle logical_rect; | ||
1201 | +/* gboolean year_left;*/ | ||
1202 | + | ||
1203 | + calendar = GTK_CALENDAR (widget); | ||
1204 | + private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1205 | + | ||
1206 | + if (private_data->freeze_count) | ||
1207 | + { | ||
1208 | + private_data->dirty_header = 1; | ||
1209 | + return; | ||
1210 | + } | ||
1211 | +/* | ||
1212 | + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) | ||
1213 | + year_left = private_data->year_before; | ||
1214 | + else | ||
1215 | + year_left = !private_data->year_before; | ||
1216 | +*/ | ||
1217 | + private_data->dirty_header = 0; | ||
1218 | + gc = calendar->gc; | ||
1219 | |||
1220 | + /* Clear window */ | ||
1221 | + gdk_window_clear (private_data->footer_win); | ||
1222 | + | ||
1223 | + header_width = widget->allocation.width - 2 * widget->style->xthickness; | ||
1224 | + cal_height = widget->allocation.height; | ||
1225 | + | ||
1226 | + /*max_month_width = private_data->max_month_width;*/ | ||
1227 | + /*max_year_width = private_data->max_year_width;*/ | ||
1228 | + | ||
1229 | + /*gdk_gc_set_foreground (gc, BACKGROUND_COLOR (GTK_WIDGET (calendar)));*/ | ||
1230 | + /*gtk_paint_shadow (widget->style, private_data->footer_win, | ||
1231 | + GTK_STATE_NORMAL, GTK_SHADOW_OUT, | ||
1232 | + NULL, widget, "calendar", | ||
1233 | + 0, 0, header_width, private_data->header_h);*/ | ||
1234 | |||
1235 | - gdk_gc_set_foreground (gc, HEADER_FG_COLOR (GTK_WIDGET (calendar))); | ||
1236 | - gdk_draw_layout (private_data->header_win, gc, x, y, layout); | ||
1237 | |||
1238 | + /*g_snprintf (buffer, sizeof (buffer), "%d", calendar->year);*/ | ||
1239 | + | ||
1240 | +/* pango_layout_get_pixel_extents (layout, NULL, &logical_rect);*/ | ||
1241 | + | ||
1242 | + /* Draw title */ | ||
1243 | + | ||
1244 | + | ||
1245 | /* Draw month */ | ||
1246 | g_snprintf (buffer, sizeof (buffer), "%s", default_monthname[calendar->month]); | ||
1247 | - pango_layout_set_text (layout, buffer, -1); | ||
1248 | + layout = gtk_widget_create_pango_layout (widget, buffer); | ||
1249 | pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1250 | - | ||
1251 | +#if 0 | ||
1252 | if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE) | ||
1253 | - if (year_left) | ||
1254 | +/* if (year_left)*/ | ||
1255 | x = header_width - (3 + max_month_width | ||
1256 | - (max_month_width - logical_rect.width)/2); | ||
1257 | - else | ||
1258 | - x = 3 + (max_month_width - logical_rect.width) / 2; | ||
1259 | + /* else | ||
1260 | + x = 3 + (max_month_width - logical_rect.width) / 2;*/ | ||
1261 | else | ||
1262 | - if (year_left) | ||
1263 | - x = header_width - (3 + private_data->arrow_width + max_month_width | ||
1264 | +/* if (year_left)*/ | ||
1265 | + x = header_width - (3 + HILDON_ARROW_WIDTH /*private_data->arrow_width*/ + max_month_width | ||
1266 | - (max_month_width - logical_rect.width)/2); | ||
1267 | - else | ||
1268 | +/* else | ||
1269 | x = 3 + private_data->arrow_width + (max_month_width - logical_rect.width)/2; | ||
1270 | +*/ | ||
1271 | +#endif | ||
1272 | + x = (widget->allocation.width - logical_rect.width) / 2; | ||
1273 | + y = (HILDON_ARROW_HEIGHT - logical_rect.height) / 2; | ||
1274 | + | ||
1275 | + gdk_gc_set_foreground (gc, HEADER_FG_COLOR(GTK_WIDGET (calendar))); | ||
1276 | + gdk_draw_layout (private_data->footer_win, gc, x, y, layout); | ||
1277 | |||
1278 | - gdk_draw_layout (private_data->header_win, gc, x, y, layout); | ||
1279 | - | ||
1280 | - gdk_gc_set_foreground (gc, BACKGROUND_COLOR (GTK_WIDGET (calendar))); | ||
1281 | - | ||
1282 | gtk_calendar_paint_arrow (widget, ARROW_MONTH_LEFT); | ||
1283 | gtk_calendar_paint_arrow (widget, ARROW_MONTH_RIGHT); | ||
1284 | - gtk_calendar_paint_arrow (widget, ARROW_YEAR_LEFT); | ||
1285 | - gtk_calendar_paint_arrow (widget, ARROW_YEAR_RIGHT); | ||
1286 | |||
1287 | - g_object_unref (layout); | ||
1288 | + g_object_unref(layout); | ||
1289 | } | ||
1290 | |||
1291 | static void | ||
1292 | @@ -1851,15 +2124,17 @@ | ||
1293 | GtkCalendarPrivateData *private_data; | ||
1294 | gint focus_padding; | ||
1295 | gint focus_width; | ||
1296 | + gboolean hildonlike; | ||
1297 | |||
1298 | g_return_if_fail (GTK_IS_CALENDAR (widget)); | ||
1299 | calendar = GTK_CALENDAR (widget); | ||
1300 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1301 | gc = calendar->gc; | ||
1302 | - | ||
1303 | + | ||
1304 | gtk_widget_style_get (GTK_WIDGET (widget), | ||
1305 | "focus-line-width", &focus_width, | ||
1306 | "focus-padding", &focus_padding, | ||
1307 | + "hildonlike", &hildonlike, | ||
1308 | NULL); | ||
1309 | /* | ||
1310 | * Handle freeze/thaw functionality | ||
1311 | @@ -1887,18 +2162,22 @@ | ||
1312 | * Draw rectangles as inverted background for the labels. | ||
1313 | */ | ||
1314 | |||
1315 | - gdk_gc_set_foreground (gc, SELECTED_BG_COLOR (widget)); | ||
1316 | - gdk_draw_rectangle (private_data->day_name_win, gc, TRUE, | ||
1317 | - CALENDAR_MARGIN, CALENDAR_MARGIN, | ||
1318 | - cal_width-CALENDAR_MARGIN * 2, | ||
1319 | - private_data->day_name_h - CALENDAR_MARGIN); | ||
1320 | - | ||
1321 | - if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS) | ||
1322 | - gdk_draw_rectangle (private_data->day_name_win, gc, TRUE, | ||
1323 | - CALENDAR_MARGIN, | ||
1324 | - private_data->day_name_h - CALENDAR_YSEP, | ||
1325 | - private_data->week_width - CALENDAR_YSEP - CALENDAR_MARGIN, | ||
1326 | - CALENDAR_YSEP); | ||
1327 | + /* Hildon: don't paint dayname window */ | ||
1328 | + if (!hildonlike) | ||
1329 | + { | ||
1330 | + gdk_gc_set_foreground (gc, SELECTED_BG_COLOR (widget)); | ||
1331 | + gdk_draw_rectangle (private_data->day_name_win, gc, TRUE, | ||
1332 | + CALENDAR_MARGIN, CALENDAR_MARGIN, | ||
1333 | + cal_width-CALENDAR_MARGIN * 2, | ||
1334 | + private_data->day_name_h - CALENDAR_MARGIN); | ||
1335 | + | ||
1336 | + if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS) | ||
1337 | + gdk_draw_rectangle (private_data->day_name_win, gc, TRUE, | ||
1338 | + CALENDAR_MARGIN, | ||
1339 | + private_data->day_name_h - CALENDAR_YSEP, | ||
1340 | + private_data->week_width - CALENDAR_YSEP - CALENDAR_MARGIN, | ||
1341 | + CALENDAR_YSEP); | ||
1342 | + } | ||
1343 | |||
1344 | /* | ||
1345 | * Write the labels | ||
1346 | @@ -1908,28 +2187,43 @@ | ||
1347 | |||
1348 | gdk_gc_set_foreground (gc, SELECTED_FG_COLOR (widget)); | ||
1349 | for (i = 0; i < 7; i++) | ||
1350 | - { | ||
1351 | + { | ||
1352 | if (gtk_widget_get_direction (GTK_WIDGET (calendar)) == GTK_TEXT_DIR_RTL) | ||
1353 | - day = 6 - i; | ||
1354 | + day = 6 - i; | ||
1355 | else | ||
1356 | - day = i; | ||
1357 | - day = (day + private_data->week_start) % 7; | ||
1358 | - g_snprintf (buffer, sizeof (buffer), "%s", default_abbreviated_dayname[day]); | ||
1359 | + day = i; | ||
1360 | + day = (day + private_data->week_start) % 7; | ||
1361 | + g_snprintf (buffer, sizeof (buffer), "%s", default_abbreviated_dayname[day]); | ||
1362 | + | ||
1363 | + pango_layout_set_text (layout, buffer, -1); | ||
1364 | + pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1365 | |||
1366 | - pango_layout_set_text (layout, buffer, -1); | ||
1367 | - pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1368 | + /* Hildon: draw passive focus for day name */ | ||
1369 | + if (hildonlike && calendar->focus_col == i) | ||
1370 | + { | ||
1371 | + guint x = left_x_for_column (calendar, calendar->focus_col); | ||
1372 | |||
1373 | - gdk_draw_layout (private_data->day_name_win, gc, | ||
1374 | - (CALENDAR_MARGIN + | ||
1375 | - + (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ? | ||
1376 | - (private_data->week_width + (private_data->week_width ? CALENDAR_XSEP : 0)) | ||
1377 | - : 0) | ||
1378 | - + day_wid_sep * i | ||
1379 | - + (day_width - logical_rect.width)/2), | ||
1380 | - CALENDAR_MARGIN + focus_width + focus_padding + logical_rect.y, | ||
1381 | - layout); | ||
1382 | + gtk_paint_box( GTK_WIDGET (calendar)->style, | ||
1383 | + private_data->day_name_win, | ||
1384 | + GTK_STATE_NORMAL, | ||
1385 | + GTK_SHADOW_OUT, NULL, | ||
1386 | + GTK_WIDGET (calendar), "passive-focus", | ||
1387 | + (x + 4) + HILDON_DAY_WIDTH, 0, | ||
1388 | + day_wid_sep + 2, | ||
1389 | + HILDON_DAY_HEIGHT); | ||
1390 | + } | ||
1391 | + gdk_draw_layout (private_data->day_name_win, gc, | ||
1392 | + (CALENDAR_MARGIN + | ||
1393 | + + (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ? | ||
1394 | + (private_data->week_width + (private_data->week_width ? CALENDAR_XSEP : 0)) | ||
1395 | + : 0) | ||
1396 | + + day_wid_sep * i | ||
1397 | + + (day_width - logical_rect.width)/2), | ||
1398 | + CALENDAR_MARGIN + focus_width + focus_padding + logical_rect.y, | ||
1399 | + layout); | ||
1400 | + | ||
1401 | + | ||
1402 | } | ||
1403 | - | ||
1404 | g_object_unref (layout); | ||
1405 | } | ||
1406 | |||
1407 | @@ -1940,14 +2234,15 @@ | ||
1408 | GdkGC *gc; | ||
1409 | gint row, week = 0, year; | ||
1410 | gint x_loc; | ||
1411 | - char buffer[3]; | ||
1412 | - gint y_loc, day_height; | ||
1413 | + char buffer[10]; | ||
1414 | + gint y_loc /*, day_height*/; | ||
1415 | GtkCalendarPrivateData *private_data; | ||
1416 | PangoLayout *layout; | ||
1417 | PangoRectangle logical_rect; | ||
1418 | gint focus_padding; | ||
1419 | gint focus_width; | ||
1420 | - | ||
1421 | + gboolean hildonlike; | ||
1422 | + | ||
1423 | g_return_if_fail (GTK_IS_CALENDAR (widget)); | ||
1424 | g_return_if_fail (widget->window != NULL); | ||
1425 | calendar = GTK_CALENDAR (widget); | ||
1426 | @@ -1968,6 +2263,7 @@ | ||
1427 | gtk_widget_style_get (GTK_WIDGET (widget), | ||
1428 | "focus-line-width", &focus_width, | ||
1429 | "focus-padding", &focus_padding, | ||
1430 | + "hildonlike", &hildonlike, | ||
1431 | NULL); | ||
1432 | |||
1433 | /* | ||
1434 | @@ -1981,18 +2277,23 @@ | ||
1435 | */ | ||
1436 | |||
1437 | gdk_gc_set_foreground (gc, SELECTED_BG_COLOR (widget)); | ||
1438 | - if (private_data->day_name_win) | ||
1439 | - gdk_draw_rectangle (private_data->week_win, gc, TRUE, | ||
1440 | - CALENDAR_MARGIN, | ||
1441 | - 0, | ||
1442 | - private_data->week_width - CALENDAR_MARGIN, | ||
1443 | - private_data->main_h - CALENDAR_MARGIN); | ||
1444 | - else | ||
1445 | - gdk_draw_rectangle (private_data->week_win, gc, TRUE, | ||
1446 | - CALENDAR_MARGIN, | ||
1447 | - CALENDAR_MARGIN, | ||
1448 | - private_data->week_width - CALENDAR_MARGIN, | ||
1449 | - private_data->main_h - 2 * CALENDAR_MARGIN); | ||
1450 | + | ||
1451 | + /* Hildon: don't paint background for weekday window */ | ||
1452 | + if (!hildonlike) | ||
1453 | + { | ||
1454 | + if (private_data->day_name_win) | ||
1455 | + gdk_draw_rectangle (private_data->week_win, gc, TRUE, | ||
1456 | + CALENDAR_MARGIN, | ||
1457 | + 0, | ||
1458 | + private_data->week_width - CALENDAR_MARGIN, | ||
1459 | + private_data->main_h + private_data->day_name_h- CALENDAR_MARGIN); | ||
1460 | + else | ||
1461 | + gdk_draw_rectangle (private_data->week_win, gc, TRUE, | ||
1462 | + CALENDAR_MARGIN, | ||
1463 | + CALENDAR_MARGIN, | ||
1464 | + private_data->week_width - CALENDAR_MARGIN, | ||
1465 | + private_data->main_h - 2 * CALENDAR_MARGIN); | ||
1466 | + } | ||
1467 | |||
1468 | /* | ||
1469 | * Write the labels | ||
1470 | @@ -2001,10 +2302,13 @@ | ||
1471 | layout = gtk_widget_create_pango_layout (widget, NULL); | ||
1472 | |||
1473 | gdk_gc_set_foreground (gc, SELECTED_FG_COLOR (widget)); | ||
1474 | - day_height = row_height (calendar); | ||
1475 | + gdk_draw_line(private_data->week_win, gc, | ||
1476 | + HILDON_DAY_WIDTH - 1, 0, HILDON_DAY_WIDTH - 1, private_data->main_h + private_data->day_name_h); | ||
1477 | + | ||
1478 | + /*day_height = row_height (calendar)*/; | ||
1479 | for (row = 0; row < 6; row++) | ||
1480 | { | ||
1481 | - year = calendar->year; | ||
1482 | + year = calendar->year; | ||
1483 | if (calendar->day[row][6] < 15 && row > 3 && calendar->month == 11) | ||
1484 | year++; | ||
1485 | |||
1486 | @@ -2012,15 +2316,30 @@ | ||
1487 | ((calendar->day[row][6] < 15 && row > 3 ? 1 : 0) | ||
1488 | + calendar->month) % 12 + 1, calendar->day[row][6])); | ||
1489 | |||
1490 | - g_snprintf (buffer, sizeof (buffer), "%d", week); | ||
1491 | - pango_layout_set_text (layout, buffer, -1); | ||
1492 | - pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1493 | - | ||
1494 | - y_loc = top_y_for_row (calendar, row) + (day_height - logical_rect.height) / 2; | ||
1495 | - | ||
1496 | - x_loc = (private_data->week_width | ||
1497 | + g_snprintf (buffer, sizeof (buffer), "%d", week); | ||
1498 | + pango_layout_set_text (layout, buffer, -1); | ||
1499 | + pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1500 | + | ||
1501 | + /* Hildon: draw passive focus for week */ | ||
1502 | + if (hildonlike && calendar->focus_row == row) | ||
1503 | + { | ||
1504 | + guint y = top_y_for_row (calendar, calendar->focus_row + 1); | ||
1505 | + | ||
1506 | + gtk_paint_box( GTK_WIDGET (calendar)->style, | ||
1507 | + private_data->week_win, | ||
1508 | + GTK_STATE_NORMAL, | ||
1509 | + GTK_SHADOW_OUT, NULL, | ||
1510 | + GTK_WIDGET (calendar), "passive-focus", | ||
1511 | + 0, y, | ||
1512 | + private_data->week_width - 4, | ||
1513 | + HILDON_DAY_HEIGHT); | ||
1514 | + } | ||
1515 | + | ||
1516 | + y_loc = private_data->day_name_h + top_y_for_row (calendar, row) + (HILDON_DAY_HEIGHT - logical_rect.height) / 2; | ||
1517 | + x_loc = (HILDON_DAY_WIDTH - logical_rect.width) / 2; | ||
1518 | + /*(private_data->week_width | ||
1519 | - logical_rect.width | ||
1520 | - - CALENDAR_XSEP - focus_padding - focus_width); | ||
1521 | + - CALENDAR_XSEP - focus_padding - focus_width);*/ | ||
1522 | |||
1523 | gdk_draw_layout (private_data->week_win, gc, x_loc, y_loc, layout); | ||
1524 | } | ||
1525 | @@ -2034,11 +2353,13 @@ | ||
1526 | { | ||
1527 | GtkCalendar *calendar; | ||
1528 | gint r, c, row, col; | ||
1529 | - | ||
1530 | + GtkCalendarPrivateData *private_data; | ||
1531 | g_return_if_fail (GTK_IS_CALENDAR (widget)); | ||
1532 | |||
1533 | calendar = GTK_CALENDAR (widget); | ||
1534 | - | ||
1535 | + | ||
1536 | + private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1537 | + | ||
1538 | row = -1; | ||
1539 | col = -1; | ||
1540 | for (r = 0; r < 6; r++) | ||
1541 | @@ -2054,6 +2375,7 @@ | ||
1542 | g_return_if_fail (col != -1); | ||
1543 | |||
1544 | gtk_calendar_paint_day (widget, row, col); | ||
1545 | + | ||
1546 | } | ||
1547 | |||
1548 | static void | ||
1549 | @@ -2065,13 +2387,14 @@ | ||
1550 | GdkGC *gc; | ||
1551 | gchar buffer[255]; | ||
1552 | gint day; | ||
1553 | - gint day_height; | ||
1554 | + /*gint day_height;*/ | ||
1555 | gint x_left; | ||
1556 | gint x_loc; | ||
1557 | gint y_top; | ||
1558 | gint y_loc; | ||
1559 | - gint day_xspace; | ||
1560 | + /*gint day_xspace;*/ | ||
1561 | gint focus_width; | ||
1562 | + gboolean hildonlike; | ||
1563 | |||
1564 | GtkCalendarPrivateData *private_data; | ||
1565 | PangoLayout *layout; | ||
1566 | @@ -2083,6 +2406,8 @@ | ||
1567 | calendar = GTK_CALENDAR (widget); | ||
1568 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1569 | |||
1570 | + if (private_data->main_win == NULL) return; | ||
1571 | + | ||
1572 | /* | ||
1573 | * Handle freeze/thaw functionality | ||
1574 | */ | ||
1575 | @@ -2092,25 +2417,25 @@ | ||
1576 | private_data->dirty_main = 1; | ||
1577 | return; | ||
1578 | } | ||
1579 | - | ||
1580 | - gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL); | ||
1581 | |||
1582 | - day_height = row_height (calendar); | ||
1583 | - | ||
1584 | - day_xspace = private_data->day_width - private_data->max_day_char_width*2; | ||
1585 | + gtk_widget_style_get (widget, "focus-line-width", &focus_width, | ||
1586 | + "hildonlike", &hildonlike, NULL); | ||
1587 | + | ||
1588 | + /*day_height = row_height (calendar)*/; | ||
1589 | + /*day_xspace = HILDON_DAY_WIDTH private_data->day_width - private_data->max_day_char_width*2*/; | ||
1590 | |||
1591 | day = calendar->day[row][col]; | ||
1592 | - | ||
1593 | + | ||
1594 | x_left = left_x_for_column (calendar, col); | ||
1595 | - x_loc = x_left + private_data->day_width / 2 + private_data->max_day_char_width; | ||
1596 | + /*x_loc = x_left + private_data->day_width / 2 + private_data->max_day_char_width;*/ | ||
1597 | |||
1598 | y_top = top_y_for_row (calendar, row); | ||
1599 | |||
1600 | gdk_window_clear_area (private_data->main_win, x_left, y_top, | ||
1601 | - private_data->day_width, day_height); | ||
1602 | + HILDON_DAY_WIDTH, HILDON_DAY_HEIGHT); | ||
1603 | |||
1604 | gc = calendar->gc; | ||
1605 | - | ||
1606 | + | ||
1607 | if (calendar->day_month[row][col] == MONTH_PREV) | ||
1608 | { | ||
1609 | gdk_gc_set_foreground (gc, PREV_MONTH_COLOR (GTK_WIDGET (calendar))); | ||
1610 | @@ -2123,44 +2448,43 @@ | ||
1611 | { | ||
1612 | /* | ||
1613 | if (calendar->highlight_row == row && calendar->highlight_col == col) | ||
1614 | - { | ||
1615 | - gdk_gc_set_foreground (gc, HIGHLIGHT_BACK_COLOR (GTK_WIDGET (calendar))); | ||
1616 | - gdk_draw_rectangle (private_data->main_win, gc, TRUE, x_left, y_top, | ||
1617 | + { | ||
1618 | + gdk_gc_set_foreground (gc, HIGHLIGHT_BACK_COLOR (GTK_WIDGET (calendar))); | ||
1619 | + gdk_draw_rectangle (private_data->main_win, gc, TRUE, x_left, y_top, | ||
1620 | private_data->day_width, day_height); | ||
1621 | - } | ||
1622 | + } | ||
1623 | */ | ||
1624 | if (calendar->selected_day == day) | ||
1625 | - { | ||
1626 | - gdk_gc_set_foreground (gc, SELECTED_BG_COLOR (GTK_WIDGET (calendar))); | ||
1627 | - gdk_draw_rectangle (private_data->main_win, gc, TRUE, x_left, y_top, | ||
1628 | - private_data->day_width, day_height); | ||
1629 | - } | ||
1630 | - | ||
1631 | + { | ||
1632 | + /* Hildon: use custom graphics */ | ||
1633 | + if (hildonlike) | ||
1634 | + { | ||
1635 | + gtk_paint_box( GTK_WIDGET (calendar)->style, | ||
1636 | + private_data->main_win, | ||
1637 | + GTK_STATE_NORMAL, | ||
1638 | + GTK_SHADOW_NONE, NULL, | ||
1639 | + GTK_WIDGET (calendar), "active-day", | ||
1640 | + x_left, y_top, | ||
1641 | + HILDON_DAY_WIDTH, | ||
1642 | + HILDON_DAY_HEIGHT); | ||
1643 | + } | ||
1644 | + else | ||
1645 | + { | ||
1646 | + gdk_gc_set_foreground (gc, SELECTED_BG_COLOR (GTK_WIDGET (calendar))); | ||
1647 | + gdk_draw_rectangle (private_data->main_win, gc, TRUE, x_left, y_top, | ||
1648 | + HILDON_DAY_WIDTH, HILDON_DAY_HEIGHT); | ||
1649 | + } | ||
1650 | + } | ||
1651 | if (calendar->marked_date[day-1]) | ||
1652 | - gdk_gc_set_foreground (gc, MARKED_COLOR (GTK_WIDGET (calendar))); | ||
1653 | + gdk_gc_set_foreground (gc, MARKED_COLOR (GTK_WIDGET (calendar))); | ||
1654 | else | ||
1655 | - gdk_gc_set_foreground (gc, NORMAL_DAY_COLOR (GTK_WIDGET (calendar))); | ||
1656 | - | ||
1657 | + gdk_gc_set_foreground (gc, NORMAL_DAY_COLOR (GTK_WIDGET (calendar))); | ||
1658 | if (calendar->selected_day == day) | ||
1659 | - gdk_gc_set_foreground (gc, SELECTED_FG_COLOR (GTK_WIDGET (calendar))); | ||
1660 | + gdk_gc_set_foreground (gc, SELECTED_FG_COLOR (GTK_WIDGET (calendar))); | ||
1661 | else | ||
1662 | - gdk_gc_set_foreground (gc, & (GTK_WIDGET (calendar)->style->fg[GTK_WIDGET_STATE (calendar)])); | ||
1663 | - } | ||
1664 | - | ||
1665 | - | ||
1666 | - g_snprintf (buffer, sizeof (buffer), "%d", day); | ||
1667 | - layout = gtk_widget_create_pango_layout (widget, buffer); | ||
1668 | - pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1669 | + gdk_gc_set_foreground (gc, & (GTK_WIDGET (calendar)->style->fg[GTK_WIDGET_STATE (calendar)])); | ||
1670 | |||
1671 | - x_loc -= logical_rect.width; | ||
1672 | - | ||
1673 | - y_loc = y_top + (day_height - logical_rect.height) / 2; | ||
1674 | - gdk_draw_layout (private_data->main_win, gc, | ||
1675 | - x_loc, y_loc, layout); | ||
1676 | - if (calendar->marked_date[day-1] | ||
1677 | - && calendar->day_month[row][col] == MONTH_CURRENT) | ||
1678 | - gdk_draw_layout (private_data->main_win, gc, | ||
1679 | - x_loc-1, y_loc, layout); | ||
1680 | + } | ||
1681 | |||
1682 | if (GTK_WIDGET_HAS_FOCUS (calendar) | ||
1683 | && calendar->focus_row == row && calendar->focus_col == col) | ||
1684 | @@ -2168,9 +2492,9 @@ | ||
1685 | GtkStateType state; | ||
1686 | |||
1687 | if (calendar->selected_day == day) | ||
1688 | - state = GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE; | ||
1689 | + state = GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE; | ||
1690 | else | ||
1691 | - state = GTK_STATE_NORMAL; | ||
1692 | + state = GTK_STATE_NORMAL; | ||
1693 | |||
1694 | gtk_paint_focus (widget->style, | ||
1695 | private_data->main_win, | ||
1696 | @@ -2178,10 +2502,29 @@ | ||
1697 | ? GTK_STATE_SELECTED : GTK_STATE_NORMAL, | ||
1698 | NULL, widget, "calendar-day", | ||
1699 | x_left, y_top, | ||
1700 | - private_data->day_width, | ||
1701 | - day_height); | ||
1702 | + HILDON_DAY_WIDTH, | ||
1703 | + HILDON_DAY_HEIGHT); | ||
1704 | } | ||
1705 | |||
1706 | + /* Hildon: paint green indicator for current day */ | ||
1707 | + if (hildonlike && (day == private_data->current_day && calendar->selected_day != | ||
1708 | + private_data->current_day) && (calendar->day_month[row][col] == MONTH_CURRENT)) | ||
1709 | + gtk_calendar_check_current_date (calendar, x_left, y_top); | ||
1710 | + | ||
1711 | + g_snprintf (buffer, sizeof (buffer), "%d", day); | ||
1712 | + layout = gtk_widget_create_pango_layout (widget, buffer); | ||
1713 | + pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1714 | + | ||
1715 | + x_loc = x_left + (HILDON_DAY_WIDTH - logical_rect.width) / 2; | ||
1716 | + y_loc = y_top + (HILDON_DAY_HEIGHT - logical_rect.height) / 2; | ||
1717 | + | ||
1718 | + gdk_draw_layout (private_data->main_win, gc, | ||
1719 | + x_loc, y_loc, layout); | ||
1720 | + if (calendar->marked_date[day-1] | ||
1721 | + && calendar->day_month[row][col] == MONTH_CURRENT) | ||
1722 | + gdk_draw_layout (private_data->main_win, gc, | ||
1723 | + x_loc-1, y_loc, layout); | ||
1724 | + | ||
1725 | g_object_unref (layout); | ||
1726 | } | ||
1727 | |||
1728 | @@ -2195,7 +2538,7 @@ | ||
1729 | |||
1730 | g_return_if_fail (GTK_IS_CALENDAR (widget)); | ||
1731 | g_return_if_fail (widget->window != NULL); | ||
1732 | - | ||
1733 | + | ||
1734 | calendar = GTK_CALENDAR (widget); | ||
1735 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1736 | |||
1737 | @@ -2208,7 +2551,7 @@ | ||
1738 | gdk_window_clear (private_data->main_win); | ||
1739 | |||
1740 | /* gtk_calendar_compute_days (calendar); */ /* REMOVE later */ | ||
1741 | - | ||
1742 | + | ||
1743 | for (col = 0; col < 7; col++) | ||
1744 | for (row = 0; row < 6; row++) | ||
1745 | gtk_calendar_paint_day (widget, row, col); | ||
1746 | @@ -2453,9 +2796,24 @@ | ||
1747 | guint month, | ||
1748 | guint year) | ||
1749 | { | ||
1750 | + gboolean hildonlike; | ||
1751 | + guint min_year, max_year; | ||
1752 | + | ||
1753 | g_return_val_if_fail (GTK_IS_CALENDAR (calendar), FALSE); | ||
1754 | g_return_val_if_fail (month <= 11, FALSE); | ||
1755 | |||
1756 | + gtk_widget_style_get(GTK_WIDGET (calendar), "hildonlike", &hildonlike, | ||
1757 | + "max-year", &max_year, "min-year", | ||
1758 | + &min_year, NULL); | ||
1759 | + | ||
1760 | + if (hildonlike) | ||
1761 | + { | ||
1762 | + if (year >= max_year) | ||
1763 | + year = max_year; | ||
1764 | + else if (year <= min_year) | ||
1765 | + year = min_year; | ||
1766 | + } | ||
1767 | + | ||
1768 | calendar->month = month; | ||
1769 | calendar->year = year; | ||
1770 | |||
1771 | @@ -2478,12 +2836,30 @@ | ||
1772 | gtk_calendar_select_day (GtkCalendar *calendar, | ||
1773 | guint day) | ||
1774 | { | ||
1775 | - g_return_if_fail (GTK_IS_CALENDAR (calendar)); | ||
1776 | - g_return_if_fail (day <= 31); | ||
1777 | - | ||
1778 | - /* gtk_calendar_compute_days (calendar); */ | ||
1779 | - | ||
1780 | - /* Deselect the old day */ | ||
1781 | + gint row, col; | ||
1782 | + GtkCalendarPrivateData *priv; | ||
1783 | + g_return_if_fail (GTK_IS_CALENDAR (calendar)); | ||
1784 | + g_return_if_fail (day <= 31); | ||
1785 | + priv = GTK_CALENDAR_PRIVATE_DATA (calendar); | ||
1786 | + | ||
1787 | + for (row = 0; row < 6; row ++) | ||
1788 | + for (col = 0; col < 7; col++) | ||
1789 | + { | ||
1790 | + if (calendar->day_month[row][col] == MONTH_CURRENT | ||
1791 | + && calendar->day[row][col] == day) | ||
1792 | + { | ||
1793 | + calendar->focus_row = row; | ||
1794 | + calendar->focus_col = col; | ||
1795 | + } | ||
1796 | + } | ||
1797 | + | ||
1798 | + /* gtk_calendar_compute_days (calendar); */ | ||
1799 | + | ||
1800 | + if (calendar->month != priv->current_month || | ||
1801 | + calendar->year != priv->current_year) | ||
1802 | + gtk_calendar_unmark_day (calendar, priv->current_day); | ||
1803 | + | ||
1804 | + /* Deselect the old day */ | ||
1805 | if (calendar->selected_day > 0) | ||
1806 | { | ||
1807 | gint selected_day; | ||
1808 | @@ -2491,20 +2867,25 @@ | ||
1809 | selected_day = calendar->selected_day; | ||
1810 | calendar->selected_day = 0; | ||
1811 | if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar))) | ||
1812 | - gtk_calendar_paint_day_num (GTK_WIDGET (calendar), selected_day); | ||
1813 | + { | ||
1814 | + gtk_calendar_paint_day_num (GTK_WIDGET (calendar), selected_day); | ||
1815 | + } | ||
1816 | } | ||
1817 | |||
1818 | calendar->selected_day = day; | ||
1819 | |||
1820 | + /*printf("Selected day = %d\n", day);*/ | ||
1821 | + | ||
1822 | /* Select the new day */ | ||
1823 | if (day != 0) | ||
1824 | { | ||
1825 | if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar))) | ||
1826 | - gtk_calendar_paint_day_num (GTK_WIDGET (calendar), day); | ||
1827 | + { | ||
1828 | + gtk_calendar_paint_day_num (GTK_WIDGET (calendar), day); | ||
1829 | + } | ||
1830 | } | ||
1831 | - | ||
1832 | + | ||
1833 | g_object_notify (G_OBJECT (calendar), "day"); | ||
1834 | - | ||
1835 | g_signal_emit (calendar, | ||
1836 | gtk_calendar_signals[DAY_SELECTED_SIGNAL], | ||
1837 | 0); | ||
1838 | @@ -2560,17 +2941,16 @@ | ||
1839 | gtk_calendar_mark_day (GtkCalendar *calendar, | ||
1840 | guint day) | ||
1841 | { | ||
1842 | - g_return_val_if_fail (GTK_IS_CALENDAR (calendar), FALSE); | ||
1843 | - | ||
1844 | - if (day >= 1 && day <= 31 && calendar->marked_date[day-1] == FALSE) | ||
1845 | - { | ||
1846 | - calendar->marked_date[day - 1] = TRUE; | ||
1847 | - calendar->num_marked_dates++; | ||
1848 | - } | ||
1849 | - if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar))) | ||
1850 | - { | ||
1851 | - gtk_calendar_paint_main (GTK_WIDGET (calendar)); | ||
1852 | - } | ||
1853 | + g_return_val_if_fail (GTK_IS_CALENDAR (calendar), FALSE); | ||
1854 | + if (day >= 1 && day <= 31 && calendar->marked_date[day-1] == FALSE) | ||
1855 | + { | ||
1856 | + calendar->marked_date[day - 1] = TRUE; | ||
1857 | + calendar->num_marked_dates++; | ||
1858 | + } | ||
1859 | + if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (calendar))) | ||
1860 | + { | ||
1861 | + gtk_calendar_paint_main (GTK_WIDGET (calendar)); | ||
1862 | + } | ||
1863 | |||
1864 | return TRUE; | ||
1865 | } | ||
1866 | @@ -2629,14 +3009,15 @@ | ||
1867 | gtk_calendar_set_year_next (calendar); | ||
1868 | break; | ||
1869 | case ARROW_MONTH_LEFT: | ||
1870 | - gtk_calendar_set_month_prev (calendar); | ||
1871 | - break; | ||
1872 | + gtk_calendar_set_month_prev (calendar); | ||
1873 | + break; | ||
1874 | case ARROW_MONTH_RIGHT: | ||
1875 | gtk_calendar_set_month_next (calendar); | ||
1876 | break; | ||
1877 | default:; | ||
1878 | /* do nothing */ | ||
1879 | } | ||
1880 | + gtk_calendar_select_and_focus_day(calendar, calendar->selected_day); | ||
1881 | } | ||
1882 | |||
1883 | static gboolean | ||
1884 | @@ -2645,6 +3026,11 @@ | ||
1885 | GtkCalendar *calendar = data; | ||
1886 | GtkCalendarPrivateData *private_data = GTK_CALENDAR_PRIVATE_DATA (calendar); | ||
1887 | gboolean retval = FALSE; | ||
1888 | + GtkSettings *settings; | ||
1889 | + guint timeout; | ||
1890 | + | ||
1891 | + settings = gtk_settings_get_default (); | ||
1892 | + g_object_get (settings, "gtk-update-timeout", &timeout, NULL); | ||
1893 | |||
1894 | GDK_THREADS_ENTER (); | ||
1895 | |||
1896 | @@ -2655,7 +3041,7 @@ | ||
1897 | if (private_data->need_timer) | ||
1898 | { | ||
1899 | private_data->need_timer = FALSE; | ||
1900 | - private_data->timer = g_timeout_add (CALENDAR_TIMER_DELAY, | ||
1901 | + private_data->timer = g_timeout_add (/*CALENDAR_TIMER_DELAY*/timeout, | ||
1902 | (GSourceFunc) calendar_timer, | ||
1903 | (gpointer) calendar); | ||
1904 | } | ||
1905 | @@ -2673,13 +3059,18 @@ | ||
1906 | gint click_child) | ||
1907 | { | ||
1908 | GtkCalendarPrivateData *private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1909 | + GtkSettings *settings; | ||
1910 | + guint timeout; | ||
1911 | |||
1912 | + settings = gtk_settings_get_default (); | ||
1913 | + g_object_get (settings, "gtk-initial-timeout", &timeout, NULL); | ||
1914 | + | ||
1915 | private_data->click_child = click_child; | ||
1916 | |||
1917 | if (!private_data->timer) | ||
1918 | { | ||
1919 | private_data->need_timer = TRUE; | ||
1920 | - private_data->timer = g_timeout_add (CALENDAR_INITIAL_TIMER_DELAY, | ||
1921 | + private_data->timer = g_timeout_add (/*CALENDAR_INITIAL_TIMER_DELAY*/timeout, | ||
1922 | calendar_timer, | ||
1923 | (gpointer) widget); | ||
1924 | } | ||
1925 | @@ -2738,12 +3129,38 @@ | ||
1926 | GtkCalendar *calendar; | ||
1927 | GtkCalendarPrivateData *private_data; | ||
1928 | gint arrow = -1; | ||
1929 | - | ||
1930 | + gboolean hildonlike; | ||
1931 | + gint min_year, max_year; | ||
1932 | + | ||
1933 | calendar = GTK_CALENDAR (widget); | ||
1934 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1935 | + | ||
1936 | + gtk_widget_style_get(widget, "hildonlike", &hildonlike, | ||
1937 | + "min-year", &min_year, "max-year", &max_year, NULL); | ||
1938 | |||
1939 | - if (event->window == private_data->main_win) | ||
1940 | - gtk_calendar_main_button (widget, event); | ||
1941 | + if (!hildonlike) | ||
1942 | + { | ||
1943 | + if (event->window == private_data->main_win) | ||
1944 | + gtk_calendar_main_button (widget, event); | ||
1945 | + } | ||
1946 | + else if (hildonlike && (event->window == private_data->main_win)) | ||
1947 | + { | ||
1948 | + gint x = (gint) (event->x); | ||
1949 | + gint y = (gint) (event->y); | ||
1950 | + gint row = row_from_y (calendar, y); | ||
1951 | + gint col = column_from_x (calendar, x); | ||
1952 | + private_data->pressed_day = calendar->day[row][col]; | ||
1953 | + | ||
1954 | + if ((calendar->year == min_year && calendar->month == 0 && calendar->day_month[row][col] == MONTH_PREV) || | ||
1955 | + (calendar->year == max_year && calendar->month == 11 && calendar->day_month[row][col] == MONTH_NEXT)) | ||
1956 | + {} | ||
1957 | + else if (calendar->day_month[row][col] == MONTH_CURRENT) | ||
1958 | + gtk_calendar_select_and_focus_day (calendar, private_data->pressed_day); | ||
1959 | + | ||
1960 | + /* Remember month where button was pressed */ | ||
1961 | + private_data->pressed_month = calendar->month; | ||
1962 | + private_data->slide_stylus = TRUE; | ||
1963 | + } | ||
1964 | |||
1965 | if (!GTK_WIDGET_HAS_FOCUS (widget)) | ||
1966 | gtk_widget_grab_focus (widget); | ||
1967 | @@ -2766,7 +3183,7 @@ | ||
1968 | } | ||
1969 | } | ||
1970 | |||
1971 | - return FALSE; | ||
1972 | + return TRUE; | ||
1973 | } | ||
1974 | |||
1975 | static gboolean | ||
1976 | @@ -2775,16 +3192,45 @@ | ||
1977 | { | ||
1978 | GtkCalendar *calendar; | ||
1979 | GtkCalendarPrivateData *private_data; | ||
1980 | + gboolean hildonlike; | ||
1981 | |||
1982 | calendar = GTK_CALENDAR (widget); | ||
1983 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
1984 | |||
1985 | + gtk_widget_style_get(widget, "hildonlike", &hildonlike, | ||
1986 | + NULL); | ||
1987 | + | ||
1988 | + if (hildonlike && (event->window == private_data->main_win)) | ||
1989 | + { | ||
1990 | + gtk_calendar_main_button (widget, event); | ||
1991 | + gint x = (gint) (event->x); | ||
1992 | + gint y = (gint) (event->y); | ||
1993 | + gint row = row_from_y (calendar, y); | ||
1994 | + gint col = column_from_x (calendar, x); | ||
1995 | + private_data->prev_col = -1; | ||
1996 | + private_data->prev_row = -1; | ||
1997 | + | ||
1998 | + if ((private_data->pressed_day == calendar->day[row][col]) && | ||
1999 | + (private_data->pressed_month == calendar->month)) | ||
2000 | + { | ||
2001 | + if (!private_data->is_bad_day) | ||
2002 | + { | ||
2003 | + g_signal_emit (calendar, gtk_calendar_signals[SELECTED_DATE_SIGNAL], 0); | ||
2004 | + } | ||
2005 | + else | ||
2006 | + { | ||
2007 | + private_data->is_bad_day = FALSE; | ||
2008 | + } | ||
2009 | + } | ||
2010 | + private_data->slide_stylus = FALSE; | ||
2011 | + } | ||
2012 | + | ||
2013 | if (event->button == 1) | ||
2014 | { | ||
2015 | stop_spinning (widget); | ||
2016 | |||
2017 | if (private_data->in_drag) | ||
2018 | - private_data->in_drag = 0; | ||
2019 | + private_data->in_drag = 0; | ||
2020 | } | ||
2021 | |||
2022 | return TRUE; | ||
2023 | @@ -2799,15 +3245,42 @@ | ||
2024 | gint event_x, event_y; | ||
2025 | gint row, col; | ||
2026 | gint old_row, old_col; | ||
2027 | + gboolean hildonlike; | ||
2028 | |||
2029 | calendar = GTK_CALENDAR (widget); | ||
2030 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
2031 | event_x = (gint) (event->x); | ||
2032 | event_y = (gint) (event->y); | ||
2033 | - | ||
2034 | + | ||
2035 | + gtk_widget_style_get(widget, "hildonlike", &hildonlike, | ||
2036 | + NULL); | ||
2037 | + | ||
2038 | if (event->window == private_data->main_win) | ||
2039 | { | ||
2040 | - | ||
2041 | + if (hildonlike) | ||
2042 | + { | ||
2043 | + /* Hildon: make active day to move, when stylus is slided */ | ||
2044 | + if (private_data->slide_stylus) | ||
2045 | + { | ||
2046 | + gint c_row = row_from_y (calendar, event_y); | ||
2047 | + gint c_col = column_from_x (calendar, event_x); | ||
2048 | + | ||
2049 | + if (calendar->day_month[c_row][c_col] == MONTH_PREV || | ||
2050 | + calendar->day_month[c_row][c_col] == MONTH_NEXT) | ||
2051 | + { } | ||
2052 | + else if ((private_data->prev_row != c_row || private_data->prev_col != c_col) && | ||
2053 | + (calendar->highlight_row != -1 && calendar->highlight_col != -1)) | ||
2054 | + { | ||
2055 | + gtk_calendar_select_and_focus_day (calendar, | ||
2056 | + calendar->day[c_row][c_col]); | ||
2057 | + /* Update passive focus indicators work weekday number and name */ | ||
2058 | + gtk_calendar_paint_week_numbers (GTK_WIDGET (calendar)); | ||
2059 | + gtk_calendar_paint_day_names (GTK_WIDGET (calendar)); | ||
2060 | + } | ||
2061 | + private_data->prev_col = c_col; | ||
2062 | + private_data->prev_row = c_row; | ||
2063 | + } | ||
2064 | + } | ||
2065 | if (private_data->in_drag) | ||
2066 | { | ||
2067 | if (gtk_drag_check_threshold (widget, | ||
2068 | @@ -2847,7 +3320,7 @@ | ||
2069 | calendar->highlight_col = col; | ||
2070 | |||
2071 | if (row > -1 && col > -1) | ||
2072 | - gtk_calendar_paint_day (widget, row, col); | ||
2073 | + gtk_calendar_paint_day (widget, row, col); | ||
2074 | } | ||
2075 | } | ||
2076 | } | ||
2077 | @@ -2863,7 +3336,7 @@ | ||
2078 | |||
2079 | calendar = GTK_CALENDAR (widget); | ||
2080 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
2081 | - | ||
2082 | + | ||
2083 | if (event->window == private_data->arrow_win[ARROW_MONTH_LEFT]) | ||
2084 | { | ||
2085 | private_data->arrow_state[ARROW_MONTH_LEFT] = GTK_STATE_PRELIGHT; | ||
2086 | @@ -2902,7 +3375,7 @@ | ||
2087 | |||
2088 | calendar = GTK_CALENDAR (widget); | ||
2089 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
2090 | - | ||
2091 | + | ||
2092 | if (event->window == private_data->main_win) | ||
2093 | { | ||
2094 | row = calendar->highlight_row; | ||
2095 | @@ -2910,7 +3383,7 @@ | ||
2096 | calendar->highlight_row = -1; | ||
2097 | calendar->highlight_col = -1; | ||
2098 | if (row > -1 && col > -1) | ||
2099 | - gtk_calendar_paint_day (widget, row, col); | ||
2100 | + gtk_calendar_paint_day (widget, row, col); | ||
2101 | } | ||
2102 | |||
2103 | if (event->window == private_data->arrow_win[ARROW_MONTH_LEFT]) | ||
2104 | @@ -2949,10 +3422,14 @@ | ||
2105 | GdkGC *gc; | ||
2106 | GtkCalendar *calendar; | ||
2107 | gint state; | ||
2108 | - gint width, height; | ||
2109 | + gint max_year, min_year; | ||
2110 | + gboolean hildonlike; | ||
2111 | +/* gint width, height;*/ | ||
2112 | |||
2113 | calendar = GTK_CALENDAR (widget); | ||
2114 | private_data = GTK_CALENDAR_PRIVATE_DATA (widget); | ||
2115 | + gtk_widget_style_get (widget, "hildonlike", &hildonlike, "max-year", | ||
2116 | + &max_year, "min-year", &min_year, NULL); | ||
2117 | |||
2118 | if (private_data->freeze_count) | ||
2119 | { | ||
2120 | @@ -2965,23 +3442,81 @@ | ||
2121 | state = private_data->arrow_state[arrow]; | ||
2122 | gc = calendar->gc; | ||
2123 | |||
2124 | - gdk_window_clear (window); | ||
2125 | +/* gdk_window_clear (window);*/ | ||
2126 | gdk_window_set_background (window, &(widget)->style->bg[state]); | ||
2127 | - gdk_drawable_get_size (window, &width, &height); | ||
2128 | - gdk_window_clear_area (window, | ||
2129 | +/* gdk_drawable_get_size (window, &width, &height);*/ | ||
2130 | +/* gdk_window_clear_area (window, | ||
2131 | 0,0, | ||
2132 | - width,height); | ||
2133 | - if (arrow == ARROW_MONTH_LEFT || arrow == ARROW_YEAR_LEFT) | ||
2134 | - gtk_paint_arrow (widget->style, window, state, | ||
2135 | + width,height);*/ | ||
2136 | + | ||
2137 | + gdk_window_clear(window); | ||
2138 | + | ||
2139 | + /* Hildon: added support for dimmed arrows */ | ||
2140 | + if (hildonlike && (calendar->year <= min_year || calendar->year >= max_year)) | ||
2141 | + { | ||
2142 | + if (calendar->year <= min_year) | ||
2143 | + { | ||
2144 | + if (arrow == ARROW_YEAR_LEFT) | ||
2145 | + gtk_paint_arrow (widget->style, window, GTK_STATE_INSENSITIVE, | ||
2146 | + GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2147 | + GTK_ARROW_LEFT, TRUE, | ||
2148 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2149 | + else if (arrow == ARROW_YEAR_RIGHT || arrow == ARROW_MONTH_RIGHT) | ||
2150 | + gtk_paint_arrow (widget->style, window, state, | ||
2151 | + GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2152 | + GTK_ARROW_RIGHT, TRUE, | ||
2153 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2154 | + else if (arrow == ARROW_MONTH_LEFT && calendar->month != 0) | ||
2155 | + gtk_paint_arrow (widget->style, window, state, | ||
2156 | + GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2157 | + GTK_ARROW_LEFT, TRUE, | ||
2158 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2159 | + else if (arrow == ARROW_MONTH_LEFT && !calendar->month) | ||
2160 | + gtk_paint_arrow (widget->style, window, GTK_STATE_INSENSITIVE, | ||
2161 | + GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2162 | + GTK_ARROW_LEFT, TRUE, | ||
2163 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2164 | + } | ||
2165 | + else if (calendar->year >= max_year) | ||
2166 | + { | ||
2167 | + if (arrow == ARROW_YEAR_RIGHT) | ||
2168 | + gtk_paint_arrow (widget->style, window, GTK_STATE_INSENSITIVE, | ||
2169 | + GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2170 | + GTK_ARROW_RIGHT, TRUE, | ||
2171 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2172 | + else if (arrow == ARROW_YEAR_LEFT || arrow == ARROW_MONTH_LEFT) | ||
2173 | + gtk_paint_arrow (widget->style, window, state, | ||
2174 | GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2175 | GTK_ARROW_LEFT, TRUE, | ||
2176 | - width/2 - 3, height/2 - 4, 8, 8); | ||
2177 | - else | ||
2178 | - gtk_paint_arrow (widget->style, window, state, | ||
2179 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2180 | + else if (arrow == ARROW_MONTH_RIGHT && calendar->month != 11) | ||
2181 | + gtk_paint_arrow (widget->style, window, state, | ||
2182 | + GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2183 | + GTK_ARROW_RIGHT, TRUE, | ||
2184 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2185 | + else if (arrow == ARROW_MONTH_RIGHT && calendar->month == 11) | ||
2186 | + gtk_paint_arrow (widget->style, window, GTK_STATE_INSENSITIVE, | ||
2187 | + GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2188 | + GTK_ARROW_RIGHT, TRUE, | ||
2189 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2190 | + } | ||
2191 | + } | ||
2192 | + else | ||
2193 | + { | ||
2194 | + if (arrow == ARROW_MONTH_LEFT || arrow == ARROW_YEAR_LEFT) | ||
2195 | + gtk_paint_arrow (widget->style, window, state, | ||
2196 | + GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2197 | + GTK_ARROW_LEFT, TRUE, | ||
2198 | + /* width/2 - 3, height/2 - 4, 8, 8);*/ | ||
2199 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2200 | + else | ||
2201 | + gtk_paint_arrow (widget->style, window, state, | ||
2202 | GTK_SHADOW_OUT, NULL, widget, "calendar", | ||
2203 | GTK_ARROW_RIGHT, TRUE, | ||
2204 | - width/2 - 2, height/2 - 4, 8, 8); | ||
2205 | - } | ||
2206 | + /* width/2 - 2, height/2 - 4, 8, 8);*/ | ||
2207 | + 0, 0, HILDON_ARROW_WIDTH, HILDON_ARROW_HEIGHT); | ||
2208 | + } | ||
2209 | + } | ||
2210 | } | ||
2211 | |||
2212 | void | ||
2213 | @@ -3159,17 +3694,26 @@ | ||
2214 | GdkEventKey *event) | ||
2215 | { | ||
2216 | GtkCalendar *calendar; | ||
2217 | + GtkSettings *settings; | ||
2218 | gint return_val; | ||
2219 | gint old_focus_row; | ||
2220 | gint old_focus_col; | ||
2221 | gint row, col, day; | ||
2222 | - | ||
2223 | + gint min_year, max_year; | ||
2224 | + gboolean knav; | ||
2225 | + | ||
2226 | calendar = GTK_CALENDAR (widget); | ||
2227 | return_val = FALSE; | ||
2228 | |||
2229 | old_focus_row = calendar->focus_row; | ||
2230 | old_focus_col = calendar->focus_col; | ||
2231 | |||
2232 | + gtk_widget_style_get (widget, "max-year", &max_year, | ||
2233 | + "min-year", &min_year, NULL); | ||
2234 | + | ||
2235 | + settings = gtk_settings_get_default (); | ||
2236 | + g_object_get (settings, "hildon-keyboard-navigation", &knav, NULL); | ||
2237 | + | ||
2238 | switch (event->keyval) | ||
2239 | { | ||
2240 | case GDK_KP_Left: | ||
2241 | @@ -3179,10 +3723,41 @@ | ||
2242 | gtk_calendar_set_month_prev (calendar); | ||
2243 | else | ||
2244 | { | ||
2245 | - move_focus (calendar, -1); | ||
2246 | - gtk_calendar_paint_day (widget, old_focus_row, old_focus_col); | ||
2247 | - gtk_calendar_paint_day (widget, calendar->focus_row, | ||
2248 | - calendar->focus_col); | ||
2249 | + /* if we are at the first allowed day of the minimum year/month then do nothing */ | ||
2250 | + if (calendar->year == min_year && calendar->month == 0 && calendar->day_month[old_focus_row][old_focus_col-1] == MONTH_PREV) | ||
2251 | + { | ||
2252 | + g_signal_emit (calendar, gtk_calendar_signals[ERRONEOUS_DATE_SIGNAL], 0); | ||
2253 | + return TRUE; | ||
2254 | + } | ||
2255 | + else /* else normal */ | ||
2256 | + { | ||
2257 | + move_focus (calendar, -1); | ||
2258 | + if (!knav) | ||
2259 | + { | ||
2260 | + gtk_calendar_paint_day (widget, old_focus_row, old_focus_col); | ||
2261 | + gtk_calendar_paint_day (widget, calendar->focus_row, | ||
2262 | + calendar->focus_col); | ||
2263 | + } | ||
2264 | + else if (knav) | ||
2265 | + { | ||
2266 | + gint day_month = calendar->day_month[calendar->focus_row][calendar->focus_col]; | ||
2267 | + if (day_month == MONTH_CURRENT && calendar->selected_day != 1) | ||
2268 | + { | ||
2269 | + gtk_calendar_select_day(calendar, calendar->selected_day - 1); | ||
2270 | + } | ||
2271 | + else | ||
2272 | + { | ||
2273 | + if (calendar->month != 0) { | ||
2274 | + calendar->selected_day = month_length[leap (calendar->year)][calendar->month]; | ||
2275 | + } else { | ||
2276 | + calendar->selected_day = month_length[leap (calendar->year -1)][12]; | ||
2277 | + } | ||
2278 | + gtk_calendar_set_month_prev (calendar); | ||
2279 | + } | ||
2280 | + gtk_calendar_paint_week_numbers (GTK_WIDGET (calendar)); | ||
2281 | + gtk_calendar_paint_day_names (GTK_WIDGET (calendar)); | ||
2282 | + } | ||
2283 | + } | ||
2284 | } | ||
2285 | break; | ||
2286 | case GDK_KP_Right: | ||
2287 | @@ -3192,10 +3767,36 @@ | ||
2288 | gtk_calendar_set_month_next (calendar); | ||
2289 | else | ||
2290 | { | ||
2291 | - move_focus (calendar, 1); | ||
2292 | - gtk_calendar_paint_day (widget, old_focus_row, old_focus_col); | ||
2293 | - gtk_calendar_paint_day (widget, calendar->focus_row, | ||
2294 | - calendar->focus_col); | ||
2295 | + if (calendar->year == max_year && calendar->month == 11 && calendar->day_month[old_focus_row][old_focus_col+1] == MONTH_NEXT) | ||
2296 | + { | ||
2297 | + g_signal_emit (calendar, gtk_calendar_signals[ERRONEOUS_DATE_SIGNAL], 0); | ||
2298 | + return TRUE; | ||
2299 | + } | ||
2300 | + else | ||
2301 | + { | ||
2302 | + move_focus (calendar, 1); | ||
2303 | + if (!knav) | ||
2304 | + { | ||
2305 | + gtk_calendar_paint_day (widget, old_focus_row, old_focus_col); | ||
2306 | + gtk_calendar_paint_day (widget, calendar->focus_row, | ||
2307 | + calendar->focus_col); | ||
2308 | + } | ||
2309 | + else if (knav) | ||
2310 | + { | ||
2311 | + gint day_month = calendar->day_month[calendar->focus_row][calendar->focus_col]; | ||
2312 | + if (day_month == MONTH_CURRENT) | ||
2313 | + { | ||
2314 | + gtk_calendar_select_day (calendar, calendar->selected_day + 1); | ||
2315 | + } | ||
2316 | + else | ||
2317 | + { | ||
2318 | + calendar->selected_day = 1; | ||
2319 | + gtk_calendar_set_month_next (calendar); | ||
2320 | + } | ||
2321 | + gtk_calendar_paint_week_numbers (GTK_WIDGET (calendar)); | ||
2322 | + gtk_calendar_paint_day_names (GTK_WIDGET (calendar)); | ||
2323 | + } | ||
2324 | + } | ||
2325 | } | ||
2326 | break; | ||
2327 | case GDK_KP_Up: | ||
2328 | @@ -3205,11 +3806,48 @@ | ||
2329 | gtk_calendar_set_year_prev (calendar); | ||
2330 | else | ||
2331 | { | ||
2332 | - if (calendar->focus_row > 0) | ||
2333 | - calendar->focus_row--; | ||
2334 | - gtk_calendar_paint_day (widget, old_focus_row, old_focus_col); | ||
2335 | - gtk_calendar_paint_day (widget, calendar->focus_row, | ||
2336 | - calendar->focus_col); | ||
2337 | + if (calendar->year == min_year && calendar->month == 0 && calendar->day_month[old_focus_row-1][old_focus_col] == MONTH_PREV) | ||
2338 | + { | ||
2339 | + g_signal_emit (calendar, gtk_calendar_signals[ERRONEOUS_DATE_SIGNAL], 0); | ||
2340 | + return TRUE; | ||
2341 | + } | ||
2342 | + else | ||
2343 | + { | ||
2344 | + if (calendar->focus_row > 0) | ||
2345 | + calendar->focus_row--; | ||
2346 | + if (!knav) | ||
2347 | + { | ||
2348 | + gtk_calendar_paint_day (widget, old_focus_row, old_focus_col); | ||
2349 | + gtk_calendar_paint_day (widget, calendar->focus_row, | ||
2350 | + calendar->focus_col); | ||
2351 | + } | ||
2352 | + else if (knav) | ||
2353 | + { | ||
2354 | + gint day_month = calendar->day_month[calendar->focus_row][calendar->focus_col]; | ||
2355 | + if (day_month == MONTH_CURRENT) | ||
2356 | + { | ||
2357 | + if ((calendar->selected_day - 7) <= 0) | ||
2358 | + { | ||
2359 | + if (calendar->month != 0) | ||
2360 | + calendar->selected_day = month_length[leap (calendar->year)][calendar->month]; | ||
2361 | + else | ||
2362 | + calendar->selected_day = month_length[leap (calendar->year - 1)][12]; | ||
2363 | + gtk_calendar_set_month_prev (calendar); | ||
2364 | + } | ||
2365 | + else | ||
2366 | + { | ||
2367 | + gtk_calendar_select_day (calendar, calendar->selected_day - 7); | ||
2368 | + } | ||
2369 | + } | ||
2370 | + else | ||
2371 | + { | ||
2372 | + calendar->selected_day = calendar->day[calendar->focus_row][calendar->focus_col]; | ||
2373 | + gtk_calendar_set_month_prev (calendar); | ||
2374 | + } | ||
2375 | + gtk_calendar_paint_week_numbers (GTK_WIDGET (calendar)); | ||
2376 | + gtk_calendar_paint_day_names (GTK_WIDGET (calendar)); | ||
2377 | + } | ||
2378 | + } | ||
2379 | } | ||
2380 | break; | ||
2381 | case GDK_KP_Down: | ||
2382 | @@ -3219,12 +3857,49 @@ | ||
2383 | gtk_calendar_set_year_next (calendar); | ||
2384 | else | ||
2385 | { | ||
2386 | - if (calendar->focus_row < 5) | ||
2387 | - calendar->focus_row++; | ||
2388 | - gtk_calendar_paint_day (widget, old_focus_row, old_focus_col); | ||
2389 | - gtk_calendar_paint_day (widget, calendar->focus_row, | ||
2390 | - calendar->focus_col); | ||
2391 | + if (calendar->year == max_year && calendar->month == 11 && calendar->day_month[old_focus_row+1][old_focus_col] == MONTH_NEXT) | ||
2392 | + { | ||
2393 | + g_signal_emit (calendar, gtk_calendar_signals[ERRONEOUS_DATE_SIGNAL], 0); | ||
2394 | + return TRUE; | ||
2395 | + } | ||
2396 | + else | ||
2397 | + { | ||
2398 | + | ||
2399 | + if (calendar->focus_row < 5) | ||
2400 | + calendar->focus_row++; | ||
2401 | + if (!knav) | ||
2402 | + { | ||
2403 | + gtk_calendar_paint_day (widget, old_focus_row, old_focus_col); | ||
2404 | + gtk_calendar_paint_day (widget, calendar->focus_row, | ||
2405 | + calendar->focus_col); | ||
2406 | + } | ||
2407 | + else if (knav) | ||
2408 | + { | ||
2409 | + gint day_month = calendar->day_month[calendar->focus_row][calendar->focus_col]; | ||
2410 | + if (day_month == MONTH_CURRENT) | ||
2411 | + { | ||
2412 | + if ((calendar->selected_day + 7) > | ||
2413 | + month_length[leap (calendar->year)][calendar->month + 1]) | ||
2414 | + { | ||
2415 | + calendar->selected_day = 1; | ||
2416 | + gtk_calendar_set_month_next (calendar); | ||
2417 | + } | ||
2418 | + else | ||
2419 | + { | ||
2420 | + gtk_calendar_select_day (calendar, calendar->selected_day + 7); | ||
2421 | + } | ||
2422 | + } | ||
2423 | + else | ||
2424 | + { | ||
2425 | + calendar->selected_day = calendar->day[calendar->focus_row][calendar->focus_col]; | ||
2426 | + gtk_calendar_set_month_next (calendar); | ||
2427 | + } | ||
2428 | + gtk_calendar_paint_week_numbers (GTK_WIDGET (calendar)); | ||
2429 | + gtk_calendar_paint_day_names (GTK_WIDGET (calendar)); | ||
2430 | + } | ||
2431 | + } | ||
2432 | } | ||
2433 | + | ||
2434 | break; | ||
2435 | case GDK_KP_Space: | ||
2436 | case GDK_space: | ||
2437 | @@ -3545,3 +4220,27 @@ | ||
2438 | gtk_calendar_select_day (calendar, day); | ||
2439 | g_object_thaw_notify (G_OBJECT (calendar)); | ||
2440 | } | ||
2441 | + | ||
2442 | +/* This function return TRUE if we should mark date and FALSE | ||
2443 | + * otherwise | ||
2444 | + */ | ||
2445 | +static void | ||
2446 | +gtk_calendar_check_current_date (GtkCalendar *calendar, gint x, gint y) | ||
2447 | +{ | ||
2448 | + GtkCalendarPrivateData *private_data; | ||
2449 | + | ||
2450 | + private_data = GTK_CALENDAR_PRIVATE_DATA (calendar); | ||
2451 | + | ||
2452 | + if (calendar->month == private_data->current_month && | ||
2453 | + calendar->year == private_data->current_year) | ||
2454 | + { | ||
2455 | + gtk_paint_box( GTK_WIDGET (calendar)->style, | ||
2456 | + private_data->main_win, | ||
2457 | + GTK_STATE_NORMAL, | ||
2458 | + GTK_SHADOW_NONE, NULL, | ||
2459 | + GTK_WIDGET (calendar), "current-day", | ||
2460 | + x, y, | ||
2461 | + HILDON_DAY_WIDTH, | ||
2462 | + HILDON_DAY_HEIGHT); | ||
2463 | + } | ||
2464 | +} | ||