diff options
author | Russell Steinthal <steintr@src.gnome.org> | 1999-11-13 01:11:02 +0800 |
---|---|---|
committer | Russell Steinthal <steintr@src.gnome.org> | 1999-11-13 01:11:02 +0800 |
commit | dded739f636bb8f75a6779bc31673e4f8b994225 (patch) | |
tree | a408cbad0fd52bb85c2a7e72d96631d17e9c4297 /calendar | |
parent | 43fd06f8ec06257cbd135b03c5e203dfcd134fd4 (diff) | |
download | gsoc2013-evolution-dded739f636bb8f75a6779bc31673e4f8b994225.tar gsoc2013-evolution-dded739f636bb8f75a6779bc31673e4f8b994225.tar.gz gsoc2013-evolution-dded739f636bb8f75a6779bc31673e4f8b994225.tar.bz2 gsoc2013-evolution-dded739f636bb8f75a6779bc31673e4f8b994225.tar.lz gsoc2013-evolution-dded739f636bb8f75a6779bc31673e4f8b994225.tar.xz gsoc2013-evolution-dded739f636bb8f75a6779bc31673e4f8b994225.tar.zst gsoc2013-evolution-dded739f636bb8f75a6779bc31673e4f8b994225.zip |
The long-awaited audio alarm timeout patch. Implements wishlist bug #3089.
Note: Per discussion on calendar-list, checks to see that timeout value is
reasonable, i.e. between 1 and MAX_AALARM_TIMEOUT (set to 3600 seconds). Check
is enforced by GtkSpinButton in property box and the patch when loading from
disk.
svn path=/trunk/; revision=1384
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 12 | ||||
-rw-r--r-- | calendar/eventedit.c | 7 | ||||
-rw-r--r-- | calendar/gnome-cal.c | 40 | ||||
-rw-r--r-- | calendar/gui/eventedit.c | 7 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 40 | ||||
-rw-r--r-- | calendar/gui/main.c | 12 | ||||
-rw-r--r-- | calendar/gui/main.h | 5 | ||||
-rw-r--r-- | calendar/gui/prop.c | 46 | ||||
-rw-r--r-- | calendar/main.c | 12 | ||||
-rw-r--r-- | calendar/main.h | 5 | ||||
-rw-r--r-- | calendar/prop.c | 46 |
11 files changed, 212 insertions, 20 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 139434da4c..050baea228 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,15 @@ +1999-11-12 Russell Steinthal <rms39@columbia.edu> + + * prop.c: Config code for timeout, make Alarms property page use a + vbox instead of an hbox so that the propbox stays a reasonable width. + + * gnome-cal.c, main.[ch]: Add timeout for audio alarms, code to load + from config file + + * eventedit.c: Give some static functions external linkage so they + can be used elsewhere (make_spin_button); add some prototypes to + appease gcc. + 1999-11-11 Russell Steinthal <rms39@columbia.edu> * calendar.c (calendar_day_change): Add call to diff --git a/calendar/eventedit.c b/calendar/eventedit.c index 2b93426b00..057c2652d2 100644 --- a/calendar/eventedit.c +++ b/calendar/eventedit.c @@ -18,6 +18,11 @@ static void event_editor_class_init (EventEditorClass *class); static void event_editor_init (EventEditor *ee); static void event_editor_destroy (GtkObject *object); +GtkWidget* make_spin_button (int val, int low, int high); +void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, + int y, gboolean control_sens, GtkSignalFunc dirty_func); +void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type); + /* Note: do not i18n these strings, they are part of the vCalendar protocol */ static char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" }; @@ -59,7 +64,7 @@ event_editor_class_init (EventEditorClass *class) object_class->destroy = event_editor_destroy; } -static GtkWidget * +GtkWidget * make_spin_button (int val, int low, int high) { GtkAdjustment *adj; diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c index 0487f07310..d452d8a2b6 100644 --- a/calendar/gnome-cal.c +++ b/calendar/gnome-cal.c @@ -387,11 +387,20 @@ mail_notify (char *mail_address, char *text, time_t app_time) } static void -stop_beeping (GtkObject *object, gpointer tagp) +stop_beeping (GtkObject* object, gpointer data) { - guint tag = GPOINTER_TO_INT (tagp); - - gtk_timeout_remove (tag); + guint timer_tag, beep_tag; + timer_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "timer_tag")); + beep_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "beep_tag")); + + if (beep_tag > 0) { + gtk_timeout_remove (beep_tag); + gtk_object_set_data (object, "beep_tag", GINT_TO_POINTER (0)); + } + if (timer_tag > 0) { + gtk_timeout_remove (timer_tag); + gtk_object_set_data (object, "timer_tag", GINT_TO_POINTER (0)); + } } static gint @@ -402,11 +411,18 @@ start_beeping (gpointer data) return TRUE; } +static gint +timeout_beep (gpointer data) +{ + stop_beeping (data, NULL); + return FALSE; +} + void calendar_notify (time_t time, CalendarAlarm *which, void *data) { iCalObject *ico = data; - guint tag; + guint beep_tag, timer_tag; if (&ico->aalarm == which){ time_t app = ico->aalarm.trigger + ico->aalarm.offset; @@ -419,8 +435,18 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data) /* Idea: we need Snooze option :-) */ w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, "Ok", NULL); - tag = gtk_timeout_add (1000, start_beeping, NULL); - gtk_signal_connect (GTK_OBJECT (w), "destroy", stop_beeping, GINT_TO_POINTER (tag)); + beep_tag = gtk_timeout_add (1000, start_beeping, NULL); + if (enable_aalarm_timeout) + timer_tag = gtk_timeout_add (audio_alarm_timeout*1000, + timeout_beep, w); + else + timer_tag = 0; + gtk_object_set_data (GTK_OBJECT (w), "timer_tag", + GINT_TO_POINTER (timer_tag)); + gtk_object_set_data (GTK_OBJECT (w), "beep_tag", + GINT_TO_POINTER (beep_tag)); + gtk_signal_connect (GTK_OBJECT (w), "destroy", stop_beeping, + NULL); gtk_widget_show (w); return; diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c index 2b93426b00..057c2652d2 100644 --- a/calendar/gui/eventedit.c +++ b/calendar/gui/eventedit.c @@ -18,6 +18,11 @@ static void event_editor_class_init (EventEditorClass *class); static void event_editor_init (EventEditor *ee); static void event_editor_destroy (GtkObject *object); +GtkWidget* make_spin_button (int val, int low, int high); +void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, + int y, gboolean control_sens, GtkSignalFunc dirty_func); +void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type); + /* Note: do not i18n these strings, they are part of the vCalendar protocol */ static char *class_names [] = { "PUBLIC", "PRIVATE", "CONFIDENTIAL" }; @@ -59,7 +64,7 @@ event_editor_class_init (EventEditorClass *class) object_class->destroy = event_editor_destroy; } -static GtkWidget * +GtkWidget * make_spin_button (int val, int low, int high) { GtkAdjustment *adj; diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 0487f07310..d452d8a2b6 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -387,11 +387,20 @@ mail_notify (char *mail_address, char *text, time_t app_time) } static void -stop_beeping (GtkObject *object, gpointer tagp) +stop_beeping (GtkObject* object, gpointer data) { - guint tag = GPOINTER_TO_INT (tagp); - - gtk_timeout_remove (tag); + guint timer_tag, beep_tag; + timer_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "timer_tag")); + beep_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "beep_tag")); + + if (beep_tag > 0) { + gtk_timeout_remove (beep_tag); + gtk_object_set_data (object, "beep_tag", GINT_TO_POINTER (0)); + } + if (timer_tag > 0) { + gtk_timeout_remove (timer_tag); + gtk_object_set_data (object, "timer_tag", GINT_TO_POINTER (0)); + } } static gint @@ -402,11 +411,18 @@ start_beeping (gpointer data) return TRUE; } +static gint +timeout_beep (gpointer data) +{ + stop_beeping (data, NULL); + return FALSE; +} + void calendar_notify (time_t time, CalendarAlarm *which, void *data) { iCalObject *ico = data; - guint tag; + guint beep_tag, timer_tag; if (&ico->aalarm == which){ time_t app = ico->aalarm.trigger + ico->aalarm.offset; @@ -419,8 +435,18 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data) /* Idea: we need Snooze option :-) */ w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, "Ok", NULL); - tag = gtk_timeout_add (1000, start_beeping, NULL); - gtk_signal_connect (GTK_OBJECT (w), "destroy", stop_beeping, GINT_TO_POINTER (tag)); + beep_tag = gtk_timeout_add (1000, start_beeping, NULL); + if (enable_aalarm_timeout) + timer_tag = gtk_timeout_add (audio_alarm_timeout*1000, + timeout_beep, w); + else + timer_tag = 0; + gtk_object_set_data (GTK_OBJECT (w), "timer_tag", + GINT_TO_POINTER (timer_tag)); + gtk_object_set_data (GTK_OBJECT (w), "beep_tag", + GINT_TO_POINTER (beep_tag)); + gtk_signal_connect (GTK_OBJECT (w), "destroy", stop_beeping, + NULL); gtk_widget_show (w); return; diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 391e5535ff..b41b9a6d63 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -86,6 +86,12 @@ static int show_todo; /* If set, beep on display alarms */ gboolean beep_on_display = 0; +/* If true, timeout the beeper on audio alarms */ + +gboolean enable_aalarm_timeout = 0; +guint audio_alarm_timeout = 0; +const guint MAX_AALARM_TIMEOUT = 3600; + /* Default values for alarms */ CalendarAlarm alarm_defaults[4] = { { ALARM_MAIL, 0, 15, ALARM_MINUTES }, @@ -212,6 +218,12 @@ init_calendar (void) /* read alarm settings */ beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE"); + enable_aalarm_timeout = gnome_config_get_bool ("/calendar/alarms/enable_audio_timeout=FALSE"); + audio_alarm_timeout = gnome_config_get_int ("/calendar/alarms/audio_alarm_timeout=60"); + if (audio_alarm_timeout < 1) + audio_alarm_timeout = 1; + if (audio_alarm_timeout > MAX_AALARM_TIMEOUT) + audio_alarm_timeout = MAX_AALARM_TIMEOUT; init_default_alarms (); diff --git a/calendar/gui/main.h b/calendar/gui/main.h index 6419153be8..bc80e37be4 100644 --- a/calendar/gui/main.h +++ b/calendar/gui/main.h @@ -44,9 +44,12 @@ extern gboolean todo_style_changed; extern gint todo_current_sort_column; extern gint todo_current_sort_type; -/* default alarm stuff */ +/* alarm stuff */ extern CalendarAlarm alarm_defaults[4]; extern gboolean beep_on_display; +extern gboolean enable_aalarm_timeout; +extern guint audio_alarm_timeout; +extern const guint MAX_AALARM_TIMEOUT; /* Creates and runs the preferences dialog box */ void properties (GtkWidget *toplevel); diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c index 4f1ec889d4..b1fa468010 100644 --- a/calendar/gui/prop.c +++ b/calendar/gui/prop.c @@ -50,10 +50,19 @@ static GtkWidget *priority_show_button; /* Widgets for the alarm page */ static GtkWidget *enable_display_beep; +static GtkWidget *to_cb; +static GtkWidget *to_spin; /* prototypes */ static void prop_apply_alarms (void); static void create_alarm_page (void); +static void to_cb_changed (GtkWidget* object, gpointer data); + +GtkWidget* make_spin_button (int val, int low, int high); +void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, + enum AlarmType type, int y, gboolean sens, + GtkSignalFunc dirty_func); +void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type); /* Callback used when the property box is closed -- just sets the prop_win variable to null. */ static int @@ -723,8 +732,9 @@ create_alarm_page (void) GtkWidget *default_table; GtkWidget *misc_frame; GtkWidget *misc_box; + GtkWidget *box, *l; - main_box = gtk_hbox_new (FALSE, GNOME_PAD); + main_box = gtk_vbox_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"))); @@ -748,6 +758,23 @@ create_alarm_page (void) (GtkSignalFunc) prop_changed, NULL); + /* audio timeout widgets */ + box = gtk_hbox_new (FALSE, GNOME_PAD); + to_cb = gtk_check_button_new_with_label (_("Audio alarms timeout after")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (to_cb), + enable_aalarm_timeout); + gtk_signal_connect (GTK_OBJECT (to_cb), "toggled", + (GtkSignalFunc) to_cb_changed, NULL); + gtk_box_pack_start (GTK_BOX (box), to_cb, FALSE, FALSE, 0); + to_spin = make_spin_button (audio_alarm_timeout, 1, MAX_AALARM_TIMEOUT); + gtk_widget_set_sensitive (to_spin, enable_aalarm_timeout); + gtk_signal_connect (GTK_OBJECT (to_spin), "changed", + (GtkSignalFunc) prop_changed, NULL); + gtk_box_pack_start (GTK_BOX (box), to_spin, FALSE, FALSE, 0); + l = gtk_label_new (_(" seconds")); + gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0); + /* populate default frame/box */ default_frame = gtk_frame_new (_("Defaults")); gtk_container_set_border_width (GTK_CONTAINER (default_frame), GNOME_PAD_SMALL); @@ -811,5 +838,22 @@ prop_apply_alarms () 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); + enable_aalarm_timeout = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb)); + gnome_config_set_bool ("/calendar/alarms/enable_audio_timeout", enable_aalarm_timeout); + audio_alarm_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (to_spin)); + gnome_config_set_int ("/calendar/alarms/audio_alarm_timeout", audio_alarm_timeout); + gnome_config_sync(); } + +static void +to_cb_changed (GtkWidget *object, gpointer data) +{ + gboolean active = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb)); + gtk_widget_set_sensitive (to_spin, active); + prop_changed (); +} + + + diff --git a/calendar/main.c b/calendar/main.c index 391e5535ff..b41b9a6d63 100644 --- a/calendar/main.c +++ b/calendar/main.c @@ -86,6 +86,12 @@ static int show_todo; /* If set, beep on display alarms */ gboolean beep_on_display = 0; +/* If true, timeout the beeper on audio alarms */ + +gboolean enable_aalarm_timeout = 0; +guint audio_alarm_timeout = 0; +const guint MAX_AALARM_TIMEOUT = 3600; + /* Default values for alarms */ CalendarAlarm alarm_defaults[4] = { { ALARM_MAIL, 0, 15, ALARM_MINUTES }, @@ -212,6 +218,12 @@ init_calendar (void) /* read alarm settings */ beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE"); + enable_aalarm_timeout = gnome_config_get_bool ("/calendar/alarms/enable_audio_timeout=FALSE"); + audio_alarm_timeout = gnome_config_get_int ("/calendar/alarms/audio_alarm_timeout=60"); + if (audio_alarm_timeout < 1) + audio_alarm_timeout = 1; + if (audio_alarm_timeout > MAX_AALARM_TIMEOUT) + audio_alarm_timeout = MAX_AALARM_TIMEOUT; init_default_alarms (); diff --git a/calendar/main.h b/calendar/main.h index 6419153be8..bc80e37be4 100644 --- a/calendar/main.h +++ b/calendar/main.h @@ -44,9 +44,12 @@ extern gboolean todo_style_changed; extern gint todo_current_sort_column; extern gint todo_current_sort_type; -/* default alarm stuff */ +/* alarm stuff */ extern CalendarAlarm alarm_defaults[4]; extern gboolean beep_on_display; +extern gboolean enable_aalarm_timeout; +extern guint audio_alarm_timeout; +extern const guint MAX_AALARM_TIMEOUT; /* Creates and runs the preferences dialog box */ void properties (GtkWidget *toplevel); diff --git a/calendar/prop.c b/calendar/prop.c index 4f1ec889d4..b1fa468010 100644 --- a/calendar/prop.c +++ b/calendar/prop.c @@ -50,10 +50,19 @@ static GtkWidget *priority_show_button; /* Widgets for the alarm page */ static GtkWidget *enable_display_beep; +static GtkWidget *to_cb; +static GtkWidget *to_spin; /* prototypes */ static void prop_apply_alarms (void); static void create_alarm_page (void); +static void to_cb_changed (GtkWidget* object, gpointer data); + +GtkWidget* make_spin_button (int val, int low, int high); +void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, + enum AlarmType type, int y, gboolean sens, + GtkSignalFunc dirty_func); +void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type); /* Callback used when the property box is closed -- just sets the prop_win variable to null. */ static int @@ -723,8 +732,9 @@ create_alarm_page (void) GtkWidget *default_table; GtkWidget *misc_frame; GtkWidget *misc_box; + GtkWidget *box, *l; - main_box = gtk_hbox_new (FALSE, GNOME_PAD); + main_box = gtk_vbox_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"))); @@ -748,6 +758,23 @@ create_alarm_page (void) (GtkSignalFunc) prop_changed, NULL); + /* audio timeout widgets */ + box = gtk_hbox_new (FALSE, GNOME_PAD); + to_cb = gtk_check_button_new_with_label (_("Audio alarms timeout after")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (to_cb), + enable_aalarm_timeout); + gtk_signal_connect (GTK_OBJECT (to_cb), "toggled", + (GtkSignalFunc) to_cb_changed, NULL); + gtk_box_pack_start (GTK_BOX (box), to_cb, FALSE, FALSE, 0); + to_spin = make_spin_button (audio_alarm_timeout, 1, MAX_AALARM_TIMEOUT); + gtk_widget_set_sensitive (to_spin, enable_aalarm_timeout); + gtk_signal_connect (GTK_OBJECT (to_spin), "changed", + (GtkSignalFunc) prop_changed, NULL); + gtk_box_pack_start (GTK_BOX (box), to_spin, FALSE, FALSE, 0); + l = gtk_label_new (_(" seconds")); + gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0); + /* populate default frame/box */ default_frame = gtk_frame_new (_("Defaults")); gtk_container_set_border_width (GTK_CONTAINER (default_frame), GNOME_PAD_SMALL); @@ -811,5 +838,22 @@ prop_apply_alarms () 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); + enable_aalarm_timeout = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb)); + gnome_config_set_bool ("/calendar/alarms/enable_audio_timeout", enable_aalarm_timeout); + audio_alarm_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (to_spin)); + gnome_config_set_int ("/calendar/alarms/audio_alarm_timeout", audio_alarm_timeout); + gnome_config_sync(); } + +static void +to_cb_changed (GtkWidget *object, gpointer data) +{ + gboolean active = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb)); + gtk_widget_set_sensitive (to_spin, active); + prop_changed (); +} + + + |