diff options
author | Chenthill Palanisamy <pchen@src.gnome.org> | 2006-01-16 20:59:44 +0800 |
---|---|---|
committer | Chenthill Palanisamy <pchen@src.gnome.org> | 2006-01-16 20:59:44 +0800 |
commit | 6c80f5f32138e8405e3490f0de42871794773bcb (patch) | |
tree | 94b6e441b8357bdf4c58880d7897c5bf06a63cac /calendar | |
parent | 14c9dc50969c61a7783bab1af5042d0570c2ffb0 (diff) | |
download | gsoc2013-evolution-6c80f5f32138e8405e3490f0de42871794773bcb.tar gsoc2013-evolution-6c80f5f32138e8405e3490f0de42871794773bcb.tar.gz gsoc2013-evolution-6c80f5f32138e8405e3490f0de42871794773bcb.tar.bz2 gsoc2013-evolution-6c80f5f32138e8405e3490f0de42871794773bcb.tar.lz gsoc2013-evolution-6c80f5f32138e8405e3490f0de42871794773bcb.tar.xz gsoc2013-evolution-6c80f5f32138e8405e3490f0de42871794773bcb.tar.zst gsoc2013-evolution-6c80f5f32138e8405e3490f0de42871794773bcb.zip |
fixes #324739
svn path=/trunk/; revision=31213
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 13 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 33 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 78 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 43 |
4 files changed, 117 insertions, 50 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index fac1693b6f..6a0018961b 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,16 @@ +2006-01-16 Srinivasa Ragavan <sragavan@novell.com> + + Fixes #324739 + * gui/e-calendar-view.c: (tooltip_grab), + (e_calendar_view_get_tooltips): + * gui/e-day-view.c: (e_day_view_convert_event_coords), + (e_day_view_on_time_canvas_scroll), (tooltip_get_view_event), + (tooltip_destroy), (e_day_view_on_text_item_event), + (e_day_view_on_editing_stopped): + * gui/e-week-view.c: (e_week_view_on_scroll), (tooltip_destroy), + (tooltip_event_cb), (e_week_view_on_text_item_event), + (e_week_view_on_editing_stopped): + 2006-01-16 Chenthill Palanisamy <pchenthill@novell.com> Patch submitted by Sebastien Bacher <seb128@debian.org> diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 64b4287e75..2eabbe5901 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -1942,14 +1942,17 @@ e_calendar_view_modify_and_send (ECalComponent *comp, } static gboolean -tooltip_grab (GtkWidget *tooltip, GdkEventKey *event, ECalendarViewEvent *pevent) +tooltip_grab (GtkWidget *tooltip, GdkEventKey *event, ECalendarView *view) { - gdk_keyboard_ungrab(GDK_CURRENT_TIME); + GtkWidget *widget = (GtkWidget *) g_object_get_data (view, "tooltip-window"); - gtk_widget_destroy (pevent->tooltip); - pevent->tooltip = NULL; - pevent->timeout = -1; + if (!widget) + return; + gdk_keyboard_ungrab(GDK_CURRENT_TIME); + gtk_widget_destroy (widget); + g_object_set_data (view, "tooltip-window", NULL); + return FALSE; } @@ -1989,12 +1992,15 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data) time_t t_start, t_end; ECalendarViewEvent *pevent; GtkStyle *style = gtk_widget_get_default_style (); - - pevent = data->get_view_event (data->cal_view, data->day, data->event_num); - g_free (data); - + GtkWidget *widget = (GtkWidget *) g_object_get_data (data->cal_view, "tooltip-window"); ECalComponent *newcomp = e_cal_component_new (); - icaltimezone *zone; + icaltimezone *zone; + + /* Delete any stray tooltip if left */ + if (widget) + gtk_widget_destroy (widget); + + pevent = data->get_view_event (data->cal_view, data->day, data->event_num); clone_comp = icalcomponent_new_clone (pevent->comp_data->icalcomp); if (!e_cal_component_set_icalcomponent (newcomp, clone_comp)) @@ -2007,6 +2013,7 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data) if (!(str && *str)) { g_object_unref (newcomp); gtk_widget_destroy (box); + g_free (data); return FALSE; } @@ -2099,11 +2106,13 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data) 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); + g_signal_connect (pevent->tooltip, "key-press-event", G_CALLBACK (tooltip_grab), data->cal_view); pevent->timeout = -1; + g_object_set_data (data->cal_view, "tooltip-window", pevent->tooltip); g_object_unref (newcomp); - + g_free (data); + return FALSE; } diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 47c466602d..d7caff97ce 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -2835,6 +2835,12 @@ e_day_view_convert_event_coords (EDayView *day_view, event_y = event->motion.y; event_window = event->motion.window; break; + case GDK_ENTER_NOTIFY: + case GDK_LEAVE_NOTIFY: + event_x = event->crossing.x; + event_y = event->crossing.y; + event_window = event->crossing.window; + break; default: /* Shouldn't get here. */ g_assert_not_reached (); @@ -2959,6 +2965,12 @@ e_day_view_on_time_canvas_scroll (GtkWidget *widget, GdkEventScroll *scroll, EDayView *day_view) { + GtkWidget *tool_window = g_object_get_data ((GObject *)day_view, "tooltip-window"); + + if (tool_window) { + gtk_widget_destroy (tool_window); + g_object_set_data (day_view, "tooltip-window", NULL); + } switch (scroll->direction) { case GDK_SCROLL_UP: @@ -5777,7 +5789,6 @@ tooltip_get_view_event (EDayView *day_view, int day, int event_num) { EDayViewEvent *pevent; - if (day == E_DAY_VIEW_LONG_EVENT) { pevent = &g_array_index (day_view->long_events, EDayViewEvent, event_num); @@ -5792,13 +5803,13 @@ tooltip_get_view_event (EDayView *day_view, int day, int event_num) static void tooltip_destroy (EDayView *day_view, GnomeCanvasItem *item) { - int day = GPOINTER_TO_INT (g_object_get_data (item, "event-day")); - int event_num = GPOINTER_TO_INT (g_object_get_data (item, "event-num")); EDayViewEvent *pevent; + int event_num = GPOINTER_TO_INT(g_object_get_data ((GObject *)item, "event-num")); + int day = GPOINTER_TO_INT(g_object_get_data ((GObject *)item, "event-day")); pevent = tooltip_get_view_event (day_view, day, event_num); if (pevent) { - if (pevent->tooltip) { + if (pevent->tooltip && g_object_get_data (day_view, "tooltip-window")) { gtk_widget_destroy (pevent->tooltip); pevent->tooltip = NULL; } @@ -5807,6 +5818,8 @@ tooltip_destroy (EDayView *day_view, GnomeCanvasItem *item) g_source_remove (pevent->timeout); pevent->timeout = -1; } + + g_object_set_data (day_view, "tooltip-window", NULL); } } @@ -5874,12 +5887,45 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item, return FALSE; case GDK_ENTER_NOTIFY: { - int day = GPOINTER_TO_INT (g_object_get_data (item, "event-day")); - int event_num = GPOINTER_TO_INT (g_object_get_data (item, "event-num")); EDayViewEvent *pevent; ECalendarViewEventData *data; - + gint event_x, event_y, row, day, event_num; + ECalendarViewPosition pos; + gboolean main_canvas = TRUE; + + /* Convert the coords to the main canvas window, or return if the + window is not found. */ + if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event, + GTK_LAYOUT (day_view->main_canvas)->bin_window, + &event_x, &event_y)) { + main_canvas = FALSE; + if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event, + GTK_LAYOUT (day_view->top_canvas)->bin_window, + &event_x, &event_y)) { + return FALSE; + } + } + /* Find out where the mouse is. */ + if (main_canvas) { + pos = e_day_view_convert_position_in_main_canvas (day_view, + event_x, event_y, + &day, &row, + &event_num); + } else { + int tmp; + + pos = e_day_view_convert_position_in_top_canvas (day_view, + event_x, event_y, + &tmp, &event_num); + day = E_DAY_VIEW_LONG_EVENT; + } + + if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) + return FALSE; + pevent = tooltip_get_view_event (day_view, day, event_num); + g_object_set_data (item, "event-num", GINT_TO_POINTER (event_num)); + g_object_set_data (item, "event-day", GINT_TO_POINTER (day)); data = g_malloc (sizeof (ECalendarViewEventData)); pevent->x = ((GdkEventCrossing *)event)->x_root; @@ -5899,15 +5945,16 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item, return TRUE; case GDK_MOTION_NOTIFY: { - int day = GPOINTER_TO_INT (g_object_get_data (item, "event-day")); - int event_num = GPOINTER_TO_INT (g_object_get_data (item, "event-num")); EDayViewEvent *pevent; + int event_num = GPOINTER_TO_INT(g_object_get_data ((GObject *)item, "event-num")); + int day = GPOINTER_TO_INT(g_object_get_data ((GObject *)item, "event-day")); pevent = tooltip_get_view_event (day_view, day, event_num); pevent->x = ((GdkEventMotion *)event)->x_root; pevent->y = ((GdkEventMotion *)event)->y_root; - + pevent->tooltip = (GtkWidget *)g_object_get_data (day_view, "tooltip-window"); + if (pevent->tooltip) { gtk_window_move ((GtkWindow *)pevent->tooltip, ((int)((GdkEventMotion *)event)->x_root)+16, ((int)((GdkEventMotion *)event)->y_root) +16); } @@ -6331,17 +6378,6 @@ e_day_view_on_editing_stopped (EDayView *day_view, out: - if (event) { - if (event->tooltip) { - gtk_widget_destroy (event->tooltip); - event->tooltip = NULL; - } - - if (event->timeout != -1) { - g_source_remove (event->timeout); - event->timeout = -1; - } - } g_object_unref (comp); g_free (text); diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 41b1d5fae1..e1ba4b14b3 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -2155,6 +2155,12 @@ e_week_view_on_scroll (GtkWidget *widget, { GtkAdjustment *adj = GTK_RANGE (week_view->vscrollbar)->adjustment; gfloat new_value; + GtkWidget *tool_window = g_object_get_data (week_view, "tooltip-window"); + + if (tool_window) { + gtk_widget_destroy (tool_window); + g_object_set_data (week_view, "tooltip-window", NULL); + } switch (scroll->direction){ case GDK_SCROLL_UP: @@ -2567,7 +2573,7 @@ tooltip_destroy (EWeekView *week_view, GnomeCanvasItem *item) pevent = tooltip_get_view_event (week_view, -1, event_num); if (pevent) { - if (pevent->tooltip) { + if (pevent->tooltip && g_object_get_data (week_view, "tooltip-window")) { gtk_widget_destroy (pevent->tooltip); pevent->tooltip = NULL; } @@ -2576,6 +2582,7 @@ tooltip_destroy (EWeekView *week_view, GnomeCanvasItem *item) g_source_remove (pevent->timeout); pevent->timeout = -1; } + g_object_set_data (week_view, "tooltip-window", NULL); } } @@ -2611,7 +2618,8 @@ tooltip_event_cb (GnomeCanvasItem *item, case GDK_MOTION_NOTIFY: pevent->x = ((GdkEventMotion *)event)->x_root; pevent->y = ((GdkEventMotion *)event)->y_root; - + pevent->tooltip = (GtkWidget *)g_object_get_data (view, "tooltip-window"); + if (pevent->tooltip) { gtk_window_move ((GtkWindow *)pevent->tooltip, ((int)((GdkEventMotion *)event)->x_root)+16, ((int)((GdkEventMotion *)event)->y_root) +16); } @@ -3030,7 +3038,7 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, EWeekViewEvent *pevent; pevent = tooltip_get_view_event (week_view, -1, nevent); - + #if 0 g_print ("In e_week_view_on_text_item_event\n"); #endif @@ -3150,7 +3158,19 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, case GDK_ENTER_NOTIFY: { ECalendarViewEventData *data; - + int nspan; + + if (!e_week_view_find_event_from_item (week_view, + item, + &nevent, + &nspan)) + return FALSE; + + + g_object_set_data ((GObject *)item, "event-num", nevent); + + pevent = tooltip_get_view_event (week_view, -1, nevent); + data = g_malloc (sizeof (ECalendarViewEventData)); pevent->x = ((GdkEventCrossing *)gdkevent)->x_root; @@ -3172,7 +3192,8 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, case GDK_MOTION_NOTIFY: pevent->x = ((GdkEventMotion *)gdkevent)->x_root; pevent->y = ((GdkEventMotion *)gdkevent)->y_root; - + pevent->tooltip = (GtkWidget *)g_object_get_data (week_view, "tooltip-window"); + if (pevent->tooltip) gtk_window_move ((GtkWindow *)pevent->tooltip, ((int)((GdkEventMotion *)gdkevent)->x_root)+16, ((int)((GdkEventMotion *)gdkevent)->y_root) +16); @@ -3540,18 +3561,6 @@ e_week_view_on_editing_stopped (EWeekView *week_view, out: - if (event) { - if (event->tooltip) { - gtk_widget_destroy (event->tooltip); - event->tooltip = NULL; - } - - if (event->timeout != -1) { - g_source_remove (event->timeout); - event->timeout = -1; - } - } - g_free (text); g_object_unref (comp); |