Exemple #1
0
/**
 * ea_calendar_helpers_get_cal_view_event_from
 * @canvas_item: the cavas_item (e_text) for the event
 *
 * Get the ECalendarViewEvent for the canvas_item.
 *
 * Returns: the ECalendarViewEvent
 **/
ECalendarViewEvent *
ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item)
{
	ECalendarView *cal_view;
	gboolean event_found;
	ECalendarViewEvent *cal_view_event;

	g_return_val_if_fail (E_IS_TEXT (canvas_item), NULL);

	cal_view = ea_calendar_helpers_get_cal_view_from (canvas_item);

	if (!cal_view)
		return NULL;

	if (E_IS_DAY_VIEW (cal_view)) {
		gint event_day, event_num;
		EDayViewEvent *day_view_event;
		EDayView *day_view = E_DAY_VIEW (cal_view);
		event_found = e_day_view_find_event_from_item (
			day_view, canvas_item,
			&event_day, &event_num);
		if (!event_found)
			return NULL;
		if (event_day == E_DAY_VIEW_LONG_EVENT) {
			/* a long event */
			day_view_event = &g_array_index (day_view->long_events,
							 EDayViewEvent, event_num);
		}
		else {
			/* a main canvas event */
			day_view_event = &g_array_index (day_view->events[event_day],
							 EDayViewEvent, event_num);
		}
		cal_view_event = (ECalendarViewEvent *) day_view_event;
	}
	else if (E_IS_WEEK_VIEW (cal_view)) {
		gint event_num, span_num;
		EWeekViewEvent *week_view_event;
		EWeekView *week_view = E_WEEK_VIEW (cal_view);
		event_found = e_week_view_find_event_from_item (
			week_view,
			canvas_item,
			&event_num,
			&span_num);
		if (!event_found)
			return NULL;

		week_view_event = &g_array_index (
			week_view->events, EWeekViewEvent, event_num);

		cal_view_event = (ECalendarViewEvent *) week_view_event;
	}
	else {
		g_return_val_if_reached (NULL);
	}
	return cal_view_event;
}
Exemple #2
0
static void
annum_shell_view_date_navigator_selection_changed_cb (AnnumShellView * self,
						       ECalendarItem * calitem)
{
	AnnumShellContent *prox_shell_content;
	GnomeCalendarViewType switch_to;
	GnomeCalendarViewType view_type;
	GnomeCalendar *calendar;
	ECalModel *model;
	GDate start_date, end_date;
	GDate new_start_date, new_end_date;
	icaltimetype tt;
	icaltimezone *timezone;
	time_t start, end, new_time;
	gboolean starts_on_week_start_day;
	gint new_days_shown;
	gint week_start_day;

	prox_shell_content = self->priv->prox_shell_content;
	calendar = annum_shell_content_get_calendar (prox_shell_content);

	model = gnome_calendar_get_model (calendar);
	view_type = gnome_calendar_get_view (calendar);
	switch_to = view_type;

	timezone = e_cal_model_get_timezone (model);
	week_start_day = e_cal_model_get_week_start_day (model);
	e_cal_model_get_time_range (model, &start, &end);

	time_to_gdate_with_zone (&start_date, start, timezone);
	time_to_gdate_with_zone (&end_date, end, timezone);

	if (view_type == GNOME_CAL_MONTH_VIEW) {
		EWeekView *week_view;
		ECalendarView *calendar_view;
		gboolean multi_week_view;
		gboolean compress_weekend;

		calendar_view =
		    gnome_calendar_get_calendar_view (calendar,
						      GNOME_CAL_MONTH_VIEW);

		week_view = E_WEEK_VIEW (calendar_view);
		multi_week_view = e_week_view_get_multi_week_view (week_view);
		compress_weekend = e_week_view_get_compress_weekend (week_view);

		if (week_start_day == 0
		    && (!multi_week_view || compress_weekend))
			g_date_add_days (&start_date, 1);
	}

	g_date_subtract_days (&end_date, 1);

	e_calendar_item_get_selection (calitem, &new_start_date, &new_end_date);

	/* There used to be a check here to make sure the rest of the
	 * code only ran when the date actually changed. We do not
	 * this to simplify always having three columns for the day
	 * view.
	 */

	new_days_shown =
	    g_date_get_julian (&new_end_date) -
	    g_date_get_julian (&new_start_date) + 1;

	/* If a complete week is selected we show the week view.
	 * Note that if weekends are compressed and the week start
	 * day is set to Sunday, we don't actually show complete
	 * weeks in the week view, so this may need tweaking. */
	starts_on_week_start_day =
	    (g_date_get_weekday (&new_start_date) % 7 == week_start_day);

	/* Update selection to be in the new time range. */
	tt = icaltime_null_time ();
	tt.year = g_date_get_year (&new_start_date);
	tt.month = g_date_get_month (&new_start_date);
	tt.day = g_date_get_day (&new_start_date);
	new_time = icaltime_as_timet_with_zone (tt, timezone);

	/* Switch views as appropriate, and change the number of
	 * days or weeks shown. */
	if (new_days_shown > 9) {
		if (view_type != GNOME_CAL_LIST_VIEW) {
			ECalendarView *calendar_view;

			calendar_view =
			    gnome_calendar_get_calendar_view (calendar,
							      GNOME_CAL_MONTH_VIEW);
			e_week_view_set_weeks_shown (E_WEEK_VIEW
						     (calendar_view),
						     (new_days_shown + 6) / 7);
			switch_to = GNOME_CAL_MONTH_VIEW;
		}
	} else if (new_days_shown == 7 && starts_on_week_start_day)
		switch_to = GNOME_CAL_WEEK_VIEW;
	else {
		ECalendarView *calendar_view;

		calendar_view =
		    gnome_calendar_get_calendar_view (calendar,
						      GNOME_CAL_DAY_VIEW);

		/* We always show three days */
		if (new_days_shown == 1)
		    new_days_shown = 3;

		e_day_view_set_days_shown (E_DAY_VIEW (calendar_view),
					   new_days_shown);

		if (new_days_shown != 5 || !starts_on_week_start_day)
			switch_to = GNOME_CAL_DAY_VIEW;

		else if (view_type != GNOME_CAL_WORK_WEEK_VIEW)
			switch_to = GNOME_CAL_DAY_VIEW;
	}

	/* Make the views display things properly. */
	gnome_calendar_update_view_times (calendar, new_time);
	gnome_calendar_set_view (calendar, switch_to);
	gnome_calendar_set_range_selected (calendar, TRUE);

	gnome_calendar_notify_dates_shown_changed (calendar);

	g_signal_emit (self, signals[DATE_CHANGED], 0, switch_to);
}
Exemple #3
0
static gboolean
ea_calendar_focus_watcher (GSignalInvocationHint *ihint,
                           guint n_param_values,
                           const GValue *param_values,
                           gpointer data)
{
	GObject *object;
	GdkEvent *event;
        AtkObject *ea_event = NULL;

	object = g_value_get_object (param_values + 0);
	event = g_value_get_boxed (param_values + 1);

	if ((E_IS_TEXT (object)) || (GNOME_IS_CANVAS_PIXBUF (object))) {
		/* "event" signal on canvas item
		 */
		GnomeCanvasItem *canvas_item;

		canvas_item = GNOME_CANVAS_ITEM (object);
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				ea_event =
					ea_calendar_helpers_get_accessible_for (canvas_item);
				if (!ea_event)
					/* not canvas item we want */
					return TRUE;

			}
			atk_focus_tracker_notify (ea_event);
		}
	}
	else if (E_IS_DAY_VIEW (object)) {
		EDayView *day_view = E_DAY_VIEW (object);
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				/* give main item chance to emit focus */
				gnome_canvas_item_grab_focus (day_view->main_canvas_item);
			}
		}
	}
	else if (E_IS_DAY_VIEW_MAIN_ITEM (object)) {
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				/* we should emit focus on main item */
				ea_event = atk_gobject_accessible_for_object (object);
			}
			else
				/* focus out */
				ea_event = NULL;
#ifdef ACC_DEBUG
			printf ("EvoAcc: focus notify on day main item %p\n", (void *)object);
#endif
			atk_focus_tracker_notify (ea_event);
		}
	} else if (E_IS_WEEK_VIEW (object)) {
		EWeekView *week_view = E_WEEK_VIEW (object);
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				/* give main item chance to emit focus */
				gnome_canvas_item_grab_focus (week_view->main_canvas_item);
			}
		}
	}
	else if (E_IS_WEEK_VIEW_MAIN_ITEM (object)) {
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				/* we should emit focus on main item */
				ea_event = atk_gobject_accessible_for_object (object);
			}
			else
				/* focus out */
				ea_event = NULL;
#ifdef ACC_DEBUG
			printf ("EvoAcc: focus notify on week main item %p\n", (void *)object);
#endif
			atk_focus_tracker_notify (ea_event);
		}
	}
	return TRUE;
}