diff options
author | Milan Crha <mcrha@src.gnome.org> | 2007-08-20 17:45:44 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2007-08-20 17:45:44 +0800 |
commit | 8b5bd65751016d6ef8ba2ed2fd9b5fb5e7748624 (patch) | |
tree | bb56bd6de9e7b11d6cb7e03464d8b6650f2ec575 /calendar | |
parent | e3bc9c823718c769c9667b9f707fdabf0d8f0697 (diff) | |
download | gsoc2013-evolution-8b5bd65751016d6ef8ba2ed2fd9b5fb5e7748624.tar.gz gsoc2013-evolution-8b5bd65751016d6ef8ba2ed2fd9b5fb5e7748624.tar.zst gsoc2013-evolution-8b5bd65751016d6ef8ba2ed2fd9b5fb5e7748624.zip |
2007-08-20 mcrha Fix for bug #262226
svn path=/trunk/; revision=34043
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 23 | ||||
-rw-r--r-- | calendar/gui/calendar-component.c | 9 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 11 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 60 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 2 |
6 files changed, 80 insertions, 27 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index f746e9e7f0..1a3517067e 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,26 @@ +2007-08-20 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #262226 + + * gui/e-calendar-view.h: + * gui/e-calendar-view.c: (e_calendar_view_new_appointment_full): + Changed meaning of the last parameter: no_past_date to indicate if + we accept past dates (we do not for File->New->items). + Also changed behavior: when don't need all_day event and there are + 24 hours selected, then change start/end to actual time in actual day, + or to 'day begins' from pereferences for other selected days, + instead of setting all_day event to TRUE. + * gui/calendar-component.c: (create_new_event): + Don't force all day event. + * gui/e-week-view.c: (e_week_view_on_button_press): + Changing call of 'e_calendar_view_new_appointment_full'. + + * gui/dialogs/event-page.c: (clear_widgets): + Fixed critical warning when no default_address set. + * gui/dialogs/event-page.c: (event_page_finalize), + (event_page_select_organizer): Free memory when no longer needed. + * gui/dialogs/event-page.c: (event_page_init): There was twice the same. + 2007-08-17 Chenthill Palanisamy <pchenthill@novell.com> Fixes #420492 diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index ab445b03d6..7998b7bff6 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -1267,15 +1267,6 @@ create_new_event (CalendarComponent *calendar_component, CalendarComponentView * return FALSE; if (component_view && (view = E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (component_view->calendar)))) { - GnomeCalendarViewType view_type; - - /* Force all for these view types because thats what's selected and it mimics a double click */ - view_type = gnome_calendar_get_view (component_view->calendar); - if (view_type == GNOME_CAL_WEEK_VIEW - || view_type == GNOME_CAL_MONTH_VIEW - || view_type == GNOME_CAL_LIST_VIEW) - is_allday = TRUE; - e_calendar_view_new_appointment_full (view, is_allday, is_meeting, TRUE); } else { ECalComponent *comp; diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 0c52fdcdbf..54281be172 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -268,8 +268,6 @@ event_page_init (EventPage *epage) priv->is_meeting = FALSE; priv->sync_timezones = FALSE; - priv->default_address = NULL; - priv->alarm_list_dlg_widget = NULL; } @@ -322,6 +320,9 @@ event_page_finalize (GObject *object) priv->alarm_list_dlg_widget = NULL; + g_free (priv->default_address); + priv->default_address = NULL; + g_free (priv); epage->priv = NULL; @@ -587,7 +588,8 @@ clear_widgets (EventPage *epage) /* Categories */ e_dialog_editable_set (priv->categories, NULL); - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->entry), priv->default_address); + if (priv->default_address) + gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->entry), priv->default_address); } static gboolean @@ -3180,7 +3182,8 @@ event_page_select_organizer (EventPage *epage, const char *backend_address) priv->default_address = full; } else if (a == def_account && !priv->default_address) priv->default_address = full; - + else + g_free (full); } g_object_unref(it); diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 0ef3fde70c..3f24b162b3 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -1886,31 +1886,67 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view, } /** - * e_calendar_view_new_appointment - * @cal_view: A calendar view. + * e_calendar_view_new_appointment_full + * @param cal_view: A calendar view. + * @param all_day: Whether create all day event or not. + * @param meeting: This is a meeting or an appointment. + * @param no_past_date: Don't create event in past date, use actual date instead (if TRUE). * * Opens an event editor dialog for a new appointment. The appointment's * start and end times are set to the currently selected time range in * the calendar view. * - * With @actual_day set to TRUE, there will be always used actual day. + * When the selection is for all day and we don't need @all_day event, + * then this do a rounding to the actual hour for actual day (today) and + * to the 'day begins' from preferences in other selected day. */ void -e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, gboolean meeting, gboolean actual_day) +e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, gboolean meeting, gboolean no_past_date) { - time_t dtstart, dtend; + time_t dtstart, dtend, now; + gboolean do_rounding = FALSE; g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (actual_day || - !e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend)) { - dtstart = time (NULL); + now = time (NULL); + + if (!e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend)) { + dtstart = now; dtend = dtstart + 3600; } - /* FIXME This is a rough hack to make sure "all day" is set for */ - if ((dtend - dtstart) % (60 * 60 * 24) == 0) - all_day = TRUE; - + + if (no_past_date && dtstart < now) { + dtend = time_day_begin (now) + (dtend - dtstart); + dtstart = time_day_begin (now); + do_rounding = TRUE; + } + + /* We either need rounding or don't want to set all_day for this, we will rather use actual */ + /* time in this cases; dtstart should be a midnight in this case */ + if (do_rounding || (!all_day && (dtend - dtstart) % (60 * 60 * 24) == 0)) { + struct tm local = *localtime (&now); + int time_div = calendar_config_get_time_divisions (); + int hours, mins; + + if (time_day_begin (now) == time_day_begin (dtstart)) { + /* same day as today */ + hours = local.tm_hour; + mins = local.tm_min; + + /* round minutes to nearest time division, up or down */ + if ((mins % time_div) >= time_div / 2) + mins += time_div; + mins = (mins - (mins % time_div)); + } else { + /* other day than today */ + hours = calendar_config_get_day_start_hour (); + mins = calendar_config_get_day_start_minute (); + } + + dtstart = dtstart + (60 * 60 * hours) + (mins * 60); + dtend = dtstart + (time_div * 60); + } + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, all_day, meeting); } diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 81c6081cea..7e26ee84cb 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -153,7 +153,7 @@ void e_calendar_view_new_appointment_for (ECalendarView *cal_view, void e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, gboolean meeting, - gboolean actual_day); + gboolean no_past_date); void e_calendar_view_new_appointment (ECalendarView *cal_view); void e_calendar_view_edit_appointment (ECalendarView *cal_view, ECal *client, diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 0cc9b7f66d..b2a8ccad2f 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -2061,7 +2061,7 @@ e_week_view_on_button_press (GtkWidget *widget, return FALSE; if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { - e_calendar_view_new_appointment_full (E_CALENDAR_VIEW (week_view), TRUE, FALSE, FALSE); + e_calendar_view_new_appointment_full (E_CALENDAR_VIEW (week_view), FALSE, FALSE, FALSE); return TRUE; } |