aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorRussell Steinthal <steintr@src.gnome.org>1999-12-03 08:55:01 +0800
committerRussell Steinthal <steintr@src.gnome.org>1999-12-03 08:55:01 +0800
commitafb45991801e0496d1f177ee5c973bca980ceef3 (patch)
treecab5dce5bbcd84be3299390f7edc66d0f265973e /calendar/gui
parentaea33f51dd45886be8dd22970e2e6f36ef9a25d6 (diff)
downloadgsoc2013-evolution-afb45991801e0496d1f177ee5c973bca980ceef3.tar
gsoc2013-evolution-afb45991801e0496d1f177ee5c973bca980ceef3.tar.gz
gsoc2013-evolution-afb45991801e0496d1f177ee5c973bca980ceef3.tar.bz2
gsoc2013-evolution-afb45991801e0496d1f177ee5c973bca980ceef3.tar.lz
gsoc2013-evolution-afb45991801e0496d1f177ee5c973bca980ceef3.tar.xz
gsoc2013-evolution-afb45991801e0496d1f177ee5c973bca980ceef3.tar.zst
gsoc2013-evolution-afb45991801e0496d1f177ee5c973bca980ceef3.zip
The long-awaited and much-needed (IMNSHO) snooze button for gnomecal alarms.
Not strictly [vi]Calendar compliant, but much more intuitive. svn path=/trunk/; revision=1456
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/gnome-cal.c45
-rw-r--r--calendar/gui/main.c10
-rw-r--r--calendar/gui/main.h3
-rw-r--r--calendar/gui/prop.c32
4 files changed, 82 insertions, 8 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index d452d8a2b6..9b3479e473 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -419,10 +419,13 @@ timeout_beep (gpointer data)
}
void
-calendar_notify (time_t time, CalendarAlarm *which, void *data)
+calendar_notify (time_t activation_time, CalendarAlarm *which, void *data)
{
iCalObject *ico = data;
guint beep_tag, timer_tag;
+ int ret;
+ gchar* snooze_button = (enable_snooze ? _("Snooze") : NULL);
+ time_t now, diff;
if (&ico->aalarm == which){
time_t app = ico->aalarm.trigger + ico->aalarm.offset;
@@ -434,7 +437,7 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data)
ico->summary, "'", NULL);
/* Idea: we need Snooze option :-) */
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, "Ok", NULL);
+ w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, _("Ok"), snooze_button, NULL);
beep_tag = gtk_timeout_add (1000, start_beeping, NULL);
if (enable_aalarm_timeout)
timer_tag = gtk_timeout_add (audio_alarm_timeout*1000,
@@ -445,10 +448,23 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data)
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);
-
+ gtk_widget_ref (w);
+ ret = gnome_dialog_run (GNOME_DIALOG (w));
+ switch (ret) {
+ case 1:
+ stop_beeping (GTK_OBJECT (w), NULL);
+ now = time (NULL);
+ diff = now - which->trigger;
+ which->trigger = which->trigger + diff + snooze_secs;
+ which->offset = which->offset - diff - snooze_secs;
+ alarm_add (which, &calendar_notify, data);
+ break;
+ default:
+ stop_beeping (GTK_OBJECT (w), NULL);
+ break;
+ }
+
+ gtk_widget_unref (w);
return;
}
@@ -474,8 +490,21 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data)
msg = g_strconcat (_("Reminder of your appointment at "),
ctime (&app), "`",
ico->summary, "'", NULL);
- w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, "Ok", NULL);
- gtk_widget_show (w);
+ w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO,
+ _("Ok"), snooze_button, NULL);
+ ret = gnome_dialog_run (GNOME_DIALOG (w));
+ switch (ret) {
+ case 1:
+ now = time (NULL);
+ diff = now - which->trigger;
+ which->trigger = which->trigger + diff + snooze_secs;
+ which->offset = which->offset - diff - snooze_secs;
+ alarm_add (which, &calendar_notify, data);
+ break;
+ default:
+ break;
+ }
+
return;
}
}
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 4aef2b7dc6..98157d101d 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -93,6 +93,9 @@ gboolean beep_on_display = 0;
gboolean enable_aalarm_timeout = 0;
guint audio_alarm_timeout = 0;
const guint MAX_AALARM_TIMEOUT = 3600;
+const guint MAX_SNOOZE_SECS = 3600;
+gboolean enable_snooze = 0;
+guint snooze_secs = 60;
/* Default values for alarms */
CalendarAlarm alarm_defaults[4] = {
@@ -231,6 +234,13 @@ init_calendar (void)
audio_alarm_timeout = 1;
if (audio_alarm_timeout > MAX_AALARM_TIMEOUT)
audio_alarm_timeout = MAX_AALARM_TIMEOUT;
+ enable_snooze = gnome_config_get_bool ("/calendar/alarms/enable_snooze=FALSE");
+ snooze_secs = gnome_config_get_int ("/calendar/alarms/snooze_secs=300");
+ if (snooze_secs < 1)
+ snooze_secs = 1;
+ if (snooze_secs > MAX_SNOOZE_SECS)
+ snooze_secs = MAX_SNOOZE_SECS;
+
init_default_alarms ();
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
index 77a5e12217..2785e1d2d1 100644
--- a/calendar/gui/main.h
+++ b/calendar/gui/main.h
@@ -56,6 +56,9 @@ extern gboolean beep_on_display;
extern gboolean enable_aalarm_timeout;
extern guint audio_alarm_timeout;
extern const guint MAX_AALARM_TIMEOUT;
+extern gboolean enable_snooze;
+extern guint snooze_secs;
+extern const guint MAX_SNOOZE_SECS;
/* Creates and runs the preferences dialog box */
void properties (GtkWidget *toplevel);
diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c
index 29b4f527f6..6f2fec605b 100644
--- a/calendar/gui/prop.c
+++ b/calendar/gui/prop.c
@@ -58,11 +58,14 @@ static GtkWidget *priority_show_button;
static GtkWidget *enable_display_beep;
static GtkWidget *to_cb;
static GtkWidget *to_spin;
+static GtkWidget *snooze_cb;
+static GtkWidget *snooze_spin;
/* prototypes */
static void prop_apply_alarms (void);
static void create_alarm_page (void);
static void to_cb_changed (GtkWidget* object, gpointer data);
+static void snooze_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,
@@ -811,6 +814,23 @@ create_alarm_page (void)
gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0);
+ /* snooze widgets */
+ box = gtk_hbox_new (FALSE, GNOME_PAD);
+ snooze_cb = gtk_check_button_new_with_label (_("Enable snoozing for "));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (snooze_cb),
+ enable_snooze);
+ gtk_signal_connect (GTK_OBJECT (snooze_cb), "toggled",
+ (GtkSignalFunc) snooze_cb_changed, NULL);
+ gtk_box_pack_start (GTK_BOX (box), snooze_cb, FALSE, FALSE, 0);
+ snooze_spin = make_spin_button (snooze_secs, 1, MAX_SNOOZE_SECS);
+ gtk_widget_set_sensitive (snooze_spin, enable_snooze);
+ gtk_signal_connect (GTK_OBJECT (snooze_spin), "changed",
+ (GtkSignalFunc) prop_changed, NULL);
+ gtk_box_pack_start (GTK_BOX (box), snooze_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);
@@ -878,6 +898,10 @@ prop_apply_alarms ()
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);
+ enable_snooze = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb));
+ gnome_config_set_bool ("/calendar/alarms/enable_snooze", enable_snooze);
+ snooze_secs = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (snooze_spin));
+ gnome_config_set_int ("/calendar/alarms/snooze_secs", snooze_secs);
gnome_config_sync();
}
@@ -891,5 +915,13 @@ to_cb_changed (GtkWidget *object, gpointer data)
prop_changed ();
}
+static void
+snooze_cb_changed (GtkWidget *object, gpointer data)
+{
+ gboolean active =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb));
+ gtk_widget_set_sensitive (snooze_spin, active);
+ prop_changed ();
+}