aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog41
-rw-r--r--calendar/cal-util/cal-component.c65
-rw-r--r--calendar/gui/calendar-config.c271
-rw-r--r--calendar/gui/calendar-config.h10
-rw-r--r--calendar/gui/calendar-model.c9
-rw-r--r--calendar/gui/comp-editor-factory.c9
-rw-r--r--calendar/gui/comp-util.c67
-rw-r--r--calendar/gui/comp-util.h2
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.c21
-rw-r--r--calendar/gui/dialogs/delete-comp.c14
-rw-r--r--calendar/gui/e-day-view.c3
-rw-r--r--calendar/gui/e-week-view.c4
-rw-r--r--calendar/gui/gnome-cal.c6
13 files changed, 433 insertions, 89 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 1bd6d5f607..fca6213ec1 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,44 @@
+2001-10-30 Federico Mena Quintero <federico@ximian.com>
+
+ * gui/dialogs/delete-comp.c (delete_component_dialog): Use an
+ EMessageBox instead of a gnome_dialog_question so that the label
+ gets line breaking. Fixes bug #11260.
+
+2001-10-29 Federico Mena Quintero <federico@ximian.com>
+
+ Fix bug #13649.
+
+ * gui/calendar-config.c
+ (calendar_config_get_use_default_reminder): New function.
+ (calendar_config_set_use_default_reminder): New function.
+ (calendar_config_get_default_reminder_interval): New function.
+ (calendar_config_set_default_reminder_interval): New function.
+ (calendar_config_get_default_reminder_units): New function.
+ (calendar_config_set_default_reminder_units): New function.
+ (config_read): Get the options for default reminders.
+ (calendar_config_write): Set the options for default reminders.
+
+ * gui/dialogs/cal-prefs-dialog.c (cal_prefs_dialog_show_config):
+ Set the default reminder widgets from the config values.
+ (cal_prefs_dialog_update_config): Set the config values from the
+ widgets.
+
+ * gui/comp-util.c (cal_comp_event_new_with_defaults): New
+ function; creates a VEVENT component with the default alarm.
+
+ * gui/e-day-view.c (e_day_view_key_press): Use
+ cal_comp_event_new_with_defaults ();
+
+ * gui/e-week-view.c (e_week_view_key_press): Likewise.
+ * gui/calendar-model.c (calendar_model_append_row): Likewise.
+ * gui/comp-editor-factory.c (get_default_component): Likewise.
+ * gui/gnome-cal.c (gnome_calendar_new_appointment_for): Likewise.
+
+ * cal-util/cal-component.c (ensure_alarm_properties_cb): Ensure we
+ have a DESCRIPTION property.
+ (cal_component_commit_sequence): Ensure we have the mandatory
+ alarm properties.
+
2001-10-30 JP Rosevear <jpr@ximian.com>
* gui/e-meeting-model.c (process_section): process an individual
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index a2074525a6..6e652b4851 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -23,6 +23,9 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <glib.h>
+#include <libgnome/gnome-defs.h>
+#include <libgnome/gnome-i18n.h>
#include "cal-component.h"
#include "timeutil.h"
@@ -1164,6 +1167,66 @@ cal_component_get_as_string (CalComponent *comp)
return buf;
}
+/* Used from g_hash_table_foreach(); ensures that an alarm subcomponent
+ * has the mandatory properties it needs.
+ */
+static void
+ensure_alarm_properties_cb (gpointer key, gpointer value, gpointer data)
+{
+ CalComponent *comp;
+ CalComponentPrivate *priv;
+ icalcomponent *alarm;
+ icalproperty *prop;
+ enum icalproperty_action action;
+ const char *str;
+
+ alarm = value;
+
+ comp = CAL_COMPONENT (data);
+ priv = comp->priv;
+
+ prop = icalcomponent_get_first_property (alarm, ICAL_ACTION_PROPERTY);
+ if (!prop)
+ return;
+
+ action = icalproperty_get_action (prop);
+
+ switch (action) {
+ case ICAL_ACTION_DISPLAY:
+ /* Ensure we have a DESCRIPTION property */
+ prop = icalcomponent_get_first_property (alarm, ICAL_DESCRIPTION_PROPERTY);
+ if (prop)
+ break;
+
+ if (!priv->summary.prop)
+ str = _("Untitled appointment");
+ else
+ str = icalproperty_get_summary (priv->summary.prop);
+
+ prop = icalproperty_new_description (str);
+ icalcomponent_add_property (alarm, prop);
+
+ break;
+
+ default:
+ break;
+ /* FIXME: add other action types here */
+ }
+}
+
+/* Ensures that alarm subcomponents have the mandatory properties they need,
+ * even when clients may not have set them properly.
+ */
+static void
+ensure_alarm_properties (CalComponent *comp)
+{
+ CalComponentPrivate *priv;
+
+ priv = comp->priv;
+
+ g_hash_table_foreach (priv->alarm_uid_hash, ensure_alarm_properties_cb, comp);
+}
+
/**
* cal_component_commit_sequence:
* @comp:
@@ -1186,6 +1249,8 @@ cal_component_commit_sequence (CalComponent *comp)
priv = comp->priv;
g_return_if_fail (priv->icalcomp != NULL);
+ ensure_alarm_properties (comp);
+
if (!priv->need_sequence_inc)
return;
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index 591bd4343f..699644767a 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -70,6 +70,9 @@ typedef struct
CalUnits hide_completed_tasks_units;
gint hide_completed_tasks_value;
gboolean confirm_delete;
+ gboolean use_default_reminder;
+ int default_reminder_interval;
+ CalUnits default_reminder_units;
} CalendarConfig;
@@ -99,7 +102,7 @@ calendar_config_init (void)
case the user can choose between 12 and 24-hour time formats. */
gboolean
calendar_config_locale_supports_12_hour_format (void)
-{
+{
char s[16];
time_t t = 0;
@@ -115,9 +118,9 @@ config_read (void)
char *units;
CORBA_exception_init (&ev);
-
+
db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
-
+
if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
CORBA_exception_free (&ev);
return;
@@ -130,17 +133,17 @@ config_read (void)
config->default_tasks_uri = bonobo_config_get_string (db,
"/Calendar/DefaultTasksUri", NULL);
-
- config->timezone = bonobo_config_get_string (db,
+
+ config->timezone = bonobo_config_get_string (db,
"/Calendar/Display/Timezone", NULL);
- config->working_days = bonobo_config_get_long_with_default (db,
+ config->working_days = bonobo_config_get_long_with_default (db,
"/Calendar/Display/WorkingDays", CAL_MONDAY | CAL_TUESDAY |
CAL_WEDNESDAY | CAL_THURSDAY | CAL_FRIDAY, NULL);
-
- config->week_start_day = bonobo_config_get_long_with_default (db,
+
+ config->week_start_day = bonobo_config_get_long_with_default (db,
"/Calendar/Display/WeekStartDay", 1, NULL);
-
+
/* If the locale defines 'am' and 'pm' strings then the user has the
choice of 12-hour or 24-hour time format, with 12-hour as the
default. If the locale doesn't have 'am' and 'pm' strings we have
@@ -151,43 +154,43 @@ config_read (void)
config->use_24_hour_format = TRUE;
}
- config->week_start_day = bonobo_config_get_long_with_default (db,
+ config->week_start_day = bonobo_config_get_long_with_default (db,
"/Calendar/Display/WeekStartDay", 1, NULL);
-
- config->day_start_hour = bonobo_config_get_long_with_default (db,
+
+ config->day_start_hour = bonobo_config_get_long_with_default (db,
"/Calendar/Display/DayStartHour", 9, NULL);
-
- config->day_start_minute = bonobo_config_get_long_with_default (db,
+
+ config->day_start_minute = bonobo_config_get_long_with_default (db,
"/Calendar/Display/DayStartMinute", 0, NULL);
-
- config->day_end_hour = bonobo_config_get_long_with_default (db,
+
+ config->day_end_hour = bonobo_config_get_long_with_default (db,
"/Calendar/Display/DayEndHour", 17, NULL);
- config->day_end_minute = bonobo_config_get_long_with_default (db,
+ config->day_end_minute = bonobo_config_get_long_with_default (db,
"/Calendar/Display/DayEndMinute", 0, NULL);
- config->time_divisions = bonobo_config_get_long_with_default (db,
+ config->time_divisions = bonobo_config_get_long_with_default (db,
"/Calendar/Display/TimeDivisions", 30, NULL);
- config->view = bonobo_config_get_long_with_default (db,
+ config->view = bonobo_config_get_long_with_default (db,
"/Calendar/Display/View", 0, NULL);
- config->hpane_pos = bonobo_config_get_float_with_default (db,
+ config->hpane_pos = bonobo_config_get_float_with_default (db,
"/Calendar/Display/HPanePosition", 1.0, NULL);
- config->vpane_pos = bonobo_config_get_float_with_default (db,
+ config->vpane_pos = bonobo_config_get_float_with_default (db,
"/Calendar/Display/VPanePosition", 1.0, NULL);
- config->month_hpane_pos = bonobo_config_get_float_with_default (db,
+ config->month_hpane_pos = bonobo_config_get_float_with_default (db,
"/Calendar/Display/MonthHPanePosition", 0.0, NULL);
- config->month_vpane_pos = bonobo_config_get_float_with_default (db,
+ config->month_vpane_pos = bonobo_config_get_float_with_default (db,
"/Calendar/Display/MonthVPanePosition", 1.0, NULL);
config->compress_weekend = bonobo_config_get_boolean_with_default (db,
"/Calendar/Display/CompressWeekend", TRUE, NULL);
- config->show_event_end = bonobo_config_get_boolean_with_default (db,
+ config->show_event_end = bonobo_config_get_boolean_with_default (db,
"/Calendar/Display/ShowEventEndTime", TRUE, NULL);
/* 'DateNavigator' settings. */
@@ -216,27 +219,69 @@ config_read (void)
else
config->hide_completed_tasks_units = CAL_DAYS;
+ g_free (units);
+
config->hide_completed_tasks_value = bonobo_config_get_long_with_default (
db, "/Calendar/Tasks/HideCompletedTasksValue", 1, NULL);
+ /* Confirmation */
config->confirm_delete = bonobo_config_get_boolean_with_default (
db, "/Calendar/Other/ConfirmDelete", TRUE, NULL);
+ /* Default reminders */
+ config->use_default_reminder = bonobo_config_get_boolean_with_default (
+ db, "/Calendar/Other/UseDefaultReminder", FALSE, NULL);
+
+ config->default_reminder_interval = bonobo_config_get_long_with_default (
+ db, "/Calendar/Other/DefaultReminderInterval", 15, NULL);
+
+ units = bonobo_config_get_string_with_default (db,
+ "/Calendar/Other/DefaultReminderUnits", "minutes", NULL);
+
+ if (!strcmp (units, "days"))
+ config->default_reminder_units = CAL_DAYS;
+ else if (!strcmp (units, "hours"))
+ config->default_reminder_units = CAL_HOURS;
+ else
+ config->default_reminder_units = CAL_MINUTES; /* changed from above because
+ * if bonobo-config fucks up
+ * we want minutes, not days!
+ */
+ g_free (units);
+
bonobo_object_release_unref (db, NULL);
}
+/* Returns the string representation of a units value */
+static const char *
+units_to_string (CalUnits units)
+{
+ switch (units) {
+ case CAL_DAYS:
+ return "days";
+
+ case CAL_HOURS:
+ return "hours";
+
+ case CAL_MINUTES:
+ return "minutes";
+
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
+}
void
calendar_config_write (void)
{
Bonobo_ConfigDatabase db;
CORBA_Environment ev;
- char *units;
CORBA_exception_init (&ev);
-
+
db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
-
+
if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
CORBA_exception_free (&ev);
return;
@@ -251,58 +296,61 @@ calendar_config_write (void)
config->default_tasks_uri, NULL);
if (config->timezone)
- bonobo_config_set_string (db, "/Calendar/Display/Timezone",
+ bonobo_config_set_string (db, "/Calendar/Display/Timezone",
config->timezone, NULL);
- bonobo_config_set_long (db, "/Calendar/Display/WorkingDays",
+ bonobo_config_set_long (db, "/Calendar/Display/WorkingDays",
config->working_days, NULL);
- bonobo_config_set_boolean (db, "/Calendar/Display/Use24HourFormat",
+ bonobo_config_set_boolean (db, "/Calendar/Display/Use24HourFormat",
config->use_24_hour_format, NULL);
- bonobo_config_set_long (db, "/Calendar/Display/WeekStartDay",
+ bonobo_config_set_long (db, "/Calendar/Display/WeekStartDay",
config->week_start_day, NULL);
- bonobo_config_set_long (db, "/Calendar/Display/DayStartHour",
+ bonobo_config_set_long (db, "/Calendar/Display/DayStartHour",
config->day_start_hour, NULL);
- bonobo_config_set_long (db, "/Calendar/Display/DayStartMinute",
+ bonobo_config_set_long (db, "/Calendar/Display/DayStartMinute",
config->day_start_minute, NULL);
- bonobo_config_set_long (db, "/Calendar/Display/DayEndHour",
+ bonobo_config_set_long (db, "/Calendar/Display/DayEndHour",
config->day_end_hour, NULL);
- bonobo_config_set_long (db, "/Calendar/Display/DayEndMinute",
+ bonobo_config_set_long (db, "/Calendar/Display/DayEndMinute",
config->day_end_minute, NULL);
- bonobo_config_set_boolean (db, "/Calendar/Display/CompressWeekend",
+ bonobo_config_set_boolean (db, "/Calendar/Display/CompressWeekend",
config->compress_weekend, NULL);
- bonobo_config_set_boolean (db, "/Calendar/Display/ShowEventEndTime",
+ bonobo_config_set_boolean (db, "/Calendar/Display/ShowEventEndTime",
config->show_event_end, NULL);
- bonobo_config_set_boolean (db,
- "/Calendar/DateNavigator/ShowWeekNumbers",
+ bonobo_config_set_boolean (db,
+ "/Calendar/DateNavigator/ShowWeekNumbers",
config->dnav_show_week_no, NULL);
- bonobo_config_set_string (db, "/Calendar/Tasks/Colors/TasksDueToday",
+ bonobo_config_set_string (db, "/Calendar/Tasks/Colors/TasksDueToday",
config->tasks_due_today_color, NULL);
- bonobo_config_set_string (db, "/Calendar/Tasks/Colors/TasksOverdue",
+ bonobo_config_set_string (db, "/Calendar/Tasks/Colors/TasksOverdue",
config->tasks_overdue_color, NULL);
- bonobo_config_set_boolean (db, "/Calendar/Tasks/HideCompletedTasks",
+ bonobo_config_set_boolean (db, "/Calendar/Tasks/HideCompletedTasks",
config->hide_completed_tasks, NULL);
- if (config->hide_completed_tasks_units == CAL_MINUTES)
- units = "minutes";
- else if (config->hide_completed_tasks_units == CAL_HOURS)
- units = "hours";
- else
- units = "days";
bonobo_config_set_string (db,
- "/Calendar/Tasks/HideCompletedTasksUnits",
- units, NULL);
- bonobo_config_set_long (db,
- "/Calendar/Tasks/HideCompletedTasksValue",
+ "/Calendar/Tasks/HideCompletedTasksUnits",
+ units_to_string (config->hide_completed_tasks_units), NULL);
+ bonobo_config_set_long (db,
+ "/Calendar/Tasks/HideCompletedTasksValue",
config->hide_completed_tasks_value, NULL);
bonobo_config_set_boolean (db, "/Calendar/Other/ConfirmDelete", config->confirm_delete, NULL);
+ bonobo_config_set_boolean (db, "/Calendar/Other/UseDefaultReminder",
+ config->use_default_reminder, NULL);
+
+ bonobo_config_set_long (db, "/Calendar/Other/DefaultReminderInterval",
+ config->default_reminder_interval, NULL);
+
+ bonobo_config_set_string (db, "/Calendar/Other/DefaultReminderUnits",
+ units_to_string (config->default_reminder_units), NULL);
+
Bonobo_ConfigDatabase_sync (db, &ev);
-
+
bonobo_object_release_unref (db, NULL);
CORBA_exception_free (&ev);
@@ -317,27 +365,27 @@ calendar_config_write_on_exit (void)
CORBA_exception_init (&ev);
db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
-
+
if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
CORBA_exception_free (&ev);
return;
}
- bonobo_config_set_long (db, "/Calendar/Display/View",
+ bonobo_config_set_long (db, "/Calendar/Display/View",
config->view, NULL);
- bonobo_config_set_long (db, "/Calendar/Display/TimeDivisions",
+ bonobo_config_set_long (db, "/Calendar/Display/TimeDivisions",
config->time_divisions, NULL);
- bonobo_config_set_float (db, "/Calendar/Display/HPanePosition",
+ bonobo_config_set_float (db, "/Calendar/Display/HPanePosition",
config->hpane_pos, NULL);
- bonobo_config_set_float (db, "/Calendar/Display/VPanePosition",
+ bonobo_config_set_float (db, "/Calendar/Display/VPanePosition",
config->vpane_pos, NULL);
- bonobo_config_set_float (db, "/Calendar/Display/MonthHPanePosition",
+ bonobo_config_set_float (db, "/Calendar/Display/MonthHPanePosition",
config->month_hpane_pos, NULL);
- bonobo_config_set_float (db, "/Calendar/Display/MonthVPanePosition",
+ bonobo_config_set_float (db, "/Calendar/Display/MonthVPanePosition",
config->month_vpane_pos, NULL);
Bonobo_ConfigDatabase_sync (db, &ev);
-
+
bonobo_object_release_unref (db, NULL);
CORBA_exception_free (&ev);
@@ -689,10 +737,10 @@ calendar_config_set_hide_completed_tasks_value (gint value)
/**
* calendar_config_get_confirm_delete:
- *
+ *
* Queries the configuration value for whether a confirmation dialog is
* presented when deleting calendar/tasks items.
- *
+ *
* Return value: Whether confirmation is required when deleting items.
**/
gboolean
@@ -704,7 +752,7 @@ calendar_config_get_confirm_delete (void)
/**
* calendar_config_set_confirm_delete:
* @confirm: Whether confirmation is required when deleting items.
- *
+ *
* Sets the configuration value for whether a confirmation dialog is presented
* when deleting calendar/tasks items.
**/
@@ -915,9 +963,9 @@ on_timezone_dialog_delete_event (GnomeDialog *dialog,
/**
* calendar_config_get_tasks_due_today_color:
- *
+ *
* Queries the color to be used to display tasks that are due today.
- *
+ *
* Return value: An X color specification.
**/
const char *
@@ -930,7 +978,7 @@ calendar_config_get_tasks_due_today_color (void)
/**
* calendar_config_set_tasks_due_today_color:
* @color: X color specification
- *
+ *
* Sets the color to be used to display tasks that are due today.
**/
void
@@ -946,9 +994,9 @@ calendar_config_set_tasks_due_today_color (const char *color)
/**
* calendar_config_get_tasks_overdue_color:
- *
+ *
* Queries the color to be used to display overdue tasks.
- *
+ *
* Return value: An X color specification.
**/
const char *
@@ -961,7 +1009,7 @@ calendar_config_get_tasks_overdue_color (void)
/**
* calendar_config_set_tasks_overdue_color:
* @color: X color specification
- *
+ *
* Sets the color to be used to display overdue tasks.
**/
void
@@ -975,10 +1023,91 @@ calendar_config_set_tasks_overdue_color (const char *color)
config->tasks_overdue_color = g_strdup (color);
}
+/**
+ * calendar_config_get_use_default_reminder:
+ *
+ * Queries whether new appointments should be created with a default reminder.
+ *
+ * Return value: Boolean value indicating whether new appointments should be
+ * created with a default reminder from the values of
+ * calendar_config_get_default_reminder_interval() and
+ * calendar_config_get_default_reminder_units().
+ **/
+gboolean
+calendar_config_get_use_default_reminder (void)
+{
+ return config->use_default_reminder;
+}
+
+/**
+ * calendar_config_set_use_default_reminder:
+ * @value: Whether to create new appointments with a default reminder.
+ *
+ * Sets whether newly-created appointments should get a default reminder set
+ * them.
+ **/
+void
+calendar_config_set_use_default_reminder (gboolean value)
+{
+ config->use_default_reminder = value;
+}
+
+/**
+ * calendar_config_get_default_reminder_interval:
+ *
+ * Queries the interval for the default reminder of newly-created
+ * appointments, i.e. 5 in "5 minutes".
+ *
+ * Return value: Interval for default reminders.
+ **/
+int
+calendar_config_get_default_reminder_interval (void)
+{
+ return config->default_reminder_interval;
+}
+
+/**
+ * calendar_config_set_default_reminder_interval:
+ * @interval: Interval value, e.g. 5 for "5 minutes".
+ *
+ * Sets the interval that should be used for the default reminder in new
+ * appointments.
+ **/
+void
+calendar_config_set_default_reminder_interval (int interval)
+{
+ config->default_reminder_interval = interval;
+}
+
+/**
+ * calendar_config_get_default_reminder_units:
+ *
+ * Queries the units of time in which default reminders should be created for
+ * new appointments, e.g. CAL_MINUTES for "5 minutes".
+ *
+ * Return value: Time units for default reminders.
+ **/
+CalUnits
+calendar_config_get_default_reminder_units (void)
+{
+ return config->default_reminder_units;
+}
+
+/**
+ * calendar_config_set_default_reminder_units:
+ * @units: Time units, e.g. CAL_MINUTES for "5 minutes".
+ *
+ * Sets the units to be used for default reminders in new appointments.
+ **/
+void
+calendar_config_set_default_reminder_units (CalUnits units)
+{
+ config->default_reminder_units = units;
+}
/**
* calendar_config_get_hide_completed_tasks_sexp:
- *
+ *
* Returns the subexpression to use to filter out completed tasks according
* to the config settings. The returned sexp should be freed.
**/
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index 4bdb7a175d..7bba7fc7a2 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -161,6 +161,16 @@ char* calendar_config_get_hide_completed_tasks_sexp (void);
gboolean calendar_config_get_confirm_delete (void);
void calendar_config_set_confirm_delete (gboolean confirm);
+/* Default reminder options */
+gboolean calendar_config_get_use_default_reminder (void);
+void calendar_config_set_use_default_reminder (gboolean value);
+
+int calendar_config_get_default_reminder_interval (void);
+void calendar_config_set_default_reminder_interval (int interval);
+
+CalUnits calendar_config_get_default_reminder_units (void);
+void calendar_config_set_default_reminder_units (CalUnits units);
+
/* Convenience functions to configure common properties of ECalendar,
EDateEdit & ECalendarTable widgets, and the ECellDateEdit ETable cell. */
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index 39df6f2b32..62d04a0d70 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -36,6 +36,7 @@
#include <cal-util/timeutil.h>
#include "calendar-commands.h"
#include "calendar-config.h"
+#include "comp-util.h"
#include "itip-utils.h"
#include "calendar-model.h"
#include "evolution-activity-client.h"
@@ -1350,8 +1351,12 @@ calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row)
/* FIXME: This should support other types of components, but for now it
* is only used for the task list.
*/
- comp = cal_component_new ();
- cal_component_set_new_vtype (comp, priv->new_comp_vtype);
+ if (priv->new_comp_vtype == CAL_COMPONENT_EVENT)
+ comp = cal_comp_event_new_with_defaults ();
+ else {
+ comp = cal_component_new ();
+ cal_component_set_new_vtype (comp, priv->new_comp_vtype);
+ }
set_categories (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_CATEGORIES, row));
set_classification (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_CLASSIFICATION, row));
diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c
index 12bf83e7dd..44f68c4e83 100644
--- a/calendar/gui/comp-editor-factory.c
+++ b/calendar/gui/comp-editor-factory.c
@@ -26,6 +26,7 @@
#include <cal-client/cal-client.h>
#include "calendar-config.h"
#include "comp-editor-factory.h"
+#include "comp-util.h"
#include "dialogs/event-editor.h"
#include "dialogs/task-editor.h"
@@ -349,13 +350,12 @@ get_default_component (CalComponentVType vtype)
{
CalComponent *comp;
- comp = cal_component_new ();
- cal_component_set_new_vtype (comp, vtype);
-
if (vtype == CAL_COMPONENT_EVENT) {
struct icaltimetype itt;
CalComponentDateTime dt;
+ comp = cal_comp_event_new_with_defaults ();
+
itt = icaltime_today ();
dt.value = &itt;
@@ -365,6 +365,9 @@ get_default_component (CalComponentVType vtype)
cal_component_set_dtend (comp, &dt);
cal_component_commit_sequence (comp);
+ } else {
+ comp = cal_component_new ();
+ cal_component_set_new_vtype (comp, vtype);
}
return comp;
diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c
index 71efec2573..ec6c4fefbf 100644
--- a/calendar/gui/comp-util.c
+++ b/calendar/gui/comp-util.c
@@ -23,6 +23,7 @@
#include <config.h>
#endif
+#include "calendar-config.h"
#include "comp-util.h"
#include "dialogs/delete-comp.h"
@@ -231,3 +232,69 @@ cal_comp_confirm_delete_empty_comp (CalComponent *comp, CalClient *client, GtkWi
} else
return EMPTY_COMP_DO_NOT_REMOVE;
}
+
+/**
+ * cal_comp_event_new_with_defaults:
+ *
+ * Creates a new VEVENT component and adds any default alarms to it as set in
+ * the program's configuration values.
+ *
+ * Return value: A newly-created calendar component.
+ **/
+CalComponent *
+cal_comp_event_new_with_defaults (void)
+{
+ CalComponent *comp;
+ int interval;
+ CalUnits units;
+ CalComponentAlarm *alarm;
+ CalAlarmTrigger trigger;
+
+ comp = cal_component_new ();
+
+ cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT);
+
+ if (!calendar_config_get_use_default_reminder ())
+ return comp;
+
+ interval = calendar_config_get_default_reminder_interval ();
+ units = calendar_config_get_default_reminder_units ();
+
+ alarm = cal_component_alarm_new ();
+
+ /* We don't set the description of the alarm; we'll copy it from the
+ * summary when it gets committed to the server.
+ */
+
+ cal_component_alarm_set_action (alarm, CAL_ALARM_DISPLAY);
+
+ trigger.type = CAL_ALARM_TRIGGER_RELATIVE_START;
+
+ memset (&trigger.u.rel_duration, 0, sizeof (trigger.u.rel_duration));
+
+ trigger.u.rel_duration.is_neg = TRUE;
+
+ switch (units) {
+ case CAL_MINUTES:
+ trigger.u.rel_duration.minutes = interval;
+ break;
+
+ case CAL_HOURS:
+ trigger.u.rel_duration.hours = interval;
+ break;
+
+ case CAL_DAYS:
+ trigger.u.rel_duration.days = interval;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ cal_component_alarm_set_trigger (alarm, trigger);
+
+ cal_component_add_alarm (comp, alarm);
+ cal_component_alarm_free (alarm);
+
+ return comp;
+}
diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h
index b8c3ea453d..a4a55c0a2d 100644
--- a/calendar/gui/comp-util.h
+++ b/calendar/gui/comp-util.h
@@ -46,4 +46,6 @@ ConfirmDeleteEmptyCompResult cal_comp_confirm_delete_empty_comp (CalComponent *c
CalClient *client,
GtkWidget *widget);
+CalComponent *cal_comp_event_new_with_defaults (void);
+
#endif
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c
index 9372236d56..fc8d7b0c91 100644
--- a/calendar/gui/dialogs/cal-prefs-dialog.c
+++ b/calendar/gui/dialogs/cal-prefs-dialog.c
@@ -83,10 +83,15 @@ static const int time_division_map[] = {
60, 30, 15, 10, 5, -1
};
+/* The following two are kept separate in case we need to re-order each menu individually */
static const int hide_completed_units_map[] = {
CAL_MINUTES, CAL_HOURS, CAL_DAYS, -1
};
+static const int default_reminder_units_map[] = {
+ CAL_MINUTES, CAL_HOURS, CAL_DAYS, -1
+};
+
static void cal_prefs_dialog_class_init (CalPrefsDialogClass *class);
static void cal_prefs_dialog_init (CalPrefsDialog *prefs);
@@ -562,6 +567,14 @@ cal_prefs_dialog_show_config (CalPrefsDialog *prefs)
/* Other page */
e_dialog_toggle_set (priv->confirm_delete, calendar_config_get_confirm_delete ());
+
+ e_dialog_toggle_set (priv->default_reminder,
+ calendar_config_get_use_default_reminder ());
+ e_dialog_spin_set (priv->default_reminder_interval,
+ calendar_config_get_default_reminder_interval ());
+ e_dialog_option_menu_set (priv->default_reminder_units,
+ calendar_config_get_default_reminder_units (),
+ default_reminder_units_map);
}
/* Returns a pointer to a static string with an X color spec for the current
@@ -657,6 +670,14 @@ cal_prefs_dialog_update_config (CalPrefsDialog *prefs)
calendar_config_set_confirm_delete (e_dialog_toggle_get (priv->confirm_delete));
+ calendar_config_set_use_default_reminder (e_dialog_toggle_get (priv->default_reminder));
+
+ calendar_config_set_default_reminder_interval (
+ e_dialog_spin_get_int (priv->default_reminder_interval));
+
+ calendar_config_set_default_reminder_units (
+ e_dialog_option_menu_get (priv->default_reminder_units, default_reminder_units_map));
+
/* Done */
calendar_config_write ();
diff --git a/calendar/gui/dialogs/delete-comp.c b/calendar/gui/dialogs/delete-comp.c
index 1fc757c38c..405a9445b4 100644
--- a/calendar/gui/dialogs/delete-comp.c
+++ b/calendar/gui/dialogs/delete-comp.c
@@ -25,10 +25,9 @@
#include <glib.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
-#include <libgnomeui/gnome-dialog.h>
-#include <libgnomeui/gnome-dialog-util.h>
-#include <libgnomeui/gnome-uidefs.h>
+#include <libgnomeui/gnome-stock.h>
#include <gal/widgets/e-unicode.h>
+#include "widgets/misc/e-messagebox.h"
#include "../calendar-config.h"
#include "delete-comp.h"
@@ -151,10 +150,15 @@ delete_component_dialog (CalComponent *comp,
}
}
- dialog = gnome_question_dialog_modal (str, NULL, NULL);
+ dialog = e_message_box_new (str, E_MESSAGE_BOX_QUESTION,
+ GNOME_STOCK_BUTTON_YES,
+ GNOME_STOCK_BUTTON_NO,
+ NULL);
g_free (str);
- if (gnome_dialog_run (GNOME_DIALOG (dialog)) == GNOME_YES)
+ gtk_widget_hide (e_message_box_get_checkbox (E_MESSAGE_BOX (dialog)));
+
+ if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == 0)
return TRUE;
else
return FALSE;
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 6fbbbd4fb5..a0b7d09681 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -5112,8 +5112,7 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event)
/* Add a new event covering the selected range */
- comp = cal_component_new ();
- cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT);
+ comp = cal_comp_event_new_with_defaults ();
e_day_view_get_selected_time_range (day_view, &dtstart, &dtend);
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 090db420eb..3af297d2ad 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -3302,8 +3302,8 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
initial_text = e_utf8_from_gtk_event_key (widget, event->keyval, event->string);
/* Add a new event covering the selected range. */
- comp = cal_component_new ();
- cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT);
+ comp = cal_comp_event_new_with_defaults ();
+
dtstart = week_view->day_starts[week_view->selection_start_day];
dtend = week_view->day_starts[week_view->selection_end_day + 1];
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 4ce38ab750..a3f2345865 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -42,6 +42,7 @@
#include "widgets/menus/gal-view-menus.h"
#include "dialogs/event-editor.h"
#include "dialogs/task-editor.h"
+#include "comp-util.h"
#include "e-day-view.h"
#include "e-week-view.h"
#include "evolution-calendar.h"
@@ -2013,10 +2014,7 @@ gnome_calendar_new_appointment_for (GnomeCalendar *cal,
else
dt.tzid = icaltimezone_get_tzid (priv->zone);
- /* Component type */
-
- comp = cal_component_new ();
- cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT);
+ comp = cal_comp_event_new_with_defaults ();
/* DTSTART, DTEND */