[evolution-patches] (Calendar) Fix to show tooltips



Hi,

Please review the patch.

-Srini.
Index: e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.286
diff -u -p -r1.286 e-day-view.c
--- e-day-view.c	24 Aug 2005 03:07:49 -0000	1.286
+++ e-day-view.c	11 Nov 2005 14:17:14 -0000
@@ -4224,6 +4224,9 @@ e_day_view_add_event (ECalComponent *com
 	}
 
 	event.start = start;
+	event.tooltip = NULL;
+	event.color = NULL;
+	event.timeout = -1;
 	event.end = end;
 	event.canvas_item = NULL;
 	event.comp_data->instance_start = start;
@@ -4465,6 +4468,7 @@ e_day_view_reshape_long_event (EDayView 
 					       NULL);
 		g_signal_connect (event->canvas_item, "event",
 				  G_CALLBACK (e_day_view_on_text_item_event), day_view);
+		g_object_set_data (event->canvas_item, "event", event);
 		g_signal_emit_by_name (G_OBJECT(day_view),
 				       "event_added", event);
 
@@ -4646,6 +4650,7 @@ e_day_view_reshape_day_event (EDayView *
 						       NULL);
 			g_signal_connect (event->canvas_item, "event",
 					  G_CALLBACK (e_day_view_on_text_item_event), day_view);
+			g_object_set_data (event->canvas_item, "event", event);
 			g_signal_emit_by_name (G_OBJECT(day_view),
 					       "event_added", event);
 
@@ -5766,6 +5771,220 @@ cancel_editing (EDayView *day_view)
 }
 
 
