aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Steinthal <steintr@src.gnome.org>1999-11-03 10:36:31 +0800
committerRussell Steinthal <steintr@src.gnome.org>1999-11-03 10:36:31 +0800
commita6c4b535334a6da5c8d1622b11a0893d0c55abee (patch)
tree40922f9ada769d340c6fdbf9fd18b22eb5a1d1f2
parent510e8547bba307dc1e7dd72bd1484faa27db1a4f (diff)
downloadgsoc2013-evolution-a6c4b535334a6da5c8d1622b11a0893d0c55abee.tar
gsoc2013-evolution-a6c4b535334a6da5c8d1622b11a0893d0c55abee.tar.gz
gsoc2013-evolution-a6c4b535334a6da5c8d1622b11a0893d0c55abee.tar.bz2
gsoc2013-evolution-a6c4b535334a6da5c8d1622b11a0893d0c55abee.tar.lz
gsoc2013-evolution-a6c4b535334a6da5c8d1622b11a0893d0c55abee.tar.xz
gsoc2013-evolution-a6c4b535334a6da5c8d1622b11a0893d0c55abee.tar.zst
gsoc2013-evolution-a6c4b535334a6da5c8d1622b11a0893d0c55abee.zip
Add default alarm support, Beep on display alarms option
Since there are now some calls from prop.c into previously static functions in eventedit.c, the code in those files should probably be reorganized. Perhaps a new alarm-utils.c file? In any case, this commits working code to the repository before we reorganize. svn path=/trunk/; revision=1366
-rw-r--r--calendar/ChangeLog10
-rw-r--r--calendar/cal-util/calobj.c21
-rw-r--r--calendar/calobj.c21
-rw-r--r--calendar/eventedit.c40
-rw-r--r--calendar/gnome-cal.c2
-rw-r--r--calendar/gui/eventedit.c40
-rw-r--r--calendar/gui/gnome-cal.c2
-rw-r--r--calendar/gui/main.c64
-rw-r--r--calendar/gui/main.h8
-rw-r--r--calendar/gui/prop.c115
-rw-r--r--calendar/main.c64
-rw-r--r--calendar/main.h8
-rw-r--r--calendar/pcs/calobj.c21
-rw-r--r--calendar/prop.c115
14 files changed, 466 insertions, 65 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 0ce0472fab..c8d5d86c0e 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,13 @@
+1999-11-02 Russell Steinthal <rms39@columbia.edu>
+
+ * prop.c: Add new alarm page to properties box
+
+ * prop.c, calobj.c, main.[ch] eventedit.c: New support for default
+ alarms, configurable in the properties box.
+
+ * gnome-cal.c, prop.c, main.[ch]: add option to beep on Display
+ alarms
+
1999-10-23 Russell Steinthal <rms39@columbia.edu>
* calendar.c (calendar_new): Correctly initialize calendar_day_end
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 806c27d8ff..f3004ddb13 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -15,6 +15,8 @@
#include "timeutil.h"
#include "../libversit/vcc.h"
+extern CalendarAlarm alarm_defaults[4];
+
static char *
ical_gen_uid (void)
{
@@ -62,19 +64,12 @@ ical_object_new (void)
static void
default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
{
- alarm->enabled = 0;
- alarm->type = type;
-
- if (type != ALARM_MAIL){
- alarm->count = 15;
- alarm->units = ALARM_MINUTES;
- } else {
- alarm->count = 1;
- alarm->units = ALARM_DAYS;
- }
-
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (def_mail);
+ alarm->type = type;
+ alarm->enabled = alarm_defaults[type].enabled;
+ alarm->count = alarm_defaults[type].count;
+ alarm->units = alarm_defaults[type].units;
+ if (alarm_defaults[type].data)
+ alarm->data = g_strdup (alarm_defaults[type].data);
else
alarm->data = g_strdup ("");
}
diff --git a/calendar/calobj.c b/calendar/calobj.c
index 806c27d8ff..f3004ddb13 100644
--- a/calendar/calobj.c
+++ b/calendar/calobj.c
@@ -15,6 +15,8 @@
#include "timeutil.h"
#include "../libversit/vcc.h"
+extern CalendarAlarm alarm_defaults[4];
+
static char *
ical_gen_uid (void)
{
@@ -62,19 +64,12 @@ ical_object_new (void)
static void
default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
{
- alarm->enabled = 0;
- alarm->type = type;
-
- if (type != ALARM_MAIL){
- alarm->count = 15;
- alarm->units = ALARM_MINUTES;
- } else {
- alarm->count = 1;
- alarm->units = ALARM_DAYS;
- }
-
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (def_mail);
+ alarm->type = type;
+ alarm->enabled = alarm_defaults[type].enabled;
+ alarm->count = alarm_defaults[type].count;
+ alarm->units = alarm_defaults[type].units;
+ if (alarm_defaults[type].data)
+ alarm->data = g_strdup (alarm_defaults[type].data);
else
alarm->data = g_strdup ("");
}
diff --git a/calendar/eventedit.c b/calendar/eventedit.c
index 926bb6f09c..2b93426b00 100644
--- a/calendar/eventedit.c
+++ b/calendar/eventedit.c
@@ -319,20 +319,30 @@ alarm_toggle (GtkToggleButton *toggle, CalendarAlarm *alarm)
#define FXS (GTK_FILL | GTK_EXPAND | GTK_SHRINK)
#define FS (GTK_FILL | GTK_SHRINK)
-static void
-ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y)
+void
+ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y, gboolean control_sens, GtkSignalFunc dirty_func)
{
GtkWidget *entry;
alarm->w_enabled = gtk_check_button_new_with_label (str);
- gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
- GTK_SIGNAL_FUNC (alarm_toggle), alarm);
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (alarm->w_enabled),
+ alarm->enabled);
+ if (control_sens)
+ gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
+ GTK_SIGNAL_FUNC (alarm_toggle), alarm);
+ if (dirty_func)
+ gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
+ GTK_SIGNAL_FUNC (dirty_func), NULL);
gtk_table_attach (table, alarm->w_enabled, 0, 1, y, y+1, FS, FS, 0, 0);
alarm->w_count = make_spin_button (alarm->count, 0, 10000);
+ if (dirty_func)
+ gtk_signal_connect (GTK_OBJECT (alarm->w_count), "changed",
+ GTK_SIGNAL_FUNC (dirty_func), NULL);
gtk_table_attach (table, alarm->w_count, 1, 2, y, y+1, FS, FS, 0, 0);
alarm->w_timesel = timesel_new ();
+ /* is there a "changed" signal which we can connect to? */
gtk_option_menu_set_history (GTK_OPTION_MENU (alarm->w_timesel), alarm->units);
gtk_table_attach (table, alarm->w_timesel, 2, 3, y, y+1, FS, FS, 0, 0);
@@ -344,6 +354,11 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t
alarm->w_entry = gtk_entry_new ();
gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data ? alarm->data : "");
+ if (dirty_func)
+ gtk_signal_connect (GTK_OBJECT (alarm->w_entry),
+ "changed",
+ GTK_SIGNAL_FUNC (dirty_func),
+ NULL);
break;
case ALARM_PROGRAM:
@@ -354,12 +369,17 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (alarm->w_entry));
gtk_entry_set_text (GTK_ENTRY (entry), alarm->data ? alarm->data : "");
gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
+ if (dirty_func)
+ gtk_signal_connect (GTK_OBJECT (entry),
+ "changed",
+ GTK_SIGNAL_FUNC (dirty_func),
+ NULL);
break;
default:
break;
}
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (alarm->w_enabled), alarm->enabled);
+
ee_alarm_setting (alarm, alarm->enabled);
}
@@ -379,10 +399,10 @@ ee_alarm_widgets (EventEditor *ee)
mailto = gtk_label_new (_("Mail to:"));
mailte = gtk_entry_new ();
- ee_create_ae (GTK_TABLE (table), _("Display"), &ee->ical->dalarm, ALARM_DISPLAY, 1);
- ee_create_ae (GTK_TABLE (table), _("Audio"), &ee->ical->aalarm, ALARM_AUDIO, 2);
- ee_create_ae (GTK_TABLE (table), _("Program"), &ee->ical->palarm, ALARM_PROGRAM, 3);
- ee_create_ae (GTK_TABLE (table), _("Mail"), &ee->ical->malarm, ALARM_MAIL, 4);
+ ee_create_ae (GTK_TABLE (table), _("Display"), &ee->ical->dalarm, ALARM_DISPLAY, 1, TRUE, NULL);
+ ee_create_ae (GTK_TABLE (table), _("Audio"), &ee->ical->aalarm, ALARM_AUDIO, 2, TRUE, NULL);
+ ee_create_ae (GTK_TABLE (table), _("Program"), &ee->ical->palarm, ALARM_PROGRAM, 3, TRUE, NULL);
+ ee_create_ae (GTK_TABLE (table), _("Mail"), &ee->ical->malarm, ALARM_MAIL, 4, TRUE, NULL);
return l;
}
@@ -423,7 +443,7 @@ ee_classification_widgets (EventEditor *ee)
* Retrieves the information from the CalendarAlarm widgets and stores them
* on the CalendarAlarm generic values
*/
-static void
+void
ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type)
{
GtkWidget *item;
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 1342e6454b..0487f07310 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -443,6 +443,8 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data)
GtkWidget *w;
char *msg;
+ if (beep_on_display)
+ gdk_beep ();
msg = g_strconcat (_("Reminder of your appointment at "),
ctime (&app), "`",
ico->summary, "'", NULL);
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index 926bb6f09c..2b93426b00 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -319,20 +319,30 @@ alarm_toggle (GtkToggleButton *toggle, CalendarAlarm *alarm)
#define FXS (GTK_FILL | GTK_EXPAND | GTK_SHRINK)
#define FS (GTK_FILL | GTK_SHRINK)
-static void
-ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y)
+void
+ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y, gboolean control_sens, GtkSignalFunc dirty_func)
{
GtkWidget *entry;
alarm->w_enabled = gtk_check_button_new_with_label (str);
- gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
- GTK_SIGNAL_FUNC (alarm_toggle), alarm);
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (alarm->w_enabled),
+ alarm->enabled);
+ if (control_sens)
+ gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
+ GTK_SIGNAL_FUNC (alarm_toggle), alarm);
+ if (dirty_func)
+ gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled",
+ GTK_SIGNAL_FUNC (dirty_func), NULL);
gtk_table_attach (table, alarm->w_enabled, 0, 1, y, y+1, FS, FS, 0, 0);
alarm->w_count = make_spin_button (alarm->count, 0, 10000);
+ if (dirty_func)
+ gtk_signal_connect (GTK_OBJECT (alarm->w_count), "changed",
+ GTK_SIGNAL_FUNC (dirty_func), NULL);
gtk_table_attach (table, alarm->w_count, 1, 2, y, y+1, FS, FS, 0, 0);
alarm->w_timesel = timesel_new ();
+ /* is there a "changed" signal which we can connect to? */
gtk_option_menu_set_history (GTK_OPTION_MENU (alarm->w_timesel), alarm->units);
gtk_table_attach (table, alarm->w_timesel, 2, 3, y, y+1, FS, FS, 0, 0);
@@ -344,6 +354,11 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t
alarm->w_entry = gtk_entry_new ();
gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data ? alarm->data : "");
+ if (dirty_func)
+ gtk_signal_connect (GTK_OBJECT (alarm->w_entry),
+ "changed",
+ GTK_SIGNAL_FUNC (dirty_func),
+ NULL);
break;
case ALARM_PROGRAM:
@@ -354,12 +369,17 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (alarm->w_entry));
gtk_entry_set_text (GTK_ENTRY (entry), alarm->data ? alarm->data : "");
gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0);
+ if (dirty_func)
+ gtk_signal_connect (GTK_OBJECT (entry),
+ "changed",
+ GTK_SIGNAL_FUNC (dirty_func),
+ NULL);
break;
default:
break;
}
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (alarm->w_enabled), alarm->enabled);
+
ee_alarm_setting (alarm, alarm->enabled);
}
@@ -379,10 +399,10 @@ ee_alarm_widgets (EventEditor *ee)
mailto = gtk_label_new (_("Mail to:"));
mailte = gtk_entry_new ();
- ee_create_ae (GTK_TABLE (table), _("Display"), &ee->ical->dalarm, ALARM_DISPLAY, 1);
- ee_create_ae (GTK_TABLE (table), _("Audio"), &ee->ical->aalarm, ALARM_AUDIO, 2);
- ee_create_ae (GTK_TABLE (table), _("Program"), &ee->ical->palarm, ALARM_PROGRAM, 3);
- ee_create_ae (GTK_TABLE (table), _("Mail"), &ee->ical->malarm, ALARM_MAIL, 4);
+ ee_create_ae (GTK_TABLE (table), _("Display"), &ee->ical->dalarm, ALARM_DISPLAY, 1, TRUE, NULL);
+ ee_create_ae (GTK_TABLE (table), _("Audio"), &ee->ical->aalarm, ALARM_AUDIO, 2, TRUE, NULL);
+ ee_create_ae (GTK_TABLE (table), _("Program"), &ee->ical->palarm, ALARM_PROGRAM, 3, TRUE, NULL);
+ ee_create_ae (GTK_TABLE (table), _("Mail"), &ee->ical->malarm, ALARM_MAIL, 4, TRUE, NULL);
return l;
}
@@ -423,7 +443,7 @@ ee_classification_widgets (EventEditor *ee)
* Retrieves the information from the CalendarAlarm widgets and stores them
* on the CalendarAlarm generic values
*/
-static void
+void
ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type)
{
GtkWidget *item;
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 1342e6454b..0487f07310 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -443,6 +443,8 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data)
GtkWidget *w;
char *msg;
+ if (beep_on_display)
+ gdk_beep ();
msg = g_strconcat (_("Reminder of your appointment at "),
ctime (&app), "`",
ico->summary, "'", NULL);
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 0f0cc91477..391e5535ff 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -83,6 +83,17 @@ static int show_events;
/* If set, show todo items quit */
static int show_todo;
+/* If set, beep on display alarms */
+gboolean beep_on_display = 0;
+
+/* Default values for alarms */
+CalendarAlarm alarm_defaults[4] = {
+ { ALARM_MAIL, 0, 15, ALARM_MINUTES },
+ { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
+ { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
+ { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
+};
+
static void
init_username (void)
{
@@ -101,6 +112,52 @@ range_check_hour (int hour)
return hour;
}
+static void
+init_default_alarms (void)
+{
+ int i;
+ gboolean def;
+
+ alarm_defaults [ALARM_DISPLAY].type = ALARM_DISPLAY;
+ alarm_defaults [ALARM_AUDIO].type = ALARM_AUDIO;
+ alarm_defaults [ALARM_PROGRAM].type = ALARM_PROGRAM;
+ alarm_defaults [ALARM_MAIL].type = ALARM_MAIL;
+
+ for (i = 0; i < 4; i++) {
+ switch (alarm_defaults [i].type) {
+ case ALARM_DISPLAY:
+ gnome_config_push_prefix ("/calendar/alarms/def_disp_");
+ break;
+ case ALARM_AUDIO:
+ gnome_config_push_prefix ("/calendar/alarms/def_audio_");
+ break;
+ case ALARM_PROGRAM:
+ gnome_config_push_prefix ("/calendar/alarms/def_prog_");
+ break;
+ case ALARM_MAIL:
+ gnome_config_push_prefix ("/calendar/alarms/def_mail_");
+ break;
+ }
+
+ alarm_defaults[i].enabled = gnome_config_get_int ("enabled=0");
+ if (alarm_defaults[i].type != ALARM_MAIL) {
+ alarm_defaults[i].count = gnome_config_get_int ("count=15");
+ alarm_defaults[i].units = gnome_config_get_int ("units=0");
+ } else {
+ alarm_defaults[i].count = gnome_config_get_int ("count=1");
+ alarm_defaults[i].count = gnome_config_get_int ("count=2");
+ }
+
+ alarm_defaults[i].data = gnome_config_get_string_with_default ("data=",
+ &def);
+ if (def)
+ alarm_defaults[i].data = NULL;
+
+ gnome_config_pop_prefix ();
+ }
+}
+
+
/*
* Initializes the calendar internal variables, loads defaults
*/
@@ -153,11 +210,18 @@ init_calendar (void)
todo_show_priority = gnome_config_get_bool("/calendar/Todo/show_priority");
+ /* read alarm settings */
+ beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE");
+ init_default_alarms ();
+
+
/* Done */
gnome_config_pop_prefix ();
}
+
+
static void save_calendar_cmd (GtkWidget *widget, void *data);
static void
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
index 584ce2e83c..6419153be8 100644
--- a/calendar/gui/main.h
+++ b/calendar/gui/main.h
@@ -44,6 +44,9 @@ extern gboolean todo_style_changed;
extern gint todo_current_sort_column;
extern gint todo_current_sort_type;
+/* default alarm stuff */
+extern CalendarAlarm alarm_defaults[4];
+extern gboolean beep_on_display;
/* Creates and runs the preferences dialog box */
void properties (GtkWidget *toplevel);
@@ -79,3 +82,8 @@ GnomeCalendar *new_calendar (char *full_name, char *calendar_file,
char *geometry, char *page, gboolean hidden);
#endif
+
+
+
+
+
diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c
index 129407293b..4f1ec889d4 100644
--- a/calendar/gui/prop.c
+++ b/calendar/gui/prop.c
@@ -21,7 +21,8 @@
enum {
PROP_TIME_DISPLAY,
PROP_COLORS,
- PROP_TODO
+ PROP_TODO,
+ PROP_ALARMS
};
static GtkWidget *prop_win; /* The preferences dialog */
@@ -47,6 +48,13 @@ static GtkWidget *due_date_show_button;
static GtkWidget *due_date_overdue_highlight;
static GtkWidget *priority_show_button;
+/* Widgets for the alarm page */
+static GtkWidget *enable_display_beep;
+
+/* prototypes */
+static void prop_apply_alarms (void);
+static void create_alarm_page (void);
+
/* Callback used when the property box is closed -- just sets the prop_win variable to null. */
static int
prop_cancel (void)
@@ -146,7 +154,11 @@ prop_apply (GtkWidget *w, int page)
break;
case PROP_TODO:
- prop_apply_todo();
+ prop_apply_todo ();
+ break;
+
+ case PROP_ALARMS:
+ prop_apply_alarms ();
break;
case -1:
@@ -654,7 +666,8 @@ properties (GtkWidget *toplevel)
create_time_display_page ();
create_colors_page ();
- create_todo_page();
+ create_todo_page ();
+ create_alarm_page ();
gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
(GtkSignalFunc) prop_cancel, NULL);
@@ -702,5 +715,101 @@ color_spec_from_prop (ColorProp propnum)
return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b);
}
+static void
+create_alarm_page (void)
+{
+ GtkWidget *main_box;
+ GtkWidget *default_frame;
+ GtkWidget *default_table;
+ GtkWidget *misc_frame;
+ GtkWidget *misc_box;
+
+ main_box = gtk_hbox_new (FALSE, GNOME_PAD);
+ gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL);
+ gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win),
+ main_box, gtk_label_new (_("Alarms")));
+
+ /* build miscellaneous box */
+ misc_frame = gtk_frame_new (_("Alarm Properties"));
+ gtk_container_set_border_width (GTK_CONTAINER (misc_frame),
+ GNOME_PAD_SMALL);
+ misc_box = gtk_vbox_new (FALSE, GNOME_PAD);
+
+ gtk_container_set_border_width (GTK_CONTAINER (misc_frame), GNOME_PAD_SMALL);
+ gtk_container_add (GTK_CONTAINER (misc_frame), misc_box);
+
+ gtk_box_pack_start (GTK_BOX (main_box), misc_frame, FALSE, FALSE, 0);
+
+ enable_display_beep = gtk_check_button_new_with_label (_("Beep on display alarms"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_display_beep),
+ beep_on_display);
+ gtk_box_pack_start (GTK_BOX (misc_box), enable_display_beep, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (enable_display_beep), "toggled",
+ (GtkSignalFunc) prop_changed,
+ NULL);
+
+ /* populate default frame/box */
+ default_frame = gtk_frame_new (_("Defaults"));
+ gtk_container_set_border_width (GTK_CONTAINER (default_frame), GNOME_PAD_SMALL);
+ gtk_box_pack_start (GTK_BOX (main_box), default_frame, FALSE, FALSE, 0);
+ default_table = gtk_table_new (1, 1, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (default_table), 4);
+ gtk_table_set_row_spacings (GTK_TABLE (default_table), 4);
+ gtk_table_set_col_spacings (GTK_TABLE (default_table), 4);
+ gtk_container_add (GTK_CONTAINER (default_frame), default_table);
+
+ ee_create_ae (GTK_TABLE (default_table), _("Display"),
+ &alarm_defaults [ALARM_DISPLAY], ALARM_DISPLAY, 1,
+ FALSE, prop_changed);
+ ee_create_ae (GTK_TABLE (default_table), _("Audio"),
+ &alarm_defaults [ALARM_AUDIO], ALARM_AUDIO, 2,
+ FALSE, prop_changed);
+ ee_create_ae (GTK_TABLE (default_table), _("Program"),
+ &alarm_defaults [ALARM_PROGRAM], ALARM_PROGRAM, 3,
+ FALSE, prop_changed);
+ ee_create_ae (GTK_TABLE (default_table), _("Mail"),
+ &alarm_defaults [ALARM_MAIL], ALARM_MAIL, 4,
+ FALSE, prop_changed);
+}
+
+static void
+prop_store_alarm_default_values (CalendarAlarm* alarm)
+{
+ ee_store_alarm (alarm, alarm->type);
+ switch (alarm->type) {
+ case ALARM_DISPLAY:
+ gnome_config_push_prefix ("/calendar/alarms/def_disp_");
+ break;
+ case ALARM_AUDIO:
+ gnome_config_push_prefix ("/calendar/alarms/def_audio_");
+ break;
+ case ALARM_PROGRAM:
+ gnome_config_push_prefix ("/calendar/alarms/def_prog_");
+ break;
+ case ALARM_MAIL:
+ gnome_config_push_prefix ("/calendar/alarms/def_mail_");
+ break;
+ }
+
+ gnome_config_set_int ("enabled", alarm->enabled);
+ gnome_config_set_int ("count", alarm->count);
+ gnome_config_set_int ("units", alarm->units);
+ if (alarm->data)
+ gnome_config_set_string ("data", alarm->data);
+
+ gnome_config_pop_prefix ();
+ gnome_config_sync ();
+}
+
+static void
+prop_apply_alarms ()
+{
+ int i;
+ for (i=0; i < 4; i++)
+ prop_store_alarm_default_values (&alarm_defaults [i]);
+ beep_on_display = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enable_display_beep));
+ gnome_config_set_bool ("/calendar/alarms/beep_on_display", beep_on_display);
+ gnome_config_sync();
+}
diff --git a/calendar/main.c b/calendar/main.c
index 0f0cc91477..391e5535ff 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -83,6 +83,17 @@ static int show_events;
/* If set, show todo items quit */
static int show_todo;
+/* If set, beep on display alarms */
+gboolean beep_on_display = 0;
+
+/* Default values for alarms */
+CalendarAlarm alarm_defaults[4] = {
+ { ALARM_MAIL, 0, 15, ALARM_MINUTES },
+ { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
+ { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
+ { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
+};
+
static void
init_username (void)
{
@@ -101,6 +112,52 @@ range_check_hour (int hour)
return hour;
}
+static void
+init_default_alarms (void)
+{
+ int i;
+ gboolean def;
+
+ alarm_defaults [ALARM_DISPLAY].type = ALARM_DISPLAY;
+ alarm_defaults [ALARM_AUDIO].type = ALARM_AUDIO;
+ alarm_defaults [ALARM_PROGRAM].type = ALARM_PROGRAM;
+ alarm_defaults [ALARM_MAIL].type = ALARM_MAIL;
+
+ for (i = 0; i < 4; i++) {
+ switch (alarm_defaults [i].type) {
+ case ALARM_DISPLAY:
+ gnome_config_push_prefix ("/calendar/alarms/def_disp_");
+ break;
+ case ALARM_AUDIO:
+ gnome_config_push_prefix ("/calendar/alarms/def_audio_");
+ break;
+ case ALARM_PROGRAM:
+ gnome_config_push_prefix ("/calendar/alarms/def_prog_");
+ break;
+ case ALARM_MAIL:
+ gnome_config_push_prefix ("/calendar/alarms/def_mail_");
+ break;
+ }
+
+ alarm_defaults[i].enabled = gnome_config_get_int ("enabled=0");
+ if (alarm_defaults[i].type != ALARM_MAIL) {
+ alarm_defaults[i].count = gnome_config_get_int ("count=15");
+ alarm_defaults[i].units = gnome_config_get_int ("units=0");
+ } else {
+ alarm_defaults[i].count = gnome_config_get_int ("count=1");
+ alarm_defaults[i].count = gnome_config_get_int ("count=2");
+ }
+
+ alarm_defaults[i].data = gnome_config_get_string_with_default ("data=",
+ &def);
+ if (def)
+ alarm_defaults[i].data = NULL;
+
+ gnome_config_pop_prefix ();
+ }
+}
+
+
/*
* Initializes the calendar internal variables, loads defaults
*/
@@ -153,11 +210,18 @@ init_calendar (void)
todo_show_priority = gnome_config_get_bool("/calendar/Todo/show_priority");
+ /* read alarm settings */
+ beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE");
+ init_default_alarms ();
+
+
/* Done */
gnome_config_pop_prefix ();
}
+
+
static void save_calendar_cmd (GtkWidget *widget, void *data);
static void
diff --git a/calendar/main.h b/calendar/main.h
index 584ce2e83c..6419153be8 100644
--- a/calendar/main.h
+++ b/calendar/main.h
@@ -44,6 +44,9 @@ extern gboolean todo_style_changed;
extern gint todo_current_sort_column;
extern gint todo_current_sort_type;
+/* default alarm stuff */
+extern CalendarAlarm alarm_defaults[4];
+extern gboolean beep_on_display;
/* Creates and runs the preferences dialog box */
void properties (GtkWidget *toplevel);
@@ -79,3 +82,8 @@ GnomeCalendar *new_calendar (char *full_name, char *calendar_file,
char *geometry, char *page, gboolean hidden);
#endif
+
+
+
+
+
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
index 806c27d8ff..f3004ddb13 100644
--- a/calendar/pcs/calobj.c
+++ b/calendar/pcs/calobj.c
@@ -15,6 +15,8 @@
#include "timeutil.h"
#include "../libversit/vcc.h"
+extern CalendarAlarm alarm_defaults[4];
+
static char *
ical_gen_uid (void)
{
@@ -62,19 +64,12 @@ ical_object_new (void)
static void
default_alarm (iCalObject *ical, CalendarAlarm *alarm, char *def_mail, enum AlarmType type)
{
- alarm->enabled = 0;
- alarm->type = type;
-
- if (type != ALARM_MAIL){
- alarm->count = 15;
- alarm->units = ALARM_MINUTES;
- } else {
- alarm->count = 1;
- alarm->units = ALARM_DAYS;
- }
-
- if (type == ALARM_MAIL)
- alarm->data = g_strdup (def_mail);
+ alarm->type = type;
+ alarm->enabled = alarm_defaults[type].enabled;
+ alarm->count = alarm_defaults[type].count;
+ alarm->units = alarm_defaults[type].units;
+ if (alarm_defaults[type].data)
+ alarm->data = g_strdup (alarm_defaults[type].data);
else
alarm->data = g_strdup ("");
}
diff --git a/calendar/prop.c b/calendar/prop.c
index 129407293b..4f1ec889d4 100644
--- a/calendar/prop.c
+++ b/calendar/prop.c
@@ -21,7 +21,8 @@
enum {
PROP_TIME_DISPLAY,
PROP_COLORS,
- PROP_TODO
+ PROP_TODO,
+ PROP_ALARMS
};
static GtkWidget *prop_win; /* The preferences dialog */
@@ -47,6 +48,13 @@ static GtkWidget *due_date_show_button;
static GtkWidget *due_date_overdue_highlight;
static GtkWidget *priority_show_button;
+/* Widgets for the alarm page */
+static GtkWidget *enable_display_beep;
+
+/* prototypes */
+static void prop_apply_alarms (void);
+static void create_alarm_page (void);
+
/* Callback used when the property box is closed -- just sets the prop_win variable to null. */
static int
prop_cancel (void)
@@ -146,7 +154,11 @@ prop_apply (GtkWidget *w, int page)
break;
case PROP_TODO:
- prop_apply_todo();
+ prop_apply_todo ();
+ break;
+
+ case PROP_ALARMS:
+ prop_apply_alarms ();
break;
case -1:
@@ -654,7 +666,8 @@ properties (GtkWidget *toplevel)
create_time_display_page ();
create_colors_page ();
- create_todo_page();
+ create_todo_page ();
+ create_alarm_page ();
gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
(GtkSignalFunc) prop_cancel, NULL);
@@ -702,5 +715,101 @@ color_spec_from_prop (ColorProp propnum)
return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b);
}
+static void
+create_alarm_page (void)
+{
+ GtkWidget *main_box;
+ GtkWidget *default_frame;
+ GtkWidget *default_table;
+ GtkWidget *misc_frame;
+ GtkWidget *misc_box;
+
+ main_box = gtk_hbox_new (FALSE, GNOME_PAD);
+ gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL);
+ gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win),
+ main_box, gtk_label_new (_("Alarms")));
+
+ /* build miscellaneous box */
+ misc_frame = gtk_frame_new (_("Alarm Properties"));
+ gtk_container_set_border_width (GTK_CONTAINER (misc_frame),
+ GNOME_PAD_SMALL);
+ misc_box = gtk_vbox_new (FALSE, GNOME_PAD);
+
+ gtk_container_set_border_width (GTK_CONTAINER (misc_frame), GNOME_PAD_SMALL);
+ gtk_container_add (GTK_CONTAINER (misc_frame), misc_box);
+
+ gtk_box_pack_start (GTK_BOX (main_box), misc_frame, FALSE, FALSE, 0);
+
+ enable_display_beep = gtk_check_button_new_with_label (_("Beep on display alarms"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_display_beep),
+ beep_on_display);
+ gtk_box_pack_start (GTK_BOX (misc_box), enable_display_beep, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (enable_display_beep), "toggled",
+ (GtkSignalFunc) prop_changed,
+ NULL);
+
+ /* populate default frame/box */
+ default_frame = gtk_frame_new (_("Defaults"));
+ gtk_container_set_border_width (GTK_CONTAINER (default_frame), GNOME_PAD_SMALL);
+ gtk_box_pack_start (GTK_BOX (main_box), default_frame, FALSE, FALSE, 0);
+ default_table = gtk_table_new (1, 1, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (default_table), 4);
+ gtk_table_set_row_spacings (GTK_TABLE (default_table), 4);
+ gtk_table_set_col_spacings (GTK_TABLE (default_table), 4);
+ gtk_container_add (GTK_CONTAINER (default_frame), default_table);
+
+ ee_create_ae (GTK_TABLE (default_table), _("Display"),
+ &alarm_defaults [ALARM_DISPLAY], ALARM_DISPLAY, 1,
+ FALSE, prop_changed);
+ ee_create_ae (GTK_TABLE (default_table), _("Audio"),
+ &alarm_defaults [ALARM_AUDIO], ALARM_AUDIO, 2,
+ FALSE, prop_changed);
+ ee_create_ae (GTK_TABLE (default_table), _("Program"),
+ &alarm_defaults [ALARM_PROGRAM], ALARM_PROGRAM, 3,
+ FALSE, prop_changed);
+ ee_create_ae (GTK_TABLE (default_table), _("Mail"),
+ &alarm_defaults [ALARM_MAIL], ALARM_MAIL, 4,
+ FALSE, prop_changed);
+}
+
+static void
+prop_store_alarm_default_values (CalendarAlarm* alarm)
+{
+ ee_store_alarm (alarm, alarm->type);
+ switch (alarm->type) {
+ case ALARM_DISPLAY:
+ gnome_config_push_prefix ("/calendar/alarms/def_disp_");
+ break;
+ case ALARM_AUDIO:
+ gnome_config_push_prefix ("/calendar/alarms/def_audio_");
+ break;
+ case ALARM_PROGRAM:
+ gnome_config_push_prefix ("/calendar/alarms/def_prog_");
+ break;
+ case ALARM_MAIL:
+ gnome_config_push_prefix ("/calendar/alarms/def_mail_");
+ break;
+ }
+
+ gnome_config_set_int ("enabled", alarm->enabled);
+ gnome_config_set_int ("count", alarm->count);
+ gnome_config_set_int ("units", alarm->units);
+ if (alarm->data)
+ gnome_config_set_string ("data", alarm->data);
+
+ gnome_config_pop_prefix ();
+ gnome_config_sync ();
+}
+
+static void
+prop_apply_alarms ()
+{
+ int i;
+ for (i=0; i < 4; i++)
+ prop_store_alarm_default_values (&alarm_defaults [i]);
+ beep_on_display = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enable_display_beep));
+ gnome_config_set_bool ("/calendar/alarms/beep_on_display", beep_on_display);
+ gnome_config_sync();
+}