[evolution-patches] Re: patch for calendar keyboard navigation (45776)



Rodrigo and JPR,
    Could you please review this patch?
    Thanks!
       Harry
   

wu yang wrote:
Hi
I had sent this patch for three times since 2 months ago.
Once I resended it, I had to modify something to adapt the current code :(
Could you take some time to review it?
It fixed bug 45776.
In DayView and WeekView, Alt + Arrow Keys with the event is selected,
Move a selected event through time lines.
Thanks

  

? stamp-h1 ? addressbook/gui/component/apps_evolution_addressbook-1.5.schemas ? calendar/gui/apps_evolution_calendar-1.5.schemas ? mail/evolution-mail-1.5.schemas ? shell/apps_evolution_shell-1.5.schemas Index: calendar/ChangeLog =================================================================== RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v retrieving revision 1.1999 diff -u -b -B -r1.1999 ChangeLog --- calendar/ChangeLog 5 Dec 2003 09:38:43 -0000 1.1999 +++ calendar/ChangeLog 7 Dec 2003 16:11:50 -0000 @@ -1,3 +1,36 @@ +2003-12-8 Andrew Wu <Yang Wu sun com> + + * gui/e-cal-view.h + add a new type "ECalViewMoveDirection". + add a new virtual method "event_move" for ECalView. + + * gui/e-cal-view.c + add a new signal "event_move" and it's key binding. + + * gui/e-day-view.h + add a new property "last_edited_comp_string" for EDayView; + + * gui/e-day-view.c + (e_day_view_event_move): + (e_day_view_change_event_time): + Use "Alt + Arrow" to move a selected event through time lines + or different days. + + * gui/e-week-view.h + add a new property "last_edited_comp_string" for EWeekView; + + * gui/e-week-view.c + (e_week_view_event_move): + (e_week_view_get_day_offset_of_event): + (e_week_view_scroll_a_step): + (e_week_view_change_event_time): + (e_week_view_move_selection_day): + (e_week_view_get_adjust_days_for_move_up): + (e_week_view_get_adjust_days_for_move_down): + (e_week_view_get_adjust_days_for_move_left): + (e_week_view_get_adjust_days_for_move_right): + Use "Alt + Arrow" to move a selected event through different days. + 2003-12-05 Yong Sun <Yong Sun Sun com> Fix for #51337 Index: calendar/gui/e-cal-view.c =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-view.c,v retrieving revision 1.26 diff -u -b -B -r1.26 e-cal-view.c --- calendar/gui/e-cal-view.c 3 Dec 2003 17:58:56 -0000 1.26 +++ calendar/gui/e-cal-view.c 7 Dec 2003 16:11:59 -0000 @@ -25,6 +25,8 @@ #include <string.h> #include <gtk/gtkimage.h> #include <gtk/gtkstock.h> +#include <gdk/gdkkeysyms.h> +#include <gtk/gtkbindings.h> #include <libgnome/gnome-i18n.h> #include <gal/util/e-util.h> #include "e-util/e-dialog-utils.h" @@ -97,6 +99,7 @@ TIMEZONE_CHANGED, EVENT_CHANGED, EVENT_ADDED, + EVENT_MOVE, LAST_SIGNAL }; @@ -145,9 +148,20 @@ { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GtkBindingSet *binding_set; parent_class = g_type_class_peek_parent (klass); + e_calendar_view_signals [EVENT_MOVE] = + g_signal_new ("event_move", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (ECalendarViewClass, event_move), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, + G_TYPE_INT); + /* Method override */ gobject_class->set_property = e_calendar_view_set_property; gobject_class->get_property = e_calendar_view_get_property; @@ -163,6 +177,55 @@ klass->set_selected_time_range = NULL; klass->get_visible_time_range = NULL; klass->update_query = NULL; + klass->event_move =NULL; + + /* + * Key bindings + */ + + binding_set = gtk_binding_set_by_class (klass); + + /* Alt+Arrow, move the editing event*/ + gtk_binding_entry_add_signal (binding_set, GDK_Up, + GDK_MOD1_MASK, + "event_move", 1, + G_TYPE_ENUM, + E_CAL_VIEW_MOVE_UP); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, + GDK_MOD1_MASK, + "event_move", 1, + G_TYPE_ENUM, + E_CAL_VIEW_MOVE_UP); + gtk_binding_entry_add_signal (binding_set, GDK_Down, + GDK_MOD1_MASK, + "event_move", 1, + G_TYPE_ENUM, + E_CAL_VIEW_MOVE_DOWN); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, + GDK_MOD1_MASK, + "event_move", 1, + G_TYPE_ENUM, + E_CAL_VIEW_MOVE_DOWN); + gtk_binding_entry_add_signal (binding_set, GDK_Left, + GDK_MOD1_MASK, + "event_move", 1, + G_TYPE_ENUM, + E_CAL_VIEW_MOVE_LEFT); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Left, + GDK_MOD1_MASK, + "event_move", 1, + G_TYPE_ENUM, + E_CAL_VIEW_MOVE_LEFT); + gtk_binding_entry_add_signal (binding_set, GDK_Right, + GDK_MOD1_MASK, + "event_move", 1, + G_TYPE_ENUM, + E_CAL_VIEW_MOVE_RIGHT); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Right, + GDK_MOD1_MASK, + "event_move", 1, + G_TYPE_ENUM, + E_CAL_VIEW_MOVE_RIGHT); g_object_class_install_property (gobject_class, PROP_MODEL, g_param_spec_object ("model", NULL, NULL, E_TYPE_CAL_MODEL, Index: calendar/gui/e-cal-view.h =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-view.h,v retrieving revision 1.17 diff -u -b -B -r1.17 e-cal-view.h --- calendar/gui/e-cal-view.h 7 Nov 2003 05:51:58 -0000 1.17 +++ calendar/gui/e-cal-view.h 7 Dec 2003 16:11:59 -0000 @@ -48,6 +48,13 @@ E_CALENDAR_VIEW_POS_BOTTOM_EDGE } ECalendarViewPosition; +typedef enum { + E_CAL_VIEW_MOVE_UP, + E_CAL_VIEW_MOVE_DOWN, + E_CAL_VIEW_MOVE_LEFT, + E_CAL_VIEW_MOVE_RIGHT +} ECalViewMoveDirection; + #define E_CALENDAR_VIEW_EVENT_FIELDS \ GnomeCanvasItem *canvas_item; \ ECalModelComponent *comp_data; \ @@ -87,6 +94,7 @@ void (* set_selected_time_range) (ECalendarView *cal_view, time_t start_time, time_t end_time); gboolean (* get_visible_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time); void (* update_query) (ECalendarView *cal_view); + void (* event_move) (ECalendarView *cal_view, ECalViewMoveDirection direction); }; GType e_calendar_view_get_type (void); Index: calendar/gui/e-day-view.c =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v retrieving revision 1.228 diff -u -b -B -r1.228 e-day-view.c --- calendar/gui/e-day-view.c 7 Nov 2003 05:51:59 -0000 1.228 +++ calendar/gui/e-day-view.c 7 Dec 2003 16:12:32 -0000 @@ -342,6 +342,8 @@ static gboolean e_day_view_on_text_item_event (GnomeCanvasItem *item, GdkEvent *event, EDayView *day_view); +static void e_day_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction); +static void e_day_view_change_event_time (EDayView *day_view, time_t start_dt, time_t end_dt); static void e_day_view_change_event_end_time_up (EDayView *day_view); static void e_day_view_change_event_end_time_down (EDayView *day_view); static void e_day_view_on_editing_started (EDayView *day_view, @@ -476,6 +478,7 @@ view_class->set_selected_time_range = e_day_view_set_selected_time_range; view_class->get_visible_time_range = e_day_view_get_visible_time_range; view_class->update_query = e_day_view_update_query; + view_class->event_move = e_day_view_event_move; /* init the accessibility support for e_day_view */ e_day_view_a11y_init (); @@ -573,6 +576,8 @@ day_view->resize_bars_event_day = -1; day_view->resize_bars_event_num = -1; + day_view->last_edited_comp_string = NULL; + day_view->selection_start_row = -1; day_view->selection_start_day = -1; day_view->selection_end_row = -1; @@ -2101,7 +2106,7 @@ day_view->lower = start_time; day_view->upper = day_view->day_starts[day_view->days_shown]; - e_day_view_update_query (day_view); + e_day_view_update_query (E_CALENDAR_VIEW (day_view)); } @@ -3822,6 +3827,9 @@ e_cal_component_set_dtend (comp, &date); } + e_cal_component_commit_sequence(comp); + day_view->last_edited_comp_string = e_cal_component_get_as_string (comp); + gnome_canvas_item_hide (day_view->resize_rect_item); gnome_canvas_item_hide (day_view->resize_bar_item); @@ -4290,12 +4298,17 @@ for (event_num = 0; event_num < day_view->events[day]->len; event_num++) { - e_day_view_reshape_day_event (day_view, day, event_num); - if (event_num == day_view->resize_event_num) { EDayViewEvent *event; - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); + gchar *current_comp_string; + + e_day_view_reshape_day_event (day_view, day, event_num); + event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); + current_comp_string = icalcomponent_as_ical_string (event->comp_data->icalcomp); + if (day_view->last_edited_comp_string == NULL) + continue; + if (strncmp(current_comp_string, day_view->last_edited_comp_string,50) == 0) { e_canvas_item_grab_focus (event->canvas_item, TRUE); + day_view-> last_edited_comp_string = NULL; } } } @@ -5543,6 +5556,153 @@ } return FALSE; +} + +static void +e_day_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction) +{ + EDayViewEvent *event; + EDayView *day_view; + gint day, event_num, resize_start_row, resize_end_row; + time_t start_dt, end_dt; + struct icaltimetype start_time,end_time; + + day_view = E_DAY_VIEW (cal_view); + day = day_view->editing_event_day; + event_num = day_view->editing_event_num; + + if ((day == -1) || (day == E_DAY_VIEW_LONG_EVENT)) + return; + + event = &g_array_index (day_view->events[day], EDayViewEvent, + event_num); + day_view->resize_event_day = day; + day_view->resize_event_num = event_num; + day_view->resize_bars_event_day = day; + day_view->resize_bars_event_num = event_num; + resize_start_row = event->start_minute / day_view->mins_per_row; + resize_end_row = (event->end_minute - 1) / day_view->mins_per_row; + if (resize_end_row < resize_start_row) + resize_end_row = resize_start_row; + + switch (direction) { + case E_CAL_VIEW_MOVE_UP: + if (resize_start_row <= 0) return; + resize_start_row--; + resize_end_row--; + start_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_start_row); + end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1); + break; + case E_CAL_VIEW_MOVE_DOWN: + if (resize_end_row >= day_view->rows - 1) return; + resize_start_row++; + resize_end_row++; + start_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_start_row); + end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1); + break; + case E_CAL_VIEW_MOVE_LEFT: + if (day <= 0) + return; + start_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_start_row); + end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1); + start_time = icaltime_from_timet(start_dt, 0); + end_time = icaltime_from_timet(end_dt, 0); + icaltime_adjust (&start_time ,-1,0,0,0); + icaltime_adjust (&end_time ,-1,0,0,0); + start_dt = icaltime_as_timet (start_time); + end_dt = icaltime_as_timet (end_time); + break; + case E_CAL_VIEW_MOVE_RIGHT: + if (day + 1 >= day_view->days_shown) + return; + start_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_start_row); + end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1); + start_time = icaltime_from_timet(start_dt, 0); + end_time = icaltime_from_timet(end_dt, 0); + icaltime_adjust (&start_time ,1,0,0,0); + icaltime_adjust (&end_time ,1,0,0,0); + start_dt = icaltime_as_timet (start_time); + end_dt = icaltime_as_timet (end_time); + break; + default: + break; + } + + e_day_view_change_event_time (day_view, start_dt, end_dt); + e_day_view_ensure_rows_visible (day_view, resize_start_row, resize_end_row); +} + +static void +e_day_view_change_event_time (EDayView *day_view, time_t start_dt, time_t end_dt) +{ + EDayViewEvent *event; + gint day, event_num; + ECalComponent *comp; + ECalComponentDateTime date; + struct icaltimetype itt; + ECal *client; + CalObjModType mod = CALOBJ_MOD_ALL; + GtkWindow *toplevel; + + day = day_view->editing_event_day; + event_num = day_view->editing_event_num; + event = &g_array_index (day_view->events[day], EDayViewEvent, + event_num); + client = event->comp_data->client; + + /* We use a temporary shallow copy of the ico since we don't want to + change the original ico here. Otherwise we would not detect that + the event's time had changed in the "update_event" callback. */ + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + + date.value = &itt; + /* FIXME: Should probably keep the timezone of the original start + and end times. */ + date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + + *date.value = icaltime_from_timet_with_zone (start_dt, FALSE, + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + e_cal_component_set_dtstart (comp, &date); + *date.value = icaltime_from_timet_with_zone (end_dt, FALSE, + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + e_cal_component_set_dtend (comp, &date); + + e_cal_component_commit_sequence (comp); + day_view->last_edited_comp_string = e_cal_component_get_as_string (comp); + + gnome_canvas_item_hide (day_view->resize_rect_item); + gnome_canvas_item_hide (day_view->resize_bar_item); + + /* Hide the horizontal bars. */ + day_view->resize_bars_event_day = -1; + day_view->resize_bars_event_num = -1; + gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); + gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); + + day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE; + + if (e_cal_component_has_recurrences (comp)) { + if (!recur_component_dialog (client, comp, &mod, NULL)) { + gtk_widget_queue_draw (day_view->top_canvas); + goto out; + } + } + + toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view))); + + e_cal_component_commit_sequence (comp); + if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) { + if (itip_organizer_is_user (comp, client) && + send_component_dialog (toplevel, client, comp, TRUE)) { + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); + } else { + g_message (G_STRLOC ": Could not update the object!"); + } + } + + out: + g_object_unref (comp); } static void Index: calendar/gui/e-day-view.h =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.h,v retrieving revision 1.56 diff -u -b -B -r1.56 e-day-view.h --- calendar/gui/e-day-view.h 3 Dec 2003 15:38:28 -0000 1.56 +++ calendar/gui/e-day-view.h 7 Dec 2003 16:12:34 -0000 @@ -411,6 +411,9 @@ gint resize_start_row; gint resize_end_row; + /* This is used to remember the last edited event. */ + gchar *last_edited_comp_string; + /* This is the event the mouse button was pressed on. If the button is released we start editing it, but if the mouse is dragged we set this to -1. */ Index: calendar/gui/e-week-view.c =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v retrieving revision 1.191 diff -u -b -B -r1.191 e-week-view.c --- calendar/gui/e-week-view.c 7 Nov 2003 05:52:00 -0000 1.191 +++ calendar/gui/e-week-view.c 7 Dec 2003 16:12:48 -0000 @@ -177,16 +177,21 @@ static gboolean e_week_view_on_text_item_event (GnomeCanvasItem *item, GdkEvent *event, EWeekView *week_view); +static void e_week_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction); +static gint e_week_view_get_day_offset_of_event (EWeekView *week_view, time_t event_time); +static void e_week_view_scroll_a_step (EWeekView *week_view, ECalViewMoveDirection direction); +static void e_week_view_change_event_time (EWeekView *week_view, time_t start_dt, time_t end_dt); static gboolean e_week_view_on_jump_button_event (GnomeCanvasItem *item, GdkEvent *event, EWeekView *week_view); static gboolean e_week_view_key_press (GtkWidget *widget, GdkEventKey *event); static gboolean e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event); -static void e_week_view_on_key_up (EWeekView *week_view, GdkEventKey *event); -static void e_week_view_on_key_down (EWeekView *week_view, GdkEventKey *event); -static void e_week_view_on_key_left (EWeekView *week_view, GdkEventKey *event); -static void e_week_view_on_key_right (EWeekView *week_view, GdkEventKey *event); +static void e_week_view_move_selection_day (EWeekView *week_view, ECalViewMoveDirection direction); +static gint e_week_view_get_adjust_days_for_move_up (EWeekView *week_view,gint current_day); +static gint e_week_view_get_adjust_days_for_move_down (EWeekView *week_view,gint current_day); +static gint e_week_view_get_adjust_days_for_move_left (EWeekView *week_view,gint current_day); +static gint e_week_view_get_adjust_days_for_move_right (EWeekView *week_view,gint current_day); static gboolean e_week_view_popup_menu (GtkWidget *widget); static gboolean e_week_view_update_event_cb (EWeekView *week_view, @@ -237,6 +242,7 @@ view_class->set_selected_time_range = e_week_view_set_selected_time_range; view_class->get_visible_time_range = e_week_view_get_visible_time_range; view_class->update_query = e_week_view_update_query; + view_class->event_move = e_week_view_event_move; /* init the accessibility support for e_week_view */ e_week_view_a11y_init (); @@ -311,6 +317,8 @@ week_view->pressed_event_num = -1; week_view->editing_event_num = -1; + week_view->last_edited_comp_string = NULL; + week_view->main_gc = NULL; /* Create the small font. */ @@ -2368,8 +2376,20 @@ event = &g_array_index (week_view->events, EWeekViewEvent, event_num); for (span_num = 0; span_num < event->num_spans; span_num++) { + gchar *current_comp_string; + e_week_view_reshape_event_span (week_view, event_num, span_num); + current_comp_string = icalcomponent_as_ical_string (event->comp_data->icalcomp); + if (week_view->last_edited_comp_string == NULL) + continue; + if (strncmp (current_comp_string, week_view->last_edited_comp_string,50) == 0) { + EWeekViewEventSpan *span; + span = &g_array_index (week_view->spans, EWeekViewEventSpan, + event->spans_index + span_num); + e_canvas_item_grab_focus (span->text_item, TRUE); + week_view->last_edited_comp_string = NULL; + } } } @@ -2947,6 +2967,169 @@ return FALSE; } +static void e_week_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction) +{ + EWeekViewEvent *event; + gint event_num, span_num, adjust_days, current_start_day, current_end_day; + time_t start_dt, end_dt; + struct icaltimetype start_time,end_time; + EWeekView *week_view = E_WEEK_VIEW (cal_view); + + event_num = week_view->editing_event_num; + span_num = week_view->editing_span_num; + adjust_days = 0; + + /* If no item is being edited, just return. */ + if (event_num == -1) + return; + + event = &g_array_index (week_view->events, EWeekViewEvent, event_num); + start_dt = event->start; + end_dt = event->end; + start_time = icaltime_from_timet (start_dt, 0); + end_time = icaltime_from_timet (end_dt, 0); + current_end_day = e_week_view_get_day_offset_of_event (week_view,end_dt); + + switch (direction) { + case E_CAL_VIEW_MOVE_UP: + adjust_days = e_week_view_get_adjust_days_for_move_up (week_view,current_end_day); + break; + case E_CAL_VIEW_MOVE_DOWN: + adjust_days = e_week_view_get_adjust_days_for_move_down (week_view,current_end_day); + break; + case E_CAL_VIEW_MOVE_LEFT: + adjust_days = e_week_view_get_adjust_days_for_move_left (week_view,current_end_day); + break; + case E_CAL_VIEW_MOVE_RIGHT: + adjust_days = e_week_view_get_adjust_days_for_move_right (week_view,current_end_day); + break; + default: + break; + } + + icaltime_adjust (&start_time ,adjust_days,0,0,0); + icaltime_adjust (&end_time ,adjust_days,0,0,0); + start_dt = icaltime_as_timet (start_time); + end_dt = icaltime_as_timet (end_time); + + current_start_day = e_week_view_get_day_offset_of_event (week_view,start_dt); + current_end_day = e_week_view_get_day_offset_of_event (week_view,end_dt); + + if (current_start_day < 0) { + return; + } + if (week_view->multi_week_view) { + if (current_end_day > week_view->weeks_shown * 7) { + return; + } + }else { + if (current_end_day >= 7) { + return; + } + } + + e_week_view_change_event_time (week_view, start_dt, end_dt); +} + +static gint +e_week_view_get_day_offset_of_event (EWeekView *week_view, time_t event_time) +{ + struct tm first_day_shown_tm = {0}; + struct tm *event_time_tm; + + event_time_tm = NULL; + + g_date_to_struct_tm (&(week_view->first_day_shown), &first_day_shown_tm); + event_time_tm = gmtime (&event_time); + return (event_time_tm->tm_yday - first_day_shown_tm.tm_yday); +} + +static void +e_week_view_scroll_a_step (EWeekView *week_view, ECalViewMoveDirection direction) +{ + GtkAdjustment *adj = GTK_RANGE (week_view->vscrollbar)->adjustment; + gfloat new_value; + + switch (direction){ + case E_CAL_VIEW_MOVE_UP: + new_value = adj->value - adj->step_increment; + break; + case E_CAL_VIEW_MOVE_DOWN: + new_value = adj->value + adj->step_increment; + break; + default: + break; + } + + new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); + gtk_adjustment_set_value (adj, new_value); +} + +static void +e_week_view_change_event_time (EWeekView *week_view, time_t start_dt, time_t end_dt) +{ + EWeekViewEvent *event; + gint event_num; + ECalComponent *comp; + ECalComponentDateTime date; + struct icaltimetype itt; + ECal *client; + CalObjModType mod = CALOBJ_MOD_ALL; + GtkWindow *toplevel; + + event_num = week_view->editing_event_num; + + /* If no item is being edited, just return. */ + if (event_num == -1) + return; + + event = &g_array_index (week_view->events, EWeekViewEvent, event_num); + client = event->comp_data->client; + + /* We use a temporary shallow copy of the ico since we don't want to + change the original ico here. Otherwise we would not detect that + the event's time had changed in the "update_event" callback. */ + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + date.value = &itt; + /* FIXME: Should probably keep the timezone of the original start + and end times. */ + date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); + + *date.value = icaltime_from_timet_with_zone (start_dt, FALSE, + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); + e_cal_component_set_dtstart (comp, &date); + *date.value = icaltime_from_timet_with_zone (end_dt, FALSE, + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); + e_cal_component_set_dtend (comp, &date); + + e_cal_component_commit_sequence (comp); + week_view->last_edited_comp_string = e_cal_component_get_as_string (comp); + + + if (e_cal_component_has_recurrences (comp)) { + if (!recur_component_dialog (client, comp, &mod, NULL)) { + gtk_widget_queue_draw (week_view->main_canvas); + goto out; + } + } + + toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (week_view))); + + e_cal_component_commit_sequence (comp); + if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) { + if (itip_organizer_is_user (comp, client) && + send_component_dialog (toplevel, client, comp, TRUE)) { + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); + } else { + g_message (G_STRLOC ": Could not update the object!"); + } + } + + out: + g_object_unref (comp); +} + static void e_week_view_on_editing_started (EWeekView *week_view, @@ -3205,22 +3388,26 @@ #endif /*Navigation through days with arrow keys*/ + if (!((event->state & GDK_SHIFT_MASK) + ||(event->state & GDK_CONTROL_MASK) + ||(event->state & GDK_MOD1_MASK))) { switch (event->keyval) { case GDK_Up: - e_week_view_on_key_up (week_view, event); + e_week_view_move_selection_day (week_view,E_CAL_VIEW_MOVE_UP); return TRUE; case GDK_Down: - e_week_view_on_key_down (week_view, event); + e_week_view_move_selection_day (week_view,E_CAL_VIEW_MOVE_DOWN); return TRUE; case GDK_Left: - e_week_view_on_key_left (week_view, event); + e_week_view_move_selection_day (week_view,E_CAL_VIEW_MOVE_LEFT); return TRUE; case GDK_Right: - e_week_view_on_key_right (week_view, event); + e_week_view_move_selection_day (week_view,E_CAL_VIEW_MOVE_RIGHT); return TRUE; default: break; } + } if (week_view->selection_start_day == -1) return FALSE; @@ -3288,9 +3475,8 @@ return TRUE; } - static void -e_week_view_on_key_up (EWeekView *week_view, GdkEventKey *event) +e_week_view_move_selection_day (EWeekView *week_view, ECalViewMoveDirection direction) { gint selection_start_day, selection_end_day; @@ -3301,61 +3487,36 @@ selection_start_day = 0; selection_end_day = 0; } - - if (week_view->multi_week_view) { - if (selection_end_day < 7) { - g_date_subtract_days (&(week_view->first_day_shown), 7); - } else - selection_end_day -= 7; - } - else { - if (selection_start_day == selection_end_day) { - if (selection_end_day == 0) { - g_date_subtract_days (&(week_view->first_day_shown), 7); - selection_end_day = 6; - } else - selection_end_day--; - } else { - selection_end_day = - (selection_start_day + selection_end_day)/2; - } + switch (direction) { + case E_CAL_VIEW_MOVE_UP: + selection_end_day += e_week_view_get_adjust_days_for_move_up (week_view,selection_end_day); + break; + case E_CAL_VIEW_MOVE_DOWN: + selection_end_day += e_week_view_get_adjust_days_for_move_down (week_view,selection_end_day); + break; + case E_CAL_VIEW_MOVE_LEFT: + selection_end_day += e_week_view_get_adjust_days_for_move_left (week_view,selection_end_day); + break; + case E_CAL_VIEW_MOVE_RIGHT: + selection_end_day += e_week_view_get_adjust_days_for_move_right (week_view,selection_end_day); + break; + default: + break; } - week_view->selection_start_day = selection_end_day; - week_view->selection_end_day = selection_end_day; - - gtk_widget_queue_draw (week_view->main_canvas); -} - -static void -e_week_view_on_key_down (EWeekView *week_view, GdkEventKey *event) -{ - gint selection_start_day, selection_end_day; - - selection_start_day = week_view->selection_start_day; - selection_end_day = week_view->selection_end_day; - - if (selection_start_day == -1) { - selection_start_day = 0; - selection_end_day = 0; + if (selection_end_day < 0) { + e_week_view_scroll_a_step(week_view, E_CAL_VIEW_MOVE_UP); + selection_end_day +=7; } - if (week_view->multi_week_view) { - if ((selection_end_day+7) / 7 >= week_view->weeks_shown) { - g_date_add_days (&(week_view->first_day_shown), 7); - } else - selection_end_day += 7; - } - else { - if (selection_start_day == selection_end_day) { - if (selection_end_day == 6) { - g_date_add_days (&(week_view->first_day_shown), 7); - selection_end_day = 0; - } else - selection_end_day++; - } else { - selection_end_day = - (selection_start_day + selection_end_day)/2; + if (selection_end_day >= week_view->weeks_shown * 7) { + e_week_view_scroll_a_step(week_view, E_CAL_VIEW_MOVE_DOWN); + selection_end_day -=7; + } + }else { + if (selection_end_day >= 7) { + e_week_view_scroll_a_step(week_view, E_CAL_VIEW_MOVE_DOWN); + selection_end_day -=7; } } @@ -3363,103 +3524,37 @@ week_view->selection_end_day = selection_end_day; gtk_widget_queue_draw (week_view->main_canvas); + } -static void -e_week_view_on_key_left (EWeekView *week_view, GdkEventKey *event) +static gint +e_week_view_get_adjust_days_for_move_up (EWeekView *week_view,gint current_day) { - gint selection_start_day, selection_end_day; - - selection_start_day = week_view->selection_start_day; - selection_end_day = week_view->selection_end_day; - - if (selection_start_day == -1) { - selection_start_day = 0; - selection_end_day = 0; - } - - if (week_view->multi_week_view) { - if (selection_end_day == 0) { - g_date_subtract_days (&(week_view->first_day_shown), 7); - selection_end_day = 6; - } else - selection_end_day -= 1; - } - else { - switch (selection_end_day) { - case 0: - case 1: - case 2: - g_date_subtract_days (&(week_view->first_day_shown), 7); - selection_end_day += 3; - break; - case 3: - case 4: - case 5: - selection_end_day -= 3; - break; - case 6: - selection_end_day -= 4; - break; - default: - break; - } - } - - week_view->selection_start_day = selection_end_day; - week_view->selection_end_day = selection_end_day; - - gtk_widget_queue_draw (week_view->main_canvas); - + if (week_view->multi_week_view) + return -7; + else + return 0; } -static void -e_week_view_on_key_right (EWeekView *week_view, GdkEventKey *event) +static gint +e_week_view_get_adjust_days_for_move_down (EWeekView *week_view,gint current_day) { + if (week_view->multi_week_view) + return 7; + else + return 0; +} - gint selection_start_day, selection_end_day; - - selection_start_day = week_view->selection_start_day; - selection_end_day = week_view->selection_end_day; - - if (selection_start_day == -1) { - selection_start_day = 0; - selection_end_day = 0; - } - - if (week_view->multi_week_view) { - if (selection_end_day == week_view->weeks_shown*7 -1 ) { - g_date_add_days (&(week_view->first_day_shown), 7); - selection_end_day -= 6; - } else - selection_end_day++; - } - else { - switch (selection_end_day) { - case 0: - case 1: - case 2: - selection_end_day += 3; - break; - case 3: - case 4: - case 5: - g_date_add_days (&(week_view->first_day_shown), 7); - selection_end_day -= 3; - break; - case 6: - g_date_add_days (&(week_view->first_day_shown), 7); - selection_end_day -= 4; - break; - default: - break; - } - } - - week_view->selection_start_day = selection_end_day; - week_view->selection_end_day = selection_end_day; +static gint +e_week_view_get_adjust_days_for_move_left (EWeekView *week_view,gint current_day) +{ + return -1; +} - gtk_widget_queue_draw (week_view->main_canvas); +static gint +e_week_view_get_adjust_days_for_move_right (EWeekView *week_view,gint current_day) +{ + return 1; } static gboolean Index: calendar/gui/e-week-view.h =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.h,v retrieving revision 1.50 diff -u -b -B -r1.50 e-week-view.h --- calendar/gui/e-week-view.h 7 Nov 2003 05:52:00 -0000 1.50 +++ calendar/gui/e-week-view.h 7 Dec 2003 16:12:50 -0000 @@ -316,6 +316,9 @@ gint editing_event_num; gint editing_span_num; + /* This is used to remember the last edited event. */ + gchar *last_edited_comp_string; + /* The event that the context menu is for. */ gint popup_event_num;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]