+static char *
+calculate_time (time_t start, time_t end)
+{
+	time_t difference = end - start;
+	char *str;
+	
+	if (difference < 60) {/* Can't be zero */ 
+		str = g_strdup_printf (_("(%d seconds)"), difference);
+	} else if (difference > 60 && difference < 3600) { /* It will be x minutes y seconds*/
+		int minutes, seconds;
+		minutes = difference / 60;
+		seconds = difference % 60;
+		if (seconds)
+			str = g_strdup_printf (_("(%d %s %d %s)"), minutes, ngettext(_("minute"), _("minutes"), minutes), seconds, ngettext(_("second"), _("seconds"), seconds));
+		else 
+			str = g_strdup_printf (_("(%d %s)"), minutes, ngettext(_("minute"), _("minutes"), minutes));
+	} else {
+		guint hours, minutes, seconds;
+		char *s_hours = NULL, *s_minutes = NULL, *s_seconds = NULL;
+		
+		hours = difference / 3600;
+		minutes = (difference % 3600)/60;
+		seconds = difference % 60;
+
+
+		if (seconds)
+			s_seconds = g_strdup_printf (ngettext(_(" %u second"), _(" %u seconds"), seconds), seconds);	
+		if (minutes)
+			s_minutes = g_strdup_printf (ngettext(_(" %u minute"), _(" %u minutes"), minutes), minutes);
+		if (hours)
+			s_hours = g_strdup_printf (ngettext(_("%u hour"),_("%u hours"), hours), hours);
+
+		if (s_minutes && s_seconds)
+			str = g_strconcat ("(", s_hours, s_minutes, s_seconds, ")", NULL);
+		else if (s_minutes)
+			str = g_strconcat ("(", s_hours, s_minutes, ")", NULL);
+		else if (s_seconds)
+			str = g_strconcat ("(", s_hours, s_seconds, ")", NULL);
+		else 
+			str = g_strconcat ("(", s_hours, ")", NULL);
+
+		g_free (s_hours);
+		g_free (s_minutes);
+		g_free (s_seconds);
+	}
+
+	return g_strchug(str);
+}
+
+static char *
+get_label (struct icaltimetype *tt)
+{
+        char buffer[1000];
+        struct tm tmp_tm;
+
+	tmp_tm = icaltimetype_to_tm (tt);
+        e_time_format_date_and_time (&tmp_tm,
+                                     calendar_config_get_24_hour_format (),
+                                     FALSE, FALSE,
+                                     buffer, 1000);
+
+        return g_strdup (buffer);
+}
+
+/* Show something like
+ * Appointment: [][][]
+ * From: foo bar com
+ * Subject: FooBar
+ * Location: BarFoo
+ * */
+
+static gboolean
+tooltip_grab (GtkWidget *tooltip, GdkEventKey *event, EDayViewEvent *pevent)
+{
+	gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+
+	gtk_widget_destroy (pevent->tooltip);
+	pevent->tooltip = NULL;
+	pevent->timeout = -1;
+
+	return FALSE;
+}
+static GtkWidget *
+get_tooltip_widget (EDayViewEvent *pevent)
+{
+	GtkWidget *label, *box, *hbox, *ebox, *frame;
+	const char *loc, *tmp, *str, *tmp1;
+	ECalComponentOrganizer organiser;	
+	ECalComponentDateTime dtstart, dtend;
+	struct icaltimetype *start;
+	icalcomponent *clone_comp;
+	time_t t_start, t_end;
+	
+	ECalComponent *newcomp = e_cal_component_new ();
+	icaltimezone *zone;
+	GdkColor color, outer_color;
+
+     	gdk_color_parse ("PeachPuff2", &color);		
+	gdk_color_parse ("antique white", &outer_color);
+
+	clone_comp = icalcomponent_new_clone (pevent->comp_data->icalcomp);
+	if (!e_cal_component_set_icalcomponent (newcomp, clone_comp))
+		g_warning ("couldn't update calendar component with modified data from backend\n");
+
+	box = gtk_vbox_new (FALSE, 0);
+
+	str = icalcomponent_get_summary (pevent->comp_data->icalcomp);
+	tmp = g_strdup_printf ("<b>%s</b>", str);
+	label = gtk_label_new (NULL);
+	gtk_label_set_markup (label, tmp);
+	
+	hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (hbox, label, FALSE, FALSE, 0);
+	ebox = gtk_event_box_new ();
+	gtk_container_add (ebox, hbox);
+	gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_ACTIVE, &color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_SELECTED, &color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_PRELIGHT, &color);
+	
+	gtk_box_pack_start (box, ebox, FALSE, FALSE, 0);
+	g_free (tmp);
+	
+	e_cal_component_get_organizer (newcomp, &organiser);
+	if (organiser.cn) {
+		char *ptr ; 
+		GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
+		ptr = strchr(organiser.value, ':');
+		ptr++;
+		tmp = g_strdup_printf ("Organiser: %s <%s>", organiser.cn, ptr);
+		label = gtk_label_new (tmp);
+		gtk_box_pack_start (hbox, label, FALSE, FALSE, 0);
+		ebox = gtk_event_box_new ();
+		gtk_container_add (ebox, hbox);
+		gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_ACTIVE, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_SELECTED, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_PRELIGHT, &outer_color);		
+		gtk_box_pack_start (box, ebox, FALSE, FALSE, 0);
+
+		g_free (tmp);
+	}
+	
+	e_cal_component_get_location (newcomp, &str);
+
+	if (str) {
+		tmp = g_strdup_printf ("Location: %s", str);
+		label = gtk_label_new (NULL);
+		gtk_label_set_markup (label, tmp);
+		hbox = gtk_hbox_new (FALSE, 0);
+		gtk_box_pack_start (hbox, label, FALSE, FALSE, 0);
+		ebox = gtk_event_box_new ();
+		gtk_container_add (ebox, hbox);
+		gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_ACTIVE, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_SELECTED, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_PRELIGHT, &outer_color);		
+		gtk_box_pack_start (box, ebox, FALSE, FALSE, 0);
+		g_free (tmp);
+	}
+	e_cal_component_get_dtstart (newcomp, &dtstart);
+	e_cal_component_get_dtend (newcomp, &dtend);
+			
+	if (dtstart.tzid) {
+		zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (newcomp), dtstart.tzid);
+	} else {
+		zone = NULL;
+	}
+	t_start = icaltime_as_timet_with_zone (*dtstart.value, zone);
+		
+	if (dtend.tzid) {
+		zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (newcomp), dtend.tzid);
+	} else {
+		zone = NULL;
+	}
+	t_end = icaltime_as_timet_with_zone (*dtend.value, zone);
+		
+	tmp1 = get_label(dtstart.value);
+	tmp = calculate_time (t_start, t_end);
+
+	str = g_strdup_printf("Time: %s %s", tmp1, tmp);
+	hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (hbox, gtk_label_new_with_mnemonic (str), TRUE, TRUE, 0);
+	ebox = gtk_event_box_new ();
+	gtk_container_add (ebox, hbox);
+	gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &outer_color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_ACTIVE, &outer_color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_SELECTED, &outer_color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_PRELIGHT, &outer_color);		
+	gtk_box_pack_start (box, ebox, FALSE, FALSE, 0);
+	
+	g_free (tmp);
+	g_free (str);
+	g_free (tmp1);
+
+	pevent->tooltip = gtk_window_new (GTK_WINDOW_POPUP);
+	frame = gtk_frame_new (NULL);
+	gtk_frame_set_shadow_type (frame, GTK_SHADOW_IN);
+	
+	gtk_window_move (pevent->tooltip, pevent->x +16, pevent->y+16);
+	gtk_container_add (frame, box);
+	gtk_container_add (pevent->tooltip, frame);
+			
+	gtk_widget_show_all (pevent->tooltip);	
+	gdk_keyboard_grab (pevent->tooltip->window, FALSE, GDK_CURRENT_TIME);
+	g_signal_connect (pevent->tooltip, "key-press-event", G_CALLBACK (tooltip_grab), pevent);
+	pevent->timeout = -1;
+
+	g_object_unref (newcomp);
+	
+	return FALSE;
+}
+
+
 static gboolean
 e_day_view_on_text_item_event (GnomeCanvasItem *item,
 			       GdkEvent *event,
@@ -5825,10 +6044,50 @@ e_day_view_on_text_item_event (GnomeCanv
 			e_day_view_on_editing_stopped (day_view, item);
 
 		return FALSE;
+	case GDK_ENTER_NOTIFY:
+		{
+			EDayViewEvent *pevent = g_object_get_data (item, "event");
+			
+			pevent->x = ((GdkEventCrossing *)event)->x_root;
+			pevent->y = ((GdkEventCrossing *)event)->y_root;
+			pevent->color = &((GtkWidget *)day_view)->style->bg_gc[GTK_STATE_NORMAL];
+			pevent->timeout = g_timeout_add (500, get_tooltip_widget, pevent);
+			
+		return TRUE;
+		}
+	case GDK_LEAVE_NOTIFY:
+		{
+			EDayViewEvent *pevent = g_object_get_data (item, "event");
+			
+			if (pevent && pevent->tooltip) {
+				gtk_widget_destroy (pevent->tooltip);
+				pevent->tooltip = NULL;
+			}
+
+			if (pevent && pevent->timeout != -1) {
+				g_source_remove (pevent->timeout);
+				pevent->timeout = -1;
+			}
+			
+		return TRUE;
+		}
+	case GDK_MOTION_NOTIFY:
+		{
+			EDayViewEvent *pevent = g_object_get_data (item, "event");
+			
+			pevent->x = ((GdkEventMotion *)event)->x_root;
+			pevent->y = ((GdkEventMotion *)event)->y_root;
+
+			if (pevent->tooltip) {
+				gtk_window_move (pevent->tooltip, ((int)((GdkEventMotion *)event)->x_root)+16, ((int)((GdkEventMotion *)event)->y_root) +16);
+			}
+
+			return TRUE;
+		}
 	default:
 		break;
 	}
-
+	
 	return FALSE;
 }
 
