aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-05-16 15:33:43 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-05-16 15:33:43 +0800
commit795956eec8940a25967b9f6bb5e3fa2f76953864 (patch)
treefd99c008e959758086b61dbf354432bfd46ae9e1 /calendar/gui/dialogs
parent6ab0ef86e224cc542eaa2b53defeb9ea01d61da8 (diff)
downloadgsoc2013-evolution-795956eec8940a25967b9f6bb5e3fa2f76953864.tar
gsoc2013-evolution-795956eec8940a25967b9f6bb5e3fa2f76953864.tar.gz
gsoc2013-evolution-795956eec8940a25967b9f6bb5e3fa2f76953864.tar.bz2
gsoc2013-evolution-795956eec8940a25967b9f6bb5e3fa2f76953864.tar.lz
gsoc2013-evolution-795956eec8940a25967b9f6bb5e3fa2f76953864.tar.xz
gsoc2013-evolution-795956eec8940a25967b9f6bb5e3fa2f76953864.tar.zst
gsoc2013-evolution-795956eec8940a25967b9f6bb5e3fa2f76953864.zip
Alarm stuff I had not cvs added, sigh - Federico
2000-05-14 Federico Mena Quintero <federico@helixcode.com> * gui/gnome-cal.c (display_notification): Use the alarm notification dialog. (display_notification_cb): New callback for the result of the alarm notification dialog. * gui/dialogs/alarm-notify.glade: New file with the alarm notification dialog. * gui/dialogs/alarm-notify-dialog.[ch]: New file. * gui/dialogs/Makefile.am: New file. * gui/Makefile.am (SUBDIRS): Added the dialogs directory. 2000-05-13 Federico Mena Quintero <federico@helixcode.com> * gui/gnome-cal.c (trigger_alarm_cb): Better error checking, and plug leaks of str_ico and ico. * gui/evolution-calendar-control.c (main): Initialize libglade. svn path=/trunk/; revision=3072
Diffstat (limited to 'calendar/gui/dialogs')
-rw-r--r--calendar/gui/dialogs/Makefile.am27
-rw-r--r--calendar/gui/dialogs/alarm-notify-dialog.c218
-rw-r--r--calendar/gui/dialogs/alarm-notify-dialog.h44
-rw-r--r--calendar/gui/dialogs/alarm-notify.glade230
-rw-r--r--calendar/gui/dialogs/alarm-notify.glade.h10
5 files changed, 529 insertions, 0 deletions
diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am
new file mode 100644
index 0000000000..8dfccc5650
--- /dev/null
+++ b/calendar/gui/dialogs/Makefile.am
@@ -0,0 +1,27 @@
+INCLUDES = \
+ -DG_LOG_DOMAIN=\"calendar-gui\" \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/calendar \
+ -I$(top_srcdir)/libical/src/libical \
+ -I$(includedir) \
+ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
+ $(BONOBO_VFS_GNOME_CFLAGS) \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
+
+noinst_LIBRARIES = libcal-dialogs.a
+
+libcal_dialogs_a_SOURCES = \
+ alarm-notify-dialog.c \
+ alarm-notify-dialog.h
+
+gladedir = $(datadir)/evolution/glade
+
+glade_DATA = \
+ alarm-notify.glade
+
+glade_messages = \
+ alarm-notify.glade.h
+
+EXTRA_DIST = \
+ $(glade_DATA) \
+ $(glade_messages)
diff --git a/calendar/gui/dialogs/alarm-notify-dialog.c b/calendar/gui/dialogs/alarm-notify-dialog.c
new file mode 100644
index 0000000000..931ab0bfac
--- /dev/null
+++ b/calendar/gui/dialogs/alarm-notify-dialog.c
@@ -0,0 +1,218 @@
+/* Evolution calendar - alarm notification dialog
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * Author: Federico Mena-Quintero <federico@helixcode.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.
+ */
+
+#include <config.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtkspinbutton.h>
+#include <gtk/gtkwindow.h>
+#include <glade/glade.h>
+#include "alarm-notify-dialog.h"
+
+
+
+/* The useful contents of the alarm notify dialog */
+typedef struct {
+ GladeXML *xml;
+
+ GtkWidget *dialog;
+ GtkWidget *close;
+ GtkWidget *snooze;
+ GtkWidget *edit;
+ GtkWidget *heading;
+ GtkWidget *summary;
+ GtkWidget *snooze_time;
+
+ AlarmNotifyFunc func;
+ gpointer func_data;
+} AlarmNotify;
+
+
+
+/* Callback used when the notify dialog is destroyed */
+static void
+dialog_destroy_cb (GtkObject *object, gpointer data)
+{
+ AlarmNotify *an;
+
+ an = data;
+ gtk_object_unref (GTK_OBJECT (an->xml));
+ g_free (an);
+}
+
+/* Delete_event handler for the alarm notify dialog */
+static gint
+delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ AlarmNotify *an;
+
+ an = data;
+ g_assert (an->func != NULL);
+
+ (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data);
+
+ gtk_widget_destroy (widget);
+ return TRUE;
+}
+
+/* Callback for the close button */
+static void
+close_clicked_cb (GtkWidget *widget, gpointer data)
+{
+ AlarmNotify *an;
+
+ an = data;
+ g_assert (an->func != NULL);
+
+ (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data);
+
+ gtk_widget_destroy (an->dialog);
+}
+
+/* Callback for the snooze button */
+static void
+snooze_clicked_cb (GtkWidget *widget, gpointer data)
+{
+ AlarmNotify *an;
+ int snooze_time;
+
+ an = data;
+ g_assert (an->func != NULL);
+
+ snooze_time = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time));
+ (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_time, an->func_data);
+
+ gtk_widget_destroy (an->dialog);
+}
+
+/* Callback for the edit button */
+static void
+edit_clicked_cb (GtkWidget *widget, gpointer data)
+{
+ AlarmNotify *an;
+
+ an = data;
+ g_assert (an->func != NULL);
+
+ (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data);
+
+ gtk_widget_destroy (an->dialog);
+}
+
+/**
+ * alarm_notify_dialog:
+ * @func: Function to be called when a dialog action is invoked.
+ * @data: Closure data for @func.
+ *
+ * Runs the alarm notification dialog. The specified @func will be used to
+ * notify the client about result of the actions in the dialog.
+ *
+ * Return value: TRUE on success, FALSE if the dialog could not be created.
+ **/
+gboolean
+alarm_notify_dialog (time_t trigger, time_t occur, iCalObject *ico,
+ AlarmNotifyFunc func, gpointer func_data)
+{
+ AlarmNotify *an;
+ char buf[256];
+ struct tm tm_trigger;
+ struct tm tm_occur;
+
+ g_return_val_if_fail (trigger != -1, FALSE);
+ g_return_val_if_fail (occur != -1, FALSE);
+ g_return_val_if_fail (ico != NULL, FALSE);
+ g_return_val_if_fail (func != NULL, FALSE);
+
+ an = g_new0 (AlarmNotify, 1);
+
+ an->func = func;
+ an->func_data = func_data;
+
+ an->xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-notify.glade", NULL);
+ if (!an->xml) {
+ g_message ("alarm_notify_dialog(): Could not load the Glade XML file!");
+ g_free (an);
+ return FALSE;
+ }
+
+ an->dialog = glade_xml_get_widget (an->xml, "alarm-notify");
+ an->close = glade_xml_get_widget (an->xml, "close");
+ an->snooze = glade_xml_get_widget (an->xml, "snooze");
+ an->edit = glade_xml_get_widget (an->xml, "edit");
+ an->heading = glade_xml_get_widget (an->xml, "heading");
+ an->summary = glade_xml_get_widget (an->xml, "summary");
+ an->snooze_time = glade_xml_get_widget (an->xml, "snooze-time");
+
+ if (!(an->dialog && an->close && an->snooze && an->edit && an->heading && an->summary
+ && an->snooze_time)) {
+ g_message ("alarm_notify_dialog(): Could not find all widgets in Glade file!");
+ gtk_object_unref (GTK_OBJECT (an->xml));
+ g_free (an);
+ return FALSE;
+ }
+
+ gtk_object_set_data (GTK_OBJECT (an->dialog), "alarm-notify", an);
+ gtk_signal_connect (GTK_OBJECT (an->dialog), "destroy",
+ GTK_SIGNAL_FUNC (dialog_destroy_cb), an);
+
+ /* Title */
+
+ /* FIXME: use am_pm_flag or 24-hour time */
+
+ tm_trigger = *localtime (&trigger);
+ strftime (buf, sizeof (buf), _("Alarm on %A %b %d %Y %H:%M"), &tm_trigger);
+ gtk_window_set_title (GTK_WINDOW (an->dialog), buf);
+
+ /* Heading */
+
+ tm_occur = *localtime (&occur);
+ strftime (buf, sizeof (buf),
+ _("Notification about your appointment on %A %b %d %Y %H:%M"),
+ &tm_occur);
+ gtk_label_set_text (GTK_LABEL (an->heading), buf);
+
+ /* Summary */
+
+ gtk_label_set_text (GTK_LABEL (an->summary), ico->summary);
+
+ /* Connect actions */
+
+ gtk_signal_connect (GTK_OBJECT (an->dialog), "delete_event",
+ GTK_SIGNAL_FUNC (delete_event_cb),
+ an);
+
+ gtk_signal_connect (GTK_OBJECT (an->close), "clicked",
+ GTK_SIGNAL_FUNC (close_clicked_cb),
+ an);
+
+ gtk_signal_connect (GTK_OBJECT (an->snooze), "clicked",
+ GTK_SIGNAL_FUNC (snooze_clicked_cb),
+ an);
+
+ gtk_signal_connect (GTK_OBJECT (an->edit), "clicked",
+ GTK_SIGNAL_FUNC (edit_clicked_cb),
+ an);
+
+ /* Run! */
+
+ gtk_widget_show (an->dialog);
+ return TRUE;
+}
diff --git a/calendar/gui/dialogs/alarm-notify-dialog.h b/calendar/gui/dialogs/alarm-notify-dialog.h
new file mode 100644
index 0000000000..770768f59c
--- /dev/null
+++ b/calendar/gui/dialogs/alarm-notify-dialog.h
@@ -0,0 +1,44 @@
+/* Evolution calendar - alarm notification dialog
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * Author: Federico Mena-Quintero <federico@helixcode.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_NOTIFY_DIALOG_H
+#define ALARM_NOTIFY_DIALOG_H
+
+#include <time.h>
+#include <glib.h>
+#include <cal-util/calobj.h>
+
+
+
+typedef enum {
+ ALARM_NOTIFY_CLOSE,
+ ALARM_NOTIFY_SNOOZE,
+ ALARM_NOTIFY_EDIT
+} AlarmNotifyResult;
+
+typedef void (* AlarmNotifyFunc) (AlarmNotifyResult result, int snooze_mins, gpointer data);
+
+gboolean alarm_notify_dialog (time_t trigger, time_t occur, iCalObject *ico,
+ AlarmNotifyFunc func, gpointer func_data);
+
+
+
+#endif
diff --git a/calendar/gui/dialogs/alarm-notify.glade b/calendar/gui/dialogs/alarm-notify.glade
new file mode 100644
index 0000000000..32d7e03f8b
--- /dev/null
+++ b/calendar/gui/dialogs/alarm-notify.glade
@@ -0,0 +1,230 @@
+<?xml version="1.0"?>
+<GTK-Interface>
+
+<project>
+ <name>Evolution Calendar</name>
+ <program_name>evolution-calendar</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>
+ <use_widget_names>False</use_widget_names>
+ <output_main_file>True</output_main_file>
+ <output_support_files>True</output_support_files>
+ <output_build_files>True</output_build_files>
+ <backup_source_files>True</backup_source_files>
+ <main_source_file>interface.c</main_source_file>
+ <main_header_file>interface.h</main_header_file>
+ <handler_source_file>callbacks.c</handler_source_file>
+ <handler_header_file>callbacks.h</handler_header_file>
+ <support_source_file>support.c</support_source_file>
+ <support_header_file>support.h</support_header_file>
+ <output_translatable_strings>True</output_translatable_strings>
+ <translatable_strings_file>alarm-notify.glade.h</translatable_strings_file>
+</project>
+
+<widget>
+ <class>GtkWindow</class>
+ <name>alarm-notify</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <title></title>
+ <type>GTK_WINDOW_DIALOG</type>
+ <position>GTK_WIN_POS_CENTER</position>
+ <modal>False</modal>
+ <allow_shrink>False</allow_shrink>
+ <allow_grow>False</allow_grow>
+ <auto_shrink>False</auto_shrink>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox2</name>
+ <border_width>4</border_width>
+ <cxx_use_heap>True</cxx_use_heap>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox3</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <homogeneous>False</homogeneous>
+ <spacing>8</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox5</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>heading</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <label></label>
+ <justify>GTK_JUSTIFY_LEFT</justify>
+ <wrap>True</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>GtkLabel</class>
+ <name>summary</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <label></label>
+ <justify>GTK_JUSTIFY_LEFT</justify>
+ <wrap>True</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>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox4</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>close</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <can_focus>True</can_focus>
+ <label>Close</label>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>snooze</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <can_focus>True</can_focus>
+ <label>Snooze</label>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>edit</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <can_focus>True</can_focus>
+ <label>Edit appointment</label>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkHSeparator</class>
+ <name>hseparator1</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox4</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <homogeneous>False</homogeneous>
+ <spacing>4</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label4</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <label>Snooze time (minutes)</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>GtkSpinButton</class>
+ <name>snooze-time</name>
+ <cxx_use_heap>True</cxx_use_heap>
+ <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>5</value>
+ <lower>1</lower>
+ <upper>1440</upper>
+ <step>1</step>
+ <page>5</page>
+ <page_size>5</page_size>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+ </widget>
+ </widget>
+</widget>
+
+</GTK-Interface>
diff --git a/calendar/gui/dialogs/alarm-notify.glade.h b/calendar/gui/dialogs/alarm-notify.glade.h
new file mode 100644
index 0000000000..c7b8918e06
--- /dev/null
+++ b/calendar/gui/dialogs/alarm-notify.glade.h
@@ -0,0 +1,10 @@
+/*
+ * Translatable strings file generated by Glade.
+ * Add this file to your project's POTFILES.in.
+ * DO NOT compile it as part of your application.
+ */
+
+gchar *s = N_("Close");
+gchar *s = N_("Snooze");
+gchar *s = N_("Edit appointment");
+gchar *s = N_("Snooze time (minutes)");