[evolution/webkit] Bug #243938 - Clicking on week numbers changes work week to week view
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit] Bug #243938 - Clicking on week numbers changes work week to week view
- Date: Mon, 11 Jul 2011 14:43:50 +0000 (UTC)
commit f76af82d4448c0f09b1958f937b7251598a94e58
Author: Milan Crha <mcrha redhat com>
Date: Fri May 13 16:55:33 2011 +0200
Bug #243938 - Clicking on week numbers changes work week to week view
calendar/gui/gnome-cal.c | 5 +++
modules/calendar/e-cal-shell-view-private.c | 10 +++++-
widgets/misc/e-calendar-item.c | 44 ++++++++++++++++++++++++--
widgets/misc/e-calendar-item.h | 2 +
4 files changed, 55 insertions(+), 6 deletions(-)
---
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index eb7ed6e..3a4adad 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1843,6 +1843,11 @@ gnome_calendar_display_view (GnomeCalendar *gcal,
gcal->priv->date_navigator->calitem,
"preserve_day_when_moving", preserve_day, NULL);
+ /* keep week days selected as before for a work week view */
+ g_object_set (G_OBJECT (gcal->priv->date_navigator->calitem),
+ "keep_wdays_on_weeknum_click", view_type == GNOME_CAL_WORK_WEEK_VIEW,
+ NULL);
+
if (!gcal->priv->base_view_time)
start_time = time (NULL);
else
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 412e5a2..29a743b 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -92,7 +92,7 @@ cal_shell_view_date_navigator_selection_changed_cb (ECalShellView *cal_shell_vie
icaltimezone *timezone;
time_t start, end, new_time;
gboolean starts_on_week_start_day;
- gint new_days_shown;
+ gint new_days_shown, old_days_shown;
gint week_start_day;
cal_shell_content = cal_shell_view->priv->cal_shell_content;
@@ -136,6 +136,9 @@ cal_shell_view_date_navigator_selection_changed_cb (ECalShellView *cal_shell_vie
g_date_compare (&end_date, &new_end_date) == 0)
return;
+ old_days_shown =
+ g_date_get_julian (&end_date) -
+ g_date_get_julian (&start_date) + 1;
new_days_shown =
g_date_get_julian (&new_end_date) -
g_date_get_julian (&new_start_date) + 1;
@@ -156,7 +159,10 @@ cal_shell_view_date_navigator_selection_changed_cb (ECalShellView *cal_shell_vie
/* Switch views as appropriate, and change the number of
* days or weeks shown. */
- if (new_days_shown > 9) {
+ if (view_type == GNOME_CAL_WORK_WEEK_VIEW && old_days_shown == new_days_shown) {
+ /* keep the work week view when has same days shown */
+ switch_to = GNOME_CAL_WORK_WEEK_VIEW;
+ } else if (new_days_shown > 9) {
if (view_type != GNOME_CAL_LIST_VIEW) {
ECalendarView *calendar_view;
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index aa666f5..f58259b 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -211,6 +211,7 @@ enum {
PROP_MAXIMUM_COLUMNS,
PROP_WEEK_START_DAY,
PROP_SHOW_WEEK_NUMBERS,
+ PROP_KEEP_WDAYS_ON_WEEKNUM_CLICK,
PROP_MAXIMUM_DAYS_SELECTED,
PROP_DAYS_TO_START_WEEK_SELECTION,
PROP_MOVE_SELECTION_WHEN_MOVING,
@@ -446,6 +447,16 @@ e_calendar_item_class_init (ECalendarItemClass *class)
g_object_class_install_property (
object_class,
+ PROP_KEEP_WDAYS_ON_WEEKNUM_CLICK,
+ g_param_spec_boolean (
+ "keep_wdays_on_weeknum_click",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
PROP_MAXIMUM_DAYS_SELECTED,
g_param_spec_int (
"maximum_days_selected",
@@ -549,6 +560,7 @@ e_calendar_item_init (ECalendarItem *calitem)
calitem->cols = 0;
calitem->show_week_numbers = FALSE;
+ calitem->keep_wdays_on_weeknum_click = FALSE;
calitem->week_start_day = 0;
calitem->expand = TRUE;
calitem->max_days_selected = 1;
@@ -678,6 +690,9 @@ e_calendar_item_get_property (GObject *object,
case PROP_SHOW_WEEK_NUMBERS:
g_value_set_boolean (value, calitem->show_week_numbers);
return;
+ case PROP_KEEP_WDAYS_ON_WEEKNUM_CLICK:
+ g_value_set_boolean (value, calitem->keep_wdays_on_weeknum_click);
+ return;
case PROP_MAXIMUM_DAYS_SELECTED:
g_value_set_int (value, e_calendar_item_get_max_days_sel (calitem));
return;
@@ -811,6 +826,9 @@ e_calendar_item_set_property (GObject *object,
gnome_canvas_item_request_update (item);
}
return;
+ case PROP_KEEP_WDAYS_ON_WEEKNUM_CLICK:
+ calitem->keep_wdays_on_weeknum_click = g_value_get_boolean (value);
+ return;
case PROP_MAXIMUM_DAYS_SELECTED:
ivalue = g_value_get_int (value);
e_calendar_item_set_max_days_sel (calitem, ivalue);
@@ -2056,7 +2074,7 @@ static gboolean
e_calendar_item_button_press (ECalendarItem *calitem,
GdkEvent *event)
{
- gint month_offset, day;
+ gint month_offset, day, add_days = 0;
gboolean all_week, round_up_end = FALSE, round_down_start = FALSE;
if (event->button.button == 4)
@@ -2094,12 +2112,30 @@ e_calendar_item_button_press (ECalendarItem *calitem,
NULL, event->button.time) != 0)
return FALSE;
+ if (all_week && calitem->keep_wdays_on_weeknum_click) {
+ gint tmp_start_moff, tmp_start_day;
+
+ tmp_start_moff = calitem->selection_start_month_offset;
+ tmp_start_day = calitem->selection_start_day;
+ e_calendar_item_round_down_selection (calitem, &tmp_start_moff, &tmp_start_day);
+
+ e_calendar_item_round_down_selection (calitem, &month_offset, &day);
+ month_offset += calitem->selection_start_month_offset - tmp_start_moff;
+ day += calitem->selection_start_day - tmp_start_day;
+
+ /* keep same count of days selected */
+ add_days = e_calendar_item_get_inclusive_days (calitem, calitem->selection_start_month_offset, calitem->selection_start_day, calitem->selection_end_month_offset, calitem->selection_end_day) - 1;
+ }
+
calitem->selection_set = TRUE;
calitem->selection_start_month_offset = month_offset;
calitem->selection_start_day = day;
calitem->selection_end_month_offset = month_offset;
calitem->selection_end_day = day;
+ if (add_days > 0)
+ e_calendar_item_add_days_to_selection (calitem, add_days);
+
calitem->selection_real_start_month_offset = month_offset;
calitem->selection_real_start_day = day;
@@ -2107,7 +2143,7 @@ e_calendar_item_button_press (ECalendarItem *calitem,
calitem->selecting = TRUE;
calitem->selection_dragging_end = TRUE;
- if (all_week) {
+ if (all_week && !calitem->keep_wdays_on_weeknum_click) {
calitem->selection_from_full_week = TRUE;
round_up_end = TRUE;
}
@@ -2117,8 +2153,8 @@ e_calendar_item_button_press (ECalendarItem *calitem,
round_up_end = TRUE;
}
- /* Don't round up or down if we can't select a week or more. */
- if (calitem->max_days_selected < 7) {
+ /* Don't round up or down if we can't select a week or more. Or when keeping week days */
+ if (calitem->max_days_selected < 7 || (all_week && calitem->keep_wdays_on_weeknum_click)) {
round_down_start = FALSE;
round_up_end = FALSE;
}
diff --git a/widgets/misc/e-calendar-item.h b/widgets/misc/e-calendar-item.h
index 34fa3e2..0b07cc7 100644
--- a/widgets/misc/e-calendar-item.h
+++ b/widgets/misc/e-calendar-item.h
@@ -161,6 +161,8 @@ struct _ECalendarItem
/* Whether we show week nubers. */
gboolean show_week_numbers;
+ /* whether to keep same week days selected on week number click */
+ gboolean keep_wdays_on_weeknum_click;
/* The first day of the week, 0 (Monday) to 6 (Sunday). */
gint week_start_day;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]