Index: e-day-view.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.h,v
retrieving revision 1.66
diff -u -p -r1.66 e-day-view.h
--- e-day-view.h	30 May 2005 09:14:26 -0000	1.66
+++ e-day-view.h	11 Nov 2005 14:17:18 -0000
@@ -169,6 +169,12 @@ typedef struct _EDayViewEvent EDayViewEv
 struct _EDayViewEvent {
 	E_CALENDAR_VIEW_EVENT_FIELDS
 
+	/* ToolTips*/
+	GtkWidget *tooltip;
+	gint	timeout;
+	GdkColor *color;
+	gint x,y;
+		
 	/* For events in the main canvas, this contains the start column.
 	   For long events in the top canvas, this is its row. */
 	guint8 start_row_or_col;
Index: e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.249
diff -u -p -r1.249 e-week-view.c
--- e-week-view.c	1 Oct 2005 15:01:57 -0000	1.249
+++ e-week-view.c	11 Nov 2005 14:17:51 -0000
@@ -2391,6 +2391,9 @@ e_week_view_add_event (ECalComponent *co
 	}
 	event.start = start;
 	event.end = end;
+	event.tooltip = NULL;
+	event.timeout = NULL;
+	event.color = NULL;
 	event.spans_index = 0;
 	event.num_spans = 0;
 	event.comp_data->instance_start = start;
@@ -2547,6 +2550,262 @@ e_week_view_reshape_events (EWeekView *w
 }
 
 
+static char *
+calculate_time (time_t start, time_t end)
+{
+	time_t difference = end - start;
+	char *str;
+	
+	if (difference < 60) {/* Can't be zero */ 
+		str = g_strdup_printf (_("(%d seconds)"), difference);
+	} else if (difference > 60 && difference < 3600) { /* It will be x minutes y seconds*/
+		int minutes, seconds;
+		minutes = difference / 60;
+		seconds = difference % 60;
+		if (seconds)
+			str = g_strdup_printf (_("(%d %s %d %s)"), minutes, ngettext(_("minute"), _("minutes"), minutes), seconds, ngettext(_("second"), _("seconds"), seconds));
+		else 
+			str = g_strdup_printf (_("(%d %s)"), minutes, ngettext(_("minute"), _("minutes"), minutes));
+	} else {
+		guint hours, minutes, seconds;
+		char *s_hours = NULL, *s_minutes = NULL, *s_seconds = NULL;
+		
+		hours = difference / 3600;
+		minutes = (difference % 3600)/60;
+		seconds = difference % 60;
+
+
+		if (seconds)
+			s_seconds = g_strdup_printf (ngettext(_(" %u second"), _(" %u seconds"), seconds), seconds);	
+		if (minutes)
+			s_minutes = g_strdup_printf (ngettext(_(" %u minute"), _(" %u minutes"), minutes), minutes);
+		if (hours)
+			s_hours = g_strdup_printf (ngettext(_("%u hour"),_("%u hours"), hours), hours);
+
+		if (s_minutes && s_seconds)
+			str = g_strconcat ("(", s_hours, s_minutes, s_seconds, ")", NULL);
+		else if (s_minutes)
+			str = g_strconcat ("(", s_hours, s_minutes, ")", NULL);
+		else if (s_seconds)
+			str = g_strconcat ("(", s_hours, s_seconds, ")", NULL);
+		else 
+			str = g_strconcat ("(", s_hours, ")", NULL);
+
+		g_free (s_hours);
+		g_free (s_minutes);
+		g_free (s_seconds);
+	}
+
+	return g_strchug(str);
+}
+
+static char *
+get_label (struct icaltimetype *tt)
+{
+        char buffer[1000];
+        struct tm tmp_tm;
+
+	tmp_tm = icaltimetype_to_tm (tt);
+        e_time_format_date_and_time (&tmp_tm,
+                                     calendar_config_get_24_hour_format (),
+                                     FALSE, FALSE,
+                                     buffer, 1000);
+
+        return g_strdup (buffer);
+}
+
+/* Show something like
+ * Appointment: [][][]
+ * From: foo bar com
+ * Subject: FooBar
+ * Location: BarFoo
+ * */
+
+static gboolean
+tooltip_grab (GtkWidget *tooltip, GdkEventKey *event, EWeekViewEvent *pevent)
+{
+	gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+
+	gtk_widget_destroy (pevent->tooltip);
+	pevent->tooltip = NULL;
+	pevent->timeout = -1;
+
+	return FALSE;
+}
+
+static GtkWidget *
+get_tooltip_widget (EWeekViewEvent *pevent)
+{
+	GtkWidget *label, *box, *hbox, *ebox, *frame;
+	const char *loc, *tmp, *str, *tmp1;
+	ECalComponentOrganizer organiser;	
+	ECalComponentDateTime dtstart, dtend;
+	struct icaltimetype *start;
+	icalcomponent *clone_comp;
+	time_t t_start, t_end;
+	
+	ECalComponent *newcomp = e_cal_component_new ();
+	icaltimezone *zone;
+	GdkColor color, outer_color;
+
+     	gdk_color_parse ("PeachPuff2", &color);		
+	gdk_color_parse ("antique white", &outer_color);
+
+	clone_comp = icalcomponent_new_clone (pevent->comp_data->icalcomp);
+	if (!e_cal_component_set_icalcomponent (newcomp, clone_comp))
+		g_warning ("couldn't update calendar component with modified data from backend\n");
+
+	box = gtk_vbox_new (FALSE, 0);
+
+	str = icalcomponent_get_summary (pevent->comp_data->icalcomp);
+	tmp = g_strdup_printf ("<b>%s</b>", str);
+	label = gtk_label_new (NULL);
+	gtk_label_set_markup (label, tmp);
+	
+	hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (hbox, label, FALSE, FALSE, 0);
+	ebox = gtk_event_box_new ();
+	gtk_container_add (ebox, hbox);
+	gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_ACTIVE, &color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_SELECTED, &color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_PRELIGHT, &color);
+	
+	gtk_box_pack_start (box, ebox, FALSE, FALSE, 0);
+	g_free (tmp);
+	
+	e_cal_component_get_organizer (newcomp, &organiser);
+	if (organiser.cn) {
+		char *ptr ; 
+		GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
+		ptr = strchr(organiser.value, ':');
+		ptr++;
+		tmp = g_strdup_printf ("Organiser: %s <%s>", organiser.cn, ptr);
+		label = gtk_label_new (tmp);
+		gtk_box_pack_start (hbox, label, FALSE, FALSE, 0);
+		ebox = gtk_event_box_new ();
+		gtk_container_add (ebox, hbox);
+		gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_ACTIVE, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_SELECTED, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_PRELIGHT, &outer_color);		
+		gtk_box_pack_start (box, ebox, FALSE, FALSE, 0);
+
+		g_free (tmp);
+	}
+	
+	e_cal_component_get_location (newcomp, &str);
+
+	if (str) {
+		tmp = g_strdup_printf ("Location: %s", str);
+		label = gtk_label_new (NULL);
+		gtk_label_set_markup (label, tmp);
+		hbox = gtk_hbox_new (FALSE, 0);
+		gtk_box_pack_start (hbox, label, FALSE, FALSE, 0);
+		ebox = gtk_event_box_new ();
+		gtk_container_add (ebox, hbox);
+		gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_ACTIVE, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_SELECTED, &outer_color);
+		gtk_widget_modify_bg (ebox, GTK_STATE_PRELIGHT, &outer_color);		
+		gtk_box_pack_start (box, ebox, FALSE, FALSE, 0);
+		g_free (tmp);
+	}
+	e_cal_component_get_dtstart (newcomp, &dtstart);
+	e_cal_component_get_dtend (newcomp, &dtend);
+			
+	if (dtstart.tzid) {
+		zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (newcomp), dtstart.tzid);
+	} else {
+		zone = NULL;
+	}
+	t_start = icaltime_as_timet_with_zone (*dtstart.value, zone);
+		
+	if (dtend.tzid) {
+		zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (newcomp), dtend.tzid);
+	} else {
+		zone = NULL;
+	}
+	t_end = icaltime_as_timet_with_zone (*dtend.value, zone);
+		
+	tmp1 = get_label(dtstart.value);
+	tmp = calculate_time (t_start, t_end);
+
+	str = g_strdup_printf("Time: %s %s", tmp1, tmp);
+	hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (hbox, gtk_label_new_with_mnemonic (str), TRUE, TRUE, 0);
+	ebox = gtk_event_box_new ();
+	gtk_container_add (ebox, hbox);
+	gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &outer_color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_ACTIVE, &outer_color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_SELECTED, &outer_color);
+	gtk_widget_modify_bg (ebox, GTK_STATE_PRELIGHT, &outer_color);		
+	gtk_box_pack_start (box, ebox, FALSE, FALSE, 0);
+	
+	g_free (tmp);
+	g_free (str);
+	g_free (tmp1);
+
+	pevent->tooltip = gtk_window_new (GTK_WINDOW_POPUP);
+	frame = gtk_frame_new (NULL);
+	gtk_frame_set_shadow_type (frame, GTK_SHADOW_IN);
+	
+	gtk_window_move (pevent->tooltip, pevent->x +16, pevent->y+16);
+	gtk_container_add (frame, box);
+	gtk_container_add (pevent->tooltip, frame);
+			
+	gtk_widget_show_all (pevent->tooltip);	
+	gdk_keyboard_grab (pevent->tooltip->window, FALSE, GDK_CURRENT_TIME);
+	g_signal_connect (pevent->tooltip, "key-press-event", G_CALLBACK (tooltip_grab), pevent);
+	pevent->timeout = -1;
+
+	g_object_unref (newcomp);
+	
+	return FALSE;
+}
+
+static gboolean
+tooltip_event_cb (GnomeCanvasItem *item,
+   	          GdkEvent *event,
+		  EWeekView *view)
+{
+	EWeekViewEvent *pevent = g_object_get_data (item, "event");
+	
+	switch (event->type) {
+		case GDK_ENTER_NOTIFY:
+			
+			pevent->x = ((GdkEventCrossing *)event)->x_root;
+			pevent->y = ((GdkEventCrossing *)event)->y_root;
+			pevent->color = &((GtkWidget *)view)->style->bg_gc[GTK_STATE_NORMAL];
+			pevent->timeout = g_timeout_add (500, get_tooltip_widget, pevent);
+			
+			return TRUE;
+		
+		case GDK_LEAVE_NOTIFY:
+			if (pevent && pevent->tooltip) {
+				gtk_widget_destroy (pevent->tooltip);
+				pevent->tooltip = NULL;
+			}
+
+			if (pevent && pevent->timeout != -1) {
+				g_source_remove (pevent->timeout);
+				pevent->timeout = -1;
+			}
+			return TRUE;
+		case GDK_MOTION_NOTIFY:
+			pevent->x = ((GdkEventMotion *)event)->x_root;
+			pevent->y = ((GdkEventMotion *)event)->y_root;
+
+			if (pevent->tooltip) {
+				gtk_window_move (pevent->tooltip, ((int)((GdkEventMotion *)event)->x_root)+16, ((int)((GdkEventMotion *)event)->y_root) +16);
+			}
+
+			return TRUE;
+	}
+
+	return FALSE;
+}
+
 static void
 e_week_view_reshape_event_span (EWeekView *week_view,
 				gint event_num,
@@ -2640,7 +2899,12 @@ e_week_view_reshape_event_span (EWeekVie
 					       e_week_view_event_item_get_type (),
 					       NULL);
 	}
