[evolution] I#380 - [Calendar] Prefill start time in the future, rather than in the past
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#380 - [Calendar] Prefill start time in the future, rather than in the past
- Date: Tue, 2 Apr 2019 10:14:34 +0000 (UTC)
commit 7ba003ac68d36b2045d673fc1b54a4ba85c26480
Author: Milan Crha <mcrha redhat com>
Date: Tue Apr 2 12:15:28 2019 +0200
I#380 - [Calendar] Prefill start time in the future, rather than in the past
Closes https://gitlab.gnome.org/GNOME/evolution/issues/380
src/calendar/gui/e-calendar-view.c | 38 +++++++++++--------------
src/calendar/gui/e-calendar-view.h | 16 +++++++----
src/calendar/gui/e-week-view.c | 3 +-
src/calendar/gui/ea-cal-view.c | 2 +-
src/modules/calendar/e-cal-shell-backend.c | 5 +++-
src/modules/calendar/e-cal-shell-view-actions.c | 21 ++++----------
6 files changed, 39 insertions(+), 46 deletions(-)
---
diff --git a/src/calendar/gui/e-calendar-view.c b/src/calendar/gui/e-calendar-view.c
index 5ba5e4a8f6..f752bdd6c4 100644
--- a/src/calendar/gui/e-calendar-view.c
+++ b/src/calendar/gui/e-calendar-view.c
@@ -1482,30 +1482,29 @@ e_calendar_view_open_event (ECalendarView *cal_view)
}
/**
- * e_calendar_view_new_appointment_full
+ * e_calendar_view_new_appointment
* @cal_view: an #ECalendarView
- * @all_day: Whether create all day event or not.
- * @meeting: This is a meeting or an appointment.
- * @no_past_date: Don't create event in past date, use actual date instead
- * (if %TRUE).
+ * @flags: bit-or of ENewAppointmentFlags
*
* 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.
+ * the calendar view, unless the flags contain E_NEW_APPOINTMENT_FLAG_FORCE_CURRENT_TIME,
+ * in which case the current time is used.
*
- * 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
+ * When the selection is for all day and we don't need all day event,
+ * then this does 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 no_past_date)
+e_calendar_view_new_appointment (ECalendarView *cal_view,
+ guint32 flags)
{
ECalModel *model;
time_t dtstart, dtend, now;
gboolean do_rounding = FALSE;
+ gboolean all_day = (flags & E_NEW_APPOINTMENT_FLAG_ALL_DAY) != 0;
+ gboolean meeting = (flags & E_NEW_APPOINTMENT_FLAG_MEETING) != 0;
+ gboolean no_past_date = (flags & E_NEW_APPOINTMENT_FLAG_NO_PAST_DATE) != 0;
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
@@ -1513,12 +1512,13 @@ e_calendar_view_new_appointment_full (ECalendarView *cal_view,
now = time (NULL);
- if (!e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend)) {
+ if ((flags & E_NEW_APPOINTMENT_FLAG_FORCE_CURRENT_TIME) != 0 ||
+ !e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend)) {
dtstart = now;
dtend = dtstart + 3600;
}
- if (no_past_date && dtstart < now) {
+ if (no_past_date && dtstart <= now) {
dtend = time_day_begin (now) + (dtend - dtstart);
dtstart = time_day_begin (now);
do_rounding = TRUE;
@@ -1550,6 +1550,8 @@ e_calendar_view_new_appointment_full (ECalendarView *cal_view,
}
dtstart = dtstart + (60 * 60 * hours) + (mins * 60);
+ if (no_past_date && dtstart <= now)
+ dtstart += ((((now - dtstart) / 60 / time_div)) + time_div) * 60;
dtend = dtstart + (time_div * 60);
}
@@ -1558,14 +1560,6 @@ e_calendar_view_new_appointment_full (ECalendarView *cal_view,
dtstart, dtend, meeting, all_day);
}
-void
-e_calendar_view_new_appointment (ECalendarView *cal_view)
-{
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
-
- e_calendar_view_new_appointment_full (cal_view, FALSE, FALSE, FALSE);
-}
-
/* Ensures the calendar is selected */
static void
object_created_cb (ECompEditor *comp_editor,
diff --git a/src/calendar/gui/e-calendar-view.h b/src/calendar/gui/e-calendar-view.h
index f114e76c43..a5fa67c7f8 100644
--- a/src/calendar/gui/e-calendar-view.h
+++ b/src/calendar/gui/e-calendar-view.h
@@ -133,6 +133,14 @@ typedef enum {
E_CALENDAR_VIEW_MOVE_TO_EXACT_DAY
} ECalendarViewMoveType;
+typedef enum {
+ E_NEW_APPOINTMENT_FLAG_NONE = 0,
+ E_NEW_APPOINTMENT_FLAG_ALL_DAY = 1 << 0,
+ E_NEW_APPOINTMENT_FLAG_MEETING = 1 << 1,
+ E_NEW_APPOINTMENT_FLAG_NO_PAST_DATE = 1 << 2,
+ E_NEW_APPOINTMENT_FLAG_FORCE_CURRENT_TIME = 1 << 3
+} ENewAppointmentFlags;
+
struct _ECalendarViewClass {
GtkGridClass parent_class;
@@ -231,12 +239,8 @@ void e_calendar_view_add_event (ECalendarView *cal_view,
icaltimezone *default_zone,
icalcomponent *icalcomp,
gboolean in_top_canvas);
-void e_calendar_view_new_appointment_full
- (ECalendarView *cal_view,
- gboolean all_day,
- gboolean meeting,
- gboolean no_past_date);
-void e_calendar_view_new_appointment (ECalendarView *cal_view);
+void e_calendar_view_new_appointment (ECalendarView *cal_view,
+ guint32 flags); /* bit-or of ENewAppointmentFlags */
void e_calendar_view_edit_appointment
(ECalendarView *cal_view,
ECalClient *client,
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index 40fad7aade..40943fc880 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -2993,7 +2993,8 @@ e_week_view_on_button_press (GtkWidget *widget,
week_view->before_click_dtstart,
week_view->before_click_dtend);
}
- e_calendar_view_new_appointment_full (E_CALENDAR_VIEW (week_view), FALSE,
calendar_config_get_prefer_meeting (), FALSE);
+ e_calendar_view_new_appointment (E_CALENDAR_VIEW (week_view),
E_NEW_APPOINTMENT_FLAG_NO_PAST_DATE |
+ (calendar_config_get_prefer_meeting () ? E_NEW_APPOINTMENT_FLAG_MEETING : 0));
return TRUE;
}
diff --git a/src/calendar/gui/ea-cal-view.c b/src/calendar/gui/ea-cal-view.c
index bbec2629f3..fea65a42b9 100644
--- a/src/calendar/gui/ea-cal-view.c
+++ b/src/calendar/gui/ea-cal-view.c
@@ -320,7 +320,7 @@ action_interface_do_action (AtkAction *action,
switch (index) {
case 0:
/* New Appointment */
- e_calendar_view_new_appointment (cal_view);
+ e_calendar_view_new_appointment (cal_view, E_NEW_APPOINTMENT_FLAG_NO_PAST_DATE);
break;
case 1:
/* New All Day Event */
diff --git a/src/modules/calendar/e-cal-shell-backend.c b/src/modules/calendar/e-cal-shell-backend.c
index 6c5e7ff03e..6171b94b4f 100644
--- a/src/modules/calendar/e-cal-shell-backend.c
+++ b/src/modules/calendar/e-cal-shell-backend.c
@@ -82,7 +82,10 @@ action_event_new_cb (GtkAction *action,
view = e_cal_shell_content_get_current_calendar_view (E_CAL_SHELL_CONTENT (shell_content));
if (view != NULL) {
- e_calendar_view_new_appointment_full (view, is_all_day, is_meeting, TRUE);
+ e_calendar_view_new_appointment (view, E_NEW_APPOINTMENT_FLAG_NO_PAST_DATE |
+ (is_all_day ? E_NEW_APPOINTMENT_FLAG_ALL_DAY : 0) |
+ (is_meeting ? E_NEW_APPOINTMENT_FLAG_MEETING : 0) |
+ (e_shell_view_is_active (shell_view) ? 0 :
E_NEW_APPOINTMENT_FLAG_FORCE_CURRENT_TIME));
return;
}
}
diff --git a/src/modules/calendar/e-cal-shell-view-actions.c b/src/modules/calendar/e-cal-shell-view-actions.c
index 91f6831116..49f1c756ae 100644
--- a/src/modules/calendar/e-cal-shell-view-actions.c
+++ b/src/modules/calendar/e-cal-shell-view-actions.c
@@ -516,16 +516,11 @@ action_event_all_day_new_cb (GtkAction *action,
ECalShellContent *cal_shell_content;
ECalendarView *calendar_view;
- /* These are just for readability. */
- gboolean all_day = TRUE;
- gboolean meeting = FALSE;
- gboolean no_past_date = FALSE;
-
cal_shell_content = cal_shell_view->priv->cal_shell_content;
calendar_view = e_cal_shell_content_get_current_calendar_view (cal_shell_content);
- e_calendar_view_new_appointment_full (
- calendar_view, all_day, meeting, no_past_date);
+ e_calendar_view_new_appointment (calendar_view, E_NEW_APPOINTMENT_FLAG_ALL_DAY |
E_NEW_APPOINTMENT_FLAG_NO_PAST_DATE |
+ (e_shell_view_is_active (E_SHELL_VIEW (cal_shell_view)) ? 0 :
E_NEW_APPOINTMENT_FLAG_FORCE_CURRENT_TIME));
}
static void
@@ -793,16 +788,11 @@ action_event_meeting_new_cb (GtkAction *action,
ECalShellContent *cal_shell_content;
ECalendarView *calendar_view;
- /* These are just for readability. */
- gboolean all_day = FALSE;
- gboolean meeting = TRUE;
- gboolean no_past_date = FALSE;
-
cal_shell_content = cal_shell_view->priv->cal_shell_content;
calendar_view = e_cal_shell_content_get_current_calendar_view (cal_shell_content);
- e_calendar_view_new_appointment_full (
- calendar_view, all_day, meeting, no_past_date);
+ e_calendar_view_new_appointment (calendar_view, E_NEW_APPOINTMENT_FLAG_MEETING |
E_NEW_APPOINTMENT_FLAG_NO_PAST_DATE |
+ (e_shell_view_is_active (E_SHELL_VIEW (cal_shell_view)) ? 0 :
E_NEW_APPOINTMENT_FLAG_FORCE_CURRENT_TIME));
}
static void
@@ -815,7 +805,8 @@ action_event_new_cb (GtkAction *action,
cal_shell_content = cal_shell_view->priv->cal_shell_content;
calendar_view = e_cal_shell_content_get_current_calendar_view (cal_shell_content);
- e_calendar_view_new_appointment (calendar_view);
+ e_calendar_view_new_appointment (calendar_view, E_NEW_APPOINTMENT_FLAG_NO_PAST_DATE |
+ (e_shell_view_is_active (E_SHELL_VIEW (cal_shell_view)) ? 0 :
E_NEW_APPOINTMENT_FLAG_FORCE_CURRENT_TIME));
}
typedef struct
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]