Re: [evolution-patches] new patch for review (#45776)



please specify the component for which the patch is for in the Subject
in the future.

thanks,

Jeff

On Fri, 2003-09-12 at 04:43, wu yang wrote:
> Hi
> This is a new patch for evolution calendar keyboard navigation .
> Bug #(45776)
> In DayView and WeekView, Alt + Arrow Keys with the event is selected, 
> Move a selected event through time lines
> p45776_withChanglog is for evolution calendar.
> etext_patch is for e-text in gal.
> Thanks
> 
> 
> ______________________________________________________________________
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
> retrieving revision 1.1867
> diff -u -b -B -r1.1867 ChangeLog
> --- ChangeLog	4 Jan 1997 01:43:31 -0000	1.1867
> +++ ChangeLog	12 Sep 2003 08:19:17 -0000
> @@ -1,3 +1,30 @@
> +2003-09-12  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-09-11  Frederic Crozat  <fcrozat mandrakesoft com>
>  
>  	* conduits/todo/Makefile.am:
> Index: gui/e-cal-view.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-view.c,v
> retrieving revision 1.15
> diff -u -b -B -r1.15 e-cal-view.c
> --- gui/e-cal-view.c	20 Aug 2003 12:02:32 -0000	1.15
> +++ gui/e-cal-view.c	12 Sep 2003 08:19:18 -0000
> @@ -26,6 +26,8 @@
>  #include <gtk/gtkimage.h>
>  #include <gtk/gtkinvisible.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"
> @@ -85,6 +87,7 @@
>  	TIMEZONE_CHANGED,
>  	EVENT_CHANGED,
>  	EVENT_ADDED,
> +	EVENT_MOVE,
>  	LAST_SIGNAL
>  };
>  
> @@ -94,6 +97,7 @@
>  e_cal_view_class_init (ECalViewClass *klass)
>  {
>  	GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
> +	GtkBindingSet *binding_set;
>  
>  	parent_class = g_type_class_peek_parent (klass);
>  
> @@ -135,6 +139,16 @@
>  			      G_TYPE_NONE, 1,
>  			      G_TYPE_POINTER);
>  
> +	e_cal_view_signals[EVENT_MOVE] =
> +		g_signal_new ("event_move",
> +			      G_TYPE_FROM_CLASS (klass),
> +			      G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
> +			      G_STRUCT_OFFSET (ECalViewClass, event_move),
> +			      NULL, NULL,
> +			      g_cclosure_marshal_VOID__INT,
> +			      G_TYPE_NONE, 1,
> +			      G_TYPE_INT);
> +
>  	/* Method override */
>  	object_class->destroy = e_cal_view_destroy;
>  
> @@ -147,6 +161,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);
>  
>  	/* clipboard atom */
>  	if (!clipboard_atom)
> Index: gui/e-cal-view.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-view.h,v
> retrieving revision 1.11
> diff -u -b -B -r1.11 e-cal-view.h
> --- gui/e-cal-view.h	20 Aug 2003 10:16:59 -0000	1.11
> +++ gui/e-cal-view.h	12 Sep 2003 08:19:19 -0000
> @@ -48,6 +48,13 @@
>  	E_CAL_VIEW_POS_BOTTOM_EDGE
>  } ECalViewPosition;
>  
> +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_CAL_VIEW_EVENT_FIELDS \
>          GnomeCanvasItem *canvas_item; \
>          ECalModelComponent *comp_data; \
> @@ -86,6 +93,7 @@
>  	void (* set_selected_time_range) (ECalView *cal_view, time_t start_time, time_t end_time);
>  	gboolean (* get_visible_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time);
>  	void (* update_query) (ECalView *cal_view);
> +	void (* event_move) (ECalView *cal_view, ECalViewMoveDirection direction);
>  };
>  
>  GType          e_cal_view_get_type (void);
> Index: gui/e-day-view.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
> retrieving revision 1.219
> diff -u -b -B -r1.219 e-day-view.c
> --- gui/e-day-view.c	1 Sep 2003 06:15:33 -0000	1.219
> +++ gui/e-day-view.c	12 Sep 2003 08:19:33 -0000
> @@ -344,6 +344,8 @@
>  static gboolean e_day_view_on_text_item_event (GnomeCanvasItem *item,
>  					       GdkEvent *event,
>  					       EDayView *day_view);
> +static void e_day_view_event_move (EDayView *day_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,
> @@ -478,6 +480,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 ();
> @@ -575,6 +578,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;
> @@ -3946,6 +3951,9 @@
>  		cal_component_set_dtend (comp, &date);
>  	}
>  
> +	cal_component_commit_sequence(comp);
> +	day_view->last_edited_comp_string = cal_component_get_as_string (comp);
> +
>  	gnome_canvas_item_hide (day_view->resize_rect_item);
>  	gnome_canvas_item_hide (day_view->resize_bar_item);
>  
> @@ -4418,11 +4426,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;
> +
> +		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;
>  		}
>  	}
>  }
> @@ -5666,6 +5680,153 @@
>  }
>  
>  static void 
> +e_day_view_event_move (EDayView *day_view, ECalViewMoveDirection direction)
> +{
> +	EDayViewEvent *event;
> +	gint day, event_num, resize_start_row, resize_end_row;
> +	time_t start_dt, end_dt;
> +	struct icaltimetype start_time,end_time;
> +
> +	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;
> +	CalComponent *comp;
> +	CalComponentDateTime date;
> +	struct icaltimetype itt;
> +	CalClient *client;
> +
> +	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 = cal_component_new ();
> +	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_cal_view_get_timezone (E_CAL_VIEW (day_view)));
> +	
> +	*date.value = icaltime_from_timet_with_zone (start_dt, FALSE,
> +						     e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
> +	cal_component_set_dtstart (comp, &date);
> +	*date.value = icaltime_from_timet_with_zone (end_dt, FALSE,
> +						     e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
> +	cal_component_set_dtend (comp, &date);
> +
> +	cal_component_commit_sequence(comp);
> +	day_view->last_edited_comp_string = 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_CAL_VIEW_POS_NONE;
> +
> +	if (cal_component_is_instance (comp)) {
> +		CalObjModType mod;
> +
> +		if (recur_component_dialog (comp, &mod, NULL)) {
> +			if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
> +				if (itip_organizer_is_user (comp, client) &&
> +				    send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
> +							   client, comp, FALSE))
> +					itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
> +			} else {
> +				g_message ("e_day_view_change_event_time(): Could not update the object!");
> +			}
> +		} else {
> +			gtk_widget_queue_draw (day_view->main_canvas);
> +		}		
> +	} else if (cal_client_update_object (client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
> +		if (itip_organizer_is_user (comp, client) &&
> +		    send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)), client, comp, FALSE))
> +			itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
> +	} else {
> +		g_message ("e_day_view_change_event_time(): Could not update the object!");
> +	}
> +	
> +	g_object_unref (comp);
> +
> +}
> +
> +static void 
>  e_day_view_change_event_end_time_up (EDayView *day_view)
>  {
>  	EDayViewEvent *event;
> Index: gui/e-day-view.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.h,v
> retrieving revision 1.51
> diff -u -b -B -r1.51 e-day-view.h
> --- gui/e-day-view.h	20 Aug 2003 10:16:59 -0000	1.51
> +++ gui/e-day-view.h	12 Sep 2003 08:19:35 -0000
> @@ -415,6 +415,9 @@
>  	gint resize_start_row;
>  	gint resize_end_row;
>  
> +	/* These are 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: gui/e-week-view.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
> retrieving revision 1.183
> diff -u -b -B -r1.183 e-week-view.c
> --- gui/e-week-view.c	20 Aug 2003 10:16:59 -0000	1.183
> +++ gui/e-week-view.c	12 Sep 2003 08:19:48 -0000
> @@ -174,16 +174,21 @@
>  static gboolean e_week_view_on_text_item_event (GnomeCanvasItem *item,
>  						GdkEvent *event,
>  						EWeekView *week_view);
> +static void e_week_view_event_move (EWeekView *week_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,
> @@ -234,6 +239,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 ();
> @@ -308,6 +314,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;
>  
>  	week_view->default_category = NULL;
> @@ -2395,6 +2403,18 @@
>  		for (span_num = 0; span_num < event->num_spans; span_num++) {
>  			e_week_view_reshape_event_span (week_view, event_num,
>  							span_num);
> +
> +			gchar *current_comp_string;
> +			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;
> +			}
>  		}
>  	}
>  
> @@ -2976,6 +2996,167 @@
>  	return FALSE;
>  }
>  
> +static void e_week_view_event_move (EWeekView *week_view, ECalViewMoveDirection direction)
> +{
> +	EWeekViewEvent *event;
> +	gint event_num, span_num, adjust_days, current_day;
> +	time_t start_dt, end_dt;
> +	struct icaltimetype start_time,end_time;
> +
> +	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_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_day);
> +		break;
> +	case E_CAL_VIEW_MOVE_DOWN:
> +		adjust_days = e_week_view_get_adjust_days_for_move_down (week_view,current_day);
> +		break;
> +	case E_CAL_VIEW_MOVE_LEFT:
> +		adjust_days = e_week_view_get_adjust_days_for_move_left (week_view,current_day);
> +		break;
> +	case E_CAL_VIEW_MOVE_RIGHT:
> +		adjust_days = e_week_view_get_adjust_days_for_move_right (week_view,current_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_day = e_week_view_get_day_offset_of_event (week_view,end_dt);
> +
> +	if (current_day < 0) {
> +		return;
> +	}
> +	if (week_view->multi_week_view) {
> +		if (current_day >= week_view->weeks_shown * 7) {
> +			return;
> +		}
> +	}else {
> +		if (current_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;
> +	CalComponent *comp;
> +	CalComponentDateTime date;
> +	struct icaltimetype itt;
> +	CalClient *client;
> +
> +	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 = cal_component_new ();
> +	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_cal_view_get_timezone (E_CAL_VIEW (week_view)));
> +	
> +	*date.value = icaltime_from_timet_with_zone (start_dt, FALSE,
> +						     e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
> +	cal_component_set_dtstart (comp, &date);
> +	*date.value = icaltime_from_timet_with_zone (end_dt, FALSE,
> +						     e_cal_view_get_timezone (E_CAL_VIEW (week_view)));
> +	cal_component_set_dtend (comp, &date);
> +
> +	cal_component_commit_sequence(comp);
> +	week_view->last_edited_comp_string = cal_component_get_as_string (comp);
> +
> +	if (cal_component_is_instance (comp)) {
> +		CalObjModType mod;
> +
> +		if (recur_component_dialog (comp, &mod, NULL)) {
> +			if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
> +				if (itip_organizer_is_user (comp, client) &&
> +				    send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (week_view)),
> +							   client, comp, FALSE))
> +					itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
> +			} else {
> +				g_message ("e_week_view_change_event_time(): Could not update the object!");
> +			}
> +		} else {
> +			gtk_widget_queue_draw (week_view->main_canvas);
> +		}		
> +	} else if (cal_client_update_object (client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
> +		if (itip_organizer_is_user (comp, client) &&
> +		    send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (week_view)), client, comp, FALSE))
> +			itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
> +	} else {
> +		g_message ("e_week_view_change_event_time(): Could not update the object!");
> +	}
> +
> +	g_object_unref (comp);
> +}
> +
>  
>  static void
>  e_week_view_on_editing_started (EWeekView *week_view,
> @@ -3226,22 +3407,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;
> @@ -3306,9 +3491,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;
>   
> @@ -3319,23 +3503,36 @@
>  		selection_start_day = 0;	  
>  		selection_end_day = 0;
>  	}
> +	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;
> +	}
>  		
> -	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;			
> +	if (selection_end_day < 0) {
> +		e_week_view_scroll_a_step(week_view, E_CAL_VIEW_MOVE_UP);
> +		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;
> +	if (week_view->multi_week_view) {
> +		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;
>  		}
>  	} 
>  
> @@ -3343,141 +3540,92 @@
>  	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)
> +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+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 (current_day % 7 == 5 )
> +			return -6;
> +		else if (current_day % 7 ==6)
> +			return -1;
> +		else
> +			return -7;
>  	} 
> -
> -	week_view->selection_start_day = selection_end_day;
> -	week_view->selection_end_day = selection_end_day;
> -
> -	gtk_widget_queue_draw (week_view->main_canvas);
> +	else
> +		return -1;
>  }
>  
> -static void 
> -e_week_view_on_key_left (EWeekView *week_view, GdkEventKey *event)
> +static gint
> +e_week_view_get_adjust_days_for_move_down (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 (current_day % 7 == 5 )
> +			return 1;
> +		else if (current_day % 7 ==6)
> +			return 6;
> +		else
> +			return 7;
>  	}
> +	else 
> +		return 1;
> +}
>  		
> -	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;			
> -	}
> +static gint
> +e_week_view_get_adjust_days_for_move_left (EWeekView *week_view,gint current_day)
> +{
> +	if (week_view->multi_week_view)
> +		return -1;			
>  	else {
> -			switch (selection_end_day) {
> +		switch (current_day) {
>  			case 0: 
>  			case 1:
>  			case 2:
> -				g_date_subtract_days (&(week_view->first_day_shown), 7);
> -				selection_end_day += 3;
> +			return -4;
>  				break;
>  			case 3: 
>  			case 4:
>  			case 5:
> -				selection_end_day -= 3;
> +			return -3;
>  				break;
>  			case 6:
> -				selection_end_day -= 4;
> +			return -4;
>  				break;
>  			default:
> +			return 0;
>  				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_right (EWeekView *week_view, GdkEventKey *event)
> +static gint
> +e_week_view_get_adjust_days_for_move_right (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 == week_view->weeks_shown*7 -1 ) {
> -			g_date_add_days (&(week_view->first_day_shown), 7);
> -			selection_end_day -= 6;
> -		} else
> -			selection_end_day++;			
> +		return 1;			
>  	}
>  	else {
> -			switch (selection_end_day) {
> +		switch (current_day) {
>  			case 0: 
>  			case 1:
>  			case 2:				
> -				selection_end_day += 3;
> +			return 3;
>  				break;
>  			case 3: 
>  			case 4:
>  			case 5:
> -				g_date_add_days (&(week_view->first_day_shown), 7);
> -				selection_end_day -= 3;
> +			return 4;
>  				break;
>  			case 6:
> -				g_date_add_days (&(week_view->first_day_shown), 7);
> -				selection_end_day -= 4;
> +			return 3;
>  				break;
>  			default:
> +			return 0;
>  				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 gboolean
> Index: gui/e-week-view.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.h,v
> retrieving revision 1.46
> diff -u -b -B -r1.46 e-week-view.h
> --- gui/e-week-view.h	20 Aug 2003 10:17:00 -0000	1.46
> +++ gui/e-week-view.h	12 Sep 2003 08:19:54 -0000
> @@ -318,6 +318,9 @@
>  	gint editing_event_num;
>  	gint editing_span_num;
>  
> +	/* These are used to remember the last edited event. */
> +	gchar *last_edited_comp_string;
> +
>  	/* The event that the context menu is for. */
>  	gint popup_event_num;
>  
> 
> ______________________________________________________________________
> Index: e-text-event-processor-emacs-like.c
> ===================================================================
> RCS file: /cvs/gnome/gal/gal/util/e-text-event-processor-emacs-like.c,v
> retrieving revision 1.18
> diff -u -b -B -r1.18 e-text-event-processor-emacs-like.c
> --- e-text-event-processor-emacs-like.c	17 Nov 2002 05:40:15 -0000	1.18
> +++ e-text-event-processor-emacs-like.c	12 Sep 2003 08:27:50 -0000
> @@ -191,6 +191,8 @@
>  			command.time = event->key.time;
>  			if (key.state & GDK_SHIFT_MASK)
>  				command.action = E_TEP_SELECT;
> +			else if (key.state & GDK_MOD1_MASK)
> +				command.action = E_TEP_NOP;
>  			else
>  				command.action = E_TEP_MOVE;
>  			switch(key.keyval) {
-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com




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