-
+	
+	g_object_set_data (span->background_item, "event", event);
+	g_signal_connect (span->background_item, "event",
+			  G_CALLBACK (tooltip_event_cb),
+			  week_view);
+	
 	gnome_canvas_item_set (span->background_item,
 			       "event_num", event_num,
 			       "span_num", span_num,
@@ -2671,7 +2935,7 @@ e_week_view_reshape_event_span (EWeekVie
 				&& e_cal_util_component_has_attendee (event->comp_data->icalcomp)) {
 			set_text_as_bold (event, span);
 		} */
-
+		g_object_set_data (span->text_item, "event", event);		
 		g_signal_connect (span->text_item, "event",
 				  G_CALLBACK (e_week_view_on_text_item_event),
 				  week_view);
@@ -2940,11 +3204,12 @@ e_week_view_on_text_item_event (GnomeCan
 {
 	EWeekViewEvent *event;
 	gint event_num, span_num;
-
+	EWeekViewEvent *pevent = g_object_get_data (item, "event");
+	
 #if 0
 	g_print ("In e_week_view_on_text_item_event\n");
 #endif
-
+	
 	switch (gdkevent->type) {
 	case GDK_KEY_PRESS:
 		if (gdkevent && gdkevent->key.keyval == GDK_Return) {
@@ -3055,6 +3320,35 @@ e_week_view_on_text_item_event (GnomeCan
 		}
 		week_view->pressed_event_num = -1;
 		break;
+		case GDK_ENTER_NOTIFY:
+			
+			pevent->x = ((GdkEventCrossing *)gdkevent)->x_root;
+			pevent->y = ((GdkEventCrossing *)gdkevent)->y_root;
+			pevent->color = &((GtkWidget *)week_view)->style->bg_gc[GTK_STATE_NORMAL];
+			pevent->timeout = g_timeout_add (500, get_tooltip_widget, pevent);
+			
+			return TRUE;
+		
+		case GDK_LEAVE_NOTIFY:
+			if (pevent && pevent->tooltip) {
+				gtk_widget_destroy (pevent->tooltip);
+				pevent->tooltip = NULL;
+			}
+
+			if (pevent && pevent->timeout != -1) {
+				g_source_remove (pevent->timeout);
+				pevent->timeout = -1;
+			}
+			return TRUE;
+		case GDK_MOTION_NOTIFY:
+			pevent->x = ((GdkEventMotion *)gdkevent)->x_root;
+			pevent->y = ((GdkEventMotion *)gdkevent)->y_root;
+
+			if (pevent->tooltip) {
+				gtk_window_move (pevent->tooltip, ((int)((GdkEventMotion *)gdkevent)->x_root)+16, ((int)((GdkEventMotion *)gdkevent)->y_root) +16);
+			}
+
+			return TRUE;		
 	case GDK_FOCUS_CHANGE:
 		if (gdkevent->focus_change.in) {
 			e_week_view_on_editing_started (week_view, item);
Index: e-week-view.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.h,v
retrieving revision 1.57
diff -u -p -r1.57 e-week-view.h
--- e-week-view.h	8 Jan 2005 10:53:53 -0000	1.57
+++ e-week-view.h	11 Nov 2005 14:17:51 -0000
@@ -143,6 +143,13 @@ struct _EWeekViewEventSpan {
 typedef struct _EWeekViewEvent EWeekViewEvent;
 struct _EWeekViewEvent {
 	E_CALENDAR_VIEW_EVENT_FIELDS
+
+	/* ToolTips*/
+	GtkWidget *tooltip;
+	gint	timeout;
+	GdkColor *color;
+	gint x,y;
+
 	gint spans_index;
 	guint8 num_spans;
 };


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