aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-07-03 12:48:06 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-07-03 12:48:06 +0800
commiteb52ee5a862b132e6c0655cd44b5887d64ead3ca (patch)
treea2ff41b231aaa8c630e0df8c37e34fe8cde15d1c
parent5847ef85662adc9158efa2780ff251b572a63dc1 (diff)
downloadgsoc2013-evolution-eb52ee5a862b132e6c0655cd44b5887d64ead3ca.tar
gsoc2013-evolution-eb52ee5a862b132e6c0655cd44b5887d64ead3ca.tar.gz
gsoc2013-evolution-eb52ee5a862b132e6c0655cd44b5887d64ead3ca.tar.bz2
gsoc2013-evolution-eb52ee5a862b132e6c0655cd44b5887d64ead3ca.tar.lz
gsoc2013-evolution-eb52ee5a862b132e6c0655cd44b5887d64ead3ca.tar.xz
gsoc2013-evolution-eb52ee5a862b132e6c0655cd44b5887d64ead3ca.tar.zst
gsoc2013-evolution-eb52ee5a862b132e6c0655cd44b5887d64ead3ca.zip
New files with the alarm options dialog; this configures the
2001-07-02 Federico Mena Quintero <federico@ximian.com> * gui/dialogs/alarm-options.[ch]: New files with the alarm options dialog; this configures the repeat/duration properties and the options specific to each alarm action type. * gui/dialogs/alarm-page.c (AlarmPagePrivate): Added the alarm options button. Also, keep an alarm structure which we are editing and an alarm options dialog. (init_widgets): Connect to the options button. (add_clicked_cb): Clone the component we are editing instead of creating a new one so that we preserve the data from the alarm options dialog. (button_options_clicked_cb): Pop up the alarm options dialog. * cal-util/cal-component.c (cal_component_alarm_new): Doh, initialize the other fields in the new alarm. svn path=/trunk/; revision=10731
-rw-r--r--calendar/ChangeLog18
-rw-r--r--calendar/cal-util/cal-component.c9
-rw-r--r--calendar/cal-util/cal-component.h2
-rw-r--r--calendar/gui/dialogs/Makefile.am3
-rw-r--r--calendar/gui/dialogs/alarm-options.c576
-rw-r--r--calendar/gui/dialogs/alarm-options.glade398
-rw-r--r--calendar/gui/dialogs/alarm-options.h29
-rw-r--r--calendar/gui/dialogs/alarm-page.c42
-rw-r--r--calendar/gui/dialogs/alarm-page.glade7
9 files changed, 1077 insertions, 7 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 3c93bd6a6b..9498fa1cc7 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,21 @@
+2001-07-02 Federico Mena Quintero <federico@ximian.com>
+
+ * gui/dialogs/alarm-options.[ch]: New files with the alarm options
+ dialog; this configures the repeat/duration properties and the
+ options specific to each alarm action type.
+
+ * gui/dialogs/alarm-page.c (AlarmPagePrivate): Added the alarm
+ options button. Also, keep an alarm structure which we are
+ editing and an alarm options dialog.
+ (init_widgets): Connect to the options button.
+ (add_clicked_cb): Clone the component we are editing instead of
+ creating a new one so that we preserve the data from the alarm
+ options dialog.
+ (button_options_clicked_cb): Pop up the alarm options dialog.
+
+ * cal-util/cal-component.c (cal_component_alarm_new): Doh,
+ initialize the other fields in the new alarm.
+
2001-07-03 Damon Chaplin <damon@ximian.com>
* cal-client/cal-client.[hc]
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 2669dc5562..86b949dfed 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -4337,6 +4337,11 @@ cal_component_alarm_new (void)
g_free (new_auid);
alarm->action = NULL;
+ alarm->attach = NULL;
+ alarm->description.prop = NULL;
+ alarm->description.altrep_param = NULL;
+ alarm->duration = NULL;
+ alarm->repeat = NULL;
alarm->trigger = NULL;
return alarm;
@@ -4532,14 +4537,14 @@ cal_component_alarm_get_attach (CalComponentAlarm *alarm, struct icalattachtype
}
/**
- * cal_copmonent_alarm_set_attach:
+ * cal_component_alarm_set_attach:
* @alarm: An alarm.
* @attach: Attachment property or NULL to remove an existing property.
*
* Sets the attachment property of an alarm.
**/
void
-cal_copmonent_alarm_set_attach (CalComponentAlarm *alarm, struct icalattachtype *attach)
+cal_component_alarm_set_attach (CalComponentAlarm *alarm, struct icalattachtype *attach)
{
g_return_if_fail (alarm != NULL);
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index 4b3bdfaae4..2dcc06ce61 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -434,7 +434,7 @@ void cal_component_alarm_get_action (CalComponentAlarm *alarm, CalAlarmAction *a
void cal_component_alarm_set_action (CalComponentAlarm *alarm, CalAlarmAction action);
void cal_component_alarm_get_attach (CalComponentAlarm *alarm, struct icalattachtype **attach);
-void cal_copmonent_alarm_set_attach (CalComponentAlarm *alarm, struct icalattachtype *attach);
+void cal_component_alarm_set_attach (CalComponentAlarm *alarm, struct icalattachtype *attach);
void cal_component_alarm_get_description (CalComponentAlarm *alarm, CalComponentText *description);
void cal_component_alarm_set_description (CalComponentAlarm *alarm, CalComponentText *description);
diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am
index 3069c97a46..7d8e37497f 100644
--- a/calendar/gui/dialogs/Makefile.am
+++ b/calendar/gui/dialogs/Makefile.am
@@ -20,6 +20,8 @@ INCLUDES = \
noinst_LIBRARIES = libcal-dialogs.a
libcal_dialogs_a_SOURCES = \
+ alarm-options.c \
+ alarm-options.h \
alarm-page.c \
alarm-page.h \
cal-prefs-dialog.c \
@@ -58,6 +60,7 @@ libcal_dialogs_a_SOURCES = \
task-page.h
glade_DATA = \
+ alarm-options.glade \
alarm-page.glade \
cal-prefs-dialog.glade \
e-timezone-dialog.glade \
diff --git a/calendar/gui/dialogs/alarm-options.c b/calendar/gui/dialogs/alarm-options.c
new file mode 100644
index 0000000000..f94d146377
--- /dev/null
+++ b/calendar/gui/dialogs/alarm-options.c
@@ -0,0 +1,576 @@
+/* Evolution calendar - Alarm options dialog
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * Authors: Federico Mena-Quintero <federico@ximian.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <libgnome/gnome-defs.h>
+#include <libgnome/gnome-i18n.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkcheckbutton.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtkwindow.h>
+#include <glade/glade.h>
+#include "e-util/e-dialog-widgets.h"
+#include "alarm-options.h"
+
+
+
+typedef struct {
+ /* Whether the dialog was accepted or canceled */
+ gboolean canceled;
+
+ /* Glade XML data */
+ GladeXML *xml;
+
+ /* Toplevel */
+ GtkWidget *toplevel;
+
+ /* Buttons */
+ GtkWidget *button_ok;
+ GtkWidget *button_cancel;
+
+ /* Alarm repeat widgets */
+ GtkWidget *repeat_toggle;
+ GtkWidget *repeat_group;
+ GtkWidget *repeat_quantity;
+ GtkWidget *repeat_value;
+ GtkWidget *repeat_unit;
+
+ /* Display alarm widgets */
+ GtkWidget *dalarm_group;
+ GtkWidget *dalarm_description;
+
+ /* Audio alarm widgets */
+ GtkWidget *aalarm_group;
+ GtkWidget *aalarm_attach;
+
+ /* FIXME: Mail alarm widgets */
+ GtkWidget *malarm_group;
+
+ /* Procedure alarm widgets */
+ GtkWidget *palarm_group;
+ GtkWidget *palarm_program;
+ GtkWidget *palarm_args;
+} Dialog;
+
+
+
+/* Gets the widgets from the XML file and returns if they are all available. */
+static gboolean
+get_widgets (Dialog *dialog)
+{
+#define GW(name) glade_xml_get_widget (dialog->xml, name)
+
+ dialog->toplevel = GW ("alarm-options-toplevel");
+
+ dialog->button_ok = GW ("button-ok");
+ dialog->button_cancel = GW ("button-cancel");
+
+ dialog->repeat_toggle = GW ("repeat-toggle");
+ dialog->repeat_group = GW ("repeat-group");
+ dialog->repeat_quantity = GW ("repeat-quantity");
+ dialog->repeat_value = GW ("repeat-value");
+ dialog->repeat_unit = GW ("repeat-unit");
+
+ dialog->dalarm_group = GW ("dalarm-group");
+ dialog->dalarm_description = GW ("dalarm-description");
+
+ dialog->aalarm_group = GW ("aalarm-group");
+ dialog->aalarm_attach = GW ("aalarm-attach");
+
+ dialog->malarm_group = GW ("malarm-group");
+
+ dialog->palarm_group = GW ("palarm-group");
+ dialog->palarm_program = GW ("palarm-program");
+ dialog->palarm_args = GW ("palarm-args");
+
+ return (dialog->toplevel
+ && dialog->button_ok
+ && dialog->button_cancel
+ && dialog->repeat_toggle
+ && dialog->repeat_group
+ && dialog->repeat_quantity
+ && dialog->repeat_value
+ && dialog->repeat_unit
+ && dialog->dalarm_group
+ && dialog->dalarm_description
+ && dialog->aalarm_group
+ && dialog->aalarm_attach
+ && dialog->malarm_group
+ && dialog->palarm_group
+ && dialog->palarm_program
+ && dialog->palarm_args);
+}
+
+/* Closes the dialog by terminating its main loop */
+static void
+close_dialog (Dialog *dialog, gboolean canceled)
+{
+ dialog->canceled = canceled;
+ gtk_main_quit ();
+}
+
+/* Callback used when the toplevel window is deleted */
+static guint
+toplevel_delete_event_cb (GtkWidget *widget, GdkEventAny *event, gpointer data)
+{
+ Dialog *dialog;
+
+ dialog = data;
+ close_dialog (dialog, TRUE);
+ return TRUE;
+}
+
+/* Callback used when the OK button is clicked */
+static void
+button_ok_clicked_cb (GtkWidget *button, gpointer data)
+{
+ Dialog *dialog;
+
+ dialog = data;
+ close_dialog (dialog, FALSE);
+}
+
+/* Callback used when the Cancel button is clicked */
+static void
+button_cancel_clicked_cb (GtkWidget *button, gpointer data)
+{
+ Dialog *dialog;
+
+ dialog = data;
+ close_dialog (dialog, TRUE);
+}
+
+/* Callback used when the repeat toggle button is toggled. We sensitize the
+ * repeat group options as appropriate.
+ */
+static void
+repeat_toggle_toggled_cb (GtkToggleButton *toggle, gpointer data)
+{
+ Dialog *dialog;
+ gboolean active;
+
+ dialog = data;
+
+ active = gtk_toggle_button_get_active (toggle);
+
+ gtk_widget_set_sensitive (dialog->repeat_group, active);
+}
+
+/* Hooks the widget signals */
+static void
+init_widgets (Dialog *dialog)
+{
+ /* Toplevel, buttons */
+
+ dialog->canceled = TRUE;
+
+ gtk_signal_connect (GTK_OBJECT (dialog->toplevel), "delete_event",
+ GTK_SIGNAL_FUNC (toplevel_delete_event_cb), dialog);
+
+ gtk_signal_connect (GTK_OBJECT (dialog->button_ok), "clicked",
+ GTK_SIGNAL_FUNC (button_ok_clicked_cb), dialog);
+
+ gtk_signal_connect (GTK_OBJECT (dialog->button_cancel), "clicked",
+ GTK_SIGNAL_FUNC (button_cancel_clicked_cb), dialog);
+
+ /* Alarm repeat */
+
+ gtk_signal_connect (GTK_OBJECT (dialog->repeat_toggle), "toggled",
+ GTK_SIGNAL_FUNC (repeat_toggle_toggled_cb), dialog);
+}
+
+/* Fills the audio alarm widgets with the values from the alarm component */
+static void
+alarm_to_aalarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ struct icalattachtype *attach;
+ char *url;
+
+ cal_component_alarm_get_attach (alarm, &attach);
+
+ if (!attach) {
+ e_dialog_editable_set (dialog->aalarm_attach, NULL);
+ return;
+ }
+
+ /* FIXME: this does not support inline data */
+
+ url = NULL;
+
+ if (icalattachtype_get_base64 (attach))
+ g_message ("alarm_to_aalarm_widgets(): FIXME: we don't support base64 data yet");
+ else if (icalattachtype_get_binary (attach))
+ g_message ("alarm_to_aalarm_widgets(): FIXME: we don't support binary data yet");
+ else
+ url = icalattachtype_get_url (attach);
+
+ e_dialog_editable_set (dialog->aalarm_attach, url);
+
+ icalattachtype_free (attach);
+}
+
+/* Fills the display alarm widgets with the values from the alarm component */
+static void
+alarm_to_dalarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ CalComponentText description;
+
+ cal_component_alarm_get_description (alarm, &description);
+
+ e_dialog_editable_set (dialog->dalarm_description, description.value);
+}
+
+/* Fills the mail alarm widgets with the values from the alarm component */
+static void
+alarm_to_malarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ /* FIXME: nothing for now; we don't support mail alarms */
+}
+
+/* Fills the procedure alarm widgets with the values from the alarm component */
+static void
+alarm_to_palarm_widgets (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ struct icalattachtype *attach;
+ CalComponentText description;
+ char *url;
+
+ cal_component_alarm_get_attach (alarm, &attach);
+ cal_component_alarm_get_description (alarm, &description);
+
+ url = icalattachtype_get_url (attach);
+
+ e_dialog_editable_set (dialog->palarm_program, url);
+ e_dialog_editable_set (dialog->palarm_args, description.value);
+
+ icalattachtype_free (attach);
+}
+
+enum duration_units {
+ DUR_MINUTES,
+ DUR_HOURS,
+ DUR_DAYS
+};
+
+static const int duration_units_map[] = {
+ DUR_MINUTES,
+ DUR_HOURS,
+ DUR_DAYS,
+ -1
+};
+
+/* Sigh. Takes an overcomplicated duration value and reduces it to its lowest
+ * common denominator.
+ */
+static void
+normalize_duration (struct icaldurationtype dur, int *value, enum duration_units *units)
+{
+ if (dur.seconds != 0 || dur.minutes != 0) {
+ *value = ((((dur.weeks * 7 + dur.days) * 24 + dur.hours) * 60) + dur.minutes
+ + dur.seconds / 60 + ((dur.seconds % 60) >= 30 ? 1 : 0));
+ *units = DUR_MINUTES;
+ } else if (dur.hours) {
+ *value = ((dur.weeks * 7) + dur.days) * 24 + dur.hours;
+ *units = DUR_HOURS;
+ } else if (dur.days != 0 || dur.weeks != 0) {
+ *value = dur.weeks * 7 + dur.days;
+ *units = DUR_DAYS;
+ } else {
+ *value = 0;
+ *units = DUR_MINUTES;
+ }
+}
+
+/* Fills the repeat widgets with the values from the alarm component */
+static void
+alarm_to_repeat_widgets (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ CalAlarmRepeat repeat;
+ int value;
+ enum duration_units units;
+
+ cal_component_alarm_get_repeat (alarm, &repeat);
+
+ /* Sensitivity */
+
+ if (repeat.repetitions == 0) {
+ gtk_widget_set_sensitive (dialog->repeat_group, FALSE);
+ e_dialog_toggle_set (dialog->repeat_toggle, FALSE);
+ return;
+ }
+
+ gtk_widget_set_sensitive (dialog->repeat_group, TRUE);
+ e_dialog_toggle_set (dialog->repeat_toggle, TRUE);
+
+ /* Repetitions */
+ e_dialog_spin_set (dialog->repeat_quantity, repeat.repetitions);
+
+ /* Duration */
+
+ normalize_duration (repeat.duration, &value, &units);
+
+ e_dialog_spin_set (dialog->repeat_value, value);
+ e_dialog_option_menu_set (dialog->repeat_unit, units, duration_units_map);
+}
+
+/* Fills the widgets with the values from the alarm component */
+static void
+alarm_to_dialog (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ CalAlarmAction action;
+
+ alarm_to_repeat_widgets (dialog, alarm);
+
+ cal_component_alarm_get_action (alarm, &action);
+
+ switch (action) {
+ case CAL_ALARM_NONE:
+ g_assert_not_reached ();
+ return;
+
+ case CAL_ALARM_AUDIO:
+ gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Audio Alarm Options"));
+ gtk_widget_show (dialog->aalarm_group);
+ gtk_widget_hide (dialog->dalarm_group);
+ gtk_widget_hide (dialog->malarm_group);
+ gtk_widget_hide (dialog->palarm_group);
+ alarm_to_aalarm_widgets (dialog, alarm);
+ break;
+
+ case CAL_ALARM_DISPLAY:
+ gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Message Alarm Options"));
+ gtk_widget_hide (dialog->aalarm_group);
+ gtk_widget_show (dialog->dalarm_group);
+ gtk_widget_hide (dialog->malarm_group);
+ gtk_widget_hide (dialog->palarm_group);
+ alarm_to_dalarm_widgets (dialog, alarm);
+ break;
+
+ case CAL_ALARM_EMAIL:
+ gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Mail Alarm Options"));
+ gtk_widget_hide (dialog->aalarm_group);
+ gtk_widget_hide (dialog->dalarm_group);
+ gtk_widget_show (dialog->malarm_group);
+ gtk_widget_hide (dialog->palarm_group);
+ alarm_to_malarm_widgets (dialog, alarm);
+ break;
+
+ case CAL_ALARM_PROCEDURE:
+ gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Program Alarm Options"));
+ gtk_widget_hide (dialog->aalarm_group);
+ gtk_widget_hide (dialog->dalarm_group);
+ gtk_widget_hide (dialog->malarm_group);
+ gtk_widget_show (dialog->palarm_group);
+ alarm_to_palarm_widgets (dialog, alarm);
+ break;
+
+ case CAL_ALARM_UNKNOWN:
+ gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Unknown Alarm Options"));
+ break;
+
+ default:
+ g_assert_not_reached ();
+ return;
+ }
+}
+
+
+
+/* Fills the alarm data with the values from the repeat/duration widgets */
+static void
+repeat_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ CalAlarmRepeat repeat;
+
+ if (!e_dialog_toggle_get (dialog->repeat_toggle)) {
+ repeat.repetitions = 0;
+
+ cal_component_alarm_set_repeat (alarm, repeat);
+ return;
+ }
+
+ repeat.repetitions = e_dialog_spin_get_int (dialog->repeat_quantity);
+
+ memset (&repeat.duration, 0, sizeof (repeat.duration));
+ switch (e_dialog_option_menu_get (dialog->repeat_unit, duration_units_map)) {
+ case DUR_MINUTES:
+ repeat.duration.minutes = e_dialog_spin_get_int (dialog->repeat_value);
+ break;
+
+ case DUR_HOURS:
+ repeat.duration.hours = e_dialog_spin_get_int (dialog->repeat_value);
+ break;
+
+ case DUR_DAYS:
+ repeat.duration.days = e_dialog_spin_get_int (dialog->repeat_value);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ cal_component_alarm_set_repeat (alarm, repeat);
+
+}
+
+/* Fills the audio alarm data with the values from the widgets */
+static void
+aalarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ char *url;
+ struct icalattachtype *attach;
+
+ attach = icalattachtype_new ();
+
+ url = e_dialog_editable_get (dialog->aalarm_attach);
+ icalattachtype_set_url (attach, url ? url : "");
+ g_free (url);
+
+ cal_component_alarm_set_attach (alarm, attach);
+ icalattachtype_free (attach);
+}
+
+/* Fills the display alarm data with the values from the widgets */
+static void
+dalarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ char *str;
+ CalComponentText description;
+
+ str = e_dialog_editable_get (dialog->dalarm_description);
+ description.value = str;
+ description.altrep = NULL;
+
+ cal_component_alarm_set_description (alarm, &description);
+ g_free (str);
+}
+
+/* Fills the mail alarm data with the values from the widgets */
+static void
+malarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ /* FIXME: nothing for now; we don't support mail alarms */
+}
+
+/* Fills the procedure alarm data with the values from the widgets */
+static void
+palarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ char *program;
+ struct icalattachtype *attach;
+ char *str;
+ CalComponentText description;
+
+ attach = icalattachtype_new ();
+
+ program = e_dialog_editable_get (dialog->palarm_program);
+ icalattachtype_set_url (attach, program ? program : "");
+ g_free (program);
+
+ cal_component_alarm_set_attach (alarm, attach);
+ icalattachtype_free (attach);
+
+ str = e_dialog_editable_get (dialog->palarm_args);
+ description.value = str;
+ description.altrep = NULL;
+
+ cal_component_alarm_set_description (alarm, &description);
+ g_free (str);
+}
+
+/* Fills the alarm data with the values from the widgets */
+static void
+dialog_to_alarm (Dialog *dialog, CalComponentAlarm *alarm)
+{
+ CalAlarmAction action;
+
+ repeat_widgets_to_alarm (dialog, alarm);
+
+ cal_component_alarm_get_action (alarm, &action);
+
+ switch (action) {
+ case CAL_ALARM_NONE:
+ g_assert_not_reached ();
+ break;
+
+ case CAL_ALARM_AUDIO:
+ aalarm_widgets_to_alarm (dialog, alarm);
+ break;
+
+ case CAL_ALARM_DISPLAY:
+ dalarm_widgets_to_alarm (dialog, alarm);
+ break;
+
+ case CAL_ALARM_EMAIL:
+ malarm_widgets_to_alarm (dialog, alarm);
+ break;
+
+ case CAL_ALARM_PROCEDURE:
+ palarm_widgets_to_alarm (dialog, alarm);
+ break;
+
+ case CAL_ALARM_UNKNOWN:
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+
+
+gboolean
+alarm_options_dialog_run (CalComponentAlarm *alarm)
+{
+ Dialog dialog;
+
+ g_return_val_if_fail (alarm != NULL, FALSE);
+
+ dialog.xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-options.glade", NULL);
+ if (!dialog.xml) {
+ g_message ("alarm_options_dialog_new(): Could not load the Glade XML file!");
+ return FALSE;
+ }
+
+ if (!get_widgets (&dialog)) {
+ gtk_object_unref (GTK_OBJECT (dialog.xml));
+ return FALSE;
+ }
+
+ init_widgets (&dialog);
+
+ alarm_to_dialog (&dialog, alarm);
+
+ gtk_widget_show (dialog.toplevel);
+ gtk_main ();
+
+ if (!dialog.canceled)
+ dialog_to_alarm (&dialog, alarm);
+
+ gtk_widget_destroy (dialog.toplevel);
+ gtk_object_unref (GTK_OBJECT (dialog.xml));
+
+ return TRUE;
+}
diff --git a/calendar/gui/dialogs/alarm-options.glade b/calendar/gui/dialogs/alarm-options.glade
new file mode 100644
index 0000000000..ad0c181561
--- /dev/null
+++ b/calendar/gui/dialogs/alarm-options.glade
@@ -0,0 +1,398 @@
+<?xml version="1.0"?>
+<GTK-Interface>
+
+<project>
+ <name>Dialogs</name>
+ <program_name>dialogs</program_name>
+ <directory></directory>
+ <source_directory>src</source_directory>
+ <pixmaps_directory>pixmaps</pixmaps_directory>
+ <language>C</language>
+ <gnome_support>True</gnome_support>
+ <gettext_support>True</gettext_support>
+</project>
+
+<widget>
+ <class>GtkWindow</class>
+ <name>alarm-options-toplevel</name>
+ <title></title>
+ <type>GTK_WINDOW_DIALOG</type>
+ <position>GTK_WIN_POS_NONE</position>
+ <modal>True</modal>
+ <allow_shrink>False</allow_shrink>
+ <allow_grow>True</allow_grow>
+ <auto_shrink>True</auto_shrink>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox1</name>
+ <border_width>4</border_width>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+
+ <widget>
+ <class>GtkFrame</class>
+ <name>frame1</name>
+ <label>Alarm Repeat</label>
+ <label_xalign>0</label_xalign>
+ <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox1</name>
+ <border_width>4</border_width>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+
+ <widget>
+ <class>GtkCheckButton</class>
+ <name>repeat-toggle</name>
+ <can_focus>True</can_focus>
+ <has_focus>True</has_focus>
+ <label>Repeat the alarm</label>
+ <active>False</active>
+ <draw_indicator>True</draw_indicator>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>repeat-group</name>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkSpinButton</class>
+ <name>repeat-quantity</name>
+ <can_focus>True</can_focus>
+ <climb_rate>1</climb_rate>
+ <digits>0</digits>
+ <numeric>False</numeric>
+ <update_policy>GTK_UPDATE_ALWAYS</update_policy>
+ <snap>False</snap>
+ <wrap>False</wrap>
+ <value>1</value>
+ <lower>0</lower>
+ <upper>999</upper>
+ <step>1</step>
+ <page>10</page>
+ <page_size>10</page_size>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label1</name>
+ <label>extra times every</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkSpinButton</class>
+ <name>repeat-value</name>
+ <can_focus>True</can_focus>
+ <climb_rate>1</climb_rate>
+ <digits>0</digits>
+ <numeric>False</numeric>
+ <update_policy>GTK_UPDATE_ALWAYS</update_policy>
+ <snap>False</snap>
+ <wrap>False</wrap>
+ <value>1</value>
+ <lower>0</lower>
+ <upper>999</upper>
+ <step>1</step>
+ <page>10</page>
+ <page_size>10</page_size>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkOptionMenu</class>
+ <name>repeat-unit</name>
+ <can_focus>True</can_focus>
+ <items>minutes
+hours
+days
+</items>
+ <initial_choice>0</initial_choice>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+ </widget>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>dalarm-group</name>
+ <visible>False</visible>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label2</name>
+ <label>Message to Display</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkScrolledWindow</class>
+ <name>scrolledwindow1</name>
+ <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
+ <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
+ <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
+ <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkText</class>
+ <name>dalarm-description</name>
+ <can_focus>True</can_focus>
+ <editable>True</editable>
+ <text></text>
+ </widget>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>aalarm-group</name>
+ <visible>False</visible>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label3</name>
+ <label>Play sound:</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GnomeFileEntry</class>
+ <name>file-entry1</name>
+ <max_saved>10</max_saved>
+ <directory>False</directory>
+ <modal>False</modal>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkEntry</class>
+ <child_name>GnomeEntry:entry</child_name>
+ <name>aalarm-attach</name>
+ <can_focus>True</can_focus>
+ <editable>True</editable>
+ <text_visible>True</text_visible>
+ <text_max_length>0</text_max_length>
+ <text></text>
+ </widget>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>malarm-group</name>
+ <visible>False</visible>
+ <label>FIXME: mail alarm options</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>palarm-group</name>
+ <visible>False</visible>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label5</name>
+ <label>Run program:</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkEntry</class>
+ <name>palarm-program</name>
+ <can_focus>True</can_focus>
+ <editable>True</editable>
+ <text_visible>True</text_visible>
+ <text_max_length>0</text_max_length>
+ <text></text>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label6</name>
+ <label>With these arguments:</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkEntry</class>
+ <name>palarm-args</name>
+ <can_focus>True</can_focus>
+ <editable>True</editable>
+ <text_visible>True</text_visible>
+ <text_max_length>0</text_max_length>
+ <text></text>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkHButtonBox</class>
+ <name>hbuttonbox1</name>
+ <layout_style>GTK_BUTTONBOX_END</layout_style>
+ <spacing>30</spacing>
+ <child_min_width>85</child_min_width>
+ <child_min_height>27</child_min_height>
+ <child_ipad_x>7</child_ipad_x>
+ <child_ipad_y>0</child_ipad_y>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button-ok</name>
+ <can_default>True</can_default>
+ <has_default>True</has_default>
+ <can_focus>True</can_focus>
+ <stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button-cancel</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ </widget>
+ </widget>
+ </widget>
+</widget>
+
+</GTK-Interface>
diff --git a/calendar/gui/dialogs/alarm-options.h b/calendar/gui/dialogs/alarm-options.h
new file mode 100644
index 0000000000..36f945f684
--- /dev/null
+++ b/calendar/gui/dialogs/alarm-options.h
@@ -0,0 +1,29 @@
+/* Evolution calendar - Alarm options dialog
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * Authors: Federico Mena-Quintero <federico@ximian.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef ALARM_OPTIONS_H
+#define ALARM_OPTIONS_H
+
+#include <cal-util/cal-component.h>
+
+gboolean alarm_options_dialog_run (CalComponentAlarm *alarm);
+
+#endif
diff --git a/calendar/gui/dialogs/alarm-page.c b/calendar/gui/dialogs/alarm-page.c
index 9a92b5c9a2..3946c15310 100644
--- a/calendar/gui/dialogs/alarm-page.c
+++ b/calendar/gui/dialogs/alarm-page.c
@@ -35,6 +35,7 @@
#include "e-util/e-dialog-widgets.h"
#include "cal-util/cal-util.h"
#include "comp-editor-util.h"
+#include "alarm-options.h"
#include "alarm-page.h"
@@ -61,6 +62,11 @@ struct _AlarmPagePrivate {
GtkWidget *relative;
GtkWidget *time;
+ GtkWidget *button_options;
+
+ /* Alarm options dialog and the alarm we maintain */
+ CalComponentAlarm *alarm;
+
gboolean updating;
};
@@ -155,6 +161,9 @@ alarm_page_init (AlarmPage *apage)
priv->value_units = NULL;
priv->relative = NULL;
priv->time = NULL;
+ priv->button_options = NULL;
+
+ priv->alarm = cal_component_alarm_new ();
priv->updating = FALSE;
}
@@ -205,6 +214,11 @@ alarm_page_destroy (GtkObject *object)
free_alarms (apage);
+ if (priv->alarm) {
+ cal_component_alarm_free (priv->alarm);
+ priv->alarm = NULL;
+ }
+
g_free (priv);
apage->priv = NULL;
@@ -581,6 +595,8 @@ get_widgets (AlarmPage *apage)
priv->relative = GW ("relative");
priv->time = GW ("time");
+ priv->button_options = GW ("button-options");
+
#undef GW
return (priv->summary
@@ -592,7 +608,8 @@ get_widgets (AlarmPage *apage)
&& priv->interval_value
&& priv->value_units
&& priv->relative
- && priv->time);
+ && priv->time
+ && priv->button_options);
}
/* This is called when any field is changed; it notifies upstream. */
@@ -621,7 +638,7 @@ add_clicked_cb (GtkButton *button, gpointer data)
apage = ALARM_PAGE (data);
priv = apage->priv;
- alarm = cal_component_alarm_new ();
+ alarm = cal_component_alarm_clone (priv->alarm);
memset (&trigger, 0, sizeof (CalAlarmTrigger));
trigger.type = e_dialog_option_menu_get (priv->time, time_map);
@@ -690,6 +707,23 @@ delete_clicked_cb (GtkButton *button, gpointer data)
gtk_widget_set_sensitive (priv->delete, FALSE);
}
+/* Callback used when the alarm options button is clicked */
+static void
+button_options_clicked_cb (GtkWidget *widget, gpointer data)
+{
+ AlarmPage *apage;
+ AlarmPagePrivate *priv;
+
+ apage = ALARM_PAGE (data);
+ priv = apage->priv;
+
+ cal_component_alarm_set_action (priv->alarm,
+ e_dialog_option_menu_get (priv->action, action_map));
+
+ if (!alarm_options_dialog_run (priv->alarm))
+ g_message ("button_options_clicked_cb(): Could not create the alarm options dialog");
+}
+
/* Hooks the widget signals */
static void
init_widgets (AlarmPage *apage)
@@ -711,6 +745,10 @@ init_widgets (AlarmPage *apage)
GTK_SIGNAL_FUNC (field_changed_cb), apage);
gtk_signal_connect (GTK_OBJECT (priv->delete), "clicked",
GTK_SIGNAL_FUNC (field_changed_cb), apage);
+
+ /* Options button */
+ gtk_signal_connect (GTK_OBJECT (priv->button_options), "clicked",
+ GTK_SIGNAL_FUNC (button_options_clicked_cb), apage);
}
diff --git a/calendar/gui/dialogs/alarm-page.glade b/calendar/gui/dialogs/alarm-page.glade
index 80db7edc76..0e4009009a 100644
--- a/calendar/gui/dialogs/alarm-page.glade
+++ b/calendar/gui/dialogs/alarm-page.glade
@@ -280,9 +280,10 @@ end of appointment
<widget>
<class>GtkButton</class>
- <name>button9</name>
+ <name>button-options</name>
<can_focus>True</can_focus>
- <label>Settings...</label>
+ <label>Options...</label>
+ <relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
@@ -361,6 +362,7 @@ end of appointment
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>Add</label>
+ <relief>GTK_RELIEF_NORMAL</relief>
</widget>
<widget>
@@ -369,6 +371,7 @@ end of appointment
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>Delete</label>
+ <relief>GTK_RELIEF_NORMAL</relief>
</widget>
</widget>
</widget>