/* Prints the calendar at its current view and time range */ void calendar_command_print (GnomeCalendar *gcal, GtkPrintOperationAction action) { if (gnome_calendar_get_view (gcal) == GNOME_CAL_LIST_VIEW) { ECalListView *list_view; ETable *table; list_view = E_CAL_LIST_VIEW (gnome_calendar_get_current_view_widget (gcal)); table = e_table_scrolled_get_table (list_view->table_scrolled); print_table (table, _("Print"), _("Calendar"), action); } else { time_t start; gnome_calendar_get_current_time_range (gcal, &start, NULL); print_calendar (gcal, action, start); } }
static void update_cal_entries_cb (EShellView *shell_view, gpointer user_data) { EShellWindow *shell_window; GtkActionGroup *action_group; gboolean visible = FALSE, is_unaccepted = FALSE, is_mtg_owner = FALSE; EShellContent *shell_content; GnomeCalendar *gcal = NULL; GnomeCalendarViewType view_type; ECalendarView *view; g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); g_object_get (shell_content, "calendar", &gcal, NULL); view_type = gnome_calendar_get_view (gcal); view = gnome_calendar_get_calendar_view (gcal, view_type); if (view) { GList *selected; selected = e_calendar_view_get_selected_events (view); if (selected && selected->data) { ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; const gchar *uri; uri = is_comp_data_valid (event) ? e_client_get_uri (E_CLIENT (event->comp_data->client)) : NULL; if (uri && g_ascii_strncasecmp (uri, "groupwise://", 12) == 0) { visible = e_cal_util_component_has_attendee (event->comp_data->icalcomp); if (visible) { ECalComponent *comp; comp = e_cal_component_new (); e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); if (e_client_check_capability (E_CLIENT (event->comp_data->client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)) { gchar *user_email; user_email = itip_get_comp_attendee (comp, event->comp_data->client); is_unaccepted = needs_to_accept (event->comp_data->icalcomp, user_email); g_free (user_email); } is_mtg_owner = is_meeting_owner (comp, event->comp_data->client); g_object_unref (comp); } } } g_list_free (selected); } action_group = e_shell_window_get_action_group (shell_window, "calendar"); visible_actions (action_group, visible, cal_entries, G_N_ELEMENTS (cal_entries)); if (visible && !is_unaccepted) { GtkAction *action; action = gtk_action_group_get_action (action_group, "gw-meeting-accept"); g_return_if_fail (action != NULL); gtk_action_set_visible (action, FALSE); action = gtk_action_group_get_action (action_group, "gw-meeting-accept-tentative"); g_return_if_fail (action != NULL); gtk_action_set_visible (action, FALSE); } if (visible && !is_mtg_owner) { GtkAction *action; action = gtk_action_group_get_action (action_group, "gw-resend-meeting"); g_return_if_fail (action != NULL); gtk_action_set_visible (action, FALSE); } g_object_unref (gcal); }
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); }