From 88afa58a5b1f01cbefd89795c4dab371fb31f9c3 Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 19 May 2001 12:49:14 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'GAL_0_8'. svn path=/tags/GAL_0_8/; revision=9892 --- calendar/gui/dialogs/.cvsignore | 3 - calendar/gui/dialogs/Makefile.am | 49 - calendar/gui/dialogs/alarm-notify-dialog.c | 231 ----- calendar/gui/dialogs/alarm-notify-dialog.h | 45 - calendar/gui/dialogs/alarm-notify.glade | 228 ----- calendar/gui/dialogs/alarm-page.c | 778 --------------- calendar/gui/dialogs/alarm-page.glade | 381 -------- calendar/gui/dialogs/alarm-page.h | 64 -- calendar/gui/dialogs/cal-prefs-dialog.c | 456 --------- calendar/gui/dialogs/cal-prefs-dialog.glade | 1241 ------------------------ calendar/gui/dialogs/cal-prefs-dialog.h | 70 -- calendar/gui/dialogs/delete-comp.c | 148 --- calendar/gui/dialogs/delete-comp.h | 32 - calendar/gui/dialogs/editor-page.c | 259 ----- calendar/gui/dialogs/editor-page.h | 86 -- calendar/gui/dialogs/event-page.c | 908 ----------------- calendar/gui/dialogs/event-page.glade | 429 -------- calendar/gui/dialogs/event-page.h | 70 -- calendar/gui/dialogs/recurrence-page.c | 900 ----------------- calendar/gui/dialogs/recurrence-page.glade | 607 ------------ calendar/gui/dialogs/recurrence-page.h | 64 -- calendar/gui/dialogs/save-comp.c | 63 -- calendar/gui/dialogs/save-comp.h | 30 - calendar/gui/dialogs/task-details-page.glade | 137 --- calendar/gui/dialogs/task-editor-dialog.glade | 695 ------------- calendar/gui/dialogs/task-editor.c | 1294 ------------------------- calendar/gui/dialogs/task-editor.h | 70 -- calendar/gui/dialogs/task-page.glade | 547 ----------- 28 files changed, 9885 deletions(-) delete mode 100644 calendar/gui/dialogs/.cvsignore delete mode 100644 calendar/gui/dialogs/Makefile.am delete mode 100644 calendar/gui/dialogs/alarm-notify-dialog.c delete mode 100644 calendar/gui/dialogs/alarm-notify-dialog.h delete mode 100644 calendar/gui/dialogs/alarm-notify.glade delete mode 100644 calendar/gui/dialogs/alarm-page.c delete mode 100644 calendar/gui/dialogs/alarm-page.glade delete mode 100644 calendar/gui/dialogs/alarm-page.h delete mode 100644 calendar/gui/dialogs/cal-prefs-dialog.c delete mode 100644 calendar/gui/dialogs/cal-prefs-dialog.glade delete mode 100644 calendar/gui/dialogs/cal-prefs-dialog.h delete mode 100644 calendar/gui/dialogs/delete-comp.c delete mode 100644 calendar/gui/dialogs/delete-comp.h delete mode 100644 calendar/gui/dialogs/editor-page.c delete mode 100644 calendar/gui/dialogs/editor-page.h delete mode 100644 calendar/gui/dialogs/event-page.c delete mode 100644 calendar/gui/dialogs/event-page.glade delete mode 100644 calendar/gui/dialogs/event-page.h delete mode 100644 calendar/gui/dialogs/recurrence-page.c delete mode 100644 calendar/gui/dialogs/recurrence-page.glade delete mode 100644 calendar/gui/dialogs/recurrence-page.h delete mode 100644 calendar/gui/dialogs/save-comp.c delete mode 100644 calendar/gui/dialogs/save-comp.h delete mode 100644 calendar/gui/dialogs/task-details-page.glade delete mode 100644 calendar/gui/dialogs/task-editor-dialog.glade delete mode 100644 calendar/gui/dialogs/task-editor.c delete mode 100644 calendar/gui/dialogs/task-editor.h delete mode 100644 calendar/gui/dialogs/task-page.glade (limited to 'calendar/gui/dialogs') diff --git a/calendar/gui/dialogs/.cvsignore b/calendar/gui/dialogs/.cvsignore deleted file mode 100644 index e995588475..0000000000 --- a/calendar/gui/dialogs/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -.deps -Makefile -Makefile.in diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am deleted file mode 100644 index ec4e31379d..0000000000 --- a/calendar/gui/dialogs/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -gladedir = $(datadir)/evolution/glade - -INCLUDES = \ - -DG_LOG_DOMAIN=\"calendar-gui\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_srcdir)/calendar/cal-client \ - -I$(top_builddir)/calendar/cal-client \ - -I$(top_srcdir)/libical/src/libical \ - -I$(top_builddir)/libical/src/libical \ - -I$(includedir) \ - $(EXTRA_GNOME_CFLAGS) \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - $(BONOBO_VFS_GNOME_CFLAGS) \ - -DGNOMELOCALEDIR=\""$(localedir)"\" - -noinst_LIBRARIES = libcal-dialogs.a - -libcal_dialogs_a_SOURCES = \ - alarm-notify-dialog.c \ - alarm-notify-dialog.h \ - alarm-page.c \ - alarm-page.h \ - cal-prefs-dialog.c \ - cal-prefs-dialog.h \ - delete-comp.c \ - delete-comp.h \ - editor-page.c \ - editor-page.h \ - event-page.c \ - event-page.h \ - save-comp.c \ - save-comp.h \ - task-editor.c \ - task-editor.h - -glade_DATA = \ - alarm-notify.glade \ - alarm-page.glade \ - cal-prefs-dialog.glade \ - event-page.glade \ - recurrence-page.glade \ - task-details-page.glade \ - task-editor-dialog.glade \ - task-page.glade - -EXTRA_DIST = \ - $(glade_DATA) diff --git a/calendar/gui/dialogs/alarm-notify-dialog.c b/calendar/gui/dialogs/alarm-notify-dialog.c deleted file mode 100644 index 164d043e13..0000000000 --- a/calendar/gui/dialogs/alarm-notify-dialog.c +++ /dev/null @@ -1,231 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#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: - * @trigger: Trigger time for the alarm. - * @occur: Occurrence time for the event. - * @comp: Calendar component object which corresponds to the alarm. - * @func: Function to be called when a dialog action is invoked. - * @func_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, CalComponent *comp, - AlarmNotifyFunc func, gpointer func_data) -{ - AlarmNotify *an; - char buf[256]; - struct tm tm_trigger; - struct tm tm_occur; - CalComponentText summary; - - g_return_val_if_fail (trigger != -1, FALSE); - g_return_val_if_fail (occur != -1, FALSE); - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), 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 */ - - cal_component_get_summary (comp, &summary); - - if (summary.value) - gtk_label_set_text (GTK_LABEL (an->summary), summary.value); - else - gtk_label_set_text (GTK_LABEL (an->summary), _("No summary available.")); - - /* 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 deleted file mode 100644 index f2c938c495..0000000000 --- a/calendar/gui/dialogs/alarm-notify-dialog.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * 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 -#include -#include - - - -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, CalComponent *comp, - AlarmNotifyFunc func, gpointer func_data); - - - -#endif diff --git a/calendar/gui/dialogs/alarm-notify.glade b/calendar/gui/dialogs/alarm-notify.glade deleted file mode 100644 index 41718d0572..0000000000 --- a/calendar/gui/dialogs/alarm-notify.glade +++ /dev/null @@ -1,228 +0,0 @@ - - - - - Evolution Calendar - evolution-calendar - - src - pixmaps - C - True - True - False - True - True - True - True - interface.c - interface.h - callbacks.c - callbacks.h - support.c - support.h - - - - GtkWindow - alarm-notify - True - - GTK_WINDOW_DIALOG - GTK_WIN_POS_CENTER - False - False - False - False - - - GtkVBox - vbox2 - 4 - True - False - 4 - - - GtkHBox - hbox3 - True - False - 8 - - 0 - True - True - - - - GtkVBox - vbox5 - True - False - 4 - - 0 - True - True - - - - GtkLabel - heading - True - - GTK_JUSTIFY_LEFT - True - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkLabel - summary - True - - GTK_JUSTIFY_LEFT - True - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - - GtkVBox - vbox4 - True - False - 4 - - 0 - True - True - - - - GtkButton - close - True - True - - - 0 - False - False - - - - - GtkButton - snooze - True - True - - - 0 - False - False - - - - - GtkButton - edit - True - True - - - 0 - False - False - - - - - - - GtkHSeparator - hseparator1 - True - - 0 - True - True - - - - - GtkHBox - hbox4 - True - False - 4 - - 0 - True - True - - - - GtkLabel - label4 - True - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkSpinButton - snooze-time - True - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 5 - 1 - 1440 - 1 - 5 - 5 - - 0 - False - False - - - - - - - diff --git a/calendar/gui/dialogs/alarm-page.c b/calendar/gui/dialogs/alarm-page.c deleted file mode 100644 index a4e0054c6b..0000000000 --- a/calendar/gui/dialogs/alarm-page.c +++ /dev/null @@ -1,778 +0,0 @@ -/* Evolution calendar - Alarm page of the calendar component dialogs - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Miguel de Icaza - * Seth Alves - * JP Rosevear - * - * 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 -#endif - -#include -#include -#include -#include -#include -#include "cal-util/cal-util.h" -#include "e-util/e-dialog-widgets.h" -#include "alarm-page.h" - - - -/* Private part of the AlarmPage structure */ -struct _AlarmPagePrivate { - /* Glade XML data */ - GladeXML *xml; - - /* Widgets from the Glade file */ - - GtkWidget *main; - - GtkWidget *summary; - GtkWidget *starting_date; - - GtkWidget *list; - GtkWidget *add; - GtkWidget *delete; - - GtkWidget *action; - GtkWidget *interval_value; - GtkWidget *value_units; - GtkWidget *relative; - GtkWidget *time; -}; - - - -static void alarm_page_class_init (AlarmPageClass *class); -static void alarm_page_init (AlarmPage *apage); -static void alarm_page_destroy (GtkObject *object); - -static GtkWidget *alarm_page_get_widget (EditorPage *page); -static void alarm_page_fill_widgets (EditorPage *page, CalComponent *comp); -static void alarm_page_fill_component (EditorPage *page, CalComponent *comp); -static void alarm_page_set_summary (EditorPage *page, const char *summary); -static char *alarm_page_get_summary (EditorPage *page); -static void alarm_page_set_dtstart (EditorPage *page, time_t start); - -static EditorPageClass *parent_class = NULL; - - - -/** - * alarm_page_get_type: - * - * Registers the #AlarmPage class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #AlarmPage class. - **/ -GtkType -alarm_page_get_type (void) -{ - static GtkType alarm_page_type; - - if (!alarm_page_type) { - static const GtkTypeInfo alarm_page_info = { - "AlarmPage", - sizeof (AlarmPage), - sizeof (AlarmPageClass), - (GtkClassInitFunc) alarm_page_class_init, - (GtkObjectInitFunc) alarm_page_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - alarm_page_type = gtk_type_unique (TYPE_EDITOR_PAGE, &alarm_page_info); - } - - return alarm_page_type; -} - -/* Class initialization function for the alarm page */ -static void -alarm_page_class_init (AlarmPageClass *class) -{ - EditorPageClass *editor_page_class; - GtkObjectClass *object_class; - - editor_page_class = (EditorPageClass *) class; - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (TYPE_EDITOR_PAGE); - - editor_page_class->get_widget = alarm_page_get_widget; - editor_page_class->fill_widgets = alarm_page_fill_widgets; - editor_page_class->fill_component = alarm_page_fill_component; - editor_page_class->set_summary = alarm_page_set_summary; - editor_page_class->get_summary = alarm_page_get_summary; - editor_page_class->set_dtstart = alarm_page_set_dtstart; - - object_class->destroy = alarm_page_destroy; -} - -/* Object initialization function for the alarm page */ -static void -alarm_page_init (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - - priv = g_new0 (AlarmPagePrivate, 1); - apage->priv = priv; - - priv->xml = NULL; - - priv->main = NULL; - priv->summary = NULL; - priv->starting_date = NULL; - priv->list = NULL; - priv->add = NULL; - priv->delete = NULL; - priv->action = NULL; - priv->interval_value = NULL; - priv->value_units = NULL; - priv->relative = NULL; - priv->time = NULL; -} - -/* Frees all the alarm data and empties the list */ -static void -free_alarms (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - GtkCList *clist; - int i; - - priv = apage->priv; - - clist = GTK_CLIST (priv->list); - - for (i = 0; i < clist->rows; i++) { - CalComponentAlarm *alarm; - - alarm = gtk_clist_get_row_data (clist, i); - g_assert (alarm != NULL); - cal_component_alarm_free (alarm); - - gtk_clist_set_row_data (clist, i, NULL); - } - - gtk_clist_clear (clist); -} - -/* Destroy handler for the alarm page */ -static void -alarm_page_destroy (GtkObject *object) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_ALARM_PAGE (object)); - - apage = ALARM_PAGE (object); - priv = apage->priv; - - if (priv->xml) { - gtk_object_unref (GTK_OBJECT (priv->xml)); - priv->xml = NULL; - } - - free_alarms (apage); - - g_free (priv); - apage->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* get_widget handler for the alarm page */ -static GtkWidget * -alarm_page_get_widget (EditorPage *page) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - return priv->main; -} - -/* Fills the widgets with default values */ -static void -clear_widgets (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - - priv = apage->priv; - - /* Summary */ - e_dialog_editable_set (priv->summary, NULL); - - /* Start date */ - gtk_label_set_text (GTK_LABEL (priv->starting_date), ""); - - /* List data */ - free_alarms (apage); -} - -static char * -get_alarm_duration_string (struct icaldurationtype *duration) -{ - GString *string = g_string_new (NULL); - char *ret; - - if (duration->days > 1) - g_string_sprintf (string, _("%d days"), duration->days); - else if (duration->days == 1) - g_string_append (string, _("1 day")); - - if (duration->weeks > 1) - g_string_sprintf (string, _("%d weeks"), duration->weeks); - else if (duration->weeks == 1) - g_string_append (string, _("1 week")); - - if (duration->hours > 1) - g_string_sprintf (string, _("%d hours"), duration->hours); - else if (duration->hours == 1) - g_string_append (string, _("1 hour")); - - if (duration->minutes > 1) - g_string_sprintf (string, _("%d minutes"), duration->minutes); - else if (duration->minutes == 1) - g_string_append (string, _("1 minute")); - - if (duration->seconds > 1) - g_string_sprintf (string, _("%d seconds"), duration->seconds); - else if (duration->seconds == 1) - g_string_append (string, _("1 second")); - - ret = string->str; - g_string_free (string, FALSE); - - return ret; -} - -static char * -get_alarm_string (CalComponentAlarm *alarm) -{ - CalAlarmAction action; - CalAlarmTrigger trigger; - char string[256]; - char *base; - char *str; - char *dur; - - string [0] = '\0'; - - cal_component_alarm_get_action (alarm, &action); - cal_component_alarm_get_trigger (alarm, &trigger); - - switch (action) { - case CAL_ALARM_AUDIO: - base = _("Play a sound"); - break; - - case CAL_ALARM_DISPLAY: - base = _("Show a dialog"); - break; - - case CAL_ALARM_EMAIL: - base = _("Send an email"); - break; - - case CAL_ALARM_PROCEDURE: - base = _("Run a program"); - break; - - case CAL_ALARM_NONE: - case CAL_ALARM_UNKNOWN: - base = _("Unknown"); - break; - } - - /* FIXME: This does not look like it will localize correctly. */ - - switch (trigger.type) { - case CAL_ALARM_TRIGGER_RELATIVE_START: - dur = get_alarm_duration_string (&trigger.u.rel_duration); - - if (trigger.u.rel_duration.is_neg) - str = g_strdup_printf ("%s %s %s", base, dur, - _(" before start of appointment")); - else - str = g_strdup_printf ("%s %s %s", base, dur, - _(" after start of appointment")); - - g_free (dur); - break; - - case CAL_ALARM_TRIGGER_RELATIVE_END: - dur = get_alarm_duration_string (&trigger.u.rel_duration); - - if (trigger.u.rel_duration.is_neg) - str = g_strdup_printf ("%s %s %s", base, dur, - _(" before end of appointment")); - else - str = g_strdup_printf ("%s %s %s", base, dur, - _(" after end of appointment")); - - g_free (dur); - break; - case CAL_ALARM_TRIGGER_NONE: - case CAL_ALARM_TRIGGER_ABSOLUTE: - str = g_strdup_printf ("%s %s", base, - _("Unknown")); - break; - } - - return str; -} - -/* Appends an alarm to the list */ -static void -append_reminder (AlarmPage *apage, CalComponentAlarm *alarm) -{ - AlarmPagePrivate *priv; - GtkCList *clist; - char *c[1]; - int i; - - priv = apage->priv; - - clist = GTK_CLIST (priv->list); - - c[0] = get_alarm_string (alarm); - i = gtk_clist_append (clist, c); - - gtk_clist_set_row_data (clist, i, alarm); - gtk_clist_select_row (clist, i, 0); - g_free (c[0]); - - gtk_widget_set_sensitive (priv->delete, TRUE); -} - -/* fill_widgets handler for the alarm page */ -static void -alarm_page_fill_widgets (EditorPage *page, CalComponent *comp) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - CalComponentText text; - GList *alarms, *l; - GtkCList *clist; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - clear_widgets (apage); - - /* Summary */ - cal_component_get_summary (comp, &text); - e_dialog_editable_set (priv->summary, text.value); - - /* List */ - if (!cal_component_has_alarms (comp)) - return; - - alarms = cal_component_get_alarm_uids (comp); - - clist = GTK_CLIST (priv->list); - for (l = alarms; l != NULL; l = l->next) { - CalComponentAlarm *ca, *ca_copy; - const char *auid; - - auid = l->data; - ca = cal_component_get_alarm (comp, auid); - g_assert (ca != NULL); - - ca_copy = cal_component_alarm_clone (ca); - cal_component_alarm_free (ca); - - append_reminder (apage, ca_copy); - } - cal_obj_uid_list_free (alarms); -} - -/* fill_component handler for the alarm page */ -static void -alarm_page_fill_component (EditorPage *page, CalComponent *comp) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - GList *list, *l; - GtkCList *clist; - int i; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - /* Remove all the alarms from the component */ - - list = cal_component_get_alarm_uids (comp); - for (l = list; l; l = l->next) { - const char *auid; - - auid = l->data; - cal_component_remove_alarm (comp, auid); - } - cal_obj_uid_list_free (list); - - /* Add the new alarms */ - - clist = GTK_CLIST (priv->list); - for (i = 0; i < clist->rows; i++) { - CalComponentAlarm *alarm, *alarm_copy; - - alarm = gtk_clist_get_row_data (clist, i); - g_assert (alarm != NULL); - - /* We clone the alarm to maintain the invariant that the alarm - * structures in the list did *not* come from the component. - */ - - alarm_copy = cal_component_alarm_clone (alarm); - cal_component_add_alarm (comp, alarm); - cal_component_alarm_free (alarm_copy); - } -} - -/* set_summary handler for the alarm page */ -static void -alarm_page_set_summary (EditorPage *page, const char *summary) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->summary), apage); - e_utf8_gtk_entry_set_text (GTK_ENTRY (priv->summary), summary); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->summary), apage); -} - -/* get_summary handler for the alarm page */ -static char * -alarm_page_get_summary (EditorPage *page) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - return e_utf8_gtk_entry_get_text (GTK_ENTRY (priv->summary)); -} - -/* set_dtstart handler for the alarm page */ -static void -alarm_page_set_dtstart (EditorPage *page, time_t start) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - char str[128]; - struct tm tm; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - tm = *localtime (&start); - strftime (str, sizeof (str), _("%A %b %d %Y %H:%M:%S"), &tm); - - gtk_entry_set_text (GTK_ENTRY (priv->starting_date), str); -} - - - -/* "relative" types */ -enum { - BEFORE, - AFTER -}; - -/* Time units */ -enum { - MINUTES, - HOURS, - DAYS -}; - -/* Option menu maps */ -static const int action_map[] = { - CAL_ALARM_DISPLAY, - CAL_ALARM_AUDIO, - CAL_ALARM_EMAIL, - CAL_ALARM_PROCEDURE, - -1 -}; - -static const int value_map[] = { - MINUTES, - HOURS, - DAYS, - -1 -}; - -static const int relative_map[] = { - BEFORE, - AFTER, - -1 -}; - -static const int time_map[] = { - CAL_ALARM_TRIGGER_RELATIVE_START, - CAL_ALARM_TRIGGER_RELATIVE_END, - -1 -}; - -/* Gets the widgets from the XML file and returns if they are all available. */ -static gboolean -get_widgets (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - GtkWidget *toplevel; - - priv = apage->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - toplevel = GW ("alarm-toplevel"); - priv->main = GW ("alarm-page"); - if (!(toplevel && priv->main)) - return FALSE; - - gtk_widget_ref (priv->main); - gtk_widget_unparent (priv->main); - gtk_widget_destroy (toplevel); - - priv->summary = GW ("summary"); - priv->starting_date = GW ("starting-date"); - - priv->list = GW ("list"); - priv->add = GW ("add"); - priv->delete = GW ("delete"); - - priv->action = GW ("action"); - priv->interval_value = GW ("interval-value"); - priv->value_units = GW ("value-units"); - priv->relative = GW ("relative"); - priv->time = GW ("time"); - -#undef GW - - return (priv->summary - && priv->starting_date - && priv->list - && priv->add - && priv->delete - && priv->action - && priv->interval_value - && priv->value_units - && priv->relative - && priv->time); -} - -/* Callback used when the summary changes; we emit the notification signal. */ -static void -summary_changed_cb (GtkEditable *editable, gpointer data) -{ - AlarmPage *apage; - - apage = ALARM_PAGE (data); - editor_page_notify_summary_changed (EDITOR_PAGE (apage)); -} - -/* This is called when any field is changed; it notifies upstream. */ -static void -field_changed_cb (GtkWidget *widget, gpointer data) -{ - AlarmPage *apage; - - apage = ALARM_PAGE (data); - editor_page_notify_changed (EDITOR_PAGE (apage)); -} - -/* Callback used for the "add reminder" button */ -static void -add_clicked_cb (GtkButton *button, gpointer data) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - CalComponentAlarm *alarm; - CalAlarmTrigger trigger; - - apage = ALARM_PAGE (data); - priv = apage->priv; - - alarm = cal_component_alarm_new (); - - memset (&trigger, 0, sizeof (CalAlarmTrigger)); - trigger.type = e_dialog_option_menu_get (priv->time, time_map); - if (e_dialog_option_menu_get (priv->relative, relative_map) == BEFORE) - trigger.u.rel_duration.is_neg = 1; - else - trigger.u.rel_duration.is_neg = 0; - - switch (e_dialog_option_menu_get (priv->value_units, value_map)) { - case MINUTES: - trigger.u.rel_duration.minutes = e_dialog_spin_get_int (priv->interval_value); - break; - - case HOURS: - trigger.u.rel_duration.hours = e_dialog_spin_get_int (priv->interval_value); - break; - - case DAYS: - trigger.u.rel_duration.days = e_dialog_spin_get_int (priv->interval_value); - break; - - default: - g_assert_not_reached (); - } - cal_component_alarm_set_trigger (alarm, trigger); - - cal_component_alarm_set_action (alarm, e_dialog_option_menu_get (priv->action, action_map)); - - append_reminder (apage, alarm); -} - -/* Callback used for the "delete reminder" button */ -static void -delete_clicked_cb (GtkButton *button, gpointer data) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - GtkCList *clist; - CalComponentAlarm *alarm; - int sel; - - apage = ALARM_PAGE (data); - priv = apage->priv; - - clist = GTK_CLIST (priv->list); - if (!clist->selection) - return; - - sel = GPOINTER_TO_INT (clist->selection->data); - - alarm = gtk_clist_get_row_data (clist, sel); - g_assert (alarm != NULL); - cal_component_alarm_free (alarm); - gtk_clist_set_row_data (clist, sel, NULL); - - gtk_clist_remove (clist, sel); - if (sel >= clist->rows) - sel--; - - if (clist->rows > 0) - gtk_clist_select_row (clist, sel, 0); - else - gtk_widget_set_sensitive (priv->delete, FALSE); -} - -/* Hooks the widget signals */ -static void -init_widgets (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - - priv = apage->priv; - - /* Summary */ - gtk_signal_connect (GTK_OBJECT (priv->summary), "changed", - GTK_SIGNAL_FUNC (summary_changed_cb), apage); - - /* Reminder buttons */ - gtk_signal_connect (GTK_OBJECT (priv->add), "clicked", - GTK_SIGNAL_FUNC (add_clicked_cb), apage); - gtk_signal_connect (GTK_OBJECT (priv->delete), "clicked", - GTK_SIGNAL_FUNC (delete_clicked_cb), apage); - - /* Connect the default signal handler to use to make sure we notify - * upstream of changes to the widget values. - */ - gtk_signal_connect (GTK_OBJECT (priv->add), "clicked", - GTK_SIGNAL_FUNC (field_changed_cb), apage); - gtk_signal_connect (GTK_OBJECT (priv->delete), "clicked", - GTK_SIGNAL_FUNC (field_changed_cb), apage); -} - - - -/** - * alarm_page_construct: - * @apage: An alarm page. - * - * Constructs an alarm page by loading its Glade data. - * - * Return value: The same object as @apage, or NULL if the widgets could not be - * created. - **/ -AlarmPage * -alarm_page_construct (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - - priv = apage->priv; - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-page.glade", NULL); - if (!priv->xml) { - g_message ("alarm_page_construct(): Could not load the Glade XML file!"); - return NULL; - } - - if (!get_widgets (apage)) { - g_message ("alarm_page_construct(): Could not find all widgets in the XML file!"); - return NULL; - } - - init_widgets (apage); - - return apage; -} - -/** - * alarm_page_new: - * - * Creates a new alarm page. - * - * Return value: A newly-created alarm page, or NULL if the page could not be - * created. - **/ -AlarmPage * -alarm_page_new (void) -{ - AlarmPage *apage; - - apage = gtk_type_new (TYPE_ALARM_PAGE); - if (!alarm_page_construct (apage)) { - gtk_object_unref (GTK_OBJECT (apage)); - return NULL; - } - - return apage; -} diff --git a/calendar/gui/dialogs/alarm-page.glade b/calendar/gui/dialogs/alarm-page.glade deleted file mode 100644 index 3a4a8d6765..0000000000 --- a/calendar/gui/dialogs/alarm-page.glade +++ /dev/null @@ -1,381 +0,0 @@ - - - - - alarm-page - alarm-page - - . - pixmaps - C - True - True - False - False - False - - - - GtkWindow - alarm-toplevel - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkVBox - alarm-page - 4 - False - 4 - - - GtkFrame - frame33 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkTable - table13 - 4 - 2 - 2 - False - 2 - 2 - - - GtkLabel - label62 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - reminder-summary - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - reminder-summary - True - True - True - 0 - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - True - False - True - False - - - - - GtkLabel - label63 - - GTK_JUSTIFY_CENTER - False - 0 - 0 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - starting date - - GTK_JUSTIFY_CENTER - False - 0 - 0 - 0 - 0 - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - - - GtkFrame - frame34 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkVBox - vbox53 - 4 - False - 4 - - - GtkHBox - hbox54 - False - 4 - - 0 - False - True - - - - GtkOptionMenu - reminder-action - True - Show a dialog -Play a sound -Send an email -Run a program - - 0 - - 0 - False - False - - - - - GtkSpinButton - reminder-interval-value - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 - 0 - 100 - 1 - 10 - 10 - - 0 - False - True - - - - - GtkOptionMenu - reminder-value-units - True - minute(s) -hour(s) -day(s) - - 0 - - 0 - False - False - - - - - GtkOptionMenu - reminder-relative - True - before -after - - 0 - - 0 - False - False - - - - - GtkOptionMenu - reminder-time - True - start of appointment -end of appointment - - 0 - - 0 - False - False - - - - - GtkButton - button9 - True - - GTK_RELIEF_NORMAL - - 0 - False - False - - - - - - GtkHBox - hbox55 - False - 0 - - 0 - True - True - - - - GtkScrolledWindow - scrolledwindow13 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - reminder-list - True - 1 - 80 - GTK_SELECTION_BROWSE - False - GTK_SHADOW_IN - - - GtkLabel - CList:title - label64 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkVButtonBox - vbuttonbox2 - GTK_BUTTONBOX_START - 10 - 85 - 27 - 7 - 0 - - 0 - False - False - - - - GtkButton - reminder-add - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - reminder-delete - True - True - - GTK_RELIEF_NORMAL - - - - - - - - - diff --git a/calendar/gui/dialogs/alarm-page.h b/calendar/gui/dialogs/alarm-page.h deleted file mode 100644 index 1cb0b301bd..0000000000 --- a/calendar/gui/dialogs/alarm-page.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Evolution calendar - Alarm page of the calendar component dialogs - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Miguel de Icaza - * Seth Alves - * JP Rosevear - * - * 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_PAGE_H -#define ALARM_PAGE_H - -#include "editor-page.h" - -BEGIN_GNOME_DECLS - - - -#define TYPE_ALARM_PAGE (alarm_page_get_type ()) -#define ALARM_PAGE(obj) (GTK_CHECK_CAST ((obj), TYPE_ALARM_PAGE, AlarmPage)) -#define ALARM_PAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_ALARM_PAGE, \ - AlarmPageClass)) -#define IS_ALARM_PAGE(obj) (GTK_CHECK_TYPE ((obj), TYPE_ALARM_PAGE)) -#define IS_ALARM_PAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), TYPE_ALARM_PAGE)) - -typedef struct _AlarmPagePrivate AlarmPagePrivate; - -typedef struct { - EditorPage page; - - /* Private data */ - AlarmPagePrivate *priv; -} AlarmPage; - -typedef struct { - EditorPageClass parent_class; -} AlarmPageClass; - -GtkType alarm_page_get_type (void); - -AlarmPage *alarm_page_construct (AlarmPage *apage); - -AlarmPage *alarm_page_new (void); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c deleted file mode 100644 index 9839318e8e..0000000000 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ /dev/null @@ -1,456 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin - * - * Copyright 2000, Helix Code, Inc. - * Copyright 2000, Ximian, Inc. - * - * 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 - */ - -/* - * CalPrefsDialog - a GtkObject which handles a libglade-loaded dialog - * to edit the calendar preference settings. - */ - -#include -#include -#include -#include -#include -#include "cal-prefs-dialog.h" -#include "../calendar-config.h" -#include "../calendar-commands.h" -#include "../e-tasks.h" - - -typedef struct { - /* Glade XML data */ - GladeXML *xml; - - GtkWidget *dialog; - - GtkWidget *working_days[7]; - GtkWidget *week_start_day; - GtkWidget *start_of_day; - GtkWidget *end_of_day; - GtkWidget *use_12_hour; - GtkWidget *use_24_hour; - GtkWidget *time_divisions; - GtkWidget *show_end_times; - GtkWidget *compress_weekend; - GtkWidget *dnav_show_week_no; -} CalPrefsDialogPrivate; - -static const int week_start_day_map[] = { - 1, 2, 3, 4, 5, 6, 0, -1 -}; - -static const int time_division_map[] = { - 60, 30, 15, 10, 5, -1 -}; - -static void cal_prefs_dialog_class_init (CalPrefsDialogClass *class); -static void cal_prefs_dialog_init (CalPrefsDialog *prefs); -static gboolean get_widgets (CalPrefsDialog *prefs); -static void cal_prefs_dialog_destroy (GtkObject *object); -static void cal_prefs_dialog_init_widgets (CalPrefsDialog *prefs); -static void cal_prefs_dialog_button_clicked (GtkWidget *dialog, - gint button, - CalPrefsDialog *prefs); -static void cal_prefs_dialog_use_24_hour_toggled(GtkWidget *button, - CalPrefsDialog *prefs); -static void cal_prefs_dialog_show_config (CalPrefsDialog *prefs); -static void cal_prefs_dialog_update_config (CalPrefsDialog *prefs); - -GtkWidget* cal_prefs_dialog_create_time_edit (void); - -static GtkObjectClass *parent_class; - -E_MAKE_TYPE (cal_prefs_dialog, "CalPrefsDialog", CalPrefsDialog, - cal_prefs_dialog_class_init, cal_prefs_dialog_init, - GTK_TYPE_OBJECT) - - -static void -cal_prefs_dialog_class_init (CalPrefsDialogClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - object_class->destroy = cal_prefs_dialog_destroy; -} - - -static void -cal_prefs_dialog_init (CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - - priv = g_new0 (CalPrefsDialogPrivate, 1); - prefs->priv = priv; - -} - - -/** - * cal_prefs_dialog_new: - * @Returns: a new #CalPrefsDialog. - * - * Creates a new #CalPrefsDialog. - **/ -CalPrefsDialog * -cal_prefs_dialog_new (void) -{ - CalPrefsDialog *prefs; - - prefs = CAL_PREFS_DIALOG (gtk_type_new (cal_prefs_dialog_get_type ())); - return cal_prefs_dialog_construct (prefs); -} - - -/** - * cal_prefs_dialog_construct: - * @prefs: A #CalPrefsDialog. - * - * Constructs a task editor by loading its Glade XML file. - * - * Return value: The same object as @prefs, or NULL if the widgets could not be - * created. In the latter case, the task editor will automatically be - * destroyed. - **/ -CalPrefsDialog * -cal_prefs_dialog_construct (CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - - g_return_val_if_fail (IS_CAL_PREFS_DIALOG (prefs), NULL); - - priv = prefs->priv; - - /* Load the content widgets */ - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/cal-prefs-dialog.glade", NULL); - if (!priv->xml) { - g_message ("cal_prefs_dialog_construct(): Could not load the Glade XML file!"); - goto error; - } - - if (!get_widgets (prefs)) { - g_message ("cal_prefs_dialog_construct(): Could not find all widgets in the XML file!"); - goto error; - } - - cal_prefs_dialog_init_widgets (prefs); - - cal_prefs_dialog_show_config (prefs); - - gtk_widget_show (priv->dialog); - - return prefs; - - error: - - gtk_object_unref (GTK_OBJECT (prefs)); - return NULL; -} - - -/* Gets the widgets from the XML file and returns if they are all available. - */ -static gboolean -get_widgets (CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - - priv = prefs->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - priv->dialog = GW ("cal-prefs-dialog"); - - /* The indices must match the mktime() values. */ - priv->working_days[0] = GW ("sun_button"); - priv->working_days[1] = GW ("mon_button"); - priv->working_days[2] = GW ("tue_button"); - priv->working_days[3] = GW ("wed_button"); - priv->working_days[4] = GW ("thu_button"); - priv->working_days[5] = GW ("fri_button"); - priv->working_days[6] = GW ("sat_button"); - - priv->week_start_day = GW ("first_day_of_week"); - priv->start_of_day = GW ("start_of_day"); - priv->end_of_day = GW ("end_of_day"); - priv->use_12_hour = GW ("use_12_hour"); - priv->use_24_hour = GW ("use_24_hour"); - priv->time_divisions = GW ("time_divisions"); - priv->show_end_times = GW ("show_end_times"); - priv->compress_weekend = GW ("compress_weekend"); - priv->dnav_show_week_no = GW ("dnav_show_week_no"); - -#undef GW - - return (priv->dialog - && priv->working_days[0] - && priv->working_days[1] - && priv->working_days[2] - && priv->working_days[3] - && priv->working_days[4] - && priv->working_days[5] - && priv->working_days[6] - && priv->week_start_day - && priv->start_of_day - && priv->end_of_day - && priv->use_12_hour - && priv->use_24_hour - && priv->time_divisions - && priv->show_end_times - && priv->compress_weekend - && priv->dnav_show_week_no); -} - - -static void -cal_prefs_dialog_destroy (GtkObject *object) -{ - CalPrefsDialog *prefs; - CalPrefsDialogPrivate *priv; - - g_return_if_fail (IS_CAL_PREFS_DIALOG (object)); - - prefs = CAL_PREFS_DIALOG (object); - priv = prefs->priv; - - - g_free (priv); - prefs->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -/* Called by libglade to create our custom EDateEdit widgets. */ -GtkWidget * -cal_prefs_dialog_create_time_edit (void) -{ - GtkWidget *dedit; - - dedit = e_date_edit_new (); - - e_date_edit_set_time_popup_range (E_DATE_EDIT (dedit), 0, 24); - e_date_edit_set_show_date (E_DATE_EDIT (dedit), FALSE); - - return dedit; -} - - -void -cal_prefs_dialog_show (CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - - g_return_if_fail (IS_CAL_PREFS_DIALOG (prefs)); - - priv = prefs->priv; - - /* If the dialog is already show just raise it, otherwise refresh the - config settings and show it. */ - if (GTK_WIDGET_MAPPED (priv->dialog)) { - gdk_window_raise (priv->dialog->window); - } else { - cal_prefs_dialog_show_config (prefs); - gtk_widget_show (priv->dialog); - } -} - - -/* Connects any necessary signal handlers. */ -static void -cal_prefs_dialog_init_widgets (CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - - priv = prefs->priv; - - gtk_signal_connect (GTK_OBJECT (priv->dialog), "clicked", - GTK_SIGNAL_FUNC (cal_prefs_dialog_button_clicked), - prefs); - - gtk_signal_connect (GTK_OBJECT (priv->use_24_hour), "toggled", - GTK_SIGNAL_FUNC (cal_prefs_dialog_use_24_hour_toggled), - prefs); -} - - -static void -cal_prefs_dialog_button_clicked (GtkWidget *dialog, - gint button, - CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - - g_return_if_fail (IS_CAL_PREFS_DIALOG (prefs)); - - priv = prefs->priv; - - /* OK & Apply buttons update the config settings. */ - if (button == 0 || button == 1) - cal_prefs_dialog_update_config (prefs); - - /* OK & Close buttons close the dialog. */ - if (button == 0 || button == 2) - gtk_widget_hide (priv->dialog); -} - - -static void -cal_prefs_dialog_use_24_hour_toggled (GtkWidget *button, - CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - gboolean use_24_hour; - - priv = prefs->priv; - - use_24_hour = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->use_24_hour)); - - e_date_edit_set_use_24_hour_format (E_DATE_EDIT (priv->start_of_day), - use_24_hour); - e_date_edit_set_use_24_hour_format (E_DATE_EDIT (priv->end_of_day), - use_24_hour); -} - - -/* Shows the current config settings in the dialog. */ -static void -cal_prefs_dialog_show_config (CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - CalWeekdays working_days; - gint mask, day, week_start_day, time_divisions; - - priv = prefs->priv; - - /* Working Days. */ - working_days = calendar_config_get_working_days (); - mask = 1 << 0; - for (day = 0; day < 7; day++) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->working_days[day]), (working_days & mask) ? TRUE : FALSE); - mask <<= 1; - } - - /* Week Start Day. */ - week_start_day = calendar_config_get_week_start_day (); - e_dialog_option_menu_set (priv->week_start_day, week_start_day, - week_start_day_map); - - /* Start of Day. */ - e_date_edit_set_time_of_day (E_DATE_EDIT (priv->start_of_day), - calendar_config_get_day_start_hour (), - calendar_config_get_day_start_minute ()); - - /* End of Day. */ - e_date_edit_set_time_of_day (E_DATE_EDIT (priv->end_of_day), - calendar_config_get_day_end_hour (), - calendar_config_get_day_end_minute ()); - - /* 12/24 Hour Format. */ - if (calendar_config_get_24_hour_format ()) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->use_24_hour), TRUE); - else - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->use_12_hour), TRUE); - - /* Time Divisions. */ - time_divisions = calendar_config_get_time_divisions (); - e_dialog_option_menu_set (priv->time_divisions, time_divisions, - time_division_map); - - /* Show Appointment End Times. */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->show_end_times), - calendar_config_get_show_event_end ()); - - /* Compress Weekend. */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->compress_weekend), calendar_config_get_compress_weekend ()); - - /* Date Navigator - Show Week Numbers. */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->dnav_show_week_no), calendar_config_get_dnav_show_week_no ()); -} - - -/* Updates the config values based on the settings in the dialog. */ -static void -cal_prefs_dialog_update_config (CalPrefsDialog *prefs) -{ - CalPrefsDialogPrivate *priv; - CalWeekdays working_days; - gint mask, day, week_start_day, time_divisions, hour, minute; - - priv = prefs->priv; - - /* Working Days. */ - working_days = 0; - mask = 1 << 0; - for (day = 0; day < 7; day++) { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->working_days[day]))) - working_days |= mask; - mask <<= 1; - } - calendar_config_set_working_days (working_days); - - /* Week Start Day. */ - week_start_day = e_dialog_option_menu_get (priv->week_start_day, - week_start_day_map); - calendar_config_set_week_start_day (week_start_day); - - /* Start of Day. */ - e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_of_day), - &hour, &minute); - calendar_config_set_day_start_hour (hour); - calendar_config_set_day_start_minute (minute); - - /* End of Day. */ - e_date_edit_get_time_of_day (E_DATE_EDIT (priv->end_of_day), - &hour, &minute); - calendar_config_set_day_end_hour (hour); - calendar_config_set_day_end_minute (minute); - - /* 12/24 Hour Format. */ - calendar_config_set_24_hour_format (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->use_24_hour))); - - /* Time Divisions. */ - time_divisions = e_dialog_option_menu_get (priv->time_divisions, - time_division_map); - calendar_config_set_time_divisions (time_divisions); - - /* Show Appointment End Times. */ - calendar_config_set_show_event_end (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->show_end_times))); - - /* Compress Weekend. */ - calendar_config_set_compress_weekend (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->compress_weekend))); - - /* Date Navigator - Show Week Numbers. */ - calendar_config_set_dnav_show_week_no (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->dnav_show_week_no))); - - calendar_config_write (); - update_all_config_settings (); - e_tasks_update_all_config_settings (); -} diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade deleted file mode 100644 index f6eccb163d..0000000000 --- a/calendar/gui/dialogs/cal-prefs-dialog.glade +++ /dev/null @@ -1,1241 +0,0 @@ - - - - - preferences - preferences - - src - pixmaps - C - True - True - - - - GnomeDialog - cal-prefs-dialog - Calendar Preferences - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - True - - - GtkVBox - GnomeDialog:vbox - vbox1 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - hbuttonbox1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button1 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button2 - True - True - GNOME_STOCK_BUTTON_APPLY - - - - GtkButton - button3 - True - True - GNOME_STOCK_BUTTON_CLOSE - - - - - GtkNotebook - notebook1 - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - 0 - True - True - - - - GtkVBox - vbox8 - 4 - False - 6 - - - GtkFrame - frame9 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkVBox - vbox9 - 4 - False - 3 - - - GtkHBox - hbox8 - True - 0 - - 0 - False - True - - - - GtkCheckButton - mon_button - True - - False - True - - 0 - False - True - - - - - GtkCheckButton - tue_button - True - - False - True - - 0 - False - True - - - - - GtkCheckButton - wed_button - True - - False - True - - 0 - False - True - - - - - GtkCheckButton - thu_button - True - - False - True - - 0 - False - True - - - - - GtkCheckButton - fri_button - True - - False - True - - 0 - False - True - - - - - GtkCheckButton - sat_button - True - - False - True - - 0 - False - True - - - - - GtkCheckButton - sun_button - True - - False - True - - 0 - False - True - - - - - - GtkHBox - hbox9 - False - 4 - - 0 - False - False - - - - GtkLabel - label16 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkOptionMenu - first_day_of_week - True - Monday -Tuesday -Wednesday -Thursday -Friday -Saturday -Sunday - - 0 - - 0 - False - False - - - - - - GtkHBox - hbox11 - False - 4 - - 0 - True - True - - - - GtkLabel - label17 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - Custom - start_of_day - cal_prefs_dialog_create_time_edit - 0 - 0 - Tue, 10 Oct 2000 15:12:12 GMT - - 0 - False - True - - - - - GtkLabel - label18 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - Custom - end_of_day - cal_prefs_dialog_create_time_edit - 0 - 0 - Tue, 10 Oct 2000 15:12:21 GMT - - 0 - False - True - - - - - - - - GtkFrame - frame10 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkTable - table4 - 4 - 4 - 3 - False - 0 - 4 - - - GtkLabel - label19 - - GTK_JUSTIFY_CENTER - False - 7.45058e-09 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label20 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkCheckButton - show_end_times - True - - False - True - - 0 - 3 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkCheckButton - compress_weekend - True - - False - True - - 0 - 3 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - - GtkHBox - hbox10 - True - 4 - - 1 - 3 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkRadioButton - use_12_hour - True - - False - True - time_format_group - - 0 - False - True - - - - - GtkRadioButton - use_24_hour - True - - False - True - time_format_group - - 0 - False - True - - - - - - GtkAlignment - alignment4 - 7.45058e-09 - 0.5 - 0 - 1 - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - GtkOptionMenu - time_divisions - True - 60 minutes -30 minutes -15 minutes -10 minutes -05 minutes - - 0 - - - - - - - GtkFrame - frame11 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkCheckButton - dnav_show_week_no - 4 - True - - False - True - - - - - - GtkLabel - Notebook:tab - label7 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkVBox - vbox3 - 4 - False - 4 - - - GtkHBox - hbox4 - False - 0 - - 0 - True - True - - - - GtkFrame - frame3 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkVBox - vbox4 - 4 - False - 0 - - - GtkCheckButton - checkbutton1 - True - - True - True - - 0 - False - False - - - - - GtkCheckButton - checkbutton2 - True - - True - True - - 0 - False - False - - - - - GtkCheckButton - checkbutton3 - True - - True - True - - 0 - False - False - - - - - - - GtkFrame - frame4 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkVBox - vbox5 - 4 - False - 0 - - - GtkCheckButton - checkbutton4 - True - - False - True - - 0 - False - False - - - - - GtkCheckButton - checkbutton5 - True - - False - True - - 0 - False - False - - - - - GtkCheckButton - checkbutton6 - True - - False - True - - 0 - False - False - - - - - - - - GtkFrame - frame5 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkTable - table3 - 4 - 3 - 2 - False - 4 - 4 - - - GnomeColorPicker - colorpicker1 - True - True - False - Pick a color - - 1 - 2 - 0 - 1 - 0 - 0 - False - False - False - False - False - False - - - - - GnomeColorPicker - colorpicker2 - True - True - False - Pick a color - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - False - False - - - - - GnomeColorPicker - colorpicker3 - True - True - False - Pick a color - - 1 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - False - False - - - - - GtkAlignment - alignment1 - 1 - 0.5 - 1 - 1 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label8 - - GTK_JUSTIFY_RIGHT - False - 1 - 0.5 - 0 - 0 - - - - - GtkAlignment - alignment2 - 1 - 0.5 - 1 - 1 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label9 - - GTK_JUSTIFY_RIGHT - True - 1 - 0.5 - 0 - 0 - - - - - GtkAlignment - alignment3 - 1 - 0.5 - 1 - 1 - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label10 - - GTK_JUSTIFY_RIGHT - False - 1 - 0.5 - 0 - 0 - - - - - - - - GtkLabel - Notebook:tab - label11 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkVBox - vbox6 - False - 0 - - - GtkFrame - frame6 - 4 - - 0 - GTK_SHADOW_ETCHED_IN - - 4 - False - True - - - - GtkHBox - hbox5 - 4 - False - 0 - - - GtkCheckButton - checkbutton7 - 2 - True - - True - True - - 0 - False - False - - - - - GtkSpinButton - spinbutton1 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 1 - 0 - 100 - 1 - 10 - 10 - - 0 - True - True - - - - - GtkLabel - label12 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 3 - 0 - - 0 - False - False - - - - - - - GtkFrame - frame7 - 4 - - 0 - GTK_SHADOW_ETCHED_IN - - 4 - False - True - - - - GtkCheckButton - checkbutton8 - 4 - True - - False - True - - - - - GtkFrame - frame8 - 4 - - 0 - GTK_SHADOW_ETCHED_IN - - 4 - False - True - - - - GtkVBox - vbox7 - 4 - False - 4 - - - GtkHBox - hbox6 - False - 0 - - 0 - False - True - - - - GtkCheckButton - checkbutton9 - True - - False - True - - 0 - False - False - - - - - GtkSpinButton - spinbutton2 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 5 - 0 - 100 - 1 - 10 - 10 - - 0 - False - False - - - - - GtkLabel - label13 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - - GtkHBox - hbox7 - False - 0 - - 0 - True - True - - - - GtkCheckButton - checkbutton10 - True - - False - True - - 0 - False - False - - - - - GtkSpinButton - spinbutton3 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 600 - 0 - 1000 - 1 - 10 - 10 - - 0 - False - False - - - - - GtkLabel - label14 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - - - - - GtkLabel - Notebook:tab - label15 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h deleted file mode 100644 index 9d744f806d..0000000000 --- a/calendar/gui/dialogs/cal-prefs-dialog.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin - * - * Copyright 2000, Helix Code, Inc. - * Copyright 2000, Ximian, Inc. - * - * 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 - */ - -/* - * CalPrefsDialog - a GtkObject which handles a libglade-loaded dialog - * to edit the calendar preference settings. - */ - -#ifndef _CAL_PREFS_DIALOG_H_ -#define _CAL_PREFS_DIALOG_H_ - -#include -#include - -BEGIN_GNOME_DECLS - - -#define CAL_PREFS_DIALOG(obj) GTK_CHECK_CAST (obj, cal_prefs_dialog_get_type (), CalPrefsDialog) -#define CAL_PREFS_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, cal_prefs_dialog_get_type (), CalPrefsDialogClass) -#define IS_CAL_PREFS_DIALOG(obj) GTK_CHECK_TYPE (obj, cal_prefs_dialog_get_type ()) - - -typedef struct _CalPrefsDialog CalPrefsDialog; -typedef struct _CalPrefsDialogClass CalPrefsDialogClass; - -struct _CalPrefsDialog -{ - GtkObject object; - - /* Private data */ - gpointer priv; -}; - -struct _CalPrefsDialogClass -{ - GtkObjectClass parent_class; -}; - - -GtkType cal_prefs_dialog_get_type (void); -CalPrefsDialog* cal_prefs_dialog_construct (CalPrefsDialog *prefs); -CalPrefsDialog* cal_prefs_dialog_new (void); - -void cal_prefs_dialog_show (CalPrefsDialog *prefs); - -END_GNOME_DECLS - -#endif /* _CAL_PREFS_DIALOG_H_ */ diff --git a/calendar/gui/dialogs/delete-comp.c b/calendar/gui/dialogs/delete-comp.c deleted file mode 100644 index a5ba1162db..0000000000 --- a/calendar/gui/dialogs/delete-comp.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Evolution calendar - Delete calendar component dialog - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * 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 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include "delete-comp.h" - - - -/** - * delete_component_dialog: - * @comp: A calendar component if a single component is to be deleted, or NULL - * if more that one component is to be deleted. - * @n_comps: Number of components that are to be deleted. - * @vtype: Type of the components that are to be deleted. This is ignored - * if only one component is to be deleted, and the vtype is extracted from - * the component instead. - * @widget: A widget to use as a basis for conversion from UTF8 into font - * encoding. - * - * Pops up a dialog box asking the user whether he wants to delete a number - * of calendar components. - * - * Return value: TRUE if the user clicked Yes, FALSE otherwise. - **/ -gboolean -delete_component_dialog (CalComponent *comp, - int n_comps, CalComponentVType vtype, - GtkWidget *widget) -{ - char *str; - GtkWidget *dialog; - - if (comp) { - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - g_return_val_if_fail (n_comps == 1, FALSE); - } else { - g_return_val_if_fail (n_comps > 1, FALSE); - g_return_val_if_fail (vtype != CAL_COMPONENT_NO_TYPE, FALSE); - } - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - - if (comp) { - CalComponentText summary; - char *tmp; - - vtype = cal_component_get_vtype (comp); - cal_component_get_summary (comp, &summary); - - tmp = e_utf8_to_gtk_string (widget, summary.value); - - switch (vtype) { - case CAL_COMPONENT_EVENT: - if (tmp) - str = g_strdup_printf (_("Are you sure you want to delete " - "the appointment `%s'?"), tmp); - else - str = g_strdup (_("Are you sure you want to delete this " - "untitled appointment?")); - break; - - case CAL_COMPONENT_TODO: - if (tmp) - str = g_strdup_printf (_("Are you sure you want to delete " - "the task `%s'?"), tmp); - else - str = g_strdup (_("Are you sure you want to delete this " - "untitled task?")); - break; - - case CAL_COMPONENT_JOURNAL: - if (tmp) - str = g_strdup_printf (_("Are you sure you want to delete " - "the journal entry `%s'?"), tmp); - else - str = g_strdup (_("Are you sure want to delete this " - "untitled journal entry?")); - break; - - default: - g_message ("delete_component_dialog(): Cannot handle object of type %d", - vtype); - g_free (tmp); - return FALSE; - } - - g_free (tmp); - } else { - switch (vtype) { - case CAL_COMPONENT_EVENT: - str = g_strdup_printf (_("Are you sure you want to delete " - "%d appointments?"), n_comps); - break; - - case CAL_COMPONENT_TODO: - str = g_strdup_printf (_("Are you sure you want to delete " - "%d tasks?"), n_comps); - break; - - case CAL_COMPONENT_JOURNAL: - str = g_strdup_printf (_("Are you sure you want to delete " - "%d journal entries?"), n_comps); - break; - - default: - g_message ("delete_component_dialog(): Cannot handle objects of type %d", - vtype); - return FALSE; - } - } - - dialog = gnome_question_dialog_modal (str, NULL, NULL); - g_free (str); - - if (gnome_dialog_run (GNOME_DIALOG (dialog)) == GNOME_YES) - return TRUE; - else - return FALSE; -} diff --git a/calendar/gui/dialogs/delete-comp.h b/calendar/gui/dialogs/delete-comp.h deleted file mode 100644 index 3b728a3f7e..0000000000 --- a/calendar/gui/dialogs/delete-comp.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Evolution calendar - Delete calendar component dialog - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * 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 DELETE_COMP_H -#define DELETE_COMP_H - -#include -#include - -gboolean delete_component_dialog (CalComponent *comp, - int n_comps, CalComponentVType vtype, - GtkWidget *widget); - -#endif diff --git a/calendar/gui/dialogs/editor-page.c b/calendar/gui/dialogs/editor-page.c deleted file mode 100644 index b46b247191..0000000000 --- a/calendar/gui/dialogs/editor-page.c +++ /dev/null @@ -1,259 +0,0 @@ -/* Evolution calendar - Base class for calendar component editor pages - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * - * 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 -#endif - -#include -#include "editor-page.h" - - - -static void editor_page_class_init (EditorPageClass *class); - -/* Signal IDs */ - -enum { - CHANGED, - SUMMARY_CHANGED, - LAST_SIGNAL -}; - -static guint editor_page_signals[LAST_SIGNAL]; - -#define CLASS(page) (EDITOR_PAGE_CLASS (GTK_OBJECT (page)->klass)) - - - -/** - * editor_page_get_type: - * - * Registers the #EditorPage class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #EditorPage class. - **/ -GtkType -editor_page_get_type (void) -{ - static GtkType editor_page_type = 0; - - if (!editor_page_type) { - static const GtkTypeInfo editor_page_info = { - "EditorPage", - sizeof (EditorPage), - sizeof (EditorPageClass), - (GtkClassInitFunc) editor_page_class_init, - (GtkObjectInitFunc) NULL, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - editor_page_type = gtk_type_unique (GTK_TYPE_OBJECT, &editor_page_info); - } - - return editor_page_type; -} - -/* Class initialization function for the abstract editor page */ -static void -editor_page_class_init (EditorPageClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - editor_page_signals[CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EditorPageClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - editor_page_signals[SUMMARY_CHANGED] = - gtk_signal_new ("summary_changed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EditorPageClass, summary_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, editor_page_signals, LAST_SIGNAL); - - class->changed = NULL; - class->summary_changed = NULL; - - class->get_widget = NULL; - class->fill_widgets = NULL; - class->fill_component = NULL; - class->set_summary = NULL; - class->get_summary = NULL; - class->set_dtstart = NULL; -} - - - -/** - * editor_page_get_widget: - * @page: An editor page. - * - * Queries the main widget of an editor page. - * - * Return value: The widget that is the page's upper container. It should - * normally be inserted in a notebook widget. - **/ -GtkWidget * -editor_page_get_widget (EditorPage *page) -{ - g_return_val_if_fail (page != NULL, NULL); - g_return_val_if_fail (IS_EDITOR_PAGE (page), NULL); - - g_assert (CLASS (page)->get_widget != NULL); - return (* CLASS (page)->get_widget) (page); -} - -/** - * editor_page_fill_widgets: - * @page: An editor page. - * @comp: A calendar component. - * - * Fills the widgets of an editor page with the data from a calendar component. - **/ -void -editor_page_fill_widgets (EditorPage *page, CalComponent *comp) -{ - g_return_if_fail (page != NULL); - g_return_if_fail (IS_EDITOR_PAGE (page)); - g_return_if_fail (comp != NULL); - - g_assert (CLASS (page)->fill_widgets != NULL); - (* CLASS (page)->fill_widgets) (page, comp); -} - -/** - * editor_page_fill_component: - * @page: An editor page. - * @comp: A calendar component. - * - * Takes the data from the widgets of an editor page and sets it on a calendar - * component, replacing the contents of the properties that the editor page - * knows how to manipulate. - **/ -void -editor_page_fill_component (EditorPage *page, CalComponent *comp) -{ - g_return_if_fail (page != NULL); - g_return_if_fail (IS_EDITOR_PAGE (page)); - g_return_if_fail (comp != NULL); - - g_assert (CLASS (page)->fill_component != NULL); - (* CLASS (page)->fill_component) (page, comp); -} - -/** - * editor_page_set_summary: - * @page: An editor page. - * @summary: Summary string to set in the page's widgets, which must be encoded - * in UTF8. - * - * Sets the calendar component summary string in an editor page. - **/ -void -editor_page_set_summary (EditorPage *page, const char *summary) -{ - g_return_if_fail (page != NULL); - g_return_if_fail (IS_EDITOR_PAGE (page)); - g_return_if_fail (summary != NULL); - - g_assert (CLASS (page)->set_summary != NULL); - (* CLASS (page)->set_summary) (page, summary); -} - -/** - * editor_page_get_summary: - * @page: An editor page. - * - * Queries the current summary string in an editor page. - * - * Return value: Summary string in UTF8; must be freed by the caller. - **/ -char * -editor_page_get_summary (EditorPage *page) -{ - g_return_val_if_fail (page != NULL, NULL); - g_return_val_if_fail (IS_EDITOR_PAGE (page), NULL); - - g_assert (CLASS (page)->get_summary != NULL); - return (* CLASS (page)->get_summary) (page); -} - -/** - * editor_page_set_dtstart: - * @page: An editor page. - * @start: Start date for calendar component. - * - * Sets the calendar component DTSTART in an editor page. - **/ -void -editor_page_set_dtstart (EditorPage *page, time_t start) -{ - g_return_if_fail (page != NULL); - g_return_if_fail (IS_EDITOR_PAGE (page)); - g_return_if_fail (start != -1); - - g_assert (CLASS (page)->set_dtstart != NULL); - (* CLASS (page)->set_dtstart) (page, start); -} - -/** - * editor_page_notify_changed: - * @page: An editor page. - * - * Makes an editor page emit the "changed" signal. This is meant to be - * used only by page implementations. - **/ -void -editor_page_notify_changed (EditorPage *page) -{ - g_return_if_fail (page != NULL); - g_return_if_fail (IS_EDITOR_PAGE (page)); - - gtk_signal_emit (GTK_OBJECT (page), editor_page_signals[CHANGED]); -} - -/** - * editor_page_notify_summary_changed: - * @page: An editor page. - * - * Makes an editor page emit the "summary_changed" signal. This is meant to be - * used only by page implementations. - **/ -void -editor_page_notify_summary_changed (EditorPage *page) -{ - g_return_if_fail (page != NULL); - g_return_if_fail (IS_EDITOR_PAGE (page)); - - gtk_signal_emit (GTK_OBJECT (page), editor_page_signals[SUMMARY_CHANGED]); -} diff --git a/calendar/gui/dialogs/editor-page.h b/calendar/gui/dialogs/editor-page.h deleted file mode 100644 index 3f9587c9de..0000000000 --- a/calendar/gui/dialogs/editor-page.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Evolution calendar - Base class for calendar component editor pages - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * - * 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 EDITOR_PAGE_H -#define EDITOR_PAGE_H - -#include -#include -#include -#include - -BEGIN_GNOME_DECLS - - - -#define TYPE_EDITOR_PAGE (editor_page_get_type ()) -#define EDITOR_PAGE(obj) (GTK_CHECK_CAST ((obj), TYPE_EDITOR_PAGE, EditorPage)) -#define EDITOR_PAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_EDITOR_PAGE, \ - EditorPageClass)) -#define IS_EDITOR_PAGE(obj) (GTK_CHECK_TYPE ((obj), TYPE_EDITOR_PAGE)) -#define IS_EDITOR_PAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), TYPE_EDITOR_PAGE)) - -typedef struct { - GtkObject object; -} EditorPage; - -typedef struct { - GtkObjectClass parent_class; - - /* Notification signals */ - - void (* changed) (EditorPage *page); - void (* summary_changed) (EditorPage *page); - void (* dtstart_changed) (EditorPage *page); - - /* Virtual methods */ - - GtkWidget *(* get_widget) (EditorPage *page); - - void (* fill_widgets) (EditorPage *page, CalComponent *comp); - void (* fill_component) (EditorPage *page, CalComponent *comp); - - void (* set_summary) (EditorPage *page, const char *summary); - char *(* get_summary) (EditorPage *page); - - void (* set_dtstart) (EditorPage *page, time_t start); -} EditorPageClass; - -GtkType editor_page_get_type (void); - -GtkWidget *editor_page_get_widget (EditorPage *page); - -void editor_page_fill_widgets (EditorPage *page, CalComponent *comp); -void editor_page_fill_component (EditorPage *page, CalComponent *comp); - -void editor_page_set_summary (EditorPage *page, const char *summary); -char *editor_page_get_summary (EditorPage *page); - -void editor_page_set_dtstart (EditorPage *page, time_t start); - -void editor_page_notify_changed (EditorPage *page); -void editor_page_notify_summary_changed (EditorPage *page); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c deleted file mode 100644 index f67b898dce..0000000000 --- a/calendar/gui/dialogs/event-page.c +++ /dev/null @@ -1,908 +0,0 @@ -/* Evolution calendar - Main page of the event editor dialog - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Miguel de Icaza - * Seth Alves - * JP Rosevear - * - * 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 -#endif - -#include -#include -#include -#include -#include -#include "cal-util/timeutil.h" -#include "e-util/e-dialog-widgets.h" -#include "widgets/misc/e-dateedit.h" -#include "../calendar-config.h" -#include "event-page.h" - - - -/* Private part of the EventPage structure */ -struct _EventPagePrivate { - /* Glade XML data */ - GladeXML *xml; - - /* Widgets from the Glade file */ - - GtkWidget *main; - - GtkWidget *summary; - - GtkWidget *start_time; - GtkWidget *end_time; - GtkWidget *all_day_event; - - GtkWidget *description; - - GtkWidget *classification_public; - GtkWidget *classification_private; - GtkWidget *classification_confidential; - - GtkWidget *contacts_btn; - GtkWidget *contacts; - - GtkWidget *categories_btn; - GtkWidget *categories; -}; - - - -static void event_page_class_init (EventPageClass *class); -static void event_page_init (EventPage *epage); -static void event_page_destroy (GtkObject *object); - -static GtkWidget *event_page_get_widget (EditorPage *page); -static void event_page_fill_widgets (EditorPage *page, CalComponent *comp); -static void event_page_fill_component (EditorPage *page, CalComponent *comp); -static void event_page_set_summary (EditorPage *page, const char *summary); -static char *event_page_get_summary (EditorPage *page); -static void event_page_set_dtstart (EditorPage *page, time_t start); - -/* Signal IDs */ -enum { - DATES_CHANGED, - LAST_SIGNAL -}; - -static guint event_page_signals[LAST_SIGNAL] = { 0 }; - -static EditorPageClass *parent_class = NULL; - - - -/** - * event_page_get_type: - * - * Registers the #EventPage class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #EventPage class. - **/ -GtkType -event_page_get_type (void) -{ - static GtkType event_page_type; - - if (!event_page_type) { - static const GtkTypeInfo event_page_info = { - "EventPage", - sizeof (EventPage), - sizeof (EventPageClass), - (GtkClassInitFunc) event_page_class_init, - (GtkObjectInitFunc) event_page_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - event_page_type = gtk_type_unique (TYPE_EDITOR_PAGE, &event_page_info); - } - - return event_page_type; -} - -/* Class initialization function for the event page */ -static void -event_page_class_init (EventPageClass *class) -{ - EditorPageClass *editor_page_class; - GtkObjectClass *object_class; - - editor_page_class = (EditorPageClass *) class; - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (TYPE_EDITOR_PAGE); - - event_page_signals[DATES_CHANGED] = - gtk_signal_new ("dates_changed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EventPageClass, dates_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, event_page_signals, LAST_SIGNAL); - - class->dates_changed = NULL; - - editor_page_class->get_widget = event_page_get_widget; - editor_page_class->fill_widgets = event_page_fill_widgets; - editor_page_class->fill_component = event_page_fill_component; - editor_page_class->set_summary = event_page_set_summary; - editor_page_class->get_summary = event_page_get_summary; - editor_page_class->set_dtstart = event_page_set_dtstart; - - object_class->destroy = event_page_destroy; -} - -/* Object initialization function for the event page */ -static void -event_page_init (EventPage *epage) -{ - EventPagePrivate *priv; - - priv = g_new0 (EventPagePrivate, 1); - epage->priv = priv; - - priv->xml = NULL; - - priv->main = NULL; - priv->summary = NULL; - priv->start_time = NULL; - priv->end_time = NULL; - priv->all_day_event = NULL; - priv->description = NULL; - priv->classification_public = NULL; - priv->classification_private = NULL; - priv->classification_confidential = NULL; - priv->contacts_btn = NULL; - priv->contacts = NULL; - priv->categories_btn = NULL; - priv->categories = NULL; -} - -/* Destroy handler for the event page */ -static void -event_page_destroy (GtkObject *object) -{ - EventPage *epage; - EventPagePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_EVENT_PAGE (object)); - - epage = EVENT_PAGE (object); - priv = epage->priv; - - if (priv->xml) { - gtk_object_unref (GTK_OBJECT (priv->xml)); - priv->xml = NULL; - } - - g_free (priv); - epage->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -static const int classification_map[] = { - CAL_COMPONENT_CLASS_PUBLIC, - CAL_COMPONENT_CLASS_PRIVATE, - CAL_COMPONENT_CLASS_CONFIDENTIAL, - -1 -}; - -/* get_widget handler for the event page */ -static GtkWidget * -event_page_get_widget (EditorPage *page) -{ - EventPage *epage; - EventPagePrivate *priv; - - epage = EVENT_PAGE (page); - priv = epage->priv; - - return priv->main; -} - -/* Checks if the event's time starts and ends at midnight, and sets the "all day - * event" box accordingly. - */ -static void -check_all_day (EventPage *epage) -{ - EventPagePrivate *priv; - time_t ev_start, ev_end; - gboolean all_day = FALSE; - - priv = epage->priv; - - /* Currently we just return if the date is not set or not valid. - I'm not entirely sure this is the corrent thing to do. */ - ev_start = e_date_edit_get_time (E_DATE_EDIT (priv->start_time)); - g_assert (ev_start != -1); - - ev_end = e_date_edit_get_time (E_DATE_EDIT (priv->end_time)); - g_assert (ev_end != -1); - - /* all day event checkbox */ - if (time_day_begin (ev_start) == ev_start && time_day_begin (ev_end) == ev_end) - all_day = TRUE; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->all_day_event), epage); - e_dialog_toggle_set (priv->all_day_event, all_day); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->all_day_event), epage); - - e_date_edit_set_show_time (E_DATE_EDIT (priv->start_time), !all_day); - e_date_edit_set_show_time (E_DATE_EDIT (priv->end_time), !all_day); -} - -/* Fills the widgets with default values */ -static void -clear_widgets (EventPage *epage) -{ - EventPagePrivate *priv; - time_t now; - - priv = epage->priv; - - now = time (NULL); - - /* Summary, description */ - e_dialog_editable_set (priv->summary, NULL); - e_dialog_editable_set (priv->description, NULL); - - /* Start and end times */ - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), epage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), epage); - - e_date_edit_set_time (E_DATE_EDIT (priv->start_time), now); - e_date_edit_set_time (E_DATE_EDIT (priv->end_time), now); - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), epage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), epage); - - check_all_day (epage); - - /* Classification */ - e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PRIVATE, classification_map); - - /* Categories */ - e_dialog_editable_set (priv->categories, NULL); -} - -/* fill_widgets handler for the event page */ -static void -event_page_fill_widgets (EditorPage *page, CalComponent *comp) -{ - EventPage *epage; - EventPagePrivate *priv; - CalComponentText text; - CalComponentClassification cl; - CalComponentDateTime d; - GSList *l; - time_t dtstart, dtend; - const char *categories; - - epage = EVENT_PAGE (page); - priv = epage->priv; - - clear_widgets (epage); - - /* Summary, description(s) */ - - cal_component_get_summary (comp, &text); - e_dialog_editable_set (priv->summary, text.value); - - cal_component_get_description_list (comp, &l); - if (l) { - text = *(CalComponentText *)l->data; - e_dialog_editable_set (priv->description, text.value); - } - cal_component_free_text_list (l); - - /* Start and end times */ - - /* All-day events are inclusive, i.e. if the end date shown is 2nd Feb - then the event includes all of the 2nd Feb. We would normally show - 3rd Feb as the end date, since it really ends at midnight on 3rd, - so we have to subtract a day so we only show the 2nd. */ - cal_component_get_dtstart (comp, &d); - dtstart = icaltime_as_timet (*d.value); - cal_component_free_datetime (&d); - - cal_component_get_dtend (comp, &d); - dtend = icaltime_as_timet (*d.value); - cal_component_free_datetime (&d); - - if (time_day_begin (dtstart) == dtstart && time_day_begin (dtend) == dtend) - dtend = time_add_day (dtend, -1); - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), epage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), epage); - - e_date_edit_set_time (E_DATE_EDIT (priv->start_time), dtstart); - e_date_edit_set_time (E_DATE_EDIT (priv->end_time), dtend); - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), epage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), epage); - - check_all_day (epage); - - /* Classification */ - - cal_component_get_classification (comp, &cl); - - switch (cl) { - case CAL_COMPONENT_CLASS_PUBLIC: - e_dialog_radio_set (priv->classification_public, CAL_COMPONENT_CLASS_PUBLIC, - classification_map); - break; - - case CAL_COMPONENT_CLASS_PRIVATE: - e_dialog_radio_set (priv->classification_public, CAL_COMPONENT_CLASS_PRIVATE, - classification_map); - break; - - case CAL_COMPONENT_CLASS_CONFIDENTIAL: - e_dialog_radio_set (priv->classification_public, CAL_COMPONENT_CLASS_CONFIDENTIAL, - classification_map); - break; - - default: - /* What do do? We can't g_assert_not_reached() since it is a - * value from an external file. - */ - } - - /* Categories */ - - cal_component_get_categories (comp, &categories); - e_dialog_editable_set (priv->categories, categories); -} - -/* fill_component handler for the event page */ -static void -event_page_fill_component (EditorPage *page, CalComponent *comp) -{ - EventPage *epage; - EventPagePrivate *priv; - CalComponentDateTime date; - struct icaltimetype icaltime; - time_t t; - gboolean all_day_event; - char *cat, *str; - CalComponentClassification classif; - - epage = EVENT_PAGE (page); - priv = epage->priv; - - /* Summary */ - - str = e_dialog_editable_get (priv->summary); - if (!str || strlen (str) == 0) - cal_component_set_summary (comp, NULL); - else { - CalComponentText text; - - text.value = str; - text.altrep = NULL; - - cal_component_set_summary (comp, &text); - } - - if (str) - g_free (str); - - /* Description */ - - str = e_dialog_editable_get (priv->description); - if (!str || strlen (str) == 0) - cal_component_set_description_list (comp, NULL); - else { - GSList l; - CalComponentText text; - - text.value = str; - text.altrep = NULL; - l.data = &text; - l.next = NULL; - - cal_component_set_description_list (comp, &l); - } - - if (str) - g_free (str); - - /* Dates */ - - date.value = &icaltime; - date.tzid = NULL; - - t = e_date_edit_get_time (E_DATE_EDIT (priv->start_time)); - if (t != -1) { - *date.value = icaltime_from_timet (t, FALSE); - cal_component_set_dtstart (comp, &date); - } else { - /* FIXME: What do we do here? */ - } - - /* If the all_day toggle is set, the end date is inclusive of the - entire day on which it points to. */ - all_day_event = e_dialog_toggle_get (priv->all_day_event); - t = e_date_edit_get_time (E_DATE_EDIT (priv->end_time)); - if (t != -1) { - if (all_day_event) - t = time_day_end (t); - - *date.value = icaltime_from_timet (t, FALSE); - cal_component_set_dtend (comp, &date); - } else { - /* FIXME: What do we do here? */ - } - - /* Categories */ - - cat = e_dialog_editable_get (priv->categories); - cal_component_set_categories (comp, cat); - - if (cat) - g_free (cat); - - /* Classification */ - - classif = e_dialog_radio_get (priv->classification_public, classification_map); - cal_component_set_classification (comp, classif); -} - -/* set_summary handler for the event page */ -static void -event_page_set_summary (EditorPage *page, const char *summary) -{ - EventPage *epage; - EventPagePrivate *priv; - - epage = EVENT_PAGE (page); - priv = epage->priv; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->summary), epage); - e_utf8_gtk_entry_set_text (GTK_ENTRY (priv->summary), summary); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->summary), epage); -} - -/* get_summary handler for the event page */ -static char * -event_page_get_summary (EditorPage *page) -{ - EventPage *epage; - EventPagePrivate *priv; - - epage = EVENT_PAGE (page); - priv = epage->priv; - - return e_utf8_gtk_entry_get_text (GTK_ENTRY (priv->summary)); -} - -/* set_dtstart handler for the event page. We do nothing since we are *the* - * only provider of the dtstart value. - */ -static void -event_page_set_dtstart (EditorPage *page, time_t start) -{ - /* nothing */ -} - - - -/* Gets the widgets from the XML file and returns if they are all available. */ -static gboolean -get_widgets (EventPage *epage) -{ - EventPagePrivate *priv; - GtkWidget *toplevel; - - priv = epage->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - toplevel = GW ("event-toplevel"); - priv->main = GW ("event-page"); - if (!(toplevel && priv->main)) - return FALSE; - - gtk_widget_ref (priv->main); - gtk_widget_unparent (priv->main); - gtk_widget_destroy (toplevel); - - priv->summary = GW ("summary"); - - priv->start_time = GW ("start-time"); - priv->end_time = GW ("end-time"); - priv->all_day_event = GW ("all-day-event"); - - priv->description = GW ("description"); - - priv->classification_public = GW ("classification-public"); - priv->classification_private = GW ("classification-private"); - priv->classification_confidential = GW ("classification-confidential"); - - priv->contacts_btn = GW ("contacts-button"); - priv->contacts = GW ("contacts"); - - priv->categories_btn = GW ("categories-button"); - priv->categories = GW ("categories"); - -#undef GW - - return (priv->summary - && priv->start_time - && priv->end_time - && priv->all_day_event - && priv->description - && priv->classification_public - && priv->classification_private - && priv->classification_confidential - && priv->contacts_btn - && priv->contacts - && priv->categories_btn - && priv->categories); -} - -/* Callback used when the summary changes; we emit the notification signal. */ -static void -summary_changed_cb (GtkEditable *editable, gpointer data) -{ - EventPage *epage; - - epage = EVENT_PAGE (data); - editor_page_notify_summary_changed (EDITOR_PAGE (epage)); -} - -/* Callback used when the start or end date widgets change. We check that the - * start date < end date and we set the "all day event" button as appropriate. - */ -static void -date_changed_cb (EDateEdit *dedit, gpointer data) -{ - EventPage *epage; - EventPagePrivate *priv; - time_t start, end; - struct tm tm_start, tm_end; - - epage = EVENT_PAGE (data); - priv = epage->priv; - - /* Ensure that start < end */ - - start = e_date_edit_get_time (E_DATE_EDIT (priv->start_time)); - g_assert (start != -1); - end = e_date_edit_get_time (E_DATE_EDIT (priv->end_time)); - g_assert (end != -1); - - if (start >= end) { - tm_start = *localtime (&start); - tm_end = *localtime (&end); - - if (start == end && tm_start.tm_hour == 0 - && tm_start.tm_min == 0 && tm_start.tm_sec == 0) { - /* If the start and end times are the same, but both are - * on day boundaries, then that is OK since it means we - * have an all-day event lasting 1 day. So we do - * nothing here. - */ - } else if (GTK_WIDGET (dedit) == priv->start_time) { - /* Modify the end time */ - - tm_end.tm_year = tm_start.tm_year; - tm_end.tm_mon = tm_start.tm_mon; - tm_end.tm_mday = tm_start.tm_mday; - tm_end.tm_hour = tm_start.tm_hour + 1; - tm_end.tm_min = tm_start.tm_min; - tm_end.tm_sec = tm_start.tm_sec; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), epage); - e_date_edit_set_time (E_DATE_EDIT (priv->end_time), mktime (&tm_end)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), epage); - } else if (GTK_WIDGET (dedit) == priv->end_time) { - /* Modify the start time */ - - tm_start.tm_year = tm_end.tm_year; - tm_start.tm_mon = tm_end.tm_mon; - tm_start.tm_mday = tm_end.tm_mday; - tm_start.tm_hour = tm_end.tm_hour - 1; - tm_start.tm_min = tm_end.tm_min; - tm_start.tm_sec = tm_end.tm_sec; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), epage); - e_date_edit_set_time (E_DATE_EDIT (priv->start_time), mktime (&tm_start)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), epage); - } else - g_assert_not_reached (); - } - - /* Set the "all day event" button as appropriate */ - check_all_day (epage); - - /* Notify upstream */ - gtk_signal_emit (GTK_OBJECT (epage), event_page_signals[DATES_CHANGED]); -} - -/* Callback: all day event button toggled. - * Note that this should only be called when the user explicitly toggles the - * button. Be sure to block this handler when the toggle button's state is set - * within the code. - */ -static void -all_day_event_toggled_cb (GtkWidget *toggle, gpointer data) -{ - EventPage *epage; - EventPagePrivate *priv; - struct tm start_tm, end_tm; - time_t start_t, end_t; - gboolean all_day; - - epage = EVENT_PAGE (data); - priv = epage->priv; - - /* When the all_day toggle is turned on, the start date is rounded down - * to the start of the day, and end date is rounded down to the start of - * the day on which the event ends. The event is then taken to be - * inclusive of the days between the start and end days. Note that if - * the event end is at midnight, we do not round it down to the previous - * day, since if we do that and the user repeatedly turns the all_day - * toggle on and off, the event keeps shrinking. (We'd also need to - * make sure we didn't adjust the time when the radio button is - * initially set.) - * - * When the all_day_toggle is turned off, we set the event start to the - * start of the working day, and if the event end is on or before the - * day of the event start we set it to one hour after the event start. - */ - all_day = GTK_TOGGLE_BUTTON (toggle)->active; - - /* - * Start time. - */ - start_t = e_date_edit_get_time (E_DATE_EDIT (priv->start_time)); - g_assert (start_t != -1); - - start_tm = *localtime (&start_t); - - if (all_day) { - /* Round down to the start of the day. */ - start_tm.tm_hour = 0; - start_tm.tm_min = 0; - start_tm.tm_sec = 0; - } else { - /* Set to the start of the working day. */ - start_tm.tm_hour = calendar_config_get_day_start_hour (); - start_tm.tm_min = calendar_config_get_day_start_minute (); - start_tm.tm_sec = 0; - } - - /* - * End time. - */ - end_t = e_date_edit_get_time (E_DATE_EDIT (priv->end_time)); - g_assert (end_t != -1); - - end_tm = *localtime (&end_t); - - if (all_day) { - /* Round down to the start of the day. */ - end_tm.tm_hour = 0; - end_tm.tm_min = 0; - end_tm.tm_sec = 0; - } else { - /* If the event end is now on or before the event start day, - * make it end one hour after the start. mktime() will fix any - * overflows. - */ - if (end_tm.tm_year < start_tm.tm_year - || (end_tm.tm_year == start_tm.tm_year - && end_tm.tm_mon < start_tm.tm_mon) - || (end_tm.tm_year == start_tm.tm_year - && end_tm.tm_mon == start_tm.tm_mon - && end_tm.tm_mday <= start_tm.tm_mday)) { - end_tm.tm_year = start_tm.tm_year; - end_tm.tm_mon = start_tm.tm_mon; - end_tm.tm_mday = start_tm.tm_mday; - end_tm.tm_hour = start_tm.tm_hour + 1; - } - } - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), epage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), epage); - - e_date_edit_set_time (E_DATE_EDIT (priv->start_time), mktime (&start_tm)); - e_date_edit_set_time (E_DATE_EDIT (priv->end_time), mktime (&end_tm)); - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), epage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), epage); - - e_date_edit_set_show_time (E_DATE_EDIT (priv->start_time), !all_day); - e_date_edit_set_show_time (E_DATE_EDIT (priv->end_time), !all_day); - - /* Notify upstream */ - gtk_signal_emit (GTK_OBJECT (epage), event_page_signals[DATES_CHANGED]); -} - -/* Callback used when the categories button is clicked; we must bring up the - * category list dialog. - */ -static void -categories_clicked_cb (GtkWidget *button, gpointer data) -{ - EventPage *epage; - EventPagePrivate *priv; - char *categories; - GnomeDialog *dialog; - int result; - GtkWidget *entry; - - epage = EVENT_PAGE (data); - priv = epage->priv; - - entry = priv->categories; - categories = e_utf8_gtk_entry_get_text (GTK_ENTRY (entry)); - - dialog = GNOME_DIALOG (e_categories_new (categories)); - result = gnome_dialog_run (dialog); - g_free (categories); - - if (result == 0) { - gtk_object_get (GTK_OBJECT (dialog), - "categories", &categories, - NULL); - e_utf8_gtk_entry_set_text (GTK_ENTRY (entry), categories); - g_free (categories); - } - - gtk_object_destroy (GTK_OBJECT (dialog)); -} - -/* This is called when any field is changed; it notifies upstream. */ -static void -field_changed_cb (GtkWidget *widget, gpointer data) -{ - EventPage *epage; - - epage = EVENT_PAGE (data); - editor_page_notify_changed (EDITOR_PAGE (epage)); -} - -/* Hooks the widget signals */ -static void -init_widgets (EventPage *epage) -{ - EventPagePrivate *priv; - - priv = epage->priv; - - /* Summary */ - gtk_signal_connect (GTK_OBJECT (priv->summary), "changed", - GTK_SIGNAL_FUNC (summary_changed_cb), epage); - - /* Start and end times */ - gtk_signal_connect (GTK_OBJECT (priv->start_time), "changed", - GTK_SIGNAL_FUNC (date_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->end_time), "changed", - GTK_SIGNAL_FUNC (date_changed_cb), epage); - - gtk_signal_connect (GTK_OBJECT (priv->all_day_event), "toggled", - GTK_SIGNAL_FUNC (all_day_event_toggled_cb), epage); - - /* Categories button */ - gtk_signal_connect (GTK_OBJECT (priv->categories_btn), "clicked", - GTK_SIGNAL_FUNC (categories_clicked_cb), epage); - - /* Connect the default signal handler to use to make sure we notify - * upstream of changes to the widget values. - */ - - gtk_signal_connect (GTK_OBJECT (priv->summary), "changed", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->start_time), "changed", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->end_time), "changed", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->all_day_event), "toggled", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->description), "changed", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->classification_public), "toggled", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->classification_private), "toggled", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->classification_confidential), "toggled", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - gtk_signal_connect (GTK_OBJECT (priv->categories), "changed", - GTK_SIGNAL_FUNC (field_changed_cb), epage); - - /* FIXME: we do not support these fields yet, so we disable them */ - - gtk_widget_set_sensitive (priv->contacts_btn, FALSE); - gtk_widget_set_sensitive (priv->contacts, FALSE); -} - - - -/** - * event_page_construct: - * @epage: An event page. - * - * Constructs an event page by loading its Glade data. - * - * Return value: The same object as @epage, or NULL if the widgets could not be - * created. - **/ -EventPage * -event_page_construct (EventPage *epage) -{ - EventPagePrivate *priv; - - priv = epage->priv; - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/event-page.glade", NULL); - if (!priv->xml) { - g_message ("event_page_construct(): Could not load the Glade XML file!"); - return NULL; - } - - if (!get_widgets (epage)) { - g_message ("event_page_construct(): Could not find all widgets in the XML file!"); - return NULL; - } - - init_widgets (epage); - - return epage; -} - -/** - * event_page_new: - * - * Creates a new event page. - * - * Return value: A newly-created event page, or NULL if the page could - * not be created. - **/ -EventPage * -event_page_new (void) -{ - EventPage *epage; - - epage = gtk_type_new (TYPE_EVENT_PAGE); - if (!event_page_construct (epage)) { - gtk_object_unref (GTK_OBJECT (epage)); - return NULL; - } - - return epage; -} diff --git a/calendar/gui/dialogs/event-page.glade b/calendar/gui/dialogs/event-page.glade deleted file mode 100644 index 76d2d4043e..0000000000 --- a/calendar/gui/dialogs/event-page.glade +++ /dev/null @@ -1,429 +0,0 @@ - - - - - event-page - event-page - - . - pixmaps - C - True - True - False - False - False - - - - GtkWindow - event-toplevel - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkVBox - event-page - 4 - False - 6 - - - GtkTable - table11 - 1 - 2 - False - 4 - 4 - - 0 - False - True - - - - GtkLabel - label56 - - GTK_JUSTIFY_CENTER - False - 7.45058e-09 - 0.5 - 0 - 0 - general-summary - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - general-summary - True - True - True - 0 - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - - GtkFrame - frame31 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - False - - - - GtkTable - table12 - 4 - 2 - 3 - False - 4 - 4 - - - GtkLabel - label57 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label58 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkCheckButton - all-day-event - True - - False - True - - 2 - 3 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - Custom - start-time - make_date_edit - - - 0 - 0 - Tue, 16 May 2000 19:11:05 GMT - - 1 - 2 - 0 - 1 - 0 - 0 - False - True - False - False - False - True - - - - - Custom - end-time - make_date_edit - 0 - 0 - Tue, 16 May 2000 19:11:10 GMT - - 1 - 2 - 1 - 2 - 0 - 0 - False - True - False - False - False - True - - - - - - - GtkScrolledWindow - scrolledwindow12 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkText - description - True - True - - - - - - GtkFrame - frame32 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - False - - - - GtkHBox - hbox52 - 2 - False - 4 - - - GtkRadioButton - classification-public - True - - True - True - classification_radio_group - - 0 - False - False - - - - - GtkRadioButton - classification-private - True - - False - True - classification_radio_group - - 0 - False - False - - - - - GtkRadioButton - classification-confidential - True - - False - True - classification_radio_group - - 0 - False - False - - - - - - - GtkHBox - hbox53 - False - 2 - - 0 - False - True - - - - GtkButton - contacts-button - True - GTK_RELIEF_NORMAL - - 0 - False - False - - - - GtkLabel - label59 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 4 - 0 - - - - - GtkEntry - contacts - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - categories-button - True - GTK_RELIEF_NORMAL - - 0 - False - False - - - - GtkLabel - label60 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 4 - 0 - - - - - GtkEntry - categories - True - True - True - 0 - - - 0 - True - True - - - - - - - diff --git a/calendar/gui/dialogs/event-page.h b/calendar/gui/dialogs/event-page.h deleted file mode 100644 index 85281b9800..0000000000 --- a/calendar/gui/dialogs/event-page.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Evolution calendar - Main page of the event editor dialog - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Miguel de Icaza - * Seth Alves - * JP Rosevear - * - * 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 EVENT_PAGE_H -#define EVENT_PAGE_H - -#include "editor-page.h" - -BEGIN_GNOME_DECLS - - - -#define TYPE_EVENT_PAGE (event_page_get_type ()) -#define EVENT_PAGE(obj) (GTK_CHECK_CAST ((obj), TYPE_EVENT_PAGE, EventPage)) -#define EVENT_PAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_EVENT_PAGE, \ - EventPageClass)) -#define IS_EVENT_PAGE(obj) (GTK_CHECK_TYPE ((obj), TYPE_EVENT_PAGE)) -#define IS_EVENT_PAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), TYPE_EVENT_PAGE)) - -typedef struct _EventPagePrivate EventPagePrivate; - -typedef struct { - EditorPage page; - - /* Private data */ - EventPagePrivate *priv; -} EventPage; - -typedef struct { - EditorPageClass parent_class; - - /* Notification signals */ - - void (* dates_changed) (EventPage *epage); -} EventPageClass; - -GtkType event_page_get_type (void); - -EventPage *event_page_construct (EventPage *epage); - -EventPage *event_page_new (void); - -time_t event_page_get_dtstart (EventPage *epage); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c deleted file mode 100644 index 0b0eace9cf..0000000000 --- a/calendar/gui/dialogs/recurrence-page.c +++ /dev/null @@ -1,900 +0,0 @@ -/* Evolution calendar - Recurrence page of the calendar component dialogs - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Miguel de Icaza - * Seth Alves - * JP Rosevear - * - * 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 -#endif - -#include -#include -#include -#include -#include -#include "e-util/e-dialog-widgets.h" -#include "recurrence-page.h" - - - -/* Private part of the RecurrencePage structure */ -struct _RecurrencePagePrivate { - /* Glade XML data */ - GladeXML *xml; - - /* Widgets from the Glade file */ - - GtkWidget *main; - - GtkWidget *summary; - GtkWidget *starting_date; - - GtkWidget *none; - GtkWidget *simple; - GtkWidget *custom; - - GtkWidget *params; - GtkWidget *interval_value; - GtkWidget *interval_unit; - GtkWidget *special; - GtkWidget *ending_menu; - GtkWidget *ending_special; - GtkWidget *custom_warning_bin; - - /* For weekly recurrences, created by hand */ - GtkWidget *weekday_picker; - guint8 weekday_day_mask; - guint8 weekday_blocked_day_mask; - - /* For monthly recurrences, created by hand */ - GtkWidget *month_index_spin; - int month_index; - - GtkWidget *month_day_menu; - enum month_day_options month_day; - - /* For ending date, created by hand */ - GtkWidget *ending_date_edit; - time_t ending_date; - - /* For ending count of occurrences, created by hand */ - GtkWidget *ending_count_spin; - int ending_count; - - /* More widgets from the Glade file */ - - GtkWidget *exception_date; - GtkWidget *exception_list; - GtkWidget *exception_add; - GtkWidget *exception_modify; - GtkWidget *exception_delete; - - GtkWidget *preview_bin; - - /* For the recurrence preview, the actual widget */ - GtkWidget *preview_calendar; -}; - - - -static void recurrence_page_class_init (RecurrencePageClass *class); -static void recurrence_page_init (RecurrencePage *rpage); -static void recurrence_page_destroy (RecurrencePage *rpage); - -static GtkWidget *recurrence_page_get_widget (EditorPage *page); -static void recurrence_page_fill_widgets (EditorPage *page, CalComponent *comp); -static void recurrence_page_fill_component (EditorPage *page, CalComponent *comp); -static void recurrence_page_set_summary (EditorPage *page, const char *summary); -static char *recurrence_page_get_summary (EditorPage *page); -static void recurrence_page_set_dtstart (EditorPage *page, time_t start); - -static EditorPageClass *parent_class = NULL; - - - -/** - * recurrence_page_get_type: - * - * Registers the #RecurrencePage class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #RecurrencePage class. - **/ -GtkType -recurrence_page_get_type (void) -{ - static GtkType recurrence_page_type; - - if (!recurrence_page_type) { - static const GtkTypeInfo recurrence_page_info = { - "RecurrencePage", - sizeof (RecurrencePage), - sizeof (RecurrencePageClass), - (GtkClassInitFunc) recurrence_page_class_init, - (GtkObjectInitFunc) recurrence_page_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - recurrence_page_type = gtk_type_unique (EDITOR_PAGE_TYPE, &recurrence_page_info); - } - - return recurrence_page_type; -} - -/* Class initialization function for the recurrence page */ -static void -recurrence_page_class_init (RecurrencePageClass *class) -{ - EditorPageClass *editor_page_class; - GtkObjectClass *object_class; - - editor_page_class = (EditorPageClass *) class; - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (EDITOR_PAGE_TYPE); - - editor_page_class->get_widget = recurrence_page_get_widget; - editor_page_class->fill_widgets = recurrence_page_fill_widgets; - editor_page_class->fill_component = recurrence_page_fill_component; - editor_page_class->set_summary = recurrence_page_set_summary; - editor_page_class->get_summary = recurrence_page_get_summary; - editor_page_class->set_dtstart = recurrence_page_set_dtstart; - - object_class->destroy = recurrence_page_destroy; -} - -/* Object initialization function for the recurrence page */ -static void -recurrence_page_init (RecurrencePage *rpage) -{ - RecurrencePagePrivate *priv; - - priv = g_new0 (RecurrencePagePrivate, 1); - rpage->priv = priv; - - priv->xml = NULL; - - priv->main = NULL; - priv->summary = NULL; - priv->starting_date = NULL; - priv->none = NULL; - priv->simple = NULL; - priv->custom = NULL; - priv->params = NULL; - priv->interval_value = NULL; - priv->interval_unit = NULL; - priv->special = NULL; - priv->ending_menu = NULL; - priv->ending_special = NULL; - priv->custom_warning_bin = NULL; - priv->weekday_picker = NULL; - priv->month_index_spin = NULL; - priv->month_day_menu = NULL; - priv->ending_date_edit = NULL; - priv->ending_count_spin = NULL; - priv->exception_date = NULL; - priv->exception_list = NULL; - priv->exception_add = NULL; - priv->exception_modify = NULL; - priv->exception_delete = NULL; - priv->preview_bin = NULL; - priv->preview_calendar = NULL; -} - -/* Frees the rows and the row data in the exceptions GtkCList */ -static void -free_exception_clist_data (RecurrencePage *rpage) -{ - RecurrencePagePrivate *priv; - GtkCList *clist; - int i; - - priv = rpage->priv; - - clist = GTK_CLIST (priv->exception_list); - - for (i = 0; i < clist->rows; i++) { - gpointer data; - - data = gtk_clist_get_row_data (clist, i); - g_free (data); - gtk_clist_set_row_data (clist, i, NULL); - } - - gtk_clist_clear (clist); -} - -/* Destroy handler for the recurrence page */ -static void -recurrence_page_destroy (GtkObject *object) -{ - RecurrencePage *rpage; - RecurrencePagePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_RECURRENCE_PAGE (object)); - - rpage = RECURRENCE_PAGE (object); - priv = rpage->priv; - - if (priv->xml) { - gtk_object_unref (GTK_OBJECT (priv->xml)); - priv->xml = NULL; - } - - free_exception_clist_data (rpage); - - g_free (priv); - rpage->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* get_widget handler for the recurrence page */ -static GtkWidget * -recurrence_page_get_widget (EditorPage *page) -{ - RecurrencePage *rpage; - RecurrencePagePrivate *priv; - - rpage = RECURRENCE_PAGE (page); - priv = rpage->priv; - - return priv->main; -} - -/* Fills the widgets with default values */ -static void -clear_widgets (RecurrencePage *rpage) -{ - RecurrencePagePrivate *priv; - - priv = rpage->priv; - - priv->weekday_day_mask = 0; - - priv->month_index = 1; - priv->month_day = MONTH_DAY_NTH; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->none), rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->simple), rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->custom), rpage); - e_dialog_radio_set (priv->none, RECUR_NONE, type_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->none), rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->simple), rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->custom), rpage); - - adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (priv->interval_value)); - gtk_signal_handler_block_by_data (GTK_OBJECT (adj), rpage); - e_dialog_spin_set (priv->interval_value, 1); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (adj), rpage); - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->interval_unit)); - gtk_signal_handler_block_by_data (GTK_OBJECT (menu), rpage); - e_dialog_option_menu_set (priv->interval_unit, ICAL_DAILY_RECURRENCE, freq_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (menu), rpage); - - priv->ending_date = time (NULL); - priv->ending_count = 1; - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->ending_menu)); - gtk_signal_handler_block_by_data (GTK_OBJECT (menu), rpage); - e_dialog_option_menu_set (priv->ending_menu, ENDING_FOREVER, ending_types_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (menu), rpage); - - /* Exceptions list */ - free_exception_clist_data (GTK_CLIST (priv->exception_list)); -} - -/* Builds a static string out of an exception date */ -static char * -get_exception_string (time_t t) -{ - static char buf[256]; - - strftime (buf, sizeof (buf), _("%a %b %d %Y"), localtime (&t)); - return buf; -} - -/* Appends an exception date to the list */ -static void -append_exception (RecurrencePage *rpage, time_t t) -{ - RecurrencePagePrivate *priv; - time_t *tt; - char *c[1]; - int i; - GtkCList *clist; - - priv = rpage->priv; - - tt = g_new (time_t, 1); - *tt = t; - - clist = GTK_CLIST (priv->exception_list); - - gtk_signal_handler_block_by_data (GTK_OBJECT (clist), rpage); - - c[0] = get_exception_string (t); - i = gtk_clist_append (clist, c); - - gtk_clist_set_row_data (clist, i, tt); - - gtk_clist_select_row (clist, i, 0); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (clist), rpage); - - e_date_edit_set_time (E_DATE_EDIT (priv->exception_date), t); - - gtk_widget_set_sensitive (priv->exception_modify, TRUE); - gtk_widget_set_sensitive (priv->exception_delete, TRUE); -} - -/* Fills in the exception widgets with the data from the calendar component */ -static void -fill_exception_widgets (RecurrencePage *rpage, CalComponent *comp) -{ - RecurrencePagePrivate *priv; - GSList *list, *l; - gboolean added; - - priv = rpage->priv; - - cal_component_get_exdate_list (comp, &list); - - added = FALSE; - - for (l = list; l; l = l->next) { - CalComponentDateTime *cdt; - time_t ext; - - added = TRUE; - - cdt = l->data; - ext = icaltime_as_timet (*cdt->value); - append_exception (rpage, ext); - } - - cal_component_free_exdate_list (list); - - if (added) - gtk_clist_select_row (GTK_CLIST (priv->exception_list), 0, 0); -} - -/* Computes a weekday mask for the start day of a calendar component, for use in - * a WeekdayPicker widget. - */ -static guint8 -get_start_weekday_mask (CalComponent *comp) -{ - CalComponentDateTime dt; - guint8 retval; - - cal_component_get_dtstart (comp, &dt); - - if (dt.value) { - time_t t; - struct tm tm; - - t = icaltime_as_timet (*dt.value); - tm = *localtime (&t); - - retval = 0x1 << tm.tm_wday; - } else - retval = 0; - - cal_component_free_datetime (&dt); - - return retval; -} - -/* Sets some sane defaults for the data sources for the recurrence special - * widgets, even if they will not be used immediately. - */ -static void -set_special_defaults (RecurrencePage *rpage) -{ - RecurrencePagePrivate *priv; - guint8 mask; - - priv = rpage->priv; - - mask = get_start_weekday_mask (priv->comp); - - priv->weekday_day_mask = mask; - priv->weekday_blocked_day_mask = mask; -} - -/* Sensitizes the recurrence widgets based on the state of the recurrence type - * radio group. - */ -static void -sensitize_recur_widgets (RecurrencePage *rpage) -{ - RecurrencePagePrivate *priv; - enum recur_type type; - GtkWidget *label; - - priv = rpage->priv; - - type = e_dialog_radio_get (priv->none, type_map); - - if (GTK_BIN (priv->custom_warning_bin)->child) - gtk_widget_destroy (GTK_BIN (priv->custom_warning_bin)->child); - - switch (type) { - case RECUR_NONE: - gtk_widget_set_sensitive (priv->params, FALSE); - gtk_widget_show (priv->params); - gtk_widget_hide (priv->custom_warning_bin); - break; - - case RECUR_SIMPLE: - gtk_widget_set_sensitive (priv->params, TRUE); - gtk_widget_show (priv->params); - gtk_widget_hide (priv->custom_warning_bin); - break; - - case RECUR_CUSTOM: - gtk_widget_set_sensitive (priv->params, FALSE); - gtk_widget_hide (priv->params); - - label = gtk_label_new (_("This appointment contains recurrences that Evolution " - "cannot edit.")); - gtk_container_add (GTK_CONTAINER (priv->custom_warning_bin), label); - gtk_widget_show_all (priv->custom_warning_bin); - break; - - default: - g_assert_not_reached (); - } -} - -/* Re-tags the recurrence preview calendar based on the current information of - * the widgets in the recurrence page. - */ -static void -preview_recur (RecurrencePage *rpage) -{ - RecurrencePagePrivate *priv; - CalComponent *comp; - CalComponentDateTime cdt; - GSList *l; - - priv = rpage->priv; - g_assert (priv->comp != NULL); - - /* Create a scratch component with the start/end and - * recurrence/excepttion information from the one we are editing. - */ - - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - - cal_component_get_dtstart (priv->comp, &cdt); - cal_component_set_dtstart (comp, &cdt); - cal_component_free_datetime (&cdt); - - cal_component_get_dtend (priv->comp, &cdt); - cal_component_set_dtend (comp, &cdt); - cal_component_free_datetime (&cdt); - - cal_component_get_exdate_list (priv->comp, &l); - cal_component_set_exdate_list (comp, l); - cal_component_free_exdate_list (l); - - cal_component_get_exrule_list (priv->comp, &l); - cal_component_set_exrule_list (comp, l); - cal_component_free_recur_list (l); - - cal_component_get_rdate_list (priv->comp, &l); - cal_component_set_rdate_list (comp, l); - cal_component_free_period_list (l); - - cal_component_get_rrule_list (priv->comp, &l); - cal_component_set_rrule_list (comp, l); - cal_component_free_recur_list (l); - - recur_to_comp_object (rpage, comp); - - tag_calendar_by_comp (E_CALENDAR (priv->preview_calendar), comp); - gtk_object_unref (GTK_OBJECT (comp)); -} - -/* fill_widgets handler for the recurrence page. This function is particularly - * tricky because it has to discriminate between recurrences we support for - * editing and the ones we don't. We only support at most one recurrence rule; - * no rdates or exrules (exdates are handled just fine elsewhere). - */ -static void -recurrence_page_fill_widgets (EditorPage *page, CalComponent *comp) -{ - RecurrencePage *rpage; - RecurrencePagePrivate *priv; - GSList *rrule_list; - int len; - struct icalrecurrencetype *r; - int n_by_second, n_by_minute, n_by_hour; - int n_by_day, n_by_month_day, n_by_year_day; - int n_by_week_no, n_by_month, n_by_set_pos; - GtkWidget *menu; - GtkAdjustment *adj; - - rpage = RECURRENCE_PAGE (page); - priv = rpage->priv; - - clear_widgets (rpage); - - fill_exception_widgets (rpage, comp); - - /* Set up defaults for the special widgets */ - set_special_defaults (rpage); - - /* No recurrences? */ - - if (!cal_component_has_rdates (comp) - && !cal_component_has_rrules (comp) - && !cal_component_has_exrules (comp)) { - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->none), rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->simple), rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->custom), rpage); - e_dialog_radio_set (priv->none, RECUR_NONE, type_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->none), rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->simple), rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->custom), rpage); - - gtk_widget_set_sensitive (priv->custom, FALSE); - - sensitize_recur_widgets (rpage); - preview_recur (rpage); - return; - } - - /* See if it is a custom set we don't support */ - - cal_component_get_rrule_list (comp, &rrule_list); - len = g_slist_length (rrule_list); - if (len > 1 - || cal_component_has_rdates (comp) - || cal_component_has_exrules (comp)) - goto custom; - - /* Down to one rule, so test that one */ - - g_assert (len == 1); - r = rrule_list->data; - - /* Any funky frequency? */ - - if (r->freq == ICAL_SECONDLY_RECURRENCE - || r->freq == ICAL_MINUTELY_RECURRENCE - || r->freq == ICAL_HOURLY_RECURRENCE) - goto custom; - - /* Any funky shit? */ - -#define N_HAS_BY(field) (count_by_xxx (field, sizeof (field) / sizeof (field[0]))) - - n_by_second = N_HAS_BY (r->by_second); - n_by_minute = N_HAS_BY (r->by_minute); - n_by_hour = N_HAS_BY (r->by_hour); - n_by_day = N_HAS_BY (r->by_day); - n_by_month_day = N_HAS_BY (r->by_month_day); - n_by_year_day = N_HAS_BY (r->by_year_day); - n_by_week_no = N_HAS_BY (r->by_week_no); - n_by_month = N_HAS_BY (r->by_month); - n_by_set_pos = N_HAS_BY (r->by_set_pos); - - if (n_by_second != 0 - || n_by_minute != 0 - || n_by_hour != 0) - goto custom; - - /* Filter the funky shit based on the frequency; if there is nothing - * weird we can actually set the widgets. - */ - - switch (r->freq) { - case ICAL_DAILY_RECURRENCE: - if (n_by_day != 0 - || n_by_month_day != 0 - || n_by_year_day != 0 - || n_by_week_no != 0 - || n_by_month != 0 - || n_by_set_pos != 0) - goto custom; - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->interval_unit)); - gtk_signal_handler_block_by_data (GTK_OBJECT (menu), rpage); - e_dialog_option_menu_set (priv->interval_unit, ICAL_DAILY_RECURRENCE, freq_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (menu), rpage); - break; - - case ICAL_WEEKLY_RECURRENCE: { - int i; - guint8 day_mask; - - if (n_by_month_day != 0 - || n_by_year_day != 0 - || n_by_week_no != 0 - || n_by_month != 0 - || n_by_set_pos != 0) - goto custom; - - day_mask = 0; - - for (i = 0; i < 8 && r->by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) { - enum icalrecurrencetype_weekday weekday; - int pos; - - weekday = icalrecurrencetype_day_day_of_week (r->by_day[i]); - pos = icalrecurrencetype_day_position (r->by_day[i]); - - if (pos != 0) - goto custom; - - switch (weekday) { - case ICAL_SUNDAY_WEEKDAY: - day_mask |= 1 << 0; - break; - - case ICAL_MONDAY_WEEKDAY: - day_mask |= 1 << 1; - break; - - case ICAL_TUESDAY_WEEKDAY: - day_mask |= 1 << 2; - break; - - case ICAL_WEDNESDAY_WEEKDAY: - day_mask |= 1 << 3; - break; - - case ICAL_THURSDAY_WEEKDAY: - day_mask |= 1 << 4; - break; - - case ICAL_FRIDAY_WEEKDAY: - day_mask |= 1 << 5; - break; - - case ICAL_SATURDAY_WEEKDAY: - day_mask |= 1 << 6; - break; - - default: - break; - } - } - - priv->weekday_day_mask = day_mask; - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->interval_unit)); - gtk_signal_handler_block_by_data (GTK_OBJECT (menu), rpage); - e_dialog_option_menu_set (priv->interval_unit, ICAL_WEEKLY_RECURRENCE, freq_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (menu), rpage); - break; - } - - case ICAL_MONTHLY_RECURRENCE: - if (n_by_year_day != 0 - || n_by_week_no != 0 - || n_by_month != 0 - || n_by_set_pos != 0) - goto custom; - - if (n_by_month_day == 1) { - int nth; - - nth = r->by_month_day[0]; - if (nth < 1) - goto custom; - - priv->month_index = nth; - priv->month_day = MONTH_DAY_NTH; - } else if (n_by_day == 1) { - enum icalrecurrencetype_weekday weekday; - int pos; - enum month_day_options month_day; - - weekday = icalrecurrencetype_day_day_of_week (r->by_day[0]); - pos = icalrecurrencetype_day_position (r->by_day[0]); - - if (pos < 1) - goto custom; - - switch (weekday) { - case ICAL_MONDAY_WEEKDAY: - month_day = MONTH_DAY_MON; - break; - - case ICAL_TUESDAY_WEEKDAY: - month_day = MONTH_DAY_TUE; - break; - - case ICAL_WEDNESDAY_WEEKDAY: - month_day = MONTH_DAY_WED; - break; - - case ICAL_THURSDAY_WEEKDAY: - month_day = MONTH_DAY_THU; - break; - - case ICAL_FRIDAY_WEEKDAY: - month_day = MONTH_DAY_FRI; - break; - - case ICAL_SATURDAY_WEEKDAY: - month_day = MONTH_DAY_SAT; - break; - - case ICAL_SUNDAY_WEEKDAY: - month_day = MONTH_DAY_SUN; - break; - - default: - goto custom; - } - - priv->month_index = pos; - priv->month_day = month_day; - } else - goto custom; - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->interval_unit)); - gtk_signal_handler_block_by_data (GTK_OBJECT (menu), rpage); - e_dialog_option_menu_set (priv->interval_unit, ICAL_MONTHLY_RECURRENCE, freq_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (menu), rpage); - break; - - case ICAL_YEARLY_RECURRENCE: - if (n_by_day != 0 - || n_by_month_day != 0 - || n_by_year_day != 0 - || n_by_week_no != 0 - || n_by_month != 0 - || n_by_set_pos != 0) - goto custom; - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->interval_unit)); - gtk_signal_handler_block_by_data (GTK_OBJECT (menu), rpage); - e_dialog_option_menu_set (priv->interval_unit, ICAL_YEARLY_RECURRENCE, freq_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (menu), rpage); - break; - - default: - goto custom; - } - - /* If we got here it means it is a simple recurrence */ - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->none), rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->simple), rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->custom), rpage); - e_dialog_radio_set (priv->simple, RECUR_SIMPLE, type_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->none), rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->simple), rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->custom), rpage); - - gtk_widget_set_sensitive (priv->custom, FALSE); - - sensitize_recur_widgets (rpage); - make_recurrence_special (rpage); - - adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (priv->interval_value)); - gtk_signal_handler_block_by_data (GTK_OBJECT (adj), rpage); - e_dialog_spin_set (priv->interval_value, r->interval); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (adj), rpage); - - fill_ending_date (rpage, r); - - goto out; - - custom: - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->none), rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->simple), rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->custom), rpage); - e_dialog_radio_set (priv->custom, RECUR_CUSTOM, type_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->none), rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->simple), rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->custom), rpage); - - gtk_widget_set_sensitive (priv->custom, TRUE); - sensitize_recur_widgets (rpage); - - out: - - cal_component_free_recur_list (rrule_list); - preview_recur (rpage); -} - - - -/* Gets the widgets from the XML file and returns if they are all available. */ -static gboolean -get_widgets (RecurrencePage *rpage) -{ - RecurrencePagePrivate *priv; - GtkWidget *toplevel; - - priv = rpage->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - toplevel = GW ("recurrence-toplevel"); - priv->main = GW ("recurrence-page"); - if (!(toplevel && priv->main)) - return NULL; - - gtk_widget_ref (priv->main); - gtk_widget_unparent (priv->main); - gtk_widget_destroy (toplevel); - - priv->summary = GW ("summary"); - priv->starting_date = GW ("starting-date"); - - priv->none = GW ("none"); - priv->simple = GW ("simple"); - priv->custom = GW ("custom"); - priv->params = GW ("params"); - - priv->interval_value = GW ("interval-value"); - priv->interval_unit = GW ("interval-unit"); - priv->special = GW ("special"); - priv->ending_menu = GW ("ending-menu"); - priv->ending_special = GW ("ending-special"); - priv->custom_warning_bin = GW ("custom-warning-bin"); - - priv->exception_date = GW ("exception-date"); - priv->exception_list = GW ("exception-list"); - priv->exception_add = GW ("exception-add"); - priv->exception_modify = GW ("exception-modify"); - priv->exception_delete = GW ("exception-delete"); - - priv->preview_bin = GW ("preview-bin"); - -#undef GW - - return (priv->summary - && priv->starting_date - && priv->none - && priv->simple - && priv->custom - && priv->params - && priv->interval_value - && priv->interval_unit - && priv->special - && priv->ending_menu - && priv->ending_special - && priv->custom_warning_bin - && priv->exception_date - && priv->exception_list - && priv->exception_add - && priv->exception_modify - && priv->exception_delete - && priv->preview_bin); -} diff --git a/calendar/gui/dialogs/recurrence-page.glade b/calendar/gui/dialogs/recurrence-page.glade deleted file mode 100644 index b84a3c288c..0000000000 --- a/calendar/gui/dialogs/recurrence-page.glade +++ /dev/null @@ -1,607 +0,0 @@ - - - - - recurrence-page - recurrence-page - - . - pixmaps - C - True - True - False - False - False - - - - GtkWindow - recurrence-toplevel - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkVBox - recurrence-page - 4 - False - 4 - - - GtkFrame - frame35 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - False - - - - GtkTable - table14 - 4 - 2 - 2 - False - 2 - 2 - - - GtkLabel - label66 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - recurrence-summary - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label67 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - recurrence-summary - True - True - True - 0 - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - True - False - True - False - - - - - GtkAlignment - alignment40 - 0 - 0.5 - 0 - 0 - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - Custom - recurrence-starting-date - make_date_edit - 0 - 0 - Fri, 22 Sep 2000 20:51:38 GMT - - - - - - - GtkVBox - vbox55 - False - 4 - - 0 - True - True - - - - GtkFrame - frame36 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - False - - - - GtkVBox - vbox56 - 4 - False - 4 - - - GtkHBox - hbox56 - False - 4 - - 0 - False - False - - - - GtkRadioButton - recurrence-none - True - - False - True - recurrence-radio - - 0 - False - False - - - - - GtkRadioButton - recurrence-simple - True - - False - True - recurrence-radio - - 0 - False - False - - - - - GtkRadioButton - recurrence-custom - True - - False - True - recurrence-radio - - 0 - False - False - - - - - - GtkHBox - hbox57 - False - 0 - - 0 - False - False - - - - GtkHBox - recurrence-params - False - 2 - - 0 - False - False - - - - GtkLabel - label68 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkSpinButton - recurrence-interval-value - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 - 1 - 10000 - 1 - 10 - 10 - - 0 - False - False - - - - - GtkOptionMenu - recurrence-interval-unit - True - day(s) -week(s) -month(s) -year(s) - - 0 - - 0 - False - False - - - - - GtkAlignment - recurrence-special - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - Placeholder - - - - - GtkOptionMenu - recurrence-ending-menu - True - for -until -forever - - 0 - - 0 - False - False - - - - - GtkAlignment - recurrence-ending-special - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - Placeholder - - - - - - GtkAlignment - recurrence-custom-warning-bin - 0 - 0.5 - 1 - 1 - - 0 - True - True - - - - Placeholder - - - - - - - - GtkHBox - hbox59 - False - 4 - - 0 - True - True - - - - GtkFrame - frame37 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox60 - 4 - False - 4 - - - GtkVBox - vbox57 - False - 4 - - 0 - False - False - - - - GtkButton - recurrence-exception-add - True - - GTK_RELIEF_NORMAL - - 0 - False - False - - - - - GtkButton - recurrence-exception-modify - True - - GTK_RELIEF_NORMAL - - 0 - False - False - - - - - GtkButton - recurrence-exception-delete - True - - GTK_RELIEF_NORMAL - - 0 - False - False - - - - - - GtkVBox - vbox58 - False - 4 - - 0 - True - True - - - - Custom - recurrence-exception-date - make_date_edit - 0 - 0 - Tue, 16 May 2000 01:42:29 GMT - - 0 - False - False - - - - - GtkScrolledWindow - scrolledwindow14 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - recurrence-exception-list - True - 1 - 80 - GTK_SELECTION_BROWSE - False - GTK_SHADOW_IN - - - GtkLabel - CList:title - label69 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - - - - GtkVBox - vbox59 - False - 0 - - 0 - False - False - - - - GtkLabel - label70 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkAlignment - recurrence-preview-bin - 0 - 0 - 1 - 1 - - 0 - True - True - - - - Placeholder - - - - - - - - - diff --git a/calendar/gui/dialogs/recurrence-page.h b/calendar/gui/dialogs/recurrence-page.h deleted file mode 100644 index 39123644b4..0000000000 --- a/calendar/gui/dialogs/recurrence-page.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Evolution calendar - Recurrence page of the calendar component dialogs - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Miguel de Icaza - * Seth Alves - * JP Rosevear - * - * 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 RECURRENCE_PAGE_H -#define RECURRENCE_PAGE_H - -#include "editor-page.h" - -BEGIN_GNOME_DECLS - - - -#define TYPE_RECURRENCE_PAGE (recurrence_page_get_type ()) -#define RECURRENCE_PAGE(obj) (GTK_CHECK_CAST ((obj), TYPE_RECURRENCE_PAGE, RecurrencePage)) -#define RECURRENCE_PAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_RECURRENCE_PAGE, \ - RecurrencePageClass)) -#define IS_RECURRENCE_PAGE(obj) (GTK_CHECK_TYPE ((obj), TYPE_RECURRENCE_PAGE)) -#define IS_RECURRENCE_PAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), TYPE_RECURRENCE_PAGE)) - -typedef struct _RecurrencePagePrivate RecurrencePagePrivate; - -typedef struct { - EditorPage page; - - /* Private data */ - RecurrencePagePrivate *priv; -} RecurrencePage; - -typedef struct { - EditorPageClass parent_class; -} RecurrencePageClass; - -GtkType recurrence_page_get_type (void); - -RecurrencePage *recurrence_page_construct (RecurrencePage *rpage); - -RecurrencePage *recurrence_page_new (void); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/dialogs/save-comp.c b/calendar/gui/dialogs/save-comp.c deleted file mode 100644 index c36e98cb5a..0000000000 --- a/calendar/gui/dialogs/save-comp.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Evolution calendar - Delete calendar component dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * 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 -#endif - -#include -#include -#include -#include -#include -#include -#include "save-comp.h" - - - -/** - * save_component_dialog: - * @parent: Window to use as the transient dialog's parent. - * - * Pops up a dialog box asking the user whether he wants to save changes for - * a calendar component. - * - * Return value: TRUE if changes shold be saved, FALSE otherwise. - **/ -gint -save_component_dialog (GtkWindow *parent) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new (_("Do you want to save changes?"), - GNOME_MESSAGE_BOX_QUESTION, - GNOME_STOCK_BUTTON_YES, - GNOME_STOCK_BUTTON_NO, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - - gnome_dialog_set_default (GNOME_DIALOG (dialog), 0); - gnome_dialog_grab_focus (GNOME_DIALOG (dialog), 0); - gnome_dialog_set_parent (GNOME_DIALOG (dialog), parent); - - return gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); -} diff --git a/calendar/gui/dialogs/save-comp.h b/calendar/gui/dialogs/save-comp.h deleted file mode 100644 index 8b1db3c503..0000000000 --- a/calendar/gui/dialogs/save-comp.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Evolution calendar - Delete calendar component dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * 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 SAVE_COMP_H -#define SAVE_COMP_H - -#include - -gint save_component_dialog (GtkWindow *parent); - -#endif diff --git a/calendar/gui/dialogs/task-details-page.glade b/calendar/gui/dialogs/task-details-page.glade deleted file mode 100644 index 31e3aba6c4..0000000000 --- a/calendar/gui/dialogs/task-details-page.glade +++ /dev/null @@ -1,137 +0,0 @@ - - - - - task-details-page - task-details-page - - src - pixmaps - C - True - True - - - - GtkWindow - task-details-toplevel - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkTable - task-details-page - 4 - 2 - 2 - False - 2 - 4 - - - GtkLabel - label12 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label14 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - url - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - Custom - completed-date - task_editor_create_date_edit - 0 - 0 - Sun, 10 Sep 2000 17:34:07 GMT - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - - diff --git a/calendar/gui/dialogs/task-editor-dialog.glade b/calendar/gui/dialogs/task-editor-dialog.glade deleted file mode 100644 index ae7ea9681a..0000000000 --- a/calendar/gui/dialogs/task-editor-dialog.glade +++ /dev/null @@ -1,695 +0,0 @@ - - - - - task-editor-dialog - task-editor-dialog - - src - pixmaps - C - True - True - - - - GnomePropertyBox - task-editor-dialog - False - GTK_WIN_POS_NONE - False - False - False - False - - - GtkNotebook - GnomeDock:contents - notebook1 - 2 - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - - GtkVBox - vbox1 - 4 - False - 4 - - - GtkTable - table3 - 1 - 2 - False - 4 - 4 - - 0 - False - True - - - - GtkLabel - label3 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - summary - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - False - False - - - - - GtkEntry - summary - True - True - True - 0 - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - - GtkFrame - frame2 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkHBox - hbox4 - 4 - False - 0 - - - GtkTable - table1 - 2 - 2 - False - 2 - 4 - - 0 - False - True - - - - GtkLabel - label6 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - Custom - due-date - task_editor_create_date_edit - 0 - 0 - Sun, 10 Sep 2000 17:32:18 GMT - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - Custom - start-date - task_editor_create_date_edit - 0 - 0 - Sun, 10 Sep 2000 17:33:31 GMT - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - - - - GtkScrolledWindow - scrolledwindow1 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - False - True - - - - GtkText - description - 80 - True - True - - - - - - GtkFrame - frame23 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkHBox - hbox3 - 4 - False - 4 - - - GtkLabel - label7 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - status - - 0 - False - False - - - - - GtkOptionMenu - status - True - Not Started -In Progress -Completed -Cancelled - - 0 - - 0 - False - False - - - - - GtkLabel - label8 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - priority - - 0 - False - False - - - - - GtkOptionMenu - priority - True - High -Normal -Low -Undefined - - 0 - - 0 - False - False - - - - - GtkLabel - label9 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - percent-complete - - 0 - False - False - - - - - GtkSpinButton - percent-complete - 60 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 0 - 0 - 100 - 10 - 10 - 10 - - 0 - False - False - - - - - - - GtkFrame - frame24 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkHBox - hbox6 - 2 - False - 4 - - - GtkRadioButton - classification-public - True - - True - True - classification_radio_group - - 0 - False - False - - - - - GtkRadioButton - classification-private - True - - False - True - classification_radio_group - - 0 - False - False - - - - - GtkRadioButton - classification-confidential - True - - False - True - classification_radio_group - - 0 - False - False - - - - - - - GtkHBox - hbox2 - False - 2 - - 0 - True - True - - - - GtkButton - contacts-button - True - - 0 - False - False - - - - GtkLabel - label16 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 4 - 0 - - - - - GtkEntry - contacts - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - categories-button - True - - 0 - False - False - - - - GtkLabel - label17 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 4 - 0 - - - - - GtkEntry - categories - True - True - True - 0 - - - 0 - True - True - - - - - - - GtkLabel - Notebook:tab - label1 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkTable - table4 - 4 - 2 - 2 - False - 2 - 4 - - - GtkLabel - label12 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label14 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - url - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - Custom - completed-date - task_editor_create_date_edit - 0 - 0 - Sun, 10 Sep 2000 17:34:07 GMT - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - - GtkLabel - Notebook:tab - label2 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c deleted file mode 100644 index b21de4bd32..0000000000 --- a/calendar/gui/dialogs/task-editor.c +++ /dev/null @@ -1,1294 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin - * - * Copyright 2000, Helix Code, Inc. - * Copyright 2000, Ximian, Inc. - * - * 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 - */ - -/* - * TaskEditor - a GtkObject which handles a libglade-loaded dialog to edit - * tasks. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "delete-comp.h" -#include "save-comp.h" -#include "task-editor.h" -#include "../calendar-config.h" -#include "../widget-util.h" - - -typedef struct { - /* Glade XML data */ - GladeXML *xml; - - /* Client to use */ - CalClient *client; - - /* Calendar component we are editing; this is an internal copy and is - * not one of the read-only objects from the parent calendar. - */ - CalComponent *comp; - - - /* This is TRUE while we are setting the widget values. We just return - from any signal handlers. */ - gboolean ignore_callbacks; - - /* Widgets from the Glade file */ - - GtkWidget *app; - - GtkWidget *summary; - - GtkWidget *due_date; - GtkWidget *start_date; - - GtkWidget *percent_complete; - - GtkWidget *status; - GtkWidget *priority; - - GtkWidget *description; - - GtkWidget *classification_public; - GtkWidget *classification_private; - GtkWidget *classification_confidential; - - GtkWidget *contacts_btn; - GtkWidget *contacts; - - GtkWidget *categories_btn; - GtkWidget *categories; - - GtkWidget *completed_date; - GtkWidget *url; - - /* Call task_editor_set_changed() to set this to TRUE when any field - in the dialog is changed. When the user closes the dialog we will - prompt to save changes. */ - gboolean changed; -} TaskEditorPrivate; - - -/* Note that these two arrays must match. */ -static const int status_map[] = { - ICAL_STATUS_NEEDSACTION, - ICAL_STATUS_INPROCESS, - ICAL_STATUS_COMPLETED, - ICAL_STATUS_CANCELLED, - -1 -}; - -typedef enum { - PRIORITY_HIGH, - PRIORITY_NORMAL, - PRIORITY_LOW, - PRIORITY_UNDEFINED, -} TaskEditorPriority; - -static const int priority_map[] = { - PRIORITY_HIGH, - PRIORITY_NORMAL, - PRIORITY_LOW, - PRIORITY_UNDEFINED, - -1 -}; - -static const int classification_map[] = { - CAL_COMPONENT_CLASS_PUBLIC, - CAL_COMPONENT_CLASS_PRIVATE, - CAL_COMPONENT_CLASS_CONFIDENTIAL, - -1 -}; - -static void task_editor_class_init (TaskEditorClass *class); -static void task_editor_init (TaskEditor *tedit); -static void tedit_apply_event_cb (GtkWidget *widget, gint page_num, gpointer data); -static gint tedit_close_event_cb (GtkWidget *widget, gpointer data); -static gint tedit_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data); -static void close_dialog (TaskEditor *tedit); -static gboolean get_widgets (TaskEditor *tedit); -static void init_widgets (TaskEditor *tedit); -static void task_editor_destroy (GtkObject *object); -static char * make_title_from_comp (CalComponent *comp); -static void set_title_from_comp (TaskEditor *tedit, CalComponent *comp); -static void clear_widgets (TaskEditor *tedit); -static void fill_widgets (TaskEditor *tedit); - -static void save_todo_object (TaskEditor *tedit); -static void dialog_to_comp_object (TaskEditor *tedit); - -static void obj_updated_cb (CalClient *client, const char *uid, gpointer data); -static void obj_removed_cb (CalClient *client, const char *uid, gpointer data); -static void raise_and_focus (GtkWidget *widget); - -static TaskEditorPriority priority_value_to_index (int priority_value); -static int priority_index_to_value (TaskEditorPriority priority); - -static void completed_changed (EDateEdit *dedit, - TaskEditor *tedit); -static void status_changed (GtkMenu *menu, - TaskEditor *tedit); -static void percent_complete_changed (GtkAdjustment *adj, - TaskEditor *tedit); -static void field_changed (GtkWidget *widget, - TaskEditor *tedit); -static void task_editor_set_changed (TaskEditor *tedit, - gboolean changed); -static gboolean prompt_to_save_changes (TaskEditor *tedit); -static CalComponentClassification classification_get (GtkWidget *widget); -static void categories_clicked (GtkWidget *button, - TaskEditor *editor); - -/* The function libglade calls to create the EDateEdit widgets in the GUI. */ -GtkWidget * task_editor_create_date_edit (void); - -static GtkObjectClass *parent_class; - -E_MAKE_TYPE(task_editor, "TaskEditor", TaskEditor, - task_editor_class_init, task_editor_init, GTK_TYPE_OBJECT) - - -static void -task_editor_class_init (TaskEditorClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - object_class->destroy = task_editor_destroy; -} - - -static void -task_editor_init (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = g_new0 (TaskEditorPrivate, 1); - tedit->priv = priv; - - priv->ignore_callbacks = FALSE; - - task_editor_set_changed (tedit, FALSE); -} - - -/** - * task_editor_new: - * @Returns: a new #TaskEditor. - * - * Creates a new #TaskEditor. - **/ -TaskEditor * -task_editor_new (void) -{ - TaskEditor *tedit; - - tedit = TASK_EDITOR (gtk_type_new (task_editor_get_type ())); - return task_editor_construct (tedit); -} - -/** - * task_editor_construct: - * @tedit: A #TaskEditor. - * - * Constructs a task editor by loading its Glade XML file. - * - * Return value: The same object as @tedit, or NULL if the widgets could not be - * created. In the latter case, the task editor will automatically be - * destroyed. - **/ -TaskEditor * -task_editor_construct (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - g_return_val_if_fail (tedit != NULL, NULL); - g_return_val_if_fail (IS_TASK_EDITOR (tedit), NULL); - - priv = tedit->priv; - - /* Load the content widgets */ - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/task-editor-dialog.glade", NULL); - if (!priv->xml) { - g_message ("task_editor_construct(): Could not load the Glade XML file!"); - goto error; - } - - if (!get_widgets (tedit)) { - g_message ("task_editor_construct(): Could not find all widgets in the XML file!"); - goto error; - } - - init_widgets (tedit); - - /* Hook to destruction of the dialog */ - gtk_signal_connect (GTK_OBJECT (priv->app), "apply", - GTK_SIGNAL_FUNC (tedit_apply_event_cb), tedit); - gtk_signal_connect (GTK_OBJECT (priv->app), "close", - GTK_SIGNAL_FUNC (tedit_close_event_cb), tedit); - gtk_signal_connect (GTK_OBJECT (priv->app), "delete_event", - GTK_SIGNAL_FUNC (tedit_delete_event_cb), tedit); - - /* Add focus to the summary entry */ - gtk_widget_grab_focus (GTK_WIDGET (priv->summary)); - - - return tedit; - - error: - - gtk_object_unref (GTK_OBJECT (tedit)); - return NULL; -} - - -/* Called by libglade to create our custom EDateEdit widgets. */ -GtkWidget * -task_editor_create_date_edit (void) -{ - GtkWidget *dedit; - - dedit = date_edit_new (TRUE, TRUE); - e_date_edit_set_allow_no_date_set (E_DATE_EDIT (dedit), TRUE); - - return dedit; -} - -/* Callback used when the dialog box is destroyed */ -static void -tedit_apply_event_cb (GtkWidget *widget, gint page_num, gpointer data) -{ - TaskEditor *tedit; - - g_return_if_fail (IS_TASK_EDITOR (data)); - - tedit = TASK_EDITOR (data); - - if (page_num != -1) - return; - - save_todo_object (tedit); -} - -/* Callback used when the dialog box is destroyed */ -static gint -tedit_close_event_cb (GtkWidget *widget, gpointer data) -{ - TaskEditor *tedit; - - g_return_val_if_fail (IS_TASK_EDITOR (data), TRUE); - - tedit = TASK_EDITOR (data); - - if (prompt_to_save_changes (tedit)) - close_dialog (tedit); - - return TRUE; -} - -/* Callback used when the dialog box is destroyed */ -static gint -tedit_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - TaskEditor *tedit; - - g_return_val_if_fail (IS_TASK_EDITOR (data), TRUE); - - tedit = TASK_EDITOR (data); - - if (prompt_to_save_changes (tedit)) - close_dialog (tedit); - - return TRUE; -} - - -/* Closes the dialog box and emits the appropriate signals */ -static void -close_dialog (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - - g_assert (priv->app != NULL); - - gtk_object_destroy (GTK_OBJECT (tedit)); -} - - -/* Gets the widgets from the XML file and returns if they are all available. - * For the widgets whose values can be simply set with e-dialog-utils, it does - * that as well. - */ -static gboolean -get_widgets (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - priv->app = GW ("task-editor-dialog"); - - priv->summary = GW ("summary"); - - priv->due_date = GW ("due-date"); - priv->start_date = GW ("start-date"); - - priv->percent_complete = GW ("percent-complete"); - - priv->status = GW ("status"); - priv->priority = GW ("priority"); - - priv->description = GW ("description"); - - priv->classification_public = GW ("classification-public"); - priv->classification_private = GW ("classification-private"); - priv->classification_confidential = GW ("classification-confidential"); - - priv->contacts_btn = GW ("contacts-button"); - priv->contacts = GW ("contacts"); - - priv->categories_btn = GW ("categories-button"); - priv->categories = GW ("categories"); - - priv->completed_date = GW ("completed-date"); - priv->url = GW ("url"); - -#undef GW - - return (priv->app - && priv->summary - && priv->due_date - && priv->start_date - && priv->percent_complete - && priv->status - && priv->priority - && priv->classification_public - && priv->classification_private - && priv->classification_confidential - && priv->description - && priv->contacts_btn - && priv->contacts - && priv->categories_btn - && priv->categories - && priv->completed_date - && priv->url); -} - - -/* Hooks the widget signals */ -static void -init_widgets (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - - /* Connect signals. The Status, Percent Complete & Date Completed - properties are closely related so whenever one changes we may need - to update the other 2. */ - gtk_signal_connect (GTK_OBJECT (priv->completed_date), "changed", - GTK_SIGNAL_FUNC (completed_changed), tedit); - - gtk_signal_connect (GTK_OBJECT (GTK_OPTION_MENU (priv->status)->menu), - "deactivate", - GTK_SIGNAL_FUNC (status_changed), tedit); - - gtk_signal_connect (GTK_OBJECT (GTK_SPIN_BUTTON (priv->percent_complete)->adjustment), - "value_changed", - GTK_SIGNAL_FUNC (percent_complete_changed), tedit); - - /* Classification */ - gtk_signal_connect (GTK_OBJECT (priv->description), "changed", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->classification_public), - "toggled", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->classification_private), - "toggled", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->classification_confidential), - "toggled", - GTK_SIGNAL_FUNC (field_changed), tedit); - - /* Connect the default signal handler to use to make sure the "changed" - field gets set whenever a field is changed. */ - gtk_signal_connect (GTK_OBJECT (priv->summary), "changed", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->due_date), "changed", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->start_date), "changed", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (GTK_OPTION_MENU (priv->priority)->menu), - "deactivate", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->description), "changed", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->contacts), "changed", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->categories), "changed", - GTK_SIGNAL_FUNC (field_changed), tedit); - gtk_signal_connect (GTK_OBJECT (priv->url), "changed", - GTK_SIGNAL_FUNC (field_changed), tedit); - - /* Button clicks */ - gtk_signal_connect (GTK_OBJECT (priv->categories_btn), "clicked", - GTK_SIGNAL_FUNC (categories_clicked), tedit); - - /* FIXME: we do not support these fields yet, so we disable them */ - - gtk_widget_set_sensitive (priv->contacts_btn, FALSE); - gtk_widget_set_sensitive (priv->contacts, FALSE); -} - -static void -task_editor_destroy (GtkObject *object) -{ - TaskEditor *tedit; - TaskEditorPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_TASK_EDITOR (object)); - - tedit = TASK_EDITOR (object); - priv = tedit->priv; - - if (priv->app) { - gtk_widget_destroy (priv->app); - priv->app = NULL; - } - - if (priv->comp) { - gtk_object_unref (GTK_OBJECT (priv->comp)); - priv->comp = NULL; - } - - if (priv->client) { - gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), - tedit); - gtk_object_unref (GTK_OBJECT (priv->client)); - priv->client = NULL; - } - - if (priv->xml) { - gtk_object_unref (GTK_OBJECT (priv->xml)); - priv->xml = NULL; - } - - g_free (priv); - tedit->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -void -task_editor_set_cal_client (TaskEditor *tedit, - CalClient *client) -{ - TaskEditorPrivate *priv; - - g_return_if_fail (tedit != NULL); - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - - if (client == priv->client) - return; - - if (client) - g_return_if_fail (IS_CAL_CLIENT (client)); - - if (client) - g_return_if_fail (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED); - - if (client) - gtk_object_ref (GTK_OBJECT (client)); - - if (priv->client) { - gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), - tedit); - gtk_object_unref (GTK_OBJECT (priv->client)); - } - - priv->client = client; - - if (priv->client) { - gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated", - GTK_SIGNAL_FUNC (obj_updated_cb), tedit); - gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed", - GTK_SIGNAL_FUNC (obj_removed_cb), tedit); - } -} - - -/* Callback used when the calendar client tells us that an object changed */ -static void -obj_updated_cb (CalClient *client, const char *uid, gpointer data) -{ - /* FIXME: Do something sensible if the component changes under our feet */ -#if 0 - TaskEditor *tedit; - TaskEditorPrivate *priv; - CalComponent *comp; - CalClientGetStatus status; - const gchar *editing_uid; - - tedit = TASK_EDITOR (data); - - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - - /* If we aren't showing the object which has been updated, return. */ - if (!priv->comp) - return; - cal_component_get_uid (priv->comp, &editing_uid); - if (strcmp (uid, editing_uid)) - return; - - - /* Get the task from the server. */ - status = cal_client_get_object (priv->client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* Everything is fine */ - break; - - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_message ("obj_updated_cb(): Syntax error when getting object `%s'", uid); - return; - - case CAL_CLIENT_GET_NOT_FOUND: - /* The object is no longer in the server, so do nothing */ - return; - - default: - g_assert_not_reached (); - return; - } - - raise_and_focus (priv->app); -#endif -} - -/* Callback used when the calendar client tells us that an object was removed */ -static void -obj_removed_cb (CalClient *client, const char *uid, gpointer data) -{ - /* FIXME: Do something sensible if the component is removed under our - * feet. - */ -#if 0 - TaskEditor *tedit; - TaskEditorPrivate *priv; - const gchar *editing_uid; - - tedit = TASK_EDITOR (data); - - g_return_if_fail (tedit != NULL); - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - - /* If we aren't showing the object which has been updated, return. */ - if (!priv->comp) - return; - cal_component_get_uid (priv->comp, &editing_uid); - if (strcmp (uid, editing_uid)) - return; - - - raise_and_focus (priv->app); -#endif -} - - -/* Brings attention to a window by raising it and giving it focus */ -static void -raise_and_focus (GtkWidget *widget) -{ - g_assert (GTK_WIDGET_REALIZED (widget)); - gdk_window_show (widget->window); - gtk_widget_grab_focus (widget); -} - - -/** - * task_editor_set_todo_object: - * @tedit: A #TaskEditor. - * @comp: A todo object. - * - * Sets the todo object that a task editor dialog will manipulate. - **/ -void -task_editor_set_todo_object (TaskEditor *tedit, - CalComponent *comp) -{ - TaskEditorPrivate *priv; - - g_return_if_fail (tedit != NULL); - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - - if (priv->comp) { - gtk_object_unref (GTK_OBJECT (priv->comp)); - priv->comp = NULL; - } - - if (comp) - priv->comp = cal_component_clone (comp); - - set_title_from_comp (tedit, priv->comp); - fill_widgets (tedit); -} - -void -task_editor_focus (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - g_return_if_fail (tedit != NULL); - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - gtk_widget_show_now (priv->app); - raise_and_focus (priv->app); -} - -#warning this is duplicated function from ../event-editor.c -/* Creates an appropriate title for the task editor dialog */ -static char * -make_title_from_comp (CalComponent *comp) -{ - char *title; - const char *type_string; - CalComponentVType type; - CalComponentText text; - - if (!comp) - return g_strdup (_("Edit Task")); - - type = cal_component_get_vtype (comp); - switch (type) { - case CAL_COMPONENT_EVENT: - type_string = _("Appointment - %s"); - break; - case CAL_COMPONENT_TODO: - type_string = _("Task - %s"); - break; - case CAL_COMPONENT_JOURNAL: - type_string = _("Journal entry - %s"); - break; - default: - g_message ("make_title_from_comp(): Cannot handle object of type %d", type); - return NULL; - } - - cal_component_get_summary (comp, &text); - if (text.value) { - char *summary; - summary = e_utf8_to_locale_string (text.value); - title = g_strdup_printf (type_string, summary); - g_free (summary); - } else - title = g_strdup_printf (type_string, _("No summary")); - - return title; -} - -/* Sets the event editor's window title from a calendar component */ -static void -set_title_from_comp (TaskEditor *tedit, CalComponent *comp) -{ - TaskEditorPrivate *priv = tedit->priv; - char *title; - - title = make_title_from_comp (comp); - gtk_window_set_title (GTK_WINDOW (priv->app), title); - g_free (title); -} - -/* Fills the widgets with default values */ -static void -clear_widgets (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - - -} - -/* Fills in the widgets with the proper values */ -static void -fill_widgets (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - CalComponentText text; - CalComponentDateTime d; - CalComponentClassification cl; - struct icaltimetype *completed; - GSList *l; - time_t t; - int *priority_value, *percent; - icalproperty_status status; - TaskEditorPriority priority; - const char *url; - const char *categories; - - priv = tedit->priv; - - task_editor_set_changed (tedit, FALSE); - - clear_widgets (tedit); - - if (!priv->comp) - return; - - /* We want to ignore any signals emitted while changing fields. */ - priv->ignore_callbacks = TRUE; - - - cal_component_get_summary (priv->comp, &text); - e_dialog_editable_set (priv->summary, text.value); - - cal_component_get_description_list (priv->comp, &l); - if (l) { - text = *(CalComponentText *)l->data; - e_dialog_editable_set (priv->description, text.value); - } else { - e_dialog_editable_set (priv->description, NULL); - } - cal_component_free_text_list (l); - - /* Due Date. */ - cal_component_get_due (priv->comp, &d); - if (d.value) { - t = icaltime_as_timet (*d.value); - } else { - t = -1; - } - e_date_edit_set_time (E_DATE_EDIT (priv->due_date), t); - - /* Start Date. */ - cal_component_get_dtstart (priv->comp, &d); - if (d.value) { - t = icaltime_as_timet (*d.value); - } else { - t = -1; - } - e_date_edit_set_time (E_DATE_EDIT (priv->start_date), t); - - /* Completed Date. */ - cal_component_get_completed (priv->comp, &completed); - if (completed) { - t = icaltime_as_timet (*completed); - cal_component_free_icaltimetype (completed); - } else { - t = -1; - } - e_date_edit_set_time (E_DATE_EDIT (priv->completed_date), t); - - /* Percent Complete. */ - cal_component_get_percent (priv->comp, &percent); - if (percent) { - e_dialog_spin_set (priv->percent_complete, *percent); - cal_component_free_percent (percent); - } else { - /* FIXME: Could check if task is completed and set 100%. */ - e_dialog_spin_set (priv->percent_complete, 0); - } - - /* Status. */ - cal_component_get_status (priv->comp, &status); - if (status == ICAL_STATUS_NONE) { - /* Try to user the percent value. */ - if (percent) { - if (*percent == 0) - status = ICAL_STATUS_NEEDSACTION; - else if (*percent == 100) - status = ICAL_STATUS_COMPLETED; - else - status = ICAL_STATUS_INPROCESS; - } else - status = ICAL_STATUS_NEEDSACTION; - } - e_dialog_option_menu_set (priv->status, status, status_map); - - /* Priority. */ - cal_component_get_priority (priv->comp, &priority_value); - if (priority_value) { - priority = priority_value_to_index (*priority_value); - cal_component_free_priority (priority_value); - } else { - priority = PRIORITY_UNDEFINED; - } - e_dialog_option_menu_set (priv->priority, priority, priority_map); - - - /* Classification. */ - cal_component_get_classification (priv->comp, &cl); - - switch (cl) { - case CAL_COMPONENT_CLASS_PUBLIC: - e_dialog_radio_set (priv->classification_public, CAL_COMPONENT_CLASS_PUBLIC, - classification_map); - case CAL_COMPONENT_CLASS_PRIVATE: - e_dialog_radio_set (priv->classification_public, CAL_COMPONENT_CLASS_PRIVATE, - classification_map); - case CAL_COMPONENT_CLASS_CONFIDENTIAL: - e_dialog_radio_set (priv->classification_public, CAL_COMPONENT_CLASS_CONFIDENTIAL, - classification_map); - default: - /* What do do? We can't g_assert_not_reached() since it is a - * value from an external file. - */ - } - - /* Categories */ - cal_component_get_categories (priv->comp, &categories); - e_dialog_editable_set (priv->categories, categories); - - /* URL. */ - cal_component_get_url (priv->comp, &url); - e_dialog_editable_set (priv->url, url); - - priv->ignore_callbacks = FALSE; -} - - -static void -save_todo_object (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - - g_return_if_fail (priv->client != NULL); - - if (!priv->comp) - return; - - dialog_to_comp_object (tedit); - set_title_from_comp (tedit, priv->comp); - - if (!cal_client_update_object (priv->client, priv->comp)) - g_message ("save_todo_object(): Could not update the object!"); - else - task_editor_set_changed (tedit, FALSE); -} - - -/* Get the values of the widgets in the event editor and put them in the iCalObject */ -static void -dialog_to_comp_object (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - CalComponent *comp; - CalComponentDateTime date; - time_t t; - icalproperty_status status; - TaskEditorPriority priority; - int priority_value, percent; - char *url, *cat; - char *str; - - priv = tedit->priv; - comp = priv->comp; - - /* Summary. */ - - str = e_dialog_editable_get (priv->summary); - if (!str || strlen (str) == 0) - cal_component_set_summary (comp, NULL); - else { - CalComponentText text; - - text.value = str; - text.altrep = NULL; - - cal_component_set_summary (comp, &text); - } - - if (str) - g_free (str); - - /* Description */ - - str = e_dialog_editable_get (priv->description); - if (!str || strlen (str) == 0) - cal_component_set_description_list (comp, NULL); - else { - GSList l; - CalComponentText text; - - text.value = str; - text.altrep = NULL; - l.data = &text; - l.next = NULL; - - cal_component_set_description_list (comp, &l); - } - - if (!str) - g_free (str); - - /* Dates */ - - date.value = g_new (struct icaltimetype, 1); - date.tzid = NULL; - - /* Due Date. */ - t = e_date_edit_get_time (E_DATE_EDIT (priv->due_date)); - if (t != -1) { - *date.value = icaltime_from_timet (t, FALSE); - cal_component_set_due (comp, &date); - } else { - cal_component_set_due (comp, NULL); - } - - /* Start Date. */ - t = e_date_edit_get_time (E_DATE_EDIT (priv->start_date)); - if (t != -1) { - *date.value = icaltime_from_timet (t, FALSE); - cal_component_set_dtstart (comp, &date); - } else { - cal_component_set_dtstart (comp, NULL); - } - - /* Completed Date. */ - t = e_date_edit_get_time (E_DATE_EDIT (priv->completed_date)); - if (t != -1) { - *date.value = icaltime_from_timet (t, FALSE); - cal_component_set_completed (comp, date.value); - } else { - cal_component_set_completed (comp, NULL); - } - - g_free (date.value); - - /* Percent Complete. */ - percent = e_dialog_spin_get_int (priv->percent_complete); - cal_component_set_percent (comp, &percent); - - /* Status. */ - status = e_dialog_option_menu_get (priv->status, status_map); - cal_component_set_status (comp, status); - - /* Priority. */ - priority = e_dialog_option_menu_get (priv->priority, priority_map); - priority_value = priority_index_to_value (priority); - cal_component_set_priority (comp, &priority_value); - - /* Classification. */ - cal_component_set_classification (comp, classification_get (priv->classification_public)); - - /* Categories */ - cat = e_dialog_editable_get (priv->categories); - cal_component_set_categories (comp, cat); - - if (cat) - g_free (cat); - - /* URL. */ - url = e_dialog_editable_get (priv->url); - cal_component_set_url (comp, url); - - if (url) - g_free (url); - - cal_component_commit_sequence (comp); -} - -static TaskEditorPriority -priority_value_to_index (int priority_value) -{ - TaskEditorPriority retval; - - if (priority_value == 0) - retval = PRIORITY_UNDEFINED; - else if (priority_value <= 4) - retval = PRIORITY_HIGH; - else if (priority_value == 5) - retval = PRIORITY_NORMAL; - else - retval = PRIORITY_LOW; - - return retval; -} - - -static int -priority_index_to_value (TaskEditorPriority priority) -{ - int retval; - - switch (priority) { - case PRIORITY_UNDEFINED: - retval = 0; - break; - case PRIORITY_HIGH: - retval = 3; - break; - case PRIORITY_NORMAL: - retval = 5; - break; - case PRIORITY_LOW: - retval = 7; - break; - default: - retval = -1; - g_assert_not_reached (); - break; - } - - return retval; -} - - -static void -completed_changed (EDateEdit *dedit, - TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - time_t t; - - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - - if (priv->ignore_callbacks) - return; - - task_editor_set_changed (tedit, TRUE); - - priv->ignore_callbacks = TRUE; - t = e_date_edit_get_time (E_DATE_EDIT (priv->completed_date)); - if (t == -1) { - /* If the 'Completed Date' is set to 'None', we set the - status to 'Not Started' and the percent-complete to 0. - The task may actually be partially-complete, but we leave - it to the user to set those fields. */ - e_dialog_option_menu_set (priv->status, ICAL_STATUS_NEEDSACTION, - status_map); - e_dialog_spin_set (priv->percent_complete, 0); - } else { - e_dialog_option_menu_set (priv->status, ICAL_STATUS_COMPLETED, - status_map); - e_dialog_spin_set (priv->percent_complete, 100); - } - priv->ignore_callbacks = FALSE; -} - - -static void -status_changed (GtkMenu *menu, - TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - icalproperty_status status; - - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - - if (priv->ignore_callbacks) - return; - - task_editor_set_changed (tedit, TRUE); - - status = e_dialog_option_menu_get (priv->status, status_map); - priv->ignore_callbacks = TRUE; - if (status == ICAL_STATUS_NEEDSACTION) { - e_dialog_spin_set (priv->percent_complete, 0); - e_date_edit_set_time (E_DATE_EDIT (priv->completed_date), -1); - } else if (status == ICAL_STATUS_COMPLETED) { - e_dialog_spin_set (priv->percent_complete, 100); - e_date_edit_set_time (E_DATE_EDIT (priv->completed_date), - time (NULL)); - } - priv->ignore_callbacks = FALSE; -} - - -static void -percent_complete_changed (GtkAdjustment *adj, - TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - gint percent; - icalproperty_status status; - time_t date_completed; - - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - - if (priv->ignore_callbacks) - return; - - task_editor_set_changed (tedit, TRUE); - - percent = e_dialog_spin_get_int (priv->percent_complete); - priv->ignore_callbacks = TRUE; - - if (percent == 100) { - date_completed = time (NULL); - status = ICAL_STATUS_COMPLETED; - } else { - /* FIXME: Set to 'None'. */ - date_completed = time (NULL); - - if (percent == 0) - status = ICAL_STATUS_NEEDSACTION; - else - status = ICAL_STATUS_INPROCESS; - } - - e_date_edit_set_time (E_DATE_EDIT (priv->completed_date), - date_completed); - e_dialog_option_menu_set (priv->status, status, status_map); - - priv->ignore_callbacks = FALSE; -} - -/* Decode the radio button group for classifications */ -static CalComponentClassification -classification_get (GtkWidget *widget) -{ - return e_dialog_radio_get (widget, classification_map); -} - - -/* This is called when all fields except those handled above (status, percent - complete & completed date) are changed. It just sets the "changed" flag. */ -static void -field_changed (GtkWidget *widget, - TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - g_return_if_fail (IS_TASK_EDITOR (tedit)); - - priv = tedit->priv; - - if (priv->ignore_callbacks) - return; - - task_editor_set_changed (tedit, TRUE); -} - - -static void -task_editor_set_changed (TaskEditor *tedit, - gboolean changed) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - -#if 0 - g_print ("In task_editor_set_changed: %s\n", - changed ? "TRUE" : "FALSE"); -#endif - - priv->changed = changed; - - if (priv->app) - gnome_property_box_set_state (GNOME_PROPERTY_BOX (priv->app), changed); -} - - -/* This checks if the "changed" field is set, and if so it prompts to save - the changes using a "Save/Discard/Cancel" modal dialog. It then saves the - changes if requested. It returns TRUE if the dialog should now be closed. */ -static gboolean -prompt_to_save_changes (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - - if (!priv->changed) - return TRUE; - - switch (save_component_dialog (GTK_WINDOW (priv->app))) { - case 0: /* Save */ - /* FIXME: If an error occurs here, we should popup a dialog - and then return FALSE. */ - save_todo_object (tedit); - return TRUE; - case 1: /* Discard */ - return TRUE; - case 2: /* Cancel */ - default: - return FALSE; - break; - } - -} - -static void -categories_clicked(GtkWidget *button, TaskEditor *tedit) -{ - char *categories; - GnomeDialog *dialog; - int result; - GtkWidget *entry; - - entry = ((TaskEditorPrivate *)tedit->priv)->categories; - categories = e_utf8_gtk_entry_get_text (GTK_ENTRY (entry)); - - dialog = GNOME_DIALOG (e_categories_new (categories)); - result = gnome_dialog_run (dialog); - g_free (categories); - - if (result == 0) { - gtk_object_get (GTK_OBJECT (dialog), - "categories", &categories, - NULL); - e_utf8_gtk_entry_set_text (GTK_ENTRY (entry), categories); - g_free (categories); - } - gtk_object_destroy (GTK_OBJECT (dialog)); -} diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h deleted file mode 100644 index 7327803a72..0000000000 --- a/calendar/gui/dialogs/task-editor.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin - * - * Copyright 2000, Helix Code, Inc. - * Copyright 2000, Ximian, Inc. - * - * 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 _TASK_EDITOR_H_ -#define _TASK_EDITOR_H_ - -#include -#include -#include -#include - -BEGIN_GNOME_DECLS - - -#define TASK_EDITOR(obj) GTK_CHECK_CAST (obj, task_editor_get_type (), TaskEditor) -#define TASK_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, task_editor_get_type (), TaskEditorClass) -#define IS_TASK_EDITOR(obj) GTK_CHECK_TYPE (obj, task_editor_get_type ()) - - -typedef struct _TaskEditor TaskEditor; -typedef struct _TaskEditorClass TaskEditorClass; - -struct _TaskEditor -{ - GtkObject object; - - /* Private data */ - gpointer priv; -}; - -struct _TaskEditorClass -{ - GtkObjectClass parent_class; -}; - -GtkType task_editor_get_type (void); -TaskEditor* task_editor_construct (TaskEditor *tedit); -TaskEditor* task_editor_new (void); -void task_editor_set_cal_client (TaskEditor *tedit, - CalClient *client); -void task_editor_set_todo_object (TaskEditor *tedit, - CalComponent *comp); -void task_editor_focus (TaskEditor *tedit); - - - -END_GNOME_DECLS - -#endif /* _TASK_EDITOR_H_ */ diff --git a/calendar/gui/dialogs/task-page.glade b/calendar/gui/dialogs/task-page.glade deleted file mode 100644 index e9f0d4700d..0000000000 --- a/calendar/gui/dialogs/task-page.glade +++ /dev/null @@ -1,547 +0,0 @@ - - - - - task-page - task-page - - src - pixmaps - C - True - True - - - - GtkWindow - task-toplevel - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkVBox - task-page - 4 - False - 4 - - - GtkTable - table3 - 1 - 2 - False - 4 - 4 - - 0 - False - True - - - - GtkLabel - label3 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - summary - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - False - False - - - - - GtkEntry - summary - True - True - True - 0 - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - - GtkFrame - frame2 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkHBox - hbox4 - 4 - False - 0 - - - GtkTable - table1 - 2 - 2 - False - 2 - 4 - - 0 - False - True - - - - GtkLabel - label6 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - Custom - due-date - task_editor_create_date_edit - 0 - 0 - Sun, 10 Sep 2000 17:32:18 GMT - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - Custom - start-date - task_editor_create_date_edit - 0 - 0 - Sun, 10 Sep 2000 17:33:31 GMT - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - - - - GtkScrolledWindow - scrolledwindow1 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - False - True - - - - GtkText - description - 80 - True - True - - - - - - GtkFrame - frame23 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkHBox - hbox3 - 4 - False - 4 - - - GtkLabel - label7 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - status - - 0 - False - False - - - - - GtkOptionMenu - status - True - Not Started -In Progress -Completed -Cancelled - - 0 - - 0 - False - False - - - - - GtkLabel - label8 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - priority - - 0 - False - False - - - - - GtkOptionMenu - priority - True - High -Normal -Low -Undefined - - 0 - - 0 - False - False - - - - - GtkLabel - label9 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - percent-complete - - 0 - False - False - - - - - GtkSpinButton - percent-complete - 60 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 0 - 0 - 100 - 10 - 10 - 10 - - 0 - False - False - - - - - - - GtkFrame - frame24 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - True - - - - GtkHBox - hbox6 - 2 - False - 4 - - - GtkRadioButton - classification-public - True - - True - True - classification_radio_group - - 0 - False - False - - - - - GtkRadioButton - classification-private - True - - False - True - classification_radio_group - - 0 - False - False - - - - - GtkRadioButton - classification-confidential - True - - False - True - classification_radio_group - - 0 - False - False - - - - - - - GtkHBox - hbox2 - False - 2 - - 0 - True - True - - - - GtkButton - contacts-button - True - GTK_RELIEF_NORMAL - - 0 - False - False - - - - GtkLabel - label16 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 4 - 0 - - - - - GtkEntry - contacts - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - categories-button - True - GTK_RELIEF_NORMAL - - 0 - False - False - - - - GtkLabel - label17 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 4 - 0 - - - - - GtkEntry - categories - True - True - True - 0 - - - 0 - True - True - - - - - - - -- cgit v1.2.3