diff options
author | Milan Crha <mcrha@redhat.com> | 2011-05-13 22:55:33 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:15 +0800 |
commit | a79844ab0d4d3b62b85fe8da73d08c80d9cdc375 (patch) | |
tree | 5ea711a5dc59e90a8416bdd0e735bc8465b48528 /widgets | |
parent | 757c1ded565f66497fe6e617cbb618ee81004328 (diff) | |
download | gsoc2013-evolution-a79844ab0d4d3b62b85fe8da73d08c80d9cdc375.tar gsoc2013-evolution-a79844ab0d4d3b62b85fe8da73d08c80d9cdc375.tar.gz gsoc2013-evolution-a79844ab0d4d3b62b85fe8da73d08c80d9cdc375.tar.bz2 gsoc2013-evolution-a79844ab0d4d3b62b85fe8da73d08c80d9cdc375.tar.lz gsoc2013-evolution-a79844ab0d4d3b62b85fe8da73d08c80d9cdc375.tar.xz gsoc2013-evolution-a79844ab0d4d3b62b85fe8da73d08c80d9cdc375.tar.zst gsoc2013-evolution-a79844ab0d4d3b62b85fe8da73d08c80d9cdc375.zip |
Bug #243938 - Clicking on week numbers changes work week to week view
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-calendar-item.c | 44 | ||||
-rw-r--r-- | widgets/misc/e-calendar-item.h | 2 |
2 files changed, 42 insertions, 4 deletions
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c index aa666f5267..f58259bdd8 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 34fa3e2be4..0b07cc7b25 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; |