diff options
author | nobody <nobody@localhost> | 2000-08-22 20:05:30 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2000-08-22 20:05:30 +0800 |
commit | ce9d5b5e12c8e0ac180f3c006ff1c12b0d14b040 (patch) | |
tree | 3b4824784cd30983db4a6ae1f38db287d5815941 /calendar/gui | |
parent | 44ae37c371e25fe05e8aee145f1d9af7130a201d (diff) | |
download | gsoc2013-evolution-ce9d5b5e12c8e0ac180f3c006ff1c12b0d14b040.tar gsoc2013-evolution-ce9d5b5e12c8e0ac180f3c006ff1c12b0d14b040.tar.gz gsoc2013-evolution-ce9d5b5e12c8e0ac180f3c006ff1c12b0d14b040.tar.bz2 gsoc2013-evolution-ce9d5b5e12c8e0ac180f3c006ff1c12b0d14b040.tar.lz gsoc2013-evolution-ce9d5b5e12c8e0ac180f3c006ff1c12b0d14b040.tar.xz gsoc2013-evolution-ce9d5b5e12c8e0ac180f3c006ff1c12b0d14b040.tar.zst gsoc2013-evolution-ce9d5b5e12c8e0ac180f3c006ff1c12b0d14b040.zip |
This commit was manufactured by cvs2svn to create tagGNOMEDB_0_1_0
'GNOMEDB_0_1_0'.
svn path=/tags/GNOMEDB_0_1_0/; revision=4935
Diffstat (limited to 'calendar/gui')
98 files changed, 0 insertions, 35260 deletions
diff --git a/calendar/gui/.cvsignore b/calendar/gui/.cvsignore deleted file mode 100644 index c55e5d266f..0000000000 --- a/calendar/gui/.cvsignore +++ /dev/null @@ -1,21 +0,0 @@ -Makefile.in -Makefile -.deps -_libs -.libs -.pure -gncal -evolution-calendar -evolution-calendar.pure -test-calendar-widget -getdate.c -GnomeCal-skels.c -GnomeCal-common.c -GnomeCal.h -calendar-pilot-sync -evolution-calendar-stubs.c -evolution-calendar-skels.c -evolution-calendar-common.c -evolution-calendar.h -GnomeCal-stubs.c -*.lo diff --git a/calendar/gui/GNOME_Evolution_Calendar.oaf.in b/calendar/gui/GNOME_Evolution_Calendar.oaf.in deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar.oaf.in +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar.oafinfo b/calendar/gui/GNOME_Evolution_Calendar.oafinfo deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar.oafinfo +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_Control.oaf.in b/calendar/gui/GNOME_Evolution_Calendar_Control.oaf.in deleted file mode 100644 index fb0f138caf..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar_Control.oaf.in +++ /dev/null @@ -1,28 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the sample Calendar control"/> -</oaf_server> - -<oaf_server iid="OAFIID:control:calendar:dd34ddae-25c6-486b-a8a8-3e8f0286b54c" - type="factory" - location="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:BonoboControl/calendar-control:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="A sample Bonobo control which displays an calendar."/> -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_Control.oafinfo b/calendar/gui/GNOME_Evolution_Calendar_Control.oafinfo deleted file mode 100644 index fb0f138caf..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar_Control.oafinfo +++ /dev/null @@ -1,28 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the sample Calendar control"/> -</oaf_server> - -<oaf_server iid="OAFIID:control:calendar:dd34ddae-25c6-486b-a8a8-3e8f0286b54c" - type="factory" - location="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:BonoboControl/calendar-control:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="A sample Bonobo control which displays an calendar."/> -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am deleted file mode 100644 index 4927f7c6b6..0000000000 --- a/calendar/gui/Makefile.am +++ /dev/null @@ -1,143 +0,0 @@ -SUBDIRS = dialogs - -help_base = $(datadir)/gnome/help/cal - -bin_PROGRAMS = evolution-calendar - -CPPFLAGS = \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" - -INCLUDES = \ - -DG_LOG_DOMAIN=\"calendar-gui\" \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/shell \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_srcdir)/libical/src/libical \ - -I$(top_srcdir)/widgets \ - -I$(includedir) \ - $(BONOBO_VFS_GNOME_CFLAGS) \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" - -LINK_FLAGS = \ - $(BONOBO_VFS_GNOME_LIBS) \ - $(INTLLIBS) \ - dialogs/libcal-dialogs.a \ - $(top_builddir)/calendar/cal-client/libcal-client.la \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ - $(top_builddir)/widgets/e-paned/libepaned.a \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/libical/src/libical/libical.a - -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - event-editor-dialog.glade - -glade_messages = event-editor-dialog.glade.h - -evolution_calendar_SOURCES = \ - alarm.c \ - alarm.h \ - calendar-commands.c \ - calendar-commands.h \ - calendar-model.c \ - calendar-model.h \ - control-factory.c \ - control-factory.h \ - component-factory.c \ - component-factory.h \ - e-calendar-table.h \ - e-calendar-table.c \ - e-day-view-main-item.c \ - e-day-view-main-item.h \ - e-day-view-time-item.c \ - e-day-view-time-item.h \ - e-day-view-top-item.c \ - e-day-view-top-item.h \ - e-day-view.c \ - e-day-view.h \ - e-week-view-event-item.c \ - e-week-view-event-item.h \ - e-week-view-main-item.c \ - e-week-view-main-item.h \ - e-week-view-titles-item.c \ - e-week-view-titles-item.h \ - e-week-view.c \ - e-week-view.h \ - event-editor.c \ - event-editor.h \ - getdate.y \ - gncal-todo.c \ - gncal-todo.h \ - gnome-cal.c \ - gnome-cal.h \ - gnome-month-item.c \ - gnome-month-item.h \ - goto.c \ - main.c \ - mark.c \ - mark.h \ - popup-menu.c \ - popup-menu.h \ - print.c \ - print.h \ - prop.c - -evolution_calendar_LDADD = \ - $(top_builddir)/shell/libeshell.a \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_HTML_GNOME_LIBS) \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la \ - $(LINK_FLAGS) - -evolution_calendar_LDFLAGS = `gnome-config --libs gdk_pixbuf` - -if USING_OAF -oafdir = $(datadir)/oaf -oaf_DATA = calendar-control.oafinfo evolution-calendar.oafinfo -else -gnorbadir = $(sysconfdir)/CORBA/servers -gnorba_DATA = calendar-control.gnorba evolution-calendar.gnorba -endif - -OAF_GNORBA_EXTRAS = calendar-control.oafinfo evolution-calendar.oafinfo calendar-control.gnorba evolution-calendar.gnorba -EXTRA_DIST = \ - $(OAF_GNORBA_EXTRAS) \ - $(glade_DATA) \ - bell.xpm \ - dayview.xpm \ - jump.xpm \ - monthview.xpm \ - recur.xpm \ - task-assigned-to.xpm \ - task-assigned.xpm \ - task-recurring.xpm \ - task.xpm \ - weekview.xpm \ - workweekview.xpm \ - yearview.xpm \ - calendar-control.gnorba \ - calendar-control.oafinfo - - -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(help_base)/C - $(mkinstalldirs) $(Conduitsdir) - -if ENABLE_PURIFY -PLINK = $(LIBTOOL) --mode=link $(PURIFY) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ - -all-local: evolution-calendar.pure - -evolution-calendar.pure: evolution-calendar - @rm -f evolution-calendar.pure - $(PLINK) $(evolution_calendar_LDFLAGS) $(evolution_calendar_OBJECTS) $(evolution_calendar_LDADD) $(LIBS) - -endif diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c deleted file mode 100644 index 7d8357599c..0000000000 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include "alarm-notify-dialog.h" - - - -/* The useful contents of the alarm notify dialog */ -typedef struct { - GladeXML *xml; - - GtkWidget *dialog; - GtkWidget *close; - GtkWidget *snooze; - GtkWidget *edit; - GtkWidget *heading; - GtkWidget *summary; - GtkWidget *snooze_time; - - AlarmNotifyFunc func; - gpointer func_data; -} AlarmNotify; - - - -/* Callback used when the notify dialog is destroyed */ -static void -dialog_destroy_cb (GtkObject *object, gpointer data) -{ - AlarmNotify *an; - - an = data; - gtk_object_unref (GTK_OBJECT (an->xml)); - g_free (an); -} - -/* Delete_event handler for the alarm notify dialog */ -static gint -delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data); - - gtk_widget_destroy (widget); - return TRUE; -} - -/* Callback for the close button */ -static void -close_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/* Callback for the snooze button */ -static void -snooze_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - int snooze_time; - - an = data; - g_assert (an->func != NULL); - - snooze_time = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time)); - (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_time, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/* Callback for the edit button */ -static void -edit_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/** - * alarm_notify_dialog: - * @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/alarm-notify/alarm-notify-dialog.h b/calendar/gui/alarm-notify/alarm-notify-dialog.h deleted file mode 100644 index 1e56f1c586..0000000000 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_NOTIFY_DIALOG_H -#define ALARM_NOTIFY_DIALOG_H - -#include <time.h> -#include <glib.h> -#include <cal-util/cal-component.h> - - - -typedef enum { - ALARM_NOTIFY_CLOSE, - ALARM_NOTIFY_SNOOZE, - ALARM_NOTIFY_EDIT -} AlarmNotifyResult; - -typedef void (* AlarmNotifyFunc) (AlarmNotifyResult result, int snooze_mins, gpointer data); - -gboolean alarm_notify_dialog (time_t trigger, time_t occur, CalComponent *comp, - AlarmNotifyFunc func, gpointer func_data); - - - -#endif diff --git a/calendar/gui/alarm-notify/alarm-notify.glade b/calendar/gui/alarm-notify/alarm-notify.glade deleted file mode 100644 index 32d7e03f8b..0000000000 --- a/calendar/gui/alarm-notify/alarm-notify.glade +++ /dev/null @@ -1,230 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>Evolution Calendar</name> - <program_name>evolution-calendar</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> - <output_main_file>True</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>alarm-notify.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GtkWindow</class> - <name>alarm-notify</name> - <cxx_use_heap>True</cxx_use_heap> - <title></title> - <type>GTK_WINDOW_DIALOG</type> - <position>GTK_WIN_POS_CENTER</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>False</allow_grow> - <auto_shrink>False</auto_shrink> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <border_width>4</border_width> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox5</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>heading</name> - <cxx_use_heap>True</cxx_use_heap> - <label></label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>True</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>summary</name> - <cxx_use_heap>True</cxx_use_heap> - <label></label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>True</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox4</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>close</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Close</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>snooze</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Snooze</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>edit</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Edit appointment</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <cxx_use_heap>True</cxx_use_heap> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox4</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label4</name> - <cxx_use_heap>True</cxx_use_heap> - <label>Snooze time (minutes)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>snooze-time</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>5</value> - <lower>1</lower> - <upper>1440</upper> - <step>1</step> - <page>5</page> - <page_size>5</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c deleted file mode 100644 index c89b65ff5e..0000000000 --- a/calendar/gui/alarm-notify/alarm.c +++ /dev/null @@ -1,304 +0,0 @@ -/* Evolution calendar - alarm notification support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <time.h> -#include <gnome.h> -#include <fcntl.h> -#include <signal.h> -#include <sys/time.h> -#include "alarm.h" - - - -/* The pipes used to notify about an alarm */ -static int alarm_pipes [2]; - -/* The list of pending alarms */ -static GList *alarms; - -/* A queued alarm structure */ -typedef struct { - time_t trigger; - AlarmFunction alarm_fn; - gpointer data; - AlarmDestroyNotify destroy_notify_fn; -} AlarmRecord; - - - -/* SIGALRM handler. Notifies the callback about the alarm. */ -static void -alarm_signal (int arg) -{ - char c = 0; - - write (alarm_pipes [1], &c, 1); -} - -/* Sets up an itimer and returns a success code */ -static gboolean -setup_itimer (time_t diff) -{ - struct itimerval itimer; - int v; - - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = diff; - itimer.it_value.tv_usec = 0; - - v = setitimer (ITIMER_REAL, &itimer, NULL); - - return (v == 0) ? TRUE : FALSE; -} - -/* Removes the head alarm, returns it, and schedules the next alarm in the - * queue. - */ -static AlarmRecord * -pop_alarm (void) -{ - AlarmRecord *ar; - GList *l; - - if (!alarms) - return NULL; - - ar = alarms->data; - - l = alarms; - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - - if (alarms) { - time_t now; - AlarmRecord *new_ar; - - now = time (NULL); - new_ar = alarms->data; - - if (!setup_itimer (new_ar->trigger - now)) { - g_message ("pop_alarm(): Could not reset the timer! " - "Weird things will happen."); - - /* FIXME: should we free the alarm list? What - * about further alarm removal requests that - * will fail? - */ - } - } else { - struct itimerval itimer; - int v; - - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = 0; - - v = setitimer (ITIMER_REAL, &itimer, NULL); - if (v != 0) - g_message ("pop_alarm(): Could not clear the timer! " - "Weird things may happen."); - } - - return ar; -} - -/* Input handler for our own alarm notification pipe */ -static void -alarm_ready (gpointer data, gint fd, GdkInputCondition cond) -{ - AlarmRecord *ar; - char c; - - if (read (alarm_pipes [0], &c, 1) != 1) { - g_message ("alarm_ready(): Uh? Could not read from notification pipe."); - return; - } - - g_assert (alarms != NULL); - ar = pop_alarm (); - - g_message ("alarm_ready(): Notifying about alarm on %s", ctime (&ar->trigger)); - - (* ar->alarm_fn) (ar, ar->trigger, ar->data); - - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); -} - -static int -compare_alarm_by_time (gconstpointer a, gconstpointer b) -{ - const AlarmRecord *ara = a; - const AlarmRecord *arb = b; - time_t diff; - - diff = ara->trigger - arb->trigger; - return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; -} - -/* Adds an alarm to the queue and sets up the timer */ -static gboolean -queue_alarm (time_t now, AlarmRecord *ar) -{ - time_t diff; - AlarmRecord *old_head; - - if (alarms) - old_head = alarms->data; - else - old_head = NULL; - - alarms = g_list_insert_sorted (alarms, ar, compare_alarm_by_time); - - if (old_head == alarms->data) - return TRUE; - - /* Set the timer for removal upon activation */ - - diff = ar->trigger - now; - if (!setup_itimer (diff)) { - GList *l; - - g_message ("queue_alarm(): Could not set up timer! Not queueing alarm."); - - l = g_list_find (alarms, ar); - g_assert (l != NULL); - - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - return FALSE; - } - - return TRUE; -} - -/** - * alarm_add: - * @trigger: Time at which alarm will trigger. - * @alarm_fn: Callback for trigger. - * @data: Closure data for callback. - * - * Adds an alarm to trigger at the specified time. The @alarm_fn will be called - * with the provided data and the alarm will be removed from the trigger list. - * - * Return value: An identifier for this alarm; it can be used to remove the - * alarm later with alarm_remove(). If the trigger time occurs in the past, then - * the alarm will not be queued and the function will return NULL. - **/ -gpointer -alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, - AlarmDestroyNotify destroy_notify_fn) -{ - time_t now; - AlarmRecord *ar; - - now = time (NULL); - if (trigger < now) - return NULL; - - ar = g_new (AlarmRecord, 1); - ar->trigger = trigger; - ar->alarm_fn = alarm_fn; - ar->data = data; - ar->destroy_notify_fn = destroy_notify_fn; - - g_message ("alarm_add(): Adding alarm for %s", ctime (&trigger)); - - if (!queue_alarm (now, ar)) { - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); - ar = NULL; - } - - return ar; -} - -/** - * alarm_remove: - * @alarm: A queued alarm identifier. - * - * Removes an alarm from the alarm queue. - **/ -void -alarm_remove (gpointer alarm) -{ - AlarmRecord *ar; - AlarmRecord *old_head; - GList *l; - - ar = alarm; - - l = g_list_find (alarms, ar); - if (!l) { - g_message ("alarm_remove(): Requested removal of nonexistent alarm!"); - return; - } - - old_head = alarms->data; - - if (old_head == ar) - pop_alarm (); - else { - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - } - - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); -} - -/** - * alarm_init: - * @void: - * - * Initializes the alarm notification system. This must be called near the - * beginning of the program. - **/ -void -alarm_init (void) -{ - struct sigaction sa; - int flags; - - pipe (alarm_pipes); - - /* set non blocking mode */ - flags = 0; - fcntl (alarm_pipes [0], F_GETFL, &flags); - fcntl (alarm_pipes [0], F_SETFL, flags | O_NONBLOCK); - gdk_input_add (alarm_pipes [0], GDK_INPUT_READ, alarm_ready, NULL); - - /* Setup the signal handler */ - sa.sa_handler = alarm_signal; - sigemptyset (&sa.sa_mask); - sa.sa_flags = SA_RESTART; - sigaction (SIGALRM, &sa, NULL); -} diff --git a/calendar/gui/alarm-notify/alarm.h b/calendar/gui/alarm-notify/alarm.h deleted file mode 100644 index 2394d28024..0000000000 --- a/calendar/gui/alarm-notify/alarm.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Evolution calendar - alarm notification support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_H -#define ALARM_H - -#include <time.h> - - - -typedef void (* AlarmFunction) (gpointer alarm_id, time_t trigger, gpointer data); -typedef void (* AlarmDestroyNotify) (gpointer data); - -void alarm_init (void); -gpointer alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, - AlarmDestroyNotify destroy_notify_fn); -void alarm_remove (gpointer alarm); - - - -#endif diff --git a/calendar/gui/alarm.c b/calendar/gui/alarm.c deleted file mode 100644 index c89b65ff5e..0000000000 --- a/calendar/gui/alarm.c +++ /dev/null @@ -1,304 +0,0 @@ -/* Evolution calendar - alarm notification support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <time.h> -#include <gnome.h> -#include <fcntl.h> -#include <signal.h> -#include <sys/time.h> -#include "alarm.h" - - - -/* The pipes used to notify about an alarm */ -static int alarm_pipes [2]; - -/* The list of pending alarms */ -static GList *alarms; - -/* A queued alarm structure */ -typedef struct { - time_t trigger; - AlarmFunction alarm_fn; - gpointer data; - AlarmDestroyNotify destroy_notify_fn; -} AlarmRecord; - - - -/* SIGALRM handler. Notifies the callback about the alarm. */ -static void -alarm_signal (int arg) -{ - char c = 0; - - write (alarm_pipes [1], &c, 1); -} - -/* Sets up an itimer and returns a success code */ -static gboolean -setup_itimer (time_t diff) -{ - struct itimerval itimer; - int v; - - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = diff; - itimer.it_value.tv_usec = 0; - - v = setitimer (ITIMER_REAL, &itimer, NULL); - - return (v == 0) ? TRUE : FALSE; -} - -/* Removes the head alarm, returns it, and schedules the next alarm in the - * queue. - */ -static AlarmRecord * -pop_alarm (void) -{ - AlarmRecord *ar; - GList *l; - - if (!alarms) - return NULL; - - ar = alarms->data; - - l = alarms; - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - - if (alarms) { - time_t now; - AlarmRecord *new_ar; - - now = time (NULL); - new_ar = alarms->data; - - if (!setup_itimer (new_ar->trigger - now)) { - g_message ("pop_alarm(): Could not reset the timer! " - "Weird things will happen."); - - /* FIXME: should we free the alarm list? What - * about further alarm removal requests that - * will fail? - */ - } - } else { - struct itimerval itimer; - int v; - - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = 0; - - v = setitimer (ITIMER_REAL, &itimer, NULL); - if (v != 0) - g_message ("pop_alarm(): Could not clear the timer! " - "Weird things may happen."); - } - - return ar; -} - -/* Input handler for our own alarm notification pipe */ -static void -alarm_ready (gpointer data, gint fd, GdkInputCondition cond) -{ - AlarmRecord *ar; - char c; - - if (read (alarm_pipes [0], &c, 1) != 1) { - g_message ("alarm_ready(): Uh? Could not read from notification pipe."); - return; - } - - g_assert (alarms != NULL); - ar = pop_alarm (); - - g_message ("alarm_ready(): Notifying about alarm on %s", ctime (&ar->trigger)); - - (* ar->alarm_fn) (ar, ar->trigger, ar->data); - - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); -} - -static int -compare_alarm_by_time (gconstpointer a, gconstpointer b) -{ - const AlarmRecord *ara = a; - const AlarmRecord *arb = b; - time_t diff; - - diff = ara->trigger - arb->trigger; - return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; -} - -/* Adds an alarm to the queue and sets up the timer */ -static gboolean -queue_alarm (time_t now, AlarmRecord *ar) -{ - time_t diff; - AlarmRecord *old_head; - - if (alarms) - old_head = alarms->data; - else - old_head = NULL; - - alarms = g_list_insert_sorted (alarms, ar, compare_alarm_by_time); - - if (old_head == alarms->data) - return TRUE; - - /* Set the timer for removal upon activation */ - - diff = ar->trigger - now; - if (!setup_itimer (diff)) { - GList *l; - - g_message ("queue_alarm(): Could not set up timer! Not queueing alarm."); - - l = g_list_find (alarms, ar); - g_assert (l != NULL); - - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - return FALSE; - } - - return TRUE; -} - -/** - * alarm_add: - * @trigger: Time at which alarm will trigger. - * @alarm_fn: Callback for trigger. - * @data: Closure data for callback. - * - * Adds an alarm to trigger at the specified time. The @alarm_fn will be called - * with the provided data and the alarm will be removed from the trigger list. - * - * Return value: An identifier for this alarm; it can be used to remove the - * alarm later with alarm_remove(). If the trigger time occurs in the past, then - * the alarm will not be queued and the function will return NULL. - **/ -gpointer -alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, - AlarmDestroyNotify destroy_notify_fn) -{ - time_t now; - AlarmRecord *ar; - - now = time (NULL); - if (trigger < now) - return NULL; - - ar = g_new (AlarmRecord, 1); - ar->trigger = trigger; - ar->alarm_fn = alarm_fn; - ar->data = data; - ar->destroy_notify_fn = destroy_notify_fn; - - g_message ("alarm_add(): Adding alarm for %s", ctime (&trigger)); - - if (!queue_alarm (now, ar)) { - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); - ar = NULL; - } - - return ar; -} - -/** - * alarm_remove: - * @alarm: A queued alarm identifier. - * - * Removes an alarm from the alarm queue. - **/ -void -alarm_remove (gpointer alarm) -{ - AlarmRecord *ar; - AlarmRecord *old_head; - GList *l; - - ar = alarm; - - l = g_list_find (alarms, ar); - if (!l) { - g_message ("alarm_remove(): Requested removal of nonexistent alarm!"); - return; - } - - old_head = alarms->data; - - if (old_head == ar) - pop_alarm (); - else { - alarms = g_list_remove_link (alarms, l); - g_list_free_1 (l); - } - - if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar->data); - - g_free (ar); -} - -/** - * alarm_init: - * @void: - * - * Initializes the alarm notification system. This must be called near the - * beginning of the program. - **/ -void -alarm_init (void) -{ - struct sigaction sa; - int flags; - - pipe (alarm_pipes); - - /* set non blocking mode */ - flags = 0; - fcntl (alarm_pipes [0], F_GETFL, &flags); - fcntl (alarm_pipes [0], F_SETFL, flags | O_NONBLOCK); - gdk_input_add (alarm_pipes [0], GDK_INPUT_READ, alarm_ready, NULL); - - /* Setup the signal handler */ - sa.sa_handler = alarm_signal; - sigemptyset (&sa.sa_mask); - sa.sa_flags = SA_RESTART; - sigaction (SIGALRM, &sa, NULL); -} diff --git a/calendar/gui/alarm.h b/calendar/gui/alarm.h deleted file mode 100644 index 2394d28024..0000000000 --- a/calendar/gui/alarm.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Evolution calendar - alarm notification support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_H -#define ALARM_H - -#include <time.h> - - - -typedef void (* AlarmFunction) (gpointer alarm_id, time_t trigger, gpointer data); -typedef void (* AlarmDestroyNotify) (gpointer data); - -void alarm_init (void); -gpointer alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, - AlarmDestroyNotify destroy_notify_fn); -void alarm_remove (gpointer alarm); - - - -#endif diff --git a/calendar/gui/bell.xpm b/calendar/gui/bell.xpm deleted file mode 100644 index b1ab537a17..0000000000 --- a/calendar/gui/bell.xpm +++ /dev/null @@ -1,83 +0,0 @@ -/* XPM */ -static char * bell_xpm[] = { -"16 16 64 1", -" c None", -". c #000000", -"+ c #E3BB43", -"@ c #E6C049", -"# c #EED275", -"$ c #F4E193", -"% c #F4DF8C", -"& c #EAC95C", -"* c #EFD57A", -"= c #FAEFBB", -"- c #FDF6D3", -"; c #FDF5C6", -"> c #F4E18F", -", c #E4BD43", -"' c #F6E295", -") c #FEF9D8", -"! c #FFFFFF", -"~ c #FFFADA", -"{ c #FCEEAA", -"] c #EBCA5A", -"^ c #E9C550", -"/ c #FAEA9C", -"( c #FEF7CB", -"_ c #FFF8CC", -": c #FDF1A8", -"< c #EED060", -"[ c #D39D12", -"} c #F2D55D", -"| c #FCEC91", -"1 c #FFF4AE", -"2 c #FFF5B6", -"3 c #FEEF97", -"4 c #F3D65E", -"5 c #D5A216", -"6 c #FAE05C", -"7 c #FFED7C", -"8 c #FFEF8C", -"9 c #FFF092", -"0 c #FDEB7A", -"a c #F4D750", -"b c #D8A717", -"c c #EAC01D", -"d c #F6D83E", -"e c #FAE255", -"f c #FAE362", -"g c #F9E161", -"h c #F6DE5B", -"i c #F1D145", -"j c #E6BE28", -"k c #D09B09", -"l c #B67E00", -"m c #CE9100", -"n c #D69F04", -"o c #E0B011", -"p c #E6BA1D", -"q c #E3B721", -"r c #E0B21E", -"s c #DCAB16", -"t c #D7A20D", -"u c #CC9303", -"v c #BE8400", -"w c #AC7500", -"x c #A06B00", -"y c #FFDD00", -" ", -" .. ", -" .+@. ", -" .#$%&. ", -" .*=-;>,. ", -" .')!~{]. ", -" .^/(~_:<[. ", -" .}|121345. ", -" .678980ab. ", -" .cdefghijkl. ", -" .mnopqrstuvwx. ", -" .............. ", -" .8y. ", -" .. ", -" ", -" "}; diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c deleted file mode 100644 index 2dd63f832c..0000000000 --- a/calendar/gui/calendar-commands.c +++ /dev/null @@ -1,855 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Main file for the GNOME Calendar program - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: - * Miguel de Icaza (miguel@kernel.org) - * Federico Mena (federico@helixcode.com) - */ - -#include <config.h> -#include <pwd.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <string.h> -#include <ctype.h> -#include <errno.h> -#include <gnome.h> -#include <libgnorba/gnorba.h> -#include <bonobo.h> -#include <cal-util/timeutil.h> -#include "gnome-cal.h" -#include "calendar-commands.h" -#include "print.h" - -#include "dayview.xpm" -#include "workweekview.xpm" -#include "weekview.xpm" -#include "monthview.xpm" - -#if 0 -#include "yearview.xpm" -#endif - -/* The username, used to set the `owner' field of the event */ -char *user_name; - -/* The full user name from the Gecos field */ -char *full_name; - -/* a gnome-config string prefix that can be used to access the calendar config info */ -char *calendar_settings; - -/* Day begin, day end parameters */ -int day_begin, day_end; - -/* Whether weeks starts on Sunday or Monday */ -int week_starts_on_monday; - -/* If AM/PM indicators should be used. This may not be supported by the new - views. */ -int am_pm_flag = 0; - -/* The array of color properties -- keep in sync with the enumeration defined in main.h. The color - * values specified here are the defaults for the program. - */ -struct color_prop color_props[] = { - { 0x3e72, 0x35ec, 0x8ba2, N_("Outline:"), "/calendar/Colors/outline" }, - { 0xffff, 0xffff, 0xffff, N_("Headings:"), "/calendar/Colors/headings" }, - { 0xf26c, 0xecec, 0xbbe7, N_("Empty days:"), "/calendar/Colors/empty_bg" }, - { 0xfc1e, 0xf87f, 0x5f80, N_("Appointments:"), "/calendar/Colors/mark_bg" }, - { 0xd364, 0xc6b7, 0x7969, N_("Highlighted day:"), "/calendar/Colors/prelight_bg" }, - { 0x01f0, 0x01f0, 0x01f0, N_("Day numbers:"), "/calendar/Colors/day_fg" }, - { 0x0000, 0x0000, 0xffff, N_("Current day's number:"), "/calendar/Colors/current_fg" }, - { 0xbbbb, 0xbbbb, 0x0000, N_("To-Do item that is not yet due:"), "/calendar/Colors/todo_not_yet" }, - { 0xdddd, 0xbbbb, 0x0000, N_("To-Do item that is due today:"), "/calendar/Colors/todo_today" }, - { 0xbbbb, 0xdddd, 0x0000, N_("To-Do item that is overdue:"), "/calendar/Colors/todo_overdue" } -}; - -/* Number of active calendars */ -int active_calendars = 0; - -/* A list of all of the calendars started */ -GList *all_calendars = NULL; - -/* If set, beep on display alarms */ -gboolean beep_on_display = 0; - -/* If true, timeout the beeper on audio alarms */ - -gboolean enable_aalarm_timeout = 0; -guint audio_alarm_timeout = 0; -const guint MAX_AALARM_TIMEOUT = 3600; -const guint MAX_SNOOZE_SECS = 3600; -gboolean enable_snooze = 0; -guint snooze_secs = 60; - -#if 0 -CalendarAlarm alarm_defaults[4] = { - { ALARM_MAIL, 0, 15, ALARM_MINUTES }, - { ALARM_PROGRAM, 0, 15, ALARM_MINUTES }, - { ALARM_DISPLAY, 0, 15, ALARM_MINUTES }, - { ALARM_AUDIO, 0, 15, ALARM_MINUTES } -}; -#endif - -static void -init_username (void) -{ - user_name = g_strdup(g_get_user_name()); - full_name = g_strdup(g_get_real_name()); -} - -static int -range_check_hour (int hour) -{ - if (hour < 0) - hour = 0; - else if (hour >= 24) - hour = 23; - - return hour; -} - -#if 0 -static void -init_default_alarms (void) -{ - int i; - gboolean def; - - alarm_defaults [ALARM_DISPLAY].type = ALARM_DISPLAY; - alarm_defaults [ALARM_AUDIO].type = ALARM_AUDIO; - alarm_defaults [ALARM_PROGRAM].type = ALARM_PROGRAM; - alarm_defaults [ALARM_MAIL].type = ALARM_MAIL; - - for (i = 0; i < 4; i++) { - switch (alarm_defaults [i].type) { - case ALARM_DISPLAY: - gnome_config_push_prefix ("/calendar/alarms/def_disp_"); - break; - case ALARM_AUDIO: - gnome_config_push_prefix ("/calendar/alarms/def_audio_"); - break; - case ALARM_PROGRAM: - gnome_config_push_prefix ("/calendar/alarms/def_prog_"); - break; - case ALARM_MAIL: - gnome_config_push_prefix ("/calendar/alarms/def_mail_"); - break; - } - - alarm_defaults[i].enabled = gnome_config_get_int ("enabled=0"); - if (alarm_defaults[i].type != ALARM_MAIL) { - alarm_defaults[i].count = gnome_config_get_int ("count=15"); - alarm_defaults[i].units = gnome_config_get_int ("units=0"); - } else { - alarm_defaults[i].count = gnome_config_get_int ("count=1"); - alarm_defaults[i].count = gnome_config_get_int ("count=2"); - } - - alarm_defaults[i].data = gnome_config_get_string_with_default ("data=", - &def); - if (def) - alarm_defaults[i].data = NULL; - - gnome_config_pop_prefix (); - } -} -#endif - -static void -about_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GtkWidget *about; - const gchar *authors[] = { - "Miguel de Icaza (miguel@kernel.org)", - "Federico Mena (federico@gimp.org)", - "Arturo Espinosa (arturo@nuclecu.unam.mx)", - "Russell Steinthal (rms39@columbia.edu)", - NULL - }; - - about = gnome_about_new (_("Gnome Calendar"), VERSION, - "(C) 1998 the Free Software Foundation", - authors, - _("The GNOME personal calendar and schedule manager."), - NULL); - gtk_window_set_modal (GTK_WINDOW (about), TRUE); - gnome_dialog_set_close (GNOME_DIALOG (about), TRUE); - gtk_widget_show (about); -} - -/* Callback for the new appointment command */ -static void -new_appointment_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (user_data); - gnome_calendar_new_appointment (gcal); -} - -/* Prints the calendar at its current view and time range */ -static void -print (GnomeCalendar *gcal, gboolean preview) -{ - time_t start; - const char *view; - PrintView print_view; - - gnome_calendar_get_current_time_range (gcal, &start, NULL); - view = gnome_calendar_get_current_view_name (gcal); - - if (strcmp (view, "dayview") == 0) - print_view = PRINT_VIEW_DAY; - else if (strcmp (view, "workweekview") == 0 || strcmp (view, "weekview") == 0) - print_view = PRINT_VIEW_WEEK; - else if (strcmp (view, "monthview") == 0) - print_view = PRINT_VIEW_MONTH; - else { - g_assert_not_reached (); - print_view = PRINT_VIEW_DAY; - } - - print_calendar (gcal, preview, start, print_view); -} - -/* Toolbar/Print callback */ -static void -tb_print_cb (GtkWidget *widget, gpointer data) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - print (gcal, FALSE); -} - -/* File/Print callback */ -static void -file_print_cb (BonoboUIHandler *uih, void *data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - print (gcal, FALSE); -} - -void -time_format_changed (void) -{ - GList *l; - - for (l = all_calendars; l; l = l->next) - gnome_calendar_time_format_changed (GNOME_CALENDAR (l->data)); -} - -void -colors_changed (void) -{ - GList *l; - - for (l = all_calendars; l; l = l->next) - gnome_calendar_colors_changed (GNOME_CALENDAR (l->data)); -} - -void -todo_properties_changed(void) -{ - GList *l; - - for (l = all_calendars; l; l = l->next) - gnome_calendar_todo_properties_changed (GNOME_CALENDAR (l->data)); -} - -/* Sets a clock cursor for the specified calendar window */ -static void -set_clock_cursor (GnomeCalendar *gcal) -{ - GdkCursor *cursor; - - cursor = gdk_cursor_new (GDK_WATCH); - gdk_window_set_cursor (GTK_WIDGET (gcal)->window, cursor); - gdk_cursor_destroy (cursor); - gdk_flush (); -} - -/* Resets the normal cursor for the specified calendar window */ -static void -set_normal_cursor (GnomeCalendar *gcal) -{ - gdk_window_set_cursor (GTK_WIDGET (gcal)->window, NULL); - gdk_flush (); -} - -static void -previous_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - set_clock_cursor (gcal); - gnome_calendar_previous (gcal); - set_normal_cursor (gcal); -} - -static void -next_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - set_clock_cursor (gcal); - gnome_calendar_next (gcal); - set_normal_cursor (gcal); -} - -static void -today_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - set_clock_cursor (gcal); - gnome_calendar_goto_today (gcal); - set_normal_cursor (gcal); -} - -static void -goto_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - goto_dialog (gcal); -} - -static void -show_day_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "dayview"); - gtk_widget_grab_focus (gcal->day_view); -} - -static void -show_work_week_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "workweekview"); - gtk_widget_grab_focus (gcal->work_week_view); -} - -static void -show_week_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "weekview"); - gtk_widget_grab_focus (gcal->week_view); -} - -static void -show_month_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "monthview"); - gtk_widget_grab_focus (gcal->month_view); -} - -#if 0 -static void -show_year_view_clicked (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - gnome_calendar_set_view (gcal, "yearview"); - gtk_widget_grab_focus (gcal->year_view); -} -#endif - -static void -new_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - new_calendar (full_name, NULL, NULL, FALSE); -} - -static void -close_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - all_calendars = g_list_remove (all_calendars, gcal); - - gtk_widget_destroy (GTK_WIDGET (gcal)); - active_calendars--; - - if (active_calendars == 0) - gtk_main_quit (); -} - - -void -quit_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - while (all_calendars){ - GnomeCalendar *cal = GNOME_CALENDAR (all_calendars->data); - - close_cmd (uih, cal, path); - } -} - - -static void -open_ok (GtkWidget *widget, GtkFileSelection *fs) -{ - GtkWidget *error_dialog; - int ret; - if(!g_file_exists (gtk_file_selection_get_filename (fs))) { - error_dialog = gnome_message_box_new ( - _("File not found"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, - NULL); - - gnome_dialog_set_parent (GNOME_DIALOG (error_dialog), GTK_WINDOW (fs)); - ret = gnome_dialog_run (GNOME_DIALOG (error_dialog)); - } else { - /* FIXME: find out who owns this calendar and use that name */ -#warning "FIXME: find out who owns this calendar and use that name" - /* - new_calendar ("Somebody", gtk_file_selection_get_filename (fs), NULL, NULL, FALSE); - */ - gtk_widget_destroy (GTK_WIDGET (fs)); - } -} - -static void -open_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GtkFileSelection *fs; - - fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Open calendar"))); - - gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", - (GtkSignalFunc) open_ok, - fs); - gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked", - (GtkSignalFunc) gtk_widget_destroy, - GTK_OBJECT (fs)); - - gtk_widget_show (GTK_WIDGET (fs)); - gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me */ -} - -static void -save_ok (GtkWidget *widget, GtkFileSelection *fs) -{ - GnomeCalendar *gcal; - gchar *fname; - - gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs))); - gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal"); - - fname = g_strdup (gtk_file_selection_get_filename (fs)); - g_free(fname); - gtk_main_quit (); -} - -static gint -close_save (GtkWidget *w) -{ - gtk_main_quit (); - return TRUE; -} - -static void -save_as_calendar_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GtkFileSelection *fs; - - fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save calendar"))); - gtk_object_set_user_data (GTK_OBJECT (fs), user_data); - - gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", - (GtkSignalFunc) save_ok, - fs); - gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked", - (GtkSignalFunc) close_save, - GTK_OBJECT (fs)); - gtk_signal_connect_object (GTK_OBJECT (fs), "delete_event", - GTK_SIGNAL_FUNC (close_save), - GTK_OBJECT (fs)); - gtk_widget_show (GTK_WIDGET (fs)); - gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me even more */ - gtk_main (); - gtk_widget_destroy (GTK_WIDGET (fs)); -} - -static void -properties_cmd (BonoboUIHandler *uih, void *user_data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (user_data); - properties (GTK_WIDGET (gcal)); -} - - -static GnomeUIInfo gnome_toolbar_view_buttons [] = { - GNOMEUIINFO_RADIOITEM (N_("Day"), N_("Show 1 day"), - show_day_view_clicked, - dayview_xpm), - GNOMEUIINFO_RADIOITEM (N_("5 Days"), N_("Show the working week"), - show_work_week_view_clicked, - workweekview_xpm), - GNOMEUIINFO_RADIOITEM (N_("Week"), N_("Show 1 week"), - show_week_view_clicked, - weekview_xpm), - GNOMEUIINFO_RADIOITEM (N_("Month"), N_("Show 1 month"), - show_month_view_clicked, - monthview_xpm), -#if 0 - GNOMEUIINFO_RADIOITEM (N_("Year"), N_("Show 1 year"), - show_year_view_clicked, - yearview_xpm), -#endif - GNOMEUIINFO_END -}; - - -static GnomeUIInfo calendar_toolbar [] = { - GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new appointment"), - new_appointment_cb, GNOME_STOCK_PIXMAP_NEW), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print this calendar"), tb_print_cb, GNOME_STOCK_PIXMAP_PRINT), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Go back in time"), previous_clicked, GNOME_STOCK_PIXMAP_BACK), - GNOMEUIINFO_ITEM_STOCK (N_("Today"), N_("Go to present time"), today_clicked, GNOME_STOCK_PIXMAP_HOME), - GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Go forward in time"), next_clicked, GNOME_STOCK_PIXMAP_FORWARD), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Go to"), N_("Go to a specific date"), goto_clicked, GNOME_STOCK_PIXMAP_JUMP_TO), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_RADIOLIST (gnome_toolbar_view_buttons), - - GNOMEUIINFO_END -}; - - - -/* Performs signal connection as appropriate for interpreters or native bindings */ -static void -do_ui_signal_connect (GnomeUIInfo *uiinfo, gchar *signal_name, - GnomeUIBuilderData *uibdata) -{ - if (uibdata->is_interp) - gtk_signal_connect_full (GTK_OBJECT (uiinfo->widget), - signal_name, NULL, uibdata->relay_func, - uibdata->data ? - uibdata->data : uiinfo->user_data, - uibdata->destroy_func, FALSE, FALSE); - - else if (uiinfo->moreinfo) - gtk_signal_connect (GTK_OBJECT (uiinfo->widget), - signal_name, uiinfo->moreinfo, uibdata->data ? - uibdata->data : uiinfo->user_data); -} - - -void -calendar_control_activate (BonoboControl *control, - GnomeCalendar *cal) -{ - Bonobo_UIHandler remote_uih; - GtkWidget *toolbar, *toolbar_frame; - BonoboControl *toolbar_control; - GnomeUIBuilderData uibdata; - BonoboUIHandler *uih; - gchar *page_name; - gint button, i; - int behavior; - - uih = bonobo_control_get_ui_handler (control); - g_assert (uih != NULL); - - uibdata.connect_func = do_ui_signal_connect; - uibdata.data = cal; - uibdata.is_interp = FALSE; - uibdata.relay_func = NULL; - uibdata.destroy_func = NULL; - - g_print ("In calendar_control_activate\n"); - - remote_uih = bonobo_control_get_remote_ui_handler (control); - bonobo_ui_handler_set_container (uih, remote_uih); - bonobo_object_release_unref (remote_uih, NULL); - - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, - GTK_TOOLBAR_BOTH); - gnome_app_fill_toolbar_custom (GTK_TOOLBAR (toolbar), - calendar_toolbar, &uibdata, - /*app->accel_group*/ NULL); - - /*gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));*/ - - for (i = 0; i < GNOME_CALENDAR_NUM_VIEWS; i++) - cal->view_toolbar_buttons[i] = gnome_toolbar_view_buttons[i].widget; - - /* Note that these indices should correspond with the button indices - in gnome_toolbar_view_buttons. */ - page_name = gnome_calendar_get_current_view_name (cal); - if (!strcmp (page_name, "dayview")) { - button = 0; - } else if (!strcmp (page_name, "workweekview")) { - button = 1; - } else if (!strcmp (page_name, "weekview")) { - button = 2; - } else if (!strcmp (page_name, "monthview")) { - button = 3; -#if 0 - } else if (!strcmp (page_name, "yearview")) { - button = 4; -#endif - } else { - g_warning ("Unknown calendar view: %s", page_name); - button = 0; - } - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cal->view_toolbar_buttons[button]), TRUE); - - gtk_widget_show_all (toolbar); - - toolbar_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (toolbar_frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (toolbar_frame), toolbar); - gtk_widget_show (toolbar_frame); - - gtk_widget_show_all (toolbar_frame); - - behavior = GNOME_DOCK_ITEM_BEH_EXCLUSIVE | GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL; - - if (!gnome_preferences_get_toolbar_detachable ()) - behavior |= GNOME_DOCK_ITEM_BEH_LOCKED; - - toolbar_control = bonobo_control_new (toolbar_frame); - - bonobo_ui_handler_dock_add (uih, "/Toolbar", - bonobo_object_corba_objref (BONOBO_OBJECT (toolbar_control)), - behavior, - GNOME_DOCK_TOP, - 1, 1, 0); - - /* file menu */ - bonobo_ui_handler_menu_new_item (uih, "/File/New/Calendar", N_("New Ca_lendar"), - N_("Create a new calendar"), - -1, BONOBO_UI_HANDLER_PIXMAP_NONE, - NULL, 0, 0, new_calendar_cmd, cal); - bonobo_ui_handler_menu_new_item (uih, "/File/Open/Calendar", N_("Open Ca_lendar"), - N_("Open a calendar"), -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, open_calendar_cmd, cal); - bonobo_ui_handler_menu_new_item (uih, "/File/Save Calendar As", - N_("Save Calendar As"), - N_("Save Calendar As"), - -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, save_as_calendar_cmd, cal); - bonobo_ui_handler_menu_new_item (uih, "/File/Print", N_("Print..."), - N_("Print this calendar"), -1, - BONOBO_UI_HANDLER_PIXMAP_STOCK, - GNOME_STOCK_PIXMAP_PRINT, - 'p', GDK_CONTROL_MASK, - file_print_cb, cal); - - /* edit menu */ - bonobo_ui_handler_menu_new_item (uih, "/Edit/New Appointment", - N_("_New appointment..."), N_("Create a new appointment"), - -1, BONOBO_UI_HANDLER_PIXMAP_STOCK, - GNOME_STOCK_MENU_NEW, 0, 0, - new_appointment_cb, cal); - - //bonobo_ui_handler_menu_new_separator (uih, "/Edit", -1); - - bonobo_ui_handler_menu_new_item (uih, "/Edit/Preferences", - N_("Preferences"), N_("Preferences"), - -1, BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, properties_cmd, cal); - /* help menu */ - - bonobo_ui_handler_menu_new_item (uih, - "/Help/About Calendar", - N_("About Calendar"), - N_("About Calendar"), - -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, about_calendar_cmd, cal); - -} - - -void -calendar_control_deactivate (BonoboControl *control) -{ - BonoboUIHandler *uih = bonobo_control_get_ui_handler (control); - g_assert (uih); - - g_print ("In calendar_control_deactivate\n"); - - bonobo_ui_handler_dock_remove (uih, "/Toolbar"); - bonobo_ui_handler_unset_container (uih); -} - - - - -static gint -calendar_close_event (GtkWidget *widget, GdkEvent *event, GnomeCalendar *gcal) -{ - close_cmd (NULL, gcal, NULL); - return TRUE; -} - - -GnomeCalendar * -new_calendar (char *full_name, char *geometry, char *page, gboolean hidden) -{ - GtkWidget *toplevel; - char title[128]; - int xpos, ypos, width, height; - - - /* i18n: This "%s%s" indicates possession. Languages where the order is - * the inverse should translate it to "%2$s%1$s". - */ - g_snprintf(title, 128, _("%s%s"), full_name, _("'s calendar")); - - toplevel = gnome_calendar_new (title); - - if (gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height)){ - if (xpos != -1) - gtk_widget_set_uposition (toplevel, xpos, ypos); - } - - if (page) - gnome_calendar_set_view (GNOME_CALENDAR (toplevel), page); - - gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event", - GTK_SIGNAL_FUNC(calendar_close_event), toplevel); - - active_calendars++; - all_calendars = g_list_prepend (all_calendars, toplevel); - - if (hidden){ - GnomeWinState state; - - /* Realize the toplevel window to prevent a segfault */ - gtk_widget_realize (toplevel); - state = gnome_win_hints_get_state (toplevel); - - state |= WIN_STATE_MINIMIZED; - gnome_win_hints_set_state (toplevel, state); - } - - gtk_widget_show (toplevel); - - return GNOME_CALENDAR (toplevel); -} - - -void calendar_set_uri (GnomeCalendar *gcal, char *calendar_file) -{ - gboolean success; - - g_return_if_fail (gcal); - g_return_if_fail (calendar_file); - - printf ("calendar_set_uri: calendar_file is '%s'\n", calendar_file); - - success = gnome_calendar_open (gcal, - calendar_file, - CALENDAR_OPEN_OR_CREATE); - - printf (" load or create returned %d\n", success); -} - - - - - -/* - * Initializes the calendar internal variables, loads defaults - */ -void -init_calendar (void) -{ - int i; - char *cspec, *color; - char *str; - - init_username (); - /*user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");*/ - - gnome_config_push_prefix (calendar_settings); - - /* Read calendar settings */ - - day_begin = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day start=8")); - day_end = range_check_hour (gnome_config_get_int ("/calendar/Calendar/Day end=17")); - am_pm_flag = gnome_config_get_bool ("/calendar/Calendar/AM PM flag=0"); - week_starts_on_monday = gnome_config_get_bool ("/calendar/Calendar/Week starts on Monday=0"); - - if (day_end < day_begin){ - day_begin = 8; - day_end = 17; - } - - /* Read color settings */ - - for (i = 0; i < COLOR_PROP_LAST; i++) { - cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b); - str = g_strconcat (color_props[i].key, "=", cspec, NULL); - - color = gnome_config_get_string (str); - parse_color_spec (color, &color_props[i].r, &color_props[i].g, &color_props[i].b); - - g_free (str); - g_free (color); - } - - /* read todolist settings */ - - todo_show_time_remaining = gnome_config_get_bool("/calendar/Todo/show_time_remain"); - todo_show_due_date = gnome_config_get_bool("/calendar/Todo/show_due_date"); - - todo_item_dstatus_highlight_overdue = gnome_config_get_bool("/calendar/Todo/highlight_overdue"); - - todo_item_dstatus_highlight_due_today = gnome_config_get_bool("/calendar/Todo/highlight_due_today"); - - todo_item_dstatus_highlight_not_due_yet = gnome_config_get_bool("/calendar/Todo/highlight_not_due_yet"); - - todo_current_sort_column = gnome_config_get_int("/calendar/Todo/sort_column"); - - todo_current_sort_type = gnome_config_get_int("/calendar/Todo/sort_type"); - - todo_show_priority = gnome_config_get_bool("/calendar/Todo/show_priority"); - - /* read alarm settings */ - beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE"); - enable_aalarm_timeout = gnome_config_get_bool ("/calendar/alarms/enable_audio_timeout=FALSE"); - audio_alarm_timeout = gnome_config_get_int ("/calendar/alarms/audio_alarm_timeout=60"); - if (audio_alarm_timeout < 1) - audio_alarm_timeout = 1; - if (audio_alarm_timeout > MAX_AALARM_TIMEOUT) - audio_alarm_timeout = MAX_AALARM_TIMEOUT; - enable_snooze = gnome_config_get_bool ("/calendar/alarms/enable_snooze=FALSE"); - snooze_secs = gnome_config_get_int ("/calendar/alarms/snooze_secs=300"); - if (snooze_secs < 1) - snooze_secs = 1; - if (snooze_secs > MAX_SNOOZE_SECS) - snooze_secs = MAX_SNOOZE_SECS; - -#if 0 - init_default_alarms (); -#endif - - /* Done */ - - gnome_config_pop_prefix (); -} diff --git a/calendar/gui/calendar-commands.h b/calendar/gui/calendar-commands.h deleted file mode 100644 index f48ba333bc..0000000000 --- a/calendar/gui/calendar-commands.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef CALENDAR_COMMANDS_H -#define CALENDAR_COMMANDS_H - -#include <bonobo/bonobo-control.h> -#include "gnome-cal.h" - -/* This enum and the following array define the color preferences */ - -typedef enum { - COLOR_PROP_OUTLINE_COLOR, /* Color of calendar outline */ - COLOR_PROP_HEADING_COLOR, /* Color for headings */ - COLOR_PROP_EMPTY_DAY_BG, /* Background color for empty days */ - COLOR_PROP_MARK_DAY_BG, /* Background color for days with appointments */ - COLOR_PROP_PRELIGHT_DAY_BG, /* Background color for prelighted day */ - COLOR_PROP_DAY_FG, /* Color for day numbers */ - COLOR_PROP_CURRENT_DAY_FG, /* Color for current day's number */ - COLOR_PROP_TODO_NOT_DUE_YET, /* Color for Todo items not yet due */ - COLOR_PROP_TODO_DUE_TODAY, /* Color for Todo items due today */ - COLOR_PROP_TODO_OVERDUE, /* Color for Todo items that are overdue */ - COLOR_PROP_LAST /* Number of color properties */ -} ColorProp; - -struct color_prop { - int r; /* Values are in [0, 65535] */ - int g; - int b; - char *label; /* Label for properties dialog */ - char *key; /* Key for gnome_config */ -}; - -extern struct color_prop color_props[]; - - -#define COOKIE_USER_HOME_DIR ((char *) -1) - - -/* Calendar preferences */ - -extern int day_begin, day_end; -extern char *user_name; -extern int am_pm_flag; -extern int week_starts_on_monday; - -/* todo preferences */ -extern int todo_show_due_date; - -extern int todo_item_dstatus_highlight_overdue; -extern int todo_item_dstatus_highlight_due_today; -extern int todo_item_dstatus_highlight_not_due_yet; - -extern int todo_show_time_remaining; -extern int todo_show_priority; -extern char *todo_overdue_font_text; -extern gboolean todo_style_changed; -extern gint todo_current_sort_column; -extern gint todo_current_sort_type; - -/* alarm stuff */ -#if 0 -extern CalendarAlarm alarm_defaults[4]; -#endif -extern gboolean beep_on_display; -extern gboolean enable_aalarm_timeout; -extern guint audio_alarm_timeout; -extern const guint MAX_AALARM_TIMEOUT; -extern gboolean enable_snooze; -extern guint snooze_secs; -extern const guint MAX_SNOOZE_SECS; - -/* Creates and runs the preferences dialog box */ -void properties (GtkWidget *toplevel); - -/* Asks for all the time-related displays to be updated when the user changes the time format - * preferences. - */ -void time_format_changed (void); - -/* Asks for all the month items' colors to be reset */ -void colors_changed (void); - -/* Asks for all todo lists to reflect the accurate properties */ -void todo_properties_changed(void); - -/* Creates and runs the Go-to date dialog */ -void goto_dialog (GnomeCalendar *gcal); - -/* Returns a pointer to a statically-allocated string with a representation of the specified color. - * Values must be in [0, 65535]. - */ -char *build_color_spec (int r, int g, int b); - -/* Parses a color specification of the form "#%04x%04x%04x" and returns the color components. */ -void parse_color_spec (char *spec, int *r, int *g, int *b); - -/* Calls build_color_spec() for the color in the specified property number */ -char *color_spec_from_prop (ColorProp propnum); - -GnomeCalendar *new_calendar (char *full_name, - char *geometry, - char *page, - gboolean hidden); - -void calendar_set_uri (GnomeCalendar *gcal, char *calendar_file); - - -/*----------------------------------------------------------------------*/ -/* FIXME -- where should this stuff go? */ -/*----------------------------------------------------------------------*/ - -void init_calendar (void); - -void calendar_control_activate (BonoboControl *control, - GnomeCalendar *cal); -void calendar_control_deactivate (BonoboControl *control); - -void quit_cmd (BonoboUIHandler *uih, void *user_data, const char *path); - -/*extern char *user_calendar_file;*/ -extern char *user_name; -extern char *full_name; -extern int debug_alarms; -extern int active_calendars; -extern GList *all_calendars; - -#endif /* CALENDAR_COMMANDS_H */ diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c deleted file mode 100644 index 8644b8928c..0000000000 --- a/calendar/gui/calendar-component.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.c - * - * Copyright (C) 2000 Helix Code, 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. - * - * Author: Ettore Perazzoli - */ - -#include <config.h> -#include <bonobo.h> -#include "evolution-shell-component.h" -#include "component-factory.h" -#include "control-factory.h" - - - -#ifdef USING_OAF -#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" -#else -#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:evolution-calendar" -#endif - -static BonoboGenericFactory *factory = NULL; - -static const EvolutionShellComponentFolderType folder_types[] = { - { "calendar", "evolution-calendar.png" }, - { NULL, NULL } -}; - - -/* EvolutionShellComponent methods and signals. */ - -static EvolutionShellComponentResult -create_view (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - BonoboControl **control_return, - void *closure) -{ - BonoboControl *control; - - if (g_strcasecmp (type, "calendar") != 0) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE; - - control = control_factory_new_control (); - bonobo_control_set_property (control, "folder_uri", physical_uri, NULL); - - *control_return = control; - - return EVOLUTION_SHELL_COMPONENT_OK; -} - -static gint owner_count = 0; - -static void -owner_set_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - const char *evolution_homedir) -{ - owner_count ++; -} - -static void -owner_unset_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - EvolutionShellClient shell_client, - void *data) -{ - owner_count --; - if (owner_count <= 0) - gtk_main_quit(); -} - - -/* The factory function. */ - -static BonoboObject * -factory_fn (BonoboGenericFactory *factory, - void *closure) -{ - EvolutionShellComponent *shell_component; - - shell_component = evolution_shell_component_new (folder_types, create_view, NULL, NULL, NULL, NULL); - - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", - GTK_SIGNAL_FUNC (owner_set_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", - GTK_SIGNAL_FUNC (owner_unset_cb), NULL); - - return BONOBO_OBJECT (shell_component); -} - - -void -component_factory_init (void) -{ - if (factory != NULL) - return; - - factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); - - if (factory == NULL) - g_error ("Cannot initialize Evolution's calendar component."); -} diff --git a/calendar/gui/calendar-component.h b/calendar/gui/calendar-component.h deleted file mode 100644 index f83a849452..0000000000 --- a/calendar/gui/calendar-component.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.h - * - * Copyright (C) 2000 Helix Code, 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. - * - * Author: Ettore Perazzoli - */ - -#ifndef _COMPONENT_FACTORY_H_ -#define _COMPONENT_FACTORY_H_ - -void component_factory_init (void); - -#endif /* _COMPONENT_FACTORY_H_ */ diff --git a/calendar/gui/calendar-control.gnorba b/calendar/gui/calendar-control.gnorba deleted file mode 100644 index ed504d8f5b..0000000000 --- a/calendar/gui/calendar-control.gnorba +++ /dev/null @@ -1,11 +0,0 @@ -[control-factory:calendar] -type=exe -repo_id=IDL:Bonobo/GenericFactory:1.0 -description=Factory for the sample Calendar control -location_info=evolution-calendar - -[control:calendar] -type=factory -repo_id=IDL:BonoboControl/calendar-control:1.0 IDL:Bonobo/Control:1.0 -description=A sample Bonobo control which displays an calendar. -location_info=control-factory:calendar diff --git a/calendar/gui/calendar-control.oafinfo b/calendar/gui/calendar-control.oafinfo deleted file mode 100644 index fb0f138caf..0000000000 --- a/calendar/gui/calendar-control.oafinfo +++ /dev/null @@ -1,28 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the sample Calendar control"/> -</oaf_server> - -<oaf_server iid="OAFIID:control:calendar:dd34ddae-25c6-486b-a8a8-3e8f0286b54c" - type="factory" - location="OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:BonoboControl/calendar-control:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="A sample Bonobo control which displays an calendar."/> -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c deleted file mode 100644 index a39044f7e6..0000000000 --- a/calendar/gui/calendar-model.c +++ /dev/null @@ -1,1782 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* Evolution calendar - Data model for ETable - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -/* We need this for strptime. */ -#define _XOPEN_SOURCE - -#include <config.h> -#include <ctype.h> -#include <math.h> -#undef _XOPEN_SOURCE -#include <sys/time.h> -#define _XOPEN_SOURCE -#include <time.h> -#include <gnome.h> -#include <cal-util/timeutil.h> -#include "calendar-model.h" -#include "calendar-commands.h" - - - -/* Private part of the ECalendarModel structure */ -typedef struct { - /* Calendar client we are using */ - CalClient *client; - - /* Types of objects we are dealing with */ - CalObjType type; - - /* Array of pointers to calendar objects */ - GArray *objects; - - /* UID -> array index hash */ - GHashTable *uid_index_hash; - - /* HACK: so that ETable can do its stupid append_row() thing */ - guint appending_row : 1; -} CalendarModelPrivate; - - - -static void calendar_model_class_init (CalendarModelClass *class); -static void calendar_model_init (CalendarModel *model); -static void calendar_model_destroy (GtkObject *object); - -static int calendar_model_column_count (ETableModel *etm); -static int calendar_model_row_count (ETableModel *etm); -static void *calendar_model_value_at (ETableModel *etm, int col, int row); -static void calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *value); -static gboolean calendar_model_is_cell_editable (ETableModel *etm, int col, int row); -static void calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row); -static void *calendar_model_duplicate_value (ETableModel *etm, int col, const void *value); -static void calendar_model_free_value (ETableModel *etm, int col, void *value); -static void *calendar_model_initialize_value (ETableModel *etm, int col); -static gboolean calendar_model_value_is_empty (ETableModel *etm, int col, const void *value); -#if 0 -static char * calendar_model_value_to_string (ETableModel *etm, int col, const void *value); -#endif -static void load_objects (CalendarModel *model); -static int remove_object (CalendarModel *model, const char *uid); - -static ETableModelClass *parent_class; - - - -/** - * calendar_model_get_type: - * @void: - * - * Registers the #CalendarModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalendarModel class. - **/ -GtkType -calendar_model_get_type (void) -{ - static GtkType calendar_model_type = 0; - - if (!calendar_model_type) { - static GtkTypeInfo calendar_model_info = { - "CalendarModel", - sizeof (CalendarModel), - sizeof (CalendarModelClass), - (GtkClassInitFunc) calendar_model_class_init, - (GtkObjectInitFunc) calendar_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - calendar_model_type = gtk_type_unique (E_TABLE_MODEL_TYPE, &calendar_model_info); - } - - return calendar_model_type; -} - -/* Class initialization function for the calendar table model */ -static void -calendar_model_class_init (CalendarModelClass *class) -{ - GtkObjectClass *object_class; - ETableModelClass *etm_class; - - object_class = (GtkObjectClass *) class; - etm_class = (ETableModelClass *) class; - - parent_class = gtk_type_class (E_TABLE_MODEL_TYPE); - - object_class->destroy = calendar_model_destroy; - - etm_class->column_count = calendar_model_column_count; - etm_class->row_count = calendar_model_row_count; - etm_class->value_at = calendar_model_value_at; - etm_class->set_value_at = calendar_model_set_value_at; - etm_class->is_cell_editable = calendar_model_is_cell_editable; - etm_class->append_row = calendar_model_append_row; - etm_class->duplicate_value = calendar_model_duplicate_value; - etm_class->free_value = calendar_model_free_value; - etm_class->initialize_value = calendar_model_initialize_value; - etm_class->value_is_empty = calendar_model_value_is_empty; -#if 0 - etm_class->value_to_string = calendar_model_value_to_string; -#endif -} - -/* Object initialization function for the calendar table model */ -static void -calendar_model_init (CalendarModel *model) -{ - CalendarModelPrivate *priv; - - priv = g_new0 (CalendarModelPrivate, 1); - model->priv = priv; - - priv->objects = g_array_new (FALSE, TRUE, sizeof (CalComponent *)); - priv->uid_index_hash = g_hash_table_new (g_str_hash, g_str_equal); -} - -/* Called from g_hash_table_foreach_remove(), frees a stored UID->index - * mapping. - */ -static gboolean -free_uid_index (gpointer key, gpointer value, gpointer data) -{ - int *idx; - - idx = value; - g_free (idx); - - return TRUE; -} - -/* Frees the objects stored in the calendar model */ -static void -free_objects (CalendarModel *model) -{ - CalendarModelPrivate *priv; - int i; - - priv = model->priv; - - g_hash_table_foreach_remove (priv->uid_index_hash, free_uid_index, NULL); - - for (i = 0; i < priv->objects->len; i++) { - CalComponent *comp; - - comp = g_array_index (priv->objects, CalComponent *, i); - g_assert (comp != NULL); - gtk_object_unref (GTK_OBJECT (comp)); - } - - g_array_set_size (priv->objects, 0); -} - -/* Destroy handler for the calendar table model */ -static void -calendar_model_destroy (GtkObject *object) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (object)); - - model = CALENDAR_MODEL (object); - priv = model->priv; - - /* Free the calendar client interface object */ - - if (priv->client) { - gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), model); - gtk_object_unref (GTK_OBJECT (priv->client)); - priv->client = NULL; - } - - /* Free the uid->index hash data and the array of UIDs */ - - free_objects (model); - - g_hash_table_destroy (priv->uid_index_hash); - priv->uid_index_hash = NULL; - - g_array_free (priv->objects, TRUE); - priv->objects = NULL; - - /* Free the private structure */ - - g_free (priv); - model->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - - -/* ETableModel methods */ - -/* column_count handler for the calendar table model */ -static int -calendar_model_column_count (ETableModel *etm) -{ - return CAL_COMPONENT_FIELD_NUM_FIELDS; -} - -/* row_count handler for the calendar table model */ -static int -calendar_model_row_count (ETableModel *etm) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - return priv->objects->len; -} - -/* Creates a nice string representation of a time value */ -static char* -get_time_t (time_t *t, gboolean skip_midnight) -{ - static char buffer[32]; - struct tm *tmp_tm; - - if (*t <= 0) { - buffer[0] = '\0'; - } else { - tmp_tm = localtime (t); - - if (skip_midnight && tmp_tm->tm_hour == 0 - && tmp_tm->tm_min == 0 && tmp_tm->tm_sec == 0) - strftime (buffer, 32, "%a %x", tmp_tm); - else - strftime (buffer, 32, "%a %x %T", tmp_tm); - } - - return buffer; -} - -/* Builds a string based on the list of CATEGORIES properties of a calendar - * component. - */ -static char * -get_categories (CalComponent *comp) -{ - GSList *categories; - GString *str; - char *s; - GSList *l; - - cal_component_get_categories_list (comp, &categories); - - str = g_string_new (NULL); - - for (l = categories; l; l = l->next) { - const char *category; - - category = l->data; - g_string_append (str, category); - - if (l->next != NULL) - g_string_append (str, ", "); - } - - s = str->str; - - g_string_free (str, FALSE); - cal_component_free_categories_list (categories); - - return s; -} - -/* Returns a string based on the CLASSIFICATION property of a calendar component */ -static char * -get_classification (CalComponent *comp) -{ - CalComponentClassification classif; - - cal_component_get_classification (comp, &classif); - - switch (classif) { - case CAL_COMPONENT_CLASS_NONE: - return ""; - - case CAL_COMPONENT_CLASS_PUBLIC: - return _("Public"); - - case CAL_COMPONENT_CLASS_PRIVATE: - return _("Private"); - - case CAL_COMPONENT_CLASS_CONFIDENTIAL: - return _("Confidential"); - - case CAL_COMPONENT_CLASS_UNKNOWN: - return _("Unknown"); - - default: - g_assert_not_reached (); - return NULL; - } -} - -/* Builds a string for the COMPLETED property of a calendar component */ -static char * -get_completed (CalComponent *comp) -{ - struct icaltimetype *completed; - time_t t; - - cal_component_get_completed (comp, &completed); - - if (!completed) - t = 0; - else { - t = time_from_icaltimetype (*completed); - cal_component_free_icaltimetype (completed); - } - - return get_time_t (&t, FALSE); -} - -/* Builds a string for and frees a date/time value */ -static char * -get_and_free_datetime (CalComponentDateTime dt) -{ - time_t t; - - if (!dt.value) - t = 0; - else - t = time_from_icaltimetype (*dt.value); - - cal_component_free_datetime (&dt); - - return get_time_t (&t, FALSE); -} - -/* Builds a string for the DTEND property of a calendar component */ -static char * -get_dtend (CalComponent *comp) -{ - CalComponentDateTime dt; - - cal_component_get_dtend (comp, &dt); - return get_and_free_datetime (dt); -} - -/* Builds a string for the DTSTART property of a calendar component */ -static char * -get_dtstart (CalComponent *comp) -{ - CalComponentDateTime dt; - - cal_component_get_dtstart (comp, &dt); - return get_and_free_datetime (dt); -} - -/* Builds a string for the DUE property of a calendar component */ -static char * -get_due (CalComponent *comp) -{ - CalComponentDateTime dt; - - cal_component_get_due (comp, &dt); - return get_and_free_datetime (dt); -} - -/* Builds a string for the GEO property of a calendar component */ -static char* -get_geo (CalComponent *comp) -{ - struct icalgeotype *geo; - static gchar buf[32]; - - cal_component_get_geo (comp, &geo); - - if (!geo) - buf[0] = '\0'; - else { - g_snprintf (buf, sizeof (buf), "%g %s, %g %s", - fabs (geo->lat), - geo->lat >= 0.0 ? _("N") : _("S"), - fabs (geo->lon), - geo->lon >= 0.0 ? _("E") : _("W")); - cal_component_free_geo (geo); - } - - return buf; -} - -/* Builds a string for the PERCENT property of a calendar component */ -static char * -get_percent (CalComponent *comp) -{ - int *percent; - static char buf[32]; - - cal_component_get_percent (comp, &percent); - - if (!percent) - buf[0] = '\0'; - else { - g_snprintf (buf, sizeof (buf), "%d%%", *percent); - cal_component_free_percent (percent); - } - - return buf; -} - -/* Builds a string for the PRIORITY property of a calendar component */ -static char * -get_priority (CalComponent *comp) -{ - int *priority; - static char buf[32]; - - cal_component_get_priority (comp, &priority); - - if (!priority) - buf[0] = '\0'; - else { - g_snprintf (buf, sizeof (buf), "%d", *priority); - cal_component_free_priority (priority); - } - - return buf; -} - -/* Builds a string for the SUMMARY property of a calendar component */ -static char * -get_summary (CalComponent *comp) -{ - CalComponentText summary; - - cal_component_get_summary (comp, &summary); - - if (summary.value) - return (char *) summary.value; - else - return ""; -} - -/* Builds a string for the TRANSPARENCY property of a calendar component */ -static char * -get_transparency (CalComponent *comp) -{ - CalComponentTransparency transp; - - cal_component_get_transparency (comp, &transp); - - switch (transp) { - case CAL_COMPONENT_TRANSP_NONE: - return ""; - - case CAL_COMPONENT_TRANSP_TRANSPARENT: - return _("Transparent"); - - case CAL_COMPONENT_TRANSP_OPAQUE: - return _("Opaque"); - - case CAL_COMPONENT_TRANSP_UNKNOWN: - return _("Unknown"); - - default: - g_assert_not_reached (); - return NULL; - } -} - -/* Builds a string for the URL property of a calendar component */ -static char * -get_url (CalComponent *comp) -{ - const char *url; - - cal_component_get_url (comp, &url); - - if (url) - return (char *) url; - else - return ""; -} - -/* Returns whether the component has any alarms defined for it */ -static gboolean -get_has_alarms (CalComponent *comp) -{ - CalComponentAlarm *alarm; - gboolean retval; - - alarm = cal_component_get_first_alarm (comp); - retval = (alarm != NULL); - - cal_component_alarm_free (alarm); - return retval; -} - -/* Returns whether the component has any recurrences defined for it */ -static gboolean -get_has_recurrences (CalComponent *comp) -{ - return cal_component_has_rdates (comp) || cal_component_has_rrules (comp); -} - -/* Returns whether the completion date has been set on a component */ -static gboolean -get_is_complete (CalComponent *comp) -{ - struct icaltimetype *t; - gboolean retval; - - cal_component_get_completed (comp, &t); - retval = (t != NULL); - - cal_component_free_icaltimetype (t); - return retval; -} - -/* Returns whether a calendar component is overdue. - * - * FIXME: This will only get called when the component is scrolled into the - * ETable. There should be some sort of dynamic update thingy for if a component - * becomes overdue while it is being viewed. - */ -static gboolean -get_is_overdue (CalComponent *comp) -{ - CalComponentDateTime dt; - gboolean retval; - - cal_component_get_due (comp, &dt); - - /* First, do we have a due date? */ - - if (!dt.value) - retval = FALSE; - else { - struct icaltimetype *completed; - time_t t; - - /* Second, is it already completed? */ - - cal_component_get_completed (comp, &completed); - - if (completed) { - retval = FALSE; - - cal_component_free_icaltimetype (completed); - goto out; - } - - /* Third, are we overdue as of right now? - * - * FIXME: should we check the PERCENT as well? If it is at 100% - * but the COMPLETED property is not set, is the component - * really overdue? - **/ - - t = time_from_icaltimetype (*dt.value); - - if (t < time (NULL)) - retval = TRUE; - else - retval = FALSE; - } - - out: - - cal_component_free_datetime (&dt); - - return retval; -} - -/* value_at handler for the calendar table model */ -static void * -calendar_model_value_at (ETableModel *etm, int col, int row) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - CalComponent *comp; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL); - g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - return get_categories (comp); - - case CAL_COMPONENT_FIELD_CLASSIFICATION: - return get_classification (comp); - - case CAL_COMPONENT_FIELD_COMPLETED: - return get_completed (comp); - - case CAL_COMPONENT_FIELD_DTEND: - return get_dtend (comp); - - case CAL_COMPONENT_FIELD_DTSTART: - return get_dtstart (comp); - - case CAL_COMPONENT_FIELD_DUE: - return get_due (comp); - - case CAL_COMPONENT_FIELD_GEO: - return get_geo (comp); - - case CAL_COMPONENT_FIELD_PERCENT: - return get_percent (comp); - - case CAL_COMPONENT_FIELD_PRIORITY: - return get_priority (comp); - - case CAL_COMPONENT_FIELD_SUMMARY: - return get_summary (comp); - - case CAL_COMPONENT_FIELD_TRANSPARENCY: - return get_transparency (comp); - - case CAL_COMPONENT_FIELD_URL: - return get_url (comp); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - return GINT_TO_POINTER (get_has_alarms (comp)); - - case CAL_COMPONENT_FIELD_ICON: - /* FIXME: Also support 'Assigned to me' & 'Assigned to someone - else'. */ - if (get_has_recurrences (comp)) - return GINT_TO_POINTER (1); - else - return GINT_TO_POINTER (0); - - case CAL_COMPONENT_FIELD_COMPLETE: - return GINT_TO_POINTER (get_is_complete (comp)); - - case CAL_COMPONENT_FIELD_RECURRING: - return GINT_TO_POINTER (get_has_recurrences (comp)); - - case CAL_COMPONENT_FIELD_OVERDUE: - return GINT_TO_POINTER (get_is_overdue (comp)); - - case CAL_COMPONENT_FIELD_COLOR: - if (get_is_overdue (comp)) - return "red"; - else - return NULL; - - default: - g_message ("calendar_model_value_at(): Requested invalid column %d", col); - return NULL; - } -} - -/* Returns whether a string is NULL, empty, or full of whitespace */ -static gboolean -string_is_empty (const char *value) -{ - const char *p; - gboolean empty = TRUE; - - if (value) { - p = value; - while (*p) { - if (!isspace (*p)) { - empty = FALSE; - break; - } - p++; - } - } - return empty; -} - - -/* FIXME: We need to set the "transient_for" property for the dialog, but - the model doesn't know anything about the windows. */ -static void -show_date_warning (void) -{ - GtkWidget *dialog; - char buffer[32], message[256]; - time_t t; - struct tm *tmp_tm; - - t = time (NULL); - tmp_tm = localtime (&t); - strftime (buffer, 32, "%a %x %T", tmp_tm); - - g_snprintf (message, 256, - _("The date must be entered in the format: \n\n%s"), - buffer); - - dialog = gnome_message_box_new (message, - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -/* Builds a list of categories from a comma-delimited string */ -static GSList * -categories_from_string (const char *value) -{ - GSList *list; - const char *categ_start; - const char *categ_end; - const char *p; - - if (!value) - return NULL; - - list = NULL; - - categ_start = categ_end = NULL; - - for (p = value; *p; p++) { - if (categ_start) { - if (*p == ',') { - char *c; - - c = g_strndup (categ_start, categ_end - categ_start + 1); - list = g_slist_prepend (list, c); - - categ_start = categ_end = NULL; - } else if (!isspace (*p)) - categ_end = p; - } else if (!isspace (*p) && *p != ',') - categ_start = categ_end = p; - } - - if (categ_start) { - char *c; - - c = g_strndup (categ_start, categ_end - categ_start + 1); - list = g_slist_prepend (list, c); - } - - return g_slist_reverse (list); -} - -/* Sets the list of categories from a comma-delimited string */ -static void -set_categories (CalComponent *comp, const char *value) -{ - GSList *list; - GSList *l; - - list = categories_from_string (value); - - cal_component_set_categories_list (comp, list); - - for (l = list; l; l = l->next) { - char *s; - - s = l->data; - g_free (s); - } - - g_slist_free (list); -} - -/* Parses a time value entered by the user; returns -1 if it could not be - * parsed. Returns 0 for an empty time. - */ -static time_t -parse_time (const char *value) -{ - struct tm tmp_tm; - struct tm *today_tm; - time_t t; - const char *p; - - if (string_is_empty (value)) - return 0; - - /* Skip any weekday name. */ - p = strptime (value, "%a", &tmp_tm); - if (!p) - p = value; - - /* Try to match the full date & time, or without the seconds, - or just the date, or just the time with/without seconds. - The info pages say we should clear the tm before calling - strptime. It also means that if we don't match a time we - get 00:00:00 which is good. */ - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%x %T", &tmp_tm)) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%x %H:%M", &tmp_tm)) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%x", &tmp_tm)) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%T", &tmp_tm)) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - if (!strptime (value, "%H:%M", &tmp_tm)) - return -1; /* Could not parse it */ - } - - /* We only got a time, so we use the - current day. */ - t = time (NULL); - today_tm = localtime (&t); - tmp_tm.tm_mday = today_tm->tm_mday; - tmp_tm.tm_mon = today_tm->tm_mon; - tmp_tm.tm_year = today_tm->tm_year; - } - } - } - - tmp_tm.tm_isdst = -1; - return mktime (&tmp_tm); -} - -/* Sets the completion time of a component */ -static void -set_completed (CalComponent *comp, const char *value) -{ - time_t t; - struct icaltimetype itt; - - t = parse_time (value); - if (t == -1) { - show_date_warning (); - return; - } else if (t == 0) { - cal_component_set_completed (comp, NULL); - return; - } else { - itt = icaltimetype_from_timet (t, FALSE); - cal_component_set_completed (comp, &itt); - } -} - -/* Sets a CalComponentDateTime value */ -static void -set_datetime (CalComponent *comp, const char *value, - void (* set_func) (CalComponent *comp, CalComponentDateTime *dt)) -{ - time_t t; - - t = parse_time (value); - if (t == -1) { - show_date_warning (); - return; - } else if (t == 0) { - (* set_func) (comp, NULL); - return; - } else { - CalComponentDateTime dt; - struct icaltimetype itt; - - itt = icaltimetype_from_timet (t, FALSE); - dt.value = &itt; - dt.tzid = NULL; - - (* set_func) (comp, &dt); - } -} - -/* FIXME: We need to set the "transient_for" property for the dialog, but the - * model doesn't know anything about the windows. - */ -static void -show_geo_warning (void) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new (_("The geographical position must be entered " - "in the format: \n\n45.436845,125.862501"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -/* Sets the geographical position value of a component */ -static void -set_geo (CalComponent *comp, const char *value) -{ - double latitude, longitude; - int matched; - struct icalgeotype geo; - - if (string_is_empty (value)) { - cal_component_set_geo (comp, NULL); - return; - } - - matched = sscanf (value, "%lg , %lg", &latitude, &longitude); - - if (matched != 2) { - show_geo_warning (); - return; - } - - geo.lat = latitude; - geo.lon = longitude; - cal_component_set_geo (comp, &geo); -} - -/* FIXME: We need to set the "transient_for" property for the dialog, but the - * model doesn't know anything about the windows. - */ -static void -show_percent_warning (void) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new (_("The percent value must be between 0 and 100, inclusive"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -/* Sets the percent value of a calendar component */ -static void -set_percent (CalComponent *comp, const char *value) -{ - int matched, percent; - - if (string_is_empty (value)) { - cal_component_set_percent (comp, NULL); - return; - } - - matched = sscanf (value, "%i", &percent); - - if (matched != 1 || percent < 0 || percent > 100) { - show_percent_warning (); - return; - } - - cal_component_set_percent (comp, &percent); -} - -/* FIXME: We need to set the "transient_for" property for the dialog, but the - * model doesn't know anything about the windows. */ -static void -show_priority_warning (void) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new (_("The priority must be between 1 and 9, inclusive"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -/* Sets the priority of a calendar component */ -static void -set_priority (CalComponent *comp, const char *value) -{ - int matched, priority; - - if (string_is_empty (value)) { - cal_component_set_priority (comp, NULL); - return; - } - - matched = sscanf (value, "%i", &priority); - - if (matched != 1 || priority < 1 || priority > 9) { - show_priority_warning (); - return; - } - - cal_component_set_priority (comp, &priority); -} - -/* Sets the summary of a calendar component */ -static void -set_summary (CalComponent *comp, const char *value) -{ - CalComponentText text; - - if (string_is_empty (value)) { - cal_component_set_summary (comp, NULL); - return; - } - - text.value = value; - text.altrep = NULL; /* FIXME: should we preserve the old ALTREP? */ - - cal_component_set_summary (comp, &text); -} - -/* Sets the URI of a calendar component */ -static void -set_url (CalComponent *comp, const char *value) -{ - if (string_is_empty (value)) { - cal_component_set_url (comp, NULL); - return; - } - - cal_component_set_url (comp, value); -} - -/* set_value_at handler for the calendar table model */ -static void -calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *value) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - CalComponent *comp; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - g_return_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS); - g_return_if_fail (row >= 0 && row < priv->objects->len); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - set_categories (comp, value); - break; - - /* FIXME: CLASSIFICATION requires an option menu cell renderer */ - - case CAL_COMPONENT_FIELD_COMPLETED: - set_completed (comp, value); - break; - - case CAL_COMPONENT_FIELD_DTEND: - /* FIXME: Need to reset dtstart if dtend happens before it */ - set_datetime (comp, value, cal_component_set_dtend); - break; - - case CAL_COMPONENT_FIELD_DTSTART: - /* FIXME: Need to reset dtend if dtstart happens after it */ - set_datetime (comp, value, cal_component_set_dtstart); - break; - - case CAL_COMPONENT_FIELD_DUE: - set_datetime (comp, value, cal_component_set_due); - break; - - case CAL_COMPONENT_FIELD_GEO: - set_geo (comp, value); - break; - - case CAL_COMPONENT_FIELD_PERCENT: - set_percent (comp, value); - break; - - case CAL_COMPONENT_FIELD_PRIORITY: - set_priority (comp, value); - break; - - case CAL_COMPONENT_FIELD_SUMMARY: - set_summary (comp, value); - break; - - /* FIXME: TRANSPARENCY requires an option menu cell renderer */ - - case CAL_COMPONENT_FIELD_URL: - set_url (comp, value); - break; - - default: - g_message ("calendar_model_set_value_at(): Requested invalid column %d", col); - break; - } - - /* FIXME: this is an ugly HACK. ETable needs a better API for the - * "click here to add an element" thingy. - */ - if (priv->appending_row) - return; - - if (!cal_client_update_object (priv->client, comp)) - g_message ("calendar_model_set_value_at(): Could not update the object!"); -} - -/* is_cell_editable handler for the calendar table model */ -static gboolean -calendar_model_is_cell_editable (ETableModel *etm, int col, int row) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, FALSE); - - /* FIXME: We can't check this as 'click-to-add' passes row 0. */ - /*g_return_val_if_fail (row >= 0 && row < priv->objects->len, FALSE);*/ - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - case CAL_COMPONENT_FIELD_SUMMARY: - case CAL_COMPONENT_FIELD_URL: - return TRUE; - - default: - return FALSE; - } -} - -/* append_row handler for the calendar model */ -static void -calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - CalComponent *comp; - int *new_idx, col; - const char *uid; - - model = CALENDAR_MODEL (etm); - priv = model->priv; - - /* This is a HACK */ - priv->appending_row = TRUE; - - /* FIXME: This should support other types of components, but for now it - * is only used for the task list. - */ - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - - cal_component_get_uid (comp, &uid); - - g_array_append_val (priv->objects, comp); - new_idx = g_new (int, 1); - *new_idx = priv->objects->len - 1; - g_hash_table_insert (priv->uid_index_hash, (char *) uid, new_idx); - - /* Notify the views about the new row. I think we have to do that here, - or the views may become confused when they start getting - "row_changed" or "cell_changed" signals for this new row. */ - e_table_model_row_inserted (etm, *new_idx); - - for (col = 0; col < CAL_COMPONENT_FIELD_NUM_FIELDS; col++) { - const void *val; - - if (!e_table_model_is_cell_editable (etm, col, *new_idx)) - continue; - - val = e_table_model_value_at(source, col, row); - e_table_model_set_value_at (etm, col, *new_idx, val); - } - - /* This is the end of the HACK */ - priv->appending_row = FALSE; - - if (!cal_client_update_object (priv->client, comp)) { - /* FIXME: Show error dialog. */ - g_message ("calendar_model_append_row(): Could not add new object!"); - remove_object (model, uid); - e_table_model_row_deleted (etm, *new_idx); - } -} - -/* Duplicates a string value */ -static char * -dup_string (const char *value) -{ - return g_strdup (value); -} - -/* duplicate_value handler for the calendar table model */ -static void * -calendar_model_duplicate_value (ETableModel *etm, int col, const void *value) -{ - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL); - - /* They are almost all dup_string()s for now, but we'll have real fields - * later. - */ - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - return dup_string (value); - - case CAL_COMPONENT_FIELD_CLASSIFICATION: - return (void *) value; - - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - return dup_string (value); - - case CAL_COMPONENT_FIELD_TRANSPARENCY: - return (void *) value; - - case CAL_COMPONENT_FIELD_URL: - return dup_string (value); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - case CAL_COMPONENT_FIELD_ICON: - case CAL_COMPONENT_FIELD_COMPLETE: - case CAL_COMPONENT_FIELD_RECURRING: - case CAL_COMPONENT_FIELD_OVERDUE: - case CAL_COMPONENT_FIELD_COLOR: - return (void *) value; - - default: - g_message ("calendar_model_duplicate_value(): Requested invalid column %d", col); - return NULL; - } -} - -/* free_value handler for the calendar table model */ -static void -calendar_model_free_value (ETableModel *etm, int col, void *value) -{ - g_return_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - g_free (value); - - case CAL_COMPONENT_FIELD_CLASSIFICATION: - return; - - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - g_free (value); - - case CAL_COMPONENT_FIELD_TRANSPARENCY: - return; - - case CAL_COMPONENT_FIELD_URL: - g_free (value); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - case CAL_COMPONENT_FIELD_ICON: - case CAL_COMPONENT_FIELD_COMPLETE: - case CAL_COMPONENT_FIELD_RECURRING: - case CAL_COMPONENT_FIELD_OVERDUE: - case CAL_COMPONENT_FIELD_COLOR: - return; - - default: - g_message ("calendar_model_free_value(): Requested invalid column %d", col); - return; - } -} - -/* Initializes a string value */ -static char * -init_string (void) -{ - return g_strdup (""); -} - -/* initialize_value handler for the calendar table model */ -static void * -calendar_model_initialize_value (ETableModel *etm, int col) -{ - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - return init_string (); - - case CAL_COMPONENT_FIELD_CLASSIFICATION: - return NULL; - - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - return init_string (); - - case CAL_COMPONENT_FIELD_TRANSPARENCY: - return NULL; - - case CAL_COMPONENT_FIELD_URL: - return init_string (); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - case CAL_COMPONENT_FIELD_ICON: - case CAL_COMPONENT_FIELD_COMPLETE: - case CAL_COMPONENT_FIELD_RECURRING: - case CAL_COMPONENT_FIELD_OVERDUE: - case CAL_COMPONENT_FIELD_COLOR: - return NULL; - - default: - g_message ("calendar_model_initialize_value(): Requested invalid column %d", col); - return NULL; - } -} - -/* value_is_empty handler for the calendar model. This should return TRUE - unless a significant value has been set. The 'click-to-add' feature - checks all fields to see if any are not empty and if so it adds a new - row, so we only want to return FALSE if we have a useful object. */ -static gboolean -calendar_model_value_is_empty (ETableModel *etm, int col, const void *value) -{ - g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, TRUE); - - switch (col) { - case CAL_COMPONENT_FIELD_CATEGORIES: - case CAL_COMPONENT_FIELD_CLASSIFICATION: /* actually goes here, not by itself */ - case CAL_COMPONENT_FIELD_COMPLETED: - case CAL_COMPONENT_FIELD_DTEND: - case CAL_COMPONENT_FIELD_DTSTART: - case CAL_COMPONENT_FIELD_DUE: - case CAL_COMPONENT_FIELD_GEO: - case CAL_COMPONENT_FIELD_PERCENT: - case CAL_COMPONENT_FIELD_PRIORITY: - case CAL_COMPONENT_FIELD_TRANSPARENCY: - case CAL_COMPONENT_FIELD_URL: - return string_is_empty (value); - - case CAL_COMPONENT_FIELD_HAS_ALARMS: - case CAL_COMPONENT_FIELD_ICON: - case CAL_COMPONENT_FIELD_COMPLETE: - case CAL_COMPONENT_FIELD_RECURRING: - case CAL_COMPONENT_FIELD_OVERDUE: - case CAL_COMPONENT_FIELD_COLOR: - return TRUE; - - default: - g_message ("calendar_model_value_is_empty(): Requested invalid column %d", col); - return TRUE; - } -} - - - -/** - * calendar_model_new: - * - * Creates a new calendar model. It must be told about the calendar client - * interface object it will monitor with calendar_model_set_cal_client(). - * - * Return value: A newly-created calendar model. - **/ -CalendarModel * -calendar_model_new (void) -{ - return CALENDAR_MODEL (gtk_type_new (TYPE_CALENDAR_MODEL)); -} - - -/* Callback used when a calendar is loaded into the server */ -static void -cal_loaded_cb (CalClient *client, - CalClientLoadStatus status, - CalendarModel *model) -{ - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - e_table_model_pre_change (E_TABLE_MODEL (model)); - load_objects (model); - e_table_model_changed (E_TABLE_MODEL (model)); -} - - -/* Removes an object from the model and updates all the indices that follow. - * Returns the index of the object that was removed, or -1 if no object with - * such UID was found. - */ -static int -remove_object (CalendarModel *model, const char *uid) -{ - CalendarModelPrivate *priv; - int *idx; - CalComponent *orig_comp; - int i; - int n; - - priv = model->priv; - - /* Find the index of the object to be removed */ - - idx = g_hash_table_lookup (priv->uid_index_hash, uid); - if (!idx) - return -1; - - orig_comp = g_array_index (priv->objects, CalComponent *, *idx); - g_assert (orig_comp != NULL); - - /* Decrease the indices of all the objects that follow in the array */ - - for (i = *idx + 1; i < priv->objects->len; i++) { - CalComponent *comp; - int *comp_idx; - const char *comp_uid; - - comp = g_array_index (priv->objects, CalComponent *, i); - g_assert (comp != NULL); - - cal_component_get_uid (comp, &comp_uid); - - comp_idx = g_hash_table_lookup (priv->uid_index_hash, comp_uid); - g_assert (comp_idx != NULL); - - (*comp_idx)--; - g_assert (*comp_idx >= 0); - } - - /* Remove this object from the array and hash */ - - g_hash_table_remove (priv->uid_index_hash, uid); - g_array_remove_index (priv->objects, *idx); - - gtk_object_unref (GTK_OBJECT (orig_comp)); - - n = *idx; - g_free (idx); - - return n; -} - -/* Callback used when an object is updated in the server */ -static void -obj_updated_cb (CalClient *client, const char *uid, gpointer data) -{ - CalendarModel *model; - CalendarModelPrivate *priv; - int orig_idx; - CalComponent *new_comp; - const char *new_comp_uid; - int *new_idx; - CalClientGetStatus status; - gboolean added; - - model = CALENDAR_MODEL (data); - priv = model->priv; - - orig_idx = remove_object (model, uid); - - status = cal_client_get_object (priv->client, uid, &new_comp); - - added = FALSE; - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - cal_component_get_uid (new_comp, &new_comp_uid); - - if (orig_idx == -1) { - /* The object not in the model originally, so we just append it */ - - g_array_append_val (priv->objects, new_comp); - - new_idx = g_new (int, 1); - *new_idx = priv->objects->len - 1; - - g_hash_table_insert (priv->uid_index_hash, (char *) new_comp_uid, new_idx); - } else { - int i; - - /* Insert the new version of the object in its old position */ - - g_array_insert_val (priv->objects, orig_idx, new_comp); - - new_idx = g_new (int, 1); - *new_idx = orig_idx; - g_hash_table_insert (priv->uid_index_hash, (char *) new_comp_uid, new_idx); - - /* Increase the indices of all subsequent objects */ - - for (i = orig_idx + 1; i < priv->objects->len; i++) { - CalComponent *comp; - int *comp_idx; - const char *comp_uid; - - comp = g_array_index (priv->objects, CalComponent *, i); - g_assert (comp != NULL); - - cal_component_get_uid (comp, &comp_uid); - - comp_idx = g_hash_table_lookup (priv->uid_index_hash, comp_uid); - g_assert (comp_idx != NULL); - - (*comp_idx)++; - } - } - - e_table_model_row_changed (E_TABLE_MODEL (model), *new_idx); - break; - - case CAL_CLIENT_GET_NOT_FOUND: - /* Nothing; the object may have been removed from the server. We just - * notify that the old object was deleted. - */ - if (orig_idx != -1) - e_table_model_row_deleted (E_TABLE_MODEL (model), orig_idx); - - break; - - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_message ("obj_updated_cb(): Syntax error when getting object `%s'", uid); - - /* Same notification as above */ - if (orig_idx != -1) - e_table_model_row_deleted (E_TABLE_MODEL (model), orig_idx); - - break; - - default: - g_assert_not_reached (); - } -} - -/* Callback used when an object is removed in the server */ -static void -obj_removed_cb (CalClient *client, const char *uid, gpointer data) -{ - CalendarModel *model; - int idx; - - model = CALENDAR_MODEL (data); - - idx = remove_object (model, uid); - - if (idx != -1) - e_table_model_row_deleted (E_TABLE_MODEL (model), idx); -} - -/* Loads the required objects from the calendar client */ -static void -load_objects (CalendarModel *model) -{ - CalendarModelPrivate *priv; - GList *uids; - GList *l; - - priv = model->priv; - - uids = cal_client_get_uids (priv->client, priv->type); - - for (l = uids; l; l = l->next) { - char *uid; - CalComponent *comp; - const char *comp_uid; - CalClientGetStatus status; - int *idx; - - uid = l->data; - status = cal_client_get_object (priv->client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - break; - - case CAL_CLIENT_GET_NOT_FOUND: - /* Nothing; the object may have been removed from the server */ - continue; - - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_message ("load_objects(): Syntax error when getting object `%s'", uid); - continue; - - default: - g_assert_not_reached (); - } - - idx = g_new (int, 1); - - g_array_append_val (priv->objects, comp); - *idx = priv->objects->len - 1; - - cal_component_get_uid (comp, &comp_uid); - g_hash_table_insert (priv->uid_index_hash, (char *) comp_uid, idx); - } - - cal_obj_uid_list_free (uids); -} - -/** - * calendar_model_get_cal_client: - * @model: A calendar model. - * - * Queries the calendar client interface object that a calendar model is using. - * - * Return value: A calendar client interface object. - **/ -CalClient * -calendar_model_get_cal_client (CalendarModel *model) -{ - CalendarModelPrivate *priv; - - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (IS_CALENDAR_MODEL (model), NULL); - - priv = model->priv; - - return priv->client; -} - - -/** - * calendar_model_set_cal_client: - * @model: A calendar model. - * @client: A calendar client interface object. - * @type: Type of objects to present. - * - * Sets the calendar client interface object that a calendar model will monitor. - * It also sets the types of objects this model will present to an #ETable. - **/ -void -calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjType type) -{ - CalendarModelPrivate *priv; - - g_return_if_fail (model != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - if (client) - g_return_if_fail (IS_CAL_CLIENT (client)); - - priv = model->priv; - - if (priv->client == client && priv->type == type) - return; - - e_table_model_pre_change (E_TABLE_MODEL(model)); - - if (client) - gtk_object_ref (GTK_OBJECT (client)); - - if (priv->client) { - gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client), model); - gtk_object_unref (GTK_OBJECT (priv->client)); - } - - free_objects (model); - - priv->client = client; - priv->type = type; - - if (priv->client) { - gtk_signal_connect (GTK_OBJECT (priv->client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), model); - gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated", - GTK_SIGNAL_FUNC (obj_updated_cb), model); - gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed", - GTK_SIGNAL_FUNC (obj_removed_cb), model); - - load_objects (model); - } - - e_table_model_changed (E_TABLE_MODEL (model)); -} - - -void -calendar_model_delete_task (CalendarModel *model, - gint row) -{ - CalendarModelPrivate *priv; - CalComponent *comp; - const char *uid; - - g_return_if_fail (model != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - priv = model->priv; - - g_return_if_fail (row >= 0 && row < priv->objects->len); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - cal_component_get_uid (comp, &uid); - - if (!cal_client_remove_object (priv->client, uid)) - g_message ("calendar_model_delete_task(): Could not remove the object!"); -} - - -void -calendar_model_mark_task_complete (CalendarModel *model, - gint row) -{ - CalendarModelPrivate *priv; - CalComponent *comp; - int percent; - struct icaltimetype itt; - - g_return_if_fail (model != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - priv = model->priv; - - g_return_if_fail (row >= 0 && row < priv->objects->len); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - percent = 100; - cal_component_set_percent (comp, &percent); - - itt = icaltimetype_from_timet (time (NULL), FALSE); - cal_component_set_completed (comp, &itt); - - if (!cal_client_update_object (priv->client, comp)) - g_message ("calendar_model_mark_task_complete(): Could not update the object!"); -} - - -/* Frees the objects stored in the calendar model */ -CalComponent * -calendar_model_get_cal_object (CalendarModel *model, - gint row) -{ - CalendarModelPrivate *priv; - - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (IS_CALENDAR_MODEL (model), NULL); - - priv = model->priv; - - g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL); - - return g_array_index (priv->objects, CalComponent *, row); -} diff --git a/calendar/gui/calendar-model.h b/calendar/gui/calendar-model.h deleted file mode 100644 index d1481a4ece..0000000000 --- a/calendar/gui/calendar-model.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Evolution calendar - Data model for ETable - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CALENDAR_MODEL_H -#define CALENDAR_MODEL_H - -#include <libgnome/gnome-defs.h> -#include <e-table/e-table-model.h> -#include <cal-client/cal-client.h> - -BEGIN_GNOME_DECLS - - - -#define TYPE_CALENDAR_MODEL (calendar_model_get_type ()) -#define CALENDAR_MODEL(obj) (GTK_CHECK_CAST ((obj), TYPE_CALENDAR_MODEL, CalendarModel)) -#define CALENDAR_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_CALENDAR_MODEL, \ - CalendarModelClass)) -#define IS_CALENDAR_MODEL(obj) (GTK_CHECK_TYPE ((obj), TYPE_CALENDAR_MODEL)) -#define IS_CALENDAR_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_CALENDAR_MODEL)) - -typedef struct _CalendarModel CalendarModel; -typedef struct _CalendarModelClass CalendarModelClass; - -struct _CalendarModel { - ETableModel model; - - /* Private data */ - gpointer priv; -}; - -struct _CalendarModelClass { - ETableModelClass parent_class; -}; - -GtkType calendar_model_get_type (void); - -CalendarModel* calendar_model_new (void); - -CalClient* calendar_model_get_cal_client (CalendarModel *model); -void calendar_model_set_cal_client (CalendarModel *model, - CalClient *client, - CalObjType type); - -void calendar_model_mark_task_complete (CalendarModel *model, - gint row); -void calendar_model_delete_task (CalendarModel *model, - gint row); - -CalComponent* calendar_model_get_cal_object (CalendarModel *model, - gint row); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/component-factory.c b/calendar/gui/component-factory.c deleted file mode 100644 index 8644b8928c..0000000000 --- a/calendar/gui/component-factory.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.c - * - * Copyright (C) 2000 Helix Code, 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. - * - * Author: Ettore Perazzoli - */ - -#include <config.h> -#include <bonobo.h> -#include "evolution-shell-component.h" -#include "component-factory.h" -#include "control-factory.h" - - - -#ifdef USING_OAF -#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" -#else -#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:evolution-calendar" -#endif - -static BonoboGenericFactory *factory = NULL; - -static const EvolutionShellComponentFolderType folder_types[] = { - { "calendar", "evolution-calendar.png" }, - { NULL, NULL } -}; - - -/* EvolutionShellComponent methods and signals. */ - -static EvolutionShellComponentResult -create_view (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - BonoboControl **control_return, - void *closure) -{ - BonoboControl *control; - - if (g_strcasecmp (type, "calendar") != 0) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE; - - control = control_factory_new_control (); - bonobo_control_set_property (control, "folder_uri", physical_uri, NULL); - - *control_return = control; - - return EVOLUTION_SHELL_COMPONENT_OK; -} - -static gint owner_count = 0; - -static void -owner_set_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - const char *evolution_homedir) -{ - owner_count ++; -} - -static void -owner_unset_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - EvolutionShellClient shell_client, - void *data) -{ - owner_count --; - if (owner_count <= 0) - gtk_main_quit(); -} - - -/* The factory function. */ - -static BonoboObject * -factory_fn (BonoboGenericFactory *factory, - void *closure) -{ - EvolutionShellComponent *shell_component; - - shell_component = evolution_shell_component_new (folder_types, create_view, NULL, NULL, NULL, NULL); - - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", - GTK_SIGNAL_FUNC (owner_set_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", - GTK_SIGNAL_FUNC (owner_unset_cb), NULL); - - return BONOBO_OBJECT (shell_component); -} - - -void -component_factory_init (void) -{ - if (factory != NULL) - return; - - factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); - - if (factory == NULL) - g_error ("Cannot initialize Evolution's calendar component."); -} diff --git a/calendar/gui/component-factory.h b/calendar/gui/component-factory.h deleted file mode 100644 index f83a849452..0000000000 --- a/calendar/gui/component-factory.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.h - * - * Copyright (C) 2000 Helix Code, 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. - * - * Author: Ettore Perazzoli - */ - -#ifndef _COMPONENT_FACTORY_H_ -#define _COMPONENT_FACTORY_H_ - -void component_factory_init (void); - -#endif /* _COMPONENT_FACTORY_H_ */ diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c deleted file mode 100644 index d7626d21f3..0000000000 --- a/calendar/gui/control-factory.c +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* control-factory.c - * - * Copyright (C) 2000 Helix Code, 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. - * - * Author: Ettore Perazzoli - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include <bonobo.h> -#include <bonobo/bonobo-control.h> -#include <glade/glade.h> - -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif - -#include <cal-util/timeutil.h> -#include <gui/alarm.h> -#include <gui/gnome-cal.h> -#include <gui/calendar-commands.h> - -#include "control-factory.h" - -#define PROPERTY_CALENDAR_URI "folder_uri" - -#define PROPERTY_CALENDAR_URI_IDX 1 - -#ifdef USING_OAF -#define CONTROL_FACTORY_ID "OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" -#else -#define CONTROL_FACTORY_ID "control-factory:calendar" -#endif - - -CORBA_Environment ev; -CORBA_ORB orb; - - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data) -{ - if (activate) - calendar_control_activate (control, user_data); - else - calendar_control_deactivate (control); -} - - -static void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - /*GnomeCalendar *gcal = user_data;*/ - - switch (arg_id) { - - case PROPERTY_CALENDAR_URI_IDX: - /* - if (fb && fb->uri) - BONOBO_ARG_SET_STRING (arg, fb->uri); - else - BONOBO_ARG_SET_STRING (arg, ""); - */ - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - } -} - - -static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - GnomeCalendar *gcal = user_data; - char *filename; - - switch (arg_id) { - - case PROPERTY_CALENDAR_URI_IDX: - printf ("set_prop: '%s'\n", BONOBO_ARG_GET_STRING (arg)); - filename = g_strdup_printf ("%s/calendar.vcf", - BONOBO_ARG_GET_STRING (arg)); - calendar_set_uri (gcal, filename); - g_free (filename); - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - break; - } -} - - -static void -calendar_properties_init (GnomeCalendar *gcal) -{ - gcal->properties = bonobo_property_bag_new (get_prop, set_prop, gcal); - - bonobo_property_bag_add (gcal->properties, - PROPERTY_CALENDAR_URI, - PROPERTY_CALENDAR_URI_IDX, - BONOBO_ARG_STRING, - NULL, - _("The URI that the calendar will display"), - 0); - - bonobo_control_set_property_bag (gcal->control, gcal->properties); -} - - -static BonoboControl * -create_control (void) -{ - BonoboControl *control; - GnomeCalendar *cal; - - cal = new_calendar (full_name, NULL, NULL, 0); - gtk_widget_show (GTK_WIDGET (cal)); - - control = bonobo_control_new (GTK_WIDGET (cal)); - cal->control = control; - - calendar_properties_init (cal); - - gtk_signal_connect (GTK_OBJECT (control), "activate", - control_activate_cb, cal); - - return control; -} - - -static BonoboObject * -control_factory (BonoboGenericFactory *Factory, void *closure) -{ - return BONOBO_OBJECT (create_control ()); -} - - -void -control_factory_init (void) -{ - static BonoboGenericFactory *factory = NULL; - - if (factory != NULL) - return; - - puts ("XXXXXX - initializing calendar factory!!!"); - - factory = bonobo_generic_factory_new (CONTROL_FACTORY_ID, control_factory, NULL); - - if (factory == NULL) - g_error ("I could not register a Calendar control factory."); -} - - -BonoboControl * -control_factory_new_control (void) -{ - return create_control (); -} diff --git a/calendar/gui/control-factory.h b/calendar/gui/control-factory.h deleted file mode 100644 index bacd2d3d90..0000000000 --- a/calendar/gui/control-factory.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* control-factory.c - * - * Copyright (C) 2000 Helix Code, 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. - * - * Author: Federico Mena Quintero - */ - -#ifndef _CONTROL_FACTORY_H_ -#define _CONTROL_FACTORY_H_ - -void control_factory_init (void); -BonoboControl *control_factory_new_control (void); - -#endif /* _CONTROL_FACTORY_H_ */ diff --git a/calendar/gui/dayview.xpm b/calendar/gui/dayview.xpm deleted file mode 100644 index bc8e74e4d6..0000000000 --- a/calendar/gui/dayview.xpm +++ /dev/null @@ -1,42 +0,0 @@ -/* XPM */ -static char * dayview_xpm[] = { -"24 24 15 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #AAAFE2", -"$ c #C7CAEB", -"% c #A3A6C7", -"& c #0010A8", -"* c #555FC5", -"= c #1725AC", -"- c #4550B5", -"; c #E3E4F5", -"> c #8B90C3", -", c #3945BB", -"' c #BABBCC", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++@++@++@#$@++@++@++. ", -" .++@++@++%&*@++@++@++. ", -" .@@@@@@@%=&-@@@@@@@@@. ", -" .++@++@++@&*@++@++@++. ", -" .++@++@++@&*@++@++@++. ", -" .@@@@@@@@@&-@@@@@@@@@. ", -" .++@++@++@&*@++@++@++. ", -" .++@++@+;>&,>++@++@++. ", -" .@@@@@@@'>>>>@@@@@@@@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; 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 227cb5aa07..0000000000 --- a/calendar/gui/dialogs/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -gladedir = $(datadir)/evolution/glade - -INCLUDES = \ - -DG_LOG_DOMAIN=\"calendar-gui\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_srcdir)/libical/src/libical \ - -I$(includedir) \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - $(BONOBO_VFS_GNOME_CFLAGS) \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" - -noinst_LIBRARIES = libcal-dialogs.a - -libcal_dialogs_a_SOURCES = \ - alarm-notify-dialog.c \ - alarm-notify-dialog.h \ - task-editor.c \ - task-editor.h - -glade_DATA = \ - alarm-notify.glade \ - task-editor-dialog.glade - -glade_messages = \ - alarm-notify.glade.h \ - task-editor-dialog.glade.h - -EXTRA_DIST = \ - $(glade_DATA) \ - $(glade_messages) diff --git a/calendar/gui/dialogs/alarm-notify-dialog.c b/calendar/gui/dialogs/alarm-notify-dialog.c deleted file mode 100644 index 7d8357599c..0000000000 --- a/calendar/gui/dialogs/alarm-notify-dialog.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include "alarm-notify-dialog.h" - - - -/* The useful contents of the alarm notify dialog */ -typedef struct { - GladeXML *xml; - - GtkWidget *dialog; - GtkWidget *close; - GtkWidget *snooze; - GtkWidget *edit; - GtkWidget *heading; - GtkWidget *summary; - GtkWidget *snooze_time; - - AlarmNotifyFunc func; - gpointer func_data; -} AlarmNotify; - - - -/* Callback used when the notify dialog is destroyed */ -static void -dialog_destroy_cb (GtkObject *object, gpointer data) -{ - AlarmNotify *an; - - an = data; - gtk_object_unref (GTK_OBJECT (an->xml)); - g_free (an); -} - -/* Delete_event handler for the alarm notify dialog */ -static gint -delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data); - - gtk_widget_destroy (widget); - return TRUE; -} - -/* Callback for the close button */ -static void -close_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/* Callback for the snooze button */ -static void -snooze_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - int snooze_time; - - an = data; - g_assert (an->func != NULL); - - snooze_time = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time)); - (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_time, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/* Callback for the edit button */ -static void -edit_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmNotify *an; - - an = data; - g_assert (an->func != NULL); - - (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data); - - gtk_widget_destroy (an->dialog); -} - -/** - * alarm_notify_dialog: - * @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 1e56f1c586..0000000000 --- a/calendar/gui/dialogs/alarm-notify-dialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Evolution calendar - alarm notification dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_NOTIFY_DIALOG_H -#define ALARM_NOTIFY_DIALOG_H - -#include <time.h> -#include <glib.h> -#include <cal-util/cal-component.h> - - - -typedef enum { - ALARM_NOTIFY_CLOSE, - ALARM_NOTIFY_SNOOZE, - ALARM_NOTIFY_EDIT -} AlarmNotifyResult; - -typedef void (* AlarmNotifyFunc) (AlarmNotifyResult result, int snooze_mins, gpointer data); - -gboolean alarm_notify_dialog (time_t trigger, time_t occur, 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 32d7e03f8b..0000000000 --- a/calendar/gui/dialogs/alarm-notify.glade +++ /dev/null @@ -1,230 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>Evolution Calendar</name> - <program_name>evolution-calendar</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> - <output_main_file>True</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>alarm-notify.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GtkWindow</class> - <name>alarm-notify</name> - <cxx_use_heap>True</cxx_use_heap> - <title></title> - <type>GTK_WINDOW_DIALOG</type> - <position>GTK_WIN_POS_CENTER</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>False</allow_grow> - <auto_shrink>False</auto_shrink> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <border_width>4</border_width> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox5</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>heading</name> - <cxx_use_heap>True</cxx_use_heap> - <label></label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>True</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>summary</name> - <cxx_use_heap>True</cxx_use_heap> - <label></label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>True</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox4</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>close</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Close</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>snooze</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Snooze</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>edit</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <label>Edit appointment</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <cxx_use_heap>True</cxx_use_heap> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox4</name> - <cxx_use_heap>True</cxx_use_heap> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label4</name> - <cxx_use_heap>True</cxx_use_heap> - <label>Snooze time (minutes)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>snooze-time</name> - <cxx_use_heap>True</cxx_use_heap> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>5</value> - <lower>1</lower> - <upper>1440</upper> - <step>1</step> - <page>5</page> - <page_size>5</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/dialogs/alarm-notify.glade.h b/calendar/gui/dialogs/alarm-notify.glade.h deleted file mode 100644 index c7b8918e06..0000000000 --- a/calendar/gui/dialogs/alarm-notify.glade.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("Close"); -gchar *s = N_("Snooze"); -gchar *s = N_("Edit appointment"); -gchar *s = N_("Snooze time (minutes)"); diff --git a/calendar/gui/dialogs/task-editor-dialog.glade b/calendar/gui/dialogs/task-editor-dialog.glade deleted file mode 100644 index 56f7f83422..0000000000 --- a/calendar/gui/dialogs/task-editor-dialog.glade +++ /dev/null @@ -1,822 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>task-editor-dialog</name> - <program_name>task-editor-dialog</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>task-editor-dialog.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GnomeApp</class> - <name>task-editor-dialog</name> - <visible>False</visible> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock1</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkNotebook</class> - <child_name>GnomeDock:contents</child_name> - <name>notebook1</name> - <border_width>2</border_width> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - - <widget> - <class>GtkVBox</class> - <name>vbox1</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkTable</class> - <name>table3</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label>S_ubject:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>entry1</default_focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry1</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label10</name> - <label>Owner:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label11</name> - <label></label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox4</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table1</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit1</name> - <show_time>True</show_time> - <use_24_format>False</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit2</name> - <show_time>True</show_time> - <use_24_format>True</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label6</name> - <label>Sta_rt Date:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label5</name> - <label>_Due Date:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator2</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label7</name> - <label>_Status:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>combo-entry1</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCombo</class> - <name>combo1</name> - <value_in_list>False</value_in_list> - <ok_if_empty>True</ok_if_empty> - <case_sensitive>False</case_sensitive> - <use_arrows>True</use_arrows> - <use_arrows_always>False</use_arrows_always> - <items>Not Started -In Progress -Completed -Cancelled -</items> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GtkCombo:entry</child_name> - <name>combo-entry1</name> - <width>60</width> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text>Not Started</text> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label8</name> - <label>_Priority:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>combo-entry2</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCombo</class> - <name>combo2</name> - <value_in_list>False</value_in_list> - <ok_if_empty>True</ok_if_empty> - <case_sensitive>False</case_sensitive> - <use_arrows>True</use_arrows> - <use_arrows_always>False</use_arrows_always> - <items>High -Normal -Low -</items> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GtkCombo:entry</child_name> - <name>combo-entry2</name> - <width>60</width> - <can_focus>True</can_focus> - <editable>False</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text>High</text> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label9</name> - <label>% Comp_lete:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>spinbutton1</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>spinbutton1</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>10</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow1</name> - <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkText</class> - <name>text1</name> - <height>150</height> - <can_focus>True</can_focus> - <editable>True</editable> - <text></text> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox2</name> - <homogeneous>False</homogeneous> - <spacing>2</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>button3</name> - <can_focus>True</can_focus> - <label>_Contacts...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry2</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button4</name> - <can_focus>True</can_focus> - <label>Ca_tegories...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry3</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>checkbutton1</name> - <can_focus>True</can_focus> - <label>Private</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label1</name> - <label>Task</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkTable</class> - <name>table4</name> - <border_width>4</border_width> - <rows>4</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit3</name> - <show_time>True</show_time> - <use_24_format>True</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label12</name> - <label>Date Completed:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label13</name> - <label>Location:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label14</name> - <label>URL:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry4</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry5</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label15</name> - <label>Resources:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry6</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label2</name> - <label>Details</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/dialogs/task-editor-dialog.glade.h b/calendar/gui/dialogs/task-editor-dialog.glade.h deleted file mode 100644 index 9ee959817f..0000000000 --- a/calendar/gui/dialogs/task-editor-dialog.glade.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("S_ubject:"); -gchar *s = N_("Owner:"); -gchar *s = N_("Sta_rt Date:"); -gchar *s = N_("_Due Date:"); -gchar *s = N_("_Status:"); -gchar *s = N_("Not Started\n" - "In Progress\n" - "Completed\n" - "Cancelled\n" - ""); -gchar *s = N_("Not Started"); -gchar *s = N_("_Priority:"); -gchar *s = N_("High\n" - "Normal\n" - "Low\n" - ""); -gchar *s = N_("High"); -gchar *s = N_("% Comp_lete:"); -gchar *s = N_("_Contacts..."); -gchar *s = N_("Ca_tegories..."); -gchar *s = N_("Private"); -gchar *s = N_("Task"); -gchar *s = N_("Date Completed:"); -gchar *s = N_("Location:"); -gchar *s = N_("URL:"); -gchar *s = N_("Resources:"); -gchar *s = N_("Details"); diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c deleted file mode 100644 index dd40c1b9df..0000000000 --- a/calendar/gui/dialogs/task-editor.c +++ /dev/null @@ -1,481 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include <e-util/e-util.h> -#include <cal-client/cal-client.h> -#include "task-editor.h" - - -typedef struct { - /* Glade XML data */ - GladeXML *xml; - - /* UI handler */ - BonoboUIHandler *uih; - - /* 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; - - /* Widgets from the Glade file */ - - GtkWidget *app; -} TaskEditorPrivate; - - -static void task_editor_class_init (TaskEditorClass *class); -static void task_editor_init (TaskEditor *tedit); -TaskEditor * task_editor_construct (TaskEditor *tedit); -static gboolean get_widgets (TaskEditor *tedit); -static void init_widgets (TaskEditor *tedit); -static void create_menu (TaskEditor *tedit); -static void create_toolbar (TaskEditor *tedit); -static void task_editor_destroy (GtkObject *object); - -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; -} - - -/** - * 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); - - /* Construct the app */ - - priv->uih = bonobo_ui_handler_new (); - if (!priv->uih) { - g_message ("task_editor_construct(): Could not create the UI handler"); - goto error; - } - - bonobo_ui_handler_set_app (priv->uih, GNOME_APP (priv->app)); - - create_menu (tedit); - create_toolbar (tedit); - - /* Hook to destruction of the dialog */ - -#if 0 - gtk_signal_connect (GTK_OBJECT (priv->app), "delete_event", - GTK_SIGNAL_FUNC (app_delete_event_cb), tedit); -#endif - - /* Show the dialog */ - - gtk_widget_show (priv->app); - - return tedit; - - error: - - gtk_object_unref (GTK_OBJECT (tedit)); - return NULL; -} - - -/* 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"); - - return TRUE; -} - - -/* Hooks the widget signals */ -static void -init_widgets (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - - priv = tedit->priv; - -} - - -/* Menu bar */ - -static GnomeUIInfo file_new_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mail Message"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Appointment"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Meeting Re_quest"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Journal Entry"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Note"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_page_setup_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Memo Style"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Define Print _Styles..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_menu[] = { - GNOMEUIINFO_MENU_NEW_SUBTREE (file_new_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_SAVE_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_SAVE_AS_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Delete"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Move to Folder..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Cop_y to Folder..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("Page Set_up"), file_page_setup_menu), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print Pre_view"), NULL, NULL), - GNOMEUIINFO_MENU_PRINT_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_PROPERTIES_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLOSE_ITEM (NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_object_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: what goes here?", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_menu[] = { - GNOMEUIINFO_MENU_UNDO_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_REDO_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CUT_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_COPY_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_PASTE_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Paste _Special..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLEAR_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_SELECT_ALL_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Mark as U_nread"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_FIND_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_FIND_AGAIN_ITEM (NULL, NULL), - GNOMEUIINFO_SUBTREE (N_("_Object"), edit_object_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_previous_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: In_complete Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Fi_rst Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_next_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: In_complete Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Last Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_toolbars_menu[] = { - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: _Standard"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: __Formatting"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Customize..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_menu[] = { - GNOMEUIINFO_SUBTREE (N_("Pre_vious"), view_previous_menu), - GNOMEUIINFO_SUBTREE (N_("Ne_xt"), view_next_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Toolbars"), view_toolbars_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo insert_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _File..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: It_em..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Object..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo format_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Font..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Paragraph..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_forms_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Desi_gn This Form"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: D_esign a Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Publish _Form..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Pu_blish Form As..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Script _Debugger"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Spelling..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Chec_k Names"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Address _Book..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Forms"), tools_forms_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo actions_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _New Task"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end Status Report"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mark Complete"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Rec_urrence..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_kip Occurrence"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Assig_n Task"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Reply"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Reply to A_ll"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: For_ward"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo help_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: fix Bonobo so it supports help items!", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo main_menu[] = { - GNOMEUIINFO_MENU_FILE_TREE (file_menu), - GNOMEUIINFO_MENU_EDIT_TREE (edit_menu), - GNOMEUIINFO_MENU_VIEW_TREE (view_menu), - GNOMEUIINFO_SUBTREE (N_("_Insert"), insert_menu), - GNOMEUIINFO_SUBTREE (N_("F_ormat"), format_menu), - GNOMEUIINFO_SUBTREE (N_("_Tools"), tools_menu), - GNOMEUIINFO_SUBTREE (N_("Actio_ns"), actions_menu), - GNOMEUIINFO_MENU_HELP_TREE (help_menu), - GNOMEUIINFO_END -}; - - -/* Creates the menu bar for the event editor */ -static void -create_menu (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - BonoboUIHandlerMenuItem *list; - - priv = tedit->priv; - - bonobo_ui_handler_create_menubar (priv->uih); - - list = bonobo_ui_handler_menu_parse_uiinfo_list_with_data (main_menu, - tedit); - bonobo_ui_handler_menu_add_list (priv->uih, "/", list); -} - - -/* Toolbar */ - -static GnomeUIInfo toolbar[] = { - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Save and Close"), - N_("Save the task and close the dialog box"), - NULL, - GNOME_STOCK_PIXMAP_SAVE), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print..."), - N_("Print this item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Insert File..."), - N_("Insert a file as an attachment"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Recurrence..."), - N_("Configure recurrence rules"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Assign Task..."), - N_("Assign the task to someone"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Delete"), - N_("Delete this item"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Previous"), - N_("Go to the previous item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Next"), - N_("Go to the next item"), NULL), - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Help"), - N_("See online help"), NULL, GNOME_STOCK_PIXMAP_HELP), - GNOMEUIINFO_END -}; - - -/* Creates the toolbar for the event editor */ -static void -create_toolbar (TaskEditor *tedit) -{ - TaskEditorPrivate *priv; - BonoboUIHandlerToolbarItem *list; - GnomeDockItem *dock_item; - GtkWidget *toolbar_child; - - priv = tedit->priv; - - bonobo_ui_handler_create_toolbar (priv->uih, "Toolbar"); - - /* Fetch the toolbar. What a pain in the ass. */ - - dock_item = gnome_app_get_dock_item_by_name (GNOME_APP (priv->app), GNOME_APP_TOOLBAR_NAME); - g_assert (dock_item != NULL); - - toolbar_child = gnome_dock_item_get_child (dock_item); - g_assert (toolbar_child != NULL && GTK_IS_TOOLBAR (toolbar_child)); - - /* Turn off labels as GtkToolbar sucks */ - gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_child), GTK_TOOLBAR_ICONS); - - list = bonobo_ui_handler_toolbar_parse_uiinfo_list_with_data (toolbar, - tedit); - bonobo_ui_handler_toolbar_add_list (priv->uih, "/Toolbar", list); -} - - -static void -task_editor_destroy (GtkObject *object) -{ - TaskEditor *tedit; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_TASK_EDITOR (object)); - - tedit = TASK_EDITOR (object); - - -} - - diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h deleted file mode 100644 index 159b969ab9..0000000000 --- a/calendar/gui/dialogs/task-editor.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 <gtk/gtkobject.h> -#include <libgnome/gnome-defs.h> -#include <bonobo.h> - -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_new (void); - - - -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 56f7f83422..0000000000 --- a/calendar/gui/dialogs/task-page.glade +++ /dev/null @@ -1,822 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>task-editor-dialog</name> - <program_name>task-editor-dialog</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>task-editor-dialog.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GnomeApp</class> - <name>task-editor-dialog</name> - <visible>False</visible> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock1</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkNotebook</class> - <child_name>GnomeDock:contents</child_name> - <name>notebook1</name> - <border_width>2</border_width> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - - <widget> - <class>GtkVBox</class> - <name>vbox1</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkTable</class> - <name>table3</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label3</name> - <label>S_ubject:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>entry1</default_focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry1</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label10</name> - <label>Owner:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label11</name> - <label></label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator1</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox4</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table1</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit1</name> - <show_time>True</show_time> - <use_24_format>False</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit2</name> - <show_time>True</show_time> - <use_24_format>True</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label6</name> - <label>Sta_rt Date:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label5</name> - <label>_Due Date:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHSeparator</class> - <name>hseparator2</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox3</name> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label7</name> - <label>_Status:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>combo-entry1</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCombo</class> - <name>combo1</name> - <value_in_list>False</value_in_list> - <ok_if_empty>True</ok_if_empty> - <case_sensitive>False</case_sensitive> - <use_arrows>True</use_arrows> - <use_arrows_always>False</use_arrows_always> - <items>Not Started -In Progress -Completed -Cancelled -</items> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GtkCombo:entry</child_name> - <name>combo-entry1</name> - <width>60</width> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text>Not Started</text> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label8</name> - <label>_Priority:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>combo-entry2</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCombo</class> - <name>combo2</name> - <value_in_list>False</value_in_list> - <ok_if_empty>True</ok_if_empty> - <case_sensitive>False</case_sensitive> - <use_arrows>True</use_arrows> - <use_arrows_always>False</use_arrows_always> - <items>High -Normal -Low -</items> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GtkCombo:entry</child_name> - <name>combo-entry2</name> - <width>60</width> - <can_focus>True</can_focus> - <editable>False</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text>High</text> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label9</name> - <label>% Comp_lete:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>spinbutton1</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>spinbutton1</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>10</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow1</name> - <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkText</class> - <name>text1</name> - <height>150</height> - <can_focus>True</can_focus> - <editable>True</editable> - <text></text> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox2</name> - <homogeneous>False</homogeneous> - <spacing>2</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>button3</name> - <can_focus>True</can_focus> - <label>_Contacts...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry2</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button4</name> - <can_focus>True</can_focus> - <label>Ca_tegories...</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry3</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>checkbutton1</name> - <can_focus>True</can_focus> - <label>Private</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label1</name> - <label>Task</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkTable</class> - <name>table4</name> - <border_width>4</border_width> - <rows>4</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GnomeDateEdit</class> - <name>dateedit3</name> - <show_time>True</show_time> - <use_24_format>True</use_24_format> - <week_start_monday>False</week_start_monday> - <lower_hour>7</lower_hour> - <upper_hour>19</upper_hour> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label12</name> - <label>Date Completed:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label13</name> - <label>Location:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label14</name> - <label>URL:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry4</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry5</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label15</name> - <label>Resources:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry6</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label2</name> - <label>Details</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c deleted file mode 100644 index 1a9e00de12..0000000000 --- a/calendar/gui/e-calendar-table.c +++ /dev/null @@ -1,482 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 - */ - -/* - * ECalendarTable - displays the iCalendar objects in a table (an ETable). - * Used for calendar events and tasks. - */ - -#include <config.h> -#include <gdk/gdkkeysyms.h> -#include <libgnomeui/gnome-popup-menu.h> -#include <e-table/e-table-scrolled.h> -#include <e-table/e-cell-checkbox.h> -#include <e-table/e-cell-toggle.h> -#include <e-table/e-cell-text.h> -#include "e-calendar-table.h" -#include "calendar-model.h" -#include "gncal-todo.h" - -/* Pixmaps. */ -#include "task.xpm" -#include "task-recurring.xpm" -#include "task-assigned.xpm" -#include "task-assigned-to.xpm" - -#include <e-table/check-filled.xpm> - - -static void e_calendar_table_class_init (ECalendarTableClass *class); -static void e_calendar_table_init (ECalendarTable *cal_table); -static void e_calendar_table_destroy (GtkObject *object); - -static void e_calendar_table_on_double_click (ETable *table, - gint row, - ECalendarTable *cal_table); -static gint e_calendar_table_on_right_click (ETable *table, - gint row, - gint col, - GdkEventButton *event, - ECalendarTable *cal_table); -static void e_calendar_table_on_open_task (GtkWidget *menuitem, - gpointer data); -static void e_calendar_table_on_mark_task_complete (GtkWidget *menuitem, - gpointer data); -static void e_calendar_table_on_delete_task (GtkWidget *menuitem, - gpointer data); -static gint e_calendar_table_on_key_press (ETable *table, - gint row, - gint col, - GdkEventKey *event, - ECalendarTable *cal_table); - -static void e_calendar_table_open_task (ECalendarTable *cal_table, - gint row); - -/* The icons to represent the task. */ -#define E_CALENDAR_MODEL_NUM_ICONS 4 -static char** icon_xpm_data[E_CALENDAR_MODEL_NUM_ICONS] = { - task_xpm, task_recurring_xpm, task_assigned_xpm, task_assigned_to_xpm -}; -static GdkPixbuf* icon_pixbufs[E_CALENDAR_MODEL_NUM_ICONS] = { 0 }; - -static GtkTableClass *parent_class; - - -GtkType -e_calendar_table_get_type (void) -{ - static GtkType e_calendar_table_type = 0; - - if (!e_calendar_table_type){ - GtkTypeInfo e_calendar_table_info = { - "ECalendarTable", - sizeof (ECalendarTable), - sizeof (ECalendarTableClass), - (GtkClassInitFunc) e_calendar_table_class_init, - (GtkObjectInitFunc) e_calendar_table_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - parent_class = gtk_type_class (GTK_TYPE_TABLE); - e_calendar_table_type = gtk_type_unique (GTK_TYPE_TABLE, - &e_calendar_table_info); - } - - return e_calendar_table_type; -} - - -static void -e_calendar_table_class_init (ECalendarTableClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - /* Method override */ - object_class->destroy = e_calendar_table_destroy; - -#if 0 - widget_class->realize = e_calendar_table_realize; - widget_class->unrealize = e_calendar_table_unrealize; - widget_class->style_set = e_calendar_table_style_set; - widget_class->size_allocate = e_calendar_table_size_allocate; - widget_class->focus_in_event = e_calendar_table_focus_in; - widget_class->focus_out_event = e_calendar_table_focus_out; - widget_class->key_press_event = e_calendar_table_key_press; -#endif -} - - -#define E_CALENDAR_TABLE_SPEC \ - "<ETableSpecification click-to-add=\"1\">" \ - "<columns-shown>" \ - "<column> 16 </column>" \ - "<column> 17 </column>" \ - "<column> 13 </column>" \ - "</columns-shown>" \ - "<grouping> </grouping>" \ - "</ETableSpecification>" - -#define e_cell_time_new e_cell_text_new -#define e_cell_time_compare g_str_compare -#define e_cell_geo_pos_new e_cell_text_new -#define e_cell_geo_pos_compare g_str_compare - -static void -e_calendar_table_init (ECalendarTable *cal_table) -{ - GtkWidget *table; - ETableModel *model; - ETableHeader *header; - ECell *cell; - ETableCol *column; - gint i; - GdkPixbuf *pixbuf; - GdkColormap *colormap; - gboolean success[E_CALENDAR_TABLE_COLOR_LAST]; - gint nfailed; - - /* Allocate the colors we need. */ - colormap = gtk_widget_get_colormap (GTK_WIDGET (cal_table)); - - cal_table->colors[E_CALENDAR_TABLE_COLOR_OVERDUE].red = 65535; - cal_table->colors[E_CALENDAR_TABLE_COLOR_OVERDUE].green = 0; - cal_table->colors[E_CALENDAR_TABLE_COLOR_OVERDUE].blue = 0; - - nfailed = gdk_colormap_alloc_colors (colormap, cal_table->colors, - E_CALENDAR_TABLE_COLOR_LAST, - FALSE, TRUE, success); - if (nfailed) - g_warning ("Failed to allocate all colors"); - - - cal_table->model = calendar_model_new (); - model = E_TABLE_MODEL (cal_table->model); - - header = e_table_header_new (); - gtk_object_ref (GTK_OBJECT (header)); - gtk_object_sink (GTK_OBJECT (header)); - - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_COMMENT, _("Comment"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_COMMENT); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_COMPLETED, _("Completed"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_COMPLETED); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_CREATED, _("Created"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_CREATED); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_DESCRIPTION, _("Description"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_DESCRIPTION); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_DTSTAMP, _("Timestamp"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_DTSTAMP); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_DTSTART, _("Start Date"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_DTSTART); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_DTEND, _("End Date"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_DTEND); - - cell = e_cell_geo_pos_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_GEO, _("Geographical Position"), - 1.0, 10, cell, e_cell_geo_pos_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_GEO); - - cell = e_cell_time_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_LAST_MOD, _("Last Modification Date"), - 1.0, 10, cell, e_cell_time_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_LAST_MOD); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_LOCATION, _("Location"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_LOCATION); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_ORGANIZER, _("Organizer"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_ORGANIZER); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_PERCENT, _("% Complete"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_PERCENT); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_PRIORITY, _("Priority"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_PRIORITY); - - /* FIXME: This should really be 'Subject' in the big view. */ - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - gtk_object_set (GTK_OBJECT (cell), - "strikeout_column", ICAL_OBJECT_FIELD_COMPLETE, - "bold_column", ICAL_OBJECT_FIELD_OVERDUE, - "color_column", ICAL_OBJECT_FIELD_COLOR, - NULL); - column = e_table_col_new (ICAL_OBJECT_FIELD_SUMMARY, _("TaskPad"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_SUMMARY); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_URL, _("URL"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_URL); - - cell = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - column = e_table_col_new (ICAL_OBJECT_FIELD_HAS_ALARMS, _("Reminder"), - 1.0, 10, cell, g_str_compare, TRUE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_HAS_ALARMS); - - /* Create pixmaps. */ - if (!icon_pixbufs[0]) { - for (i = 0; i < E_CALENDAR_MODEL_NUM_ICONS; i++) { - icon_pixbufs[i] = gdk_pixbuf_new_from_xpm_data ( - (const char **) icon_xpm_data[i]); - } - } - - cell = e_cell_toggle_new (0, 4, icon_pixbufs); - column = e_table_col_new_with_pixbuf (ICAL_OBJECT_FIELD_ICON, - icon_pixbufs[0], 0.0, 16, cell, - g_int_compare, FALSE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_ICON); - - cell = e_cell_checkbox_new (); - pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) check_filled_xpm); - column = e_table_col_new_with_pixbuf (ICAL_OBJECT_FIELD_COMPLETE, - pixbuf, 0.0, 16, cell, - g_int_compare, FALSE); - e_table_header_add_column (header, column, ICAL_OBJECT_FIELD_COMPLETE); - - - table = e_table_scrolled_new (header, model, E_CALENDAR_TABLE_SPEC); - gtk_object_set (GTK_OBJECT (table), - "click_to_add_message", "Click here to add a new Task", - NULL); - gtk_table_attach (GTK_TABLE (cal_table), table, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (table); - - gtk_signal_connect (GTK_OBJECT (table), "double_click", - GTK_SIGNAL_FUNC (e_calendar_table_on_double_click), - cal_table); - gtk_signal_connect (GTK_OBJECT (table), "right_click", - GTK_SIGNAL_FUNC (e_calendar_table_on_right_click), - cal_table); - gtk_signal_connect (GTK_OBJECT (table), "key_press", - GTK_SIGNAL_FUNC (e_calendar_table_on_key_press), - cal_table); -} - - -/** - * e_calendar_table_new: - * @Returns: a new #ECalendarTable. - * - * Creates a new #ECalendarTable. - **/ -GtkWidget * -e_calendar_table_new (void) -{ - GtkWidget *cal_table; - - cal_table = GTK_WIDGET (gtk_type_new (e_calendar_table_get_type ())); - - return cal_table; -} - - -static void -e_calendar_table_destroy (GtkObject *object) -{ - ECalendarTable *cal_table; - - cal_table = E_CALENDAR_TABLE (object); - - - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -void -e_calendar_table_set_cal_client (ECalendarTable *cal_table, - CalClient *client) -{ - g_print ("In e_calendar_table_set_cal_client\n"); - - calendar_model_set_cal_client (cal_table->model, client, - CALOBJ_TYPE_TODO); -} - - -static void -e_calendar_table_on_double_click (ETable *table, - gint row, - ECalendarTable *cal_table) -{ - g_print ("In e_calendar_table_on_double_click row:%i\n", row); - - e_calendar_table_open_task (cal_table, row); -} - - -static GnomeUIInfo e_calendar_table_popup_uiinfo[] = { - { GNOME_APP_UI_ITEM, N_("Open..."), - N_("Open the task"), e_calendar_table_on_open_task, - NULL, NULL, 0, 0, 0, 0 }, - { GNOME_APP_UI_ITEM, N_("Mark Complete"), - N_("Mark the task complete"), e_calendar_table_on_mark_task_complete, - NULL, NULL, 0, 0, 0, 0 }, - { GNOME_APP_UI_ITEM, N_("Delete"), - N_("Delete the task"), e_calendar_table_on_delete_task, - NULL, NULL, 0, 0, 0, 0 }, - - GNOMEUIINFO_END -}; - - -typedef struct _ECalendarMenuData ECalendarMenuData; -struct _ECalendarMenuData { - ECalendarTable *cal_table; - gint row; -}; - -static gint -e_calendar_table_on_right_click (ETable *table, - gint row, - gint col, - GdkEventButton *event, - ECalendarTable *cal_table) -{ - ECalendarMenuData menu_data; - GtkWidget *popup_menu; - - menu_data.cal_table = cal_table; - menu_data.row = row; - - popup_menu = gnome_popup_menu_new (e_calendar_table_popup_uiinfo); - gnome_popup_menu_do_popup_modal (popup_menu, NULL, NULL, event, - &menu_data); - - gtk_widget_destroy (popup_menu); - - return TRUE; -} - - -static void -e_calendar_table_on_open_task (GtkWidget *menuitem, - gpointer data) -{ - ECalendarMenuData *menu_data = (ECalendarMenuData*) data; - - e_calendar_table_open_task (menu_data->cal_table, - menu_data->row); -} - - -static void -e_calendar_table_on_mark_task_complete (GtkWidget *menuitem, - gpointer data) -{ - ECalendarMenuData *menu_data = (ECalendarMenuData*) data; - - calendar_model_mark_task_complete (menu_data->cal_table->model, - menu_data->row); -} - - -static void -e_calendar_table_on_delete_task (GtkWidget *menuitem, - gpointer data) -{ - ECalendarMenuData *menu_data = (ECalendarMenuData*) data; - - calendar_model_delete_task (menu_data->cal_table->model, - menu_data->row); -} - - - -static gint -e_calendar_table_on_key_press (ETable *table, - gint row, - gint col, - GdkEventKey *event, - ECalendarTable *cal_table) -{ - g_print ("In e_calendar_table_on_key_press\n"); - - if (event->keyval == GDK_Delete) { - g_print (" delete key!!!\n"); - - calendar_model_delete_task (cal_table->model, row); - } - - return FALSE; -} - - -static void -e_calendar_table_open_task (ECalendarTable *cal_table, - gint row) -{ - iCalObject *ico; - -#if 0 - task_editor_new (); - /* FIXME: Set iCalObject to edit. */ -#endif - - ico = calendar_model_get_cal_object (cal_table->model, row); - - gncal_todo_edit (calendar_model_get_cal_client (cal_table->model), - ico); -} - - diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h deleted file mode 100644 index eed021e846..0000000000 --- a/calendar/gui/e-calendar-table.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 2000, Helix Code, 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 _E_CALENDAR_TABLE_H_ -#define _E_CALENDAR_TABLE_H_ - -#include <gtk/gtktable.h> -#include "calendar-model.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * ECalendarTable - displays the iCalendar objects in a table (an ETable). - * Used for calendar events and tasks. - */ - -/* These index our colors array. */ -typedef enum -{ - E_CALENDAR_TABLE_COLOR_OVERDUE, - - E_CALENDAR_TABLE_COLOR_LAST -} ECalendarTableColors; - - -#define E_CALENDAR_TABLE(obj) GTK_CHECK_CAST (obj, e_calendar_table_get_type (), ECalendarTable) -#define E_CALENDAR_TABLE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_calendar_table_get_type (), ECalendarTableClass) -#define E_IS_CALENDAR_TABLE(obj) GTK_CHECK_TYPE (obj, e_calendar_table_get_type ()) - - -typedef struct _ECalendarTable ECalendarTable; -typedef struct _ECalendarTableClass ECalendarTableClass; - -struct _ECalendarTable -{ - GtkTable table; - - CalendarModel *model; - - /* Colors for drawing. */ - GdkColor colors[E_CALENDAR_TABLE_COLOR_LAST]; -}; - -struct _ECalendarTableClass -{ - GtkTableClass parent_class; -}; - - -GtkType e_calendar_table_get_type (void); -GtkWidget* e_calendar_table_new (void); - - -void e_calendar_table_set_cal_client (ECalendarTable *cal_table, - CalClient *client); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CALENDAR_TABLE_H_ */ diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c deleted file mode 100644 index 8353c0497e..0000000000 --- a/calendar/gui/e-day-view-main-item.c +++ /dev/null @@ -1,651 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * EDayViewMainItem - canvas item which displays most of the appointment - * data in the main Day/Work Week display. - */ - -#include <config.h> -#include "e-day-view-main-item.h" - -static void e_day_view_main_item_class_init (EDayViewMainItemClass *class); -static void e_day_view_main_item_init (EDayViewMainItem *dvtitem); - -static void e_day_view_main_item_set_arg (GtkObject *o, GtkArg *arg, - guint arg_id); -static void e_day_view_main_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, int flags); -static void e_day_view_main_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, int y, - int width, int height); -static double e_day_view_main_item_point (GnomeCanvasItem *item, - double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item); -static gint e_day_view_main_item_event (GnomeCanvasItem *item, - GdkEvent *event); - -static void e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height, - gint day); -static void e_day_view_main_item_draw_day_events (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height, - gint day); -static void e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height, - gint day, gint event_num); - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_DAY_VIEW -}; - - -GtkType -e_day_view_main_item_get_type (void) -{ - static GtkType e_day_view_main_item_type = 0; - - if (!e_day_view_main_item_type) { - GtkTypeInfo e_day_view_main_item_info = { - "EDayViewMainItem", - sizeof (EDayViewMainItem), - sizeof (EDayViewMainItemClass), - (GtkClassInitFunc) e_day_view_main_item_class_init, - (GtkObjectInitFunc) e_day_view_main_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_day_view_main_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_day_view_main_item_info); - } - - return e_day_view_main_item_type; -} - - -static void -e_day_view_main_item_class_init (EDayViewMainItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EDayViewMainItem::day_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_DAY_VIEW); - - object_class->set_arg = e_day_view_main_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_day_view_main_item_update; - item_class->draw = e_day_view_main_item_draw; - item_class->point = e_day_view_main_item_point; - item_class->event = e_day_view_main_item_event; -} - - -static void -e_day_view_main_item_init (EDayViewMainItem *dvtitem) -{ - dvtitem->day_view = NULL; -} - - -static void -e_day_view_main_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EDayViewMainItem *dvmitem; - - item = GNOME_CANVAS_ITEM (o); - dvmitem = E_DAY_VIEW_MAIN_ITEM (o); - - switch (arg_id){ - case ARG_DAY_VIEW: - dvmitem->day_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_day_view_main_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable, - int x, int y, int width, int height) -{ - EDayViewMainItem *dvmitem; - EDayView *day_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc, *gc; - GdkFont *font; - gint row, row_y, grid_x1, grid_x2; - gint day, grid_y1, grid_y2; - gint work_day_start_row, work_day_end_row; - gint work_day_start_y, work_day_end_y; - gint work_day_x, work_day_w; - gint start_row, end_row, rect_x, rect_y, rect_width, rect_height; - -#if 0 - g_print ("In e_day_view_main_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - dvmitem = E_DAY_VIEW_MAIN_ITEM (canvas_item); - day_view = dvmitem->day_view; - g_return_if_fail (day_view != NULL); - - style = GTK_WIDGET (day_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - - /* Paint the background colors. */ - gc = day_view->main_gc; - work_day_start_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); - work_day_start_y = work_day_start_row * day_view->row_height - y; - work_day_end_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_end_hour, day_view->work_day_end_minute); - work_day_end_y = work_day_end_row * day_view->row_height - y; - - work_day_x = day_view->day_offsets[0] - x; - work_day_w = width - work_day_x; - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]); - gdk_draw_rectangle (drawable, gc, TRUE, - work_day_x, 0 - y, - work_day_w, work_day_start_y - (0 - y)); - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING]); - gdk_draw_rectangle (drawable, gc, TRUE, - work_day_x, work_day_start_y, - work_day_w, work_day_end_y - work_day_start_y); - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING]); - gdk_draw_rectangle (drawable, gc, TRUE, - work_day_x, work_day_end_y, - work_day_w, height - work_day_end_y); - - /* Paint the selection background. */ - if (GTK_WIDGET_HAS_FOCUS (day_view) - && day_view->selection_start_day != -1 - && !day_view->selection_in_top_canvas) { - for (day = day_view->selection_start_day; - day <= day_view->selection_end_day; - day++) { - if (day == day_view->selection_start_day - && day_view->selection_start_row != -1) - start_row = day_view->selection_start_row; - else - start_row = 0; - if (day == day_view->selection_end_day - && day_view->selection_end_row != -1) - end_row = day_view->selection_end_row; - else - end_row = day_view->rows - 1; - - rect_x = day_view->day_offsets[day] - x; - rect_width = day_view->day_widths[day]; - rect_y = start_row * day_view->row_height - y; - rect_height = (end_row - start_row + 1) * day_view->row_height; - - gc = style->bg_gc[GTK_STATE_SELECTED]; - gdk_draw_rectangle (drawable, gc, TRUE, - rect_x, rect_y, - rect_width, rect_height); - } - } - - /* Drawing the horizontal grid lines. */ - grid_x1 = day_view->day_offsets[0] - x; - grid_x2 = day_view->day_offsets[day_view->days_shown] - x; - - for (row = 0, row_y = 0 - y; - row < day_view->rows && row_y < height; - row++, row_y += day_view->row_height) { - if (row_y >= 0 && row_y < height) - gdk_draw_line (drawable, dark_gc, - grid_x1, row_y, grid_x2, row_y); - } - - /* Draw the vertical bars down the left of each column. */ - grid_y1 = 0; - grid_y2 = height; - for (day = 0; day < day_view->days_shown; day++) { - grid_x1 = day_view->day_offsets[day] - x; - - /* Skip if it isn't visible. */ - if (grid_x1 >= width || grid_x1 + E_DAY_VIEW_BAR_WIDTH <= 0) - continue; - - gdk_draw_line (drawable, fg_gc, - grid_x1, grid_y1, - grid_x1, grid_y2); - gdk_draw_line (drawable, fg_gc, - grid_x1 + E_DAY_VIEW_BAR_WIDTH - 1, grid_y1, - grid_x1 + E_DAY_VIEW_BAR_WIDTH - 1, grid_y2); - gdk_draw_rectangle (drawable, style->white_gc, TRUE, - grid_x1 + 1, grid_y1, - E_DAY_VIEW_BAR_WIDTH - 2, grid_y2 - grid_y1); - - /* Fill in the bars when the user is busy. */ - e_day_view_main_item_draw_events_in_vbars (dvmitem, drawable, - x, y, - width, height, - day); - } - - /* Fill in the vertical bars corresponding to the busy times from the - long events. */ - e_day_view_main_item_draw_long_events_in_vbars (dvmitem, drawable, - x, y, width, height); - - /* Draw the event borders and backgrounds, and the vertical bars - down the left edges. */ - for (day = 0; day < day_view->days_shown; day++) { - e_day_view_main_item_draw_day_events (dvmitem, drawable, - x, y, width, height, - day); - } -} - - -static void -e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height, - gint day) -{ - EDayView *day_view; - EDayViewEvent *event; - GdkGC *gc; - gint grid_x, event_num, bar_y, bar_h; - - day_view = dvmitem->day_view; - - gc = day_view->main_gc; - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]); - - grid_x = day_view->day_offsets[day] + 1 - x; - - /* Draw the busy times corresponding to the events in the day. */ - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* We can skip the events in the first column since they will - draw over this anyway. */ - if (event->num_columns > 0 && event->start_row_or_col == 0) - continue; - - bar_y = event->start_minute * day_view->row_height / day_view->mins_per_row; - bar_h = event->end_minute * day_view->row_height / day_view->mins_per_row - bar_y; - bar_y -= y; - - /* Skip it if it isn't visible. */ - if (bar_y >= height || bar_y + bar_h <= 0) - continue; - - gdk_draw_rectangle (drawable, gc, TRUE, - grid_x, bar_y, - E_DAY_VIEW_BAR_WIDTH - 2, bar_h); - } -} - - -static void -e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, - int width, int height) -{ - EDayView *day_view; - EDayViewEvent *event; - gint event_num, start_day, end_day, day, bar_y1, bar_y2, grid_x; - GdkGC *gc; - - day_view = dvmitem->day_view; - - gc = day_view->main_gc; - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]); - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (!e_day_view_find_long_event_days (day_view, event, - &start_day, &end_day)) - continue; - - for (day = start_day; day <= end_day; day++) { - grid_x = day_view->day_offsets[day] + 1 - x; - - /* Skip if it isn't visible. */ - if (grid_x >= width - || grid_x + E_DAY_VIEW_BAR_WIDTH <= 0) - continue; - - if (event->start <= day_view->day_starts[day]) { - bar_y1 = 0; - } else { - bar_y1 = event->start_minute * day_view->row_height / day_view->mins_per_row - y; - } - - if (event->end >= day_view->day_starts[day + 1]) { - bar_y2 = height; - } else { - bar_y2 = event->end_minute * day_view->row_height / day_view->mins_per_row - y; - } - - if (bar_y1 < height && bar_y2 > 0 && bar_y2 > bar_y1) { - gdk_draw_rectangle (drawable, gc, TRUE, - grid_x, bar_y1, - E_DAY_VIEW_BAR_WIDTH - 2, - bar_y2 - bar_y1); - } - } - - - } -} - - -static void -e_day_view_main_item_draw_day_events (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, int width, int height, - gint day) -{ - EDayView *day_view; - gint event_num; - - day_view = dvmitem->day_view; - - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - e_day_view_main_item_draw_day_event (dvmitem, drawable, - x, y, width, height, - day, event_num); - } -} - - -static void -e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, - GdkDrawable *drawable, - int x, int y, int width, int height, - gint day, gint event_num) -{ - EDayView *day_view; - EDayViewEvent *event; - gint item_x, item_y, item_w, item_h, bar_y1, bar_y2; - GtkStyle *style; - GdkGC *gc; - CalComponent *comp; - gint num_icons, icon_x, icon_y, icon_x_inc, icon_y_inc; - gint max_icon_w, max_icon_h; - gboolean draw_reminder_icon, draw_recurrence_icon; - - day_view = dvmitem->day_view; - - /* If the event is currently being dragged, don't draw it. It will - be drawn in the special drag items. */ - if (day_view->drag_event_day == day - && day_view->drag_event_num == event_num) - return; - - style = GTK_WIDGET (day_view)->style; - - gc = day_view->main_gc; - gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]); - - /* Get the position of the event. If it is not shown skip it.*/ - if (!e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) - return; - - item_x -= x; - item_y -= y; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* Fill in the white background. Note that for events in the first - column of the day, we might not want to paint over the vertical bar, - since that is used for multiple events. But then you can't see - where the event in the first column finishes. */ -#if 0 - if (event->start_row_or_col == 0) - gdk_draw_rectangle (drawable, style->white_gc, TRUE, - item_x + E_DAY_VIEW_BAR_WIDTH, item_y + 1, - MAX (item_w - E_DAY_VIEW_BAR_WIDTH - 1, 0), - item_h - 2); - else -#endif - gdk_draw_rectangle (drawable, style->white_gc, TRUE, - item_x + 1, item_y + 1, - MAX (item_w - 2, 0), item_h - 2); - - /* Draw the right edge of the vertical bar. */ - gdk_draw_line (drawable, style->black_gc, - item_x + E_DAY_VIEW_BAR_WIDTH - 1, - item_y + 1, - item_x + E_DAY_VIEW_BAR_WIDTH - 1, - item_y + item_h - 2); - - /* Draw the vertical colored bar showing when the appointment - begins & ends. */ - bar_y1 = event->start_minute * day_view->row_height / day_view->mins_per_row - y; - bar_y2 = event->end_minute * day_view->row_height / day_view->mins_per_row - y; - - /* When an item is being resized, we fill the bar up to the new row. */ - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == day - && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) - bar_y1 = item_y + 1; - else if (day_view->resize_drag_pos == E_DAY_VIEW_POS_BOTTOM_EDGE) - bar_y2 = item_y + item_h - 1; - } - - gdk_draw_rectangle (drawable, gc, TRUE, - item_x + 1, bar_y1, - E_DAY_VIEW_BAR_WIDTH - 2, bar_y2 - bar_y1); - - /* Draw the box around the entire event. Do this after drawing - the colored bar so we don't have to worry about being 1 - pixel out. */ - gdk_draw_rectangle (drawable, style->black_gc, FALSE, - item_x, item_y, MAX (item_w - 1, 0), item_h - 1); - -#if 0 - /* Draw the horizontal bars above and beneath the event if it - is currently being edited. */ - if (day_view->editing_event_day == day - && day_view->editing_event_num == event_num) { - gdk_draw_rectangle (drawable, gc, TRUE, - item_x, - item_y - E_DAY_VIEW_BAR_HEIGHT, - item_w, - E_DAY_VIEW_BAR_HEIGHT); - gdk_draw_rectangle (drawable, gc, TRUE, - item_x, item_y + item_h, - item_w, E_DAY_VIEW_BAR_HEIGHT); - } -#endif - - /* Draw the reminder & recurrence icons, if needed. */ - num_icons = 0; - draw_reminder_icon = FALSE; - draw_recurrence_icon = FALSE; - icon_x = item_x + E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_ICON_X_PAD; - icon_y = item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT - + E_DAY_VIEW_ICON_Y_PAD; - comp = event->comp; - -#if 0 - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) { - draw_reminder_icon = TRUE; - num_icons++; - } -#endif - - if (cal_component_has_rrules (comp) - || cal_component_has_rdates (comp)) { - draw_recurrence_icon = TRUE; - num_icons++; - } - - if (num_icons != 0) { - if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD) - * num_icons) { - icon_x_inc = 0; - icon_y_inc = E_DAY_VIEW_ICON_HEIGHT - + E_DAY_VIEW_ICON_Y_PAD; - } else { - icon_x_inc = E_DAY_VIEW_ICON_WIDTH - + E_DAY_VIEW_ICON_X_PAD; - icon_y_inc = 0; - } - - if (draw_reminder_icon) { - max_icon_w = item_x + item_w - icon_x - - E_DAY_VIEW_EVENT_BORDER_WIDTH; - max_icon_h = item_y + item_h - icon_y - - E_DAY_VIEW_EVENT_BORDER_HEIGHT; - - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, day_view->reminder_mask); - gdk_draw_pixmap (drawable, gc, - day_view->reminder_icon, - 0, 0, icon_x, icon_y, - MIN (E_DAY_VIEW_ICON_WIDTH, - max_icon_w), - MIN (E_DAY_VIEW_ICON_HEIGHT, - max_icon_h)); - icon_x += icon_x_inc; - icon_y += icon_y_inc; - } - - if (draw_recurrence_icon) { - max_icon_w = item_x + item_w - icon_x - - E_DAY_VIEW_EVENT_BORDER_WIDTH; - max_icon_h = item_y + item_h - icon_y - - E_DAY_VIEW_EVENT_BORDER_HEIGHT; - - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, day_view->recurrence_mask); - gdk_draw_pixmap (drawable, gc, - day_view->recurrence_icon, - 0, 0, icon_x, icon_y, - MIN (E_DAY_VIEW_ICON_WIDTH, - max_icon_w), - MIN (E_DAY_VIEW_ICON_HEIGHT, - max_icon_h)); - } - gdk_gc_set_clip_mask (gc, NULL); - } -} - - -/* This is supposed to return the nearest item to the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_day_view_main_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_day_view_main_item_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EDayViewMainItem *dvtitem; - - dvtitem = E_DAY_VIEW_MAIN_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - - case GDK_BUTTON_RELEASE: - - case GDK_MOTION_NOTIFY: - - default: - break; - } - - return FALSE; -} - - diff --git a/calendar/gui/e-day-view-main-item.h b/calendar/gui/e-day-view-main-item.h deleted file mode 100644 index d8305e594d..0000000000 --- a/calendar/gui/e-day-view-main-item.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 _E_DAY_VIEW_MAIN_ITEM_H_ -#define _E_DAY_VIEW_MAIN_ITEM_H_ - -#include "e-day-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EDayViewMainItem - canvas item which displays most of the appointment - * data in the main Day/Work Week display. - */ - -#define E_DAY_VIEW_MAIN_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_day_view_main_item_get_type (), EDayViewMainItem)) -#define E_DAY_VIEW_MAIN_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_day_view_main_item_get_type ())) -#define E_IS_DAY_VIEW_MAIN_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_day_view_main_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EDayView widget. */ - EDayView *day_view; -} EDayViewMainItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EDayViewMainItemClass; - - -GtkType e_day_view_main_item_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DAY_VIEW_MAIN_ITEM_H_ */ diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c deleted file mode 100644 index c2dcf55727..0000000000 --- a/calendar/gui/e-day-view-time-item.c +++ /dev/null @@ -1,531 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * EDayViewTimeItem - canvas item which displays the times down the left of - * the EDayView. - */ - -#include <config.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkradiomenuitem.h> -#include "e-day-view-time-item.h" -#include "../../e-util/e-gui-utils.h" - - -/* The spacing between items in the time column. GRID_X_PAD is the space down - either side of the column, i.e. outside the main horizontal grid lines. - HOUR_L_PAD & HOUR_R_PAD are the spaces on the left & right side of the - big hour number (this is inside the horizontal grid lines). - MIN_X_PAD is the spacing either side of the minute number. The smaller - horizontal grid lines match with this. - 60_MIN_X_PAD is the space either side of the HH:MM display used when - we are displaying 60 mins per row (inside the main grid lines). */ -#define E_DVTMI_TIME_GRID_X_PAD 4 -#define E_DVTMI_HOUR_L_PAD 4 -#define E_DVTMI_HOUR_R_PAD 2 -#define E_DVTMI_MIN_X_PAD 2 -#define E_DVTMI_60_MIN_X_PAD 4 - - -static void e_day_view_time_item_class_init (EDayViewTimeItemClass *class); -static void e_day_view_time_item_init (EDayViewTimeItem *dvtmitem); -static void e_day_view_time_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); - -static void e_day_view_time_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, int flags); -static void e_day_view_time_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, int y, - int width, int height); -static double e_day_view_time_item_point (GnomeCanvasItem *item, - double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item); -static gint e_day_view_time_item_event (GnomeCanvasItem *item, - GdkEvent *event); -static void e_day_view_time_item_show_popup_menu (EDayViewTimeItem *dvtmitem, - GdkEvent *event); -static void e_day_view_time_item_on_set_divisions (GtkWidget *item, - EDayViewTimeItem *dvtmitem); -static void e_day_view_time_item_on_button_press (EDayViewTimeItem *dvtmitem, - GdkEvent *event); -static void e_day_view_time_item_on_button_release (EDayViewTimeItem *dvtmitem, - GdkEvent *event); -static void e_day_view_time_item_on_motion_notify (EDayViewTimeItem *dvtmitem, - GdkEvent *event); -static gint e_day_view_time_item_convert_position_to_row (EDayViewTimeItem *dvtmitem, - gint y); - - -static GnomeCanvasItemClass *parent_class; - - -/* The arguments we take */ -enum { - ARG_0, - ARG_DAY_VIEW -}; - - -GtkType -e_day_view_time_item_get_type (void) -{ - static GtkType e_day_view_time_item_type = 0; - - if (!e_day_view_time_item_type) { - GtkTypeInfo e_day_view_time_item_info = { - "EDayViewTimeItem", - sizeof (EDayViewTimeItem), - sizeof (EDayViewTimeItemClass), - (GtkClassInitFunc) e_day_view_time_item_class_init, - (GtkObjectInitFunc) e_day_view_time_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_day_view_time_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_day_view_time_item_info); - } - - return e_day_view_time_item_type; -} - - -static void -e_day_view_time_item_class_init (EDayViewTimeItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EDayViewTimeItem::day_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_DAY_VIEW); - - object_class->set_arg = e_day_view_time_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_day_view_time_item_update; - item_class->draw = e_day_view_time_item_draw; - item_class->point = e_day_view_time_item_point; - item_class->event = e_day_view_time_item_event; -} - - -static void -e_day_view_time_item_init (EDayViewTimeItem *dvtmitem) -{ - dvtmitem->dragging_selection = FALSE; -} - - -static void -e_day_view_time_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EDayViewTimeItem *dvtmitem; - - item = GNOME_CANVAS_ITEM (o); - dvtmitem = E_DAY_VIEW_TIME_ITEM (o); - - switch (arg_id){ - case ARG_DAY_VIEW: - dvtmitem->day_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_day_view_time_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* Returns the minimum width needed for the column, by adding up all the - maximum widths of the strings. The string widths are all calculated in - the style_set handlers of EDayView and EDayViewTimeCanvas. */ -gint -e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem) -{ - EDayView *day_view; - - day_view = dvtmitem->day_view; - g_return_val_if_fail (day_view != NULL, 0); - - /* Calculate the width of each time column. */ - if (day_view->mins_per_row == 60) { - dvtmitem->column_width = day_view->max_small_hour_width - + day_view->colon_width - + day_view->max_minute_width - + E_DVTMI_60_MIN_X_PAD * 2 - + E_DVTMI_TIME_GRID_X_PAD * 2; - } else { - dvtmitem->column_width = day_view->max_large_hour_width - + day_view->max_minute_width - + E_DVTMI_MIN_X_PAD * 2 - + E_DVTMI_HOUR_L_PAD - + E_DVTMI_HOUR_R_PAD - + E_DVTMI_TIME_GRID_X_PAD * 2; - } - - return dvtmitem->column_width; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EDayView *day_view; - EDayViewTimeItem *dvtmitem; - gint time_hour_x1, time_hour_x2, time_min_x1; - gint hour, minute, hour_y, min_y, hour_r, min_r, start_y; - gint row, row_y, min_width, hour_width; - GtkStyle *style; - GdkFont *small_font, *large_font; - GdkGC *fg_gc, *dark_gc; - gchar buffer[16]; - - dvtmitem = E_DAY_VIEW_TIME_ITEM (canvas_item); - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - style = GTK_WIDGET (day_view)->style; - small_font = style->font; - large_font = day_view->large_font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - - /* Step through each row, drawing the horizontal grid lines for each - day column and the times. */ - time_hour_x1 = E_DVTMI_TIME_GRID_X_PAD - x; - time_hour_x2 = dvtmitem->column_width - E_DVTMI_TIME_GRID_X_PAD - x; - if (day_view->mins_per_row == 60) { - min_r = time_hour_x2 - E_DVTMI_60_MIN_X_PAD; - } else { - time_min_x1 = time_hour_x2 - E_DVTMI_MIN_X_PAD * 2 - - day_view->max_minute_width; - hour_r = time_min_x1 - E_DVTMI_HOUR_R_PAD; - min_r = time_hour_x2 - E_DVTMI_MIN_X_PAD; - } - - hour = day_view->first_hour_shown; - hour_y = large_font->ascent + 2; /* FIXME */ - minute = day_view->first_minute_shown; - min_y = small_font->ascent + 2; /* FIXME */ - start_y = 0 - MAX (day_view->row_height, hour_y + large_font->descent); - for (row = 0, row_y = 0 - y; - row < day_view->rows && row_y < height; - row++, row_y += day_view->row_height) { - if (row_y > start_y) { - /* Draw the times down the left if needed. */ - if (min_r <= 0) - continue; - - if (day_view->mins_per_row == 60) { - gdk_draw_line (drawable, dark_gc, - time_hour_x1, row_y, - time_hour_x2, row_y); - sprintf (buffer, "%02i:%02i", hour, minute); - min_width = day_view->small_hour_widths[hour] + day_view->minute_widths[minute / 5] + day_view->colon_width; - gdk_draw_string (drawable, small_font, fg_gc, - min_r - min_width, - row_y + min_y, buffer); - } else { - if (minute == 0) { - gdk_draw_line (drawable, dark_gc, - time_hour_x1, row_y, - time_hour_x2, row_y); - sprintf (buffer, "%02i", hour); - hour_width = day_view->large_hour_widths[hour]; - gdk_draw_string (drawable, large_font, - fg_gc, - hour_r - hour_width, - row_y + hour_y, - buffer); - } else { - gdk_draw_line (drawable, dark_gc, - time_min_x1, row_y, - time_hour_x2, row_y); - } - - if (day_view->mins_per_row != 30 - || minute != 30) { - sprintf (buffer, "%02i", minute); - min_width = day_view->minute_widths[minute / 5]; - gdk_draw_string (drawable, small_font, - fg_gc, - min_r - min_width, - row_y + min_y, - buffer); - } - } - } - - minute += day_view->mins_per_row; - if (minute >= 60) { - hour++; - minute -= 60; - } - } -} - - -static double -e_day_view_time_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_day_view_time_item_event (GnomeCanvasItem *item, - GdkEvent *event) -{ - EDayViewTimeItem *dvtmitem; - - dvtmitem = E_DAY_VIEW_TIME_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - if (event->button.button == 1) { - e_day_view_time_item_on_button_press (dvtmitem, event); - } else if (event->button.button == 3) { - e_day_view_time_item_show_popup_menu (dvtmitem, event); - return TRUE; - } - break; - case GDK_BUTTON_RELEASE: - if (event->button.button == 1) - e_day_view_time_item_on_button_release (dvtmitem, - event); - break; - - case GDK_MOTION_NOTIFY: - e_day_view_time_item_on_motion_notify (dvtmitem, event); - break; - - default: - break; - } - - return FALSE; -} - - -static void -e_day_view_time_item_show_popup_menu (EDayViewTimeItem *dvtmitem, - GdkEvent *event) -{ - static gint divisions[] = { 60, 30, 15, 10, 5 }; - EDayView *day_view; - gint num_divisions = sizeof (divisions) / sizeof (divisions[0]); - GtkWidget *menu, *item; - gchar buffer[256]; - GSList *group = NULL; - gint current_divisions, i; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - current_divisions = e_day_view_get_mins_per_row (day_view); - - menu = gtk_menu_new (); - - /* Make sure the menu is destroyed when it disappears. */ - e_auto_kill_popup_menu_on_hide (GTK_MENU (menu)); - - for (i = 0; i < num_divisions; i++) { - sprintf (buffer, _("%02i minute divisions"), divisions[i]); - item = gtk_radio_menu_item_new_with_label (group, buffer); - group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (item)); - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - - if (current_divisions == divisions[i]) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - - gtk_object_set_data (GTK_OBJECT (item), "divisions", - GINT_TO_POINTER (divisions[i])); - - gtk_signal_connect (GTK_OBJECT (item), "toggled", - e_day_view_time_item_on_set_divisions, - dvtmitem); - } - - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, - event->button.button, event->button.time); -} - - -static void -e_day_view_time_item_on_set_divisions (GtkWidget *item, - EDayViewTimeItem *dvtmitem) -{ - EDayView *day_view; - gint divisions; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - if (!GTK_CHECK_MENU_ITEM (item)->active) - return; - - divisions = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (item), - "divisions")); - e_day_view_set_mins_per_row (day_view, divisions); -} - - -static void -e_day_view_time_item_on_button_press (EDayViewTimeItem *dvtmitem, - GdkEvent *event) -{ - EDayView *day_view; - GnomeCanvas *canvas; - gint row; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - canvas = GNOME_CANVAS_ITEM (dvtmitem)->canvas; - - row = e_day_view_time_item_convert_position_to_row (dvtmitem, - event->button.y); - - if (row == -1) - return; - - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (canvas)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, event->button.time) == 0) { - e_day_view_start_selection (day_view, -1, row); - dvtmitem->dragging_selection = TRUE; - } -} - - -static void -e_day_view_time_item_on_button_release (EDayViewTimeItem *dvtmitem, - GdkEvent *event) -{ - EDayView *day_view; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - if (dvtmitem->dragging_selection) { - gdk_pointer_ungrab (event->button.time); - e_day_view_finish_selection (day_view); - e_day_view_stop_auto_scroll (day_view); - } - - dvtmitem->dragging_selection = FALSE; -} - - -static void -e_day_view_time_item_on_motion_notify (EDayViewTimeItem *dvtmitem, - GdkEvent *event) -{ - EDayView *day_view; - GnomeCanvas *canvas; - gdouble window_y; - gint y, row; - - if (!dvtmitem->dragging_selection) - return; - - day_view = dvtmitem->day_view; - g_return_if_fail (day_view != NULL); - - canvas = GNOME_CANVAS_ITEM (dvtmitem)->canvas; - - y = event->motion.y; - row = e_day_view_time_item_convert_position_to_row (dvtmitem, y); - - if (row != -1) { - gnome_canvas_world_to_window (canvas, 0, event->motion.y, - NULL, &window_y); - e_day_view_update_selection (day_view, -1, row); - e_day_view_check_auto_scroll (day_view, -1, (gint) window_y); - } -} - - -/* Returns the row corresponding to the y position, or -1. */ -static gint -e_day_view_time_item_convert_position_to_row (EDayViewTimeItem *dvtmitem, - gint y) -{ - EDayView *day_view; - gint row; - - day_view = dvtmitem->day_view; - g_return_val_if_fail (day_view != NULL, -1); - - if (y < 0) - return -1; - - row = y / day_view->row_height; - if (row >= day_view->rows) - return -1; - - return row; -} diff --git a/calendar/gui/e-day-view-time-item.h b/calendar/gui/e-day-view-time-item.h deleted file mode 100644 index 8b20fe999e..0000000000 --- a/calendar/gui/e-day-view-time-item.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 _E_DAY_VIEW_TIME_ITEM_H_ -#define _E_DAY_VIEW_TIME_ITEM_H_ - -#include "e-day-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EDayViewTimeItem - canvas item which displays the times down the left of - * the EDayView. - */ - -#define E_DAY_VIEW_TIME_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_day_view_time_item_get_type (), EDayViewTimeItem)) -#define E_DAY_VIEW_TIME_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_day_view_time_item_get_type ())) -#define E_IS_DAY_VIEW_TIME_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_day_view_time_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EDayView widget. */ - EDayView *day_view; - - /* The width of the time column. */ - gint column_width; - - /* TRUE if we are currently dragging the selection times. */ - gboolean dragging_selection; -} EDayViewTimeItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EDayViewTimeItemClass; - - -GtkType e_day_view_time_item_get_type (void); - - -gint e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DAY_VIEW_TIME_ITEM_H_ */ diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c deleted file mode 100644 index 88e30885ca..0000000000 --- a/calendar/gui/e-day-view-top-item.c +++ /dev/null @@ -1,586 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * EDayViewTopItem - displays the top part of the Day/Work Week calendar view. - */ - -#include <config.h> -#include "e-day-view-top-item.h" - -static void e_day_view_top_item_class_init (EDayViewTopItemClass *class); -static void e_day_view_top_item_init (EDayViewTopItem *dvtitem); - -static void e_day_view_top_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_day_view_top_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_day_view_top_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, - gint event_num, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem, - GdkDrawable *drawable, - gint x, - gint y, - gint w, - gint h); -static double e_day_view_top_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); -static gint e_day_view_top_item_event (GnomeCanvasItem *item, - GdkEvent *event); - - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_DAY_VIEW -}; - - -GtkType -e_day_view_top_item_get_type (void) -{ - static GtkType e_day_view_top_item_type = 0; - - if (!e_day_view_top_item_type) { - GtkTypeInfo e_day_view_top_item_info = { - "EDayViewTopItem", - sizeof (EDayViewTopItem), - sizeof (EDayViewTopItemClass), - (GtkClassInitFunc) e_day_view_top_item_class_init, - (GtkObjectInitFunc) e_day_view_top_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_day_view_top_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_day_view_top_item_info); - } - - return e_day_view_top_item_type; -} - - -static void -e_day_view_top_item_class_init (EDayViewTopItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EDayViewTopItem::day_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_DAY_VIEW); - - object_class->set_arg = e_day_view_top_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_day_view_top_item_update; - item_class->draw = e_day_view_top_item_draw; - item_class->point = e_day_view_top_item_point; - item_class->event = e_day_view_top_item_event; -} - - -static void -e_day_view_top_item_init (EDayViewTopItem *dvtitem) -{ - dvtitem->day_view = NULL; -} - - -static void -e_day_view_top_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EDayViewTopItem *dvtitem; - - item = GNOME_CANVAS_ITEM (o); - dvtitem = E_DAY_VIEW_TOP_ITEM (o); - - switch (arg_id){ - case ARG_DAY_VIEW: - dvtitem->day_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_day_view_top_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_day_view_top_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EDayViewTopItem *dvtitem; - EDayView *day_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc; - gchar buffer[128]; - GdkRectangle clip_rect; - GdkFont *font; - gint canvas_width, canvas_height, left_edge, day, date_width, date_x; - gint item_height, event_num; - struct tm *day_start; - -#if 0 - g_print ("In e_day_view_top_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - dvtitem = E_DAY_VIEW_TOP_ITEM (canvas_item); - day_view = dvtitem->day_view; - g_return_if_fail (day_view != NULL); - - style = GTK_WIDGET (day_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - canvas_width = GTK_WIDGET (canvas_item->canvas)->allocation.width; - canvas_height = GTK_WIDGET (canvas_item->canvas)->allocation.height; - left_edge = 0; - item_height = day_view->top_row_height - E_DAY_VIEW_TOP_CANVAS_Y_GAP; - - /* Clear the entire background. */ - gdk_draw_rectangle (drawable, dark_gc, TRUE, - left_edge - x, 0, - canvas_width - left_edge, height); - - /* Draw the shadow around the dates. */ - gdk_draw_line (drawable, light_gc, - left_edge + 1 - x, 1 - y, - canvas_width - 2 - x, 1 - y); - gdk_draw_line (drawable, light_gc, - left_edge + 1 - x, 2 - y, - left_edge + 1 - x, item_height - 1 - y); - - /* Draw the background for the dates. */ - gdk_draw_rectangle (drawable, bg_gc, TRUE, - left_edge + 2 - x, 2 - y, - canvas_width - left_edge - 3, - item_height - 3); - - /* Draw the selection background. */ - if (GTK_WIDGET_HAS_FOCUS (day_view) - && day_view->selection_start_day != -1) { - gint start_col, end_col, rect_x, rect_y, rect_w, rect_h; - - start_col = day_view->selection_start_day; - end_col = day_view->selection_end_day; - - if (end_col > start_col - || day_view->selection_start_row == -1 - || day_view->selection_end_row == -1) { - rect_x = day_view->day_offsets[start_col]; - rect_y = item_height; - rect_w = day_view->day_offsets[end_col + 1] - rect_x; - rect_h = canvas_height - 1 - rect_y; - - gdk_draw_rectangle (drawable, style->white_gc, TRUE, - rect_x - x, rect_y - y, - rect_w, rect_h); - } - } - - /* Draw the date. Set a clipping rectangle so we don't draw over the - next day. */ - for (day = 0; day < day_view->days_shown; day++) { - day_start = localtime (&day_view->day_starts[day]); - - if (day_view->date_format == E_DAY_VIEW_DATE_FULL) - strftime (buffer, 128, "%d %B", day_start); - else if (day_view->date_format == E_DAY_VIEW_DATE_ABBREVIATED) - strftime (buffer, 128, "%d %b", day_start); - else - strftime (buffer, 128, "%d", day_start); - - clip_rect.x = day_view->day_offsets[day] - x; - clip_rect.y = 2 - y; - clip_rect.width = day_view->day_widths[day]; - clip_rect.height = item_height - 2; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - date_width = gdk_string_width (font, buffer); - date_x = day_view->day_offsets[day] + (day_view->day_widths[day] - date_width) / 2; - gdk_draw_string (drawable, font, fg_gc, - date_x - x, 3 + font->ascent - y, buffer); - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - /* Draw the lines down the left and right of the date cols. */ - if (day != 0) { - gdk_draw_line (drawable, light_gc, - day_view->day_offsets[day] - x, - 4 - y, - day_view->day_offsets[day] - x, - item_height - 4 - y); - - gdk_draw_line (drawable, dark_gc, - day_view->day_offsets[day] - 1 - x, - 4 - y, - day_view->day_offsets[day] - 1 - x, - item_height - 4 - y); - } - - /* Draw the lines between each column. */ - if (day != 0) { - gdk_draw_line (drawable, style->black_gc, - day_view->day_offsets[day] - x, - item_height - y, - day_view->day_offsets[day] - x, - canvas_height - y); - } - } - - /* Draw the long events. */ - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - e_day_view_top_item_draw_long_event (dvtitem, event_num, - drawable, - x, y, width, height); - } -} - - -/* This draws one event in the top canvas. */ -static void -e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, - gint event_num, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EDayView *day_view; - EDayViewEvent *event; - GtkStyle *style; - GdkGC *gc, *fg_gc, *bg_gc; - GdkFont *font; - gint start_day, end_day; - gint item_x, item_y, item_w, item_h; - gint text_x, icon_x, icon_y, icon_x_inc; - CalComponent *comp; - gchar buffer[16]; - gint hour, minute, offset, time_width, time_x, min_end_time_x; - gboolean draw_start_triangle, draw_end_triangle; - GdkRectangle clip_rect; - - day_view = dvtitem->day_view; - - /* If the event is currently being dragged, don't draw it. It will - be drawn in the special drag items. */ - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->drag_event_num == event_num) - return; - - if (!e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) - return; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - style = GTK_WIDGET (day_view)->style; - font = style->font; - gc = day_view->main_gc; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - comp = event->comp; - - /* Draw the lines across the top & bottom of the entire event. */ - gdk_draw_line (drawable, fg_gc, - item_x - x, item_y - y, - item_x + item_w - 1 - x, item_y - y); - gdk_draw_line (drawable, fg_gc, - item_x - x, item_y + item_h - 1 - y, - item_x + item_w - 1 - x, item_y + item_h - 1 - y); - - /* Fill it in. */ - gdk_draw_rectangle (drawable, bg_gc, TRUE, - item_x - x, item_y + 1 - y, - item_w, item_h - 2); - - /* When resizing we don't draw the triangles.*/ - draw_start_triangle = TRUE; - draw_end_triangle = TRUE; - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) - draw_start_triangle = FALSE; - - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_RIGHT_EDGE) - draw_end_triangle = FALSE; - } - - /* If the event starts before the first day shown, draw a triangle, - else just draw a vertical line down the left. */ - if (draw_start_triangle - && event->start < day_view->day_starts[start_day]) { - e_day_view_top_item_draw_triangle (dvtitem, drawable, - item_x - x, item_y - y, - -E_DAY_VIEW_BAR_WIDTH, - item_h); - } else { - gdk_draw_line (drawable, fg_gc, - item_x - x, item_y - y, - item_x - x, item_y + item_h - 1 - y); - } - - /* Similar for the event end. */ - if (draw_end_triangle - && event->end > day_view->day_starts[end_day + 1]) { - e_day_view_top_item_draw_triangle (dvtitem, drawable, - item_x + item_w - 1 - x, - item_y - y, - E_DAY_VIEW_BAR_WIDTH, - item_h); - } else { - gdk_draw_line (drawable, fg_gc, - item_x + item_w - 1 - x, - item_y - y, - item_x + item_w - 1 - x, - item_y + item_h - 1 - y); - } - - /* If we are editing the event we don't show the icons or the start - & end times. */ - if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->editing_event_num == event_num) - return; - - /* Determine the position of the label, so we know where to place the - icons. Note that since the top canvas never scrolls we don't need - to take the scroll offset into account. It will always be 0. */ - text_x = event->canvas_item->x1; - - /* Draw the icons. */ - icon_x_inc = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD; - icon_x = text_x - icon_x_inc - x; - icon_y = item_y + 1 + E_DAY_VIEW_ICON_Y_PAD - y; - - if (cal_component_has_rrules (comp) - || cal_component_has_rdates (comp)) { - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, day_view->recurrence_mask); - gdk_draw_pixmap (drawable, gc, - day_view->recurrence_icon, - 0, 0, icon_x, icon_y, - E_DAY_VIEW_ICON_WIDTH, - E_DAY_VIEW_ICON_HEIGHT); - icon_x -= icon_x_inc; - } - -#if 0 - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) { - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, day_view->reminder_mask); - gdk_draw_pixmap (drawable, gc, - day_view->reminder_icon, - 0, 0, icon_x, icon_y, - E_DAY_VIEW_ICON_WIDTH, - E_DAY_VIEW_ICON_HEIGHT); - icon_x -= icon_x_inc; - } - gdk_gc_set_clip_mask (gc, NULL); -#endif - - /* Draw the start & end times, if necessary. - Note that GtkLabel adds 1 to the ascent so we must do that to be - level with it. */ - min_end_time_x = item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x; - - if (event->start > day_view->day_starts[start_day]) { - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown + event->start_minute; - hour = offset / 60; - minute = offset % 60; - sprintf (buffer, "%02i:%02i", hour, minute); - - clip_rect.x = item_x - x; - clip_rect.y = item_y - y; - clip_rect.width = item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH; - clip_rect.height = item_h; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - gdk_draw_string (drawable, font, fg_gc, - item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x, - item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD + font->ascent + 1 - y, - buffer); - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - min_end_time_x += day_view->small_hour_widths[hour] + 2 - + day_view->max_minute_width + day_view->colon_width; - } - - if (event->end < day_view->day_starts[end_day + 1]) { - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown - + event->end_minute; - hour = offset / 60; - minute = offset % 60; - time_width = day_view->small_hour_widths[hour] - + day_view->max_minute_width + day_view->colon_width; - time_x = item_x + item_w - E_DAY_VIEW_LONG_EVENT_X_PAD - time_width - E_DAY_VIEW_LONG_EVENT_TIME_X_PAD - x; - - if (time_x >= min_end_time_x) { - sprintf (buffer, "%02i:%02i", hour, minute); - gdk_draw_string (drawable, font, fg_gc, - time_x, - item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD - + font->ascent + 1 - y, - buffer); - } - } -} - - -/* This draws a little triangle to indicate that an event extends past - the days visible on screen. */ -static void -e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem, - GdkDrawable *drawable, - gint x, - gint y, - gint w, - gint h) -{ - EDayView *day_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc; - GdkPoint points[3]; - gint c1, c2; - - day_view = dvtitem->day_view; - - style = GTK_WIDGET (day_view)->style; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - - points[0].x = x; - points[0].y = y; - points[1].x = x + w; - points[1].y = y + (h / 2) - 1; - points[2].x = x; - points[2].y = y + h - 1; - - /* If the height is odd we can use the same central point for both - lines. If it is even we use different end-points. */ - c1 = c2 = y + (h / 2); - if (h % 2 == 0) - c1--; - - gdk_draw_polygon (drawable, bg_gc, TRUE, points, 3); - gdk_draw_line (drawable, fg_gc, x, y, x + w, c1); - gdk_draw_line (drawable, fg_gc, x, y + h - 1, x + w, c2); -} - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_day_view_top_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_day_view_top_item_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EDayViewTopItem *dvtitem; - - dvtitem = E_DAY_VIEW_TOP_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - - case GDK_BUTTON_RELEASE: - - case GDK_MOTION_NOTIFY: - - default: - break; - } - - return FALSE; -} - - diff --git a/calendar/gui/e-day-view-top-item.h b/calendar/gui/e-day-view-top-item.h deleted file mode 100644 index 435ef12b58..0000000000 --- a/calendar/gui/e-day-view-top-item.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 _E_DAY_VIEW_TOP_ITEM_H_ -#define _E_DAY_VIEW_TOP_ITEM_H_ - -#include "e-day-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EDayViewTopItem - displays the top part of the Day/Work Week calendar view. - */ - -#define E_DAY_VIEW_TOP_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_day_view_top_item_get_type (), EDayViewTopItem)) -#define E_DAY_VIEW_TOP_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_day_view_top_item_get_type ())) -#define E_IS_DAY_VIEW_TOP_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_day_view_top_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EDayView widget. */ - EDayView *day_view; -} EDayViewTopItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EDayViewTopItemClass; - - -GtkType e_day_view_top_item_get_type (void); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DAY_VIEW_TOP_ITEM_H_ */ diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c deleted file mode 100644 index c14da5f58f..0000000000 --- a/calendar/gui/e-day-view.c +++ /dev/null @@ -1,5716 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * EDayView - displays the Day & Work-Week views of the calendar. - */ - -#include <config.h> -#include <math.h> -#include <time.h> -#include <gnome.h> -#include <gdk/gdkx.h> -#include <cal-util/timeutil.h> -#include "e-day-view.h" -#include "e-day-view-time-item.h" -#include "e-day-view-top-item.h" -#include "e-day-view-main-item.h" -#include "calendar-commands.h" -#include "popup-menu.h" -#include "../e-util/e-canvas.h" -#include "../widgets/e-text/e-text.h" -#include "e-util/e-canvas-utils.h" - -/* Images */ -#include "bell.xpm" -#include "recur.xpm" - -/* The minimum amount of space wanted on each side of the date string. */ -#define E_DAY_VIEW_DATE_X_PAD 4 - -#define E_DAY_VIEW_LARGE_FONT \ - "-adobe-utopia-regular-r-normal-*-*-240-*-*-p-*-iso8859-*" -#define E_DAY_VIEW_LARGE_FONT_FALLBACK \ - "-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-iso8859-*" - -/* The offset from the top/bottom of the canvas before auto-scrolling starts.*/ -#define E_DAY_VIEW_AUTO_SCROLL_OFFSET 16 - -/* The time between each auto-scroll, in milliseconds. */ -#define E_DAY_VIEW_AUTO_SCROLL_TIMEOUT 50 - -/* The number of timeouts we skip before we start scrolling. */ -#define E_DAY_VIEW_AUTO_SCROLL_DELAY 5 - -/* The number of pixels the mouse has to be moved with the button down before - we start a drag. */ -#define E_DAY_VIEW_DRAG_START_OFFSET 4 - -/* Drag and Drop stuff. */ -enum { - TARGET_CALENDAR_EVENT -}; -static GtkTargetEntry target_table[] = { - { "application/x-e-calendar-event", 0, TARGET_CALENDAR_EVENT } -}; -static guint n_targets = sizeof(target_table) / sizeof(target_table[0]); - -static void e_day_view_class_init (EDayViewClass *class); -static void e_day_view_init (EDayView *day_view); -static void e_day_view_destroy (GtkObject *object); -static void e_day_view_realize (GtkWidget *widget); -static void e_day_view_unrealize (GtkWidget *widget); -static void e_day_view_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static void e_day_view_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean e_day_view_update_scroll_regions (EDayView *day_view); -static gint e_day_view_focus_in (GtkWidget *widget, - GdkEventFocus *event); -static gint e_day_view_focus_out (GtkWidget *widget, - GdkEventFocus *event); -static gint e_day_view_key_press (GtkWidget *widget, - GdkEventKey *event); -static void e_day_view_cursor_key_up_shifted (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_down_shifted (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_left_shifted (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_right_shifted (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_up (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_down (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_left (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_cursor_key_right (EDayView *day_view, - GdkEventKey *event); -static void e_day_view_ensure_rows_visible (EDayView *day_view, - gint start_row, - gint end_row); - -static gboolean e_day_view_check_if_new_event_fits (EDayView *day_view); - -static void e_day_view_on_canvas_realized (GtkWidget *widget, - EDayView *day_view); - -static gboolean e_day_view_on_top_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); -static gboolean e_day_view_on_top_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); -static gboolean e_day_view_on_top_canvas_motion (GtkWidget *widget, - GdkEventMotion *event, - EDayView *day_view); - -static gboolean e_day_view_on_main_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); -static gboolean e_day_view_on_main_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); - -static gboolean e_day_view_on_time_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view); - -static void e_day_view_update_calendar_selection_time (EDayView *day_view); -static gboolean e_day_view_on_main_canvas_motion (GtkWidget *widget, - GdkEventMotion *event, - EDayView *day_view); -static gboolean e_day_view_convert_event_coords (EDayView *day_view, - GdkEvent *event, - GdkWindow *window, - gint *x_return, - gint *y_return); -static void e_day_view_update_long_event_resize (EDayView *day_view, - gint day); -static void e_day_view_update_resize (EDayView *day_view, - gint row); -static void e_day_view_finish_long_event_resize (EDayView *day_view); -static void e_day_view_finish_resize (EDayView *day_view); -static void e_day_view_abort_resize (EDayView *day_view, - guint32 time); - - -static gboolean e_day_view_on_long_event_button_press (EDayView *day_view, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y); -static gboolean e_day_view_on_event_button_press (EDayView *day_view, - gint day, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y); -static void e_day_view_on_long_event_click (EDayView *day_view, - gint event_num, - GdkEventButton *bevent, - EDayViewPosition pos, - gint event_x, - gint event_y); -static void e_day_view_on_event_click (EDayView *day_view, - gint day, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y); -static void e_day_view_on_event_double_click (EDayView *day_view, - gint day, - gint event_num); -static void e_day_view_on_event_right_click (EDayView *day_view, - GdkEventButton *bevent, - gint day, - gint event_num); - -static void e_day_view_recalc_day_starts (EDayView *day_view, - time_t start_time); -static void e_day_view_recalc_num_rows (EDayView *day_view); - -static EDayViewPosition e_day_view_convert_position_in_top_canvas (EDayView *day_view, - gint x, - gint y, - gint *day_return, - gint *event_num_return); -static EDayViewPosition e_day_view_convert_position_in_main_canvas (EDayView *day_view, - gint x, - gint y, - gint *day_return, - gint *row_return, - gint *event_num_return); -static gboolean e_day_view_find_event_from_item (EDayView *day_view, - GnomeCanvasItem *item, - gint *day_return, - gint *event_num_return); -static gboolean e_day_view_find_event_from_uid (EDayView *day_view, - const gchar *uid, - gint *day_return, - gint *event_num_return); - -typedef gboolean (* EDayViewForeachEventCallback) (EDayView *day_view, - gint day, - gint event_num, - gpointer data); - -static void e_day_view_foreach_event_with_uid (EDayView *day_view, - const gchar *uid, - EDayViewForeachEventCallback callback, - gpointer data); - -static void e_day_view_reload_events (EDayView *day_view); -static void e_day_view_free_events (EDayView *day_view); -static void e_day_view_free_event_array (EDayView *day_view, - GArray *array); -static int e_day_view_add_event (CalComponent *comp, - time_t start, - time_t end, - gpointer data); -static void e_day_view_update_event_label (EDayView *day_view, - gint day, - gint event_num); -static void e_day_view_update_long_event_label (EDayView *day_view, - gint event_num); - -static void e_day_view_layout_long_events (EDayView *day_view); -static void e_day_view_layout_long_event (EDayView *day_view, - EDayViewEvent *event, - guint8 *grid); -static void e_day_view_reshape_long_events (EDayView *day_view); -static void e_day_view_reshape_long_event (EDayView *day_view, - gint event_num); -static void e_day_view_layout_day_events (EDayView *day_view, - gint day); -static void e_day_view_layout_day_event (EDayView *day_view, - gint day, - EDayViewEvent *event, - guint8 *grid, - guint16 *group_starts); -static void e_day_view_expand_day_event (EDayView *day_view, - gint day, - EDayViewEvent *event, - guint8 *grid); -static void e_day_view_recalc_cols_per_row (EDayView *day_view, - gint day, - guint16 *group_starts); -static void e_day_view_reshape_day_events (EDayView *day_view, - gint day); -static void e_day_view_reshape_day_event (EDayView *day_view, - gint day, - gint event_num); -static void e_day_view_reshape_main_canvas_resize_bars (EDayView *day_view); -static void e_day_view_reshape_resize_long_event_rect_item (EDayView *day_view); -static void e_day_view_reshape_resize_rect_item (EDayView *day_view); - -static void e_day_view_ensure_events_sorted (EDayView *day_view); -static gint e_day_view_event_sort_func (const void *arg1, - const void *arg2); - -static void e_day_view_start_editing_event (EDayView *day_view, - gint day, - gint event_num, - gchar *initial_text); -static void e_day_view_stop_editing_event (EDayView *day_view); -static gboolean e_day_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *event, - EDayView *day_view); -static void e_day_view_on_editing_started (EDayView *day_view, - GnomeCanvasItem *item); -static void e_day_view_on_editing_stopped (EDayView *day_view, - GnomeCanvasItem *item); - -static time_t e_day_view_convert_grid_position_to_time (EDayView *day_view, - gint col, - gint row); -static gboolean e_day_view_convert_time_to_grid_position (EDayView *day_view, - time_t time, - gint *col, - gint *row); - -static void e_day_view_start_auto_scroll (EDayView *day_view, - gboolean scroll_up); -static gboolean e_day_view_auto_scroll_handler (gpointer data); - -static void e_day_view_on_new_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_edit_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_delete_occurrence (GtkWidget *widget, - gpointer data); -static void e_day_view_on_delete_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_unrecur_appointment (GtkWidget *widget, - gpointer data); -static EDayViewEvent* e_day_view_get_popup_menu_event (EDayView *day_view); - -static gint e_day_view_on_top_canvas_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EDayView *day_view); -static void e_day_view_update_top_canvas_drag (EDayView *day_view, - gint day); -static void e_day_view_reshape_top_canvas_drag_item (EDayView *day_view); -static gint e_day_view_on_main_canvas_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EDayView *day_view); -static void e_day_view_reshape_main_canvas_drag_item (EDayView *day_view); -static void e_day_view_update_main_canvas_drag (EDayView *day_view, - gint row, - gint day); -static void e_day_view_on_top_canvas_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time, - EDayView *day_view); -static void e_day_view_on_main_canvas_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time, - EDayView *day_view); -static void e_day_view_on_drag_begin (GtkWidget *widget, - GdkDragContext *context, - EDayView *day_view); -static void e_day_view_on_drag_end (GtkWidget *widget, - GdkDragContext *context, - EDayView *day_view); -static void e_day_view_on_drag_data_get (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - EDayView *day_view); -static void e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - EDayView *day_view); -static void e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - EDayView *day_view); -static gboolean e_day_view_update_event_cb (EDayView *day_view, - gint day, - gint event_num, - gpointer data); -static gboolean e_day_view_remove_event_cb (EDayView *day_view, - gint day, - gint event_num, - gpointer data); -static void e_day_view_normalize_selection (EDayView *day_view); - - -static GtkTableClass *parent_class; - - -GtkType -e_day_view_get_type (void) -{ - static GtkType e_day_view_type = 0; - - if (!e_day_view_type){ - GtkTypeInfo e_day_view_info = { - "EDayView", - sizeof (EDayView), - sizeof (EDayViewClass), - (GtkClassInitFunc) e_day_view_class_init, - (GtkObjectInitFunc) e_day_view_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - parent_class = gtk_type_class (GTK_TYPE_TABLE); - e_day_view_type = gtk_type_unique (GTK_TYPE_TABLE, - &e_day_view_info); - } - - return e_day_view_type; -} - - -static void -e_day_view_class_init (EDayViewClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - /* Method override */ - object_class->destroy = e_day_view_destroy; - - widget_class->realize = e_day_view_realize; - widget_class->unrealize = e_day_view_unrealize; - widget_class->style_set = e_day_view_style_set; - widget_class->size_allocate = e_day_view_size_allocate; - widget_class->focus_in_event = e_day_view_focus_in; - widget_class->focus_out_event = e_day_view_focus_out; - widget_class->key_press_event = e_day_view_key_press; -} - - -static void -e_day_view_init (EDayView *day_view) -{ - GdkColormap *colormap; - gboolean success[E_DAY_VIEW_COLOR_LAST]; - gint day, nfailed; - GnomeCanvasGroup *canvas_group; - - GTK_WIDGET_SET_FLAGS (day_view, GTK_CAN_FOCUS); - - colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view)); - - day_view->calendar = NULL; - - day_view->long_events = g_array_new (FALSE, FALSE, - sizeof (EDayViewEvent)); - day_view->long_events_sorted = TRUE; - day_view->long_events_need_layout = FALSE; - day_view->long_events_need_reshape = FALSE; - - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) { - day_view->events[day] = g_array_new (FALSE, FALSE, - sizeof (EDayViewEvent)); - day_view->events_sorted[day] = TRUE; - day_view->need_layout[day] = FALSE; - day_view->need_reshape[day] = FALSE; - } - - /* These indicate that the times haven't been set. */ - day_view->lower = 0; - day_view->upper = 0; - - /* FIXME: Initialize day_starts. */ - day_view->days_shown = 1; - - day_view->mins_per_row = 30; - day_view->date_format = E_DAY_VIEW_DATE_FULL; - day_view->rows_in_top_display = 0; - - /* Note that these don't work yet. It would need a few fixes to the - way event->start_minute and event->end_minute are used, and there - may be problems with events that go outside the visible times. */ - day_view->first_hour_shown = 0; - day_view->first_minute_shown = 0; - day_view->last_hour_shown = 24; - day_view->last_minute_shown = 0; - - day_view->main_gc = NULL; - e_day_view_recalc_num_rows (day_view); - - day_view->work_day_start_hour = 9; - day_view->work_day_start_minute = 0; - day_view->work_day_end_hour = 17; - day_view->work_day_end_minute = 0; - day_view->scroll_to_work_day = TRUE; - - day_view->editing_event_day = -1; - day_view->editing_event_num = -1; - day_view->editing_new_event = FALSE; - - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - - day_view->selection_start_row = -1; - day_view->selection_start_day = -1; - day_view->selection_end_row = -1; - day_view->selection_end_day = -1; - day_view->selection_is_being_dragged = FALSE; - day_view->selection_drag_pos = E_DAY_VIEW_DRAG_END; - day_view->selection_in_top_canvas = FALSE; - - day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - - day_view->pressed_event_day = -1; - - day_view->drag_event_day = -1; - day_view->drag_last_day = -1; - - day_view->auto_scroll_timeout_id = 0; - - /* Create the large font. */ - day_view->large_font = gdk_font_load (E_DAY_VIEW_LARGE_FONT); - if (!day_view->large_font) - day_view->large_font = gdk_font_load (E_DAY_VIEW_LARGE_FONT_FALLBACK); - if (!day_view->large_font) - g_warning ("Couldn't load font"); - - - /* Allocate the colors. */ -#if 1 - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].red = 247 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].green = 247 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].blue = 244 * 257; - - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].red = 216 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].green = 216 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].blue = 214 * 257; -#else - - /* FG: MistyRose1, LightPink3 | RosyBrown | MistyRose3. */ - - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].red = 255 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].green = 228 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].blue = 225 * 257; - - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].red = 238 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].green = 162 * 257; - day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].blue = 173 * 257; -#endif - - day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].red = 0; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].green = 0; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].blue = 65535; - - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].red = 65535; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].green = 65535; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].blue = 65535; - - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].red = 0; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].green = 0; - day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].blue = 0; - - nfailed = gdk_colormap_alloc_colors (colormap, day_view->colors, - E_DAY_VIEW_COLOR_LAST, FALSE, - TRUE, success); - if (nfailed) - g_warning ("Failed to allocate all colors"); - - - - /* - * Top Canvas - */ - day_view->top_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (day_view), day_view->top_canvas, - 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (day_view->top_canvas); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), "button_press_event", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_button_press), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), "button_release_event", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_button_release), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), "motion_notify_event", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_motion), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), - "drag_motion", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_drag_motion), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->top_canvas), - "drag_leave", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_drag_leave), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), - "drag_begin", - GTK_SIGNAL_FUNC (e_day_view_on_drag_begin), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), - "drag_end", - GTK_SIGNAL_FUNC (e_day_view_on_drag_end), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), - "drag_data_get", - GTK_SIGNAL_FUNC (e_day_view_on_drag_data_get), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), - "drag_data_received", - GTK_SIGNAL_FUNC (e_day_view_on_top_canvas_drag_data_received), - day_view); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->top_canvas)->root); - - day_view->top_canvas_item = - gnome_canvas_item_new (canvas_group, - e_day_view_top_item_get_type (), - "EDayViewTopItem::day_view", day_view, - NULL); - - day_view->resize_long_event_rect_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type(), - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - - day_view->drag_long_event_rect_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->drag_long_event_rect_item); - - day_view->drag_long_event_item = - gnome_canvas_item_new (canvas_group, - e_text_get_type (), - "anchor", GTK_ANCHOR_NW, - "line_wrap", TRUE, - "clip", TRUE, - "max_lines", 1, - "editable", TRUE, - NULL); - gnome_canvas_item_hide (day_view->drag_long_event_item); - - /* - * Main Canvas - */ - day_view->main_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (day_view), day_view->main_canvas, - 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (day_view->main_canvas); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), "realize", - GTK_SIGNAL_FUNC (e_day_view_on_canvas_realized), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "button_press_event", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_button_press), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "button_release_event", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_button_release), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "motion_notify_event", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_motion), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "drag_motion", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_drag_motion), - day_view); - gtk_signal_connect_after (GTK_OBJECT (day_view->main_canvas), - "drag_leave", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_drag_leave), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), - "drag_begin", - GTK_SIGNAL_FUNC (e_day_view_on_drag_begin), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), - "drag_end", - GTK_SIGNAL_FUNC (e_day_view_on_drag_end), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), - "drag_data_get", - GTK_SIGNAL_FUNC (e_day_view_on_drag_data_get), - day_view); - gtk_signal_connect (GTK_OBJECT (day_view->main_canvas), - "drag_data_received", - GTK_SIGNAL_FUNC (e_day_view_on_main_canvas_drag_data_received), - day_view); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->main_canvas)->root); - - day_view->main_canvas_item = - gnome_canvas_item_new (canvas_group, - e_day_view_main_item_get_type (), - "EDayViewMainItem::day_view", day_view, - NULL); - - day_view->resize_rect_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type(), - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->resize_rect_item); - - day_view->resize_bar_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type(), - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->resize_bar_item); - - day_view->main_canvas_top_resize_bar_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - - day_view->main_canvas_bottom_resize_bar_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - - - day_view->drag_rect_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->drag_rect_item); - - day_view->drag_bar_item = - gnome_canvas_item_new (canvas_group, - gnome_canvas_rect_get_type (), - "width_pixels", 1, - "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR], - "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER], - NULL); - gnome_canvas_item_hide (day_view->drag_bar_item); - - day_view->drag_item = - gnome_canvas_item_new (canvas_group, - e_text_get_type (), - "anchor", GTK_ANCHOR_NW, - "line_wrap", TRUE, - "clip", TRUE, - "editable", TRUE, - NULL); - gnome_canvas_item_hide (day_view->drag_item); - - - /* - * Times Canvas - */ - day_view->time_canvas = e_canvas_new (); - gtk_layout_set_vadjustment (GTK_LAYOUT (day_view->time_canvas), - GTK_LAYOUT (day_view->main_canvas)->vadjustment); - gtk_table_attach (GTK_TABLE (day_view), day_view->time_canvas, - 0, 1, 1, 2, - GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (day_view->time_canvas); - gtk_signal_connect_after (GTK_OBJECT (day_view->time_canvas), - "button_press_event", - GTK_SIGNAL_FUNC (e_day_view_on_time_canvas_button_press), - day_view); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->time_canvas)->root); - - day_view->time_canvas_item = - gnome_canvas_item_new (canvas_group, - e_day_view_time_item_get_type (), - "EDayViewTimeItem::day_view", day_view, - NULL); - - - /* - * Scrollbar. - */ - day_view->vscrollbar = gtk_vscrollbar_new (GTK_LAYOUT (day_view->main_canvas)->vadjustment); - gtk_table_attach (GTK_TABLE (day_view), day_view->vscrollbar, - 2, 3, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (day_view->vscrollbar); - - - /* Create the pixmaps. */ - day_view->reminder_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &day_view->reminder_mask, NULL, bell_xpm); - day_view->recurrence_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &day_view->recurrence_mask, NULL, recur_xpm); - - - /* Create the cursors. */ - day_view->normal_cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW); - day_view->move_cursor = gdk_cursor_new (GDK_FLEUR); - day_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); - day_view->resize_height_cursor = gdk_cursor_new (GDK_SB_V_DOUBLE_ARROW); - day_view->last_cursor_set_in_top_canvas = NULL; - day_view->last_cursor_set_in_main_canvas = NULL; - - /* Set up the drop sites. */ - gtk_drag_dest_set (day_view->top_canvas, - GTK_DEST_DEFAULT_ALL, - target_table, n_targets, - GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_drag_dest_set (day_view->main_canvas, - GTK_DEST_DEFAULT_ALL, - target_table, n_targets, - GDK_ACTION_COPY | GDK_ACTION_MOVE); -} - - -/* Turn off the background of the canvas windows. This reduces flicker - considerably when scrolling. (Why isn't it in GnomeCanvas?). */ -static void -e_day_view_on_canvas_realized (GtkWidget *widget, - EDayView *day_view) -{ - gdk_window_set_back_pixmap (GTK_LAYOUT (widget)->bin_window, - NULL, FALSE); -} - - -/** - * e_day_view_new: - * @Returns: a new #EDayView. - * - * Creates a new #EDayView. - **/ -GtkWidget * -e_day_view_new (void) -{ - GtkWidget *day_view; - - day_view = GTK_WIDGET (gtk_type_new (e_day_view_get_type ())); - - return day_view; -} - - -static void -e_day_view_destroy (GtkObject *object) -{ - EDayView *day_view; - gint day; - - day_view = E_DAY_VIEW (object); - - e_day_view_stop_auto_scroll (day_view); - - if (day_view->large_font) - gdk_font_unref (day_view->large_font); - - gdk_cursor_destroy (day_view->normal_cursor); - gdk_cursor_destroy (day_view->move_cursor); - gdk_cursor_destroy (day_view->resize_width_cursor); - gdk_cursor_destroy (day_view->resize_height_cursor); - - e_day_view_free_events (day_view); - g_array_free (day_view->long_events, TRUE); - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - g_array_free (day_view->events[day], TRUE); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -static void -e_day_view_realize (GtkWidget *widget) -{ - EDayView *day_view; - - if (GTK_WIDGET_CLASS (parent_class)->realize) - (*GTK_WIDGET_CLASS (parent_class)->realize)(widget); - - day_view = E_DAY_VIEW (widget); - day_view->main_gc = gdk_gc_new (widget->window); -} - - -static void -e_day_view_unrealize (GtkWidget *widget) -{ - EDayView *day_view; - - day_view = E_DAY_VIEW (widget); - - gdk_gc_unref (day_view->main_gc); - day_view->main_gc = NULL; - - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget); -} - - -static void -e_day_view_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - EDayView *day_view; - GdkFont *font; - gint top_rows, top_canvas_height; - gint month, max_month_width, max_abbr_month_width, number_width; - gint hour, max_large_hour_width, month_width; - gint minute, max_minute_width, i; - GDate date; - gchar buffer[128]; - gint times_width; - - if (GTK_WIDGET_CLASS (parent_class)->style_set) - (*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style); - - day_view = E_DAY_VIEW (widget); - font = widget->style->font; - - /* Recalculate the height of each row based on the font size. */ - day_view->row_height = font->ascent + font->descent + E_DAY_VIEW_EVENT_BORDER_HEIGHT * 2 + E_DAY_VIEW_EVENT_Y_PAD * 2 + 2 /* FIXME */; - day_view->row_height = MAX (day_view->row_height, E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD + 2); - GTK_LAYOUT (day_view->main_canvas)->vadjustment->step_increment = day_view->row_height; - - day_view->top_row_height = font->ascent + font->descent + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT * 2 + E_DAY_VIEW_LONG_EVENT_Y_PAD * 2 + E_DAY_VIEW_TOP_CANVAS_Y_GAP; - day_view->top_row_height = MAX (day_view->top_row_height, E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD + 2 + E_DAY_VIEW_TOP_CANVAS_Y_GAP); - - /* Set the height of the top canvas based on the row height and the - number of rows needed (min 1 + 1 for the dates + 1 space for DnD).*/ - top_rows = MAX (1, day_view->rows_in_top_display); - top_canvas_height = (top_rows + 2) * day_view->top_row_height; - gtk_widget_set_usize (day_view->top_canvas, -1, top_canvas_height); - - /* Find the biggest full month name. */ - g_date_clear (&date, 1); - g_date_set_dmy (&date, 20, 1, 2000); - max_month_width = 0; - max_abbr_month_width = 0; - for (month = 1; month <= 12; month++) { - g_date_set_month (&date, month); - - g_date_strftime (buffer, 128, "%B", &date); - month_width = gdk_string_width (font, buffer); - max_month_width = MAX (max_month_width, month_width); - - g_date_strftime (buffer, 128, "%b", &date); - month_width = gdk_string_width (font, buffer); - max_abbr_month_width = MAX (max_abbr_month_width, month_width); - } - number_width = gdk_string_width (font, "31 "); - day_view->long_format_width = number_width + max_month_width - + E_DAY_VIEW_DATE_X_PAD; - day_view->abbreviated_format_width = number_width - + max_abbr_month_width + E_DAY_VIEW_DATE_X_PAD; - - /* Calculate the widths of all the time strings necessary. */ - day_view->max_small_hour_width = 0; - max_large_hour_width = 0; - for (hour = 0; hour < 24; hour++) { - sprintf (buffer, "%02i", hour); - day_view->small_hour_widths[hour] = gdk_string_width (font, buffer); - day_view->large_hour_widths[hour] = gdk_string_width (day_view->large_font, buffer); - day_view->max_small_hour_width = MAX (day_view->max_small_hour_width, day_view->small_hour_widths[hour]); - max_large_hour_width = MAX (max_large_hour_width, day_view->large_hour_widths[hour]); - } - day_view->max_large_hour_width = max_large_hour_width; - - max_minute_width = 0; - for (minute = 0, i = 0; minute < 60; minute += 5, i++) { - sprintf (buffer, "%02i", minute); - day_view->minute_widths[i] = gdk_string_width (font, buffer); - max_minute_width = MAX (max_minute_width, day_view->minute_widths[i]); - } - day_view->max_minute_width = max_minute_width; - day_view->colon_width = gdk_string_width (font, ":"); - - /* Calculate the width of the time column. */ - times_width = e_day_view_time_item_get_column_width (E_DAY_VIEW_TIME_ITEM (day_view->time_canvas_item)); - gtk_widget_set_usize (day_view->time_canvas, times_width, -1); -} - - -/* This recalculates the sizes of each column. */ -static void -e_day_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - EDayView *day_view; - gfloat width, offset; - gint col, day, scroll_y; - gboolean need_reshape; - gdouble old_x2, old_y2, new_x2, new_y2; - -#if 0 - g_print ("In e_day_view_size_allocate\n"); -#endif - day_view = E_DAY_VIEW (widget); - - (*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); - - /* Calculate the column sizes, using floating point so that pixels - get divided evenly. Note that we use one more element than the - number of columns, to make it easy to get the column widths. */ - width = day_view->main_canvas->allocation.width; - width /= day_view->days_shown; - offset = 0; - for (col = 0; col <= day_view->days_shown; col++) { - day_view->day_offsets[col] = floor (offset + 0.5); - offset += width; - } - - /* Calculate the days widths based on the offsets. */ - for (col = 0; col < day_view->days_shown; col++) { - day_view->day_widths[col] = day_view->day_offsets[col + 1] - day_view->day_offsets[col]; - } - - /* Determine which date format to use, based on the column widths. */ - if (day_view->day_widths[0] > day_view->long_format_width) - day_view->date_format = E_DAY_VIEW_DATE_FULL; - else if (day_view->day_widths[0] > day_view->abbreviated_format_width) - day_view->date_format = E_DAY_VIEW_DATE_ABBREVIATED; - else - day_view->date_format = E_DAY_VIEW_DATE_SHORT; - - /* Set the scroll region of the top canvas to its allocated size. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (day_view->top_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = day_view->top_canvas->allocation.width - 1; - new_y2 = day_view->top_canvas->allocation.height - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (day_view->top_canvas), - 0, 0, new_x2, new_y2); - - need_reshape = e_day_view_update_scroll_regions (day_view); - - /* Scroll to the start of the working day, if this is the initial - allocation. */ - if (day_view->scroll_to_work_day) { - scroll_y = e_day_view_convert_time_to_position (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); - gnome_canvas_scroll_to (GNOME_CANVAS (day_view->main_canvas), - 0, scroll_y); - day_view->scroll_to_work_day = FALSE; - } - - /* Flag that we need to reshape the events. Note that changes in height - don't matter, since the rows are always the same height. */ - if (need_reshape) { - day_view->long_events_need_reshape = TRUE; - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - day_view->need_reshape[day] = TRUE; - - e_day_view_check_layout (day_view); - } -} - - -static gint -e_day_view_focus_in (GtkWidget *widget, GdkEventFocus *event) -{ - EDayView *day_view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - day_view = E_DAY_VIEW (widget); - - GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); - - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - return FALSE; -} - - -static gint -e_day_view_focus_out (GtkWidget *widget, GdkEventFocus *event) -{ - EDayView *day_view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - day_view = E_DAY_VIEW (widget); - - GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - return FALSE; -} - - -void -e_day_view_set_calendar (EDayView *day_view, - GnomeCalendar *calendar) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - day_view->calendar = calendar; - - /* FIXME: free current events? */ -} - - -/* This reloads all calendar events. */ -void -e_day_view_update_all_events (EDayView *day_view) -{ - e_day_view_reload_events (day_view); -} - - -/* This is called when one event has been added or updated. */ -void -e_day_view_update_event (EDayView *day_view, - const gchar *uid) -{ - EDayViewEvent *event; - CalComponent *comp; - CalClientGetStatus status; - gint day, event_num; - - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - -#if 0 - /* FIXME: Just for testing. */ - chdir ("/home/damon/tmp"); - g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); - - g_print ("In e_day_view_update_event day_view:%p uid:%s\n", - day_view, uid); -#endif - - /* If our calendar or time hasn't been set yet, just return. */ - if (!day_view->calendar - || (day_view->lower == 0 && day_view->upper == 0)) - return; - - /* Get the event from the server. */ - status = cal_client_get_object (day_view->calendar->client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* Do nothing. */ - break; - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_warning ("syntax error uid=%s\n", uid); - return; - case CAL_CLIENT_GET_NOT_FOUND: - g_warning ("obj not found uid=%s\n", uid); - return; - } - - /* We only care about events. */ - if (comp && cal_component_get_vtype (comp) == CAL_COMPONENT_EVENT) { - gtk_object_unref (GTK_OBJECT (comp)); - return; - } - - /* If the event already exists and the dates didn't change, we can - update the event fairly easily without changing the events arrays - or computing a new layout. */ - if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) { - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); -#warning "FIX ME" - /* Do this the long way every time for now */ -#if 0 - if (ical_object_compare_dates (event->ico, ico)) { - g_print ("updated object's dates unchanged\n"); - e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, ico); - ical_object_unref (ico); - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - return; - } -#endif - /* The dates have changed, so we need to remove the - old occurrrences before adding the new ones. */ - g_print ("dates changed - removing occurrences\n"); - e_day_view_foreach_event_with_uid (day_view, uid, - e_day_view_remove_event_cb, - NULL); - } - - /* Add the occurrences of the event. */ - cal_recur_generate_instances (comp, day_view->lower, - day_view->upper, - e_day_view_add_event, - day_view); - gtk_object_unref (GTK_OBJECT (comp)); - - e_day_view_check_layout (day_view); - - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static gboolean -e_day_view_update_event_cb (EDayView *day_view, - gint day, - gint event_num, - gpointer data) -{ - EDayViewEvent *event; - CalComponent *comp; - - comp = data; -#if 0 - g_print ("In e_day_view_update_event_cb day:%i event_num:%i\n", - day, event_num); -#endif - if (day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - } else { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - } - - gtk_object_unref (GTK_OBJECT (event->comp)); - event->comp = comp; - gtk_object_ref (GTK_OBJECT (comp)); - - /* If we are editing an event which we have just created, we will get - an update_event callback from the server. But we need to ignore it - or we will lose the text the user has already typed in. */ - if (day_view->editing_new_event - && day_view->editing_event_day == day - && day_view->editing_event_num == event_num) { - return TRUE; - } - - if (day == E_DAY_VIEW_LONG_EVENT) { - e_day_view_update_long_event_label (day_view, event_num); - e_day_view_reshape_long_event (day_view, event_num); - } else { - e_day_view_update_event_label (day_view, day, event_num); - e_day_view_reshape_day_event (day_view, day, event_num); - } - return TRUE; -} - - -/* This calls a given function for each event instance that matches the given - uid. Note that it is safe for the callback to remove the event (since we - step backwards through the arrays). */ -static void -e_day_view_foreach_event_with_uid (EDayView *day_view, - const gchar *uid, - EDayViewForeachEventCallback callback, - gpointer data) -{ - EDayViewEvent *event; - gint day, event_num; - const char *u; - - for (day = 0; day < day_view->days_shown; day++) { - for (event_num = day_view->events[day]->len - 1; - event_num >= 0; - event_num--) { - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - cal_component_get_uid (event->comp, &u); - if (uid && !strcmp (uid, u)) { - if (!(*callback) (day_view, day, event_num, - data)) - return; - } - } - } - - for (event_num = day_view->long_events->len - 1; - event_num >= 0; - event_num--) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - if (!(*callback) (day_view, E_DAY_VIEW_LONG_EVENT, - event_num, data)) - return; - } - } -} - - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void -e_day_view_remove_event (EDayView *day_view, - const gchar *uid) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - -#if 1 - g_print ("In e_day_view_remove_event day_view:%p uid:%s\n", - day_view, uid); -#endif - - e_day_view_foreach_event_with_uid (day_view, uid, - e_day_view_remove_event_cb, NULL); - - e_day_view_check_layout (day_view); - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static gboolean -e_day_view_remove_event_cb (EDayView *day_view, - gint day, - gint event_num, - gpointer data) -{ - EDayViewEvent *event; - -#if 1 - g_print ("In e_day_view_remove_event_cb day:%i event_num:%i\n", - day, event_num); -#endif - - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - /* If we were editing this event, set editing_event_num to -1 so - on_editing_stopped doesn't try to update the event. */ - if (day_view->editing_event_day == day - && day_view->editing_event_num == event_num) - day_view->editing_event_day = -1; - - if (event->canvas_item) - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - gtk_object_unref (GTK_OBJECT (event->comp)); - - if (day == E_DAY_VIEW_LONG_EVENT) { - g_array_remove_index (day_view->long_events, event_num); - day_view->long_events_need_layout = TRUE; - } else { - g_array_remove_index (day_view->events[day], event_num); - day_view->need_layout[day] = TRUE; - } - return TRUE; -} - - -/* This updates the text shown for an event. If the event start or end do not - lie on a row boundary, the time is displayed before the summary. */ -static void -e_day_view_update_event_label (EDayView *day_view, - gint day, - gint event_num) -{ - EDayViewEvent *event; - gchar *text; - gboolean free_text = FALSE, editing_event = FALSE; - gint offset, start_minute, end_minute; - CalComponentText summary; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* If the event isn't visible just return. */ - if (!event->canvas_item) - return; - - cal_component_get_summary (event->comp, &summary); - text = summary.value ? summary.value : ""; - - if (day_view->editing_event_day == day - && day_view->editing_event_num == event_num) - editing_event = TRUE; - - if (!editing_event - && (event->start_minute % day_view->mins_per_row != 0 - || event->end_minute % day_view->mins_per_row != 0)) { - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - start_minute = offset + event->start_minute; - end_minute = offset + event->end_minute; - text = g_strdup_printf ("%02i:%02i-%02i:%02i %s", - start_minute / 60, - start_minute % 60, - end_minute / 60, - end_minute % 60, - text); - free_text = TRUE; - } - - gnome_canvas_item_set (event->canvas_item, - "text", text, - NULL); - - if (free_text) - g_free (text); -} - - -static void -e_day_view_update_long_event_label (EDayView *day_view, - gint event_num) -{ - EDayViewEvent *event; - CalComponentText summary; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - /* If the event isn't visible just return. */ - if (!event->canvas_item) - return; - - cal_component_get_summary (event->comp, &summary); - gnome_canvas_item_set (event->canvas_item, - "text", summary.value ? summary.value : "", - NULL); -} - - -/* Finds the day and index of the event with the given canvas item. - If is is a long event, -1 is returned as the day. - Returns TRUE if the event was found. */ -static gboolean -e_day_view_find_event_from_item (EDayView *day_view, - GnomeCanvasItem *item, - gint *day_return, - gint *event_num_return) -{ - EDayViewEvent *event; - gint day, event_num; - - for (day = 0; day < day_view->days_shown; day++) { - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - if (event->canvas_item == item) { - *day_return = day; - *event_num_return = event_num; - return TRUE; - } - } - } - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - if (event->canvas_item == item) { - *day_return = E_DAY_VIEW_LONG_EVENT; - *event_num_return = event_num; - return TRUE; - } - } - - return FALSE; -} - - -/* Finds the day and index of the event with the given uid. - If is is a long event, E_DAY_VIEW_LONG_EVENT is returned as the day. - Returns TRUE if an event with the uid was found. - Note that for recurring events there may be several EDayViewEvents, one - for each instance, all with the same iCalObject and uid. So only use this - function if you know the event doesn't recur or you are just checking to - see if any events with the uid exist. */ -static gboolean -e_day_view_find_event_from_uid (EDayView *day_view, - const gchar *uid, - gint *day_return, - gint *event_num_return) -{ - EDayViewEvent *event; - gint day, event_num; - const char *u; - - for (day = 0; day < day_view->days_shown; day++) { - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - *day_return = day; - *event_num_return = event_num; - return TRUE; - } - } - } - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - *day_return = E_DAY_VIEW_LONG_EVENT; - *event_num_return = event_num; - return TRUE; - } - } - - return FALSE; -} - - -/* This sets the selected time range. The EDayView will show the day or week - corresponding to the start time. If the start_time & end_time are not equal - and are both visible in the view, then the selection is set to those times, - otherwise it is set to 1 hour from the start of the working day. */ -void -e_day_view_set_selected_time_range (EDayView *day_view, - time_t start_time, - time_t end_time) -{ - GDate date; - time_t lower; - gint start_row, start_col, end_row, end_col; - gboolean need_redraw = FALSE, start_in_grid, end_in_grid; - - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - /* Calculate the first day that should be shown, based on start_time - and the days_shown setting. If we are showing 1 day it is just the - start of the day given by start_time, otherwise it is the previous - Monday. */ - if (day_view->days_shown == 1) - lower = time_day_begin (start_time); - else { - g_date_clear (&date, 1); - g_date_set_time (&date, start_time); - g_date_subtract_days (&date, g_date_weekday (&date) - 1); - lower = time_from_day (g_date_year (&date), - g_date_month (&date) - 1, - g_date_day (&date)); - } - - /* See if we need to change the days shown. */ - if (lower != day_view->lower) { - e_day_view_recalc_day_starts (day_view, lower); - e_day_view_reload_events (day_view); - need_redraw = TRUE; - } - - /* Set the selection. */ - start_in_grid = e_day_view_convert_time_to_grid_position (day_view, - start_time, - &start_col, - &start_row); - end_in_grid = e_day_view_convert_time_to_grid_position (day_view, - end_time - 60, - &end_col, - &end_row); - - /* If either of the times isn't in the grid, or the selection covers - an entire day, we set the selection to 1 row from the start of the - working day, in the day corresponding to the start time. */ - if (!start_in_grid || !end_in_grid - || (start_row == 0 && end_row == day_view->rows - 1)) { - end_col = start_col; - - start_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); - start_row = CLAMP (start_row, 0, day_view->rows - 1); - end_row = start_row; - } - - if (start_row != day_view->selection_start_row - || start_col != day_view->selection_start_day) { - need_redraw = TRUE; - day_view->selection_in_top_canvas = FALSE; - day_view->selection_start_row = start_row; - day_view->selection_start_day = start_col; - } - - if (end_row != day_view->selection_end_row - || end_col != day_view->selection_end_day) { - need_redraw = TRUE; - day_view->selection_in_top_canvas = FALSE; - day_view->selection_end_row = end_row; - day_view->selection_end_day = end_col; - } - - if (need_redraw) { - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -/* Returns the selected time range. */ -void -e_day_view_get_selected_time_range (EDayView *day_view, - time_t *start_time, - time_t *end_time) -{ - gint start_col, start_row, end_col, end_row; - time_t start, end; - - start_col = day_view->selection_start_day; - start_row = day_view->selection_start_row; - end_col = day_view->selection_end_day; - end_row = day_view->selection_end_row; - - if (start_col == -1) { - start_col = 0; - start_row = 0; - end_col = 0; - end_row = 0; - } - - /* Check if the selection is only in the top canvas, in which case - we can simply use the day_starts array. */ - if (day_view->selection_in_top_canvas) { - start = day_view->day_starts[start_col]; - end = day_view->day_starts[end_col + 1]; - } else { - /* Convert the start col + row into a time. */ - start = e_day_view_convert_grid_position_to_time (day_view, start_col, start_row); - end = e_day_view_convert_grid_position_to_time (day_view, end_col, end_row + 1); - } - - if (start_time) - *start_time = start; - - if (end_time) - *end_time = end; -} - - -static void -e_day_view_recalc_day_starts (EDayView *day_view, - time_t start_time) -{ - gint day; - - day_view->day_starts[0] = start_time; - for (day = 1; day <= day_view->days_shown; day++) { - day_view->day_starts[day] = time_add_day (day_view->day_starts[day - 1], 1); - } - - day_view->lower = start_time; - day_view->upper = day_view->day_starts[day_view->days_shown]; -} - - -gint -e_day_view_get_days_shown (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->days_shown; -} - - -void -e_day_view_set_days_shown (EDayView *day_view, - gint days_shown) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - g_return_if_fail (days_shown >= 1); - g_return_if_fail (days_shown <= E_DAY_VIEW_MAX_DAYS); - - if (day_view->days_shown != days_shown) { - day_view->days_shown = days_shown; - - /* FIXME: Update everything. */ - } -} - - -gint -e_day_view_get_mins_per_row (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->mins_per_row; -} - - -void -e_day_view_set_mins_per_row (EDayView *day_view, - gint mins_per_row) -{ - gint day; - - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - if (mins_per_row != 5 && mins_per_row != 10 && mins_per_row != 15 - && mins_per_row != 30 && mins_per_row != 60) { - g_warning ("Invalid minutes per row setting"); - return; - } - - if (day_view->mins_per_row == mins_per_row) - return; - - day_view->mins_per_row = mins_per_row; - e_day_view_recalc_num_rows (day_view); - - /* If we aren't visible, we'll sort it out later. */ - if (!GTK_WIDGET_VISIBLE (day_view)) - return; - - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - day_view->need_layout[day] = TRUE; - - /* We must layout the events before updating the scroll region, since - that will result in a redraw which would crash otherwise. */ - e_day_view_check_layout (day_view); - gtk_widget_queue_draw (day_view->time_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - e_day_view_update_scroll_regions (day_view); -} - - -static gboolean -e_day_view_update_scroll_regions (EDayView *day_view) -{ - gdouble old_x2, old_y2, new_x2, new_y2; - gboolean need_reshape = FALSE; - - /* Set the scroll region of the time canvas to its allocated width, - but with the height the same as the main canvas. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (day_view->time_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = day_view->time_canvas->allocation.width - 1; - new_y2 = MAX (day_view->rows * day_view->row_height, - day_view->main_canvas->allocation.height) - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (day_view->time_canvas), - 0, 0, new_x2, new_y2); - - /* Set the scroll region of the main canvas to its allocated width, - but with the height depending on the number of rows needed. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (day_view->main_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = day_view->main_canvas->allocation.width - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) { - need_reshape = TRUE; - gnome_canvas_set_scroll_region (GNOME_CANVAS (day_view->main_canvas), - 0, 0, new_x2, new_y2); - } - - return need_reshape; -} - - -/* This recalculates the number of rows to display, based on the time range - shown and the minutes per row. */ -static void -e_day_view_recalc_num_rows (EDayView *day_view) -{ - gint hours, minutes, total_minutes; - - hours = day_view->last_hour_shown - day_view->first_hour_shown; - /* This could be negative but it works out OK. */ - minutes = day_view->last_minute_shown - day_view->first_minute_shown; - total_minutes = hours * 60 + minutes; - day_view->rows = total_minutes / day_view->mins_per_row; -} - - -/* Converts an hour and minute to a row in the canvas. Note that if we aren't - showing all 24 hours of the day, the returned row may be negative or - greater than day_view->rows. */ -gint -e_day_view_convert_time_to_row (EDayView *day_view, - gint hour, - gint minute) -{ - gint total_minutes, start_minute, offset; - - total_minutes = hour * 60 + minute; - start_minute = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - offset = total_minutes - start_minute; - if (offset < 0) - return -1; - else - return offset / day_view->mins_per_row; -} - - -/* Converts an hour and minute to a y coordinate in the canvas. */ -gint -e_day_view_convert_time_to_position (EDayView *day_view, - gint hour, - gint minute) -{ - gint total_minutes, start_minute, offset; - - total_minutes = hour * 60 + minute; - start_minute = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - offset = total_minutes - start_minute; - - return offset * day_view->row_height / day_view->mins_per_row; -} - - -static gboolean -e_day_view_on_top_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - gint event_x, event_y, scroll_x, scroll_y, day, event_num; - EDayViewPosition pos; - - /* Convert the coords to the main canvas window, or return if the - window is not found. */ - if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event, - GTK_LAYOUT (widget)->bin_window, - &event_x, &event_y)) - return FALSE; - - /* The top canvas doesn't scroll, but just in case. */ - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - event_x += scroll_x; - event_y += scroll_y; - - pos = e_day_view_convert_position_in_top_canvas (day_view, - event_x, event_y, - &day, &event_num); - - if (pos == E_DAY_VIEW_POS_OUTSIDE) - return FALSE; - - if (pos != E_DAY_VIEW_POS_NONE) - return e_day_view_on_long_event_button_press (day_view, - event_num, - event, pos, - event_x, - event_y); - - e_day_view_stop_editing_event (day_view); - - if (event->button == 1) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, event->time) == 0) { - e_day_view_start_selection (day_view, day, -1); - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - e_day_view_on_event_right_click (day_view, event, -1, -1); - } - - return TRUE; -} - - -static gboolean -e_day_view_convert_event_coords (EDayView *day_view, - GdkEvent *event, - GdkWindow *window, - gint *x_return, - gint *y_return) -{ - gint event_x, event_y, win_x, win_y; - GdkWindow *event_window;; - - /* Get the event window, x & y from the appropriate event struct. */ - switch (event->type) { - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - event_x = event->button.x; - event_y = event->button.y; - event_window = event->button.window; - break; - case GDK_MOTION_NOTIFY: - event_x = event->motion.x; - event_y = event->motion.y; - event_window = event->motion.window; - break; - default: - /* Shouldn't get here. */ - g_assert_not_reached (); - return FALSE; - } - - while (event_window && event_window != window - && event_window != GDK_ROOT_PARENT()) { - gdk_window_get_position (event_window, &win_x, &win_y); - event_x += win_x; - event_y += win_y; - event_window = gdk_window_get_parent (event_window); - } - - *x_return = event_x; - *y_return = event_y; - - if (event_window != window) - g_warning ("Couldn't find event window\n"); - - return (event_window == window) ? TRUE : FALSE; -} - - -static gboolean -e_day_view_on_main_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - gint event_x, event_y, scroll_x, scroll_y, row, day, event_num; - EDayViewPosition pos; - - /* Handle scroll wheel events */ - if (event->button == 4 || event->button == 5) { - GtkAdjustment *adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; - gfloat new_value; - - new_value = adj->value + ((event->button == 4) ? - -adj->page_increment / 2: - adj->page_increment / 2); - new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); - gtk_adjustment_set_value (adj, new_value); - - return TRUE; - } - - /* Convert the coords to the main canvas window, or return if the - window is not found. */ - if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event, - GTK_LAYOUT (widget)->bin_window, - &event_x, &event_y)) - return FALSE; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - event_x += scroll_x; - event_y += scroll_y; - - /* Find out where the mouse is. */ - pos = e_day_view_convert_position_in_main_canvas (day_view, - event_x, event_y, - &day, &row, - &event_num); - - if (pos == E_DAY_VIEW_POS_OUTSIDE) - return FALSE; - - if (pos != E_DAY_VIEW_POS_NONE) - return e_day_view_on_event_button_press (day_view, day, - event_num, event, pos, - event_x, event_y); - - e_day_view_stop_editing_event (day_view); - - /* Start the selection drag. */ - if (event->button == 1) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, event->time) == 0) { - e_day_view_start_selection (day_view, day, row); - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - e_day_view_on_event_right_click (day_view, event, -1, -1); - } - - return TRUE; -} - - -static gboolean -e_day_view_on_time_canvas_button_press (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - /* Handle scroll wheel events */ - if (event->button == 4 || event->button == 5) { - GtkAdjustment *adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; - gfloat new_value; - - new_value = adj->value + ((event->button == 4) ? - -adj->page_increment / 2: - adj->page_increment / 2); - new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); - gtk_adjustment_set_value (adj, new_value); - - return TRUE; - } - - return FALSE; -} - - -static gboolean -e_day_view_on_long_event_button_press (EDayView *day_view, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y) -{ - if (event->button == 1) { - if (event->type == GDK_BUTTON_PRESS) { - e_day_view_on_long_event_click (day_view, event_num, - event, pos, - event_x, event_y); - return TRUE; - } else if (event->type == GDK_2BUTTON_PRESS) { - e_day_view_on_event_double_click (day_view, -1, - event_num); - return TRUE; - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - e_day_view_on_event_right_click (day_view, event, - E_DAY_VIEW_LONG_EVENT, - event_num); - return TRUE; - } - return FALSE; -} - - -static gboolean -e_day_view_on_event_button_press (EDayView *day_view, - gint day, - gint event_num, - GdkEventButton *event, - EDayViewPosition pos, - gint event_x, - gint event_y) -{ - if (event->button == 1) { - if (event->type == GDK_BUTTON_PRESS) { - e_day_view_on_event_click (day_view, day, event_num, - event, pos, - event_x, event_y); - return TRUE; - } else if (event->type == GDK_2BUTTON_PRESS) { - e_day_view_on_event_double_click (day_view, day, - event_num); - return TRUE; - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - e_day_view_on_event_right_click (day_view, event, - day, event_num); - return TRUE; - } - return FALSE; -} - - -static void -e_day_view_on_long_event_click (EDayView *day_view, - gint event_num, - GdkEventButton *bevent, - EDayViewPosition pos, - gint event_x, - gint event_y) -{ - EDayViewEvent *event; - gint start_day, end_day, day; - gint item_x, item_y, item_w, item_h; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - /* Ignore clicks on the EText while editing. */ - if (pos == E_DAY_VIEW_POS_EVENT - && E_TEXT (event->canvas_item)->editing) - return; - - if (!(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp)) - && (pos == E_DAY_VIEW_POS_LEFT_EDGE - || pos == E_DAY_VIEW_POS_RIGHT_EDGE)) { - if (!e_day_view_find_long_event_days (day_view, event, - &start_day, &end_day)) - return; - - /* Grab the keyboard focus, so the event being edited is saved - and we can use the Escape key to abort the resize. */ - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (day_view->top_canvas)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, bevent->time) == 0) { - - day_view->resize_event_day = E_DAY_VIEW_LONG_EVENT; - day_view->resize_event_num = event_num; - day_view->resize_drag_pos = pos; - day_view->resize_start_row = start_day; - day_view->resize_end_row = end_day; - - /* Create the edit rect if necessary. */ - e_day_view_reshape_resize_long_event_rect_item (day_view); - - /* Make sure the text item is on top. */ - gnome_canvas_item_raise_to_top (day_view->resize_long_event_rect_item); - - /* Raise the event's item, above the rect as well. */ - gnome_canvas_item_raise_to_top (event->canvas_item); - } - } else if (e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) { - /* Remember the item clicked and the mouse position, - so we can start a drag if the mouse moves. */ - day_view->pressed_event_day = E_DAY_VIEW_LONG_EVENT; - day_view->pressed_event_num = event_num; - - day_view->drag_event_x = event_x; - day_view->drag_event_y = event_y; - - e_day_view_convert_position_in_top_canvas (day_view, - event_x, event_y, - &day, NULL); - day_view->drag_event_offset = day - start_day; - } -} - - -static void -e_day_view_on_event_click (EDayView *day_view, - gint day, - gint event_num, - GdkEventButton *bevent, - EDayViewPosition pos, - gint event_x, - gint event_y) -{ - EDayViewEvent *event; - gint tmp_day, row, start_row; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* Ignore clicks on the EText while editing. */ - if (pos == E_DAY_VIEW_POS_EVENT - && E_TEXT (event->canvas_item)->editing) - return; - - if (!(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp)) - && (pos == E_DAY_VIEW_POS_TOP_EDGE - || pos == E_DAY_VIEW_POS_BOTTOM_EDGE)) { - /* Grab the keyboard focus, so the event being edited is saved - and we can use the Escape key to abort the resize. */ - if (!GTK_WIDGET_HAS_FOCUS (day_view)) - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (day_view->main_canvas)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, bevent->time) == 0) { - - day_view->resize_event_day = day; - day_view->resize_event_num = event_num; - day_view->resize_drag_pos = pos; - day_view->resize_start_row = event->start_minute / day_view->mins_per_row; - day_view->resize_end_row = (event->end_minute - 1) / day_view->mins_per_row; - - day_view->resize_bars_event_day = day; - day_view->resize_bars_event_num = event_num; - - /* Create the edit rect if necessary. */ - e_day_view_reshape_resize_rect_item (day_view); - - e_day_view_reshape_main_canvas_resize_bars (day_view); - - /* Make sure the text item is on top. */ - gnome_canvas_item_raise_to_top (day_view->resize_rect_item); - gnome_canvas_item_raise_to_top (day_view->resize_bar_item); - - /* Raise the event's item, above the rect as well. */ - gnome_canvas_item_raise_to_top (event->canvas_item); - } - - } else { - /* Remember the item clicked and the mouse position, - so we can start a drag if the mouse moves. */ - day_view->pressed_event_day = day; - day_view->pressed_event_num = event_num; - - day_view->drag_event_x = event_x; - day_view->drag_event_y = event_y; - - e_day_view_convert_position_in_main_canvas (day_view, - event_x, event_y, - &tmp_day, &row, - NULL); - start_row = event->start_minute / day_view->mins_per_row; - day_view->drag_event_offset = row - start_row; - } -} - - -static void -e_day_view_reshape_resize_long_event_rect_item (EDayView *day_view) -{ - gint day, event_num, start_day, end_day; - gint item_x, item_y, item_w, item_h; - gdouble x1, y1, x2, y2; - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - - /* If we're not resizing an event, or the event is not shown, - hide the resize bars. */ - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_NONE - || !e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) { - gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - return; - } - - x1 = item_x; - y1 = item_y; - x2 = item_x + item_w - 1; - y2 = item_y + item_h - 1; - - gnome_canvas_item_set (day_view->resize_long_event_rect_item, - "x1", x1, - "y1", y1, - "x2", x2, - "y2", y2, - NULL); - gnome_canvas_item_show (day_view->resize_long_event_rect_item); -} - - -static void -e_day_view_reshape_resize_rect_item (EDayView *day_view) -{ - gint day, event_num; - gint item_x, item_y, item_w, item_h; - gdouble x1, y1, x2, y2; - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - - /* If we're not resizing an event, or the event is not shown, - hide the resize bars. */ - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_NONE - || !e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) { - gnome_canvas_item_hide (day_view->resize_rect_item); - return; - } - - x1 = item_x; - y1 = item_y; - x2 = item_x + item_w - 1; - y2 = item_y + item_h - 1; - - gnome_canvas_item_set (day_view->resize_rect_item, - "x1", x1 + E_DAY_VIEW_BAR_WIDTH - 1, - "y1", y1, - "x2", x2, - "y2", y2, - NULL); - gnome_canvas_item_show (day_view->resize_rect_item); - - gnome_canvas_item_set (day_view->resize_bar_item, - "x1", x1, - "y1", y1, - "x2", x1 + E_DAY_VIEW_BAR_WIDTH - 1, - "y2", y2, - NULL); - gnome_canvas_item_show (day_view->resize_bar_item); -} - - -static void -e_day_view_on_event_double_click (EDayView *day_view, - gint day, - gint event_num) -{ -#if 0 - g_print ("In e_day_view_on_event_double_click\n"); -#endif - -} - - -static void -e_day_view_on_event_right_click (EDayView *day_view, - GdkEventButton *bevent, - gint day, - gint event_num) -{ - EDayViewEvent *event; - int have_selection, not_being_edited, items, i; - struct menu_item *context_menu; - - static struct menu_item main_items[] = { - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item child_items[] = { - { N_("Edit this appointment..."), (GtkSignalFunc) e_day_view_on_edit_appointment, NULL, TRUE }, - { N_("Delete this appointment"), (GtkSignalFunc) e_day_view_on_delete_appointment, NULL, TRUE }, - { NULL, NULL, NULL, TRUE }, - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item recur_child_items[] = { - { N_("Edit this appointment..."), (GtkSignalFunc) e_day_view_on_edit_appointment, NULL, TRUE }, - { N_("Make this appointment movable"), (GtkSignalFunc) e_day_view_on_unrecur_appointment, NULL, TRUE }, - { N_("Delete this occurrence"), (GtkSignalFunc) e_day_view_on_delete_occurrence, NULL, TRUE }, - { N_("Delete all occurrences"), (GtkSignalFunc) e_day_view_on_delete_appointment, NULL, TRUE }, - { NULL, NULL, NULL, TRUE }, - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE } - }; - - have_selection = GTK_WIDGET_HAS_FOCUS (day_view) - && day_view->selection_start_day != -1; - - if (event_num == -1) { - items = 1; - context_menu = &main_items[0]; - context_menu[0].sensitive = have_selection; - } else { - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - /* This used to be set only if the event wasn't being edited - in the event editor, but we can't check that at present. - We could possibly set up another method of checking it. */ - not_being_edited = TRUE; - - if (cal_component_has_rrules (event->comp) - || cal_component_has_rdates (event->comp)) { - items = 6; - context_menu = &recur_child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[2].sensitive = not_being_edited; - context_menu[3].sensitive = not_being_edited; - context_menu[5].sensitive = have_selection; - } else { - items = 4; - context_menu = &child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[3].sensitive = have_selection; - } - } - - for (i = 0; i < items; i++) - context_menu[i].data = day_view; - - day_view->popup_event_day = day; - day_view->popup_event_num = event_num; - popup_menu (context_menu, items, bevent); -} - - -static void -e_day_view_on_new_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - CalComponent *comp; - CalComponentDateTime date; - time_t dtstart, dtend; - - day_view = E_DAY_VIEW (data); - - comp = cal_component_new (); - e_day_view_get_selected_time_range (day_view, &dtstart, &dtend); - - date.value = g_new (struct icaltimetype, 1); - *date.value = icaltimetype_from_timet (dtstart, FALSE); - cal_component_set_dtstart (comp, &date); - *date.value = icaltimetype_from_timet (dtend, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - - gnome_calendar_edit_object (day_view->calendar, comp); - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_day_view_on_edit_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - gnome_calendar_edit_object (day_view->calendar, event->comp); -} - - -static void -e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - CalComponent *comp; - CalComponentDateTime *date=NULL; - GSList *list; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - /* We must duplicate the CalComponent, or we won't know it has changed - when we get the "update_event" callback. */ - comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - list = g_slist_append (list, date); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltimetype_from_timet (event->start, TRUE); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_on_delete_occurrence(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_day_view_on_delete_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - const char *uid; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - if (day_view->editing_event_day >= 0) - e_day_view_stop_editing_event (day_view); - - cal_component_get_uid (event->comp, &uid); - if (!cal_client_remove_object (day_view->calendar->client, uid)) - g_message ("e_day_view_on_delete_appointment(): Could not remove the object!"); -} - - -static void -e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - CalComponent *comp, *new_comp; - CalComponentDateTime *date; - GSList *list; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - /* For the recurring object, we add a exception to get rid of the - instance. */ - comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltimetype_from_timet (event->start, TRUE); - list = g_slist_append (list, date); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); - - /* For the unrecurred instance we duplicate the original object, - create a new uid for it, get rid of the recurrence rules, and set - the start & end times to the instances times. */ - new_comp = cal_component_clone (event->comp); - cal_component_set_uid (new_comp, cal_component_gen_uid ()); - cal_component_set_exdate_list (new_comp, NULL); - cal_component_set_exrule_list (new_comp, NULL); - - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - - *date->value = icaltimetype_from_timet (event->start, FALSE); - cal_component_set_dtstart (new_comp, date); - *date->value = icaltimetype_from_timet (event->end, FALSE); - cal_component_set_dtend (new_comp, date); - - cal_component_free_datetime (date); - - /* Now update both CalComponents. Note that we do this last since at - * present the updates happen synchronously so our event may disappear. - */ - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - if (!cal_client_update_object (day_view->calendar->client, new_comp)) - g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (new_comp)); -} - - -static EDayViewEvent* -e_day_view_get_popup_menu_event (EDayView *day_view) -{ - if (day_view->popup_event_num == -1) - return NULL; - - if (day_view->popup_event_day == E_DAY_VIEW_LONG_EVENT) - return &g_array_index (day_view->long_events, - EDayViewEvent, - day_view->popup_event_num); - else - return &g_array_index (day_view->events[day_view->popup_event_day], - EDayViewEvent, - day_view->popup_event_num); -} - - -static gboolean -e_day_view_on_top_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - if (day_view->selection_is_being_dragged) { - gdk_pointer_ungrab (event->time); - e_day_view_finish_selection (day_view); - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - e_day_view_finish_long_event_resize (day_view); - gdk_pointer_ungrab (event->time); - } else if (day_view->pressed_event_day != -1) { - e_day_view_start_editing_event (day_view, - day_view->pressed_event_day, - day_view->pressed_event_num, - NULL); - } - - day_view->pressed_event_day = -1; - - return FALSE; -} - - -static gboolean -e_day_view_on_main_canvas_button_release (GtkWidget *widget, - GdkEventButton *event, - EDayView *day_view) -{ - if (day_view->selection_is_being_dragged) { - gdk_pointer_ungrab (event->time); - e_day_view_finish_selection (day_view); - e_day_view_stop_auto_scroll (day_view); - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - e_day_view_finish_resize (day_view); - gdk_pointer_ungrab (event->time); - e_day_view_stop_auto_scroll (day_view); - } else if (day_view->pressed_event_day != -1) { - e_day_view_start_editing_event (day_view, - day_view->pressed_event_day, - day_view->pressed_event_num, - NULL); - } - - day_view->pressed_event_day = -1; - - return FALSE; -} - - -static void -e_day_view_update_calendar_selection_time (EDayView *day_view) -{ - time_t start, end; - - e_day_view_get_selected_time_range (day_view, &start, &end); - gnome_calendar_set_selected_time_range (day_view->calendar, - start, end); -} - - -static gboolean -e_day_view_on_top_canvas_motion (GtkWidget *widget, - GdkEventMotion *mevent, - EDayView *day_view) -{ - EDayViewEvent *event = NULL; - EDayViewPosition pos; - gint event_x, event_y, scroll_x, scroll_y, canvas_x, canvas_y; - gint day, event_num; - GdkCursor *cursor; - -#if 0 - g_print ("In e_day_view_on_top_canvas_motion\n"); -#endif - - /* Convert the coords to the main canvas window, or return if the - window is not found. */ - if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) mevent, - GTK_LAYOUT (widget)->bin_window, - &event_x, &event_y)) - return FALSE; - - /* The top canvas doesn't scroll, but just in case. */ - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - canvas_x = event_x + scroll_x; - canvas_y = event_y + scroll_y; - - pos = e_day_view_convert_position_in_top_canvas (day_view, - canvas_x, canvas_y, - &day, &event_num); - if (event_num != -1) - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (day_view->selection_is_being_dragged) { - e_day_view_update_selection (day_view, day, -1); - return TRUE; - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - e_day_view_update_long_event_resize (day_view, day); - return TRUE; - } - } else if (day_view->pressed_event_day == E_DAY_VIEW_LONG_EVENT) { - GtkTargetList *target_list; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->pressed_event_num); - - if (!(cal_component_has_rdates (event->comp) - && cal_component_has_rrules (event->comp)) - && (abs (canvas_x - day_view->drag_event_x) > E_DAY_VIEW_DRAG_START_OFFSET - || abs (canvas_y - day_view->drag_event_y) > E_DAY_VIEW_DRAG_START_OFFSET)) { - day_view->drag_event_day = day_view->pressed_event_day; - day_view->drag_event_num = day_view->pressed_event_num; - day_view->pressed_event_day = -1; - - /* Hide the horizontal bars. */ - if (day_view->resize_bars_event_day != -1) { - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - } - - target_list = gtk_target_list_new (target_table, - n_targets); - gtk_drag_begin (widget, target_list, - GDK_ACTION_COPY | GDK_ACTION_MOVE, - 1, (GdkEvent*)mevent); - gtk_target_list_unref (target_list); - } - } else { - cursor = day_view->normal_cursor; - - /* Recurring events can't be resized. */ - if (event && - !(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp))) { - switch (pos) { - case E_DAY_VIEW_POS_LEFT_EDGE: - case E_DAY_VIEW_POS_RIGHT_EDGE: - cursor = day_view->resize_width_cursor; - break; - default: - break; - } - } - - /* Only set the cursor if it is different to last one set. */ - if (day_view->last_cursor_set_in_top_canvas != cursor) { - day_view->last_cursor_set_in_top_canvas = cursor; - gdk_window_set_cursor (widget->window, cursor); - } - - } - - return FALSE; -} - - -static gboolean -e_day_view_on_main_canvas_motion (GtkWidget *widget, - GdkEventMotion *mevent, - EDayView *day_view) -{ - EDayViewEvent *event = NULL; - EDayViewPosition pos; - gint event_x, event_y, scroll_x, scroll_y, canvas_x, canvas_y; - gint row, day, event_num; - GdkCursor *cursor; - -#if 0 - g_print ("In e_day_view_on_main_canvas_motion\n"); -#endif - - /* Convert the coords to the main canvas window, or return if the - window is not found. */ - if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) mevent, - GTK_LAYOUT (widget)->bin_window, - &event_x, &event_y)) - return FALSE; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - canvas_x = event_x + scroll_x; - canvas_y = event_y + scroll_y; - - pos = e_day_view_convert_position_in_main_canvas (day_view, - canvas_x, canvas_y, - &day, &row, - &event_num); - if (event_num != -1) - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - if (day_view->selection_is_being_dragged) { - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - e_day_view_update_selection (day_view, day, row); - e_day_view_check_auto_scroll (day_view, - event_x, event_y); - return TRUE; - } - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - e_day_view_update_resize (day_view, row); - e_day_view_check_auto_scroll (day_view, - event_x, event_y); - return TRUE; - } - } else if (day_view->pressed_event_day != -1 - && day_view->pressed_event_day != E_DAY_VIEW_LONG_EVENT) { - GtkTargetList *target_list; - - event = &g_array_index (day_view->events[day_view->pressed_event_day], EDayViewEvent, day_view->pressed_event_num); - - if (!(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp)) - && (abs (canvas_x - day_view->drag_event_x) > E_DAY_VIEW_DRAG_START_OFFSET - || abs (canvas_y - day_view->drag_event_y) > E_DAY_VIEW_DRAG_START_OFFSET)) { - day_view->drag_event_day = day_view->pressed_event_day; - day_view->drag_event_num = day_view->pressed_event_num; - day_view->pressed_event_day = -1; - - /* Hide the horizontal bars. */ - if (day_view->resize_bars_event_day != -1) { - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - } - - target_list = gtk_target_list_new (target_table, - n_targets); - gtk_drag_begin (widget, target_list, - GDK_ACTION_COPY | GDK_ACTION_MOVE, - 1, (GdkEvent*)mevent); - gtk_target_list_unref (target_list); - } - } else { - cursor = day_view->normal_cursor; - - /* Recurring events can't be resized. */ - if (event && - !(cal_component_has_rrules (event->comp) - && cal_component_has_rdates (event->comp))) { - switch (pos) { - case E_DAY_VIEW_POS_LEFT_EDGE: - cursor = day_view->move_cursor; - break; - case E_DAY_VIEW_POS_TOP_EDGE: - case E_DAY_VIEW_POS_BOTTOM_EDGE: - cursor = day_view->resize_height_cursor; - break; - default: - break; - } - } - - /* Only set the cursor if it is different to last one set. */ - if (day_view->last_cursor_set_in_main_canvas != cursor) { - day_view->last_cursor_set_in_main_canvas = cursor; - gdk_window_set_cursor (widget->window, cursor); - } - } - - return FALSE; -} - - -/* This sets the selection to a single cell. If day is -1 then the current - start day is reused. If row is -1 then the selection is in the top canvas. -*/ -void -e_day_view_start_selection (EDayView *day_view, - gint day, - gint row) -{ - if (day == -1) { - day = day_view->selection_start_day; - if (day == -1) - day = 0; - } - - day_view->selection_start_day = day; - day_view->selection_end_day = day; - - day_view->selection_start_row = row; - day_view->selection_end_row = row; - - day_view->selection_is_being_dragged = TRUE; - day_view->selection_drag_pos = E_DAY_VIEW_DRAG_END; - day_view->selection_in_top_canvas = (row == -1) ? TRUE : FALSE; - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -/* Updates the selection during a drag. If day is -1 the selection day is - unchanged. */ -void -e_day_view_update_selection (EDayView *day_view, - gint day, - gint row) -{ - gboolean need_redraw = FALSE; - -#if 0 - g_print ("Updating selection %i,%i\n", day, row); -#endif - - day_view->selection_in_top_canvas = (row == -1) ? TRUE : FALSE; - - if (day == -1) - day = (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - ? day_view->selection_start_day - : day_view->selection_end_day; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) { - if (row != day_view->selection_start_row - || day != day_view->selection_start_day) { - need_redraw = TRUE; - day_view->selection_start_row = row; - day_view->selection_start_day = day; - } - } else { - if (row != day_view->selection_end_row - || day != day_view->selection_end_day) { - need_redraw = TRUE; - day_view->selection_end_row = row; - day_view->selection_end_day = day; - } - } - - e_day_view_normalize_selection (day_view); - - /* FIXME: Optimise? */ - if (need_redraw) { - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -static void -e_day_view_normalize_selection (EDayView *day_view) -{ - gint tmp_row, tmp_day; - - /* Switch the drag position if necessary. */ - if (day_view->selection_start_day > day_view->selection_end_day - || (day_view->selection_start_day == day_view->selection_end_day - && day_view->selection_start_row > day_view->selection_end_row)) { - tmp_row = day_view->selection_start_row; - tmp_day = day_view->selection_start_day; - day_view->selection_start_day = day_view->selection_end_day; - day_view->selection_start_row = day_view->selection_end_row; - day_view->selection_end_day = tmp_day; - day_view->selection_end_row = tmp_row; - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - day_view->selection_drag_pos = E_DAY_VIEW_DRAG_END; - else - day_view->selection_drag_pos = E_DAY_VIEW_DRAG_START; - } -} - - -void -e_day_view_finish_selection (EDayView *day_view) -{ - day_view->selection_is_being_dragged = FALSE; - e_day_view_update_calendar_selection_time (day_view); -} - - -static void -e_day_view_update_long_event_resize (EDayView *day_view, - gint day) -{ - EDayViewEvent *event; - gint event_num; - gboolean need_reshape = FALSE; - -#if 0 - g_print ("Updating resize Day:%i\n", day); -#endif - - event_num = day_view->resize_event_num; - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) { - day = MIN (day, day_view->resize_end_row); - if (day != day_view->resize_start_row) { - need_reshape = TRUE; - day_view->resize_start_row = day; - - } - } else { - day = MAX (day, day_view->resize_start_row); - if (day != day_view->resize_end_row) { - need_reshape = TRUE; - day_view->resize_end_row = day; - } - } - - /* FIXME: Optimise? */ - if (need_reshape) { - e_day_view_reshape_long_event (day_view, event_num); - e_day_view_reshape_resize_long_event_rect_item (day_view); - gtk_widget_queue_draw (day_view->top_canvas); - } -} - - -static void -e_day_view_update_resize (EDayView *day_view, - gint row) -{ - EDayViewEvent *event; - gint day, event_num; - gboolean need_reshape = FALSE; - -#if 0 - g_print ("Updating resize Row:%i\n", row); -#endif - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) { - row = MIN (row, day_view->resize_end_row); - if (row != day_view->resize_start_row) { - need_reshape = TRUE; - day_view->resize_start_row = row; - - } - } else { - row = MAX (row, day_view->resize_start_row); - if (row != day_view->resize_end_row) { - need_reshape = TRUE; - day_view->resize_end_row = row; - } - } - - /* FIXME: Optimise? */ - if (need_reshape) { - e_day_view_reshape_day_event (day_view, day, event_num); - e_day_view_reshape_resize_rect_item (day_view); - e_day_view_reshape_main_canvas_resize_bars (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -/* This converts the resize start or end row back to a time and updates the - event. */ -static void -e_day_view_finish_long_event_resize (EDayView *day_view) -{ - EDayViewEvent *event; - gint event_num; - CalComponent *comp; - CalComponentDateTime date; - time_t dt; - - event_num = day_view->resize_event_num; - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - /* We use a temporary shallow copy of the ico since we don't want to - change the original ico here. Otherwise we would not detect that - the event's time had changed in the "update_event" callback. */ - comp = cal_component_clone (event->comp); - - date.value = g_new (struct icaltimetype, 1); - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) { - dt = day_view->day_starts[day_view->resize_start_row]; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtstart (comp, &date); - } else { - dt = day_view->day_starts[day_view->resize_end_row + 1]; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtend (comp, &date); - } - g_free (date.value); - - gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - - day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_finish_long_event_resize(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -/* This converts the resize start or end row back to a time and updates the - event. */ -static void -e_day_view_finish_resize (EDayView *day_view) -{ - EDayViewEvent *event; - gint day, event_num; - CalComponent *comp; - CalComponentDateTime date; - time_t dt; - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* We use a temporary shallow copy of the ico since we don't want to - change the original ico here. Otherwise we would not detect that - the event's time had changed in the "update_event" callback. */ - comp = cal_component_clone (event->comp); - - date.value = g_new (struct icaltimetype, 1); - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) { - dt = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_start_row); - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtstart (comp, &date); - } else { - dt = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_end_row + 1); - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtend (comp, &date); - } - g_free (date.value); - - gnome_canvas_item_hide (day_view->resize_rect_item); - gnome_canvas_item_hide (day_view->resize_bar_item); - - /* Hide the horizontal bars. */ - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - - day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_finish_resize(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_day_view_abort_resize (EDayView *day_view, - guint32 time) -{ - gint day, event_num; - - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_NONE) - return; - - day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - gdk_pointer_ungrab (time); - - day = day_view->resize_event_day; - event_num = day_view->resize_event_num; - - if (day == E_DAY_VIEW_LONG_EVENT) { - e_day_view_reshape_long_event (day_view, event_num); - gtk_widget_queue_draw (day_view->top_canvas); - - day_view->last_cursor_set_in_top_canvas = day_view->normal_cursor; - gdk_window_set_cursor (day_view->top_canvas->window, - day_view->normal_cursor); - gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - } else { - e_day_view_reshape_day_event (day_view, day, event_num); - e_day_view_reshape_main_canvas_resize_bars (day_view); - gtk_widget_queue_draw (day_view->main_canvas); - - day_view->last_cursor_set_in_main_canvas = day_view->normal_cursor; - gdk_window_set_cursor (day_view->main_canvas->window, - day_view->normal_cursor); - gnome_canvas_item_hide (day_view->resize_rect_item); - gnome_canvas_item_hide (day_view->resize_bar_item); - } -} - - -static void -e_day_view_reload_events (EDayView *day_view) -{ - e_day_view_free_events (day_view); - - /* Reset all our indices. */ - day_view->editing_event_day = -1; - day_view->popup_event_day = -1; - day_view->resize_bars_event_day = -1; - day_view->resize_event_day = -1; - day_view->pressed_event_day = -1; - day_view->drag_event_day = -1; - - /* If both lower & upper are 0, then the time range hasn't been set, - so we don't try to load any events. */ - if (day_view->calendar - && (day_view->lower != 0 || day_view->upper != 0)) { - cal_client_generate_instances (day_view->calendar->client, - CALOBJ_TYPE_EVENT, - day_view->lower, - day_view->upper, - e_day_view_add_event, - day_view); - } - - /* We need to do this to make sure the top canvas is resized. */ - day_view->long_events_need_layout = TRUE; - - e_day_view_check_layout (day_view); - e_day_view_reshape_main_canvas_resize_bars (day_view); - - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_free_events (EDayView *day_view) -{ - gint day; - - e_day_view_free_event_array (day_view, day_view->long_events); - - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - e_day_view_free_event_array (day_view, day_view->events[day]); -} - - -static void -e_day_view_free_event_array (EDayView *day_view, - GArray *array) -{ - EDayViewEvent *event; - gint event_num; - - for (event_num = 0; event_num < array->len; event_num++) { - event = &g_array_index (array, EDayViewEvent, event_num); - if (event->canvas_item) - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - gtk_object_unref (GTK_OBJECT (event->comp)); - } - - g_array_set_size (array, 0); -} - - -/* This adds one event to the view, adding it to the appropriate array. */ -static gboolean -e_day_view_add_event (CalComponent *comp, - time_t start, - time_t end, - gpointer data) - -{ - EDayView *day_view; - EDayViewEvent event; - gint day, offset; - struct tm start_tm, end_tm; - - day_view = E_DAY_VIEW (data); - - /* Check that the event times are valid. */ - g_return_val_if_fail (start <= end, TRUE); - g_return_val_if_fail (start < day_view->upper, TRUE); - g_return_val_if_fail (end > day_view->lower, TRUE); - - start_tm = *(localtime (&start)); - end_tm = *(localtime (&end)); - - event.comp = comp; - gtk_object_ref (GTK_OBJECT (comp)); - event.start = start; - event.end = end; - event.canvas_item = NULL; - - /* Calculate the start & end minute, relative to the top of the - display. */ - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - event.start_minute = start_tm.tm_hour * 60 + start_tm.tm_min - offset; - event.end_minute = end_tm.tm_hour * 60 + end_tm.tm_min - offset; - - event.start_row_or_col = -1; - event.num_columns = -1; - - /* Find out which array to add the event to. */ - for (day = 0; day < day_view->days_shown; day++) { - if (start >= day_view->day_starts[day] - && end <= day_view->day_starts[day + 1]) { - - /* Special case for when the appointment ends at - midnight, i.e. the start of the next day. */ - if (end == day_view->day_starts[day + 1]) { - - /* If the event last the entire day, then we - skip it here so it gets added to the top - canvas. */ - if (start == day_view->day_starts[day]) - break; - - event.end_minute = 24 * 60; - } - - g_array_append_val (day_view->events[day], event); - day_view->events_sorted[day] = FALSE; - day_view->need_layout[day] = TRUE; - return TRUE; - } - } - - /* The event wasn't within one day so it must be a long event, - i.e. shown in the top canvas. */ - g_array_append_val (day_view->long_events, event); - day_view->long_events_sorted = FALSE; - day_view->long_events_need_layout = TRUE; - return TRUE; -} - - -/* This lays out the short (less than 1 day) events in the columns. - Any long events are simply skipped. */ -void -e_day_view_check_layout (EDayView *day_view) -{ - gint day; - - /* Don't bother if we aren't visible. */ - if (!GTK_WIDGET_VISIBLE (day_view)) - return; - - /* Make sure the events are sorted (by start and size). */ - e_day_view_ensure_events_sorted (day_view); - - for (day = 0; day < day_view->days_shown; day++) { - if (day_view->need_layout[day]) - e_day_view_layout_day_events (day_view, day); - - if (day_view->need_layout[day] - || day_view->need_reshape[day]) { - e_day_view_reshape_day_events (day_view, day); - - if (day_view->resize_bars_event_day == day) - e_day_view_reshape_main_canvas_resize_bars (day_view); - } - - day_view->need_layout[day] = FALSE; - day_view->need_reshape[day] = FALSE; - } - - if (day_view->long_events_need_layout) - e_day_view_layout_long_events (day_view); - - if (day_view->long_events_need_layout - || day_view->long_events_need_reshape) - e_day_view_reshape_long_events (day_view); - - day_view->long_events_need_layout = FALSE; - day_view->long_events_need_reshape = FALSE; -} - - -static void -e_day_view_layout_long_events (EDayView *day_view) -{ - EDayViewEvent *event; - gint event_num, old_rows_in_top_display, top_canvas_height, top_rows; - guint8 *grid; - - /* This is a temporary 2-d grid which is used to place events. - Each element is 0 if the position is empty, or 1 if occupied. - We allocate the maximum size possible here, assuming that each - event will need its own row. */ - grid = g_new0 (guint8, - day_view->long_events->len * E_DAY_VIEW_MAX_DAYS); - - /* Reset the number of rows in the top display to 0. It will be - updated as events are layed out below. */ - old_rows_in_top_display = day_view->rows_in_top_display; - day_view->rows_in_top_display = 0; - - /* Iterate over the events, finding which days they cover, and putting - them in the first free row available. */ - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - e_day_view_layout_long_event (day_view, event, grid); - } - - /* Free the grid. */ - g_free (grid); - - /* Set the height of the top canvas based on the row height and the - number of rows needed (min 1 + 1 for the dates + 1 space for DnD).*/ - if (day_view->rows_in_top_display != old_rows_in_top_display) { - top_rows = MAX (1, day_view->rows_in_top_display); - top_canvas_height = (top_rows + 2) * day_view->top_row_height; - gtk_widget_set_usize (day_view->top_canvas, -1, - top_canvas_height); - } -} - - -static void -e_day_view_layout_long_event (EDayView *day_view, - EDayViewEvent *event, - guint8 *grid) -{ - gint start_day, end_day, free_row, day, row; - - event->num_columns = 0; - - if (!e_day_view_find_long_event_days (day_view, event, - &start_day, &end_day)) - return; - - /* Try each row until we find a free one. */ - row = 0; - do { - free_row = row; - for (day = start_day; day <= end_day; day++) { - if (grid[row * E_DAY_VIEW_MAX_DAYS + day]) { - free_row = -1; - break; - } - } - row++; - } while (free_row == -1); - - event->start_row_or_col = free_row; - event->num_columns = 1; - - /* Mark the cells as full. */ - for (day = start_day; day <= end_day; day++) { - grid[free_row * E_DAY_VIEW_MAX_DAYS + day] = 1; - } - - /* Update the number of rows in the top canvas if necessary. */ - day_view->rows_in_top_display = MAX (day_view->rows_in_top_display, - free_row + 1); -} - - -static void -e_day_view_reshape_long_events (EDayView *day_view) -{ - EDayViewEvent *event; - gint event_num; - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (event->num_columns == 0) { - if (event->canvas_item) { - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - event->canvas_item = NULL; - } - } else { - e_day_view_reshape_long_event (day_view, event_num); - } - } -} - - -static void -e_day_view_reshape_long_event (EDayView *day_view, - gint event_num) -{ - EDayViewEvent *event; - GdkFont *font; - gint start_day, end_day, item_x, item_y, item_w, item_h; - gint text_x, text_w, num_icons, icons_width, width, time_width; - CalComponent *comp; - gint min_text_x, max_text_w, text_width, line_len; - gchar *text, *end_of_line; - gboolean show_icons = TRUE, use_max_width = FALSE; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (!e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) { - if (event->canvas_item) { - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - event->canvas_item = NULL; - } - return; - } - - /* Take off the border and padding. */ - item_x += E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD; - item_w -= (E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD) * 2; - item_y += E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD; - item_h -= (E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD) * 2; - - /* We don't show the icons while resizing, since we'd have to - draw them on top of the resize rect. Nor when editing. */ - num_icons = 0; - comp = event->comp; - font = GTK_WIDGET (day_view)->style->font; - - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->resize_event_num == event_num) - show_icons = FALSE; - - if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->editing_event_num == event_num) { - show_icons = FALSE; - use_max_width = TRUE; - } - -#if 0 - if (show_icons) { - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) - num_icons++; - if (ico->recur) - num_icons++; - } -#endif - - if (!event->canvas_item) { - event->canvas_item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->top_canvas)->root), - e_text_get_type (), - "font_gdk", GTK_WIDGET (day_view)->style->font, - "anchor", GTK_ANCHOR_NW, - "clip", TRUE, - "max_lines", 1, - "editable", TRUE, - "use_ellipsis", TRUE, - NULL); - gtk_signal_connect (GTK_OBJECT (event->canvas_item), "event", - GTK_SIGNAL_FUNC (e_day_view_on_text_item_event), - day_view); - e_day_view_update_long_event_label (day_view, event_num); - } - - /* Calculate its position. We first calculate the ideal position which - is centered with the icons. We then make sure we haven't gone off - the left edge of the available space. Finally we make sure we don't - go off the right edge. */ - icons_width = (E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD) - * num_icons; - time_width = day_view->max_small_hour_width + day_view->colon_width - + day_view->max_minute_width; - - if (use_max_width) { - text_x = item_x; - text_w = item_w; - } else { - /* Get the requested size of the label. */ - gtk_object_get (GTK_OBJECT (event->canvas_item), - "text", &text, - NULL); - text_width = 0; - if (text) { - end_of_line = strchr (text, '\n'); - if (end_of_line) - line_len = end_of_line - text; - else - line_len = strlen (text); - text_width = gdk_text_width (font, text, line_len); - g_free (text); - } - - width = text_width + icons_width; - text_x = item_x + (item_w - width) / 2; - - min_text_x = item_x; - if (event->start > day_view->day_starts[start_day]) - min_text_x += time_width + E_DAY_VIEW_LONG_EVENT_TIME_X_PAD; - - text_x = MAX (text_x, min_text_x); - - max_text_w = item_x + item_w - text_x; - if (event->end < day_view->day_starts[end_day + 1]) - max_text_w -= time_width + E_DAY_VIEW_LONG_EVENT_TIME_X_PAD; - - text_w = MIN (width, max_text_w); - - /* Now take out the space for the icons. */ - text_x += icons_width; - text_w -= icons_width; - } - - text_w = MAX (text_w, 0); - gnome_canvas_item_set (event->canvas_item, - "clip_width", (gdouble) text_w, - "clip_height", (gdouble) item_h, - NULL); - e_canvas_item_move_absolute(event->canvas_item, - text_x, item_y); -} - - -/* Find the start and end days for the event. */ -gboolean -e_day_view_find_long_event_days (EDayView *day_view, - EDayViewEvent *event, - gint *start_day_return, - gint *end_day_return) -{ - gint day, start_day, end_day; - - start_day = -1; - end_day = -1; - - for (day = 0; day < day_view->days_shown; day++) { - if (start_day == -1 - && event->start < day_view->day_starts[day + 1]) - start_day = day; - if (event->end > day_view->day_starts[day]) - end_day = day; - } - - /* Sanity check. */ - if (start_day < 0 || start_day >= day_view->days_shown - || end_day < 0 || end_day >= day_view->days_shown - || end_day < start_day) { - g_warning ("Invalid date range for event"); - return FALSE; - } - - *start_day_return = start_day; - *end_day_return = end_day; - - return TRUE; -} - - -static void -e_day_view_layout_day_events (EDayView *day_view, - gint day) -{ - EDayViewEvent *event; - gint row, event_num; - guint8 *grid; - - /* This is a temporary array which keeps track of rows which are - connected. When an appointment spans multiple rows then the number - of columns in each of these rows must be the same (i.e. the maximum - of all of them). Each element in the array corresponds to one row - and contains the index of the first row in the group of connected - rows. */ - guint16 group_starts[12 * 24]; - - /* Reset the cols_per_row array, and initialize the connected rows. */ - for (row = 0; row < day_view->rows; row++) { - day_view->cols_per_row[day][row] = 0; - group_starts[row] = row; - } - - /* This is a temporary 2-d grid which is used to place events. - Each element is 0 if the position is empty, or 1 if occupied. */ - grid = g_new0 (guint8, day_view->rows * E_DAY_VIEW_MAX_COLUMNS); - - - /* Iterate over the events, finding which rows they cover, and putting - them in the first free column available. Increment the number of - events in each of the rows it covers, and make sure they are all - in one group. */ - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - e_day_view_layout_day_event (day_view, day, event, - grid, group_starts); - } - - /* Recalculate the number of columns needed in each row. */ - e_day_view_recalc_cols_per_row (day_view, day, group_starts); - - /* Iterate over the events again, trying to expand events horizontally - if there is enough space. */ - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - e_day_view_expand_day_event (day_view, day, event, grid); - } - - /* Free the grid. */ - g_free (grid); -} - - -/* Finds the first free position to place the event in. - Increments the number of events in each of the rows it covers, and makes - sure they are all in one group. */ -static void -e_day_view_layout_day_event (EDayView *day_view, - gint day, - EDayViewEvent *event, - guint8 *grid, - guint16 *group_starts) -{ - gint start_row, end_row, free_col, col, row, group_start; - - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - - event->num_columns = 0; - - /* If the event can't currently be seen, just return. */ - if (start_row >= day_view->rows || end_row < 0) - return; - - /* Make sure we don't go outside the visible times. */ - start_row = CLAMP (start_row, 0, day_view->rows - 1); - end_row = CLAMP (end_row, 0, day_view->rows - 1); - - /* Try each column until we find a free one. */ - for (col = 0; col < E_DAY_VIEW_MAX_COLUMNS; col++) { - free_col = col; - for (row = start_row; row <= end_row; row++) { - if (grid[row * E_DAY_VIEW_MAX_COLUMNS + col]) { - free_col = -1; - break; - } - } - - if (free_col != -1) - break; - } - - /* If we can't find space for the event, just return. */ - if (free_col == -1) - return; - - /* The event is assigned 1 col initially, but may be expanded later. */ - event->start_row_or_col = free_col; - event->num_columns = 1; - - /* Determine the start index of the group. */ - group_start = group_starts[start_row]; - - /* Increment number of events in each of the rows the event covers. - We use the cols_per_row array for this. It will be sorted out after - all the events have been layed out. Also make sure all the rows that - the event covers are in one group. */ - for (row = start_row; row <= end_row; row++) { - grid[row * E_DAY_VIEW_MAX_COLUMNS + free_col] = 1; - day_view->cols_per_row[day][row]++; - group_starts[row] = group_start; - } - - /* If any following rows should be in the same group, add them. */ - for (row = end_row + 1; row < day_view->rows; row++) { - if (group_starts[row] > end_row) - break; - group_starts[row] = group_start; - } -} - - -/* For each group of rows, find the max number of events in all the - rows, and set the number of cols in each of the rows to that. */ -static void -e_day_view_recalc_cols_per_row (EDayView *day_view, - gint day, - guint16 *group_starts) -{ - gint start_row = 0, row, next_start_row, max_events; - - while (start_row < day_view->rows) { - - max_events = 0; - for (row = start_row; row < day_view->rows && group_starts[row] == start_row; row++) - max_events = MAX (max_events, day_view->cols_per_row[day][row]); - - next_start_row = row; - - for (row = start_row; row < next_start_row; row++) - day_view->cols_per_row[day][row] = max_events; - - start_row = next_start_row; - } -} - - -/* Expands the event horizontally to fill any free space. */ -static void -e_day_view_expand_day_event (EDayView *day_view, - gint day, - EDayViewEvent *event, - guint8 *grid) -{ - gint start_row, end_row, col, row; - gboolean clashed; - - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - - /* Try each column until we find a free one. */ - clashed = FALSE; - for (col = event->start_row_or_col + 1; col < day_view->cols_per_row[day][start_row]; col++) { - for (row = start_row; row <= end_row; row++) { - if (grid[row * E_DAY_VIEW_MAX_COLUMNS + col]) { - clashed = TRUE; - break; - } - } - - if (clashed) - break; - - event->num_columns++; - } -} - - -/* This creates or updates the sizes of the canvas items for one day of the - main canvas. */ -static void -e_day_view_reshape_day_events (EDayView *day_view, - gint day) -{ - gint event_num; - - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - e_day_view_reshape_day_event (day_view, day, event_num); - } -} - - -static void -e_day_view_reshape_day_event (EDayView *day_view, - gint day, - gint event_num) -{ - EDayViewEvent *event; - gint item_x, item_y, item_w, item_h; - gint num_icons, icons_offset; - CalComponent *comp; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - comp = event->comp; - - if (!e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) { - if (event->canvas_item) { - gtk_object_destroy (GTK_OBJECT (event->canvas_item)); - event->canvas_item = NULL; - } - } else { - /* Skip the border and padding. */ - item_x += E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_EVENT_X_PAD; - item_w -= E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_EVENT_X_PAD * 2; - item_y += E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD; - item_h -= (E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD) * 2; - - /* We don't show the icons while resizing, since we'd have to - draw them on top of the resize rect. */ - num_icons = 0; - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_NONE - || day_view->resize_event_day != day - || day_view->resize_event_num != event_num) { -#if 0 - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) - num_icons++; -#endif - if (cal_component_has_rrules (comp) - || cal_component_has_rdates (comp)) - num_icons++; - } - - if (num_icons > 0) { - if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD) * num_icons) - icons_offset = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD * 2; - else - icons_offset = (E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW_ICON_X_PAD) * num_icons + E_DAY_VIEW_ICON_X_PAD; - item_x += icons_offset; - item_w -= icons_offset; - } - - if (!event->canvas_item) { - event->canvas_item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->main_canvas)->root), - e_text_get_type (), - "font_gdk", GTK_WIDGET (day_view)->style->font, - "anchor", GTK_ANCHOR_NW, - "line_wrap", TRUE, - "editable", TRUE, - "clip", TRUE, - "use_ellipsis", TRUE, - NULL); - gtk_signal_connect (GTK_OBJECT (event->canvas_item), - "event", - GTK_SIGNAL_FUNC (e_day_view_on_text_item_event), - day_view); - e_day_view_update_event_label (day_view, day, - event_num); - } - - item_w = MAX (item_w, 0); - gnome_canvas_item_set (event->canvas_item, - "clip_width", (gdouble) item_w, - "clip_height", (gdouble) item_h, - NULL); - e_canvas_item_move_absolute(event->canvas_item, - item_x, item_y); - } -} - - -/* This creates or resizes the horizontal bars used to resize events in the - main canvas. */ -static void -e_day_view_reshape_main_canvas_resize_bars (EDayView *day_view) -{ - gint day, event_num; - gint item_x, item_y, item_w, item_h; - gdouble x, y, w, h; - - day = day_view->resize_bars_event_day; - event_num = day_view->resize_bars_event_num; - - /* If we're not editing an event, or the event is not shown, - hide the resize bars. */ - if (day != -1 && day == day_view->drag_event_day - && event_num == day_view->drag_event_num) { - gtk_object_get (GTK_OBJECT (day_view->drag_rect_item), - "x1", &x, - "y1", &y, - "x2", &w, - "y2", &h, - NULL); - w -= x; - x++; - h -= y; - } else if (day != -1 - && e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) { - x = item_x + E_DAY_VIEW_BAR_WIDTH; - y = item_y; - w = item_w - E_DAY_VIEW_BAR_WIDTH; - h = item_h; - } else { - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - return; - } - - gnome_canvas_item_set (day_view->main_canvas_top_resize_bar_item, - "x1", x - E_DAY_VIEW_BAR_WIDTH, - "y1", y - E_DAY_VIEW_BAR_HEIGHT, - "x2", x + w - 1, - "y2", y - 1, - NULL); - gnome_canvas_item_show (day_view->main_canvas_top_resize_bar_item); - - gnome_canvas_item_set (day_view->main_canvas_bottom_resize_bar_item, - "x1", x - E_DAY_VIEW_BAR_WIDTH, - "y1", y + h, - "x2", x + w - 1, - "y2", y + h + E_DAY_VIEW_BAR_HEIGHT - 1, - NULL); - gnome_canvas_item_show (day_view->main_canvas_bottom_resize_bar_item); -} - - -static void -e_day_view_ensure_events_sorted (EDayView *day_view) -{ - gint day; - - /* Sort the long events. */ - if (!day_view->long_events_sorted) { - qsort (day_view->long_events->data, - day_view->long_events->len, - sizeof (EDayViewEvent), - e_day_view_event_sort_func); - day_view->long_events_sorted = TRUE; - } - - /* Sort the events for each day. */ - for (day = 0; day < day_view->days_shown; day++) { - if (!day_view->events_sorted[day]) { - qsort (day_view->events[day]->data, - day_view->events[day]->len, - sizeof (EDayViewEvent), - e_day_view_event_sort_func); - day_view->events_sorted[day] = TRUE; - } - } -} - - -static gint -e_day_view_event_sort_func (const void *arg1, - const void *arg2) -{ - EDayViewEvent *event1, *event2; - - event1 = (EDayViewEvent*) arg1; - event2 = (EDayViewEvent*) arg2; - - if (event1->start < event2->start) - return -1; - if (event1->start > event2->start) - return 1; - - if (event1->end > event2->end) - return -1; - if (event1->end < event2->end) - return 1; - - return 0; -} - - -static gint -e_day_view_key_press (GtkWidget *widget, GdkEventKey *event) -{ - EDayView *day_view; - CalComponent *comp; - gint day, event_num; - gchar *initial_text; - guint keyval; - gboolean stop_emission; - time_t dtstart, dtend; - const char *uid; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - day_view = E_DAY_VIEW (widget); - keyval = event->keyval; - - /* The Escape key aborts a resize operation. */ - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - if (keyval == GDK_Escape) { - e_day_view_abort_resize (day_view, event->time); - } - return FALSE; - } - - /* Handle the cursor keys for moving & extending the selection. */ - stop_emission = TRUE; - if (event->state & GDK_SHIFT_MASK) { - switch (keyval) { - case GDK_Up: - e_day_view_cursor_key_up_shifted (day_view, event); - break; - case GDK_Down: - e_day_view_cursor_key_down_shifted (day_view, event); - break; - case GDK_Left: - e_day_view_cursor_key_left_shifted (day_view, event); - break; - case GDK_Right: - e_day_view_cursor_key_right_shifted (day_view, event); - break; - default: - stop_emission = FALSE; - break; - } - } else { - switch (keyval) { - case GDK_Up: - e_day_view_cursor_key_up (day_view, event); - break; - case GDK_Down: - e_day_view_cursor_key_down (day_view, event); - break; - case GDK_Left: - e_day_view_cursor_key_left (day_view, event); - break; - case GDK_Right: - e_day_view_cursor_key_right (day_view, event); - break; - default: - stop_emission = FALSE; - break; - } - } - if (stop_emission) - return TRUE; - - if (day_view->selection_start_day == -1) - return FALSE; - - /* Check if there is room for a new event to be typed in. If there - isn't we don't want to add an event as we will then add a new - event for every key press. */ - if (!e_day_view_check_if_new_event_fits (day_view)) { - return FALSE; - } - - /* We only want to start an edit with a return key or a simple - character. */ - if (keyval == GDK_Return) { - initial_text = NULL; - } else if ((keyval < 0x20) - || (keyval > 0xFF) - || (event->length == 0) - || (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) { - return FALSE; - } else { - initial_text = event->string; - } - - /* Add a new event covering the selected range. - Note that user_name is a global variable. */ - comp = cal_component_new (); - - e_day_view_get_selected_time_range (day_view, &dtstart, &dtend); - - /* We add the event locally and start editing it. When we get the - "update_event" callback from the server, we basically ignore it. - If we were to wait for the "update_event" callback it wouldn't be - as responsive and we may lose a few keystrokes. */ - e_day_view_add_event (comp, dtstart, dtend, day_view); - e_day_view_check_layout (day_view); - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - cal_component_get_uid (comp, &uid); - if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) { - e_day_view_start_editing_event (day_view, day, event_num, - initial_text); - day_view->editing_new_event = TRUE; - } else { - g_warning ("Couldn't find event to start editing.\n"); - } - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_key_press(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - return TRUE; -} - - -static void -e_day_view_cursor_key_up_shifted (EDayView *day_view, GdkEventKey *event) -{ - gint *row; - - if (day_view->selection_in_top_canvas) - return; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - row = &day_view->selection_start_row; - else - row = &day_view->selection_end_row; - - if (*row == 0) - return; - - *row = *row - 1; - - e_day_view_ensure_rows_visible (day_view, *row, *row); - - e_day_view_normalize_selection (day_view); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_down_shifted (EDayView *day_view, GdkEventKey *event) -{ - gint *row; - - if (day_view->selection_in_top_canvas) - return; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - row = &day_view->selection_start_row; - else - row = &day_view->selection_end_row; - - if (*row >= day_view->rows - 1) - return; - - *row = *row + 1; - - e_day_view_ensure_rows_visible (day_view, *row, *row); - - e_day_view_normalize_selection (day_view); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_left_shifted (EDayView *day_view, GdkEventKey *event) -{ - gint *day; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - day = &day_view->selection_start_day; - else - day = &day_view->selection_end_day; - - if (*day == 0) - return; - - *day = *day - 1; - - e_day_view_normalize_selection (day_view); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_right_shifted (EDayView *day_view, GdkEventKey *event) -{ - gint *day; - - if (day_view->selection_drag_pos == E_DAY_VIEW_DRAG_START) - day = &day_view->selection_start_day; - else - day = &day_view->selection_end_day; - - if (*day >= day_view->days_shown - 1) - return; - - *day = *day + 1; - - e_day_view_normalize_selection (day_view); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_up (EDayView *day_view, GdkEventKey *event) -{ - if (day_view->selection_start_day == -1) { - day_view->selection_start_day = 0; - day_view->selection_start_row = 0; - } - day_view->selection_end_day = day_view->selection_start_day; - - if (day_view->selection_in_top_canvas) { - return; - } else if (day_view->selection_start_row == 0) { - day_view->selection_in_top_canvas = TRUE; - day_view->selection_start_row = -1; - } else { - day_view->selection_start_row--; - } - day_view->selection_end_row = day_view->selection_start_row; - - if (!day_view->selection_in_top_canvas) - e_day_view_ensure_rows_visible (day_view, - day_view->selection_start_row, - day_view->selection_end_row); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_down (EDayView *day_view, GdkEventKey *event) -{ - if (day_view->selection_start_day == -1) { - day_view->selection_start_day = 0; - day_view->selection_start_row = 0; - } - day_view->selection_end_day = day_view->selection_start_day; - - if (day_view->selection_in_top_canvas) { - day_view->selection_in_top_canvas = FALSE; - day_view->selection_start_row = 0; - } else if (day_view->selection_start_row >= day_view->rows - 1) { - return; - } else { - day_view->selection_start_row++; - } - day_view->selection_end_row = day_view->selection_start_row; - - if (!day_view->selection_in_top_canvas) - e_day_view_ensure_rows_visible (day_view, - day_view->selection_start_row, - day_view->selection_end_row); - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); -} - - -static void -e_day_view_cursor_key_left (EDayView *day_view, GdkEventKey *event) -{ - if (day_view->selection_start_day == 0) { - gnome_calendar_previous (day_view->calendar); - } else { - day_view->selection_start_day--; - day_view->selection_end_day--; - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -static void -e_day_view_cursor_key_right (EDayView *day_view, GdkEventKey *event) -{ - if (day_view->selection_end_day == day_view->days_shown - 1) { - gnome_calendar_next (day_view->calendar); - } else { - day_view->selection_start_day++; - day_view->selection_end_day++; - - e_day_view_update_calendar_selection_time (day_view); - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (day_view->top_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - } -} - - -static gboolean -e_day_view_check_if_new_event_fits (EDayView *day_view) -{ - gint day, start_row, end_row, row; - - day = day_view->selection_start_day; - start_row = day_view->selection_start_row; - end_row = day_view->selection_end_row; - - /* Long events always fit, since we keep adding rows to the top - canvas. */ - if (day != day_view->selection_end_day) - return FALSE; - if (start_row == 0 && end_row == day_view->rows) - return FALSE; - - /* If any of the rows already have E_DAY_VIEW_MAX_COLUMNS columns, - return FALSE. */ - for (row = start_row; row <= end_row; row++) { - if (day_view->cols_per_row[day][row] >= E_DAY_VIEW_MAX_COLUMNS) - return FALSE; - } - - return TRUE; -} - - -static void -e_day_view_ensure_rows_visible (EDayView *day_view, - gint start_row, - gint end_row) -{ - GtkAdjustment *adj; - gfloat value, min_value, max_value; - - adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; - - value = adj->value; - - min_value = (end_row + 1) * day_view->row_height - adj->page_size; - if (value < min_value) - value = min_value; - - max_value = start_row * day_view->row_height; - if (value > max_value) - value = max_value; - - if (value != adj->value) { - adj->value = value; - gtk_adjustment_value_changed (adj); - } -} - - -static void -e_day_view_start_editing_event (EDayView *day_view, - gint day, - gint event_num, - gchar *initial_text) -{ - EDayViewEvent *event; - ETextEventProcessor *event_processor = NULL; - ETextEventProcessorCommand command; - - /* If we are already editing the event, just return. */ - if (day == day_view->editing_event_day - && event_num == day_view->editing_event_num) - return; - - if (day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - } else { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - } - - /* If the event is not shown, don't try to edit it. */ - if (!event->canvas_item) - return; - - /* We must grab the focus before setting the initial text, since - grabbing the focus will result in a call to - e_day_view_on_editing_started(), which will reset the text to get - rid of the start and end times. */ - e_canvas_item_grab_focus (event->canvas_item); - - if (initial_text) { - gnome_canvas_item_set (event->canvas_item, - "text", initial_text, - NULL); - } - - /* Try to move the cursor to the end of the text. */ - gtk_object_get (GTK_OBJECT (event->canvas_item), - "event_processor", &event_processor, - NULL); - if (event_processor) { - command.action = E_TEP_MOVE; - command.position = E_TEP_END_OF_BUFFER; - gtk_signal_emit_by_name (GTK_OBJECT (event_processor), - "command", &command); - } -} - - -/* This stops the current edit. If accept is TRUE the event summary is update, - else the edit is cancelled. */ -static void -e_day_view_stop_editing_event (EDayView *day_view) -{ - GtkWidget *toplevel; - - /* Check we are editing an event. */ - if (day_view->editing_event_day == -1) - return; - - /* Set focus to the toplevel so the item loses focus. */ - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (day_view)); - if (toplevel && GTK_IS_WINDOW (toplevel)) - gtk_window_set_focus (GTK_WINDOW (toplevel), NULL); -} - - -static gboolean -e_day_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *event, - EDayView *day_view) -{ - switch (event->type) { - case GDK_KEY_PRESS: - if (event && event->key.keyval == GDK_Return) { - /* We set the keyboard focus to the EDayView, so the - EText item loses it and stops the edit. */ - gtk_widget_grab_focus (GTK_WIDGET (day_view)); - - /* Stop the signal last or we will also stop any - other events getting to the EText item. */ - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - return TRUE; - } - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - /* Only let the EText handle the event while editing. */ - if (!E_TEXT (item)->editing) - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - break; - case GDK_FOCUS_CHANGE: - if (event->focus_change.in) - e_day_view_on_editing_started (day_view, item); - else - e_day_view_on_editing_stopped (day_view, item); - - return FALSE; - default: - break; - } - - return FALSE; -} - - -static void -e_day_view_on_editing_started (EDayView *day_view, - GnomeCanvasItem *item) -{ - gint day, event_num; - - if (!e_day_view_find_event_from_item (day_view, item, - &day, &event_num)) - return; - -#if 0 - g_print ("In e_day_view_on_editing_started Day:%i Event:%i\n", - day, event_num); -#endif - - /* FIXME: This is a temporary workaround for a bug which seems to stop - us getting focus_out signals. It is not a complete fix since if we - don't get focus_out signals we don't save the appointment text so - this may be lost. */ - if (day_view->editing_event_day == day - && day_view->editing_event_num == event_num) - return; - - day_view->editing_event_day = day; - day_view->editing_event_num = event_num; - - if (day == E_DAY_VIEW_LONG_EVENT) { - e_day_view_reshape_long_event (day_view, event_num); - } else { - day_view->resize_bars_event_day = day; - day_view->resize_bars_event_num = event_num; - e_day_view_update_event_label (day_view, day, event_num); - e_day_view_reshape_main_canvas_resize_bars (day_view); - } -} - - -static void -e_day_view_on_editing_stopped (EDayView *day_view, - GnomeCanvasItem *item) -{ - gint day, event_num; - gboolean editing_long_event = FALSE; - EDayViewEvent *event; - gchar *text = NULL; - CalComponentText summary; - const char *uid; - - /* Note: the item we are passed here isn't reliable, so we just stop - the edit of whatever item was being edited. We also receive this - event twice for some reason. */ - day = day_view->editing_event_day; - event_num = day_view->editing_event_num; - - /* If no item is being edited, just return. */ - if (day == -1) - return; - -#if 0 - g_print ("In e_day_view_on_editing_stopped Day:%i Event:%i\n", - day, event_num); -#endif - - if (day == E_DAY_VIEW_LONG_EVENT) { - editing_long_event = TRUE; - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - } else { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* Hide the horizontal bars. */ - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - } - - /* Reset the edit fields. */ - day_view->editing_event_day = -1; - day_view->editing_event_num = -1; - day_view->editing_new_event = FALSE; - - day_view->resize_bars_event_day = -1; - day_view->resize_bars_event_num = -1; - - /* Check that the event is still valid. */ - cal_component_get_uid (event->comp, &uid); - if (!uid) - return; - - gtk_object_get (GTK_OBJECT (event->canvas_item), - "text", &text, - NULL); - - /* Only update the summary if necessary. */ - cal_component_get_summary (event->comp, &summary); - if (text && summary.value && !strcmp (text, summary.value)) { - g_free (text); - - if (day == E_DAY_VIEW_LONG_EVENT) - e_day_view_reshape_long_event (day_view, event_num); - return; - } - - cal_component_set_summary (event->comp, &summary); - g_free (text); - - if (!cal_client_update_object (day_view->calendar->client, event->comp)) - g_message ("e_day_view_on_editing_stopped(): Could not update the object!"); -} - - -/* FIXME: It is possible that we may produce an invalid time due to daylight - saving times (i.e. when clocks go forward there is a range of time which - is not valid). I don't know the best way to handle daylight saving time. */ -static time_t -e_day_view_convert_grid_position_to_time (EDayView *day_view, - gint col, - gint row) -{ - struct tm *tmp_tm; - time_t val; - gint minutes; - - /* Calulate the number of minutes since the start of the day. */ - minutes = day_view->first_hour_shown * 60 - + day_view->first_minute_shown - + row * day_view->mins_per_row; - - /* A special case for midnight, where we can use the start of the - next day. */ - if (minutes == 60 * 24) - return day_view->day_starts[col + 1]; - - /* We convert the start of the day to a struct tm, then set the - hour and minute, then convert it back to a time_t. */ - tmp_tm = localtime (&day_view->day_starts[col]); - - tmp_tm->tm_hour = minutes / 60; - tmp_tm->tm_min = minutes % 60; - tmp_tm->tm_isdst = -1; - - val = mktime (tmp_tm); - return val; -} - - -static gboolean -e_day_view_convert_time_to_grid_position (EDayView *day_view, - time_t time, - gint *col, - gint *row) -{ - struct tm *tmp_tm; - gint day, minutes; - - *col = *row = 0; - - if (time < day_view->lower || time >= day_view->upper) - return FALSE; - - /* We can find the column easily using the day_starts array. */ - for (day = 1; day <= day_view->days_shown; day++) { - if (time < day_view->day_starts[day]) { - *col = day - 1; - break; - } - } - - /* To find the row we need to convert the time to a struct tm, - calculate the offset in minutes from the top of the display and - divide it by the mins per row setting. */ - tmp_tm = localtime (&time); - minutes = tmp_tm->tm_hour * 60 + tmp_tm->tm_min; - minutes -= day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - - *row = minutes / day_view->mins_per_row; - - if (*row < 0 || *row >= day_view->rows) - return FALSE; - - return TRUE; -} - - -/* This starts or stops auto-scrolling when dragging a selection or resizing - an event. */ -void -e_day_view_check_auto_scroll (EDayView *day_view, - gint event_x, - gint event_y) -{ - day_view->last_mouse_x = event_x; - day_view->last_mouse_y = event_y; - - if (event_y < E_DAY_VIEW_AUTO_SCROLL_OFFSET) - e_day_view_start_auto_scroll (day_view, TRUE); - else if (event_y >= day_view->main_canvas->allocation.height - - E_DAY_VIEW_AUTO_SCROLL_OFFSET) - e_day_view_start_auto_scroll (day_view, FALSE); - else - e_day_view_stop_auto_scroll (day_view); -} - - -static void -e_day_view_start_auto_scroll (EDayView *day_view, - gboolean scroll_up) -{ - if (day_view->auto_scroll_timeout_id == 0) { - day_view->auto_scroll_timeout_id = g_timeout_add (E_DAY_VIEW_AUTO_SCROLL_TIMEOUT, e_day_view_auto_scroll_handler, day_view); - day_view->auto_scroll_delay = E_DAY_VIEW_AUTO_SCROLL_DELAY; - } - day_view->auto_scroll_up = scroll_up; -} - - -void -e_day_view_stop_auto_scroll (EDayView *day_view) -{ - if (day_view->auto_scroll_timeout_id != 0) { - gtk_timeout_remove (day_view->auto_scroll_timeout_id); - day_view->auto_scroll_timeout_id = 0; - } -} - - -static gboolean -e_day_view_auto_scroll_handler (gpointer data) -{ - EDayView *day_view; - EDayViewPosition pos; - gint scroll_x, scroll_y, new_scroll_y, canvas_x, canvas_y, row, day; - GtkAdjustment *adj; - - g_return_val_if_fail (E_IS_DAY_VIEW (data), FALSE); - - day_view = E_DAY_VIEW (data); - - GDK_THREADS_ENTER (); - - if (day_view->auto_scroll_delay > 0) { - day_view->auto_scroll_delay--; - GDK_THREADS_LEAVE (); - return TRUE; - } - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (day_view->main_canvas), - &scroll_x, &scroll_y); - - adj = GTK_LAYOUT (day_view->main_canvas)->vadjustment; - - if (day_view->auto_scroll_up) - new_scroll_y = MAX (scroll_y - adj->step_increment, 0); - else - new_scroll_y = MIN (scroll_y + adj->step_increment, - adj->upper - adj->page_size); - - if (new_scroll_y != scroll_y) { - /* NOTE: This reduces flicker, but only works if we don't use - canvas items which have X windows. */ - gtk_layout_freeze (GTK_LAYOUT (day_view->main_canvas)); - - gnome_canvas_scroll_to (GNOME_CANVAS (day_view->main_canvas), - scroll_x, new_scroll_y); - - gtk_layout_thaw (GTK_LAYOUT (day_view->main_canvas)); - } - - canvas_x = day_view->last_mouse_x + scroll_x; - canvas_y = day_view->last_mouse_y + new_scroll_y; - - /* The last_mouse_x position is set to -1 when we are selecting using - the time column. In this case we set canvas_x to 0 and we ignore - the resulting day. */ - if (day_view->last_mouse_x == -1) - canvas_x = 0; - - /* Update the selection/resize/drag if necessary. */ - pos = e_day_view_convert_position_in_main_canvas (day_view, - canvas_x, canvas_y, - &day, &row, NULL); - - if (day_view->last_mouse_x == -1) - day = -1; - - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - if (day_view->selection_is_being_dragged) { - e_day_view_update_selection (day_view, day, row); - } else if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE) { - e_day_view_update_resize (day_view, row); - } else if (day_view->drag_item->object.flags - & GNOME_CANVAS_ITEM_VISIBLE) { - e_day_view_update_main_canvas_drag (day_view, row, - day); - } - } - - GDK_THREADS_LEAVE (); - return TRUE; -} - - -gboolean -e_day_view_get_event_position (EDayView *day_view, - gint day, - gint event_num, - gint *item_x, - gint *item_y, - gint *item_w, - gint *item_h) -{ - EDayViewEvent *event; - gint start_row, end_row, cols_in_row, start_col, num_columns; - - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* If the event is flagged as not displayed, return FALSE. */ - if (event->num_columns == 0) - return FALSE; - - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - cols_in_row = day_view->cols_per_row[day][start_row]; - start_col = event->start_row_or_col; - num_columns = event->num_columns; - - if (cols_in_row == 0) - return FALSE; - - /* If the event is being resize, use the resize position. */ - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == day - && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_TOP_EDGE) - start_row = day_view->resize_start_row; - else if (day_view->resize_drag_pos == E_DAY_VIEW_POS_BOTTOM_EDGE) - end_row = day_view->resize_end_row; - } - - *item_x = day_view->day_offsets[day] + day_view->day_widths[day] * start_col / cols_in_row; - *item_w = day_view->day_widths[day] * num_columns / cols_in_row - E_DAY_VIEW_GAP_WIDTH; - *item_w = MAX (*item_w, 0); - *item_y = start_row * day_view->row_height; - *item_h = (end_row - start_row + 1) * day_view->row_height; - - return TRUE; -} - - -gboolean -e_day_view_get_long_event_position (EDayView *day_view, - gint event_num, - gint *start_day, - gint *end_day, - gint *item_x, - gint *item_y, - gint *item_w, - gint *item_h) -{ - EDayViewEvent *event; - - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - /* If the event is flagged as not displayed, return FALSE. */ - if (event->num_columns == 0) - return FALSE; - - if (!e_day_view_find_long_event_days (day_view, event, - start_day, end_day)) - return FALSE; - - /* If the event is being resize, use the resize position. */ - if (day_view->resize_drag_pos != E_DAY_VIEW_POS_NONE - && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT - && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_DAY_VIEW_POS_LEFT_EDGE) - *start_day = day_view->resize_start_row; - else if (day_view->resize_drag_pos == E_DAY_VIEW_POS_RIGHT_EDGE) - *end_day = day_view->resize_end_row; - } - - *item_x = day_view->day_offsets[*start_day] + E_DAY_VIEW_BAR_WIDTH; - *item_w = day_view->day_offsets[*end_day + 1] - *item_x - - E_DAY_VIEW_GAP_WIDTH; - *item_w = MAX (*item_w, 0); - *item_y = (event->start_row_or_col + 1) * day_view->top_row_height; - *item_h = day_view->top_row_height - E_DAY_VIEW_TOP_CANVAS_Y_GAP; - return TRUE; -} - - -/* Converts a position within the entire top canvas to a day & event and - a place within the event if appropriate. If event_num_return is NULL, it - simply returns the grid position without trying to find the event. */ -static EDayViewPosition -e_day_view_convert_position_in_top_canvas (EDayView *day_view, - gint x, - gint y, - gint *day_return, - gint *event_num_return) -{ - EDayViewEvent *event; - gint day, row, col; - gint event_num, start_day, end_day, item_x, item_y, item_w, item_h; - - *day_return = -1; - if (event_num_return) - *event_num_return = -1; - - if (x < 0 || y < 0) - return E_DAY_VIEW_POS_OUTSIDE; - - row = y / day_view->top_row_height - 1; - - day = -1; - for (col = 1; col <= day_view->days_shown; col++) { - if (x < day_view->day_offsets[col]) { - day = col - 1; - break; - } - } - if (day == -1) - return E_DAY_VIEW_POS_OUTSIDE; - - *day_return = day; - - /* If only the grid position is wanted, return. */ - if (event_num_return == NULL) - return E_DAY_VIEW_POS_NONE; - - for (event_num = 0; event_num < day_view->long_events->len; - event_num++) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - - if (event->start_row_or_col != row) - continue; - - if (!e_day_view_get_long_event_position (day_view, event_num, - &start_day, &end_day, - &item_x, &item_y, - &item_w, &item_h)) - continue; - - if (x < item_x) - continue; - - if (x >= item_x + item_w) - continue; - - *event_num_return = event_num; - - if (x < item_x + E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH - + E_DAY_VIEW_LONG_EVENT_X_PAD) - return E_DAY_VIEW_POS_LEFT_EDGE; - - if (x >= item_x + item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH - - E_DAY_VIEW_LONG_EVENT_X_PAD) - return E_DAY_VIEW_POS_RIGHT_EDGE; - - return E_DAY_VIEW_POS_EVENT; - } - - return E_DAY_VIEW_POS_NONE; -} - - -/* Converts a position within the entire main canvas to a day, row, event and - a place within the event if appropriate. If event_num_return is NULL, it - simply returns the grid position without trying to find the event. */ -static EDayViewPosition -e_day_view_convert_position_in_main_canvas (EDayView *day_view, - gint x, - gint y, - gint *day_return, - gint *row_return, - gint *event_num_return) -{ - gint day, row, col, event_num; - gint item_x, item_y, item_w, item_h; - - *day_return = -1; - *row_return = -1; - if (event_num_return) - *event_num_return = -1; - - /* Check the position is inside the canvas, and determine the day - and row. */ - if (x < 0 || y < 0) - return E_DAY_VIEW_POS_OUTSIDE; - - row = y / day_view->row_height; - if (row >= day_view->rows) - return E_DAY_VIEW_POS_OUTSIDE; - - day = -1; - for (col = 1; col <= day_view->days_shown; col++) { - if (x < day_view->day_offsets[col]) { - day = col - 1; - break; - } - } - if (day == -1) - return E_DAY_VIEW_POS_OUTSIDE; - - *day_return = day; - *row_return = row; - - /* If only the grid position is wanted, return. */ - if (event_num_return == NULL) - return E_DAY_VIEW_POS_NONE; - - /* Check the selected item first, since the horizontal resizing bars - may be above other events. */ - if (day_view->resize_bars_event_day == day) { - if (e_day_view_get_event_position (day_view, day, - day_view->resize_bars_event_num, - &item_x, &item_y, - &item_w, &item_h)) { - if (x >= item_x && x < item_x + item_w) { - *event_num_return = day_view->resize_bars_event_num; - if (y >= item_y - E_DAY_VIEW_BAR_HEIGHT - && y < item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT) - return E_DAY_VIEW_POS_TOP_EDGE; - if (y >= item_y + item_h - E_DAY_VIEW_EVENT_BORDER_HEIGHT - && y < item_y + item_h + E_DAY_VIEW_BAR_HEIGHT) - return E_DAY_VIEW_POS_BOTTOM_EDGE; - } - } - } - - /* Try to find the event at the found position. */ - *event_num_return = -1; - for (event_num = 0; event_num < day_view->events[day]->len; - event_num++) { - if (!e_day_view_get_event_position (day_view, day, event_num, - &item_x, &item_y, - &item_w, &item_h)) - continue; - - if (x < item_x || x >= item_x + item_w - || y < item_y || y >= item_y + item_h) - continue; - - *event_num_return = event_num; - - if (x < item_x + E_DAY_VIEW_BAR_WIDTH) - return E_DAY_VIEW_POS_LEFT_EDGE; - - if (y < item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT - + E_DAY_VIEW_EVENT_Y_PAD) - return E_DAY_VIEW_POS_TOP_EDGE; - - if (y >= item_y + item_h - E_DAY_VIEW_EVENT_BORDER_HEIGHT - - E_DAY_VIEW_EVENT_Y_PAD) - return E_DAY_VIEW_POS_BOTTOM_EDGE; - - return E_DAY_VIEW_POS_EVENT; - } - - return E_DAY_VIEW_POS_NONE; -} - - -static gint -e_day_view_on_top_canvas_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EDayView *day_view) -{ - gint scroll_x, scroll_y; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - day_view->drag_event_x = x + scroll_x; - day_view->drag_event_y = y + scroll_y; - - e_day_view_reshape_top_canvas_drag_item (day_view); - - return TRUE; -} - - -static void -e_day_view_reshape_top_canvas_drag_item (EDayView *day_view) -{ - EDayViewPosition pos; - gint x, y, day; - - /* Calculate the day & start row of the event being dragged, using - the current mouse position. */ - x = day_view->drag_event_x; - y = day_view->drag_event_y; - pos = e_day_view_convert_position_in_top_canvas (day_view, x, y, - &day, NULL); - /* This shouldn't really happen in a drag. */ - if (pos == E_DAY_VIEW_POS_OUTSIDE) - return; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) - day -= day_view->drag_event_offset; - day = MAX (day, 0); - - e_day_view_update_top_canvas_drag (day_view, day); -} - - -static void -e_day_view_update_top_canvas_drag (EDayView *day_view, - gint day) -{ - EDayViewEvent *event = NULL; - gint row, num_days, start_day, end_day; - gdouble item_x, item_y, item_w, item_h; - GdkFont *font; - gchar *text; - - - /* Calculate the event's position. If the event is in the same - position we started in, we use the same columns. */ - row = day_view->rows_in_top_display + 1; - num_days = 1; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->drag_event_num); - row = event->start_row_or_col + 1; - - if (!e_day_view_find_long_event_days (day_view, event, - &start_day, &end_day)) - return; - - num_days = end_day - start_day + 1; - - /* Make sure we don't go off the screen. */ - day = MIN (day, day_view->days_shown - num_days); - - } else if (day_view->drag_event_day != -1) { - event = &g_array_index (day_view->events[day_view->drag_event_day], - EDayViewEvent, - day_view->drag_event_num); - } - - /* If the position hasn't changed, just return. */ - if (day_view->drag_last_day == day - && (day_view->drag_long_event_item->object.flags - & GNOME_CANVAS_ITEM_VISIBLE)) - return; - - day_view->drag_last_day = day; - - - item_x = day_view->day_offsets[day] + E_DAY_VIEW_BAR_WIDTH; - item_w = day_view->day_offsets[day + num_days] - item_x - - E_DAY_VIEW_GAP_WIDTH; - item_y = row * day_view->top_row_height; - item_h = day_view->top_row_height - E_DAY_VIEW_TOP_CANVAS_Y_GAP; - - - /* Set the positions of the event & associated items. */ - gnome_canvas_item_set (day_view->drag_long_event_rect_item, - "x1", item_x, - "y1", item_y, - "x2", item_x + item_w - 1, - "y2", item_y + item_h - 1, - NULL); - - font = GTK_WIDGET (day_view)->style->font; - gnome_canvas_item_set (day_view->drag_long_event_item, - "font_gdk", font, - "clip_width", item_w - (E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD) * 2, - "clip_height", item_h - (E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD) * 2, - NULL); - e_canvas_item_move_absolute(day_view->drag_long_event_item, - item_x + E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD, - item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD); - - if (!(day_view->drag_long_event_rect_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - gnome_canvas_item_raise_to_top (day_view->drag_long_event_rect_item); - gnome_canvas_item_show (day_view->drag_long_event_rect_item); - } - - /* Set the text, if necessary. We don't want to set the text every - time it moves, so we check if it is currently invisible and only - set the text then. */ - if (!(day_view->drag_long_event_item->object.flags - & GNOME_CANVAS_ITEM_VISIBLE)) { - CalComponentText summary; - - cal_component_get_summary (event->comp, &summary); - if (event) { - cal_component_get_summary (event->comp, &summary); - text = g_strdup (summary.value); - } else { - text = NULL; - } - - gnome_canvas_item_set (day_view->drag_long_event_item, - "text", text ? text : "", - NULL); - gnome_canvas_item_raise_to_top (day_view->drag_long_event_item); - gnome_canvas_item_show (day_view->drag_long_event_item); - - g_free (text); - } -} - - -static gint -e_day_view_on_main_canvas_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - EDayView *day_view) -{ - gint scroll_x, scroll_y; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - day_view->drag_event_x = x + scroll_x; - day_view->drag_event_y = y + scroll_y; - - e_day_view_reshape_main_canvas_drag_item (day_view); - e_day_view_reshape_main_canvas_resize_bars (day_view); - - e_day_view_check_auto_scroll (day_view, x, y); - - return TRUE; -} - - -static void -e_day_view_reshape_main_canvas_drag_item (EDayView *day_view) -{ - EDayViewPosition pos; - gint x, y, day, row; - - /* Calculate the day & start row of the event being dragged, using - the current mouse position. */ - x = day_view->drag_event_x; - y = day_view->drag_event_y; - pos = e_day_view_convert_position_in_main_canvas (day_view, x, y, - &day, &row, NULL); - /* This shouldn't really happen in a drag. */ - if (pos == E_DAY_VIEW_POS_OUTSIDE) - return; - - if (day_view->drag_event_day != -1 - && day_view->drag_event_day != E_DAY_VIEW_LONG_EVENT) - row -= day_view->drag_event_offset; - row = MAX (row, 0); - - e_day_view_update_main_canvas_drag (day_view, row, day); -} - - -static void -e_day_view_update_main_canvas_drag (EDayView *day_view, - gint row, - gint day) -{ - EDayViewEvent *event = NULL; - gint cols_in_row, start_col, num_columns, num_rows, start_row, end_row; - gdouble item_x, item_y, item_w, item_h; - GdkFont *font; - gchar *text; - - /* If the position hasn't changed, just return. */ - if (day_view->drag_last_day == day - && day_view->drag_last_row == row - && (day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) - return; - - day_view->drag_last_day = day; - day_view->drag_last_row = row; - - /* Calculate the event's position. If the event is in the same - position we started in, we use the same columns. */ - cols_in_row = 1; - start_col = 0; - num_columns = 1; - num_rows = 1; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->drag_event_num); - } else if (day_view->drag_event_day != -1) { - event = &g_array_index (day_view->events[day_view->drag_event_day], - EDayViewEvent, - day_view->drag_event_num); - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - num_rows = end_row - start_row + 1; - } - - if (day_view->drag_event_day == day && start_row == row) { - cols_in_row = day_view->cols_per_row[day][row]; - start_col = event->start_row_or_col; - num_columns = event->num_columns; - } - - item_x = day_view->day_offsets[day] - + day_view->day_widths[day] * start_col / cols_in_row; - item_w = day_view->day_widths[day] * num_columns / cols_in_row - - E_DAY_VIEW_GAP_WIDTH; - item_y = row * day_view->row_height; - item_h = num_rows * day_view->row_height; - - /* Set the positions of the event & associated items. */ - gnome_canvas_item_set (day_view->drag_rect_item, - "x1", item_x + E_DAY_VIEW_BAR_WIDTH - 1, - "y1", item_y, - "x2", item_x + item_w - 1, - "y2", item_y + item_h - 1, - NULL); - - gnome_canvas_item_set (day_view->drag_bar_item, - "x1", item_x, - "y1", item_y, - "x2", item_x + E_DAY_VIEW_BAR_WIDTH - 1, - "y2", item_y + item_h - 1, - NULL); - - font = GTK_WIDGET (day_view)->style->font; - gnome_canvas_item_set (day_view->drag_item, - "font_gdk", font, - "clip_width", item_w - E_DAY_VIEW_BAR_WIDTH - E_DAY_VIEW_EVENT_X_PAD * 2, - "clip_height", item_h - (E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD) * 2, - NULL); - e_canvas_item_move_absolute(event->canvas_item, - item_x + E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_EVENT_X_PAD, - item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD); - - if (!(day_view->drag_bar_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - gnome_canvas_item_raise_to_top (day_view->drag_bar_item); - gnome_canvas_item_show (day_view->drag_bar_item); - } - - if (!(day_view->drag_rect_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - gnome_canvas_item_raise_to_top (day_view->drag_rect_item); - gnome_canvas_item_show (day_view->drag_rect_item); - } - - /* Set the text, if necessary. We don't want to set the text every - time it moves, so we check if it is currently invisible and only - set the text then. */ - if (!(day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) { - CalComponentText summary; - - if (event) { - cal_component_get_summary (event->comp, &summary); - text = g_strdup (summary.value); - } else { - text = NULL; - } - - gnome_canvas_item_set (day_view->drag_item, - "text", text ? text : "", - NULL); - gnome_canvas_item_raise_to_top (day_view->drag_item); - gnome_canvas_item_show (day_view->drag_item); - - g_free (text); - } -} - - -static void -e_day_view_on_top_canvas_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time, - EDayView *day_view) -{ - day_view->drag_last_day = -1; - - gnome_canvas_item_hide (day_view->drag_long_event_rect_item); - gnome_canvas_item_hide (day_view->drag_long_event_item); -} - - -static void -e_day_view_on_main_canvas_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time, - EDayView *day_view) -{ - day_view->drag_last_day = -1; - - e_day_view_stop_auto_scroll (day_view); - - gnome_canvas_item_hide (day_view->drag_rect_item); - gnome_canvas_item_hide (day_view->drag_bar_item); - gnome_canvas_item_hide (day_view->drag_item); - - /* Hide the resize bars if they are being used in the drag. */ - if (day_view->drag_event_day == day_view->resize_bars_event_day - && day_view->drag_event_num == day_view->resize_bars_event_num) { - gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); - gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - } -} - - -static void -e_day_view_on_drag_begin (GtkWidget *widget, - GdkDragContext *context, - EDayView *day_view) -{ - EDayViewEvent *event; - gint day, event_num; - - day = day_view->drag_event_day; - event_num = day_view->drag_event_num; - - /* These should both be set. */ - g_return_if_fail (day != -1); - g_return_if_fail (event_num != -1); - - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - else - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - - /* Hide the text item, since it will be shown in the special drag - items. */ - gnome_canvas_item_hide (event->canvas_item); -} - - -static void -e_day_view_on_drag_end (GtkWidget *widget, - GdkDragContext *context, - EDayView *day_view) -{ - EDayViewEvent *event; - gint day, event_num; - - day = day_view->drag_event_day; - event_num = day_view->drag_event_num; - - /* If the calendar has already been updated in drag_data_received() - we just return. */ - if (day == -1 || event_num == -1) - return; - - if (day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - event_num); - gtk_widget_queue_draw (day_view->top_canvas); - } else { - event = &g_array_index (day_view->events[day], EDayViewEvent, - event_num); - gtk_widget_queue_draw (day_view->main_canvas); - } - - /* Show the text item again. */ - gnome_canvas_item_show (event->canvas_item); - - day_view->drag_event_day = -1; - day_view->drag_event_num = -1; -} - - -static void -e_day_view_on_drag_data_get (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - EDayView *day_view) -{ - EDayViewEvent *event; - gint day, event_num; - const char *event_uid; - - day = day_view->drag_event_day; - event_num = day_view->drag_event_num; - - /* These should both be set. */ - g_return_if_fail (day != -1); - g_return_if_fail (event_num != -1); - - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - - cal_component_get_uid (event->comp, &event_uid); - - g_return_if_fail (event_uid != NULL); - - if (info == TARGET_CALENDAR_EVENT) { - gtk_selection_data_set (selection_data, selection_data->target, - 8, event_uid, strlen (event_uid)); - } -} - - -static void -e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - EDayView *day_view) -{ - EDayViewEvent *event=NULL; - EDayViewPosition pos; - gint day, start_day, end_day, num_days; - gint start_offset, end_offset; - gchar *event_uid; - CalComponent *comp; - CalComponentDateTime date; - time_t dt; - - if ((data->length >= 0) && (data->format == 8)) { - pos = e_day_view_convert_position_in_top_canvas (day_view, - x, y, &day, - NULL); - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - const char *uid; - num_days = 1; - start_offset = 0; - end_offset = -1; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->drag_event_num); - day -= day_view->drag_event_offset; - day = MAX (day, 0); - - e_day_view_find_long_event_days (day_view, - event, - &start_day, - &end_day); - num_days = end_day - start_day + 1; - /* Make sure we don't go off the screen. */ - day = MIN (day, day_view->days_shown - num_days); - - start_offset = event->start_minute; - end_offset = event->end_minute; - } else if (day_view->drag_event_day != -1) { - event = &g_array_index (day_view->events[day_view->drag_event_day], - EDayViewEvent, - day_view->drag_event_num); - } - - event_uid = data->data; - - cal_component_get_uid (event->comp, &uid); - - if (!event_uid || !uid || strcmp (event_uid, uid)) - g_warning ("Unexpected event UID"); - - /* We use a temporary shallow of the comp since we - don't want to change the original comp here. - Otherwise we would not detect that the event's time - had changed in the "update_event" callback. */ - - comp = cal_component_clone (event->comp); - - date.value = g_new (struct icaltimetype, 1); - dt = day_view->day_starts[day] + start_offset * 60; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtstart (comp, &date); - if (end_offset == -1 || end_offset == 0) - dt = day_view->day_starts[day + num_days]; - else - dt = day_view->day_starts[day + num_days - 1] + end_offset * 60; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - - gtk_drag_finish (context, TRUE, TRUE, time); - - /* Reset this since it will be invalid. */ - day_view->drag_event_day = -1; - - /* Show the text item again, just in case it hasn't - moved. If we don't do this it may not appear. */ - if (event->canvas_item) - gnome_canvas_item_show (event->canvas_item); - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_on_top_canvas_drag_data_received(): Could " - "not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - return; - } - } - - gtk_drag_finish (context, FALSE, FALSE, time); -} - - -static void -e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - EDayView *day_view) -{ - EDayViewEvent *event = NULL; - EDayViewPosition pos; - gint day, row, start_row, end_row, num_rows, scroll_x, scroll_y; - gint start_offset, end_offset; - gchar *event_uid; - CalComponent *comp; - CalComponentDateTime date; - time_t dt; - - gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), - &scroll_x, &scroll_y); - x += scroll_x; - y += scroll_y; - - if ((data->length >= 0) && (data->format == 8)) { - pos = e_day_view_convert_position_in_main_canvas (day_view, - x, y, &day, - &row, NULL); - if (pos != E_DAY_VIEW_POS_OUTSIDE) { - const char *uid; - num_rows = 1; - start_offset = 0; - end_offset = 0; - - if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { - event = &g_array_index (day_view->long_events, EDayViewEvent, - day_view->drag_event_num); - } else if (day_view->drag_event_day != -1) { - event = &g_array_index (day_view->events[day_view->drag_event_day], - EDayViewEvent, - day_view->drag_event_num); - row -= day_view->drag_event_offset; - - /* Calculate time offset from start row. */ - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; - num_rows = end_row - start_row + 1; - - start_offset = event->start_minute % day_view->mins_per_row; - end_offset = event->end_minute % day_view->mins_per_row; - if (end_offset != 0) - end_offset = day_view->mins_per_row - end_offset; - } - - event_uid = data->data; - - cal_component_get_uid (event->comp, &uid); - if (!event_uid || !uid || strcmp (event_uid, uid)) - g_warning ("Unexpected event UID"); - - /* We use a temporary shallow copy of comp since we - don't want to change the original comp here. - Otherwise we would not detect that the event's time - had changed in the "update_event" callback. */ - comp = cal_component_clone (event->comp); - - date.value = g_new (struct icaltimetype, 1); - dt = e_day_view_convert_grid_position_to_time (day_view, day, row) + start_offset * 60; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtstart (comp, &date); - dt = e_day_view_convert_grid_position_to_time (day_view, day, row + num_rows) - end_offset * 60; - *date.value = icaltimetype_from_timet (dt, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - - gtk_drag_finish (context, TRUE, TRUE, time); - - /* Reset this since it will be invalid. */ - day_view->drag_event_day = -1; - - /* Show the text item again, just in case it hasn't - moved. If we don't do this it may not appear. */ - if (event->canvas_item) - gnome_canvas_item_show (event->canvas_item); - - if (!cal_client_update_object (day_view->calendar->client, comp)) - g_message ("e_day_view_on_main_canvas_drag_data_received(): " - "Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - return; - } - } - - gtk_drag_finish (context, FALSE, FALSE, time); -} - - - - - diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h deleted file mode 100644 index 955ef0541c..0000000000 --- a/calendar/gui/e-day-view.h +++ /dev/null @@ -1,504 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 _E_DAY_VIEW_H_ -#define _E_DAY_VIEW_H_ - -#include <time.h> -#include <gtk/gtktable.h> -#include <libgnomeui/gnome-canvas.h> - -#include "gnome-cal.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EDayView - displays the Day & Work-Week views of the calendar. - */ - -/* The maximum number of days shown. We use 7 since we only show 1 week max. */ -#define E_DAY_VIEW_MAX_DAYS 7 - -/* This is used as a special code to signify a long event instead of the day - of a normal event. */ -#define E_DAY_VIEW_LONG_EVENT E_DAY_VIEW_MAX_DAYS - -/* The maximum number of columns of appointments within a day. */ -#define E_DAY_VIEW_MAX_COLUMNS 6 - -/* The width of the gap between appointments. This should be at least - E_DAY_VIEW_BAR_WIDTH, since in the top canvas we use this space to draw - the triangle to represent continuing events. */ -#define E_DAY_VIEW_GAP_WIDTH 8 - -/* The width of the bars down the left of each column and appointment. - This includes the borders on each side of it. */ -#define E_DAY_VIEW_BAR_WIDTH 8 - -/* The height of the horizontal bar above & beneath the selected event. - This includes the borders on the top and bottom. */ -#define E_DAY_VIEW_BAR_HEIGHT 6 - -/* The size of the reminder & recurrence icons, and padding around them. */ -#define E_DAY_VIEW_ICON_WIDTH 16 -#define E_DAY_VIEW_ICON_HEIGHT 16 -#define E_DAY_VIEW_ICON_X_PAD 0 -#define E_DAY_VIEW_ICON_Y_PAD 0 - -/* The size of the border around the event. */ -#define E_DAY_VIEW_EVENT_BORDER_WIDTH 1 -#define E_DAY_VIEW_EVENT_BORDER_HEIGHT 1 - -/* The padding on each side of the event text. */ -#define E_DAY_VIEW_EVENT_X_PAD 2 -#define E_DAY_VIEW_EVENT_Y_PAD 1 - -/* The padding on each side of the event text for events in the top canvas. */ -#define E_DAY_VIEW_LONG_EVENT_X_PAD 2 -#define E_DAY_VIEW_LONG_EVENT_Y_PAD 2 - -/* The size of the border around the long events in the top canvas. */ -#define E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH 1 -#define E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT 1 - -/* The space between the time and the icon/text in the top canvas. */ -#define E_DAY_VIEW_LONG_EVENT_TIME_X_PAD 2 - -/* The gap between rows in the top canvas. */ -#define E_DAY_VIEW_TOP_CANVAS_Y_GAP 2 - - -/* These are used to specify the type of an appointment. They match those - used in EMeetingTimeSelector. */ -typedef enum -{ - E_DAY_VIEW_BUSY_TENTATIVE = 0, - E_DAY_VIEW_BUSY_OUT_OF_OFFICE = 1, - E_DAY_VIEW_BUSY_BUSY = 2, - - E_DAY_VIEW_BUSY_LAST = 3 -} EDayViewBusyType; - -/* This is used to specify the format used when displaying the dates. - The full format is like 'September 12'. The abbreviated format is like - 'Sep 12'. The short format is like '12'. The actual format used is - determined in style_set(), once we know the font being used. */ -typedef enum -{ - E_DAY_VIEW_DATE_FULL, - E_DAY_VIEW_DATE_ABBREVIATED, - E_DAY_VIEW_DATE_SHORT -} EDayViewDateFormat; - -/* These index our colors array. */ -typedef enum -{ - E_DAY_VIEW_COLOR_BG_WORKING, - E_DAY_VIEW_COLOR_BG_NOT_WORKING, - E_DAY_VIEW_COLOR_EVENT_VBAR, - - E_DAY_VIEW_COLOR_EVENT_BACKGROUND, - E_DAY_VIEW_COLOR_EVENT_BORDER, - - E_DAY_VIEW_COLOR_LAST -} EDayViewColors; - -/* These specify which part of the selection we are dragging, if any. */ -typedef enum -{ - E_DAY_VIEW_DRAG_START, - E_DAY_VIEW_DRAG_END -} EDayViewDragPosition; - -/* Specifies the position of the mouse. */ -typedef enum -{ - E_DAY_VIEW_POS_OUTSIDE, - E_DAY_VIEW_POS_NONE, - E_DAY_VIEW_POS_EVENT, - E_DAY_VIEW_POS_LEFT_EDGE, - E_DAY_VIEW_POS_RIGHT_EDGE, - E_DAY_VIEW_POS_TOP_EDGE, - E_DAY_VIEW_POS_BOTTOM_EDGE -} EDayViewPosition; - -typedef struct _EDayViewEvent EDayViewEvent; -struct _EDayViewEvent { - CalComponent *comp; - time_t start; - time_t end; - guint8 start_row_or_col;/* The start column for normal events, or the - start row for long events. */ - guint8 num_columns; /* 0 indicates not displayed. For long events - this is just 1 if the event is shown. */ - guint16 start_minute; /* Offsets from the start of the display. */ - guint16 end_minute; - GnomeCanvasItem *canvas_item; -}; - - -#define E_DAY_VIEW(obj) GTK_CHECK_CAST (obj, e_day_view_get_type (), EDayView) -#define E_DAY_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_day_view_get_type (), EDayViewClass) -#define E_IS_DAY_VIEW(obj) GTK_CHECK_TYPE (obj, e_day_view_get_type ()) - - -typedef struct _EDayView EDayView; -typedef struct _EDayViewClass EDayViewClass; - -struct _EDayView -{ - GtkTable table; - - /* The top canvas where the dates and long appointments are shown. */ - GtkWidget *top_canvas; - GnomeCanvasItem *top_canvas_item; - - /* The main canvas where the rest of the appointments are shown. */ - GtkWidget *main_canvas; - GnomeCanvasItem *main_canvas_item; - - /* The canvas displaying the times of the day. */ - GtkWidget *time_canvas; - GnomeCanvasItem *time_canvas_item; - - GtkWidget *vscrollbar; - - /* The calendar we are associated with. */ - GnomeCalendar *calendar; - - /* The start and end of the day shown. */ - time_t lower; - time_t upper; - - /* The number of days we are showing. Usually 1 or 5. Maybe 6 or 7. */ - gint days_shown; - - /* The start of each day & an extra element to hold the last time. */ - time_t day_starts[E_DAY_VIEW_MAX_DAYS + 1]; - - - /* An array of EDayViewEvent elements for the top view and each day. */ - GArray *long_events; - GArray *events[E_DAY_VIEW_MAX_DAYS]; - - /* These are set to FALSE whenever an event in the corresponding array - is changed. Any function that needs the events sorted calls - e_day_view_ensure_events_sorted(). */ - gboolean long_events_sorted; - gboolean events_sorted[E_DAY_VIEW_MAX_DAYS]; - - /* This is TRUE if we need to relayout the events before drawing. */ - gboolean long_events_need_layout; - gboolean need_layout[E_DAY_VIEW_MAX_DAYS]; - - /* This is TRUE if we need to reshape the canvas items, but a full - layout is not necessary. */ - gboolean long_events_need_reshape; - gboolean need_reshape[E_DAY_VIEW_MAX_DAYS]; - - /* The number of minutes per row. 5, 10, 15, 30 or 60. */ - gint mins_per_row; - - /* The number of rows needed, depending on the times shown and the - minutes per row. */ - gint rows; - - /* The height of each row. */ - gint row_height; - - /* The number of rows in the top display. */ - gint rows_in_top_display; - - /* The height of each row in the top canvas. */ - gint top_row_height; - - /* The first and last times shown in the display. The last time isn't - included in the range. Default is 0:00-24:00 */ - gint first_hour_shown; - gint first_minute_shown; - gint last_hour_shown; - gint last_minute_shown; - - /* The start and end of the work day, rounded to the nearest row. */ - gint work_day_start_hour; - gint work_day_start_minute; - gint work_day_end_hour; - gint work_day_end_minute; - - /* This is set to TRUE when the widget is created, so it scrolls to - the start of the working day when first shown. */ - gboolean scroll_to_work_day; - - /* This is the width & offset of each of the day columns in the - display. */ - gint day_widths[E_DAY_VIEW_MAX_DAYS]; - gint day_offsets[E_DAY_VIEW_MAX_DAYS + 1]; - - /* An array holding the number of columns in each row, in each day. */ - guint8 cols_per_row[E_DAY_VIEW_MAX_DAYS][12 * 24]; - - /* Sizes of the various time strings. */ - gint large_hour_widths[24]; - gint small_hour_widths[24]; - gint minute_widths[12]; /* intervals of 5 minutes. */ - gint max_small_hour_width; - gint max_large_hour_width; - gint max_minute_width; - gint colon_width; - - /* This specifies how we are displaying the dates at the top. */ - EDayViewDateFormat date_format; - - /* These are the maximum widths of the different types of dates. */ - gint long_format_width; - gint abbreviated_format_width; - - /* The large font use to display the hours. I don't think we need a - fontset since we only display numbers. */ - GdkFont *large_font; - - /* The GC used for painting in different colors. */ - GdkGC *main_gc; - - /* The icons. */ - GdkPixmap *reminder_icon; - GdkBitmap *reminder_mask; - GdkPixmap *recurrence_icon; - GdkBitmap *recurrence_mask; - - /* Colors for drawing. */ - GdkColor colors[E_DAY_VIEW_COLOR_LAST]; - - /* The normal & resizing cursors. */ - GdkCursor *normal_cursor; - GdkCursor *move_cursor; - GdkCursor *resize_width_cursor; - GdkCursor *resize_height_cursor; - - /* This remembers the last cursor set on the window. */ - GdkCursor *last_cursor_set_in_top_canvas; - GdkCursor *last_cursor_set_in_main_canvas; - - /* - * Editing, Selection & Dragging data - */ - - /* The horizontal bars to resize events in the main canvas. */ - GnomeCanvasItem *main_canvas_top_resize_bar_item; - GnomeCanvasItem *main_canvas_bottom_resize_bar_item; - - /* The event currently being edited. The day is -1 if no event is - being edited, or E_DAY_VIEW_LONG_EVENT if a long event is edited. */ - gint editing_event_day; - gint editing_event_num; - - /* This is TRUE if we are editing an event which we have just created. - We ignore the "update_event" callback which we will get from the - server when the event is added. */ - gboolean editing_new_event; - - /* This is a GnomeCanvasRect which is placed around an item while it - is being resized, so we can raise it above all other EText items. */ - GnomeCanvasItem *resize_long_event_rect_item; - GnomeCanvasItem *resize_rect_item; - GnomeCanvasItem *resize_bar_item; - - /* The event for which a popup menu is being displayed, as above. */ - gint popup_event_day; - gint popup_event_num; - - /* The currently selected region. If selection_start_day is -1 there is - no current selection. If start_row or end_row is -1 then the - selection is in the top canvas. */ - gint selection_start_day; - gint selection_end_day; - gint selection_start_row; - gint selection_end_row; - - /* This is TRUE if the selection is currently being dragged using the - mouse. */ - gboolean selection_is_being_dragged; - - /* This specifies which end of the selection is being dragged. */ - EDayViewDragPosition selection_drag_pos; - - /* This is TRUE if the selection is in the top canvas only (i.e. if the - last motion event was in the top canvas). */ - gboolean selection_in_top_canvas; - - /* The last mouse position, relative to the main canvas window. - Used when auto-scrolling to update the selection. */ - gint last_mouse_x; - gint last_mouse_y; - - /* Auto-scroll info for when selecting an area or dragging an item. */ - gint auto_scroll_timeout_id; - gint auto_scroll_delay; - gboolean auto_scroll_up; - - /* These are used for the resize bars. */ - gint resize_bars_event_day; - gint resize_bars_event_num; - - /* These are used when resizing events. */ - gint resize_event_day; - gint resize_event_num; - EDayViewPosition resize_drag_pos; - gint resize_start_row; - gint resize_end_row; - - /* This is the event the mouse button was pressed on. If the button - is released we start editing it, but if the mouse is dragged we set - this to -1. */ - gint pressed_event_day; - gint pressed_event_num; - - /* These are used when dragging events. If drag_event_day is not -1 we - know that we are dragging one of the EDayView events around. */ - gint drag_event_day; - gint drag_event_num; - - /* The last mouse position when dragging, in the entire canvas. */ - gint drag_event_x; - gint drag_event_y; - - /* The offset of the mouse from the top of the event, in rows. - In the top canvas this is the offset from the left, in days. */ - gint drag_event_offset; - - /* The last day & row dragged to, so we know when we need to update - the dragged event's position. */ - gint drag_last_day; - gint drag_last_row; - - /* This is a GnomeCanvasRect which is placed around an item while it - is being resized, so we can raise it above all other EText items. */ - GnomeCanvasItem *drag_long_event_rect_item; - GnomeCanvasItem *drag_long_event_item; - GnomeCanvasItem *drag_rect_item; - GnomeCanvasItem *drag_bar_item; - GnomeCanvasItem *drag_item; -}; - -struct _EDayViewClass -{ - GtkTableClass parent_class; -}; - - -GtkType e_day_view_get_type (void); -GtkWidget* e_day_view_new (void); - -void e_day_view_set_calendar (EDayView *day_view, - GnomeCalendar *calendar); - -/* This sets the selected time range. The EDayView will show the day or week - corresponding to the start time. If the start_time & end_time are not equal - and are both visible in the view, then the selection is set to those times, - otherwise it is set to 1 hour from the start of the working day. */ -void e_day_view_set_selected_time_range (EDayView *day_view, - time_t start_time, - time_t end_time); - -/* Returns the selected time range. */ -void e_day_view_get_selected_time_range (EDayView *day_view, - time_t *start_time, - time_t *end_time); - -/* This reloads all calendar events. */ -void e_day_view_update_all_events (EDayView *day_view); - -/* This is called when one event has been added or updated. */ -void e_day_view_update_event (EDayView *day_view, - const gchar *uid); - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void e_day_view_remove_event (EDayView *day_view, - const gchar *uid); - -/* The number of days shown in the EDayView, from 1 to 7. This is normally - either 1 or 5 (for the Work-Week view). */ -gint e_day_view_get_days_shown (EDayView *day_view); -void e_day_view_set_days_shown (EDayView *day_view, - gint days_shown); - -/* This specifies how many minutes are represented by one row in the display. - It can be 60, 30, 15, 10 or 5. The default is 30. */ -gint e_day_view_get_mins_per_row (EDayView *day_view); -void e_day_view_set_mins_per_row (EDayView *day_view, - gint mins_per_row); - - - -/* - * Internal functions called by the associated canvas items. - */ -void e_day_view_check_layout (EDayView *day_view); -gint e_day_view_convert_time_to_row (EDayView *day_view, - gint hour, - gint minute); -gint e_day_view_convert_time_to_position (EDayView *day_view, - gint hour, - gint minute); -gboolean e_day_view_get_event_position (EDayView *day_view, - gint day, - gint event_num, - gint *item_x, - gint *item_y, - gint *item_w, - gint *item_h); -gboolean e_day_view_get_long_event_position (EDayView *day_view, - gint event_num, - gint *start_day, - gint *end_day, - gint *item_x, - gint *item_y, - gint *item_w, - gint *item_h); -gboolean e_day_view_find_long_event_days (EDayView *day_view, - EDayViewEvent *event, - gint *start_day, - gint *end_day); - -void e_day_view_start_selection (EDayView *day_view, - gint day, - gint row); -void e_day_view_update_selection (EDayView *day_view, - gint day, - gint row); -void e_day_view_finish_selection (EDayView *day_view); - -void e_day_view_check_auto_scroll (EDayView *day_view, - gint event_x, - gint event_y); -void e_day_view_stop_auto_scroll (EDayView *day_view); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DAY_VIEW_H_ */ diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c deleted file mode 100644 index f8812f6c33..0000000000 --- a/calendar/gui/e-week-view-event-item.c +++ /dev/null @@ -1,753 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * EWeekViewEventItem - displays the background, times and icons for an event - * in the week/month views. A separate EText canvas item is used to display & - * edit the text. - */ - -#include <config.h> -#include "../widgets/e-text/e-text.h" -#include "e-week-view-event-item.h" - -static void e_week_view_event_item_class_init (EWeekViewEventItemClass *class); -static void e_week_view_event_item_init (EWeekViewEventItem *wveitem); - -static void e_week_view_event_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_week_view_event_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_week_view_event_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, - GdkDrawable *drawable, - gint icon_x, - gint icon_y, - gint x2, - gboolean right_align); -static void e_week_view_event_item_draw_triangle (EWeekViewEventItem *wveitem, - GdkDrawable *drawable, - gint x, - gint y, - gint w, - gint h); -static double e_week_view_event_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); -static gint e_week_view_event_item_event (GnomeCanvasItem *item, - GdkEvent *event); -static gboolean e_week_view_event_item_button_press (EWeekViewEventItem *wveitem, - GdkEvent *event); -static gboolean e_week_view_event_item_button_release (EWeekViewEventItem *wveitem, - GdkEvent *event); -static EWeekViewPosition e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, - gdouble x, - gdouble y); - - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_EVENT_NUM, - ARG_SPAN_NUM -}; - - -GtkType -e_week_view_event_item_get_type (void) -{ - static GtkType e_week_view_event_item_type = 0; - - if (!e_week_view_event_item_type) { - GtkTypeInfo e_week_view_event_item_info = { - "EWeekViewEventItem", - sizeof (EWeekViewEventItem), - sizeof (EWeekViewEventItemClass), - (GtkClassInitFunc) e_week_view_event_item_class_init, - (GtkObjectInitFunc) e_week_view_event_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_week_view_event_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_week_view_event_item_info); - } - - return e_week_view_event_item_type; -} - - -static void -e_week_view_event_item_class_init (EWeekViewEventItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EWeekViewEventItem::event_num", - GTK_TYPE_INT, GTK_ARG_WRITABLE, - ARG_EVENT_NUM); - gtk_object_add_arg_type ("EWeekViewEventItem::span_num", - GTK_TYPE_INT, GTK_ARG_WRITABLE, - ARG_SPAN_NUM); - - object_class->set_arg = e_week_view_event_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_week_view_event_item_update; - item_class->draw = e_week_view_event_item_draw; - item_class->point = e_week_view_event_item_point; - item_class->event = e_week_view_event_item_event; -} - - -static void -e_week_view_event_item_init (EWeekViewEventItem *wveitem) -{ - wveitem->event_num = -1; - wveitem->span_num = -1; -} - - -static void -e_week_view_event_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EWeekViewEventItem *wveitem; - gboolean needs_update = FALSE; - - item = GNOME_CANVAS_ITEM (o); - wveitem = E_WEEK_VIEW_EVENT_ITEM (o); - - switch (arg_id){ - case ARG_EVENT_NUM: - wveitem->event_num = GTK_VALUE_INT (*arg); - needs_update = TRUE; - break; - case ARG_SPAN_NUM: - wveitem->span_num = GTK_VALUE_INT (*arg); - needs_update = TRUE; - break; - } - - if (needs_update) - gnome_canvas_item_request_update (item); -} - - -static void -e_week_view_event_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - EWeekViewEventItem *wveitem; - EWeekView *week_view; - gint span_x, span_y, span_w; - -#if 0 - g_print ("In e_week_view_event_item_update\n"); -#endif - - wveitem = E_WEEK_VIEW_EVENT_ITEM (item); - week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - item->x1 = 0; - item->y1 = 0; - item->x2 = 0; - item->y2 = 0; - - if (wveitem->event_num != -1 && wveitem->span_num != -1) { - if (e_week_view_get_span_position (week_view, - wveitem->event_num, - wveitem->span_num, - &span_x, &span_y, - &span_w)) { -#if 0 - g_print (" Event:%i Span:%i %i,%i W:%i\n", - wveitem->event_num, wveitem->span_num, - span_x, span_y, span_w); -#endif - item->x1 = span_x; - item->y1 = span_y; - item->x2 = span_x + span_w - 1; - item->y2 = span_y + week_view->row_height - 1; - } - } -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_week_view_event_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EWeekViewEventItem *wveitem; - EWeekView *week_view; - EWeekViewEvent *event; - EWeekViewEventSpan *span; - GtkStyle *style; - GdkGC *fg_gc, *gc; - GdkFont *font; - gint x1, y1, x2, y2, time_x, time_y, time_y_small_min; - gint icon_x, icon_y, time_width, min_end_time_x; - gint rect_x, rect_w, rect_x2; - gboolean one_day_event, editing_span = FALSE; - gint start_minute, end_minute; - gchar buffer[128]; - gboolean draw_start_triangle = FALSE, draw_end_triangle = FALSE; - GdkRectangle clip_rect; - -#if 0 - g_print ("In e_week_view_event_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - - wveitem = E_WEEK_VIEW_EVENT_ITEM (canvas_item); - week_view = E_WEEK_VIEW (GTK_WIDGET (canvas_item->canvas)->parent); - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (wveitem->event_num == -1 || wveitem->span_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - wveitem->event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + wveitem->span_num); - - style = GTK_WIDGET (week_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - gc = week_view->main_gc; - - x1 = canvas_item->x1 - x; - y1 = canvas_item->y1 - y; - x2 = canvas_item->x2 - x; - y2 = canvas_item->y2 - y; - - if (x1 == x2 || y1 == y2) - return; - - icon_y = y1 + E_WEEK_VIEW_EVENT_BORDER_HEIGHT + E_WEEK_VIEW_ICON_Y_PAD; - start_minute = event->start_minute; - end_minute = event->end_minute; - time_y = y1 + E_WEEK_VIEW_EVENT_BORDER_HEIGHT - + E_WEEK_VIEW_EVENT_TEXT_Y_PAD + font->ascent; - if (week_view->small_font) - time_y_small_min = y1 + E_WEEK_VIEW_EVENT_BORDER_HEIGHT - + E_WEEK_VIEW_EVENT_TEXT_Y_PAD - + week_view->small_font->ascent; - if (week_view->use_small_font && week_view->small_font) - time_width = week_view->digit_width * 2 - + week_view->small_digit_width * 2; - else - time_width = week_view->digit_width * 4 - + week_view->colon_width; - - one_day_event = e_week_view_is_one_day_event (week_view, - wveitem->event_num); - if (one_day_event) { - time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD; - - /* Convert the time into a string. We use different parts of - the string for the different time formats. Notice that the - string is always 11 characters long. */ - sprintf (buffer, "%02i:%02i %02i:%02i", - start_minute / 60, start_minute % 60, - end_minute / 60, end_minute % 60); - - /* Draw the start and end times, as required. */ - switch (week_view->time_format) { - case E_WEEK_VIEW_TIME_BOTH_SMALL_MIN: - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 2); - gdk_draw_text (drawable, week_view->small_font, fg_gc, - time_x + week_view->digit_width * 2, - time_y_small_min, buffer + 3, 2); - gdk_draw_text (drawable, font, fg_gc, - time_x + week_view->digit_width * 4 - 2, - time_y, buffer + 6, 2); - gdk_draw_text (drawable, week_view->small_font, fg_gc, - time_x + week_view->digit_width * 6 - 2, - time_y_small_min, buffer + 9, 2); - - icon_x = x1 + time_width * 2 + week_view->space_width - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - break; - case E_WEEK_VIEW_TIME_START_SMALL_MIN: - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 2); - gdk_draw_text (drawable, week_view->small_font, fg_gc, - time_x + week_view->digit_width * 2, - time_y_small_min, buffer + 3, 2); - - icon_x = x1 + time_width - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - break; - case E_WEEK_VIEW_TIME_BOTH: - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 11); - icon_x = x1 + time_width * 2 + week_view->space_width - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - break; - case E_WEEK_VIEW_TIME_START: - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 5); - icon_x = x1 + time_width - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - break; - case E_WEEK_VIEW_TIME_NONE: - icon_x = x1 + E_WEEK_VIEW_EVENT_L_PAD; - break; - } - - /* Draw the icons. */ - e_week_view_event_item_draw_icons (wveitem, drawable, - icon_x, icon_y, - x2, FALSE); - - } else { - rect_x = x1 + E_WEEK_VIEW_EVENT_L_PAD; - rect_w = x2 - x1 - E_WEEK_VIEW_EVENT_L_PAD - - E_WEEK_VIEW_EVENT_R_PAD + 1; - - /* Draw the triangles at the start & end, if needed. */ - if (event->start < week_view->day_starts[span->start_day]) { - draw_start_triangle = TRUE; - rect_x += 2; - rect_w -= 2; - } - - if (event->end > week_view->day_starts[span->start_day - + span->num_days]) { - draw_end_triangle = TRUE; - rect_w -= 2; - } - - gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]); - gdk_draw_rectangle (drawable, gc, TRUE, - rect_x, y1 + 1, rect_w, y2 - y1 - 1); - - gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]); - rect_x2 = rect_x + rect_w - 1; - gdk_draw_line (drawable, gc, rect_x, y1, rect_x2, y1); - gdk_draw_line (drawable, gc, rect_x, y2, rect_x2, y2); - - if (draw_start_triangle) { - e_week_view_event_item_draw_triangle (wveitem, drawable, x1 + E_WEEK_VIEW_EVENT_L_PAD + 2, y1, -3, y2 - y1 + 1); - } else { - gdk_draw_line (drawable, gc, rect_x, y1, rect_x, y2); - } - - if (draw_end_triangle) { - e_week_view_event_item_draw_triangle (wveitem, drawable, x2 - E_WEEK_VIEW_EVENT_R_PAD - 2, y1, 3, y2 - y1 + 1); - } else { - gdk_draw_line (drawable, gc, rect_x2, y1, rect_x2, y2); - } - - if (span->text_item && E_TEXT (span->text_item)->editing) - editing_span = TRUE; - - /* Draw the start & end times, if necessary. */ - min_end_time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - if (!editing_span - && event->start > week_view->day_starts[span->start_day]) { - sprintf (buffer, "%02i:%02i", - start_minute / 60, start_minute % 60); - time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - - clip_rect.x = x1; - clip_rect.y = y1; - clip_rect.width = x2 - x1 - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH + 1; - clip_rect.height = y2 - y1 + 1; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - if (week_view->use_small_font - && week_view->small_font) { - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 2); - gdk_draw_text (drawable, week_view->small_font, - fg_gc, - time_x + week_view->digit_width * 2, - time_y_small_min, - buffer + 3, 2); - } else { - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, buffer, 5); - } - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - min_end_time_x += time_width + 2; - } - - if (!editing_span - && event->end < week_view->day_starts[span->start_day - + span->num_days]) { - sprintf (buffer, "%02i:%02i", - end_minute / 60, end_minute % 60); - time_x = x2 - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_TEXT_X_PAD - 1 - - time_width; - - if (time_x >= min_end_time_x) { - if (week_view->use_small_font - && week_view->small_font) { - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, - buffer, 2); - gdk_draw_text (drawable, - week_view->small_font, - fg_gc, - time_x + week_view->digit_width * 2, - time_y_small_min, - buffer + 3, 2); - } else { - gdk_draw_text (drawable, font, fg_gc, - time_x, time_y, - buffer, 5); - } - } - } - - /* Draw the icons. */ - if (span->text_item) { - icon_x = span->text_item->x1 - x; - e_week_view_event_item_draw_icons (wveitem, drawable, - icon_x, icon_y, - x2, TRUE); - } - } -} - - -static void -e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, - GdkDrawable *drawable, - gint icon_x, - gint icon_y, - gint x2, - gboolean right_align) -{ - EWeekView *week_view; - EWeekViewEvent *event; - EWeekViewEventSpan *span; - CalComponent *comp; - GdkGC *gc; - gint num_icons = 0, icon_x_inc; - gboolean draw_reminder_icon = FALSE, draw_recurrence_icon = FALSE; - - week_view = E_WEEK_VIEW (GTK_WIDGET (GNOME_CANVAS_ITEM (wveitem)->canvas)->parent); - - event = &g_array_index (week_view->events, EWeekViewEvent, - wveitem->event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + wveitem->span_num); - comp = event->comp; - - gc = week_view->main_gc; - -#if 0 - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) { - draw_reminder_icon = TRUE; - num_icons++; - } -#endif - - if (cal_component_has_rdates (comp) - || cal_component_has_rrules (comp)) { - draw_recurrence_icon = TRUE; - num_icons++; - } - - icon_x_inc = E_WEEK_VIEW_ICON_WIDTH + E_WEEK_VIEW_ICON_X_PAD; - - if (right_align) - icon_x -= icon_x_inc * num_icons; - - if (draw_reminder_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH <= x2) { - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, week_view->reminder_mask); - gdk_draw_pixmap (drawable, gc, - week_view->reminder_icon, - 0, 0, icon_x, icon_y, - E_WEEK_VIEW_ICON_WIDTH, - E_WEEK_VIEW_ICON_HEIGHT); - icon_x += icon_x_inc; - } - - if (draw_recurrence_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH <= x2) { - gdk_gc_set_clip_origin (gc, icon_x, icon_y); - gdk_gc_set_clip_mask (gc, week_view->recurrence_mask); - gdk_draw_pixmap (drawable, gc, - week_view->recurrence_icon, - 0, 0, icon_x, icon_y, - E_WEEK_VIEW_ICON_WIDTH, - E_WEEK_VIEW_ICON_HEIGHT); - icon_x += icon_x_inc; - } - - gdk_gc_set_clip_mask (gc, NULL); -} - - -/* This draws a little triangle to indicate that an event extends past - the days visible on screen. */ -static void -e_week_view_event_item_draw_triangle (EWeekViewEventItem *wveitem, - GdkDrawable *drawable, - gint x, - gint y, - gint w, - gint h) -{ - EWeekView *week_view; - GdkGC *gc; - GdkPoint points[3]; - gint c1, c2; - - week_view = E_WEEK_VIEW (GTK_WIDGET (GNOME_CANVAS_ITEM (wveitem)->canvas)->parent); - - gc = week_view->main_gc; - - points[0].x = x; - points[0].y = y; - points[1].x = x + w; - points[1].y = y + (h / 2) - 1; - points[2].x = x; - points[2].y = y + h - 1; - - gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND]); - gdk_draw_polygon (drawable, gc, TRUE, points, 3); - - gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER]); - - /* If the height is odd we can use the same central point for both - lines. If it is even we use different end-points. */ - c1 = c2 = y + (h / 2); - if (h % 2 == 0) - c1--; - - gdk_draw_line (drawable, gc, x, y, x + w, c1); - gdk_draw_line (drawable, gc, x, y + h - 1, x + w, c2); -} - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_week_view_event_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - -static gint -e_week_view_event_item_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EWeekViewEventItem *wveitem; - - wveitem = E_WEEK_VIEW_EVENT_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - return e_week_view_event_item_button_press (wveitem, event); - case GDK_BUTTON_RELEASE: - return e_week_view_event_item_button_release (wveitem, event); - case GDK_MOTION_NOTIFY: - break; - default: - break; - } - - return FALSE; -} - - -static gboolean -e_week_view_event_item_button_press (EWeekViewEventItem *wveitem, - GdkEvent *bevent) -{ - EWeekView *week_view; - EWeekViewPosition pos; - EWeekViewEvent *event; - EWeekViewEventSpan *span; - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (wveitem); - - week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - - event = &g_array_index (week_view->events, EWeekViewEvent, - wveitem->event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + wveitem->span_num); - -#if 0 - g_print ("In e_week_view_event_item_button_press\n"); -#endif - - pos = e_week_view_event_item_get_position (wveitem, bevent->button.x, - bevent->button.y); - if (pos == E_WEEK_VIEW_POS_NONE) - return FALSE; - - week_view->pressed_event_num = wveitem->event_num; - week_view->pressed_span_num = wveitem->span_num; - - if (bevent->button.button == 1) { - /* Ignore clicks on the event while editing. */ - if (E_TEXT (span->text_item)->editing) - return FALSE; - - /* Remember the item clicked and the mouse position, - so we can start a drag if the mouse moves. */ - week_view->drag_event_x = bevent->button.x; - week_view->drag_event_y = bevent->button.y; - - /* FIXME: Remember the day offset from the start of the event. - */ - } else if (bevent->button.button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (week_view)) - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - e_week_view_show_popup_menu (week_view, - (GdkEventButton*) bevent, - wveitem->event_num); - gtk_signal_emit_stop_by_name (GTK_OBJECT (item->canvas), - "button_press_event"); - } - - return TRUE; -} - - -static gboolean -e_week_view_event_item_button_release (EWeekViewEventItem *wveitem, - GdkEvent *event) -{ - EWeekView *week_view; - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (wveitem); - - week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - -#if 0 - g_print ("In e_week_view_event_item_button_release\n"); -#endif - - if (week_view->pressed_event_num != -1 - && week_view->pressed_event_num == wveitem->event_num - && week_view->pressed_span_num == wveitem->span_num) { - e_week_view_start_editing_event (week_view, - wveitem->event_num, - wveitem->span_num, - NULL); - week_view->pressed_event_num = -1; - return TRUE; - } - - week_view->pressed_event_num = -1; - - return FALSE; -} - - -static EWeekViewPosition -e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, - gdouble x, - gdouble y) -{ - EWeekView *week_view; - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (wveitem); - - week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), E_WEEK_VIEW_POS_NONE); - -#if 0 - g_print ("In e_week_view_event_item_get_position item: %g,%g %g,%g point: %g,%g\n", item->x1, item->y1, item->x2, item->y2, x, y); -#endif - - if (x < item->x1 + E_WEEK_VIEW_EVENT_L_PAD - || x >= item->x2 - E_WEEK_VIEW_EVENT_R_PAD) - return E_WEEK_VIEW_POS_NONE; - - /* Support left/right edge for long events only. */ - if (!e_week_view_is_one_day_event (week_view, wveitem->event_num)) { - if (x < item->x1 + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD) - return E_WEEK_VIEW_POS_LEFT_EDGE; - - if (x >= item->x2 - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_TEXT_X_PAD) - return E_WEEK_VIEW_POS_RIGHT_EDGE; - } - - return E_WEEK_VIEW_POS_EVENT; -} diff --git a/calendar/gui/e-week-view-event-item.h b/calendar/gui/e-week-view-event-item.h deleted file mode 100644 index cfe58699b0..0000000000 --- a/calendar/gui/e-week-view-event-item.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 _E_WEEK_VIEW_EVENT_ITEM_H_ -#define _E_WEEK_VIEW_EVENT_ITEM_H_ - -#include "e-week-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EWeekViewEventItem - displays the background, times and icons for an event - * in the week/month views. A separate EText canvas item is used to display & - * edit the text. - */ - -#define E_WEEK_VIEW_EVENT_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_week_view_event_item_get_type (), EWeekViewEventItem)) -#define E_WEEK_VIEW_EVENT_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_week_view_event_item_get_type ())) -#define E_IS_WEEK_VIEW_EVENT_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_week_view_event_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The event index in the EWeekView events array. */ - gint event_num; - - /* The span index within the event. */ - gint span_num; -} EWeekViewEventItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EWeekViewEventItemClass; - - -GtkType e_week_view_event_item_get_type (void); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_WEEK_VIEW_EVENT_ITEM_H_ */ diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c deleted file mode 100644 index 49c2ca3d7d..0000000000 --- a/calendar/gui/e-week-view-main-item.c +++ /dev/null @@ -1,367 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * EWeekViewMainItem - displays the background grid and dates for the Week and - * Month calendar views. - */ - -#include <config.h> -#include "e-week-view-main-item.h" - -static void e_week_view_main_item_class_init (EWeekViewMainItemClass *class); -static void e_week_view_main_item_init (EWeekViewMainItem *wvmitem); - -static void e_week_view_main_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_week_view_main_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_week_view_main_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem, - gint day, - GDate *date, - GdkDrawable *drawable, - gint x, - gint y, - gint width, - gint height); -static double e_week_view_main_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); - - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WEEK_VIEW -}; - - -GtkType -e_week_view_main_item_get_type (void) -{ - static GtkType e_week_view_main_item_type = 0; - - if (!e_week_view_main_item_type) { - GtkTypeInfo e_week_view_main_item_info = { - "EWeekViewMainItem", - sizeof (EWeekViewMainItem), - sizeof (EWeekViewMainItemClass), - (GtkClassInitFunc) e_week_view_main_item_class_init, - (GtkObjectInitFunc) e_week_view_main_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_week_view_main_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_week_view_main_item_info); - } - - return e_week_view_main_item_type; -} - - -static void -e_week_view_main_item_class_init (EWeekViewMainItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EWeekViewMainItem::week_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_WEEK_VIEW); - - object_class->set_arg = e_week_view_main_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_week_view_main_item_update; - item_class->draw = e_week_view_main_item_draw; - item_class->point = e_week_view_main_item_point; -} - - -static void -e_week_view_main_item_init (EWeekViewMainItem *wvmitem) -{ - wvmitem->week_view = NULL; -} - - -static void -e_week_view_main_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EWeekViewMainItem *wvmitem; - - item = GNOME_CANVAS_ITEM (o); - wvmitem = E_WEEK_VIEW_MAIN_ITEM (o); - - switch (arg_id){ - case ARG_WEEK_VIEW: - wvmitem->week_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_week_view_main_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_week_view_main_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EWeekViewMainItem *wvmitem; - EWeekView *week_view; - GDate date; - gint num_days, day, day_x, day_y, day_w, day_h; - -#if 0 - g_print ("In e_week_view_main_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - - wvmitem = E_WEEK_VIEW_MAIN_ITEM (canvas_item); - week_view = wvmitem->week_view; - g_return_if_fail (week_view != NULL); - - /* Step through each of the days. */ - date = week_view->first_day_shown; - - /* If no date has been set, we just use Dec 1999/January 2000. */ - if (!g_date_valid (&date)) - g_date_set_dmy (&date, 27, 12, 1999); - - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - for (day = 0; day < num_days; day++) { - e_week_view_get_day_position (week_view, day, - &day_x, &day_y, - &day_w, &day_h); - /* Skip any days which are outside the area. */ - if (day_x < x + width && day_x + day_w >= x - && day_y < y + height && day_y + day_h >= y) { - e_week_view_main_item_draw_day (wvmitem, day, &date, - drawable, - day_x - x, day_y - y, - day_w, day_h); - } - g_date_add_days (&date, 1); - } -} - - -static void -e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem, - gint day, - GDate *date, - GdkDrawable *drawable, - gint x, - gint y, - gint width, - gint height) -{ - EWeekView *week_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc, *gc, *date_gc; - GdkGC *selected_fg_gc, *selected_bg_gc; - GdkFont *font; - gint right_edge, bottom_edge, date_width, date_x, line_y; - gboolean show_day_name, show_month_name, selected; - gchar buffer[128], *format_string; - gint month, day_of_month, max_width; - GdkColor *bg_color; - -#if 0 - g_print ("Drawing Day:%i at %i,%i\n", day, x, y); -#endif - week_view = wvmitem->week_view; - style = GTK_WIDGET (week_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_PRELIGHT]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - selected_fg_gc = style->fg_gc[GTK_STATE_SELECTED]; - selected_bg_gc = style->bg_gc[GTK_STATE_SELECTED]; - gc = week_view->main_gc; - - month = g_date_month (date); - day_of_month = g_date_day (date); - line_y = y + E_WEEK_VIEW_DATE_T_PAD + font->ascent - + font->descent + E_WEEK_VIEW_DATE_LINE_T_PAD; - - /* Draw the background of the day. In the month view odd months are - one color and even months another, so you can easily see when each - month starts (defaults are white for odd - January, March, ... and - light gray for even). In the week view the background is always the - same color, the color used for the odd months in the month view. */ - if (week_view->display_month && (month % 2 == 0)) - bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS]; - else - bg_color = &week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS]; - - gdk_gc_set_foreground (gc, bg_color); - gdk_draw_rectangle (drawable, gc, TRUE, x, y, width, height); - - /* Draw the lines on the right and bottom of the cell. The canvas is - sized so that the lines on the right & bottom edges will be off the - edge of the canvas, so we don't have to worry about them. */ - right_edge = x + width - 1; - bottom_edge = y + height - 1; - - gdk_draw_line (drawable, fg_gc, - right_edge, y, right_edge, bottom_edge); - gdk_draw_line (drawable, fg_gc, - x, bottom_edge, right_edge, bottom_edge); - - /* If the day is selected, draw the blue background. */ - selected = TRUE; - if (!GTK_WIDGET_HAS_FOCUS (week_view) - || week_view->selection_start_day == -1 - || week_view->selection_start_day > day - || week_view->selection_end_day < day) - selected = FALSE; - if (selected) { - if (week_view->display_month) - gdk_draw_rectangle (drawable, selected_bg_gc, TRUE, - x + 2, y + 1, - width - 5, - E_WEEK_VIEW_DATE_T_PAD - 1 - + font->ascent + font->descent); - else - gdk_draw_rectangle (drawable, selected_bg_gc, TRUE, - x + 2, y + 1, - width - 5, line_y - y); - } - - /* Display the date in the top of the cell. - In the week view, display the long format "10 January" in all cells, - or abbreviate it to "10 Jan" or "10" if that doesn't fit. - In the month view, only use the long format for the first cell and - the 1st of each month, otherwise use "10". */ - show_day_name = FALSE; - show_month_name = FALSE; - if (!week_view->display_month) { - show_day_name = TRUE; - show_month_name = TRUE; - } else if (day == 0 || day_of_month == 1) { - show_month_name = TRUE; - } - - /* Now find the longest form of the date that will fit. */ - max_width = width - 4; - format_string = NULL; - if (show_day_name) { - if (week_view->max_abbr_day_width + - week_view->digit_width * 2 + week_view->space_width * 2 - + week_view->month_widths[month - 1] < max_width) - format_string = "%a %d %B"; - } - if (!format_string && show_month_name) { - if (week_view->digit_width * 2 + week_view->space_width - + week_view->month_widths[month - 1] < max_width) - format_string = "%d %B"; - else if (week_view->digit_width * 2 + week_view->space_width - + week_view->abbr_month_widths[month - 1] < max_width) - format_string = "%d %b"; - } - - g_date_strftime (buffer, 128, format_string ? format_string : "%d", - date); - date_width = gdk_string_width (font, buffer); - date_x = x + width - date_width - E_WEEK_VIEW_DATE_R_PAD; - date_x = MAX (date_x, x + 1); - - if (selected) - date_gc = selected_fg_gc; - else - date_gc = fg_gc; - gdk_draw_string (drawable, font, date_gc, - date_x, y + E_WEEK_VIEW_DATE_T_PAD + font->ascent, - buffer); - - /* Draw the line under the date. */ - if (!week_view->display_month) { - gdk_draw_line (drawable, fg_gc, - x + E_WEEK_VIEW_DATE_LINE_L_PAD, line_y, - right_edge, line_y); - } -} - - - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_week_view_main_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - diff --git a/calendar/gui/e-week-view-main-item.h b/calendar/gui/e-week-view-main-item.h deleted file mode 100644 index f75dcb0ec9..0000000000 --- a/calendar/gui/e-week-view-main-item.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 _E_WEEK_VIEW_MAIN_ITEM_H_ -#define _E_WEEK_VIEW_MAIN_ITEM_H_ - -#include "e-week-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EWeekViewMainItem - displays the background grid and dates for the Week and - * Month calendar views. - */ - -#define E_WEEK_VIEW_MAIN_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_week_view_main_item_get_type (), EWeekViewMainItem)) -#define E_WEEK_VIEW_MAIN_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_week_view_main_item_get_type ())) -#define E_IS_WEEK_VIEW_MAIN_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_week_view_main_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EWeekView widget. */ - EWeekView *week_view; -} EWeekViewMainItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EWeekViewMainItemClass; - - -GtkType e_week_view_main_item_get_type (void); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_WEEK_VIEW_MAIN_ITEM_H_ */ diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c deleted file mode 100644 index 14f47e4bcf..0000000000 --- a/calendar/gui/e-week-view-titles-item.c +++ /dev/null @@ -1,300 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * EWeekViewTitlesItem - displays the 'Monday', 'Tuesday' etc. at the top of - * the Month calendar view. - */ - -#include <config.h> -#include "e-week-view-titles-item.h" - -static void e_week_view_titles_item_class_init (EWeekViewTitlesItemClass *class); -static void e_week_view_titles_item_init (EWeekViewTitlesItem *wvtitem); - -static void e_week_view_titles_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_week_view_titles_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_week_view_titles_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static double e_week_view_titles_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); - - -static GnomeCanvasItemClass *parent_class; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WEEK_VIEW -}; - - -GtkType -e_week_view_titles_item_get_type (void) -{ - static GtkType e_week_view_titles_item_type = 0; - - if (!e_week_view_titles_item_type) { - GtkTypeInfo e_week_view_titles_item_info = { - "EWeekViewTitlesItem", - sizeof (EWeekViewTitlesItem), - sizeof (EWeekViewTitlesItemClass), - (GtkClassInitFunc) e_week_view_titles_item_class_init, - (GtkObjectInitFunc) e_week_view_titles_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_week_view_titles_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_week_view_titles_item_info); - } - - return e_week_view_titles_item_type; -} - - -static void -e_week_view_titles_item_class_init (EWeekViewTitlesItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = gtk_type_class (gnome_canvas_item_get_type()); - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - gtk_object_add_arg_type ("EWeekViewTitlesItem::week_view", - GTK_TYPE_POINTER, GTK_ARG_WRITABLE, - ARG_WEEK_VIEW); - - object_class->set_arg = e_week_view_titles_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->update = e_week_view_titles_item_update; - item_class->draw = e_week_view_titles_item_draw; - item_class->point = e_week_view_titles_item_point; -} - - -static void -e_week_view_titles_item_init (EWeekViewTitlesItem *wvtitem) -{ - wvtitem->week_view = NULL; -} - - -static void -e_week_view_titles_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EWeekViewTitlesItem *wvtitem; - - item = GNOME_CANVAS_ITEM (o); - wvtitem = E_WEEK_VIEW_TITLES_ITEM (o); - - switch (arg_id){ - case ARG_WEEK_VIEW: - wvtitem->week_view = GTK_VALUE_POINTER (*arg); - break; - } -} - - -static void -e_week_view_titles_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - /* The item covers the entire canvas area. */ - item->x1 = 0; - item->y1 = 0; - item->x2 = INT_MAX; - item->y2 = INT_MAX; -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - EWeekViewTitlesItem *wvtitem; - EWeekView *week_view; - GtkStyle *style; - GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc; - GdkFont *font; - gint canvas_width, canvas_height, col_width, col, date_width, date_x; - gchar buffer[128], *date_format; - GDate date; - GdkRectangle clip_rect; - gboolean long_format; - -#if 0 - g_print ("In e_week_view_titles_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - - wvtitem = E_WEEK_VIEW_TITLES_ITEM (canvas_item); - week_view = wvtitem->week_view; - g_return_if_fail (week_view != NULL); - - style = GTK_WIDGET (week_view)->style; - font = style->font; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - canvas_width = GTK_WIDGET (canvas_item->canvas)->allocation.width; - canvas_height = GTK_WIDGET (canvas_item->canvas)->allocation.height; - - /* Draw the shadow around the dates. */ - gdk_draw_line (drawable, light_gc, - 1 - x, 1 - y, - canvas_width - 2 - x, 1 - y); - gdk_draw_line (drawable, light_gc, - 1 - x, 2 - y, - 1 - x, canvas_height - 1 - y); - - gdk_draw_rectangle (drawable, dark_gc, FALSE, - 0 - x, 0 - y, - canvas_width - 1, canvas_height); - - /* Determine the format to use. */ - col_width = canvas_width / week_view->columns; - if (col_width > week_view->max_day_width + 2) { - date_format = "%A"; - long_format = TRUE; - } else { - date_format = "%a"; - long_format = FALSE; - } - - /* Shift right one pixel to account for the shadow around the main - canvas. */ - x--; - - /* Draw the date. Set a clipping rectangle so we don't draw over the - next day. */ - g_date_clear (&date, 1); - g_date_set_dmy (&date, 27, 3, 2000); /* Must be a Monday. */ - for (col = 0; col < week_view->columns; col++) { - if (col == 5 && week_view->compress_weekend) { - g_date_strftime (buffer, 128, "%a/", &date); - g_date_add_days (&date, 1); - g_date_strftime (buffer + strlen (buffer), 100, - "%a", &date); - } else { - g_date_strftime (buffer, 128, date_format, &date); - } - - clip_rect.x = week_view->col_offsets[col] - x; - clip_rect.y = 2 - y; - clip_rect.width = week_view->col_widths[col]; - clip_rect.height = canvas_height - 2; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - if (col == 5 && week_view->compress_weekend) - date_width = week_view->abbr_day_widths[5] - + week_view->slash_width - + week_view->abbr_day_widths[6]; - else if (long_format) - date_width = week_view->day_widths[col]; - else - date_width = week_view->abbr_day_widths[col]; - - date_x = week_view->col_offsets[col] - + (week_view->col_widths[col] - date_width) / 2; - date_x = MAX (date_x, week_view->col_offsets[col]); - gdk_draw_string (drawable, font, fg_gc, - date_x - x, 3 + font->ascent - y, buffer); - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - - /* Draw the lines down the left and right of the date cols. */ - if (col != 0) { - gdk_draw_line (drawable, light_gc, - week_view->col_offsets[col] - x, - 4 - y, - week_view->col_offsets[col] - x, - canvas_height - 4 - y); - - gdk_draw_line (drawable, dark_gc, - week_view->col_offsets[col] - 1 - x, - 4 - y, - week_view->col_offsets[col] - 1 - x, - canvas_height - 4 - y); - } - - /* Draw the lines between each column. */ - if (col != 0) { - gdk_draw_line (drawable, style->black_gc, - week_view->col_offsets[col] - x, - canvas_height - y, - week_view->col_offsets[col] - x, - canvas_height - y); - } - - g_date_add_days (&date, 1); - } -} - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_week_view_titles_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - - diff --git a/calendar/gui/e-week-view-titles-item.h b/calendar/gui/e-week-view-titles-item.h deleted file mode 100644 index 7ce1ccd386..0000000000 --- a/calendar/gui/e-week-view-titles-item.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 _E_WEEK_VIEW_TITLES_ITEM_H_ -#define _E_WEEK_VIEW_TITLES_ITEM_H_ - -#include "e-week-view.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EWeekViewTitlesItem - displays the 'Monday', 'Tuesday' etc. at the top of - * the Month calendar view. - */ - -#define E_WEEK_VIEW_TITLES_ITEM(obj) (GTK_CHECK_CAST((obj), \ - e_week_view_titles_item_get_type (), EWeekViewTitlesItem)) -#define E_WEEK_VIEW_TITLES_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k),\ - e_week_view_titles_item_get_type ())) -#define E_IS_WEEK_VIEW_TITLES_ITEM(o) (GTK_CHECK_TYPE((o), \ - e_week_view_titles_item_get_type ())) - -typedef struct { - GnomeCanvasItem canvas_item; - - /* The parent EWeekView widget. */ - EWeekView *week_view; -} EWeekViewTitlesItem; - -typedef struct { - GnomeCanvasItemClass parent_class; - -} EWeekViewTitlesItemClass; - - -GtkType e_week_view_titles_item_get_type (void); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_WEEK_VIEW_TITLES_ITEM_H_ */ diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c deleted file mode 100644 index faf78db567..0000000000 --- a/calendar/gui/e-week-view.c +++ /dev/null @@ -1,2925 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 - */ - -/* - * EWeekView - displays the Week & Month views of the calendar. - */ - -#include <config.h> -#include <math.h> -#include <gnome.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include "calendar-commands.h" -#include "e-week-view.h" -#include "e-week-view-event-item.h" -#include "e-week-view-main-item.h" -#include "e-week-view-titles-item.h" -#include <cal-util/timeutil.h> -#include "popup-menu.h" -#include "../e-util/e-canvas.h" -#include "../widgets/e-text/e-text.h" -#include "e-util/e-canvas-utils.h" - -/* Images */ -#include "bell.xpm" -#include "recur.xpm" - -#include "jump.xpm" - -#define E_WEEK_VIEW_SMALL_FONT \ - "-adobe-utopia-regular-r-normal-*-*-100-*-*-p-*-iso8859-*" -#define E_WEEK_VIEW_SMALL_FONT_FALLBACK \ - "-adobe-helvetica-medium-r-normal-*-*-80-*-*-p-*-iso8859-*" - -/* We use a 7-bit field to store row numbers in EWeekViewEventSpan, so the - maximum number or rows we can allow is 127. It is very unlikely to be - reached anyway. */ -#define E_WEEK_VIEW_MAX_ROWS_PER_CELL 127 - -#define E_WEEK_VIEW_JUMP_BUTTON_WIDTH 16 -#define E_WEEK_VIEW_JUMP_BUTTON_HEIGHT 8 - -#define E_WEEK_VIEW_JUMP_BUTTON_X_PAD 3 -#define E_WEEK_VIEW_JUMP_BUTTON_Y_PAD 3 - -static void e_week_view_class_init (EWeekViewClass *class); -static void e_week_view_init (EWeekView *week_view); -static void e_week_view_destroy (GtkObject *object); -static void e_week_view_realize (GtkWidget *widget); -static void e_week_view_unrealize (GtkWidget *widget); -static void e_week_view_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static void e_week_view_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void e_week_view_recalc_cell_sizes (EWeekView *week_view); -static gint e_week_view_focus_in (GtkWidget *widget, - GdkEventFocus *event); -static gint e_week_view_focus_out (GtkWidget *widget, - GdkEventFocus *event); -static gint e_week_view_expose_event (GtkWidget *widget, - GdkEventExpose *event); -static void e_week_view_draw (GtkWidget *widget, - GdkRectangle *area); -static void e_week_view_draw_shadow (EWeekView *week_view); - -static gboolean e_week_view_on_button_press (GtkWidget *widget, - GdkEventButton *event, - EWeekView *week_view); -static gboolean e_week_view_on_button_release (GtkWidget *widget, - GdkEventButton *event, - EWeekView *week_view); -static gboolean e_week_view_on_motion (GtkWidget *widget, - GdkEventMotion *event, - EWeekView *week_view); -static gint e_week_view_convert_position_to_day (EWeekView *week_view, - gint x, - gint y); -static void e_week_view_update_selection (EWeekView *week_view, - gint day); - -static void e_week_view_reload_events (EWeekView *week_view); -static void e_week_view_free_events (EWeekView *week_view); -static gboolean e_week_view_add_event (CalComponent *comp, - time_t start, - time_t end, - gpointer data); -static void e_week_view_check_layout (EWeekView *week_view); -static void e_week_view_layout_events (EWeekView *week_view); -static void e_week_view_layout_event (EWeekView *week_view, - EWeekViewEvent *event, - guint8 *grid, - GArray *spans); -static void e_week_view_ensure_events_sorted (EWeekView *week_view); -static gint e_week_view_event_sort_func (const void *arg1, - const void *arg2); -static void e_week_view_reshape_events (EWeekView *week_view); -static void e_week_view_reshape_event_span (EWeekView *week_view, - gint event_num, - gint span_num); -static gint e_week_view_find_day (EWeekView *week_view, - time_t time_to_find, - gboolean include_midnight_in_prev_day); -static gint e_week_view_find_span_end (EWeekView *week_view, - gint day); -static void e_week_view_recalc_day_starts (EWeekView *week_view, - time_t lower); -static void e_week_view_on_adjustment_changed (GtkAdjustment *adjustment, - EWeekView *week_view); -static void e_week_view_on_editing_started (EWeekView *week_view, - GnomeCanvasItem *item); -static void e_week_view_on_editing_stopped (EWeekView *week_view, - GnomeCanvasItem *item); -static gboolean e_week_view_find_event_from_item (EWeekView *week_view, - GnomeCanvasItem *item, - gint *event_num, - gint *span_num); -static gboolean e_week_view_find_event_from_uid (EWeekView *week_view, - const gchar *uid, - gint *event_num_return); -typedef gboolean (* EWeekViewForeachEventCallback) (EWeekView *week_view, - gint event_num, - gpointer data); - -static void e_week_view_foreach_event_with_uid (EWeekView *week_view, - const gchar *uid, - EWeekViewForeachEventCallback callback, - gpointer data); -static gboolean e_week_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *event, - EWeekView *week_view); -static gboolean e_week_view_on_jump_button_event (GnomeCanvasItem *item, - GdkEvent *event, - EWeekView *week_view); -static gint e_week_view_key_press (GtkWidget *widget, GdkEventKey *event); -static void e_week_view_on_new_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_edit_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_delete_occurrence (GtkWidget *widget, - gpointer data); -static void e_week_view_on_delete_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_unrecur_appointment (GtkWidget *widget, - gpointer data); - -static gboolean e_week_view_update_event_cb (EWeekView *week_view, - gint event_num, - gpointer data); -static gboolean e_week_view_remove_event_cb (EWeekView *week_view, - gint event_num, - gpointer data); - -static GtkTableClass *parent_class; - - -GtkType -e_week_view_get_type (void) -{ - static GtkType e_week_view_type = 0; - - if (!e_week_view_type){ - GtkTypeInfo e_week_view_info = { - "EWeekView", - sizeof (EWeekView), - sizeof (EWeekViewClass), - (GtkClassInitFunc) e_week_view_class_init, - (GtkObjectInitFunc) e_week_view_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - parent_class = gtk_type_class (GTK_TYPE_TABLE); - e_week_view_type = gtk_type_unique (GTK_TYPE_TABLE, - &e_week_view_info); - } - - return e_week_view_type; -} - - -static void -e_week_view_class_init (EWeekViewClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - /* Method override */ - object_class->destroy = e_week_view_destroy; - - widget_class->realize = e_week_view_realize; - widget_class->unrealize = e_week_view_unrealize; - widget_class->style_set = e_week_view_style_set; - widget_class->size_allocate = e_week_view_size_allocate; - widget_class->focus_in_event = e_week_view_focus_in; - widget_class->focus_out_event = e_week_view_focus_out; - widget_class->key_press_event = e_week_view_key_press; - widget_class->expose_event = e_week_view_expose_event; - widget_class->draw = e_week_view_draw; -} - - -static void -e_week_view_init (EWeekView *week_view) -{ - GdkColormap *colormap; - gboolean success[E_WEEK_VIEW_COLOR_LAST]; - gint nfailed; - GnomeCanvasGroup *canvas_group; - GtkObject *adjustment; - GdkPixbuf *pixbuf; - gint i; - - GTK_WIDGET_SET_FLAGS (week_view, GTK_CAN_FOCUS); - - colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view)); - - week_view->calendar = NULL; - - week_view->events = g_array_new (FALSE, FALSE, - sizeof (EWeekViewEvent)); - week_view->events_sorted = TRUE; - week_view->events_need_layout = FALSE; - week_view->events_need_reshape = FALSE; - - week_view->spans = NULL; - - week_view->display_month = FALSE; - week_view->rows = 6; - week_view->columns = 2; - week_view->compress_weekend = TRUE; - - g_date_clear (&week_view->base_date, 1); - g_date_clear (&week_view->first_day_shown, 1); - - week_view->row_height = 10; - week_view->rows_per_cell = 1; - - week_view->selection_start_day = -1; - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE; - - week_view->pressed_event_num = -1; - week_view->editing_event_num = -1; - week_view->editing_new_event = FALSE; - - /* Create the small font. */ - week_view->use_small_font = TRUE; - week_view->small_font = gdk_font_load (E_WEEK_VIEW_SMALL_FONT); - if (!week_view->small_font) - week_view->small_font = gdk_font_load (E_WEEK_VIEW_SMALL_FONT_FALLBACK); - if (!week_view->small_font) - g_warning ("Couldn't load font"); - - /* Allocate the colors. */ - week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].red = 0xeded; - week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].green = 0xeded; - week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].blue = 0xeded; - - week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].red = 65535; - week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].green = 65535; - week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].blue = 65535; - - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].red = 0xd6d6; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green = 0xd6d6; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].blue = 0xd6d6; - - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].red = 0; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].green = 0; - week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].blue = 0; - - nfailed = gdk_colormap_alloc_colors (colormap, week_view->colors, - E_WEEK_VIEW_COLOR_LAST, FALSE, - TRUE, success); - if (nfailed) - g_warning ("Failed to allocate all colors"); - - - /* - * Titles Canvas. Note that we don't show it is only shown in the - * Month view. - */ - week_view->titles_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (week_view), week_view->titles_canvas, - 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->titles_canvas)->root); - - week_view->titles_canvas_item = - gnome_canvas_item_new (canvas_group, - e_week_view_titles_item_get_type (), - "EWeekViewTitlesItem::week_view", week_view, - NULL); - - /* - * Main Canvas - */ - week_view->main_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (week_view), week_view->main_canvas, - 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1); - gtk_widget_show (week_view->main_canvas); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root); - - week_view->main_canvas_item = - gnome_canvas_item_new (canvas_group, - e_week_view_main_item_get_type (), - "EWeekViewMainItem::week_view", week_view, - NULL); - - gtk_signal_connect_after (GTK_OBJECT (week_view->main_canvas), - "button_press_event", - GTK_SIGNAL_FUNC (e_week_view_on_button_press), - week_view); - gtk_signal_connect_after (GTK_OBJECT (week_view->main_canvas), - "button_release_event", - GTK_SIGNAL_FUNC (e_week_view_on_button_release), - week_view); - gtk_signal_connect_after (GTK_OBJECT (week_view->main_canvas), - "motion_notify_event", - GTK_SIGNAL_FUNC (e_week_view_on_motion), - week_view); - - /* Create the buttons to jump to each days. */ - pixbuf = gdk_pixbuf_new_from_xpm_data ((const char**) jump_xpm); - - for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) { - week_view->jump_buttons[i] = gnome_canvas_item_new - (canvas_group, - gnome_canvas_pixbuf_get_type (), - "GnomeCanvasPixbuf::pixbuf", pixbuf, - NULL); - - gtk_signal_connect (GTK_OBJECT (week_view->jump_buttons[i]), - "event", - GTK_SIGNAL_FUNC (e_week_view_on_jump_button_event), - week_view); - } - - - /* - * Scrollbar. - */ - adjustment = gtk_adjustment_new (0, -52, 52, 1, 1, 1); - gtk_signal_connect (adjustment, "value_changed", - GTK_SIGNAL_FUNC (e_week_view_on_adjustment_changed), - week_view); - - week_view->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (adjustment)); - gtk_table_attach (GTK_TABLE (week_view), week_view->vscrollbar, - 2, 3, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (week_view->vscrollbar); - - - /* Create the pixmaps. */ - week_view->reminder_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &week_view->reminder_mask, NULL, bell_xpm); - week_view->recurrence_icon = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &week_view->recurrence_mask, NULL, recur_xpm); - - - /* Create the cursors. */ - week_view->normal_cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW); - week_view->move_cursor = gdk_cursor_new (GDK_FLEUR); - week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); - week_view->last_cursor_set = NULL; -} - - -/** - * e_week_view_new: - * @Returns: a new #EWeekView. - * - * Creates a new #EWeekView. - **/ -GtkWidget * -e_week_view_new (void) -{ - GtkWidget *week_view; - - week_view = GTK_WIDGET (gtk_type_new (e_week_view_get_type ())); - - return week_view; -} - - -static void -e_week_view_destroy (GtkObject *object) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (object); - - /* FIXME: free the colors. In EDayView as well. */ - /* FIXME: free the events and the spans. In EDayView as well? */ - - if (week_view->small_font) - gdk_font_unref (week_view->small_font); - - gdk_cursor_destroy (week_view->normal_cursor); - gdk_cursor_destroy (week_view->move_cursor); - gdk_cursor_destroy (week_view->resize_width_cursor); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -static void -e_week_view_realize (GtkWidget *widget) -{ - EWeekView *week_view; - - if (GTK_WIDGET_CLASS (parent_class)->realize) - (*GTK_WIDGET_CLASS (parent_class)->realize)(widget); - - week_view = E_WEEK_VIEW (widget); - week_view->main_gc = gdk_gc_new (widget->window); -} - - -static void -e_week_view_unrealize (GtkWidget *widget) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (widget); - - gdk_gc_unref (week_view->main_gc); - week_view->main_gc = NULL; - - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget); -} - - -static void -e_week_view_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - EWeekView *week_view; - GdkFont *font; - gint day, day_width, max_day_width, max_abbr_day_width; - gint month, month_width, max_month_width, max_abbr_month_width; - GDate date; - gchar buffer[128]; - - if (GTK_WIDGET_CLASS (parent_class)->style_set) - (*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style); - - week_view = E_WEEK_VIEW (widget); - font = widget->style->font; - - /* Recalculate the height of each row based on the font size. */ - week_view->row_height = font->ascent + font->descent + E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2 + E_WEEK_VIEW_EVENT_TEXT_Y_PAD * 2; - week_view->row_height = MAX (week_view->row_height, E_WEEK_VIEW_ICON_HEIGHT + E_WEEK_VIEW_ICON_Y_PAD + E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2); - - /* Set the height of the top canvas. */ - gtk_widget_set_usize (week_view->titles_canvas, -1, - font->ascent + font->descent + 5); - - /* Save the sizes of various strings in the font, so we can quickly - decide which date formats to use. */ - g_date_clear (&date, 1); - g_date_set_dmy (&date, 27, 3, 2000); /* Must be a Monday. */ - - max_day_width = 0; - max_abbr_day_width = 0; - for (day = 0; day < 7; day++) { - g_date_strftime (buffer, 128, "%A", &date); - day_width = gdk_string_width (font, buffer); - week_view->day_widths[day] = day_width; - max_day_width = MAX (max_day_width, day_width); - - g_date_strftime (buffer, 128, "%a", &date); - day_width = gdk_string_width (font, buffer); - week_view->abbr_day_widths[day] = day_width; - max_abbr_day_width = MAX (max_abbr_day_width, day_width); - - g_date_add_days (&date, 1); - } - - max_month_width = 0; - max_abbr_month_width = 0; - for (month = 0; month < 12; month++) { - g_date_set_month (&date, month + 1); - - g_date_strftime (buffer, 128, "%B", &date); - month_width = gdk_string_width (font, buffer); - week_view->month_widths[month] = month_width; - max_month_width = MAX (max_month_width, month_width); - - g_date_strftime (buffer, 128, "%b", &date); - month_width = gdk_string_width (font, buffer); - week_view->abbr_month_widths[month] = month_width; - max_abbr_month_width = MAX (max_abbr_month_width, month_width); - } - - week_view->space_width = gdk_string_width (font, " "); - week_view->colon_width = gdk_string_width (font, ":"); - week_view->slash_width = gdk_string_width (font, "/"); - week_view->digit_width = gdk_string_width (font, "5"); - if (week_view->small_font) - week_view->small_digit_width = gdk_string_width (week_view->small_font, "5"); - week_view->max_day_width = max_day_width; - week_view->max_abbr_day_width = max_abbr_day_width; - week_view->max_month_width = max_month_width; - week_view->max_abbr_month_width = max_abbr_month_width; -} - - -/* This recalculates the sizes of each column. */ -static void -e_week_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - EWeekView *week_view; - gint width, height, time_width; - gdouble old_x2, old_y2, new_x2, new_y2; - GdkFont *font; - - week_view = E_WEEK_VIEW (widget); - font = widget->style->font; - - (*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); - - e_week_view_recalc_cell_sizes (week_view); - - /* Calculate the number of rows of events in each cell, for the large - cells and the compressed weekend cells. */ - if (week_view->display_month) { - week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD - + font->ascent + font->descent - + E_WEEK_VIEW_DATE_B_PAD; - } else { - week_view->events_y_offset = E_WEEK_VIEW_DATE_T_PAD - + font->ascent + font->descent - + E_WEEK_VIEW_DATE_LINE_T_PAD + 1 - + E_WEEK_VIEW_DATE_LINE_B_PAD; - } - - height = week_view->row_heights[0]; - week_view->rows_per_cell = (height * 2 - week_view->events_y_offset) - / (week_view->row_height + E_WEEK_VIEW_EVENT_Y_SPACING); - week_view->rows_per_cell = MIN (week_view->rows_per_cell, - E_WEEK_VIEW_MAX_ROWS_PER_CELL); - - week_view->rows_per_compressed_cell = - (height - week_view->events_y_offset) - / (week_view->row_height + E_WEEK_VIEW_EVENT_Y_SPACING); - week_view->rows_per_compressed_cell = MIN (week_view->rows_per_compressed_cell, - E_WEEK_VIEW_MAX_ROWS_PER_CELL); - - /* Determine which time format to use, based on the width of the cells. - We only allow the time to take up about half of the width. */ - width = week_view->col_widths[0]; - - week_view->time_format = E_WEEK_VIEW_TIME_NONE; - if (week_view->use_small_font && week_view->small_font) { - time_width = week_view->digit_width * 2 - + week_view->small_digit_width * 2; - if (width / 2 > time_width * 2 + week_view->space_width) - week_view->time_format = E_WEEK_VIEW_TIME_BOTH_SMALL_MIN; - else if (width / 2 > time_width) - week_view->time_format = E_WEEK_VIEW_TIME_START_SMALL_MIN; - } else { - time_width = week_view->digit_width * 4 - + week_view->colon_width; - if (width / 2 > time_width * 2 + week_view->space_width) - week_view->time_format = E_WEEK_VIEW_TIME_BOTH; - else if (width / 2 > time_width) - week_view->time_format = E_WEEK_VIEW_TIME_START; - } - - /* Set the scroll region of the top canvas to its allocated size. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (week_view->titles_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = week_view->titles_canvas->allocation.width - 1; - new_y2 = week_view->titles_canvas->allocation.height - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (week_view->titles_canvas), - 0, 0, new_x2, new_y2); - - - /* Set the scroll region of the main canvas to its allocated width, - but with the height depending on the number of rows needed. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (week_view->main_canvas), - NULL, NULL, &old_x2, &old_y2); - new_x2 = week_view->main_canvas->allocation.width - 1; - new_y2 = week_view->main_canvas->allocation.height - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (week_view->main_canvas), - 0, 0, new_x2, new_y2); - - /* Flag that we need to reshape the events. */ - if (old_x2 != new_x2 || old_y2 != new_y2) { - week_view->events_need_reshape = TRUE; - e_week_view_check_layout (week_view); - } -} - - -static void -e_week_view_recalc_cell_sizes (EWeekView *week_view) -{ - gfloat width, height, offset; - gint row, col; - - if (week_view->display_month) { - week_view->rows = 10; - week_view->columns = 6; - } else { - week_view->rows = 6; - week_view->columns = 2; - } - - /* Calculate the column sizes, using floating point so that pixels - get divided evenly. Note that we use one more element than the - number of columns, to make it easy to get the column widths. - We also add one to the width so that the right border of the last - column is off the edge of the displayed area. */ - width = week_view->main_canvas->allocation.width + 1; - width /= week_view->columns; - offset = 0; - for (col = 0; col <= week_view->columns; col++) { - week_view->col_offsets[col] = floor (offset + 0.5); - offset += width; - } - - /* Calculate the cell widths based on the offsets. */ - for (col = 0; col < week_view->columns; col++) { - week_view->col_widths[col] = week_view->col_offsets[col + 1] - - week_view->col_offsets[col]; - } - - /* Now do the same for the row heights. */ - height = week_view->main_canvas->allocation.height + 1; - height /= week_view->rows; - offset = 0; - for (row = 0; row <= week_view->rows; row++) { - week_view->row_offsets[row] = floor (offset + 0.5); - offset += height; - } - - /* Calculate the cell heights based on the offsets. */ - for (row = 0; row < week_view->rows; row++) { - week_view->row_heights[row] = week_view->row_offsets[row + 1] - - week_view->row_offsets[row]; - } -} - - -static gint -e_week_view_focus_in (GtkWidget *widget, GdkEventFocus *event) -{ - EWeekView *week_view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - week_view = E_WEEK_VIEW (widget); - - GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); - - gtk_widget_queue_draw (week_view->main_canvas); - - return FALSE; -} - - -static gint -e_week_view_focus_out (GtkWidget *widget, GdkEventFocus *event) -{ - EWeekView *week_view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - week_view = E_WEEK_VIEW (widget); - - GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - - gtk_widget_queue_draw (week_view->main_canvas); - - return FALSE; -} - - -/* This draws a shadow around the top display and main display. */ -static gint -e_week_view_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (widget); - - e_week_view_draw_shadow (week_view); - - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - (*GTK_WIDGET_CLASS (parent_class)->expose_event)(widget, event); - - return FALSE; -} - - -static void -e_week_view_draw (GtkWidget *widget, - GdkRectangle *area) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (widget); - - e_week_view_draw_shadow (week_view); - - if (GTK_WIDGET_CLASS (parent_class)->draw) - (*GTK_WIDGET_CLASS (parent_class)->draw)(widget, area); -} - - -static void -e_week_view_draw_shadow (EWeekView *week_view) -{ - gint x1, y1, x2, y2; - GtkStyle *style; - GdkGC *light_gc, *dark_gc; - GdkWindow *window; - - /* Draw the shadow around the graphical displays. */ - x1 = week_view->main_canvas->allocation.x - 1; - y1 = week_view->main_canvas->allocation.y - 1; - x2 = x1 + week_view->main_canvas->allocation.width + 2; - y2 = y1 + week_view->main_canvas->allocation.height + 2; - - style = GTK_WIDGET (week_view)->style; - dark_gc = style->dark_gc[GTK_STATE_NORMAL]; - light_gc = style->light_gc[GTK_STATE_NORMAL]; - - window = GTK_WIDGET (week_view)->window; - gdk_draw_line (window, dark_gc, x1, y1, x1, y2); - gdk_draw_line (window, dark_gc, x1, y1, x2, y1); - gdk_draw_line (window, light_gc, x2, y1, x2, y2); - gdk_draw_line (window, light_gc, x1, y2, x2, y2); -} - - -void -e_week_view_set_calendar (EWeekView *week_view, - GnomeCalendar *calendar) -{ - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - week_view->calendar = calendar; - - /* FIXME: free current events? */ -} - - -/* This sets the selected time range. The EWeekView will show the corresponding - month and the days between start_time and end_time will be selected. - To select a single day, use the same value for start_time & end_time. */ -void -e_week_view_set_selected_time_range (EWeekView *week_view, - time_t start_time, - time_t end_time) -{ - GDate date, base_date, end_date; - gint day_offset, num_days; - gboolean update_adjustment_value = FALSE; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - g_date_clear (&date, 1); - g_date_set_time (&date, start_time); - - if (week_view->display_month) { - /* Find the number of days since the start of the month. */ - day_offset = g_date_day (&date) - 1; - - /* Find the 1st Monday at or before the start of the month. */ - base_date = date; - g_date_set_day (&base_date, 1); - day_offset += g_date_weekday (&base_date) - 1; - } else { - /* Find the 1st Monday at or before the given day. */ - day_offset = g_date_weekday (&date) - 1; - } - - /* Calculate the base date, i.e. the first day shown when the - scrollbar adjustment value is 0. */ - base_date = date; - g_date_subtract_days (&base_date, day_offset); - - /* See if we need to update the base date. */ - if (!g_date_valid (&week_view->base_date) - || g_date_compare (&week_view->base_date, &base_date)) { - week_view->base_date = base_date; - update_adjustment_value = TRUE; - } - - /* See if we need to update the first day shown. */ - if (!g_date_valid (&week_view->first_day_shown) - || g_date_compare (&week_view->first_day_shown, &base_date)) { - week_view->first_day_shown = base_date; - start_time = time_add_day (start_time, -day_offset); - start_time = time_day_begin (start_time); - e_week_view_recalc_day_starts (week_view, start_time); - e_week_view_reload_events (week_view); - } - - /* Set the selection to the given days. */ - week_view->selection_start_day = g_date_julian (&date) - - g_date_julian (&base_date); - if (end_time == start_time - || end_time <= time_add_day (start_time, 1)) - week_view->selection_end_day = week_view->selection_start_day; - else { - g_date_clear (&end_date, 1); - g_date_set_time (&end_date, end_time - 60); - week_view->selection_end_day = g_date_julian (&end_date) - - g_date_julian (&base_date); - } - - /* Make sure the selection is valid. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - num_days--; - week_view->selection_start_day = CLAMP (week_view->selection_start_day, - 0, num_days); - week_view->selection_end_day = CLAMP (week_view->selection_end_day, - week_view->selection_start_day, - num_days); - - /* Reset the adjustment value to 0 if the base address has changed. - Note that we do this after updating first_day_shown so that our - signal handler will not try to reload the events. */ - if (update_adjustment_value) - gtk_adjustment_set_value (GTK_RANGE (week_view->vscrollbar)->adjustment, 0); - - - gtk_widget_queue_draw (week_view->main_canvas); -} - - -/* Returns the selected time range. */ -void -e_week_view_get_selected_time_range (EWeekView *week_view, - time_t *start_time, - time_t *end_time) -{ - gint start_day, end_day; - - start_day = week_view->selection_start_day; - end_day = week_view->selection_end_day; - - if (start_day == -1) { - start_day = 0; - end_day = 0; - } - - if (start_time) - *start_time = week_view->day_starts[start_day]; - - if (end_time) - *end_time = week_view->day_starts[end_day + 1]; -} - - -/* Recalculates the time_t corresponding to the start of each day. */ -static void -e_week_view_recalc_day_starts (EWeekView *week_view, - time_t lower) -{ - gint num_days, day; - time_t tmp_time; - - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - - tmp_time = lower; - week_view->day_starts[0] = tmp_time; - for (day = 1; day <= num_days; day++) { - /* FIXME: There is a bug in time_add_day(). */ -#if 0 - g_print ("Day:%i - %s\n", day, ctime (&tmp_time)); -#endif - tmp_time = time_add_day (tmp_time, 1); - week_view->day_starts[day] = tmp_time; - } -} - - -gboolean -e_week_view_get_display_month (EWeekView *week_view) -{ - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - - return week_view->display_month; -} - - -void -e_week_view_set_display_month (EWeekView *week_view, - gboolean display_month) -{ - GtkAdjustment *adjustment; - gint page_increment, page_size; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (week_view->display_month == display_month) - return; - - week_view->display_month = display_month; - - if (display_month) { - gtk_widget_show (week_view->titles_canvas); - page_increment = 4; - page_size = 5; - } else { - gtk_widget_hide (week_view->titles_canvas); - page_increment = page_size = 1; - } - - adjustment = GTK_RANGE (week_view->vscrollbar)->adjustment; - adjustment->page_increment = page_increment; - adjustment->page_size = page_size; - gtk_adjustment_changed (adjustment); - - /* FIXME: Need to change start date and adjustment value? */ - - e_week_view_recalc_day_starts (week_view, week_view->day_starts[0]); - e_week_view_recalc_cell_sizes (week_view); - e_week_view_reload_events (week_view); -} - - -gboolean -e_week_view_get_compress_weekend (EWeekView *week_view) -{ - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - - return week_view->compress_weekend; -} - - -void -e_week_view_set_compress_weekend (EWeekView *week_view, - gboolean compress) -{ - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (week_view->compress_weekend == compress) - return; - - week_view->compress_weekend = compress; - - /* The option only affects the month view. */ - if (!week_view->display_month) - return; - - /* FIXME: Need to update layout. */ -} - - -/* This reloads all calendar events. */ -void -e_week_view_update_all_events (EWeekView *week_view) -{ - e_week_view_reload_events (week_view); -} - - -/* This is called when one event has been added or updated. */ -void -e_week_view_update_event (EWeekView *week_view, - const gchar *uid) -{ - EWeekViewEvent *event; - gint event_num, num_days; - CalComponent *comp; - CalClientGetStatus status; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - -#if 0 - g_print ("In e_week_view_update_event\n"); -#endif - - /* If we don't have a calendar or valid date set yet, just return. */ - if (!week_view->calendar - || !g_date_valid (&week_view->first_day_shown)) - return; - - /* Get the event from the server. */ - status = cal_client_get_object (week_view->calendar->client, uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* Do nothing. */ - break; - case CAL_CLIENT_GET_SYNTAX_ERROR: - g_warning ("syntax error uid=%s\n", uid); - return; - case CAL_CLIENT_GET_NOT_FOUND: - g_warning ("obj not found uid=%s\n", uid); - return; - } - - /* We only care about events. */ - if (comp && cal_component_get_vtype (comp) != CAL_COMPONENT_EVENT) { - gtk_object_unref (GTK_OBJECT (comp)); - return; - } - - /* If the event already exists and the dates didn't change, we can - update the event fairly easily without changing the events arrays - or computing a new layout. */ - if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) { -#warning "FIX ME" - /* Do this the long way every time for now */ -#if 0 - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - if (ical_object_compare_dates (event->ico, ico)) { - e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, comp); - gtk_object_unref (GTK_OBJECT (comp)); - gtk_widget_queue_draw (week_view->main_canvas); - return; - } -#endif - /* The dates have changed, so we need to remove the - old occurrrences before adding the new ones. */ - e_week_view_foreach_event_with_uid (week_view, uid, - e_week_view_remove_event_cb, - NULL); - } - - /* Add the occurrences of the event. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - - cal_recur_generate_instances (comp, - week_view->day_starts[0], - week_view->day_starts[num_days], - e_week_view_add_event, - week_view); - - gtk_object_unref (GTK_OBJECT (comp)); - - e_week_view_check_layout (week_view); - - gtk_widget_queue_draw (week_view->main_canvas); -} - - -static gboolean -e_week_view_update_event_cb (EWeekView *week_view, - gint event_num, - gpointer data) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint span_num; - gchar *text; - CalComponent *comp; - - comp = data; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - event->comp = comp; - gtk_object_ref (GTK_OBJECT (comp)); - - /* If we are editing an event which we have just created, we will get - an update_event callback from the server. But we need to ignore it - or we will lose the text the user has already typed in. */ - if (week_view->editing_new_event - && week_view->editing_event_num == event_num) { - return TRUE; - } - - for (span_num = 0; span_num < event->num_spans; span_num++) { - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - if (span->text_item) { - CalComponentText t; - - cal_component_get_summary (event->comp, &t); - text = g_strdup (t.value); - gnome_canvas_item_set (span->text_item, - "text", text ? text : "", - NULL); - g_free (text); - - e_week_view_reshape_event_span (week_view, event_num, - span_num); - } - } - - return TRUE; -} - - -/* This calls a given function for each event instance that matches the given - uid. Note that it is safe for the callback to remove the event (since we - step backwards through the arrays). */ -static void -e_week_view_foreach_event_with_uid (EWeekView *week_view, - const gchar *uid, - EWeekViewForeachEventCallback callback, - gpointer data) -{ - EWeekViewEvent *event; - gint event_num; - - for (event_num = week_view->events->len - 1; - event_num >= 0; - event_num--) { - const char *u; - - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - if (!(*callback) (week_view, event_num, data)) - return; - } - } -} - - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void -e_week_view_remove_event (EWeekView *week_view, - const gchar *uid) -{ - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - e_week_view_foreach_event_with_uid (week_view, uid, - e_week_view_remove_event_cb, NULL); - - e_week_view_check_layout (week_view); - gtk_widget_queue_draw (week_view->main_canvas); -} - - -static gboolean -e_week_view_remove_event_cb (EWeekView *week_view, - gint event_num, - gpointer data) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint span_num; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - - /* If we were editing this event, set editing_event_num to -1 so - on_editing_stopped doesn't try to update the event. */ - if (week_view->editing_event_num == event_num) - week_view->editing_event_num = -1; - - /* We leave the span elements in the array, but set the canvas item - pointers to NULL. */ - for (span_num = 0; span_num < event->num_spans; span_num++) { - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - if (span->text_item) { - gtk_object_destroy (GTK_OBJECT (span->text_item)); - span->text_item = NULL; - } - if (span->background_item) { - gtk_object_destroy (GTK_OBJECT (span->background_item)); - span->background_item = NULL; - } - } - - gtk_object_unref (GTK_OBJECT (event->comp)); - - g_array_remove_index (week_view->events, event_num); - week_view->events_need_layout = TRUE; - - return TRUE; -} - - -void -e_week_view_get_day_position (EWeekView *week_view, - gint day, - gint *day_x, - gint *day_y, - gint *day_w, - gint *day_h) -{ - gint week, day_of_week, row; - - *day_x = *day_y = *day_w = *day_h = 0; - g_return_if_fail (day >= 0); - - if (week_view->display_month) { - g_return_if_fail (day < E_WEEK_VIEW_MAX_WEEKS * 7); - - week = day / 7; - day_of_week = day % 7; - if (week_view->compress_weekend && day_of_week >= 5) { - /* In the compressed view Saturday is above Sunday and - both have just one row as opposed to 2 for all the - other days. */ - if (day_of_week == 5) { - *day_y = week_view->row_offsets[week * 2]; - *day_h = week_view->row_heights[week * 2]; - } else { - *day_y = week_view->row_offsets[week * 2 + 1]; - *day_h = week_view->row_heights[week * 2 + 1]; - } - /* Both Saturday and Sunday are in the 6th column. */ - *day_x = week_view->col_offsets[5]; - *day_w = week_view->col_widths[5]; - } else { - *day_y = week_view->row_offsets[week * 2]; - *day_h = week_view->row_heights[week * 2] - + week_view->row_heights[week * 2 + 1]; - *day_x = week_view->col_offsets[day_of_week]; - *day_w = week_view->col_widths[day_of_week]; - } - } else { - g_return_if_fail (day < 7); - - /* The week view has Mon, Tue & Wed down the left column and - Thu, Fri & Sat/Sun down the right. */ - if (day < 3) { - *day_x = week_view->col_offsets[0]; - *day_w = week_view->col_widths[0]; - } else { - *day_x = week_view->col_offsets[1]; - *day_w = week_view->col_widths[1]; - } - - if (day < 5) { - row = (day % 3) * 2; - *day_y = week_view->row_offsets[row]; - *day_h = week_view->row_heights[row] - + week_view->row_heights[row + 1]; - } else { - /* Saturday & Sunday. */ - *day_y = week_view->row_offsets[day - 1]; - *day_h = week_view->row_heights[day - 1]; - } - } -} - - -/* Returns the bounding box for a span of an event. Usually this can easily - be determined by the start & end days and row of the span, which are set in - e_week_view_layout_event(). Though we need a special case for the weekends - when they are compressed, since the span may not fit. */ -gboolean -e_week_view_get_span_position (EWeekView *week_view, - gint event_num, - gint span_num, - gint *span_x, - gint *span_y, - gint *span_w) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint end_day_of_week, num_days; - gint start_x, start_y, start_w, start_h; - gint end_x, end_y, end_w, end_h; - - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); - g_return_val_if_fail (event_num < week_view->events->len, FALSE); - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - - g_return_val_if_fail (span_num < event->num_spans, FALSE); - - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - if (span->row >= week_view->rows_per_cell) - return FALSE; - - end_day_of_week = (span->start_day + span->num_days - 1) % 7; - num_days = span->num_days; - /* Check if the row will not be visible in compressed cells. */ - if (span->row >= week_view->rows_per_compressed_cell) { - if (week_view->display_month) { - if (week_view->compress_weekend) { - /* If it ends on a Saturday and is 1 day long - we skip it, else we shorten it. If it ends - on a Sunday it must be 1 day long and we - skip it. */ - if (end_day_of_week == 5) { /* Sat */ - if (num_days == 1) { - return FALSE; - } else { - num_days--; - } - } else if (end_day_of_week == 6) { /* Sun */ - return FALSE; - } - } - } else { - /* All spans are 1 day long in the week view, so we - just skip it. */ - if (end_day_of_week > 4) - return FALSE; - } - } - - e_week_view_get_day_position (week_view, span->start_day, - &start_x, &start_y, &start_w, &start_h); - *span_y = start_y + week_view->events_y_offset - + span->row * (week_view->row_height - + E_WEEK_VIEW_EVENT_Y_SPACING); - if (num_days == 1) { - *span_x = start_x; - *span_w = start_w; - } else { - e_week_view_get_day_position (week_view, - span->start_day + num_days - 1, - &end_x, &end_y, &end_w, &end_h); - *span_x = start_x; - *span_w = end_x - start_x + end_w; - } - - return TRUE; -} - - - -static gboolean -e_week_view_on_button_press (GtkWidget *widget, - GdkEventButton *event, - EWeekView *week_view) -{ - gint x, y, day; - -#if 0 - g_print ("In e_week_view_on_button_press\n"); -#endif - - /* Handle scroll wheel events */ - if (event->button == 4 || event->button == 5) { - GtkAdjustment *adj = GTK_RANGE (week_view->vscrollbar)->adjustment; - gfloat new_value; - - new_value = adj->value + ((event->button == 4) ? - -adj->page_increment: - adj->page_increment); - new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size); - gtk_adjustment_set_value (adj, new_value); - - return TRUE; - } - - /* If an event is pressed just return. */ - if (week_view->pressed_event_num != -1) - return FALSE; - - /* Convert the mouse position to a week & day. */ - x = event->x; - y = event->y; - day = e_week_view_convert_position_to_day (week_view, x, y); - if (day == -1) - return FALSE; - - /* Start the selection drag. */ - if (event->button == 1) { - if (!GTK_WIDGET_HAS_FOCUS (week_view)) - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - - if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE, - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - FALSE, NULL, event->time) == 0) { - week_view->selection_start_day = day; - week_view->selection_end_day = day; - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_END; - - /* FIXME: Optimise? */ - gtk_widget_queue_draw (week_view->main_canvas); - } - } else if (event->button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (week_view)) - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - e_week_view_show_popup_menu (week_view, event, -1); - } - - return FALSE; -} - - -static gboolean -e_week_view_on_button_release (GtkWidget *widget, - GdkEventButton *event, - EWeekView *week_view) -{ - time_t start, end; - -#if 0 - g_print ("In e_week_view_on_button_release\n"); -#endif - - if (week_view->selection_drag_pos != E_WEEK_VIEW_DRAG_NONE) { - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE; - gdk_pointer_ungrab (event->time); - start = week_view->day_starts[week_view->selection_start_day]; - end = week_view->day_starts[week_view->selection_end_day + 1]; - gnome_calendar_set_selected_time_range (week_view->calendar, - start, end); - } - - return FALSE; -} - - -static gboolean -e_week_view_on_motion (GtkWidget *widget, - GdkEventMotion *mevent, - EWeekView *week_view) -{ - gint x, y, day; - -#if 0 - g_print ("In e_week_view_on_motion\n"); -#endif - - /* Convert the mouse position to a week & day. */ - x = mevent->x; - y = mevent->y; - day = e_week_view_convert_position_to_day (week_view, x, y); - if (day == -1) - return FALSE; - - if (week_view->selection_drag_pos != E_WEEK_VIEW_DRAG_NONE) { - e_week_view_update_selection (week_view, day); - return TRUE; - } - - return FALSE; -} - - -/* Converts a position in the canvas window to a day offset from the first - day displayed. Returns -1 if the position is outside the grid. */ -static gint -e_week_view_convert_position_to_day (EWeekView *week_view, - gint x, - gint y) -{ - gint col, row, grid_x = -1, grid_y = -1, week, day; - - /* First we convert it to a grid position. */ - for (col = 0; col <= week_view->columns; col++) { - if (x < week_view->col_offsets[col]) { - grid_x = col - 1; - break; - } - } - - for (row = 0; row <= week_view->rows; row++) { - if (y < week_view->row_offsets[row]) { - grid_y = row - 1; - break; - } - } - - /* If the mouse is outside the grid return FALSE. */ - if (grid_x == -1 || grid_y == -1) - return -1; - - /* Now convert the grid position to a week and day. */ - if (week_view->display_month) { - week = grid_y / 2; - if (week_view->compress_weekend && grid_x == 5 - && grid_y % 2 == 1) - day = 6; - else - day = grid_x; - } else { - week = 0; - if (grid_x == 0) - day = grid_y / 2; - else if (grid_y == 5) - day = 6; - else - day = grid_y / 2 + 3; - } - - return week * 7 + day; -} - - -static void -e_week_view_update_selection (EWeekView *week_view, - gint day) -{ - gint tmp_day; - gboolean need_redraw = FALSE; - -#if 0 - g_print ("Updating selection %i,%i\n", week, day); -#endif - - if (week_view->selection_drag_pos == E_WEEK_VIEW_DRAG_START) { - if (day != week_view->selection_start_day) { - need_redraw = TRUE; - week_view->selection_start_day = day; - } - } else { - if (day != week_view->selection_end_day) { - need_redraw = TRUE; - week_view->selection_end_day = day; - } - } - - /* Switch the drag position if necessary. */ - if (week_view->selection_start_day > week_view->selection_end_day) { - tmp_day = week_view->selection_start_day; - week_view->selection_start_day = week_view->selection_end_day; - week_view->selection_end_day = tmp_day; - if (week_view->selection_drag_pos == E_WEEK_VIEW_DRAG_START) - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_END; - else - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_START; - } - - /* FIXME: Optimise? */ - if (need_redraw) { - gtk_widget_queue_draw (week_view->main_canvas); - } -} - - -static void -e_week_view_reload_events (EWeekView *week_view) -{ - gint num_days; - - e_week_view_free_events (week_view); - - if (week_view->calendar - && g_date_valid (&week_view->first_day_shown)) { - num_days = week_view->display_month - ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - - cal_client_generate_instances (week_view->calendar->client, - CALOBJ_TYPE_EVENT, - week_view->day_starts[0], - week_view->day_starts[num_days], - e_week_view_add_event, - week_view); - } - - e_week_view_check_layout (week_view); - - gtk_widget_queue_draw (week_view->main_canvas); -} - - -static void -e_week_view_free_events (EWeekView *week_view) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint event_num, span_num; - - for (event_num = 0; event_num < week_view->events->len; event_num++) { - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - gtk_object_unref (GTK_OBJECT (event->comp)); - } - - g_array_set_size (week_view->events, 0); - - /* Destroy all the old canvas items. */ - if (week_view->spans) { - for (span_num = 0; span_num < week_view->spans->len; - span_num++) { - span = &g_array_index (week_view->spans, - EWeekViewEventSpan, span_num); - if (span->background_item) - gtk_object_destroy (GTK_OBJECT (span->background_item)); - if (span->text_item) - gtk_object_destroy (GTK_OBJECT (span->text_item)); - } - g_array_free (week_view->spans, TRUE); - week_view->spans = NULL; - } -} - - -/* This adds one event to the view, adding it to the appropriate array. */ -static gboolean -e_week_view_add_event (CalComponent *comp, - time_t start, - time_t end, - gpointer data) - -{ - EWeekView *week_view; - EWeekViewEvent event; - gint num_days; - struct tm start_tm, end_tm; - - week_view = E_WEEK_VIEW (data); - - /* Check that the event times are valid. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - -#if 0 - g_print ("View start:%li end:%li Event start:%li end:%li\n", - week_view->day_starts[0], week_view->day_starts[num_days], - start, end); -#endif - - g_return_val_if_fail (start <= end, TRUE); - g_return_val_if_fail (start < week_view->day_starts[num_days], TRUE); - g_return_val_if_fail (end > week_view->day_starts[0], TRUE); - - start_tm = *(localtime (&start)); - end_tm = *(localtime (&end)); - - event.comp = comp; - gtk_object_ref (GTK_OBJECT (event.comp)); - event.start = start; - event.end = end; - event.spans_index = 0; - event.num_spans = 0; - - event.start_minute = start_tm.tm_hour * 60 + start_tm.tm_min; - event.end_minute = end_tm.tm_hour * 60 + end_tm.tm_min; - if (event.end_minute == 0 && start != end) - event.end_minute = 24 * 60; - - g_array_append_val (week_view->events, event); - week_view->events_sorted = FALSE; - week_view->events_need_layout = TRUE; - - return TRUE; -} - - -/* This lays out the events, or reshapes them, as necessary. */ -static void -e_week_view_check_layout (EWeekView *week_view) -{ - /* Don't bother if we aren't visible. */ - if (!GTK_WIDGET_VISIBLE (week_view)) - return; - - /* Make sure the events are sorted (by start and size). */ - e_week_view_ensure_events_sorted (week_view); - - if (week_view->events_need_layout) - e_week_view_layout_events (week_view); - - if (week_view->events_need_layout || week_view->events_need_reshape) - e_week_view_reshape_events (week_view); - - week_view->events_need_layout = FALSE; - week_view->events_need_reshape = FALSE; -} - - -static void -e_week_view_layout_events (EWeekView *week_view) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint num_days, day, event_num, span_num; - guint8 *grid; - GArray *spans, *old_spans; - - /* This is a temporary 2-d grid which is used to place events. - Each element is 0 if the position is empty, or 1 if occupied. - We allocate the maximum size possible here, assuming that each - event will need its own row. */ - grid = g_new0 (guint8, E_WEEK_VIEW_MAX_ROWS_PER_CELL * 7 - * E_WEEK_VIEW_MAX_WEEKS); - - /* We create a new array of spans, which will replace the old one. */ - spans = g_array_new (FALSE, FALSE, sizeof (EWeekViewEventSpan)); - - /* Clear the number of rows used per day. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - for (day = 0; day <= num_days; day++) { - week_view->rows_per_day[day] = 0; - } - - /* Iterate over the events, finding which weeks they cover, and putting - them in the first free row available. */ - for (event_num = 0; event_num < week_view->events->len; event_num++) { - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - e_week_view_layout_event (week_view, event, grid, spans); - } - - /* Free the grid. */ - g_free (grid); - - /* Replace the spans array. */ - old_spans = week_view->spans; - week_view->spans = spans; - - /* Destroy the old spans array, destroying any unused canvas items. */ - if (old_spans) { - for (span_num = 0; span_num < old_spans->len; span_num++) { - span = &g_array_index (old_spans, EWeekViewEventSpan, - span_num); - if (span->background_item) - gtk_object_destroy (GTK_OBJECT (span->background_item)); - if (span->text_item) - gtk_object_destroy (GTK_OBJECT (span->text_item)); - } - g_array_free (old_spans, TRUE); - } -} - - -static void -e_week_view_layout_event (EWeekView *week_view, - EWeekViewEvent *event, - guint8 *grid, - GArray *spans) -{ - gint start_day, end_day, span_start_day, span_end_day, rows_per_cell; - gint free_row, row, day, span_num, spans_index, num_spans, max_day; - EWeekViewEventSpan span, *old_span; - - start_day = e_week_view_find_day (week_view, event->start, FALSE); - end_day = e_week_view_find_day (week_view, event->end, TRUE); - max_day = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 - 1 - : 7 - 1; - start_day = CLAMP (start_day, 0, max_day); - end_day = CLAMP (end_day, 0, max_day); - -#if 0 - g_print ("In e_week_view_layout_event Start:%i End: %i\n", - start_day, end_day); -#endif - - /* Iterate through each of the spans of the event, where each span - is a sequence of 1 or more days displayed next to each other. */ - span_start_day = start_day; - rows_per_cell = E_WEEK_VIEW_MAX_ROWS_PER_CELL; - span_num = 0; - spans_index = spans->len; - num_spans = 0; - while (span_start_day <= end_day) { - span_end_day = e_week_view_find_span_end (week_view, - span_start_day); - span_end_day = MIN (span_end_day, end_day); -#if 0 - g_print (" Span start:%i end:%i\n", span_start_day, - span_end_day); -#endif - /* Try each row until we find a free one or we fall off the - bottom of the available rows. */ - row = 0; - free_row = -1; - while (free_row == -1 && row < rows_per_cell) { - free_row = row; - for (day = span_start_day; day <= span_end_day; - day++) { - if (grid[day * rows_per_cell + row]) { - free_row = -1; - break; - } - } - row++; - }; - - if (free_row != -1) { - /* Mark the cells as full. */ - for (day = span_start_day; day <= span_end_day; - day++) { - grid[day * rows_per_cell + free_row] = 1; - week_view->rows_per_day[day] = MAX (week_view->rows_per_day[day], free_row + 1); - } -#if 0 - g_print (" Span start:%i end:%i row:%i\n", - span_start_day, span_end_day, free_row); -#endif - /* Add the span to the array, and try to reuse any - canvas items from the old spans. */ - span.start_day = span_start_day; - span.num_days = span_end_day - span_start_day + 1; - span.row = free_row; - span.background_item = NULL; - span.text_item = NULL; - if (event->num_spans > span_num) { - old_span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num); - span.background_item = old_span->background_item; - span.text_item = old_span->text_item; - old_span->background_item = NULL; - old_span->text_item = NULL; - } - - g_array_append_val (spans, span); - num_spans++; - } - - span_start_day = span_end_day + 1; - span_num++; - } - - /* Set the event's spans. */ - event->spans_index = spans_index; - event->num_spans = num_spans; -} - - -static void -e_week_view_ensure_events_sorted (EWeekView *week_view) -{ - if (!week_view->events_sorted) { - qsort (week_view->events->data, - week_view->events->len, - sizeof (EWeekViewEvent), - e_week_view_event_sort_func); - week_view->events_sorted = TRUE; - } -} - - -static gint -e_week_view_event_sort_func (const void *arg1, - const void *arg2) -{ - EWeekViewEvent *event1, *event2; - - event1 = (EWeekViewEvent*) arg1; - event2 = (EWeekViewEvent*) arg2; - - if (event1->start < event2->start) - return -1; - if (event1->start > event2->start) - return 1; - - if (event1->end > event2->end) - return -1; - if (event1->end < event2->end) - return 1; - - return 0; -} - - -static void -e_week_view_reshape_events (EWeekView *week_view) -{ - EWeekViewEvent *event; - gint event_num, span_num; - gint num_days, day, day_x, day_y, day_w, day_h, max_rows; - gboolean is_weekend; - - for (event_num = 0; event_num < week_view->events->len; event_num++) { - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - for (span_num = 0; span_num < event->num_spans; span_num++) { - e_week_view_reshape_event_span (week_view, event_num, - span_num); - } - } - - /* Reshape the jump buttons and show/hide them as appropriate. */ - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - for (day = 0; day < num_days; day++) { - - is_weekend = (day % 7 >= 5) ? TRUE : FALSE; - if (!is_weekend || (week_view->display_month - && !week_view->compress_weekend)) - max_rows = week_view->rows_per_cell; - else - max_rows = week_view->rows_per_compressed_cell; - - /* Determine whether the jump button should be shown. */ - if (week_view->rows_per_day[day] <= max_rows) { - gnome_canvas_item_hide (week_view->jump_buttons[day]); - } else { - e_week_view_get_day_position (week_view, day, - &day_x, &day_y, - &day_w, &day_h); - - gnome_canvas_item_set (week_view->jump_buttons[day], - "GnomeCanvasPixbuf::x", (gdouble) (day_x + day_w - E_WEEK_VIEW_JUMP_BUTTON_X_PAD - E_WEEK_VIEW_JUMP_BUTTON_WIDTH), - "GnomeCanvasPixbuf::y", (gdouble) (day_y + day_h - E_WEEK_VIEW_JUMP_BUTTON_Y_PAD - E_WEEK_VIEW_JUMP_BUTTON_HEIGHT), - NULL); - - gnome_canvas_item_show (week_view->jump_buttons[day]); - gnome_canvas_item_raise_to_top (week_view->jump_buttons[day]); - } - } - - for (day = num_days; day < E_WEEK_VIEW_MAX_WEEKS * 7; day++) { - gnome_canvas_item_hide (week_view->jump_buttons[day]); - } -} - - -static void -e_week_view_reshape_event_span (EWeekView *week_view, - gint event_num, - gint span_num) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - GdkFont *font; - gint span_x, span_y, span_w, num_icons, icons_width, time_width; - gint min_text_x, max_text_w, width; - gboolean show_icons = TRUE, use_max_width = FALSE; - gboolean one_day_event; - CalComponent *comp; - gdouble text_x, text_y, text_w, text_h; - gchar *text, *end_of_line; - gint line_len, text_width; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - comp = event->comp; - font = GTK_WIDGET (week_view)->style->font; - - one_day_event = e_week_view_is_one_day_event (week_view, event_num); - - /* If the span will not be visible destroy the canvas items and - return. */ - if (!e_week_view_get_span_position (week_view, event_num, span_num, - &span_x, &span_y, &span_w)) { - if (span->background_item) - gtk_object_destroy (GTK_OBJECT (span->background_item)); - if (span->text_item) - gtk_object_destroy (GTK_OBJECT (span->text_item)); - span->background_item = NULL; - span->text_item = NULL; - return; - } - - if (!one_day_event && week_view->editing_event_num == event_num - && week_view->editing_span_num == span_num) { - show_icons = FALSE; - use_max_width = TRUE; - } - - num_icons = 0; -#if 0 - if (show_icons) { - if (ico->dalarm.enabled || ico->malarm.enabled - || ico->palarm.enabled || ico->aalarm.enabled) - num_icons++; - if (ico->recur) - num_icons++; - } -#endif - - /* Create the background canvas item if necessary. */ - if (!span->background_item) { - span->background_item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root), - e_week_view_event_item_get_type (), - NULL); - } - - gnome_canvas_item_set (span->background_item, - "event_num", event_num, - "span_num", span_num, - NULL); - - /* Create the text item if necessary. */ - if (!span->text_item) { - CalComponentText text; - - cal_component_get_summary (comp, &text); - span->text_item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root), - e_text_get_type (), - "font_gdk", GTK_WIDGET (week_view)->style->font, - "anchor", GTK_ANCHOR_NW, - "clip", TRUE, -#if 0 - "max_lines", 1, -#endif - "editable", TRUE, - "text", text.value ? text.value : "", - "use_ellipsis", TRUE, - NULL); - gtk_signal_connect (GTK_OBJECT (span->text_item), "event", - GTK_SIGNAL_FUNC (e_week_view_on_text_item_event), - week_view); - } - - /* Calculate the position of the text item. - For events < 1 day it starts after the times & icons and ends at the - right edge of the span. - For events > 1 day we need to determine whether times are shown at - the start and end of the span, then try to center the text item with - the icons in the middle, but making sure we don't go over the times. - */ - - - /* Calculate the space necessary to display a time, e.g. "13:00". */ - if (week_view->use_small_font && week_view->small_font) - time_width = week_view->digit_width * 2 - + week_view->small_digit_width * 2; - else - time_width = week_view->digit_width * 4 - + week_view->colon_width; - - /* Calculate the space needed for the icons. */ - icons_width = (E_WEEK_VIEW_ICON_WIDTH + E_WEEK_VIEW_ICON_X_PAD) - * num_icons; - - /* The y position and height are the same for both event types. */ - text_y = span_y + E_WEEK_VIEW_EVENT_BORDER_HEIGHT - + E_WEEK_VIEW_EVENT_TEXT_Y_PAD; - text_h = font->ascent + font->descent; - - if (one_day_event) { - text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD + icons_width; - - switch (week_view->time_format) { - case E_WEEK_VIEW_TIME_BOTH_SMALL_MIN: - case E_WEEK_VIEW_TIME_BOTH: - text_x += time_width * 2 + week_view->space_width - + E_WEEK_VIEW_EVENT_TIME_R_PAD; - break; - case E_WEEK_VIEW_TIME_START_SMALL_MIN: - case E_WEEK_VIEW_TIME_START: - text_x += time_width + E_WEEK_VIEW_EVENT_TIME_R_PAD; - break; - case E_WEEK_VIEW_TIME_NONE: - break; - } - text_w = span_x + span_w - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_R_PAD - text_x; - - } else { - if (use_max_width) { - text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - text_w = span_x + span_w - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_TEXT_X_PAD - text_x; - } else { - /* Get the requested size of the label. */ - gtk_object_get (GTK_OBJECT (span->text_item), - "text", &text, - NULL); - text_width = 0; - if (text) { - end_of_line = strchr (text, '\n'); - if (end_of_line) - line_len = end_of_line - text; - else - line_len = strlen (text); - text_width = gdk_text_width (font, text, line_len); - g_free (text); - } - - /* Add on the width of the icons and find the default - position. */ - width = text_width + icons_width; - text_x = span_x + (span_w - width) / 2; - - /* Now calculate the left-most valid position, and make - sure we don't go to the left of that. */ - min_text_x = span_x + E_WEEK_VIEW_EVENT_L_PAD - + E_WEEK_VIEW_EVENT_BORDER_WIDTH - + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - if (event->start > week_view->day_starts[span->start_day]) - min_text_x += time_width - + E_WEEK_VIEW_EVENT_TIME_R_PAD; - - text_x = MAX (text_x, min_text_x); - - /* Now calculate the largest valid width, using the - calculated x position, and make sure we don't - exceed that. */ - max_text_w = span_x + span_w - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH - - E_WEEK_VIEW_EVENT_TEXT_X_PAD - text_x; - if (event->end < week_view->day_starts[span->start_day - + span->num_days]) - max_text_w -= time_width - + E_WEEK_VIEW_EVENT_TIME_R_PAD; - - text_w = MIN (width, max_text_w); - - /* Now take out the space for the icons. */ - text_x += icons_width; - text_w -= icons_width; - } - } - - text_w = MAX (text_w, 0); - gnome_canvas_item_set (span->text_item, - "clip_width", (gdouble) text_w, - "clip_height", (gdouble) text_h, - NULL); - e_canvas_item_move_absolute(span->text_item, - text_x, text_y); -} - - -/* Finds the day containing the given time. - If include_midnight_in_prev_day is TRUE then if the time exactly - matches the start of a day the previous day is returned. This is useful - when calculating the end day of an event. */ -static gint -e_week_view_find_day (EWeekView *week_view, - time_t time_to_find, - gboolean include_midnight_in_prev_day) -{ - gint num_days, day; - time_t *day_starts; - - num_days = week_view->display_month ? E_WEEK_VIEW_MAX_WEEKS * 7 : 7; - day_starts = week_view->day_starts; - - if (time_to_find < day_starts[0]) - return -1; - if (time_to_find > day_starts[num_days]) - return num_days; - - for (day = 1; day <= num_days; day++) { - if (time_to_find <= day_starts[day]) { - if (time_to_find == day_starts[day] - && !include_midnight_in_prev_day) - return day; - return day - 1; - } - } - - g_assert_not_reached (); - return num_days; -} - - -/* This returns the last day in the same span as the given day. A span is all - the days which are displayed next to each other from left to right. - In the week view all spans are only 1 day, since Tuesday is below Monday - rather than beside it etc. In the month view, if the weekends are not - compressed then each week is a span, otherwise Monday to Saturday of each - week is a span, and the Sundays are separate spans. */ -static gint -e_week_view_find_span_end (EWeekView *week_view, - gint day) -{ - gint week, day_of_week, end_day; - - if (week_view->display_month) { - week = day / 7; - day_of_week = day % 7; - if (week_view->compress_weekend && day_of_week <= 5) - end_day = 5; - else - end_day = 6; - return week * 7 + end_day; - } else { - return day; - } -} - - -static void -e_week_view_on_adjustment_changed (GtkAdjustment *adjustment, - EWeekView *week_view) -{ - GDate date; - gint week_offset; - struct tm tm; - time_t lower, start, end; - guint32 old_first_day_julian, new_first_day_julian; - - /* If we don't have a valid date set yet, just return. */ - if (!g_date_valid (&week_view->first_day_shown)) - return; - - /* Determine the first date shown. */ - date = week_view->base_date; - week_offset = floor (adjustment->value + 0.5); - g_date_add_days (&date, week_offset * 7); - - /* Convert the old & new first days shown to julian values. */ - old_first_day_julian = g_date_julian (&week_view->first_day_shown); - new_first_day_julian = g_date_julian (&date); - - /* If we are already showing the date, just return. */ - if (old_first_day_julian == new_first_day_julian) - return; - - /* Set the new first day shown. */ - week_view->first_day_shown = date; - - /* Convert it to a time_t. */ - g_date_to_struct_tm (&date, &tm); - lower = mktime (&tm); - lower = time_day_begin (lower); - - e_week_view_recalc_day_starts (week_view, lower); - e_week_view_reload_events (week_view); - - /* Update the selection, if needed. */ - if (week_view->selection_start_day != -1) { - start = week_view->day_starts[week_view->selection_start_day]; - end = week_view->day_starts[week_view->selection_end_day + 1]; - gnome_calendar_set_selected_time_range (week_view->calendar, - start, end); - } - - gtk_widget_queue_draw (week_view->main_canvas); -} - - -void -e_week_view_start_editing_event (EWeekView *week_view, - gint event_num, - gint span_num, - gchar *initial_text) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - ETextEventProcessor *event_processor = NULL; - ETextEventProcessorCommand command; - - /* If we are already editing the event, just return. */ - if (event_num == week_view->editing_event_num - && span_num == week_view->editing_span_num) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - /* If the event is not shown, don't try to edit it. */ - if (!span->text_item) - return; - - if (initial_text) { - gnome_canvas_item_set (span->text_item, - "text", initial_text, - NULL); - } - - e_canvas_item_grab_focus (span->text_item); - - /* Try to move the cursor to the end of the text. */ - gtk_object_get (GTK_OBJECT (span->text_item), - "event_processor", &event_processor, - NULL); - if (event_processor) { - command.action = E_TEP_MOVE; - command.position = E_TEP_END_OF_BUFFER; - gtk_signal_emit_by_name (GTK_OBJECT (event_processor), - "command", &command); - } -} - - -/* This stops the current edit. If accept is TRUE the event summary is update, - else the edit is cancelled. */ -void -e_week_view_stop_editing_event (EWeekView *week_view) -{ - GtkWidget *toplevel; - - /* Check we are editing an event. */ - if (week_view->editing_event_num == -1) - return; - - /* Set focus to the toplevel so the item loses focus. */ - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (week_view)); - if (toplevel && GTK_IS_WINDOW (toplevel)) - gtk_window_set_focus (GTK_WINDOW (toplevel), NULL); -} - - -static gboolean -e_week_view_on_text_item_event (GnomeCanvasItem *item, - GdkEvent *event, - EWeekView *week_view) -{ - gint event_num, span_num; - -#if 0 - g_print ("In e_week_view_on_text_item_event\n"); -#endif - - switch (event->type) { - case GDK_KEY_PRESS: - if (event && event->key.keyval == GDK_Return) { - /* We set the keyboard focus to the EDayView, so the - EText item loses it and stops the edit. */ - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - - /* Stop the signal last or we will also stop any - other events getting to the EText item. */ - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - return TRUE; - } - break; - case GDK_BUTTON_PRESS: - if (!e_week_view_find_event_from_item (week_view, item, - &event_num, &span_num)) - return FALSE; - - if (event->button.button == 3) { - if (!GTK_WIDGET_HAS_FOCUS (week_view)) - gtk_widget_grab_focus (GTK_WIDGET (week_view)); - e_week_view_show_popup_menu (week_view, - (GdkEventButton*) event, - event_num); - gtk_signal_emit_stop_by_name (GTK_OBJECT (item->canvas), - "button_press_event"); - return TRUE; - } - - week_view->pressed_event_num = event_num; - week_view->pressed_span_num = span_num; - - /* Only let the EText handle the event while editing. */ - if (!E_TEXT (item)->editing) { - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - - if (event) { - week_view->drag_event_x = event->button.x; - week_view->drag_event_y = event->button.y; - } else - g_warning ("No GdkEvent"); - - /* FIXME: Remember the day offset from the start of - the event. */ - - return TRUE; - } - break; - case GDK_BUTTON_RELEASE: - if (!E_TEXT (item)->editing) { - /* This shouldn't ever happen. */ - if (!e_week_view_find_event_from_item (week_view, - item, - &event_num, - &span_num)) - return FALSE; - - if (week_view->pressed_event_num != -1 - && week_view->pressed_event_num == event_num - && week_view->pressed_span_num == span_num) { - e_week_view_start_editing_event (week_view, - event_num, - span_num, - NULL); - week_view->pressed_event_num = -1; - } - - /* Stop the signal last or we will also stop any - other events getting to the EText item. */ - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - return TRUE; - } - week_view->pressed_event_num = -1; - break; - case GDK_FOCUS_CHANGE: - if (event->focus_change.in) { - e_week_view_on_editing_started (week_view, item); - } else { - e_week_view_on_editing_stopped (week_view, item); - } - - return FALSE; - default: - break; - } - - return FALSE; -} - - -static void -e_week_view_on_editing_started (EWeekView *week_view, - GnomeCanvasItem *item) -{ - gint event_num, span_num; - - if (!e_week_view_find_event_from_item (week_view, item, - &event_num, &span_num)) - return; - -#if 0 - g_print ("In e_week_view_on_editing_started event_num:%i span_num:%i\n", event_num, span_num); -#endif - - week_view->editing_event_num = event_num; - week_view->editing_span_num = span_num; - - /* We need to reshape long events so the whole width is used while - editing. */ - if (!e_week_view_is_one_day_event (week_view, event_num)) { - e_week_view_reshape_event_span (week_view, event_num, - span_num); - } -} - - -static void -e_week_view_on_editing_stopped (EWeekView *week_view, - GnomeCanvasItem *item) -{ - gint event_num, span_num; - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gchar *text = NULL; - CalComponentText summary; - const char *uid; - - /* Note: the item we are passed here isn't reliable, so we just stop - the edit of whatever item was being edited. We also receive this - event twice for some reason. */ - event_num = week_view->editing_event_num; - span_num = week_view->editing_span_num; - - /* If no item is being edited, just return. */ - if (event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - /* Reset the edit fields. */ - week_view->editing_event_num = -1; - week_view->editing_new_event = FALSE; - - /* Check that the event is still valid. */ - cal_component_get_uid (event->comp, &uid); - if (!uid) - return; - - gtk_object_get (GTK_OBJECT (span->text_item), - "text", &text, - NULL); - - /* Only update the summary if necessary. */ - cal_component_get_summary (event->comp, &summary); - if (text && summary.value && !strcmp (text, summary.value)) { - g_free (text); - if (!e_week_view_is_one_day_event (week_view, event_num)) - e_week_view_reshape_event_span (week_view, event_num, - span_num); - return; - } - - summary.value = text; - cal_component_set_summary (event->comp, &summary); - g_free (text); - - if (!cal_client_update_object (week_view->calendar->client, event->comp)) - g_message ("e_week_view_on_editing_stopped(): Could not update the object!"); -} - - -static gboolean -e_week_view_find_event_from_item (EWeekView *week_view, - GnomeCanvasItem *item, - gint *event_num_return, - gint *span_num_return) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - gint event_num, span_num, num_events; - - num_events = week_view->events->len; - for (event_num = 0; event_num < num_events; event_num++) { - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - for (span_num = 0; span_num < event->num_spans; span_num++) { - span = &g_array_index (week_view->spans, - EWeekViewEventSpan, - event->spans_index + span_num); - if (span->text_item == item) { - *event_num_return = event_num; - *span_num_return = span_num; - return TRUE; - } - } - } - - return FALSE; -} - - -/* Finds the index of the event with the given uid. - Returns TRUE if an event with the uid was found. - Note that for recurring events there may be several EWeekViewEvents, one - for each instance, all with the same iCalObject and uid. So only use this - function if you know the event doesn't recur or you are just checking to - see if any events with the uid exist. */ -static gboolean -e_week_view_find_event_from_uid (EWeekView *week_view, - const gchar *uid, - gint *event_num_return) -{ - EWeekViewEvent *event; - gint event_num, num_events; - - num_events = week_view->events->len; - for (event_num = 0; event_num < num_events; event_num++) { - const char *u; - - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - cal_component_get_uid (event->comp, &u); - if (u && !strcmp (uid, u)) { - *event_num_return = event_num; - return TRUE; - } - } - - return FALSE; -} - - -gboolean -e_week_view_is_one_day_event (EWeekView *week_view, - gint event_num) -{ - EWeekViewEvent *event; - EWeekViewEventSpan *span; - - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - if (event->num_spans != 1) - return FALSE; - - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index); - - if (event->start == week_view->day_starts[span->start_day] - && event->end == week_view->day_starts[span->start_day + 1]) - return FALSE; - - if (span->num_days == 1 - && event->start >= week_view->day_starts[span->start_day] - && event->end <= week_view->day_starts[span->start_day + 1]) - return TRUE; - - return FALSE; -} - - -static gint -e_week_view_key_press (GtkWidget *widget, GdkEventKey *event) -{ - EWeekView *week_view; - CalComponent *comp; - gint event_num; - gchar *initial_text; - CalComponentDateTime date; - time_t dtstart, dtend; - const char *uid; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - week_view = E_WEEK_VIEW (widget); - - /* The Escape key aborts a resize operation. */ -#if 0 - if (week_view->resize_drag_pos != E_WEEK_VIEW_POS_NONE) { - if (event->keyval == GDK_Escape) { - e_week_view_abort_resize (week_view, event->time); - } - return FALSE; - } -#endif - - if (week_view->selection_start_day == -1) - return FALSE; - - /* We only want to start an edit with a return key or a simple - character. */ - if (event->keyval == GDK_Return) { - initial_text = NULL; - } else if ((event->keyval < 0x20) - || (event->keyval > 0xFF) - || (event->length == 0) - || (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) { - return FALSE; - } else { - initial_text = event->string; - } - - /* Add a new event covering the selected range. */ - comp = cal_component_new (); - dtstart = week_view->day_starts[week_view->selection_start_day]; - dtend = week_view->day_starts[week_view->selection_end_day + 1]; - - date.value = g_new0 (struct icaltimetype, 1); - *date.value = icaltimetype_from_timet (dtstart, FALSE); - cal_component_set_dtstart (comp, &date); - *date.value = icaltimetype_from_timet (dtend, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - - /* We add the event locally and start editing it. When we get the - "update_event" callback from the server, we basically ignore it. - If we were to wait for the "update_event" callback it wouldn't be - as responsive and we may lose a few keystrokes. */ - e_week_view_add_event (comp, dtstart, dtend, week_view); - e_week_view_check_layout (week_view); - gtk_widget_queue_draw (week_view->main_canvas); - - cal_component_get_uid (comp, &uid); - if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) { - e_week_view_start_editing_event (week_view, event_num, 0, - initial_text); - week_view->editing_new_event = TRUE; - } else { - g_warning ("Couldn't find event to start editing.\n"); - } - - if (!cal_client_update_object (week_view->calendar->client, comp)) - g_message ("e_week_view_key_press(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - return TRUE; -} - - -void -e_week_view_show_popup_menu (EWeekView *week_view, - GdkEventButton *bevent, - gint event_num) -{ - EWeekViewEvent *event; - int have_selection, not_being_edited, num_items, i; - struct menu_item *context_menu; - - static struct menu_item items[] = { - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item child_items[] = { - { N_("Edit this appointment..."), (GtkSignalFunc) e_week_view_on_edit_appointment, NULL, TRUE }, - { N_("Delete this appointment"), (GtkSignalFunc) e_week_view_on_delete_appointment, NULL, TRUE }, - { NULL, NULL, NULL, TRUE }, - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item recur_child_items[] = { - { N_("Edit this appointment..."), (GtkSignalFunc) e_week_view_on_edit_appointment, NULL, TRUE }, - { N_("Make this appointment movable"), (GtkSignalFunc) e_week_view_on_unrecur_appointment, NULL, TRUE }, - { N_("Delete this occurrence"), (GtkSignalFunc) e_week_view_on_delete_occurrence, NULL, TRUE }, - { N_("Delete all occurrences"), (GtkSignalFunc) e_week_view_on_delete_appointment, NULL, TRUE }, - { NULL, NULL, NULL, TRUE }, - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; - - have_selection = GTK_WIDGET_HAS_FOCUS (week_view) - && week_view->selection_start_day != -1; - - if (event_num == -1) { - num_items = 1; - context_menu = &items[0]; - context_menu[0].sensitive = have_selection; - } else { - event = &g_array_index (week_view->events, - EWeekViewEvent, event_num); - - /* This used to be set only if the event wasn't being edited - in the event editor, but we can't check that at present. - We could possibly set up another method of checking it. */ - not_being_edited = TRUE; - - if (cal_component_has_rrules (event->comp) - || cal_component_has_rdates (event->comp)) { - num_items = 6; - context_menu = &recur_child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[2].sensitive = not_being_edited; - context_menu[3].sensitive = not_being_edited; - context_menu[5].sensitive = have_selection; - } else { - num_items = 4; - context_menu = &child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[3].sensitive = have_selection; - } - } - - for (i = 0; i < num_items; i++) - context_menu[i].data = week_view; - - week_view->popup_event_num = event_num; - popup_menu (context_menu, num_items, bevent); -} - - -static void -e_week_view_on_new_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - CalComponent *comp; - CalComponentDateTime date; - week_view = E_WEEK_VIEW (data); - - comp = cal_component_new (); - - date.value = g_new0 (struct icaltimetype, 1); - - *date.value = - icaltimetype_from_timet (week_view->day_starts[week_view->selection_start_day], - FALSE); - cal_component_set_dtstart (comp, &date); - - *date.value = - icaltimetype_from_timet (week_view->day_starts[week_view->selection_end_day + 1], - FALSE); - cal_component_set_dtend (comp, &date); - - g_free (date.value); - - gnome_calendar_edit_object (week_view->calendar, comp); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_week_view_on_edit_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - gnome_calendar_edit_object (week_view->calendar, event->comp); -} - - -static void -e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - CalComponent *comp; - CalComponentDateTime *date=NULL; - GSList *list; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - /* We must duplicate the CalComponent, or we won't know it has changed - when we get the "update_event" callback. */ - - comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - list = g_slist_append (list, date); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltimetype_from_timet (event->start, TRUE); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); - - if (!cal_client_update_object (week_view->calendar->client, comp)) - g_message ("e_week_view_on_delete_occurrence(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); -} - - -static void -e_week_view_on_delete_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - const char *uid; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - cal_component_get_uid (event->comp, &uid); - if (!cal_client_remove_object (week_view->calendar->client, uid)) - g_message ("e_week_view_on_delete_appointment(): Could not remove the object!"); -} - - -static void -e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - CalComponent *comp, *new_comp; - CalComponentDateTime *date; - GSList *list; - - week_view = E_WEEK_VIEW (data); - - if (week_view->popup_event_num == -1) - return; - - event = &g_array_index (week_view->events, EWeekViewEvent, - week_view->popup_event_num); - - /* For the recurring object, we add a exception to get rid of the - instance. */ - - comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltimetype_from_timet (event->start, TRUE); - list = g_slist_append (list, date); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); - - /* For the unrecurred instance we duplicate the original object, - create a new uid for it, get rid of the recurrence rules, and set - the start & end times to the instances times. */ - new_comp = cal_component_clone (event->comp); - cal_component_set_uid (new_comp, cal_component_gen_uid ()); - cal_component_set_exdate_list (new_comp, NULL); - cal_component_set_exrule_list (new_comp, NULL); - - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - - *date->value = icaltimetype_from_timet (event->start, TRUE); - cal_component_set_dtstart (new_comp, date); - *date->value = icaltimetype_from_timet (event->end, TRUE); - cal_component_set_dtend (new_comp, date); - - cal_component_free_datetime (date); - - /* Now update both CalComponents. Note that we do this last since at - present the updates happen synchronously so our event may disappear. - */ - if (!cal_client_update_object (week_view->calendar->client, comp)) - g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - if (!cal_client_update_object (week_view->calendar->client, new_comp)) - g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (new_comp)); -} - - -static gboolean -e_week_view_on_jump_button_event (GnomeCanvasItem *item, - GdkEvent *event, - EWeekView *week_view) -{ - gint day; - - if (event->type == GDK_BUTTON_PRESS) { - for (day = 0; day < E_WEEK_VIEW_MAX_WEEKS * 7; day++) { - if (item == week_view->jump_buttons[day]) { - gnome_calendar_dayjump (week_view->calendar, - week_view->day_starts[day]); - /* A quick hack to make the 'Day' toolbar - button active. */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (week_view->calendar->view_toolbar_buttons[0]), TRUE); - return TRUE; - } - } - - } - - return FALSE; -} diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h deleted file mode 100644 index dc2b01e4ff..0000000000 --- a/calendar/gui/e-week-view.h +++ /dev/null @@ -1,380 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@helixcode.com> - * - * Copyright 1999, Helix Code, 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 _E_WEEK_VIEW_H_ -#define _E_WEEK_VIEW_H_ - -#include <gtk/gtktable.h> -#include <libgnomeui/gnome-canvas.h> - -#include "gnome-cal.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * EWeekView - displays the Week & Month views of the calendar. - */ - -/* The maximum number of weeks we show. 5 is usually enough for 1 month. */ -#define E_WEEK_VIEW_MAX_WEEKS 5 - -/* The size of the reminder & recurrence icons, and padding around them. */ -#define E_WEEK_VIEW_ICON_WIDTH 16 -#define E_WEEK_VIEW_ICON_HEIGHT 16 -#define E_WEEK_VIEW_ICON_X_PAD 0 -#define E_WEEK_VIEW_ICON_Y_PAD 0 - -/* The space on the left & right of the event. (The triangle to indicate the - event continues is displayed in this space). */ -#define E_WEEK_VIEW_EVENT_L_PAD 2 -#define E_WEEK_VIEW_EVENT_R_PAD 3 - -/* The vertical spacing between rows of events. */ -#define E_WEEK_VIEW_EVENT_Y_SPACING 1 - -/* The size of the border around the event. */ -#define E_WEEK_VIEW_EVENT_BORDER_WIDTH 1 -#define E_WEEK_VIEW_EVENT_BORDER_HEIGHT 1 - -/* The padding on each side of the event text. */ -#define E_WEEK_VIEW_EVENT_TEXT_X_PAD 4 -#define E_WEEK_VIEW_EVENT_TEXT_Y_PAD 1 - -/* The space on the right of the time string, if it is shown. */ -#define E_WEEK_VIEW_EVENT_TIME_R_PAD 2 - -/* The padding above and on the right of the date string at the top of each - cell. */ -#define E_WEEK_VIEW_DATE_T_PAD 2 -#define E_WEEK_VIEW_DATE_R_PAD 4 - -/* The padding above and below the line under the date string, in the Week - view, and also the space on the left of it. */ -#define E_WEEK_VIEW_DATE_LINE_T_PAD 1 -#define E_WEEK_VIEW_DATE_LINE_B_PAD 1 -#define E_WEEK_VIEW_DATE_LINE_L_PAD 10 - -/* The padding below the date string in the Month view. */ -#define E_WEEK_VIEW_DATE_B_PAD 1 - -/* These index our colors array. */ -typedef enum -{ - E_WEEK_VIEW_COLOR_EVEN_MONTHS, - E_WEEK_VIEW_COLOR_ODD_MONTHS, - E_WEEK_VIEW_COLOR_EVENT_BACKGROUND, - E_WEEK_VIEW_COLOR_EVENT_BORDER, - - E_WEEK_VIEW_COLOR_LAST -} EWeekViewColors; - -/* These specify which part of the selection we are dragging, if any. */ -typedef enum -{ - E_WEEK_VIEW_DRAG_NONE, - E_WEEK_VIEW_DRAG_START, - E_WEEK_VIEW_DRAG_END -} EWeekViewDragPosition; - -/* These specify which times are shown for the 1-day events. We use the small - font for the minutes if it can be loaded and the option is on. */ -typedef enum -{ - E_WEEK_VIEW_TIME_NONE, - E_WEEK_VIEW_TIME_START, - E_WEEK_VIEW_TIME_BOTH, - E_WEEK_VIEW_TIME_START_SMALL_MIN, - E_WEEK_VIEW_TIME_BOTH_SMALL_MIN -} EWeekViewTimeFormat; - -/* Specifies the position of the mouse. */ -typedef enum -{ - E_WEEK_VIEW_POS_OUTSIDE, - E_WEEK_VIEW_POS_NONE, - E_WEEK_VIEW_POS_EVENT, - E_WEEK_VIEW_POS_LEFT_EDGE, - E_WEEK_VIEW_POS_RIGHT_EDGE -} EWeekViewPosition; - - -typedef struct _EWeekViewEventSpan EWeekViewEventSpan; -struct _EWeekViewEventSpan { - guint start_day : 6; - guint num_days : 3; - guint row : 7; - GnomeCanvasItem *background_item; - GnomeCanvasItem *text_item; -}; - -typedef struct _EWeekViewEvent EWeekViewEvent; -struct _EWeekViewEvent { - CalComponent *comp; - time_t start; - time_t end; - guint16 start_minute; /* Minutes from the start of the day. */ - guint16 end_minute; - gint spans_index; - guint num_spans; -}; - - -#define E_WEEK_VIEW(obj) GTK_CHECK_CAST (obj, e_week_view_get_type (), EWeekView) -#define E_WEEK_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_week_view_get_type (), EWeekViewClass) -#define E_IS_WEEK_VIEW(obj) GTK_CHECK_TYPE (obj, e_week_view_get_type ()) - - -typedef struct _EWeekView EWeekView; -typedef struct _EWeekViewClass EWeekViewClass; - -struct _EWeekView -{ - GtkTable table; - - /* The top canvas where the dates are shown. */ - GtkWidget *titles_canvas; - GnomeCanvasItem *titles_canvas_item; - - /* The main canvas where the appointments are shown. */ - GtkWidget *main_canvas; - GnomeCanvasItem *main_canvas_item; - - GnomeCanvasItem *jump_buttons[E_WEEK_VIEW_MAX_WEEKS * 7]; - - GtkWidget *vscrollbar; - - /* The calendar we are associated with. */ - GnomeCalendar *calendar; - - /* The array of EWeekViewEvent elements. */ - GArray *events; - gboolean events_sorted; - gboolean events_need_layout; - gboolean events_need_reshape; - - /* An array of EWeekViewEventSpan elements. Each event has its own - space within this array, and uses the spans_index and num_spans - fields of the EWeekViewEvent struct to access it. */ - GArray *spans; - - /* The start of each day displayed. */ - time_t day_starts[E_WEEK_VIEW_MAX_WEEKS * 7 + 1]; - - /* The base date, where the adjustment value is 0. */ - GDate base_date; - - /* The first day shown in the view. */ - GDate first_day_shown; - - /* If we are displaying 1 week or 1 month. */ - gboolean display_month; - - /* If Sat & Sun are compressed. Only applicable in month view, since - they are always compressed into 1 cell in the week view. */ - gboolean compress_weekend; - - /* The vertical offset of the events from the top of the cells. */ - gint events_y_offset; - - /* The height of the events, not including spacing between them. */ - gint row_height; - - /* The number of rows of events in each cell. */ - gint rows_per_cell; - gint rows_per_compressed_cell; - - /* The number of rows we have used for each day (i.e. each cell) */ - gint rows_per_day[E_WEEK_VIEW_MAX_WEEKS * 7]; - - /* If the small font is used for displaying the minutes. */ - gboolean use_small_font; - - /* Small font to display the minutes. */ - GdkFont *small_font; - - /* The widths of various pieces of text, used to determine which of - several date formats to display, set in e_week_view_style_set(). */ - gint space_width; /* One space character ' '. */ - gint colon_width; /* Size of ':' in the font. */ - gint slash_width; /* Size of '/' in the font. */ - gint digit_width; /* Size of a '0' digit. */ - gint small_digit_width; /* Size of a small_font '0' digit. */ - gint day_widths[7]; /* Monday first. */ - gint max_day_width; - gint abbr_day_widths[7]; - gint max_abbr_day_width; - gint month_widths[12]; - gint max_month_width; - gint abbr_month_widths[12]; - gint max_abbr_month_width; - - /* The size of the main grid of days and of the cells. Note that the - offsets arrays have one more element than the widths/heights arrays - since they also contain the right/bottom edge. */ - gint rows; - gint columns; - gint col_widths[7]; - gint col_offsets[8]; - gint row_heights[10]; - gint row_offsets[11]; - - /* This specifies which times we are showing for the events, depending - on how much room is available. */ - EWeekViewTimeFormat time_format; - - /* The GC used for painting in different colors. */ - GdkGC *main_gc; - - /* The icons. */ - GdkPixmap *reminder_icon; - GdkBitmap *reminder_mask; - GdkPixmap *recurrence_icon; - GdkBitmap *recurrence_mask; - - /* Colors for drawing. */ - GdkColor colors[E_WEEK_VIEW_COLOR_LAST]; - - /* The normal & resizing cursors. */ - GdkCursor *normal_cursor; - GdkCursor *move_cursor; - GdkCursor *resize_width_cursor; - - /* This remembers the last cursor set on the window. */ - GdkCursor *last_cursor_set; - - /* The currently selected region, in days from the first day shown. - If selection_start_day is -1 there is no current selection. */ - gint selection_start_day; - gint selection_end_day; - - /* This specifies which end of the selection is being dragged, or is - E_WEEK_VIEW_DRAG_NONE if the selection isn't being dragged. */ - EWeekViewDragPosition selection_drag_pos; - - /* This is the event the mouse button was pressed on. If the button - is released we start editing it, but if the mouse is dragged we set - this to -1. */ - gint pressed_event_num; - gint pressed_span_num; - - /* The event span currently being edited. The num is -1 if no event is - being edited. */ - gint editing_event_num; - gint editing_span_num; - - /* This is TRUE if we are editing an event which we have just created. - We ignore the "update_event" callback which we will get from the - server when the event is added. */ - gboolean editing_new_event; - - /* The event that the context menu is for. */ - gint popup_event_num; - - /* The last mouse position when dragging, in the entire canvas. */ - gint drag_event_x; - gint drag_event_y; -}; - -struct _EWeekViewClass -{ - GtkTableClass parent_class; -}; - - -GtkType e_week_view_get_type (void); -GtkWidget* e_week_view_new (void); - -void e_week_view_set_calendar (EWeekView *week_view, - GnomeCalendar *calendar); - -/* This sets the selected time range. The EWeekView will show the corresponding - month and the days between start_time and end_time will be selected. - To select a single day, use the same value for start_time & end_time. */ -void e_week_view_set_selected_time_range (EWeekView *week_view, - time_t start_time, - time_t end_time); - -/* Returns the selected time range. */ -void e_week_view_get_selected_time_range (EWeekView *week_view, - time_t *start_time, - time_t *end_time); - -/* Whether to display 1 week or 1 month (5 weeks). It defaults to 1 week. */ -gboolean e_week_view_get_display_month (EWeekView *week_view); -void e_week_view_set_display_month (EWeekView *week_view, - gboolean display_month); - -/* Whether the weekend (Sat/Sun) should be compressed into 1 cell in the Month - view. In the Week view they are always compressed. */ -gboolean e_week_view_get_compress_weekend (EWeekView *week_view); -void e_week_view_set_compress_weekend (EWeekView *week_view, - gboolean compress); - -/* This reloads all calendar events. */ -void e_week_view_update_all_events (EWeekView *week_view); - -/* This is called when one event has been added or updated. */ -void e_week_view_update_event (EWeekView *week_view, - const gchar *uid); - -/* This removes all the events associated with the given uid. Note that for - recurring events there may be more than one. If any events are found and - removed we need to layout the events again. */ -void e_week_view_remove_event (EWeekView *week_view, - const gchar *uid); - - -/* - * Internal functions called by the associated canvas items. - */ -void e_week_view_get_day_position (EWeekView *week_view, - gint day, - gint *day_x, - gint *day_y, - gint *day_w, - gint *day_h); -gboolean e_week_view_get_span_position (EWeekView *week_view, - gint event_num, - gint span_num, - gint *span_x, - gint *span_y, - gint *span_w); -gboolean e_week_view_is_one_day_event (EWeekView *week_view, - gint event_num); -void e_week_view_start_editing_event (EWeekView *week_view, - gint event_num, - gint span_num, - gchar *initial_text); -void e_week_view_stop_editing_event (EWeekView *week_view); - -void e_week_view_show_popup_menu (EWeekView *week_view, - GdkEventButton *event, - gint event_num); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_WEEK_VIEW_H_ */ diff --git a/calendar/gui/event-editor-dialog.glade b/calendar/gui/event-editor-dialog.glade deleted file mode 100644 index d166bca079..0000000000 --- a/calendar/gui/event-editor-dialog.glade +++ /dev/null @@ -1,2024 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>event-editor-dialog</name> - <program_name>event-editor-dialog</program_name> - <directory></directory> - <source_directory>.</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <output_main_file>False</output_main_file> - <output_support_files>False</output_support_files> - <output_build_files>False</output_build_files> - <output_translatable_strings>True</output_translatable_strings> - <translatable_strings_file>event-editor-dialog.glade.h</translatable_strings_file> -</project> - -<widget> - <class>GnomeApp</class> - <name>event-editor-dialog</name> - <visible>False</visible> - <title>event-editor-dialog</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock2</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkNotebook</class> - <child_name>GnomeDock:contents</child_name> - <name>dialog-contents</name> - <border_width>2</border_width> - <can_focus>True</can_focus> - <show_tabs>True</show_tabs> - <show_border>True</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - - <widget> - <class>GtkVBox</class> - <name>vbox2</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>6</spacing> - - <widget> - <class>GtkTable</class> - <name>table5</name> - <rows>2</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkEntry</class> - <name>general-owner</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>general-summary</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label41</name> - <label>_Summary:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>7.45058e-09</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>general-summary</focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label13</name> - <label>_Owner:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>7.45058e-09</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>general-owner</focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame4</name> - <label>Time</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table3</name> - <border_width>4</border_width> - <rows>2</rows> - <columns>3</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GtkLabel</class> - <name>label15</name> - <label>Start time:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label16</name> - <label>End time:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>Custom</class> - <name>start-time</name> - <creation_function>make_date_edit_with_time</creation_function> - <string1></string1> - <string2></string2> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Tue, 16 May 2000 19:11:05 GMT</last_modification_time> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - </widget> - - <widget> - <class>Custom</class> - <name>end-time</name> - <creation_function>make_date_edit_with_time</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Tue, 16 May 2000 19:11:10 GMT</last_modification_time> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>all-day-event</name> - <can_focus>True</can_focus> - <label>A_ll day event</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow3</name> - <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkText</class> - <name>description</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text></text> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame5</name> - <label>Classification</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkHBox</class> - <name>hbox6</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>GtkRadioButton</class> - <name>classification-radio</name> - <can_focus>True</can_focus> - <label>Pu_blic</label> - <active>True</active> - <draw_indicator>True</draw_indicator> - <group>classification_radio_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name></name> - <can_focus>True</can_focus> - <label>Pri_vate</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>classification_radio_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name></name> - <can_focus>True</can_focus> - <label>_Confidential</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>classification_radio_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label11</name> - <label>General</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkTable</class> - <name>table4</name> - <border_width>4</border_width> - <rows>4</rows> - <columns>5</columns> - <homogeneous>False</homogeneous> - <row_spacing>4</row_spacing> - <column_spacing>4</column_spacing> - - <widget> - <class>GtkSpinButton</class> - <name>alarm-display-amount</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>True</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>alarm-audio-amount</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>alarm-program-amount</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>alarm-mail-amount</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>0</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>alarm-display-unit</name> - <can_focus>True</can_focus> - <items>Minutes -Hours -Days -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>alarm-audio-unit</name> - <can_focus>True</can_focus> - <items>Minutes -Hours -Days -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>alarm-program-unit</name> - <can_focus>True</can_focus> - <items>Minutes -Hours -Days -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>alarm-mail-unit</name> - <can_focus>True</can_focus> - <items>Minutes -Hours -Days -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>alarm-mail-mail-to</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>4</left_attach> - <right_attach>5</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GnomeFileEntry</class> - <name>alarm-program-run-program</name> - <max_saved>10</max_saved> - <directory>False</directory> - <modal>False</modal> - <child> - <left_attach>4</left_attach> - <right_attach>5</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - - <widget> - <class>GtkEntry</class> - <child_name>GnomeEntry:entry</child_name> - <name>alarm-program-run-program-entry</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - </widget> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>alarm-display</name> - <can_focus>True</can_focus> - <label>_Display</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>alarm-audio</name> - <can_focus>True</can_focus> - <label>_Audio</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>alarm-program</name> - <can_focus>True</can_focus> - <label>_Program</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>alarm-mail</name> - <can_focus>True</can_focus> - <label>_Mail</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label18</name> - <label>Mail _to:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>7.45058e-09</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>alarm-mail-mail-to</focus_target> - <child> - <left_attach>3</left_attach> - <right_attach>4</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label17</name> - <label>_Run program:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>alarm-program-run-program-entry</focus_target> - <child> - <left_attach>3</left_attach> - <right_attach>4</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label42</name> - <label>Reminder</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox3</name> - <border_width>6</border_width> - <homogeneous>False</homogeneous> - <spacing>6</spacing> - - <widget> - <class>GtkFrame</class> - <name>frame8</name> - <label>Recurrence rule</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkHBox</class> - <name>hbox7</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkVBox</class> - <name>vbox4</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-none</name> - <can_focus>True</can_focus> - <label>None</label> - <active>True</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-daily</name> - <can_focus>True</can_focus> - <label>Daily</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-weekly</name> - <can_focus>True</can_focus> - <label>Weekly</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-monthly</name> - <can_focus>True</can_focus> - <label>Monthly</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-yearly</name> - <can_focus>True</can_focus> - <label>Yearly</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_group</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkVSeparator</class> - <name>vseparator1</name> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkNotebook</class> - <name>recurrence-rule-notebook</name> - <show_tabs>False</show_tabs> - <show_border>False</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkTable</class> - <name>table6</name> - <rows>3</rows> - <columns>3</columns> - <homogeneous>False</homogeneous> - <row_spacing>0</row_spacing> - <column_spacing>0</column_spacing> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label23</name> - <label>label23</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkAlignment</class> - <name>alignment1</name> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xscale>1</xscale> - <yscale>1</yscale> - - <widget> - <class>GtkVBox</class> - <name>vbox7</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox13</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label31</name> - <label>Every </label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-daily-days</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label32</name> - <label>day(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label24</name> - <label>label24</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox8</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>2</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox14</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label33</name> - <label>Every </label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-weekly-weeks</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label34</name> - <label>week(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox15</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-mon</name> - <can_focus>True</can_focus> - <label>Mon</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-tue</name> - <can_focus>True</can_focus> - <label>Tue</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-wed</name> - <can_focus>True</can_focus> - <label>Wed</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-thu</name> - <can_focus>True</can_focus> - <label>Thu</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-fri</name> - <can_focus>True</can_focus> - <label>Fri</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-sat</name> - <can_focus>True</can_focus> - <label>Sat</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>recurrence-rule-weekly-sun</name> - <can_focus>True</can_focus> - <label>Sun</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label25</name> - <label>label25</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkTable</class> - <name>table8</name> - <rows>2</rows> - <columns>4</columns> - <homogeneous>False</homogeneous> - <row_spacing>2</row_spacing> - <column_spacing>2</column_spacing> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-monthly-on-day</name> - <can_focus>True</can_focus> - <label>Recur on the</label> - <active>True</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_monthly_group</group> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-rule-monthly-weekday</name> - <can_focus>True</can_focus> - <label>Recur on the</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_rule_monthly_group</group> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label35</name> - <label>th day of the month</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>recurrence-rule-monthly-week</name> - <can_focus>True</can_focus> - <items>1st -2nd -3rd -4th -5th -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>recurrence-rule-monthly-weekpos</name> - <can_focus>True</can_focus> - <items>Monday -Tuesday -Wednesday -Thursday -Friday -Saturday -Sunday -</items> - <initial_choice>0</initial_choice> - <child> - <left_attach>2</left_attach> - <right_attach>3</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>False</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox19</name> - <border_width>3</border_width> - <homogeneous>False</homogeneous> - <spacing>3</spacing> - <child> - <left_attach>3</left_attach> - <right_attach>4</right_attach> - <top_attach>0</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label36</name> - <label>Every</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-monthly-every-n-months</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>1</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label37</name> - <label>month(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-monthly-day-nth</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <left_attach>1</left_attach> - <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label26</name> - <label>label26</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox11</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox20</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label38</name> - <label>Every </label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-rule-yearly-every-n-years</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>1</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label39</name> - <label>year(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label27</name> - <label>label27</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox8</name> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkFrame</class> - <name>frame9</name> - <label>Ending date</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox5</name> - <border_width>4</border_width> - <homogeneous>True</homogeneous> - <spacing>2</spacing> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-ending-date-repeat-forever</name> - <can_focus>True</can_focus> - <label>Repeat forever</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_ending_date</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox12</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-ending-date-end-on</name> - <can_focus>True</can_focus> - <label>End on </label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_ending_date</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>Custom</class> - <name>recurrence-ending-date-end-on-date</name> - <width>100</width> - <creation_function>make_date_edit</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Sat, 13 May 2000 18:02:55 GMT</last_modification_time> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox10</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkRadioButton</class> - <name>recurrence-ending-date-end-after</name> - <can_focus>True</can_focus> - <label>End after</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>recurrence_ending_date</group> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkSpinButton</class> - <name>recurrence-ending-date-end-after-count</name> - <can_focus>True</can_focus> - <climb_rate>1</climb_rate> - <digits>0</digits> - <numeric>False</numeric> - <update_policy>GTK_UPDATE_ALWAYS</update_policy> - <snap>False</snap> - <wrap>False</wrap> - <value>2</value> - <lower>0</lower> - <upper>100</upper> - <step>1</step> - <page>10</page> - <page_size>10</page_size> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label28</name> - <label>occurrence(s)</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame10</name> - <label>Exceptions</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox12</name> - <border_width>4</border_width> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - - <widget> - <class>Custom</class> - <name>recurrence-exceptions-date</name> - <creation_function>make_date_edit</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Tue, 16 May 2000 01:42:29 GMT</last_modification_time> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox21</name> - <homogeneous>False</homogeneous> - <spacing>4</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <name>vbox13</name> - <homogeneous>False</homogeneous> - <spacing>2</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>recurrence-exceptions-add</name> - <can_focus>True</can_focus> - <label>Add</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>recurrence-exceptions-change</name> - <can_focus>True</can_focus> - <label>Change</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>recurrence-exceptions-delete</name> - <can_focus>True</can_focus> - <label>Delete</label> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow2</name> - <hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkCList</class> - <name>recurrence-exceptions-list</name> - <can_focus>True</can_focus> - <columns>1</columns> - <column_widths>80</column_widths> - <selection_mode>GTK_SELECTION_SINGLE</selection_mode> - <show_titles>False</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>label40</name> - <label></label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - </widget> - </widget> - </widget> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label12</name> - <label>Recurrence</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - - <widget> - <class>GnomeAppBar</class> - <child_name>GnomeApp:appbar</child_name> - <name>appbar2</name> - <has_progress>True</has_progress> - <has_status>True</has_status> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> -</widget> - -</GTK-Interface> diff --git a/calendar/gui/event-editor-dialog.glade.h b/calendar/gui/event-editor-dialog.glade.h deleted file mode 100644 index d921f3746a..0000000000 --- a/calendar/gui/event-editor-dialog.glade.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("event-editor-dialog"); -gchar *s = N_("_Summary:"); -gchar *s = N_("_Owner:"); -gchar *s = N_("Time"); -gchar *s = N_("Start time:"); -gchar *s = N_("End time:"); -gchar *s = N_("A_ll day event"); -gchar *s = N_("Classification"); -gchar *s = N_("Pu_blic"); -gchar *s = N_("Pri_vate"); -gchar *s = N_("_Confidential"); -gchar *s = N_("General"); -gchar *s = N_("Minutes\n" - "Hours\n" - "Days\n" - ""); -gchar *s = N_("Minutes\n" - "Hours\n" - "Days\n" - ""); -gchar *s = N_("Minutes\n" - "Hours\n" - "Days\n" - ""); -gchar *s = N_("Minutes\n" - "Hours\n" - "Days\n" - ""); -gchar *s = N_("_Display"); -gchar *s = N_("_Audio"); -gchar *s = N_("_Program"); -gchar *s = N_("_Mail"); -gchar *s = N_("Mail _to:"); -gchar *s = N_("_Run program:"); -gchar *s = N_("Reminder"); -gchar *s = N_("Recurrence rule"); -gchar *s = N_("None"); -gchar *s = N_("Daily"); -gchar *s = N_("Weekly"); -gchar *s = N_("Monthly"); -gchar *s = N_("Yearly"); -gchar *s = N_("label23"); -gchar *s = N_("Every "); -gchar *s = N_("day(s)"); -gchar *s = N_("label24"); -gchar *s = N_("Every "); -gchar *s = N_("week(s)"); -gchar *s = N_("Mon"); -gchar *s = N_("Tue"); -gchar *s = N_("Wed"); -gchar *s = N_("Thu"); -gchar *s = N_("Fri"); -gchar *s = N_("Sat"); -gchar *s = N_("Sun"); -gchar *s = N_("label25"); -gchar *s = N_("Recur on the"); -gchar *s = N_("Recur on the"); -gchar *s = N_("th day of the month"); -gchar *s = N_("1st\n" - "2nd\n" - "3rd\n" - "4th\n" - "5th\n" - ""); -gchar *s = N_("Monday\n" - "Tuesday\n" - "Wednesday\n" - "Thursday\n" - "Friday\n" - "Saturday\n" - "Sunday\n" - ""); -gchar *s = N_("Every"); -gchar *s = N_("month(s)"); -gchar *s = N_("label26"); -gchar *s = N_("Every "); -gchar *s = N_("year(s)"); -gchar *s = N_("label27"); -gchar *s = N_("Ending date"); -gchar *s = N_("Repeat forever"); -gchar *s = N_("End on "); -gchar *s = N_("End after"); -gchar *s = N_("occurrence(s)"); -gchar *s = N_("Exceptions"); -gchar *s = N_("Add"); -gchar *s = N_("Change"); -gchar *s = N_("Delete"); -gchar *s = N_("Recurrence"); diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c deleted file mode 100644 index ff4a6e7e29..0000000000 --- a/calendar/gui/event-editor.c +++ /dev/null @@ -1,1985 +0,0 @@ -/* Evolution calendar - Event editor dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * Seth Alves <alves@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include <e-util/e-dialog-widgets.h> -#include <cal-util/timeutil.h> -#include "event-editor.h" - - - - -typedef struct { - /* Glade XML data */ - GladeXML *xml; - - /* UI handler */ - BonoboUIHandler *uih; - - /* Calendar object we are editing; this is an internal copy and is not - * one of the read-only objects from the parent calendar. - */ - CalComponent *comp; - - /* Widgets from the Glade file */ - - GtkWidget *app; - - GtkWidget *general_owner; - GtkWidget *general_summary; - - GtkWidget *start_time; - GtkWidget *end_time; - GtkWidget *all_day_event; - - GtkWidget *description; - - GtkWidget *alarm_display; - GtkWidget *alarm_program; - GtkWidget *alarm_audio; - GtkWidget *alarm_mail; - GtkWidget *alarm_display_amount; - GtkWidget *alarm_display_unit; - GtkWidget *alarm_audio_amount; - GtkWidget *alarm_audio_unit; - GtkWidget *alarm_program_amount; - GtkWidget *alarm_program_unit; - GtkWidget *alarm_program_run_program; - GtkWidget *alarm_program_run_program_entry; - GtkWidget *alarm_mail_amount; - GtkWidget *alarm_mail_unit; - GtkWidget *alarm_mail_mail_to; - - GtkWidget *classification_radio; - - GtkWidget *recurrence_rule_notebook; - GtkWidget *recurrence_rule_none; - GtkWidget *recurrence_rule_daily; - GtkWidget *recurrence_rule_weekly; - GtkWidget *recurrence_rule_monthly; - GtkWidget *recurrence_rule_yearly; - - GtkWidget *recurrence_rule_daily_days; - - GtkWidget *recurrence_rule_weekly_weeks; - GtkWidget *recurrence_rule_weekly_sun; - GtkWidget *recurrence_rule_weekly_mon; - GtkWidget *recurrence_rule_weekly_tue; - GtkWidget *recurrence_rule_weekly_wed; - GtkWidget *recurrence_rule_weekly_thu; - GtkWidget *recurrence_rule_weekly_fri; - GtkWidget *recurrence_rule_weekly_sat; - - GtkWidget *recurrence_rule_monthly_on_day; - GtkWidget *recurrence_rule_monthly_weekday; - GtkWidget *recurrence_rule_monthly_day_nth; - GtkWidget *recurrence_rule_monthly_week; - GtkWidget *recurrence_rule_monthly_weekpos; - GtkWidget *recurrence_rule_monthly_every_n_months; - GtkWidget *recurrence_rule_yearly_every_n_years; - - GtkWidget *recurrence_ending_date_repeat_forever; - GtkWidget *recurrence_ending_date_end_on; - GtkWidget *recurrence_ending_date_end_on_date; - GtkWidget *recurrence_ending_date_end_after; - GtkWidget *recurrence_ending_date_end_after_count; - - GtkWidget *recurrence_exceptions_date; - GtkWidget *recurrence_exceptions_list; - GtkWidget *recurrence_exception_add; - GtkWidget *recurrence_exception_delete; - GtkWidget *recurrence_exception_change; - - GtkWidget *exception_list; - GtkWidget *exception_date; -} EventEditorPrivate; - - - -/* Signal IDs */ -enum { - SAVE_ICAL_OBJECT, - ICAL_OBJECT_RELEASED, - EDITOR_CLOSED, - LAST_SIGNAL -}; - -static void event_editor_class_init (EventEditorClass *class); -static void event_editor_init (EventEditor *ee); -static void event_editor_destroy (GtkObject *object); - -static GtkObjectClass *parent_class; - -extern int day_begin, day_end; -extern char *user_name; -extern int am_pm_flag; -extern int week_starts_on_monday; - - -static void append_exception (EventEditor *ee, time_t t); -static void check_all_day (EventEditor *ee); -static void set_all_day (GtkWidget *toggle, EventEditor *ee); -static void alarm_toggle (GtkWidget *toggle, EventEditor *ee); -static void check_dates (GnomeDateEdit *gde, EventEditor *ee); -static void check_times (GnomeDateEdit *gde, EventEditor *ee); -static void recurrence_toggled (GtkWidget *radio, EventEditor *ee); -static void recurrence_exception_added (GtkWidget *widget, EventEditor *ee); -static void recurrence_exception_deleted (GtkWidget *widget, EventEditor *ee); -static void recurrence_exception_changed (GtkWidget *widget, EventEditor *ee); - -static guint event_editor_signals[LAST_SIGNAL]; - - - -/** - * event_editor_get_type: - * @void: - * - * Registers the #EventEditor class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #EventEditor class. - **/ -GtkType -event_editor_get_type (void) -{ - static GtkType event_editor_type = 0; - - if (!event_editor_type) { - static const GtkTypeInfo event_editor_info = { - "EventEditor", - sizeof (EventEditor), - sizeof (EventEditorClass), - (GtkClassInitFunc) event_editor_class_init, - (GtkObjectInitFunc) event_editor_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - event_editor_type = gtk_type_unique (GTK_TYPE_OBJECT, &event_editor_info); - } - - return event_editor_type; -} - -/* Class initialization function for the event editor */ -static void -event_editor_class_init (EventEditorClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - event_editor_signals[SAVE_ICAL_OBJECT] = - gtk_signal_new ("save_ical_object", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EventEditorClass, save_ical_object), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - event_editor_signals[ICAL_OBJECT_RELEASED] = - gtk_signal_new ("ical_object_released", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EventEditorClass, ical_object_released), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - event_editor_signals[EDITOR_CLOSED] = - gtk_signal_new ("editor_closed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EventEditorClass, editor_closed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, event_editor_signals, LAST_SIGNAL); - - object_class->destroy = event_editor_destroy; -} - -/* Object initialization function for the event editor */ -static void -event_editor_init (EventEditor *ee) -{ - EventEditorPrivate *priv; - - priv = g_new0 (EventEditorPrivate, 1); - ee->priv = priv; -} - -/* Destroy handler for the event editor */ -static void -event_editor_destroy (GtkObject *object) -{ - EventEditor *ee; - EventEditorPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_EVENT_EDITOR (object)); - - ee = EVENT_EDITOR (object); - priv = ee->priv; - - if (priv->uih) { - bonobo_object_unref (BONOBO_OBJECT (priv->uih)); - priv->uih = NULL; - } - - if (priv->app) { - gtk_signal_disconnect_by_data (GTK_OBJECT (priv->app), ee); - gtk_widget_destroy (priv->app); - priv->app = NULL; - } - - if (priv->comp) { - /* We do not emit the "ical_object_released" signal here. If - * the user cloased the dialog box, then it has already been - * released. If the application just destroyed the event - * editor, then it had better clean up after itself. - */ - gtk_object_unref (GTK_OBJECT (priv->comp)); - priv->comp = NULL; - } - - if (priv->xml) { - gtk_object_unref (GTK_OBJECT (priv->xml)); - priv->xml = NULL; - } - - g_free (priv); - ee->priv = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* Creates an appropriate title for the event editor dialog */ -static char * -make_title_from_comp (CalComponent *comp) -{ - const char *summary; - CalComponentVType type; - CalComponentText text; - - if (!comp) - return g_strdup (_("Edit Appointment")); - - cal_component_get_summary (comp, &text); - if (text.value) - summary = text.value; - else - summary = _("No summary"); - - - type = cal_component_get_vtype (comp); - switch (type) { - case CAL_COMPONENT_EVENT: - return g_strdup_printf (_("Appointment - %s"), summary); - - case CAL_COMPONENT_TODO: - return g_strdup_printf (_("Task - %s"), summary); - - case CAL_COMPONENT_JOURNAL: - return g_strdup_printf (_("Journal entry - %s"), summary); - - default: - g_message ("make_title_from_comp(): Cannot handle object of type %d", type); - return NULL; - } -} - -/* 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 (EventEditor *ee) -{ - EventEditorPrivate *priv; - - priv = ee->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - priv->app = GW ("event-editor-dialog"); - - priv->general_owner = GW ("general-owner"); - priv->general_summary = GW ("general-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->alarm_display = GW ("alarm-display"); - priv->alarm_program = GW ("alarm-program"); - priv->alarm_audio = GW ("alarm-audio"); - priv->alarm_mail = GW ("alarm-mail"); - priv->alarm_display_amount = GW ("alarm-display-amount"); - priv->alarm_display_unit = GW ("alarm-display-unit"); - priv->alarm_audio_amount = GW ("alarm-audio-amount"); - priv->alarm_audio_unit = GW ("alarm-audio-unit"); - priv->alarm_program_amount = GW ("alarm-program-amount"); - priv->alarm_program_unit = GW ("alarm-program-unit"); - priv->alarm_program_run_program = GW ("alarm-program-run-program"); - priv->alarm_program_run_program_entry = GW ("alarm-program-run-program-entry"); - priv->alarm_mail_amount = GW ("alarm-mail-amount"); - priv->alarm_mail_unit = GW ("alarm-mail-unit"); - priv->alarm_mail_mail_to = GW ("alarm-mail-mail-to"); - - priv->classification_radio = GW ("classification-radio"); - - priv->recurrence_rule_notebook = GW ("recurrence-rule-notebook"); - priv->recurrence_rule_none = GW ("recurrence-rule-none"); - priv->recurrence_rule_daily = GW ("recurrence-rule-daily"); - priv->recurrence_rule_weekly = GW ("recurrence-rule-weekly"); - priv->recurrence_rule_monthly = GW ("recurrence-rule-monthly"); - priv->recurrence_rule_yearly = GW ("recurrence-rule-yearly"); - - priv->recurrence_rule_daily_days = GW ("recurrence-rule-daily-days"); - - priv->recurrence_rule_weekly_weeks = GW ("recurrence-rule-weekly-weeks"); - priv->recurrence_rule_weekly_sun = GW ("recurrence-rule-weekly-sun"); - priv->recurrence_rule_weekly_mon = GW ("recurrence-rule-weekly-mon"); - priv->recurrence_rule_weekly_tue = GW ("recurrence-rule-weekly-tue"); - priv->recurrence_rule_weekly_wed = GW ("recurrence-rule-weekly-wed"); - priv->recurrence_rule_weekly_thu = GW ("recurrence-rule-weekly-thu"); - priv->recurrence_rule_weekly_fri = GW ("recurrence-rule-weekly-fri"); - priv->recurrence_rule_weekly_sat = GW ("recurrence-rule-weekly-sat"); - - priv->recurrence_rule_monthly_on_day = GW ("recurrence-rule-monthly-on-day"); - priv->recurrence_rule_monthly_weekday = GW ("recurrence-rule-monthly-weekday"); - priv->recurrence_rule_monthly_day_nth = GW ("recurrence-rule-monthly-day-nth"); - priv->recurrence_rule_monthly_week = GW ("recurrence-rule-monthly-week"); - priv->recurrence_rule_monthly_weekpos = GW ("recurrence-rule-monthly-weekpos"); - priv->recurrence_rule_monthly_every_n_months = GW ("recurrence-rule-monthly-every-n-months"); - priv->recurrence_rule_yearly_every_n_years = GW ("recurrence-rule-yearly-every-n-years"); - - priv->recurrence_ending_date_repeat_forever = GW ("recurrence-ending-date-repeat-forever"); - priv->recurrence_ending_date_end_on = GW ("recurrence-ending-date-end-on"); - priv->recurrence_ending_date_end_on_date = GW ("recurrence-ending-date-end-on-date"); - priv->recurrence_ending_date_end_after = GW ("recurrence-ending-date-end-after"); - priv->recurrence_ending_date_end_after_count = GW ("recurrence-ending-date-end-after-count"); - - priv->recurrence_exceptions_date = GW ("recurrence-exceptions-date"); - priv->recurrence_exceptions_list = GW ("recurrence-exceptions-list"); - priv->recurrence_exception_add = GW ("recurrence-exceptions-add"); - priv->recurrence_exception_delete = GW ("recurrence-exceptions-delete"); - priv->recurrence_exception_change = GW ("recurrence-exceptions-change"); - - priv->exception_list = GW ("recurrence-exceptions-list"); - priv->exception_date = GW ("recurrence-exceptions-date"); - -#undef GW - - return (priv->general_owner - && priv->general_summary - && priv->start_time - && priv->end_time - && priv->all_day_event - && priv->description - && priv->alarm_display - && priv->alarm_program - && priv->alarm_audio - && priv->alarm_mail - && priv->alarm_display_amount - && priv->alarm_display_unit - && priv->alarm_audio_amount - && priv->alarm_audio_unit - && priv->alarm_program_amount - && priv->alarm_program_unit - && priv->alarm_program_run_program - && priv->alarm_program_run_program_entry - && priv->alarm_mail_amount - && priv->alarm_mail_unit - && priv->alarm_mail_mail_to - && priv->classification_radio - && priv->recurrence_rule_notebook - && priv->recurrence_rule_none - && priv->recurrence_rule_daily - && priv->recurrence_rule_weekly - && priv->recurrence_rule_monthly - && priv->recurrence_rule_yearly - && priv->recurrence_rule_daily_days - && priv->recurrence_rule_weekly_weeks - && priv->recurrence_rule_monthly_on_day - && priv->recurrence_rule_monthly_weekday - && priv->recurrence_rule_monthly_day_nth - && priv->recurrence_rule_monthly_week - && priv->recurrence_rule_monthly_weekpos - && priv->recurrence_rule_monthly_every_n_months - && priv->recurrence_rule_yearly_every_n_years - && priv->recurrence_ending_date_repeat_forever - && priv->recurrence_ending_date_end_on - && priv->recurrence_ending_date_end_on_date - && priv->recurrence_ending_date_end_after - && priv->recurrence_ending_date_end_after_count - && priv->recurrence_exceptions_date - && priv->recurrence_exceptions_list - && priv->recurrence_exception_add - && priv->recurrence_exception_delete - && priv->recurrence_exception_change - && priv->exception_list - && priv->exception_date); -} - -static const int classification_map[] = { - CAL_COMPONENT_CLASS_PUBLIC, - CAL_COMPONENT_CLASS_PRIVATE, - CAL_COMPONENT_CLASS_CONFIDENTIAL, - -1 -}; - -#if 0 -static const int alarm_unit_map[] = { - ALARM_MINUTES, - ALARM_HOURS, - ALARM_DAYS, - -1 -}; - -static void -alarm_unit_set (GtkWidget *widget, enum AlarmUnit unit) -{ - e_dialog_option_menu_set (widget, unit, alarm_unit_map); -} - -static enum AlarmUnit -alarm_unit_get (GtkWidget *widget) -{ - return e_dialog_option_menu_get (widget, alarm_unit_map); -} -#endif - -/* Recurrence types for mapping them to radio buttons */ -static const int recur_options_map[] = { - ICAL_NO_RECURRENCE, - ICAL_DAILY_RECURRENCE, - ICAL_WEEKLY_RECURRENCE, - ICAL_MONTHLY_RECURRENCE, - ICAL_YEARLY_RECURRENCE, - -1 -}; - -static icalrecurrencetype_frequency -recur_options_get (GtkWidget *widget) -{ - return e_dialog_radio_get (widget, recur_options_map); -} - -static const int month_pos_map[] = { 0, 1, 2, 3, 4, -1 }; -static const int weekday_map[] = { 0, 1, 2, 3, 4, 5, 6, -1 }; - -/* Frees the rows and the row data in the recurrence exceptions GtkCList */ -static void -free_exception_clist_data (GtkCList *clist) -{ - int i; - - 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); -} - -/* Hooks the widget signals */ -static void -init_widgets (EventEditor *ee) -{ - EventEditorPrivate *priv; - GnomeDateEdit *gde; - GtkWidget *widget; - - priv = ee->priv; - - /* Start and end times */ - - gtk_signal_connect (GTK_OBJECT (priv->start_time), "date_changed", - GTK_SIGNAL_FUNC (check_dates), ee); - gtk_signal_connect (GTK_OBJECT (priv->start_time), "time_changed", - GTK_SIGNAL_FUNC (check_times), ee); - - gtk_signal_connect (GTK_OBJECT (priv->end_time), "date_changed", - GTK_SIGNAL_FUNC (check_dates), ee); - gtk_signal_connect (GTK_OBJECT (priv->end_time), "time_changed", - GTK_SIGNAL_FUNC (check_times), ee); - - gtk_signal_connect (GTK_OBJECT (priv->all_day_event), "toggled", - GTK_SIGNAL_FUNC (set_all_day), ee); - - /* Alarms */ - - gtk_signal_connect (GTK_OBJECT (priv->alarm_display), "toggled", - GTK_SIGNAL_FUNC (alarm_toggle), ee); - gtk_signal_connect (GTK_OBJECT (priv->alarm_program), "toggled", - GTK_SIGNAL_FUNC (alarm_toggle), ee); - gtk_signal_connect (GTK_OBJECT (priv->alarm_audio), "toggled", - GTK_SIGNAL_FUNC (alarm_toggle), ee); - gtk_signal_connect (GTK_OBJECT (priv->alarm_mail), "toggled", - GTK_SIGNAL_FUNC (alarm_toggle), ee); - - /* Recurrence types */ - - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_none), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_daily), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_weekly), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_monthly), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_rule_yearly), "toggled", - GTK_SIGNAL_FUNC (recurrence_toggled), ee); - - /* Exception buttons */ - - gtk_signal_connect (GTK_OBJECT (priv->recurrence_exception_add), "clicked", - GTK_SIGNAL_FUNC (recurrence_exception_added), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_exception_delete), "clicked", - GTK_SIGNAL_FUNC (recurrence_exception_deleted), ee); - gtk_signal_connect (GTK_OBJECT (priv->recurrence_exception_change), "clicked", - GTK_SIGNAL_FUNC (recurrence_exception_changed), ee); - - /* Hide the stupid 'Calendar' labels. */ - gde = GNOME_DATE_EDIT (priv->start_time); - gtk_widget_hide (gde->cal_label); - widget = gde->date_entry; - gtk_box_set_child_packing (GTK_BOX (widget->parent), widget, - FALSE, FALSE, 0, GTK_PACK_START); - widget = gde->time_entry; - gtk_box_set_child_packing (GTK_BOX (widget->parent), widget, - FALSE, FALSE, 0, GTK_PACK_START); - gtk_box_set_spacing (GTK_BOX (widget->parent), 2); - - gde = GNOME_DATE_EDIT (priv->end_time); - gtk_widget_hide (gde->cal_label); - widget = gde->date_entry; - gtk_box_set_child_packing (GTK_BOX (widget->parent), widget, - FALSE, FALSE, 0, GTK_PACK_START); - widget = gde->time_entry; - gtk_box_set_child_packing (GTK_BOX (widget->parent), widget, - FALSE, FALSE, 0, GTK_PACK_START); - gtk_box_set_spacing (GTK_BOX (widget->parent), 2); -} - -/* Fills the widgets with default values */ -static void -clear_widgets (EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t now; - - priv = ee->priv; - - now = time (NULL); - - /* Owner, summary */ - - e_dialog_editable_set (priv->general_owner, _("?")); - e_dialog_editable_set (priv->general_summary, NULL); - e_dialog_editable_set (priv->description, NULL); - - /* Start and end times */ - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - - e_dialog_dateedit_set (priv->start_time, now); - e_dialog_dateedit_set (priv->end_time, now); - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - - check_all_day (ee); - - /* Alarms */ - - /* FIXMe: these should use configurable defaults */ - - e_dialog_toggle_set (priv->alarm_display, FALSE); - e_dialog_toggle_set (priv->alarm_program, FALSE); - e_dialog_toggle_set (priv->alarm_audio, FALSE); - e_dialog_toggle_set (priv->alarm_mail, FALSE); - - e_dialog_spin_set (priv->alarm_display_amount, 15); - e_dialog_spin_set (priv->alarm_audio_amount, 15); - e_dialog_spin_set (priv->alarm_program_amount, 15); - e_dialog_spin_set (priv->alarm_mail_amount, 15); - -#if 0 - alarm_unit_set (priv->alarm_display_unit, ALARM_MINUTES); - alarm_unit_set (priv->alarm_audio_unit, ALARM_MINUTES); - alarm_unit_set (priv->alarm_program_unit, ALARM_MINUTES); - alarm_unit_set (priv->alarm_mail_unit, ALARM_MINUTES); -#endif - - e_dialog_editable_set (priv->alarm_program_run_program_entry, NULL); - e_dialog_editable_set (priv->alarm_mail_mail_to, NULL); - - /* Classification */ - - e_dialog_radio_set (priv->classification_radio, - CAL_COMPONENT_CLASS_PRIVATE, classification_map); - - /* Recurrences */ - - e_dialog_radio_set (priv->recurrence_rule_none, ICAL_NO_RECURRENCE, recur_options_map); - - e_dialog_spin_set (priv->recurrence_rule_daily_days, 1); - - e_dialog_spin_set (priv->recurrence_rule_weekly_weeks, 1); - e_dialog_toggle_set (priv->recurrence_rule_weekly_sun, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_mon, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_tue, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_wed, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_thu, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_fri, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_sat, FALSE); - - e_dialog_toggle_set (priv->recurrence_rule_monthly_on_day, TRUE); - e_dialog_spin_set (priv->recurrence_rule_monthly_day_nth, 1); - e_dialog_spin_set (priv->recurrence_rule_monthly_every_n_months, 1); - e_dialog_option_menu_set (priv->recurrence_rule_monthly_week, 0, month_pos_map); - e_dialog_option_menu_set (priv->recurrence_rule_monthly_weekpos, 0, weekday_map); - e_dialog_spin_set (priv->recurrence_rule_monthly_every_n_months, 1); - - e_dialog_spin_set (priv->recurrence_rule_yearly_every_n_years, 1); - - e_dialog_toggle_set (priv->recurrence_ending_date_repeat_forever, TRUE); - e_dialog_spin_set (priv->recurrence_ending_date_end_after_count, 1); - e_dialog_dateedit_set (priv->recurrence_ending_date_end_on_date, - time_add_day (time (NULL), 1)); - - /* Exceptions list */ - - free_exception_clist_data (GTK_CLIST (priv->recurrence_exceptions_list)); -} - -/* Fills in the widgets with the proper values */ -static void -fill_widgets (EventEditor *ee) -{ - EventEditorPrivate *priv; - CalComponentText text; - CalComponentClassification cl; - CalComponentDateTime d; - GSList *list, *l; - time_t dtstart, dtend; - - priv = ee->priv; - - clear_widgets (ee); - - if (!priv->comp) - return; - - /* Owner, summary */ -#warning "FIX ME" - /* kludge until I figure out where to get the organizer */ -/* e_dialog_editable_set (priv->general_owner, */ -/* priv->ico->organizer->addr ? */ -/* priv->ico->organizer->addr : _("?")); */ - e_dialog_editable_set (priv->general_owner, _("?")); - - cal_component_get_summary (priv->comp, &text); - e_dialog_editable_set (priv->general_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); - } - cal_component_free_text_list (l); - - /* Start and end times */ - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - - /* 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 (priv->comp, &d); - dtstart = time_from_icaltimetype (*d.value); - cal_component_get_dtend (priv->comp, &d); - dtend = time_from_icaltimetype (*d.value); - if (time_day_begin (dtstart) == dtstart - && time_day_begin (dtend) == dtend) { - dtend = time_add_day (dtend, -1); - } - - e_dialog_dateedit_set (priv->start_time, dtstart); - e_dialog_dateedit_set (priv->end_time, dtend); - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - - check_all_day (ee); - - /* Alarms */ -#if 0 - e_dialog_toggle_set (priv->alarm_display, priv->ico->dalarm.enabled); - e_dialog_toggle_set (priv->alarm_program, priv->ico->palarm.enabled); - e_dialog_toggle_set (priv->alarm_audio, priv->ico->aalarm.enabled); - e_dialog_toggle_set (priv->alarm_mail, priv->ico->malarm.enabled); -#endif - /* Alarm data */ -#if 0 - e_dialog_spin_set (priv->alarm_display_amount, priv->ico->dalarm.count); - e_dialog_spin_set (priv->alarm_audio_amount, priv->ico->aalarm.count); - e_dialog_spin_set (priv->alarm_program_amount, priv->ico->palarm.count); - e_dialog_spin_set (priv->alarm_mail_amount, priv->ico->malarm.count); - - alarm_unit_set (priv->alarm_display_unit, priv->ico->dalarm.units); - alarm_unit_set (priv->alarm_audio_unit, priv->ico->aalarm.units); - alarm_unit_set (priv->alarm_program_unit, priv->ico->palarm.units); - alarm_unit_set (priv->alarm_mail_unit, priv->ico->malarm.units); - - e_dialog_editable_set (priv->alarm_program_run_program_entry, priv->ico->palarm.data); - e_dialog_editable_set (priv->alarm_mail_mail_to, priv->ico->malarm.data); -#endif - /* Classification */ - cal_component_get_classification (priv->comp, &cl); - switch (cl) { - case CAL_COMPONENT_CLASS_PUBLIC: - e_dialog_radio_set (priv->classification_radio, CAL_COMPONENT_CLASS_PUBLIC, - classification_map); - case CAL_COMPONENT_CLASS_PRIVATE: - e_dialog_radio_set (priv->classification_radio, CAL_COMPONENT_CLASS_PRIVATE, - classification_map); - case CAL_COMPONENT_CLASS_CONFIDENTIAL: - e_dialog_radio_set (priv->classification_radio, 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. - */ - } - - /* Recurrences */ -#warning "FIX ME" - /* Need to handle recurrence dates as well as recurrence rules */ - /* Need to handle more than one rrule */ - if (cal_component_has_rrules (priv->comp)) { - struct icalrecurrencetype *r; - int i; - - cal_component_get_rrule_list (priv->comp, &list); - r = list->data; - - switch (r->freq) { - case ICAL_DAILY_RECURRENCE: - e_dialog_radio_set (priv->recurrence_rule_daily, ICAL_DAILY_RECURRENCE, - recur_options_map); - e_dialog_spin_set (priv->recurrence_rule_daily_days, r->interval); - break; - - case ICAL_WEEKLY_RECURRENCE: - e_dialog_radio_set (priv->recurrence_rule_weekly, ICAL_WEEKLY_RECURRENCE, - recur_options_map); - e_dialog_spin_set (priv->recurrence_rule_weekly_weeks, r->interval); - - e_dialog_toggle_set (priv->recurrence_rule_weekly_sun, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_mon, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_tue, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_wed, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_thu, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_fri, FALSE); - e_dialog_toggle_set (priv->recurrence_rule_weekly_sat, FALSE); - - for (i=0; i<8 && r->by_day[i] != SHRT_MAX; i++) { - switch (r->by_day[i]) { - case ICAL_SUNDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_sun, TRUE); - break; - case ICAL_MONDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_mon, TRUE); - break; - case ICAL_TUESDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_tue, TRUE); - break; - case ICAL_WEDNESDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_wed, TRUE); - break; - case ICAL_THURSDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_thu, TRUE); - break; - case ICAL_FRIDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_fri, TRUE); - break; - case ICAL_SATURDAY_WEEKDAY: - e_dialog_toggle_set (priv->recurrence_rule_weekly_sat, TRUE); - break; - default: - g_assert_not_reached (); - } - } - break; - - case ICAL_MONTHLY_RECURRENCE: - e_dialog_radio_set (priv->recurrence_rule_monthly, ICAL_MONTHLY_RECURRENCE, - recur_options_map); - - if (r->by_month_day[0] != SHRT_MAX) { - e_dialog_toggle_set (priv->recurrence_rule_monthly_on_day, TRUE); - e_dialog_spin_set (priv->recurrence_rule_monthly_day_nth, - r->by_month_day[0]); - } else if (r->by_day[0] != SHRT_MAX) { - e_dialog_toggle_set (priv->recurrence_rule_monthly_weekday, TRUE); - /* libical does not handle ints in by day */ -/* e_dialog_option_menu_set (priv->recurrence_rule_monthly_week, */ -/* priv->ico->recur->u.month_pos, */ -/* month_pos_map); */ -/* e_dialog_option_menu_set (priv->recurrence_rule_monthly_weekpos, */ -/* priv->ico->recur->weekday, */ -/* weekday_map); */ - } - - e_dialog_spin_set (priv->recurrence_rule_monthly_every_n_months, - r->interval); - break; - - case ICAL_YEARLY_RECURRENCE: - e_dialog_radio_set (priv->recurrence_rule_yearly, ICAL_YEARLY_RECURRENCE, - recur_options_map); - e_dialog_spin_set (priv->recurrence_rule_yearly_every_n_years, - r->interval); - break; - - default: - g_assert_not_reached (); - } - - if (r->until.year == 0) { - if (r->count == 0) - e_dialog_toggle_set (priv->recurrence_ending_date_repeat_forever, - TRUE); - else { - e_dialog_toggle_set (priv->recurrence_ending_date_end_after, TRUE); - e_dialog_spin_set (priv->recurrence_ending_date_end_after_count, - r->count); - } - } else { - time_t t = time_from_icaltimetype (r->until); - e_dialog_toggle_set (priv->recurrence_ending_date_end_on, TRUE); - /* Shorten by one day, as we store end-on date a day ahead */ - /* FIXME is this correct? */ - e_dialog_dateedit_set (priv->recurrence_ending_date_end_on_date, - time_add_day (t, -1)); - } - cal_component_free_recur_list (list); - } - - /* Exceptions list */ -#warning "FIX ME" - /* Need to handle exception rules as well as dates */ - cal_component_get_exdate_list (priv->comp, &list); - for (l = list; l; l = l->next) { - struct icaltimetype *t; - time_t ext; - - t = l->data; - ext = time_from_icaltimetype (*t); - append_exception (ee, ext); - } - cal_component_free_exdate_list (list); -} - - - -/* Decode the radio button group for classifications */ -static CalComponentClassification -classification_get (GtkWidget *widget) -{ - return e_dialog_radio_get (widget, classification_map); -} - -/* Get the values of the widgets in the event editor and put them in the iCalObject */ -static void -dialog_to_comp_object (EventEditor *ee) -{ - EventEditorPrivate *priv; - CalComponent *comp; - CalComponentText *text; - CalComponentDateTime date; - time_t t; - struct icalrecurrencetype *recur; - gboolean all_day_event; - int i, pos = 0; - GtkCList *exception_list; - GSList *list = NULL; - - priv = ee->priv; - comp = priv->comp; - - text = g_new0 (CalComponentText, 1); - text->value = e_dialog_editable_get (priv->general_summary); - cal_component_set_summary (comp, text); - - text->value = e_dialog_editable_get (priv->description); - g_slist_prepend (list, text); - cal_component_set_description_list (comp, list); - cal_component_free_text_list (list); - list = NULL; - - date.value = g_new (struct icaltimetype, 1); - t = e_dialog_dateedit_get (priv->start_time); - *date.value = icaltimetype_from_timet (t, FALSE); - cal_component_set_dtstart (comp, &date); - - /* 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_dialog_dateedit_get (priv->end_time); - if (all_day_event) - t = time_day_end (t); - - *date.value = icaltimetype_from_timet (t, FALSE); - cal_component_set_dtend (comp, &date); - g_free (date.value); - -#if 0 - ico->dalarm.enabled = e_dialog_toggle_get (priv->alarm_display); - ico->aalarm.enabled = e_dialog_toggle_get (priv->alarm_program); - ico->palarm.enabled = e_dialog_toggle_get (priv->alarm_audio); - ico->malarm.enabled = e_dialog_toggle_get (priv->alarm_mail); - - ico->dalarm.count = e_dialog_spin_get_int (priv->alarm_display_amount); - ico->aalarm.count = e_dialog_spin_get_int (priv->alarm_audio_amount); - ico->palarm.count = e_dialog_spin_get_int (priv->alarm_program_amount); - ico->malarm.count = e_dialog_spin_get_int (priv->alarm_mail_amount); - - ico->dalarm.units = alarm_unit_get (priv->alarm_display_unit); - ico->aalarm.units = alarm_unit_get (priv->alarm_audio_unit); - ico->palarm.units = alarm_unit_get (priv->alarm_program_unit); - ico->malarm.units = alarm_unit_get (priv->alarm_mail_unit); - - if (ico->palarm.data) - g_free (ico->palarm.data); - - if (ico->malarm.data) - g_free (ico->malarm.data); - - ico->palarm.data = e_dialog_editable_get (priv->alarm_program_run_program_entry); - ico->malarm.data = e_dialog_editable_get (priv->alarm_mail_mail_to); -#endif - - cal_component_set_classification (comp, classification_get (priv->classification_radio)); - - /* Recurrence information */ - recur = g_new (struct icalrecurrencetype, 1); - icalrecurrencetype_clear (recur); - recur->freq = recur_options_get (priv->recurrence_rule_none); - - switch (recur->freq) { - case ICAL_NO_RECURRENCE: - /* nothing */ - break; - - case ICAL_DAILY_RECURRENCE: - recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_daily_days); - break; - - case ICAL_WEEKLY_RECURRENCE: - - recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_weekly_weeks); - - - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_sun)) - recur->by_day[pos++] = ICAL_SUNDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_mon)) - recur->by_day[pos++] = ICAL_MONDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_tue)) - recur->by_day[pos++] = ICAL_TUESDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_wed)) - recur->by_day[pos++] = ICAL_WEDNESDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_thu)) - recur->by_day[pos++] = ICAL_THURSDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_fri)) - recur->by_day[pos++] = ICAL_FRIDAY_WEEKDAY; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_sat)) - recur->by_day[pos++] = ICAL_SATURDAY_WEEKDAY; - - break; - - case ICAL_MONTHLY_RECURRENCE: - - if (e_dialog_toggle_get (priv->recurrence_rule_monthly_on_day)) { - /* by day of in the month (ex: the 5th) */ - recur->by_month_day[0] = - e_dialog_spin_get_int (priv->recurrence_rule_monthly_day_nth); - } else if (e_dialog_toggle_get (priv->recurrence_rule_monthly_weekday)) { - /* "recurrence-rule-monthly-weekday" is TRUE */ - /* by position on the calender (ex: 2nd monday) */ - /* libical does not handle this yet */ -/* ico->recur->u.month_pos = e_dialog_option_menu_get ( */ -/* priv->recurrence_rule_monthly_week, */ -/* month_pos_map); */ -/* ico->recur->weekday = e_dialog_option_menu_get ( */ -/* priv->recurrence_rule_monthly_weekpos, */ -/* weekday_map); */ - - } else - g_assert_not_reached (); - - recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_monthly_every_n_months); - - break; - - case ICAL_YEARLY_RECURRENCE: - recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_yearly_every_n_years); - - default: - g_assert_not_reached (); - } - - /* recurrence ending date */ - if (e_dialog_toggle_get (priv->recurrence_ending_date_end_on)) { - /* Also here, to ensure that the event is used, we add 86400 - * secs to get get next day, in accordance to the RFC - */ - t = e_dialog_dateedit_get (priv->recurrence_ending_date_end_on_date) + 86400; - recur->until = icaltimetype_from_timet (t, TRUE); - } else if (e_dialog_toggle_get (priv->recurrence_ending_date_end_after)) { - recur->count = e_dialog_spin_get_int (priv->recurrence_ending_date_end_after_count); - } - g_slist_append (list, recur); - cal_component_set_rrule_list (comp, list); - list = NULL; - - /* Get exceptions from clist into ico->exdate */ - exception_list = GTK_CLIST (priv->recurrence_exceptions_list); - for (i = 0; i < exception_list->rows; i++) { - struct icaltimetype *tt = g_new (struct icaltimetype, 1); - time_t *t; - - t = gtk_clist_get_row_data (exception_list, i); - *tt = icaltimetype_from_timet (*t, FALSE); - - list = g_slist_prepend (list, tt); - } - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); -} - -/* Emits the "save_ical_object" signal if the event editor is editing an object. */ -static void -save_ical_object (EventEditor *ee) -{ - EventEditorPrivate *priv; - char *title; - - priv = ee->priv; - - if (!priv->comp) - return; - - dialog_to_comp_object (ee); - - title = make_title_from_comp (priv->comp); - gtk_window_set_title (GTK_WINDOW (priv->app), title); - g_free (title); - - gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[SAVE_ICAL_OBJECT], - priv->comp); -} - -/* Closes the dialog box and emits the appropriate signals */ -static void -close_dialog (EventEditor *ee) -{ - EventEditorPrivate *priv; - - priv = ee->priv; - - g_assert (priv->app != NULL); - - free_exception_clist_data (GTK_CLIST (priv->recurrence_exceptions_list)); - - gtk_widget_destroy (priv->app); - priv->app = NULL; - - if (priv->comp) { - const char *uid; - - cal_component_get_uid (priv->comp, &uid); - gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[ICAL_OBJECT_RELEASED], uid); - gtk_object_unref (GTK_OBJECT (priv->comp)); - priv->comp = NULL; - } - - gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[EDITOR_CLOSED]); -} - - - -/* File/Save callback */ -static void -file_save_cb (GtkWidget *widget, gpointer data) -{ - EventEditor *ee; - - ee = EVENT_EDITOR (data); - save_ical_object (ee); -} - -/* File/Close callback */ -static void -file_close_cb (GtkWidget *widget, gpointer data) -{ - EventEditor *ee; - - /* FIXME: need to check for a dirty object */ - - ee = EVENT_EDITOR (data); - close_dialog (ee); -} - - - -/* Menu bar */ - -static GnomeUIInfo file_new_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Appointment"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Meeting Re_quest"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mail Message"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Journal Entry"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Note"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_page_setup_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Memo Style"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Define Print _Styles..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_menu[] = { - GNOMEUIINFO_MENU_NEW_SUBTREE (file_new_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_SAVE_ITEM (file_save_cb, NULL), - GNOMEUIINFO_MENU_SAVE_AS_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Delete"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Move to Folder..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Cop_y to Folder..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("Page Set_up"), file_page_setup_menu), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print Pre_view"), NULL, NULL), - GNOMEUIINFO_MENU_PRINT_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_PROPERTIES_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLOSE_ITEM (file_close_cb, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_object_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: what goes here?", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_menu[] = { - GNOMEUIINFO_MENU_UNDO_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_REDO_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CUT_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_COPY_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_PASTE_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Paste _Special..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLEAR_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_SELECT_ALL_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Mark as U_nread"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_FIND_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_FIND_AGAIN_ITEM (NULL, NULL), - GNOMEUIINFO_SUBTREE (N_("_Object"), edit_object_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_previous_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Fi_rst Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_next_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Last Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_toolbars_menu[] = { - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: _Standard"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: __Formatting"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Customize..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_menu[] = { - GNOMEUIINFO_SUBTREE (N_("Pre_vious"), view_previous_menu), - GNOMEUIINFO_SUBTREE (N_("Ne_xt"), view_next_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ca_lendar..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Toolbars"), view_toolbars_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo insert_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _File..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: It_em..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Object..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo format_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Font..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Paragraph..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_forms_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Desi_gn This Form"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: D_esign a Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Publish _Form..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Pu_blish Form As..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Script _Debugger"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Spelling..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Chec_k Names"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Address _Book..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Forms"), tools_forms_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo actions_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _New Appointment"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Rec_urrence..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Invite _Attendees..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: C_ancel Invitation..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Forward as v_Calendar"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: For_ward"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo help_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: fix Bonobo so it supports help items!", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo main_menu[] = { - GNOMEUIINFO_MENU_FILE_TREE (file_menu), - GNOMEUIINFO_MENU_EDIT_TREE (edit_menu), - GNOMEUIINFO_MENU_VIEW_TREE (view_menu), - GNOMEUIINFO_SUBTREE (N_("_Insert"), insert_menu), - GNOMEUIINFO_SUBTREE (N_("F_ormat"), format_menu), - GNOMEUIINFO_SUBTREE (N_("_Tools"), tools_menu), - GNOMEUIINFO_SUBTREE (N_("Actio_ns"), actions_menu), - GNOMEUIINFO_MENU_HELP_TREE (help_menu), - GNOMEUIINFO_END -}; - -/* Creates the menu bar for the event editor */ -static void -create_menu (EventEditor *ee) -{ - EventEditorPrivate *priv; - BonoboUIHandlerMenuItem *list; - - priv = ee->priv; - - bonobo_ui_handler_create_menubar (priv->uih); - - list = bonobo_ui_handler_menu_parse_uiinfo_list_with_data (main_menu, ee); - bonobo_ui_handler_menu_add_list (priv->uih, "/", list); -} - - - -/* Toolbar/Save and Close callback */ -static void -tb_save_and_close_cb (GtkWidget *widget, gpointer data) -{ - EventEditor *ee; - - ee = EVENT_EDITOR (data); - save_ical_object (ee); - close_dialog (ee); -} - - - -/* Toolbar */ - -static GnomeUIInfo toolbar[] = { - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Save and Close"), - N_("Save the appointment and close the dialog box"), - tb_save_and_close_cb, - GNOME_STOCK_PIXMAP_SAVE), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print..."), - N_("Print this item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Insert File..."), - N_("Insert a file as an attachment"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Recurrence..."), - N_("Configure recurrence rules"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Invite Attendees..."), - N_("Invite attendees to a meeting"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Delete"), - N_("Delete this item"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Previous"), - N_("Go to the previous item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Next"), - N_("Go to the next item"), NULL), - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Help"), - N_("See online help"), NULL, GNOME_STOCK_PIXMAP_HELP), - GNOMEUIINFO_END -}; - -/* Creates the toolbar for the event editor */ -static void -create_toolbar (EventEditor *ee) -{ - EventEditorPrivate *priv; - BonoboUIHandlerToolbarItem *list; - GnomeDockItem *dock_item; - GtkWidget *toolbar_child; - - priv = ee->priv; - - bonobo_ui_handler_create_toolbar (priv->uih, "Toolbar"); - - /* Fetch the toolbar. What a pain in the ass. */ - - dock_item = gnome_app_get_dock_item_by_name (GNOME_APP (priv->app), GNOME_APP_TOOLBAR_NAME); - g_assert (dock_item != NULL); - - toolbar_child = gnome_dock_item_get_child (dock_item); - g_assert (toolbar_child != NULL && GTK_IS_TOOLBAR (toolbar_child)); - - /* Turn off labels as GtkToolbar sucks */ - gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_child), GTK_TOOLBAR_ICONS); - - list = bonobo_ui_handler_toolbar_parse_uiinfo_list_with_data (toolbar, ee); - bonobo_ui_handler_toolbar_add_list (priv->uih, "/Toolbar", list); -} - - - -/* Callback used when the dialog box is destroyed */ -static gint -app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - EventEditor *ee; - - /* FIXME: need to check for a dirty object */ - - ee = EVENT_EDITOR (data); - close_dialog (ee); - - return TRUE; -} - -/** - * event_editor_construct: - * @ee: An event editor. - * - * Constructs an event editor by loading its Glade data. - * - * Return value: The same object as @ee, or NULL if the widgets could not be - * created. In the latter case, the event editor will automatically be - * destroyed. - **/ -EventEditor * -event_editor_construct (EventEditor *ee) -{ - EventEditorPrivate *priv; - - g_return_val_if_fail (ee != NULL, NULL); - g_return_val_if_fail (IS_EVENT_EDITOR (ee), NULL); - - priv = ee->priv; - - /* Load the content widgets */ - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/event-editor-dialog.glade", NULL); - if (!priv->xml) { - g_message ("event_editor_construct(): Could not load the Glade XML file!"); - goto error; - } - - if (!get_widgets (ee)) { - g_message ("event_editor_construct(): Could not find all widgets in the XML file!"); - goto error; - } - - init_widgets (ee); - - /* Construct the app */ - - priv->uih = bonobo_ui_handler_new (); - if (!priv->uih) { - g_message ("event_editor_construct(): Could not create the UI handler"); - goto error; - } - - bonobo_ui_handler_set_app (priv->uih, GNOME_APP (priv->app)); - - create_menu (ee); - create_toolbar (ee); - - /* Hook to destruction of the dialog */ - - gtk_signal_connect (GTK_OBJECT (priv->app), "delete_event", - GTK_SIGNAL_FUNC (app_delete_event_cb), ee); - - /* Show the dialog */ - - gtk_widget_show (priv->app); - - return ee; - - error: - - gtk_object_unref (GTK_OBJECT (ee)); - return NULL; -} - -/** - * event_editor_new: - * - * Creates a new event editor dialog. - * - * Return value: A newly-created event editor dialog, or NULL if the event - * editor could not be created. - **/ -EventEditor * -event_editor_new (void) -{ - EventEditor *ee; - - ee = EVENT_EDITOR (gtk_type_new (TYPE_EVENT_EDITOR)); - return event_editor_construct (EVENT_EDITOR (ee)); -} - -/** - * event_editor_set_ical_object: - * @ee: An event editor. - * @comp: A calendar object. - * - * Sets the calendar object that an event editor dialog will manipulate. - **/ -void -event_editor_set_ical_object (EventEditor *ee, CalComponent *comp) -{ - EventEditorPrivate *priv; - char *title; - - g_return_if_fail (ee != NULL); - g_return_if_fail (IS_EVENT_EDITOR (ee)); - - priv = ee->priv; - - if (priv->comp) { - const char *uid; - - cal_component_get_uid (priv->comp, &uid); - gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[ICAL_OBJECT_RELEASED], uid); - gtk_object_unref (GTK_OBJECT (priv->comp)); - priv->comp = NULL; - } - - if (comp) - priv->comp = cal_component_clone (comp); - - title = make_title_from_comp (priv->comp); - gtk_window_set_title (GTK_WINDOW (priv->app), title); - g_free (title); - - fill_widgets (ee); -} - -/* 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); -} - -/** - * event_editor_focus: - * @ee: An event editor. - * - * Makes sure an event editor is shown, on top of other windows, and focused. - **/ -void -event_editor_focus (EventEditor *ee) -{ - EventEditorPrivate *priv; - - g_return_if_fail (ee != NULL); - g_return_if_fail (IS_EVENT_EDITOR (ee)); - - priv = ee->priv; - gtk_widget_show_now (priv->app); - raise_and_focus (priv->app); -} - -static void -alarm_toggle (GtkWidget *toggle, EventEditor *ee) -{ - EventEditorPrivate *priv; - GtkWidget *alarm_amount = NULL; - GtkWidget *alarm_unit = NULL; - gboolean active; - - priv = ee->priv; - - active = GTK_TOGGLE_BUTTON (toggle)->active; - - if (toggle == priv->alarm_display) { - alarm_amount = priv->alarm_display_amount; - alarm_unit = priv->alarm_display_unit; - } else if (toggle == priv->alarm_audio) { - alarm_amount = priv->alarm_audio_amount; - alarm_unit = priv->alarm_audio_unit; - } else if (toggle == priv->alarm_program) { - alarm_amount = priv->alarm_program_amount; - alarm_unit = priv->alarm_program_unit; - gtk_widget_set_sensitive (priv->alarm_program_run_program, active); - } else if (toggle == priv->alarm_mail) { - alarm_amount = priv->alarm_mail_amount; - alarm_unit = priv->alarm_mail_unit; - gtk_widget_set_sensitive (priv->alarm_mail_mail_to, active); - } else - g_assert_not_reached (); - - gtk_widget_set_sensitive (alarm_amount, active); - gtk_widget_set_sensitive (alarm_unit, active); -} - -/* - * Checks if the day range occupies all the day, and if so, check the - * box accordingly - */ -static void -check_all_day (EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t ev_start, ev_end; - - priv = ee->priv; - - ev_start = e_dialog_dateedit_get (priv->start_time); - ev_end = e_dialog_dateedit_get (priv->end_time); - - /* all day event checkbox */ - if (time_day_begin (ev_start) == ev_start - && time_day_begin (ev_end) == ev_end) - e_dialog_toggle_set (priv->all_day_event, TRUE); - else - e_dialog_toggle_set (priv->all_day_event, FALSE); -} - -/* - * Callback: all day event box clicked - */ -static void -set_all_day (GtkWidget *toggle, EventEditor *ee) -{ - EventEditorPrivate *priv; - struct tm start_tm, end_tm; - time_t start_t, end_t; - gboolean all_day; - int flags; - - priv = ee->priv; - - /* If the all_day toggle is set, the end date is inclusive of the - entire day on which it points to. */ - all_day = GTK_TOGGLE_BUTTON (toggle)->active; - - start_t = e_dialog_dateedit_get (priv->start_time); - start_tm = *localtime (&start_t); - start_tm.tm_min = 0; - start_tm.tm_sec = 0; - - if (all_day) - start_tm.tm_hour = 0; - else - start_tm.tm_hour = day_begin; - - e_dialog_dateedit_set (priv->start_time, mktime (&start_tm)); - - end_t = e_dialog_dateedit_get (priv->end_time); - end_tm = *localtime (&end_t); - end_tm.tm_min = 0; - end_tm.tm_sec = 0; - - if (all_day) { - /* mktime() will fix this if we go past the end of the month.*/ - end_tm.tm_hour = 0; - } else { - if (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) - end_tm.tm_hour = start_tm.tm_hour + 1; - } - - flags = gnome_date_edit_get_flags (GNOME_DATE_EDIT (priv->start_time)); - if (all_day) - flags &= ~GNOME_DATE_EDIT_SHOW_TIME; - else - flags |= GNOME_DATE_EDIT_SHOW_TIME; - gnome_date_edit_set_flags (GNOME_DATE_EDIT (priv->start_time), flags); - gnome_date_edit_set_flags (GNOME_DATE_EDIT (priv->end_time), flags); - - e_dialog_dateedit_set (priv->end_time, mktime (&end_tm)); - - gtk_widget_hide (GNOME_DATE_EDIT (priv->start_time)->cal_label); - gtk_widget_hide (GNOME_DATE_EDIT (priv->end_time)->cal_label); -} - -/* - * Callback: checks that the dates are start < end - */ -static void -check_dates (GnomeDateEdit *gde, EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t start, end; - struct tm tm_start, tm_end; - - priv = ee->priv; - - start = e_dialog_dateedit_get (priv->start_time); - end = e_dialog_dateedit_get (priv->end_time); - - if (start > end) { - tm_start = *localtime (&start); - tm_end = *localtime (&end); - - if (GTK_WIDGET (gde) == priv->start_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; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - e_dialog_dateedit_set (priv->end_time, mktime (&tm_end)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - } else if (GTK_WIDGET (gde) == priv->end_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; - -#if 0 - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - e_dialog_dateedit_set (priv->start_time, mktime (&tm_start)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); -#endif - } - } -} - -/* - * Callback: checks that start_time < end_time and whether the - * selected hour range spans all of the day - */ -static void -check_times (GnomeDateEdit *gde, EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t start, end; - struct tm tm_start, tm_end; - - priv = ee->priv; -#if 0 - gdk_pointer_ungrab (GDK_CURRENT_TIME); - gdk_flush (); -#endif - start = e_dialog_dateedit_get (priv->start_time); - end = e_dialog_dateedit_get (priv->end_time); - - if (start > end) { - tm_start = *localtime (&start); - tm_end = *localtime (&end); - - if (GTK_WIDGET (gde) == priv->start_time) { - tm_end.tm_min = tm_start.tm_min; - tm_end.tm_sec = tm_start.tm_sec; - tm_end.tm_hour = tm_start.tm_hour + 1; - - if (tm_end.tm_hour >= 24) { - tm_end.tm_hour = 24; /* mktime() will bump the day */ - tm_end.tm_min = 0; - tm_end.tm_sec = 0; - } - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->end_time), ee); - e_dialog_dateedit_set (priv->end_time, mktime (&tm_end)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->end_time), ee); - } else if (GTK_WIDGET (gde) == priv->end_time) { - tm_start.tm_min = tm_end.tm_min; - tm_start.tm_sec = tm_end.tm_sec; - tm_start.tm_hour = tm_end.tm_hour - 1; - - if (tm_start.tm_hour < 0) { - tm_start.tm_hour = 0; - tm_start.tm_min = 0; - tm_start.tm_min = 0; - } - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time), ee); - e_dialog_dateedit_set (priv->start_time, mktime (&tm_start)); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->start_time), ee); - } - } - - /* Check whether the event spans the whole day */ - - check_all_day (ee); -} - -static void -recurrence_toggled (GtkWidget *radio, EventEditor *ee) -{ - EventEditorPrivate *priv; - icalrecurrencetype_frequency rf; - - priv = ee->priv; - - if (!GTK_TOGGLE_BUTTON (radio)->active) - return; - - rf = e_dialog_radio_get (radio, recur_options_map); - - gtk_notebook_set_page (GTK_NOTEBOOK (priv->recurrence_rule_notebook), (int) rf); -} - - -static char * -get_exception_string (time_t t) -{ - static char buf[256]; - - strftime (buf, sizeof (buf), _("%a %b %d %Y"), localtime (&t)); - return buf; -} - - -static void -append_exception (EventEditor *ee, time_t t) -{ - EventEditorPrivate *priv; - time_t *tt; - char *c[1]; - int i; - GtkCList *clist; - - priv = ee->priv; - - c[0] = get_exception_string (t); - - tt = g_new (time_t, 1); - *tt = t; - - clist = GTK_CLIST (priv->recurrence_exceptions_list); - - i = gtk_clist_append (clist, c); - gtk_clist_set_row_data (clist, i, tt); - gtk_clist_select_row (clist, i, 0); - -/* gtk_widget_set_sensitive (ee->recur_ex_vbox, TRUE); */ -} - - -static void -recurrence_exception_added (GtkWidget *widget, EventEditor *ee) -{ - EventEditorPrivate *priv; - time_t t; - - priv = ee->priv; - - t = e_dialog_dateedit_get (priv->recurrence_exceptions_date); - append_exception (ee, t); -} - - -static void -recurrence_exception_deleted (GtkWidget *widget, EventEditor *ee) -{ - EventEditorPrivate *priv; - GtkCList *clist; - int sel; - - priv = ee->priv; - - clist = GTK_CLIST (priv->recurrence_exceptions_list); - if (!clist->selection) - return; - - sel = GPOINTER_TO_INT (clist->selection->data); - - g_free (gtk_clist_get_row_data (clist, sel)); /* free the time_t stored there */ - - gtk_clist_remove (clist, sel); - if (sel >= clist->rows) - sel--; - - gtk_clist_select_row (clist, sel, 0); -} - - -static void -recurrence_exception_changed (GtkWidget *widget, EventEditor *ee) -{ - EventEditorPrivate *priv; - GtkCList *clist; - time_t *t; - int sel; - - priv = ee->priv; - - clist = GTK_CLIST (priv->recurrence_exceptions_list); - if (!clist->selection) - return; - - sel = GPOINTER_TO_INT (clist->selection->data); - - t = gtk_clist_get_row_data (clist, sel); - *t = e_dialog_dateedit_get (priv->recurrence_exceptions_date); - - gtk_clist_set_text (clist, sel, 0, get_exception_string (*t)); -} - - -GtkWidget * -make_date_edit (void) -{ - return date_edit_new (time (NULL), FALSE); -} - - -GtkWidget * -make_date_edit_with_time (void) -{ - return date_edit_new (time (NULL), TRUE); -} - - -GtkWidget * -date_edit_new (time_t the_time, int show_time) -{ - return gnome_date_edit_new_flags (the_time, - ((show_time ? GNOME_DATE_EDIT_SHOW_TIME : 0) - | (am_pm_flag ? 0 : GNOME_DATE_EDIT_24_HR) - | (week_starts_on_monday - ? GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY - : 0))); -} - - - -GtkWidget * -make_spin_button (int val, int low, int high) -{ - GtkAdjustment *adj; - GtkWidget *spin; - - adj = GTK_ADJUSTMENT (gtk_adjustment_new (val, low, high, 1, 10, 10)); - spin = gtk_spin_button_new (adj, 0.5, 0); - gtk_widget_set_usize (spin, 60, 0); - - return spin; -} - - -/* todo - - build some of the recur stuff by hand to take into account - the start-on-monday preference? - - get the apply button to work right - - make the properties stuff unglobal - - figure out why alarm units aren't sticking between edits - - closing the dialog window with the wm caused a crash - Gtk-WARNING **: invalid cast from `(unknown)' to `GnomeDialog' - on line 669: gnome_dialog_close (GNOME_DIALOG(dialog->dialog)); - */ diff --git a/calendar/gui/event-editor.h b/calendar/gui/event-editor.h deleted file mode 100644 index 8e95e08cfb..0000000000 --- a/calendar/gui/event-editor.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Evolution calendar - Event editor dialog - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Miguel de Icaza <miguel@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * Seth Alves <alves@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __EVENT_EDITOR_DIALOG_H__ -#define __EVENT_EDITOR_DIALOG_H__ - -#include <libgnome/gnome-defs.h> -#include <gtk/gtkobject.h> -#include "gnome-cal.h" - - - -#define TYPE_EVENT_EDITOR (event_editor_get_type ()) -#define EVENT_EDITOR(obj) (GTK_CHECK_CAST ((obj), TYPE_EVENT_EDITOR, EventEditor)) -#define EVENT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_EVENT_EDITOR, \ - EventEditorClass)) -#define IS_EVENT_EDITOR(obj) (GTK_CHECK_TYPE ((obj), TYPE_EVENT_EDITOR)) -#define IS_EVENT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_EVENT_EDITOR)) - -typedef struct _EventEditor EventEditor; -typedef struct _EventEditorClass EventEditorClass; - -struct _EventEditor { - GtkObject object; - - /* Private data */ - gpointer priv; -}; - -struct _EventEditorClass { - GtkObjectClass parent_class; - - /* Notification signals */ - - void (* save_ical_object) (EventEditor *ee, CalComponent *comp); - void (* ical_object_released) (EventEditor *ee, const char *uid); - void (* editor_closed) (EventEditor *ee); -}; - - -GtkType event_editor_get_type (void); -EventEditor *event_editor_construct (EventEditor *ee); - -EventEditor *event_editor_new (void); - -void event_editor_set_ical_object (EventEditor *ee, CalComponent *comp); - -void event_editor_focus (EventEditor *ee); - -#if 0 -/* Convenience function to create and show a new event editor for an - * event that goes from day_begin to day_end of the specified day. - */ -void event_editor_new_whole_day (GnomeCalendar *owner, time_t day); -#endif - -GtkWidget *make_date_edit (void); -GtkWidget *make_date_edit_with_time (void); -GtkWidget *date_edit_new (time_t the_time, int show_time); - -GtkWidget *make_spin_button (int val, int low, int high); - - - -#endif /* __EVENT_EDITOR_DIALOG_H__ */ diff --git a/calendar/gui/evolution-calendar-control.c b/calendar/gui/evolution-calendar-control.c deleted file mode 100644 index 7ebe2b5f8e..0000000000 --- a/calendar/gui/evolution-calendar-control.c +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include <gnome.h> -#include <glade/glade.h> -#include <bonobo.h> -#include <bonobo/bonobo-control.h> -#include <glade/glade.h> - -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif - -#include <cal-util/timeutil.h> -#include <gui/alarm.h> -#include <gui/gnome-cal.h> -#include <gui/calendar-commands.h> - -#define PROPERTY_CALENDAR_URI "folder_uri" - -#define PROPERTY_CALENDAR_URI_IDX 1 - -#ifdef USING_OAF -#define CONTROL_FACTORY_ID "OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" -#else -#define CONTROL_FACTORY_ID "control-factory:calendar" -#endif - -CORBA_Environment ev; -CORBA_ORB orb; - - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data) -{ - if (activate) - calendar_control_activate (control, user_data); - else - calendar_control_deactivate (control); -} - - - -static void -init_bonobo (int *argc, char **argv) -{ -#ifdef USING_OAF - /* FIXME: VERSION instead of "0.0". */ - gnome_init_with_popt_table ("evolution-calendar", "0.0", - *argc, argv, oaf_popt_options, - 0, NULL); - oaf_init (*argc, argv); -#else - gnome_CORBA_init_with_popt_table ( - "evolution-calendar", "0.0", - argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); -#endif - - if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); - - glade_gnome_init (); -} - - - -static void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - /*GnomeCalendar *gcal = user_data;*/ - - switch (arg_id) { - - case PROPERTY_CALENDAR_URI_IDX: - /* - if (fb && fb->uri) - BONOBO_ARG_SET_STRING (arg, fb->uri); - else - BONOBO_ARG_SET_STRING (arg, ""); - */ - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - } -} - -static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - GnomeCalendar *gcal = user_data; - char *filename; - - switch (arg_id) { - - case PROPERTY_CALENDAR_URI_IDX: - printf ("set_prop: '%s'\n", BONOBO_ARG_GET_STRING (arg)); - filename = g_strdup_printf ("%s/calendar.vcf", - BONOBO_ARG_GET_STRING (arg)); - calendar_set_uri (gcal, filename); - g_free (filename); - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - break; - } -} - - -static void -calendar_properties_init (GnomeCalendar *gcal) -{ - gcal->properties = bonobo_property_bag_new (get_prop, set_prop, gcal); - - bonobo_property_bag_add (gcal->properties, - PROPERTY_CALENDAR_URI, - PROPERTY_CALENDAR_URI_IDX, - BONOBO_ARG_STRING, - NULL, - _("The URI that the calendar will display"), - 0); - - bonobo_control_set_property_bag (gcal->control, gcal->properties); -} - - - -static BonoboObject * -calendar_control_factory (BonoboGenericFactory *Factory, void *closure) -{ - BonoboControl *control; - - /* Create the control. */ - GnomeCalendar *cal = new_calendar (full_name, NULL, NULL, 0); - - gtk_widget_show (GTK_WIDGET (cal)); - - control = bonobo_control_new (GTK_WIDGET (cal)); - cal->control = control; - - calendar_properties_init (cal); - - gtk_signal_connect (GTK_OBJECT (control), "activate", - control_activate_cb, cal); - - return BONOBO_OBJECT (control); -} - - -static void -calendar_control_factory_init (void) -{ - static BonoboGenericFactory *factory = NULL; - - if (factory != NULL) - return; - - puts ("XXXXXX - initializing calendar factory!!!"); - - factory = bonobo_generic_factory_new (CONTROL_FACTORY_ID, calendar_control_factory, NULL); - - if (factory == NULL) - g_error ("I could not register a Calendar control factory."); -} - - -int -main (int argc, char **argv) -{ - init_bonobo (&argc, argv); - glade_gnome_init (); - alarm_init (); - e_cursors_init (); - - init_calendar (); - - //g_log_set_always_fatal ((GLogLevelFlags) 0xFFFF); - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); - - CORBA_exception_init (&ev); - - calendar_control_factory_init (); - component_factory_init (); - - bonobo_main (); - - return 0; -} diff --git a/calendar/gui/evolution-calendar.gnorba b/calendar/gui/evolution-calendar.gnorba deleted file mode 100644 index e2f1107926..0000000000 --- a/calendar/gui/evolution-calendar.gnorba +++ /dev/null @@ -1,11 +0,0 @@ -[evolution-shell-component-factory:evolution-calendar] -type=exe -repo_id=IDL:Bonobo/GenericFactory:1.0 -description=Factory for the Evolution calendar component. -location_info=evolution-calendar - -[evolution-shell-component:evolution-calendar] -type=factory -repo_id=IDL:Evolution/ShellComponent:1.0 -description=Evolution component for handling the calendar. -location_info=evolution-shell-component-factory:evolution-calendar diff --git a/calendar/gui/evolution-calendar.oafinfo b/calendar/gui/evolution-calendar.oafinfo deleted file mode 100644 index c8a4907854..0000000000 --- a/calendar/gui/evolution-calendar.oafinfo +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" - type="exe" - location="evolution-calendar"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Factory for the Evolution calendar component."/> - -</oaf_server> - -<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" - type="factory" - location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Evolution/ShellComponent:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Evolution component for handling the calendar."/> - -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/getdate.y b/calendar/gui/getdate.y deleted file mode 100644 index 6df71bddda..0000000000 --- a/calendar/gui/getdate.y +++ /dev/null @@ -1,1001 +0,0 @@ -%{ -/* -** Originally) written by Steven M. Bellovin <smb@research.att.com> while -** at the University of North Carolina at Chapel Hill. Later tweaked by -** a couple of people on Usenet. Completely overhauled by Rich $alz -** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990; -** send any email to Rich. -** -** This grammar has 10 shift/reduce conflicts. -** -** This code is in the public domain and has no copyright. -*/ -/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */ -/* SUPPRESS 288 on yyerrlab *//* Label unused */ - -#include <config.h> -#include <gnome.h> - -/* Since the code of getdate.y is not included in the Emacs executable - itself, there is no need to #define static in this file. Even if - the code were included in the Emacs executable, it probably - wouldn't do any harm to #undef it here; this will only cause - problems if we try to write to a static variable, which I don't - think this code needs to do. */ -#ifdef emacs -#undef static -#endif - -#include <stdio.h> -#include <ctype.h> - -/* The code at the top of get_date which figures out the offset of the - current time zone checks various CPP symbols to see if special - tricks are need, but defaults to using the gettimeofday system call. - Include <sys/time.h> if that will be used. */ - -#if defined(vms) - -#include <types.h> -#include <time.h> - -#else - -#include <sys/types.h> - -#ifdef TIME_WITH_SYS_TIME -#include <sys/time.h> -#include <time.h> -#else -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#else -#include <time.h> -#endif -#endif - -#ifdef timezone -#undef timezone /* needed for sgi */ -#endif - -#if defined(HAVE_SYS_TIMEB_H) -#include <sys/timeb.h> -#else -/* -** We use the obsolete `struct timeb' as part of our interface! -** Since the system doesn't have it, we define it here; -** our callers must do likewise. -*/ -struct timeb { - time_t time; /* Seconds since the epoch */ - unsigned short millitm; /* Field not used */ - short timezone; /* Minutes west of GMT */ - short dstflag; /* Field not used */ -}; -#endif /* defined(HAVE_SYS_TIMEB_H) */ - -#endif /* defined(vms) */ - -#if defined (STDC_HEADERS) || defined (USG) -#include <string.h> -#endif - -/* Some old versions of bison generate parsers that use bcopy. - That loses on systems that don't provide the function, so we have - to redefine it here. */ -#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy) -#define bcopy(from, to, len) memcpy ((to), (from), (len)) -#endif - -#if defined (STDC_HEADERS) -#include <stdlib.h> -#endif - -/* NOTES on rebuilding getdate.c (particularly for inclusion in CVS - releases): - - We don't want to mess with all the portability hassles of alloca. - In particular, most (all?) versions of bison will use alloca in - their parser. If bison works on your system (e.g. it should work - with gcc), then go ahead and use it, but the more general solution - is to use byacc instead of bison, which should generate a portable - parser. I played with adding "#define alloca dont_use_alloca", to - give an error if the parser generator uses alloca (and thus detect - unportable getdate.c's), but that seems to cause as many problems - as it solves. */ - -extern struct tm *gmtime(); -extern struct tm *localtime(); - -#define yyparse getdate_yyparse -#define yylex getdate_yylex -#define yyerror getdate_yyerror - -static int yylex (); -static int yyerror (); - -#define EPOCH 1970 -#define HOUR(x) ((time_t)(x) * 60) -#define SECSPERDAY (24L * 60L * 60L) - - -/* -** An entry in the lexical lookup table. -*/ -typedef struct _TABLE { - char *name; - int type; - time_t value; -} TABLE; - - -/* -** Daylight-savings mode: on, off, or not yet known. -*/ -typedef enum _DSTMODE { - DSTon, DSToff, DSTmaybe -} DSTMODE; - -/* -** Meridian: am, pm, or 24-hour style. -*/ -typedef enum _MERIDIAN { - MERam, MERpm, MER24 -} MERIDIAN; - - -/* -** Global variables. We could get rid of most of these by using a good -** union as the yacc stack. (This routine was originally written before -** yacc had the %union construct.) Maybe someday; right now we only use -** the %union very rarely. -*/ -static char *yyInput; -static DSTMODE yyDSTmode; -static time_t yyDayOrdinal; -static time_t yyDayNumber; -static int yyHaveDate; -static int yyHaveDay; -static int yyHaveRel; -static int yyHaveTime; -static int yyHaveZone; -static time_t yyTimezone; -static time_t yyDay; -static time_t yyHour; -static time_t yyMinutes; -static time_t yyMonth; -static time_t yySeconds; -static time_t yyYear; -static MERIDIAN yyMeridian; -static time_t yyRelMonth; -static time_t yyRelSeconds; - -%} - -%union { - time_t Number; - enum _MERIDIAN Meridian; -} - -%token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT -%token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST - -%type <Number> tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT -%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tZONE -%type <Meridian> tMERIDIAN o_merid - -%% - -spec : /* NULL */ - | spec item - ; - -item : time { - yyHaveTime++; - } - | zone { - yyHaveZone++; - } - | date { - yyHaveDate++; - } - | day { - yyHaveDay++; - } - | rel { - yyHaveRel++; - } - | number - ; - -time : tUNUMBER tMERIDIAN { - yyHour = $1; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = $2; - } - | tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = 0; - yyMeridian = $4; - } - | tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($4 % 100 + ($4 / 100) * 60); - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = $6; - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($6 % 100 + ($6 / 100) * 60); - } - ; - -zone : tZONE { - yyTimezone = $1; - yyDSTmode = DSToff; - } - | tDAYZONE { - yyTimezone = $1; - yyDSTmode = DSTon; - } - | - tZONE tDST { - yyTimezone = $1; - yyDSTmode = DSTon; - } - ; - -day : tDAY { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tDAY ',' { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tUNUMBER tDAY { - yyDayOrdinal = $1; - yyDayNumber = $2; - } - ; - -date : tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - } - | tUNUMBER '/' tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - yyYear = $5; - } - | tUNUMBER tSNUMBER tSNUMBER { - /* ISO 8601 format. yyyy-mm-dd. */ - yyYear = $1; - yyMonth = -$2; - yyDay = -$3; - } - | tUNUMBER tMONTH tSNUMBER { - /* e.g. 17-JUN-1992. */ - yyDay = $1; - yyMonth = $2; - yyYear = -$3; - } - | tMONTH tUNUMBER { - yyMonth = $1; - yyDay = $2; - } - | tMONTH tUNUMBER ',' tUNUMBER { - yyMonth = $1; - yyDay = $2; - yyYear = $4; - } - | tUNUMBER tMONTH { - yyMonth = $2; - yyDay = $1; - } - | tUNUMBER tMONTH tUNUMBER { - yyMonth = $2; - yyDay = $1; - yyYear = $3; - } - ; - -rel : relunit tAGO { - yyRelSeconds = -yyRelSeconds; - yyRelMonth = -yyRelMonth; - } - | relunit - ; - -relunit : tUNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tSNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tMINUTE_UNIT { - yyRelSeconds += $1 * 60L; - } - | tSNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tUNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tSEC_UNIT { - yyRelSeconds++; - } - | tSNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tUNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tMONTH_UNIT { - yyRelMonth += $1; - } - ; - -number : tUNUMBER { - if (yyHaveTime && yyHaveDate && !yyHaveRel) - yyYear = $1; - else { - if($1>10000) { - yyHaveDate++; - yyDay= ($1)%100; - yyMonth= ($1/100)%100; - yyYear = $1/10000; - } - else { - yyHaveTime++; - if ($1 < 100) { - yyHour = $1; - yyMinutes = 0; - } - else { - yyHour = $1 / 100; - yyMinutes = $1 % 100; - } - yySeconds = 0; - yyMeridian = MER24; - } - } - } - ; - -o_merid : /* NULL */ { - $$ = MER24; - } - | tMERIDIAN { - $$ = $1; - } - ; - -%% - -/* Month and day table. */ -static TABLE const MonthDayTable[] = { - { N_("january"), tMONTH, 1 }, - { N_("february"), tMONTH, 2 }, - { N_("march"), tMONTH, 3 }, - { N_("april"), tMONTH, 4 }, - { N_("may"), tMONTH, 5 }, - { N_("june"), tMONTH, 6 }, - { N_("july"), tMONTH, 7 }, - { N_("august"), tMONTH, 8 }, - { N_("september"), tMONTH, 9 }, - { N_("sept"), tMONTH, 9 }, - { N_("october"), tMONTH, 10 }, - { N_("november"), tMONTH, 11 }, - { N_("december"), tMONTH, 12 }, - { N_("sunday"), tDAY, 0 }, - { N_("monday"), tDAY, 1 }, - { N_("tuesday"), tDAY, 2 }, - { N_("tues"), tDAY, 2 }, - { N_("wednesday"), tDAY, 3 }, - { N_("wednes"), tDAY, 3 }, - { N_("thursday"), tDAY, 4 }, - { N_("thur"), tDAY, 4 }, - { N_("thurs"), tDAY, 4 }, - { N_("friday"), tDAY, 5 }, - { N_("saturday"), tDAY, 6 }, - { NULL } -}; - -/* Time units table. */ -static TABLE const UnitsTable[] = { - { N_("year"), tMONTH_UNIT, 12 }, - { N_("month"), tMONTH_UNIT, 1 }, - { N_("fortnight"), tMINUTE_UNIT, 14 * 24 * 60 }, - { N_("week"), tMINUTE_UNIT, 7 * 24 * 60 }, - { N_("day"), tMINUTE_UNIT, 1 * 24 * 60 }, - { N_("hour"), tMINUTE_UNIT, 60 }, - { N_("minute"), tMINUTE_UNIT, 1 }, - { N_("min"), tMINUTE_UNIT, 1 }, - { N_("second"), tSEC_UNIT, 1 }, - { N_("sec"), tSEC_UNIT, 1 }, - { NULL } -}; - -/* Assorted relative-time words. */ -static TABLE const OtherTable[] = { - { N_("tomorrow"), tMINUTE_UNIT, 1 * 24 * 60 }, - { N_("yesterday"), tMINUTE_UNIT, -1 * 24 * 60 }, - { N_("today"), tMINUTE_UNIT, 0 }, - { N_("now"), tMINUTE_UNIT, 0 }, - { N_("last"), tUNUMBER, -1 }, - { N_("this"), tMINUTE_UNIT, 0 }, - { N_("next"), tUNUMBER, 2 }, - { N_("first"), tUNUMBER, 1 }, -/* { N_("second"), tUNUMBER, 2 }, */ - { N_("third"), tUNUMBER, 3 }, - { N_("fourth"), tUNUMBER, 4 }, - { N_("fifth"), tUNUMBER, 5 }, - { N_("sixth"), tUNUMBER, 6 }, - { N_("seventh"), tUNUMBER, 7 }, - { N_("eighth"), tUNUMBER, 8 }, - { N_("ninth"), tUNUMBER, 9 }, - { N_("tenth"), tUNUMBER, 10 }, - { N_("eleventh"), tUNUMBER, 11 }, - { N_("twelfth"), tUNUMBER, 12 }, - { N_("ago"), tAGO, 1 }, - { NULL } -}; - -/* The timezone table. */ -/* Some of these are commented out because a time_t can't store a float. */ -static TABLE const TimezoneTable[] = { - { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ - { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ - { "utc", tZONE, HOUR( 0) }, - { "wet", tZONE, HOUR( 0) }, /* Western European */ - { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ - { "wat", tZONE, HOUR( 1) }, /* West Africa */ - { "at", tZONE, HOUR( 2) }, /* Azores */ -#if 0 - /* For completeness. BST is also British Summer, and GST is - * also Guam Standard. */ - { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ - { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ -#endif -#if 0 - { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */ - { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */ - { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */ -#endif - { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ - { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ - { "est", tZONE, HOUR( 5) }, /* Eastern Standard */ - { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ - { "cst", tZONE, HOUR( 6) }, /* Central Standard */ - { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ - { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ - { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ - { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ - { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ - { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ - { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ - { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ - { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */ - { "cat", tZONE, HOUR(10) }, /* Central Alaska */ - { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */ - { "nt", tZONE, HOUR(11) }, /* Nome */ - { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ - { "cet", tZONE, -HOUR(1) }, /* Central European */ - { "met", tZONE, -HOUR(1) }, /* Middle European */ - { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */ - { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */ - { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */ - { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */ - { "fwt", tZONE, -HOUR(1) }, /* French Winter */ - { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */ - { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */ - { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */ -#if 0 - { "it", tZONE, -HOUR(3.5) },/* Iran */ -#endif - { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */ - { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */ -#if 0 - { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */ -#endif - { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */ -#if 0 - /* For completeness. NST is also Newfoundland Stanard, and SST is - * also Swedish Summer. */ - { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */ - { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */ -#endif /* 0 */ - { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */ - { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */ -#if 0 - { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */ -#endif - { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */ - { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */ -#if 0 - { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */ - { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */ -#endif - { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ - { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ - { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */ - { "nzt", tZONE, -HOUR(12) }, /* New Zealand */ - { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ - { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ - { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ - { NULL } -}; - -/* Military timezone table. */ -static TABLE const MilitaryTable[] = { - { "a", tZONE, HOUR( 1) }, - { "b", tZONE, HOUR( 2) }, - { "c", tZONE, HOUR( 3) }, - { "d", tZONE, HOUR( 4) }, - { "e", tZONE, HOUR( 5) }, - { "f", tZONE, HOUR( 6) }, - { "g", tZONE, HOUR( 7) }, - { "h", tZONE, HOUR( 8) }, - { "i", tZONE, HOUR( 9) }, - { "k", tZONE, HOUR( 10) }, - { "l", tZONE, HOUR( 11) }, - { "m", tZONE, HOUR( 12) }, - { "n", tZONE, HOUR(- 1) }, - { "o", tZONE, HOUR(- 2) }, - { "p", tZONE, HOUR(- 3) }, - { "q", tZONE, HOUR(- 4) }, - { "r", tZONE, HOUR(- 5) }, - { "s", tZONE, HOUR(- 6) }, - { "t", tZONE, HOUR(- 7) }, - { "u", tZONE, HOUR(- 8) }, - { "v", tZONE, HOUR(- 9) }, - { "w", tZONE, HOUR(-10) }, - { "x", tZONE, HOUR(-11) }, - { "y", tZONE, HOUR(-12) }, - { "z", tZONE, HOUR( 0) }, - { NULL } -}; - - - - -/* ARGSUSED */ -static int -yyerror(s) - char *s; -{ - return 0; -} - - -static time_t -ToSeconds(Hours, Minutes, Seconds, Meridian) - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; -{ - if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) - return -1; - switch (Meridian) { - case MER24: - if (Hours < 0 || Hours > 23) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERam: - if (Hours < 1 || Hours > 12) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERpm: - if (Hours < 1 || Hours > 12) - return -1; - return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; - default: - abort (); - } - /* NOTREACHED */ -} - - -static time_t -Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) - time_t Month; - time_t Day; - time_t Year; - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; - DSTMODE DSTmode; -{ - static int DaysInMonth[12] = { - 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - time_t tod; - time_t Julian; - int i; - - if (Year < 0) - Year = -Year; - if (Year < 100) - Year += 1900; - DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) - ? 29 : 28; - if (Year < EPOCH || Year > 1999 - || Month < 1 || Month > 12 - /* Lint fluff: "conversion from long may lose accuracy" */ - || Day < 1 || Day > DaysInMonth[(int)--Month]) - return -1; - - for (Julian = Day - 1, i = 0; i < Month; i++) - Julian += DaysInMonth[i]; - for (i = EPOCH; i < Year; i++) - Julian += 365 + (i % 4 == 0); - Julian *= SECSPERDAY; - Julian += yyTimezone * 60L; - if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) - return -1; - Julian += tod; - if (DSTmode == DSTon - || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) - Julian -= 60 * 60; - return Julian; -} - - -static time_t -DSTcorrect(Start, Future) - time_t Start; - time_t Future; -{ - time_t StartDay; - time_t FutureDay; - - StartDay = (localtime(&Start)->tm_hour + 1) % 24; - FutureDay = (localtime(&Future)->tm_hour + 1) % 24; - return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; -} - - -static time_t -RelativeDate(Start, DayOrdinal, DayNumber) - time_t Start; - time_t DayOrdinal; - time_t DayNumber; -{ - struct tm *tm; - time_t now; - - now = Start; - tm = localtime(&now); - now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); - now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); - return DSTcorrect(Start, now); -} - - -static time_t -RelativeMonth(Start, RelMonth) - time_t Start; - time_t RelMonth; -{ - struct tm *tm; - time_t Month; - time_t Year; - - if (RelMonth == 0) - return 0; - tm = localtime(&Start); - Month = 12 * tm->tm_year + tm->tm_mon + RelMonth; - Year = Month / 12; - Month = Month % 12 + 1; - return DSTcorrect(Start, - Convert(Month, (time_t)tm->tm_mday, Year, - (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, - MER24, DSTmaybe)); -} - - -static int -LookupWord(buff) - char *buff; -{ - register char *p; - register char *q; - register const TABLE *tp; - int i; - int abbrev; - - /* Make it lowercase. */ - for (p = buff; *p; p++) - if (isupper(*p)) - *p = tolower(*p); - - if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { - yylval.Meridian = MERam; - return tMERIDIAN; - } - if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { - yylval.Meridian = MERpm; - return tMERIDIAN; - } - - /* See if we have an abbreviation for a month. */ - if (strlen(buff) == 3) - abbrev = 1; - else if (strlen(buff) == 4 && buff[3] == '.') { - abbrev = 1; - buff[3] = '\0'; - } - else - abbrev = 0; - - for (tp = MonthDayTable; tp->name; tp++) { - if (abbrev) { - if (strncmp(buff, tp->name, 3) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - else if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - if (strcmp(buff, "dst") == 0) - return tDST; - - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - /* Strip off any plural and try the units table again. */ - i = strlen(buff) - 1; - if (buff[i] == 's') { - buff[i] = '\0'; - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - buff[i] = 's'; /* Put back for "this" in OtherTable. */ - } - - for (tp = OtherTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - /* Military timezones. */ - if (buff[1] == '\0' && isalpha(*buff)) { - for (tp = MilitaryTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - - /* Drop out any periods and try the timezone table again. */ - for (i = 0, p = q = buff; *q; q++) - if (*q != '.') - *p++ = *q; - else - i++; - *p = '\0'; - if (i) - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - return tID; -} - - -static int -yylex() -{ - register char c; - register char *p; - char buff[20]; - int Count; - int sign; - - for ( ; ; ) { - while (isspace(*yyInput)) - yyInput++; - - if (isdigit(c = *yyInput) || c == '-' || c == '+') { - if (c == '-' || c == '+') { - sign = c == '-' ? -1 : 1; - if (!isdigit(*++yyInput)) - /* skip the '-' sign */ - continue; - } - else - sign = 0; - for (yylval.Number = 0; isdigit(c = *yyInput++); ) - yylval.Number = 10 * yylval.Number + c - '0'; - yyInput--; - if (sign < 0) - yylval.Number = -yylval.Number; - return sign ? tSNUMBER : tUNUMBER; - } - if (isalpha(c)) { - for (p = buff; isalpha(c = *yyInput++) || c == '.'; ) - if (p < &buff[sizeof buff - 1]) - *p++ = c; - *p = '\0'; - yyInput--; - return LookupWord(buff); - } - if (c != '(') - return *yyInput++; - Count = 0; - do { - c = *yyInput++; - if (c == '\0') - return c; - if (c == '(') - Count++; - else if (c == ')') - Count--; - } while (Count > 0); - } -} - -#define TM_YEAR_ORIGIN 1900 - -/* Yield A - B, measured in seconds. */ -static long -difftm (a, b) - struct tm *a, *b; -{ - int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); - int by = b->tm_year + (TM_YEAR_ORIGIN - 1); - int days = ( - /* difference in day of year */ - a->tm_yday - b->tm_yday - /* + intervening leap days */ - + ((ay >> 2) - (by >> 2)) - - (ay/100 - by/100) - + ((ay/100 >> 2) - (by/100 >> 2)) - /* + difference in years * 365 */ - + (long)(ay-by) * 365 - ); - return (60*(60*(24*days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) - + (a->tm_sec - b->tm_sec)); -} - -time_t -get_date(p, now) - char *p; - struct timeb *now; -{ - struct tm *tm, gmt; - struct timeb ftz; - time_t Start; - time_t tod; - time_t nowtime; - - yyInput = p; - if (now == NULL) { - now = &ftz; - (void)time (&nowtime); - - if (! (tm = gmtime (&nowtime))) - return -1; - gmt = *tm; /* Make a copy, in case localtime modifies *tm. */ - - if (! (tm = localtime (&nowtime))) - return -1; - - ftz.timezone = difftm (&gmt, tm) / 60; - if(tm->tm_isdst) - ftz.timezone += 60; - } - else - { - nowtime = now->time; - } - - tm = localtime(&nowtime); - yyYear = tm->tm_year; - yyMonth = tm->tm_mon + 1; - yyDay = tm->tm_mday; - yyTimezone = now->timezone; - yyDSTmode = DSTmaybe; - yyHour = 0; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = MER24; - yyRelSeconds = 0; - yyRelMonth = 0; - yyHaveDate = 0; - yyHaveDay = 0; - yyHaveRel = 0; - yyHaveTime = 0; - yyHaveZone = 0; - - if (yyparse() - || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1) - return -1; - - if (yyHaveDate || yyHaveTime || yyHaveDay) { - Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds, - yyMeridian, yyDSTmode); - if (Start < 0) - return -1; - } - else { - Start = nowtime; - if (!yyHaveRel) - Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec; - } - - Start += yyRelSeconds; - Start += RelativeMonth(Start, yyRelMonth); - - if (yyHaveDay && !yyHaveDate) { - tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber); - Start += tod; - } - - /* Have to do *something* with a legitimate -1 so it's distinguishable - * from the error return value. (Alternately could set errno on error.) */ - return Start == -1 ? 0 : Start; -} - - -#if defined(TEST) - -/* ARGSUSED */ -int -main(ac, av) - int ac; - char *av[]; -{ - char buff[128]; - time_t d; - - (void)printf("Enter date, or blank line to exit.\n\t> "); - (void)fflush(stdout); - while (gets(buff) && buff[0]) { - d = get_date(buff, (struct timeb *)NULL); - if (d == -1) - (void)printf("Bad format - couldn't convert.\n"); - else - (void)printf("%s", ctime(&d)); - (void)printf("\t> "); - (void)fflush(stdout); - } - exit(0); - /* NOTREACHED */ -} -#endif /* defined(TEST) */ diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c deleted file mode 100644 index a79d39363c..0000000000 --- a/calendar/gui/gncal-todo.c +++ /dev/null @@ -1,960 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* To-do widget for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#include <config.h> -#include <string.h> -#include <gnome.h> -#include <cal-client/cal-client.h> -#include <cal-util/timeutil.h> -#include "event-editor.h" -#include "gncal-todo.h" -#include "calendar-commands.h" -#include "popup-menu.h" - -int todo_show_due_date = 0; -int todo_show_priority = 0; -int todo_show_time_remaining = 0; - -int todo_item_dstatus_highlight_overdue = 0; -int todo_item_dstatus_highlight_due_today = 0; -int todo_item_dstatus_highlight_not_due_yet = 0; - - -char *todo_overdue_font_text; -gint todo_current_sort_column = 0; -gint todo_current_sort_type = GTK_SORT_ASCENDING; - -gboolean todo_style_changed =0; -gboolean todo_list_autoresize = 1; -gboolean todo_list_redraw_in_progess = 0; -static void gncal_todo_init (GncalTodo *todo); - - -guint -gncal_todo_get_type (void) -{ - static guint todo_type = 0; - - if (!todo_type) { - GtkTypeInfo todo_info = { - "GncalTodo", - sizeof (GncalTodo), - sizeof (GncalTodoClass), - (GtkClassInitFunc) NULL, - (GtkObjectInitFunc) gncal_todo_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - todo_type = gtk_type_unique (gtk_vbox_get_type (), &todo_info); - } - - return todo_type; -} - -static void -ok_button (GtkWidget *widget, GnomeDialog *dialog) -{ - CalComponent *comp; - CalClient *cal_client; - GnomeDateEdit *due_date; - GtkEditable *entry; - GtkSpinButton *priority; - GtkText *comment; - CalComponentText *text = g_new0 (CalComponentText, 1); - CalComponentDateTime date; - GSList *l; - gchar *t; - time_t d; - int p; - - comp = gtk_object_get_user_data (GTK_OBJECT (dialog)); - - cal_client = (CalClient*) (gtk_object_get_data (GTK_OBJECT (dialog), "cal_client")); - - /* Due date */ - due_date = GNOME_DATE_EDIT (gtk_object_get_data(GTK_OBJECT(dialog), "due_date")); - d = gnome_date_edit_get_date (due_date); - date.value = g_new0 (struct icaltimetype, 1); - *date.value = icaltimetype_from_timet (d, 1); - cal_component_set_dtend (comp, &date); - - /* Summary */ - entry = GTK_EDITABLE (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry")); - t = gtk_editable_get_chars (entry, 0, -1); - text->value = t; - cal_component_set_summary (comp, text); - g_free (t); - - /* Priority */ - priority = GTK_SPIN_BUTTON (gtk_object_get_data(GTK_OBJECT(dialog), "priority")); - p = gtk_spin_button_get_value_as_int (priority); - cal_component_set_priority (comp, &p); - - /* Comment */ - cal_component_get_comment_list (comp, &l); - comment = GTK_TEXT(gtk_object_get_data (GTK_OBJECT(dialog), "comment")); - t = gtk_editable_get_chars (entry, 0, -1); - text->value = t; - g_slist_append (l, text); - cal_component_set_comment_list (comp, l); - cal_component_free_text_list (l); - - if (!cal_client_update_object (cal_client, comp)) - g_message ("ok_button(): Could not update the object!"); - - gtk_object_unref (GTK_OBJECT (comp)); - - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - -static void -cancel_button (GtkWidget *widget, GnomeDialog *dialog) -{ - CalComponent *comp; - - comp = gtk_object_get_user_data (GTK_OBJECT (dialog)); - - gtk_object_unref (GTK_OBJECT (comp)); - - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - -static gint -delete_event (GtkWidget *widget, GdkEvent *event, GnomeDialog *dialog) -{ - cancel_button (NULL, dialog); - return TRUE; -} - -/* I've hacked this so we can use it separate from the rest of GncalTodo. - This whole file will go once we've got the new editor working. */ -void -gncal_todo_edit (CalClient *client, CalComponent *comp) -{ - GtkWidget *dialog; - GtkWidget *hbox; - GtkWidget *due_box; - GtkWidget *due_label; - GtkWidget *due_entry; - GtkWidget *comment_box; - GtkWidget *comment_label; - GtkWidget *comment_text; - GtkWidget *comment_internal_box; - GtkWidget *comment_sep; - GtkWidget *w; - GtkWidget *pri_box; - GtkWidget *pri_label; - GtkWidget *pri_spin; - GtkObject *pri_adj; - GtkWidget *entry; - gboolean new; - CalComponentText text; - CalComponentDateTime date; - GSList *l; - time_t d; - gint *p; - - new = (CAL_COMPONENT_NO_TYPE == cal_component_get_vtype (comp)); - if (new) - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - - dialog = gnome_dialog_new (new ? _("Create to-do item") : _("Edit to-do item"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); -#if 0 - gnome_dialog_set_parent (GNOME_DIALOG (dialog), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (todo->calendar)))); -#endif - hbox = gtk_hbox_new (FALSE, 4); - gtk_container_border_width (GTK_CONTAINER (hbox), 4); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), - hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - - due_box = gtk_hbox_new (FALSE, 4); - gtk_container_border_width (GTK_CONTAINER (due_box), 4); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), due_box, FALSE, FALSE, 0); - gtk_widget_show (due_box); - - pri_box = gtk_hbox_new (FALSE, 4); - gtk_container_border_width (GTK_CONTAINER (pri_box), 4); - gtk_box_pack_start(GTK_BOX (GNOME_DIALOG (dialog)->vbox), pri_box, FALSE, FALSE, 0); - gtk_widget_show (pri_box); - - comment_box = gtk_hbox_new (FALSE, 4); - gtk_container_border_width (GTK_CONTAINER (comment_box), 4); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), comment_box, FALSE, FALSE, 0); - gtk_widget_show (comment_box); - - comment_internal_box = gtk_vbox_new(FALSE,2); - gtk_container_border_width (GTK_CONTAINER (comment_internal_box), 4); - - gtk_box_pack_start (GTK_BOX (comment_box), comment_internal_box, TRUE, TRUE, 0); - gtk_widget_show (comment_internal_box); - - w = gtk_label_new (_("Summary:")); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - entry = gtk_entry_new (); - cal_component_get_summary (comp, &text); - gtk_entry_set_text (GTK_ENTRY (entry), text.value); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); - gtk_widget_show (entry); - - - due_label = gtk_label_new (_("Due Date:")); - gtk_box_pack_start (GTK_BOX (due_box), due_label, FALSE, FALSE, 0); - gtk_widget_show (due_label); - - due_entry = gtk_entry_new (); - cal_component_get_dtend (comp, &date); - d = time_from_icaltimetype (*date.value); - due_entry = date_edit_new (d, TRUE); - gtk_box_pack_start (GTK_BOX (due_box), due_entry, TRUE, TRUE, 0); - gtk_widget_show (due_entry); - - pri_label = gtk_label_new (_("Priority:")); - gtk_box_pack_start (GTK_BOX (pri_box), pri_label, FALSE, FALSE, 0); - gtk_widget_show (pri_label); - - pri_adj = gtk_adjustment_new (5.0, 1.0, 9.0, 1.0, 3.0, 0.0); - pri_spin = gtk_spin_button_new (GTK_ADJUSTMENT(pri_adj), 0.0, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (pri_spin), TRUE); - gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (pri_spin), FALSE); - gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (pri_spin), FALSE); - cal_component_get_priority (comp, &p); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (pri_spin), (gfloat) *p); - gtk_box_pack_start (GTK_BOX (pri_box), pri_spin, FALSE, FALSE, 0); - gtk_widget_show (pri_spin); - - comment_sep = gtk_hseparator_new (); - gtk_box_pack_start (GTK_BOX (comment_box), comment_sep, FALSE, FALSE, 0); - gtk_widget_show(comment_sep); - - comment_label = gtk_label_new (_("Item Comments:")); - gtk_label_set_justify(GTK_LABEL(comment_label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (comment_internal_box), comment_label, TRUE, TRUE, 0); - gtk_widget_show (comment_label); - - comment_text = gtk_text_new (NULL, NULL); - gtk_text_set_editable (GTK_TEXT (comment_text), TRUE); - gtk_text_set_word_wrap( GTK_TEXT(comment_text), TRUE); - gtk_text_freeze(GTK_TEXT(comment_text)); -#warning "FIX ME" - /* Need to handle multiple comments */ - cal_component_get_comment_list (comp, &l); - if (l) { - CalComponentText text = *(CalComponentText*)l->data; - - gtk_text_insert(GTK_TEXT(comment_text), NULL, NULL, NULL, - text.value, strlen(text.value)); - } - cal_component_free_text_list (l); - gtk_text_thaw(GTK_TEXT(comment_text)); - gtk_box_pack_start (GTK_BOX (comment_internal_box), comment_text, FALSE, TRUE, 0); - gtk_widget_show (comment_text); - - gtk_object_set_user_data (GTK_OBJECT (dialog), comp); - gtk_object_ref (GTK_OBJECT (comp)); - - gtk_object_set_data (GTK_OBJECT (dialog), "cal_client", client); - gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry); - gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry); - gtk_object_set_data (GTK_OBJECT (dialog), "priority", pri_spin); - gtk_object_set_data (GTK_OBJECT (dialog), "comment", comment_text); - - gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog); - gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog); - - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - (GtkSignalFunc) delete_event, - dialog); - - gnome_dialog_set_default (GNOME_DIALOG (dialog), 0); - gnome_dialog_editable_enters (GNOME_DIALOG (dialog), GTK_EDITABLE(entry)); - - gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_widget_show (dialog); - gtk_widget_grab_focus (entry); -} - -static CalComponent * -get_clist_selected_comp (GtkCList *clist) -{ - gint sel; - - if (!clist->selection) - return NULL; - - sel = GPOINTER_TO_INT(clist->selection->data); - - return gtk_clist_get_row_data (clist, sel); -} - -static void -add_todo (GncalTodo *todo) -{ - CalComponent *comp; - - comp = cal_component_new (); - -#if 0 - gncal_todo_edit (todo, comp); -#endif - gtk_object_unref (GTK_OBJECT (comp)); -} - -static void -edit_todo (GncalTodo *todo) -{ - CalComponent *comp; - - comp = get_clist_selected_comp (todo->clist); - -#if 0 - gncal_todo_edit (todo, comp); -#endif -} - -static void -delete_todo (GncalTodo *todo) -{ - CalComponent *comp; - const char *uid; - - comp = get_clist_selected_comp (todo->clist); - cal_component_get_uid (comp, &uid); - - if (!cal_client_remove_object (todo->calendar->client, uid)) - g_message ("delete_todo(): Could not remove the object!"); -} - -static void -add_activated (GtkWidget *widget, GncalTodo *todo) -{ - GtkWidget *w; - - while ((w = gtk_grab_get_current ()) != NULL) - gtk_grab_remove (w); - - add_todo (todo); -} - -static void -edit_activated (GtkWidget *widget, GncalTodo *todo) -{ - GtkWidget *w; - - while ((w = gtk_grab_get_current ()) != NULL) - gtk_grab_remove (w); - - edit_todo (todo); -} - -static void -delete_activated (GtkWidget *widget, GncalTodo *todo) -{ - delete_todo (todo); -} - - -static void -clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *event, GncalTodo *todo) -{ - static struct menu_item items[] = { - { N_("Add to-do item..."), (GtkSignalFunc) add_activated, NULL, TRUE }, - { N_("Edit this item..."), (GtkSignalFunc) edit_activated, NULL, TRUE }, - { N_("Delete this item"), (GtkSignalFunc) delete_activated, NULL, TRUE } - }; - - int i; - - gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL)); - gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL)); - - if (!event) - return; - - switch (event->button) { - case 1: - if (event->type == GDK_2BUTTON_PRESS) - edit_todo (todo); - break; - - case 3: - for (i = 0; i < (sizeof (items) / sizeof (items[0])); i++) - items[i].data = todo; - - popup_menu (items, sizeof (items) / sizeof (items[0]), event); - break; - - default: - break; - } -} - -/* - * once we get a call back stating that a column - * has been resized never ever automatically resize again - */ -static void -column_resized (GtkWidget *widget, GncalTodo *todo) -{ - /* disabling autoresize of columns */ - if (todo_list_autoresize && !todo_list_redraw_in_progess){ - todo_list_autoresize = 0; - } -} - -/* - * restore the previously set settings for sorting the - * todo list - */ -static void -init_column_sorting (GtkCList *clist) -{ - - /* due date isn't shown so we can't sort by it */ - if (todo_current_sort_column == 1 && ! todo_show_due_date) - todo_current_sort_column = 0; - - clist->sort_type = todo_current_sort_type; - clist->sort_column = todo_current_sort_column; - - gtk_clist_set_sort_column (clist, todo_current_sort_column); - gtk_clist_sort (clist); -} - -static void -todo_click_column (GtkCList *clist, gint column, gpointer data) -{ - if (column == clist->sort_column) - { - if (clist->sort_type == GTK_SORT_ASCENDING) { - clist->sort_type = GTK_SORT_DESCENDING; - todo_current_sort_type = GTK_SORT_DESCENDING; - } else { - clist->sort_type = GTK_SORT_ASCENDING; - todo_current_sort_type = GTK_SORT_ASCENDING; - } - } - else { - gtk_clist_set_sort_column (clist, column); - todo_current_sort_column = column; - } - - gtk_clist_sort (clist); - - /* - * save the sorting preferences cause I hate to have the user - * click twice - */ - - gnome_config_set_int("/calendar/Todo/sort_column", todo_current_sort_column); - gnome_config_set_int("/calendar/Todo/sort_type", todo_current_sort_type); - gnome_config_sync(); -} - -static void -gncal_todo_init (GncalTodo *todo) -{ - GtkWidget *w; - GtkWidget *sw; - GtkWidget *hbox; - gchar *titles[4] = { - N_("Summary"), - N_("Due Date"), - N_("Priority"), - N_("Time Left") - }; - char *tmp[4]; - tmp[0] = _(titles[0]); - tmp[1] = _(titles[1]); - tmp[2] = _(titles[2]); - tmp[3] = _(titles[3]); - - gtk_box_set_spacing (GTK_BOX (todo), 4); - - /* Label */ - - w = gtk_label_new (_("To-do list")); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (todo), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Clist */ - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start (GTK_BOX (todo), sw, TRUE, TRUE, 0); - gtk_widget_show (sw); - - - w = gtk_clist_new_with_titles(4, tmp); - - todo->clist = GTK_CLIST (w); - gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE); - - gtk_signal_connect (GTK_OBJECT (todo->clist), "select_row", - (GtkSignalFunc) clist_row_selected, - todo); - gtk_clist_set_button_actions (todo->clist, 2, GTK_BUTTON_SELECTS); - gtk_signal_connect (GTK_OBJECT (todo->clist), "resize_column", - (GtkSignalFunc) column_resized, - todo); - gtk_signal_connect (GTK_OBJECT (todo->clist), "click_column", - (GtkSignalFunc) todo_click_column, NULL); - - gtk_container_add (GTK_CONTAINER (sw), w); - gtk_widget_show (w); - - /* Box for buttons */ - - hbox = gtk_hbox_new (TRUE, 4); - gtk_box_pack_start (GTK_BOX (todo), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - /* Add */ - - w = gtk_button_new_with_label (_("Add...")); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) add_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); - - /* Edit */ - - w = gtk_button_new_with_label (_("Edit...")); - todo->edit_button = w; - gtk_widget_set_sensitive (w, FALSE); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) edit_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); - - /* Delete */ - - w = gtk_button_new_with_label (_("Delete")); - todo->delete_button = w; - gtk_widget_set_sensitive (w, FALSE); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) delete_activated, - todo); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); -} - -GtkWidget * -gncal_todo_new (GnomeCalendar *calendar) -{ - GncalTodo *todo; - - g_return_val_if_fail (calendar != NULL, NULL); - - todo = gtk_type_new (gncal_todo_get_type ()); - - todo->calendar = calendar; - - gncal_todo_update (todo, NULL, 0); - - return GTK_WIDGET (todo); -} - -static char * -convert_time_t_to_char (time_t t) -{ - char buf[100]; - struct tm tm; - - tm = *localtime (&t); - strftime(buf, sizeof (buf), "%m/%d/%Y", &tm); - - return g_strdup (buf); -} - - -enum todo_styles { - TODO_STYLE_OVERDUE, - TODO_STYLE_DUE_TODAY, - TODO_STYLE_NOT_DUE -}; - - -enum todo_status { - TODO_ITEM_DSTATUS_NOT_DUE_YET, - TODO_ITEM_DSTATUS_DUE_TODAY, - TODO_ITEM_DSTATUS_OVERDUE, - TODO_ITEM_DSTATUS_LAST_DUE_STATUS -}; -typedef enum todo_status todo_status; - -static GtkStyle * -make_todo_style(GncalTodo *todo, todo_status style_type) -{ - GtkStyle *style = NULL; - GdkColor style_color; - int color_prop = 0; - switch(style_type) { - case TODO_ITEM_DSTATUS_NOT_DUE_YET: - color_prop = COLOR_PROP_TODO_NOT_DUE_YET; - break; - case TODO_ITEM_DSTATUS_DUE_TODAY: - color_prop = COLOR_PROP_TODO_DUE_TODAY; - break; - case TODO_ITEM_DSTATUS_OVERDUE: - color_prop = COLOR_PROP_TODO_OVERDUE; - break; - case TODO_ITEM_DSTATUS_LAST_DUE_STATUS: - } - - style_color.red = color_props[color_prop].r; - style_color.green = color_props[color_prop].g; - style_color.blue = color_props[color_prop].b; - - style = gtk_style_copy (GTK_WIDGET (todo->clist)->style); - style->base[GTK_STATE_NORMAL] = style_color; - return style; -} - - -static -todo_status todo_item_due_status(time_t *todo_due_time) { - struct tm due_tm_time; - struct tm current_time; - struct tm *temp_tm; - time_t current_time_val = time(NULL); - temp_tm = localtime(todo_due_time); - /* make a copy so it dosen't get over written */ - memcpy(&due_tm_time, temp_tm, sizeof(struct tm)); - - - temp_tm = localtime(¤t_time_val); - memcpy(¤t_time, temp_tm, sizeof(struct tm)); - - if(due_tm_time.tm_mon == current_time.tm_mon && - due_tm_time.tm_mday == current_time.tm_mday && - due_tm_time.tm_year == current_time.tm_year) { - return TODO_ITEM_DSTATUS_DUE_TODAY; - } - - if((*todo_due_time) < current_time_val) { - return TODO_ITEM_DSTATUS_OVERDUE; - } - - return TODO_ITEM_DSTATUS_NOT_DUE_YET; -} - - -enum todo_remaining_time_form { - TODO_ITEM_REMAINING_WEEKS, - TODO_ITEM_REMAINING_DAYS, - TODO_ITEM_REMAINING_HOURS, - TODO_ITEM_REMAINING_MINUTES, - TODO_ITEM_REMAINING_SECONDS -}; -typedef enum todo_remaining_time_form todo_remaining_time_form; - - -static void -insert_in_clist (GncalTodo *todo, CalComponent *comp) -{ - int i; - CalComponentText t; - CalComponentDateTime date; - char *text[4]; - char time_remaining_buffer[100]; - time_t time_remain; - todo_remaining_time_form time_remaining_form; - int sec_in_week = 3600*7*24; - int sec_in_day = 3600*24; - int sec_in_hour = 3600; - int sec_in_minute = 60; - int weeks = 0; - int days = 0; - int hours = 0; - int minutes = 0; - int seconds = 0; - int *p; - time_t d; - - /* an array for the styles of items */ - static GtkStyle *dstatus_styles[TODO_ITEM_DSTATUS_LAST_DUE_STATUS]; - /* we want to remake the styles when the status is changed, - also we need to check for the null value in the pointer so we init them - at startup */ - if (todo_style_changed || !dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]) { - g_free(dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]); - g_free(dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]); - g_free(dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]); - - dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET] = make_todo_style(todo, TODO_ITEM_DSTATUS_NOT_DUE_YET); - dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE] = make_todo_style(todo, TODO_ITEM_DSTATUS_OVERDUE); - dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY] = make_todo_style(todo, TODO_ITEM_DSTATUS_DUE_TODAY); - - todo_style_changed = 0; - } - - cal_component_get_summary (comp, &t); - text[0] = g_strdup (t.value); - - if(todo_show_time_remaining) { - memset(time_remaining_buffer, 0, 100); - /* we need to make a string that represents the amount of time remaining - before this task is due */ - - /* for right now all I'll do is up to the hours. */ - cal_component_get_dtend (comp, &date); - time_remain = time_from_icaltimetype (*date.value) - time (NULL); - if(time_remain < 0) { - text[3] = "Overdue!"; - } - else { - - /* lets determine a decent denomination to display */ - if(time_remain / (sec_in_week)) - { - /* we have weeks available */ - time_remaining_form = TODO_ITEM_REMAINING_WEEKS; - weeks = time_remain / sec_in_week; - days = (time_remain % (sec_in_week))/sec_in_day; - } - else if(time_remain / (sec_in_day)) - { - /* we have days available */ - time_remaining_form = TODO_ITEM_REMAINING_DAYS; - days = time_remain / sec_in_day; - hours = (time_remain % sec_in_day)/sec_in_hour; - } - else if(time_remain / (sec_in_hour)) - { - /* we have hours available */ - time_remaining_form = TODO_ITEM_REMAINING_HOURS; - hours = time_remain /sec_in_hour; - minutes = (time_remain % sec_in_hour) / sec_in_minute; - } - else if(time_remain / sec_in_minute) - { - time_remaining_form = TODO_ITEM_REMAINING_MINUTES; - minutes = time_remain / sec_in_minute; - seconds = time_remain % sec_in_minute; - } - else - { - time_remaining_form = TODO_ITEM_REMAINING_SECONDS; - seconds = time_remain; - } - - switch(time_remaining_form) - { - case TODO_ITEM_REMAINING_WEEKS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", weeks, - (weeks > 1) ? _("Weeks") : _("Week"), - days, (days > 1) ? _("Days") : _("Day")); - break; - case TODO_ITEM_REMAINING_DAYS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", days, - (days > 1) ? _("Days") : _("Day"), - hours, (hours > 1) ? _("Hours") : _("Hour")); - break; - case TODO_ITEM_REMAINING_HOURS: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", hours, - (hours > 1) ? _("Hours") : _("Hour"), - minutes, (minutes > 1) ? _("Minutes") : _("Minute")); - break; - case TODO_ITEM_REMAINING_MINUTES: - snprintf(time_remaining_buffer, 100, "%d %s %d %s", minutes, - (minutes > 1) ? _("Minutes") : _("Minute"), - seconds, (seconds > 1) ? _("Seconds") : _("Second")); - break; - case TODO_ITEM_REMAINING_SECONDS: - snprintf(time_remaining_buffer, 100, "%d %s", seconds, - (seconds > 1) ? _("Seconds") : _("Second")); - break; - } - text[3] = g_strdup(time_remaining_buffer); - todo->data_ptrs = g_slist_append(todo->data_ptrs, text[3]); - } - - } - else { - text[3] = "Loose penguini!"; - } - /* - * right now column 0 will be the summary - * and column 1 will be the due date. - * WISH: this should be able to be changed on the fly - */ - - cal_component_get_dtend (comp, &date); - d = time_from_icaltimetype (*date.value); - if(todo_show_due_date) - { - text[1] = convert_time_t_to_char (d); - /* Append the data's pointer so later it can be properly freed */ - todo->data_ptrs = g_slist_append (todo->data_ptrs, text[1]); - } - else - text[1] = NULL; - - cal_component_get_priority (comp, &p); - if(p && todo_show_priority) - { - text[2] = g_strdup_printf ("%d", *p); - todo->data_ptrs = g_slist_append (todo->data_ptrs, text[2]); - } - else - text[2] = NULL; - - i = gtk_clist_append (todo->clist, text); - - gtk_clist_set_row_data_full (todo->clist, i, comp, - (GtkDestroyNotify) gtk_object_ref); - gtk_object_ref (GTK_OBJECT (comp)); - - /* - * determine if the task is overdue.. - * if so mark with the apropriate style - */ - - switch(todo_item_due_status(&d)) { - case TODO_ITEM_DSTATUS_NOT_DUE_YET: - if(todo_item_dstatus_highlight_not_due_yet) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_NOT_DUE_YET]); - } - break; - case TODO_ITEM_DSTATUS_DUE_TODAY: - if(todo_item_dstatus_highlight_due_today) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_DUE_TODAY]); - } - break; - case TODO_ITEM_DSTATUS_OVERDUE: - if(todo_item_dstatus_highlight_overdue) - { - gtk_clist_set_row_style(todo->clist, i, dstatus_styles[TODO_ITEM_DSTATUS_OVERDUE]); - } - break; - case TODO_ITEM_DSTATUS_LAST_DUE_STATUS: - } - - /* keep the list in order */ - gtk_clist_sort (todo->clist); -} - - -void -gncal_todo_update (GncalTodo *todo, CalComponent *comp, int flags) -{ - GSList *current_list; - CalClientGetStatus status; - GList *l, *uids; - - g_return_if_fail (todo != NULL); - g_return_if_fail (GNCAL_IS_TODO (todo)); - - /* - * shut down the resize handler cause we are playing with the list. - * In otherwords turn off the event handler - */ - todo_list_redraw_in_progess =1; - - /* freeze the list */ - gtk_clist_freeze (todo->clist); - init_column_sorting (todo->clist); - - /* - * before here we have to free some of the memory that - * stores the due date, or else we have a memory leak. - * luckily all of the pointers are stored in todo->data_ptrs; - */ - - /* check on the columns that we should display */ - /* check for due date */ - - if(todo_show_due_date) { - gtk_clist_set_column_visibility (todo->clist, 1, 1); - } - else { - gtk_clist_set_column_visibility (todo->clist, 1, 0); - } - - if(todo_show_time_remaining) { - gtk_clist_set_column_visibility (todo->clist, 3, 1); - } - else { - gtk_clist_set_column_visibility (todo->clist, 3, 0); - } - - - if(todo_show_priority) - gtk_clist_set_column_visibility (todo->clist, 2, 1); - else - gtk_clist_set_column_visibility (todo->clist, 2, 0); - - /* free the memory locations that were used in the previous display */ - for (current_list = todo->data_ptrs; - current_list != NULL; - current_list = g_slist_next(current_list)){ - g_free(current_list->data); - } - - /* free the list and clear out the pointer */ - g_slist_free(todo->data_ptrs); - todo->data_ptrs = NULL; - - gtk_clist_clear (todo->clist); - - - uids = cal_client_get_uids (todo->calendar->client, CAL_COMPONENT_TODO); - for (l = uids; l; l = l->next){ - char *uid = l->data; - CalComponent *comp; - - status = cal_client_get_object (todo->calendar->client, uid, - &comp); - - if (status == CAL_CLIENT_GET_SUCCESS) { - insert_in_clist (todo, comp); - gtk_object_unref (GTK_OBJECT (comp)); - } -#warning "FIX ME" - /* else? */ - g_free (uid); - } - g_list_free (uids); - - /* if we are autoresizing then do it now */ - if(todo_list_autoresize && todo->clist->rows != 0) - gtk_clist_columns_autosize (todo->clist); - - gtk_clist_thaw (todo->clist); - - gtk_widget_set_sensitive (todo->edit_button, - (todo->clist->selection != NULL)); - gtk_widget_set_sensitive (todo->delete_button, - (todo->clist->selection != NULL)); - todo_list_redraw_in_progess = 0; -} - - - - - - - - - - - diff --git a/calendar/gui/gncal-todo.h b/calendar/gui/gncal-todo.h deleted file mode 100644 index 1102e32d77..0000000000 --- a/calendar/gui/gncal-todo.h +++ /dev/null @@ -1,54 +0,0 @@ -/* To-do widget for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#ifndef GNCAL_TODO_H -#define GNCAL_TODO_H - -#include <gtk/gtkclist.h> -#include <gtk/gtkvbox.h> -#include <libgnome/gnome-defs.h> -#include "gnome-cal.h" - - -BEGIN_GNOME_DECLS - - -#define GNCAL_TODO(obj) GTK_CHECK_CAST (obj, gncal_todo_get_type (), GncalTodo) -#define GNCAL_TODO_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_todo_get_type (), GncalTodoClass) -#define GNCAL_IS_TODO(obj) GTK_CHECK_TYPE (obj, gncal_todo_get_type ()) - - -typedef struct _GncalTodo GncalTodo; -typedef struct _GncalTodoClass GncalTodoClass; - -struct _GncalTodo { - GtkVBox vbox; - - GnomeCalendar *calendar; /* the calendar we are associated to */ - - GtkCList *clist; - - GtkWidget *edit_button; - GtkWidget *delete_button; - GSList *data_ptrs; -}; - -struct _GncalTodoClass { - GtkVBoxClass parent_class; -}; - - -guint gncal_todo_get_type (void); -GtkWidget *gncal_todo_new (GnomeCalendar *calendar); - -void gncal_todo_update (GncalTodo *todo, CalComponent *comp, int flags); - -void gncal_todo_edit (CalClient *client, CalComponent *comp); - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c deleted file mode 100644 index 334e66f331..0000000000 --- a/calendar/gui/gnome-cal.c +++ /dev/null @@ -1,1530 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * GnomeCalendar widget - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: Miguel de Icaza (miguel@kernel.org) - * Federico Mena-Quintero <federico@helixcode.com> - */ - -#include <config.h> -#include <unistd.h> -#include <signal.h> -#include <sys/wait.h> -#include <fcntl.h> -#include <gtk/gtkframe.h> -#include <widgets/e-paned/e-hpaned.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkmain.h> -#include <gtk/gtknotebook.h> -#include <gtk/gtkscrolledwindow.h> -#include <widgets/e-paned/e-vpaned.h> -#include <libgnomeui/gnome-messagebox.h> -#include <cal-util/timeutil.h> -#include "dialogs/alarm-notify-dialog.h" -#include "alarm.h" -#include "e-calendar-table.h" -#include "e-day-view.h" -#include "e-week-view.h" -#include "event-editor.h" -#include "gnome-cal.h" -#include "calendar-commands.h" - - - -/* An entry in the UID->alarms hash table. The UID key *is* the uid field in - * this structure, so don't free it separately. - */ -typedef struct { - char *uid; - GList *alarm_ids; -} ObjectAlarms; - - - -static void gnome_calendar_class_init (GnomeCalendarClass *class); -static void gnome_calendar_init (GnomeCalendar *gcal); -static void gnome_calendar_destroy (GtkObject *object); - -static void gnome_calendar_update_view_times (GnomeCalendar *gcal, - GtkWidget *page); -static void gnome_calendar_update_gtk_calendar (GnomeCalendar *gcal); -static void gnome_calendar_on_day_selected (GtkCalendar *calendar, - GnomeCalendar *gcal); -static void gnome_calendar_on_month_changed (GtkCalendar *calendar, - GnomeCalendar *gcal); - -static GtkVBoxClass *parent_class; - -static void setup_alarm (GnomeCalendar *cal, CalAlarmInstance *ai); - - - -guint -gnome_calendar_get_type (void) -{ - static guint gnome_calendar_type = 0; - if(!gnome_calendar_type) { - GtkTypeInfo gnome_calendar_info = { - "GnomeCalendar", - sizeof (GnomeCalendar), - sizeof (GnomeCalendarClass), - (GtkClassInitFunc) gnome_calendar_class_init, - (GtkObjectInitFunc) gnome_calendar_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - /* - gnome_calendar_type = gtk_type_unique(gnome_app_get_type(), &gnome_calendar_info); - parent_class = gtk_type_class (gnome_app_get_type()); - */ - gnome_calendar_type = gtk_type_unique (gtk_vbox_get_type (), - &gnome_calendar_info); - parent_class = gtk_type_class (gtk_vbox_get_type ()); - } - return gnome_calendar_type; -} - -/* Class initialization function for the gnome calendar */ -static void -gnome_calendar_class_init (GnomeCalendarClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) class; - - object_class->destroy = gnome_calendar_destroy; -} - -/* Object initialization function for the gnome calendar */ -static void -gnome_calendar_init (GnomeCalendar *gcal) -{ - gcal->object_editor_hash = g_hash_table_new (g_str_hash, g_str_equal); - gcal->alarms = g_hash_table_new (g_str_hash, g_str_equal); -} - -/* Used from g_hash_table_foreach(); frees an object alarms entry */ -static void -free_object_alarms (gpointer key, gpointer value, gpointer data) -{ - ObjectAlarms *oa; - - oa = value; - - g_assert (oa->uid != NULL); - g_free (oa->uid); - oa->uid = NULL; - - g_assert (oa->alarm_ids != NULL); - g_list_free (oa->alarm_ids); - oa->alarm_ids = NULL; - - g_free (oa); -} - -/* Used from g_hash_table_foreach(); frees an UID string */ -static void -free_uid (gpointer key, gpointer value, gpointer data) -{ - char *uid; - - uid = key; - g_free (uid); -} - -static void -gnome_calendar_destroy (GtkObject *object) -{ - GnomeCalendar *gcal; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (object)); - - gcal = GNOME_CALENDAR (object); - - gtk_object_unref (GTK_OBJECT (gcal->client)); - - g_hash_table_foreach (gcal->alarms, free_object_alarms, NULL); - g_hash_table_destroy (gcal->alarms); - gcal->alarms = NULL; - - g_hash_table_foreach (gcal->object_editor_hash, free_uid, NULL); - g_hash_table_destroy (gcal->object_editor_hash); - gcal->object_editor_hash = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -setup_widgets (GnomeCalendar *gcal) -{ - GtkWidget *vpane, *w; - - /* The Main Notebook. */ - gcal->main_notebook = gtk_notebook_new (); - gtk_notebook_set_show_border (GTK_NOTEBOOK (gcal->main_notebook), - FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (gcal->main_notebook), FALSE); - gtk_widget_show (gcal->main_notebook); - gtk_box_pack_start (GTK_BOX (gcal), gcal->main_notebook, - TRUE, TRUE, 0); - - /* The First Page of the Main Notebook, containing a HPaned with the - Sub-Notebook on the left and the GtkCalendar and ToDo list on the - right. */ - gcal->hpane = e_hpaned_new (); - gtk_widget_show (gcal->hpane); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->main_notebook), - gcal->hpane, gtk_label_new ("")); - - /* The Sub-Notebook, to contain the Day, Work-Week & Week views. */ - gcal->sub_notebook = gtk_notebook_new (); - gtk_notebook_set_show_border (GTK_NOTEBOOK (gcal->sub_notebook), - FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (gcal->sub_notebook), FALSE); - gtk_widget_show (gcal->sub_notebook); - e_paned_pack1 (E_PANED (gcal->hpane), gcal->sub_notebook, - TRUE, TRUE); - - /* The VPaned widget, to contain the GtkCalendar & ToDo list. */ - vpane = e_vpaned_new (); - gtk_widget_show (vpane); - e_paned_pack2 (E_PANED (gcal->hpane), vpane, FALSE, TRUE); - - /* The GtkCalendar. */ - w = gtk_calendar_new (); - gcal->gtk_calendar = GTK_CALENDAR (w); - gtk_widget_show (w); - e_paned_pack1 (E_PANED (vpane), w, FALSE, TRUE); - gcal->day_selected_id = gtk_signal_connect (GTK_OBJECT (gcal->gtk_calendar), - "day_selected", - (GtkSignalFunc) gnome_calendar_on_day_selected, - gcal); - gtk_signal_connect (GTK_OBJECT (gcal->gtk_calendar), "month_changed", - GTK_SIGNAL_FUNC (gnome_calendar_on_month_changed), - gcal); - - /* The ToDo list. */ -#if 0 - gcal->todo = gncal_todo_new (gcal); - e_paned_pack2 (E_PANED (vpane), gcal->todo, TRUE, TRUE); - gtk_widget_show (gcal->todo); -#endif - - gcal->todo = e_calendar_table_new (); - e_paned_pack2 (E_PANED (vpane), gcal->todo, TRUE, TRUE); - gtk_widget_show (gcal->todo); - e_calendar_table_set_cal_client (E_CALENDAR_TABLE (gcal->todo), - gcal->client); - - - /* The Day View. */ - gcal->day_view = e_day_view_new (); - e_day_view_set_calendar (E_DAY_VIEW (gcal->day_view), gcal); - gtk_widget_show (gcal->day_view); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), - gcal->day_view, gtk_label_new ("")); - - /* The Work Week View. */ - gcal->work_week_view = e_day_view_new (); - e_day_view_set_days_shown (E_DAY_VIEW (gcal->work_week_view), 5); - e_day_view_set_calendar (E_DAY_VIEW (gcal->work_week_view), gcal); - gtk_widget_show (gcal->work_week_view); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), - gcal->work_week_view, gtk_label_new ("")); - - /* The Week View. */ - gcal->week_view = e_week_view_new (); - e_week_view_set_calendar (E_WEEK_VIEW (gcal->week_view), gcal); - gtk_widget_show (gcal->week_view); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->sub_notebook), - gcal->week_view, gtk_label_new ("")); - - /* The Month View. */ - gcal->month_view = e_week_view_new (); - e_week_view_set_calendar (E_WEEK_VIEW (gcal->month_view), gcal); - e_week_view_set_display_month (E_WEEK_VIEW (gcal->month_view), TRUE); - gtk_widget_show (gcal->month_view); - gtk_notebook_append_page (GTK_NOTEBOOK (gcal->main_notebook), - gcal->month_view, gtk_label_new ("")); -} - -static GtkWidget * -get_current_page (GnomeCalendar *gcal) -{ - GtkWidget *page; - - page = GTK_NOTEBOOK (gcal->main_notebook)->cur_page->child; - if (page == gcal->hpane) - return GTK_NOTEBOOK (gcal->sub_notebook)->cur_page->child; - else - return page; -} - -char * -gnome_calendar_get_current_view_name (GnomeCalendar *gcal) -{ - GtkWidget *page; - - g_return_val_if_fail (gcal != NULL, "dayview"); - g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), "dayview"); - - page = get_current_page (gcal); - - if (page == gcal->day_view) - return "dayview"; - else if (page == gcal->work_week_view) - return "workweekview"; - else if (page == gcal->week_view) - return "weekview"; - else if (page == gcal->month_view) - return "monthview"; - else - return "dayview"; -} - -void -gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (new_time != -1); - - gcal->selection_start_time = time_day_begin (new_time); - gcal->selection_end_time = time_add_day (gcal->selection_start_time, - 1); - gnome_calendar_update_view_times (gcal, NULL); - gnome_calendar_update_gtk_calendar (gcal); -} - - -static void -gnome_calendar_update_view_times (GnomeCalendar *gcal, - GtkWidget *page) -{ - if (page == NULL) - page = get_current_page (gcal); - - if (page == gcal->day_view - || page == gcal->work_week_view) - e_day_view_set_selected_time_range (E_DAY_VIEW (page), - gcal->selection_start_time, - gcal->selection_end_time); - else if (page == gcal->week_view - || page == gcal->month_view) - e_week_view_set_selected_time_range (E_WEEK_VIEW (page), - gcal->selection_start_time, - gcal->selection_end_time); - else { - g_warning ("My penguin is gone!"); - g_assert_not_reached (); - } -} - -static void -gnome_calendar_direction (GnomeCalendar *gcal, int direction) -{ - GtkWidget *cp = get_current_page (gcal); - time_t start_time, end_time; - - start_time = gcal->selection_start_time; - end_time = gcal->selection_end_time; - - if (cp == gcal->day_view) { - start_time = time_add_day (start_time, direction); - end_time = time_add_day (end_time, direction); - } else if (cp == gcal->work_week_view) { - start_time = time_add_week (start_time, direction); - end_time = time_add_week (end_time, direction); - } else if (cp == gcal->week_view) { - start_time = time_add_week (start_time, direction); - end_time = time_add_week (end_time, direction); - } else if (cp == gcal->month_view) { - start_time = time_add_month (start_time, direction); - end_time = time_add_month (end_time, direction); - } else { - g_warning ("Weee! Where did the penguin go?"); - g_assert_not_reached (); - start_time = 0; - end_time = 0; - } - - gcal->selection_start_time = start_time; - gcal->selection_end_time = end_time; - - gnome_calendar_update_view_times (gcal, NULL); - gnome_calendar_update_gtk_calendar (gcal); -} - -void -gnome_calendar_next (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_direction (gcal, 1); -} - -void -gnome_calendar_previous (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_direction (gcal, -1); -} - -void -gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_set_view (gcal, "dayview"); - gnome_calendar_goto (gcal, time); -} - -void -gnome_calendar_goto_today (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_goto (gcal, time (NULL)); -} - - -/* This sets which view is currently shown. It also updates the selection time - of the view so it shows the appropriate days. */ -void -gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name) -{ - GtkWidget *page; - int main_page = 0, sub_page = -1; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (page_name != NULL); - - if (strcmp (page_name, "dayview") == 0) { - page = gcal->day_view; - sub_page = 0; - } else if (strcmp (page_name, "workweekview") == 0) { - page = gcal->work_week_view; - sub_page = 1; - } else if (strcmp (page_name, "weekview") == 0) { - page = gcal->week_view; - sub_page = 2; - } else if (strcmp (page_name, "monthview") == 0) { - page = gcal->month_view; - main_page = 1; - } else { - g_warning ("Unknown calendar view: %s", page_name); - return; - } - - gnome_calendar_update_view_times (gcal, page); - - if (sub_page != -1) - gtk_notebook_set_page (GTK_NOTEBOOK (gcal->sub_notebook), - sub_page); - gtk_notebook_set_page (GTK_NOTEBOOK (gcal->main_notebook), main_page); - - gnome_calendar_update_gtk_calendar (gcal); -} - -/* Sends a mail notification of an alarm trigger */ -static void -mail_notification (char *mail_address, char *text, time_t app_time) -{ - pid_t pid; - int p [2]; - char *command; - - pipe (p); - pid = fork (); - if (pid == 0){ - int dev_null; - - dev_null = open ("/dev/null", O_RDWR); - dup2 (p [0], 0); - dup2 (dev_null, 1); - dup2 (dev_null, 2); - execl ("/usr/lib/sendmail", "/usr/lib/sendmail", - mail_address, NULL); - _exit (127); - } - command = g_strconcat ("To: ", mail_address, "\n", - "Subject: ", _("Reminder of your appointment at "), - ctime (&app_time), "\n\n", text, "\n", NULL); - write (p [1], command, strlen (command)); - close (p [1]); - close (p [0]); - g_free (command); -} - -static int -max_open_files (void) -{ - static int files; - - if (files) - return files; - - files = sysconf (_SC_OPEN_MAX); - if (files != -1) - return files; -#ifdef OPEN_MAX - return files = OPEN_MAX; -#else - return files = 256; -#endif -} - -/* Executes a program as a notification of an alarm trigger */ -static void -program_notification (char *command, int close_standard) -{ - struct sigaction ignore, save_intr, save_quit; - int status = 0, i; - pid_t pid; - - ignore.sa_handler = SIG_IGN; - sigemptyset (&ignore.sa_mask); - ignore.sa_flags = 0; - - sigaction (SIGINT, &ignore, &save_intr); - sigaction (SIGQUIT, &ignore, &save_quit); - - if ((pid = fork ()) < 0){ - fprintf (stderr, "\n\nfork () = -1\n"); - return; - } - if (pid == 0){ - pid = fork (); - if (pid == 0){ - const int top = max_open_files (); - sigaction (SIGINT, &save_intr, NULL); - sigaction (SIGQUIT, &save_quit, NULL); - - for (i = (close_standard ? 0 : 3); i < top; i++) - close (i); - - /* FIXME: As an excercise to the reader, copy the - * code from mc to setup shell properly instead of - * /bin/sh. Yes, this comment is larger than a cut and paste. - */ - execl ("/bin/sh", "/bin/sh", "-c", command, (char *) 0); - - _exit (127); - } else { - _exit (127); - } - } - wait (&status); - sigaction (SIGINT, &save_intr, NULL); - sigaction (SIGQUIT, &save_quit, NULL); -} - -/* Queues a snooze alarm */ -static void -snooze (GnomeCalendar *gcal, CalComponent *comp, time_t occur, int snooze_mins, gboolean audio) -{ - time_t now, trigger; - struct tm tm; - CalAlarmInstance ai; - - now = time (NULL); - tm = *localtime (&now); - tm.tm_min += snooze_mins; - - trigger = mktime (&tm); - if (trigger == -1) { - g_message ("snooze(): produced invalid time_t; not queueing alarm!"); - return; - } - -#if 0 - cal_component_get_uid (comp, &ai.uid); - ai.type = audio ? ALARM_AUDIO : ALARM_DISPLAY; -#endif - ai.trigger = trigger; - ai.occur = occur; - - setup_alarm (gcal, &ai); -} - -/* Edits an appointment from the alarm notification dialog */ -static void -edit (GnomeCalendar *gcal, CalComponent *comp) -{ - gnome_calendar_edit_object (gcal, comp); -} - -struct alarm_notify_closure { - GnomeCalendar *gcal; - CalComponent *comp; - time_t occur; -}; - -/* Callback used for the result of the alarm notification dialog */ -static void -display_notification_cb (AlarmNotifyResult result, int snooze_mins, gpointer data) -{ - struct alarm_notify_closure *c; - - c = data; - - switch (result) { - case ALARM_NOTIFY_CLOSE: - break; - - case ALARM_NOTIFY_SNOOZE: - snooze (c->gcal, c->comp, c->occur, snooze_mins, FALSE); - break; - - case ALARM_NOTIFY_EDIT: - edit (c->gcal, c->comp); - break; - - default: - g_assert_not_reached (); - } - - gtk_object_unref (GTK_OBJECT (c->comp)); - g_free (c); -} - -/* Present a display notification of an alarm trigger */ -static void -display_notification (time_t trigger, time_t occur, CalComponent *comp, GnomeCalendar *gcal) -{ - gboolean result; - struct alarm_notify_closure *c; - - gtk_object_ref (GTK_OBJECT (comp)); - - c = g_new (struct alarm_notify_closure, 1); - c->gcal = gcal; - c->comp = comp; - c->occur = occur; - - result = alarm_notify_dialog (trigger, occur, comp, display_notification_cb, c); - if (!result) { - g_message ("display_notification(): could not display the alarm notification dialog"); - g_free (c); - gtk_object_unref (GTK_OBJECT (comp)); - } -} - -/* Present an audible notification of an alarm trigger */ -static void -audio_notification (time_t trigger, time_t occur, CalComponent *comp, GnomeCalendar *gcal) -{ - g_message ("AUDIO NOTIFICATION!"); - /* FIXME */ -} - -struct trigger_alarm_closure { - GnomeCalendar *gcal; - char *uid; - CalComponentAlarmAction type; - time_t occur; -}; - -/* Callback function used when an alarm is triggered */ -static void -trigger_alarm_cb (gpointer alarm_id, time_t trigger, gpointer data) -{ - struct trigger_alarm_closure *c; - CalComponent *comp; - CalClientGetStatus status; - const char *uid; - ObjectAlarms *oa; - GList *l; - - c = data; - - /* Fetch the object */ - - status = cal_client_get_object (c->gcal->client, c->uid, &comp); - - switch (status) { - case CAL_CLIENT_GET_SUCCESS: - /* Go on */ - break; - case CAL_CLIENT_GET_SYNTAX_ERROR: - case CAL_CLIENT_GET_NOT_FOUND: - g_message ("trigger_alarm_cb(): syntax error in fetched object"); - return; - } - - g_assert (comp != NULL); - - /* Present notification */ - - switch (c->type) { - case CAL_COMPONENT_ALARM_EMAIL: -#if 0 - g_assert (ico->malarm.enabled); - mail_notification (ico->malarm.data, ico->summary, c->occur); -#endif - break; - - case CAL_COMPONENT_ALARM_PROCEDURE: -#if 0 - g_assert (ico->palarm.enabled); - program_notification (ico->palarm.data, FALSE); -#endif - break; - - case CAL_COMPONENT_ALARM_DISPLAY: -#if 0 - g_assert (ico->dalarm.enabled); -#endif - display_notification (trigger, c->occur, comp, c->gcal); - break; - - case CAL_COMPONENT_ALARM_AUDIO: -#if 0 - g_assert (ico->aalarm.enabled); -#endif - audio_notification (trigger, c->occur, comp, c->gcal); - break; - - default: - break; - } - - /* Remove the alarm from the hash table */ - cal_component_get_uid (comp, &uid); - oa = g_hash_table_lookup (c->gcal->alarms, uid); - g_assert (oa != NULL); - - l = g_list_find (oa->alarm_ids, alarm_id); - g_assert (l != NULL); - - oa->alarm_ids = g_list_remove_link (oa->alarm_ids, l); - g_list_free_1 (l); - - if (!oa->alarm_ids) { - g_hash_table_remove (c->gcal->alarms, uid); - g_free (oa->uid); - g_free (oa); - } - - gtk_object_unref (GTK_OBJECT (comp)); -} - -/* Frees a struct trigger_alarm_closure */ -static void -free_trigger_alarm_closure (gpointer data) -{ - struct trigger_alarm_closure *c; - - c = data; - g_free (c->uid); - g_free (c); -} - -/* Queues the specified alarm */ -static void -setup_alarm (GnomeCalendar *cal, CalAlarmInstance *ai) -{ - struct trigger_alarm_closure *c; - gpointer alarm; - ObjectAlarms *oa; - - c = g_new (struct trigger_alarm_closure, 1); - c->gcal = cal; - c->uid = g_strdup (ai->uid); -#if 0 - c->type = ai->type; -#endif - c->occur = ai->occur; - - alarm = alarm_add (ai->trigger, trigger_alarm_cb, c, free_trigger_alarm_closure); - if (!alarm) { - g_message ("setup_alarm(): Could not set up alarm"); - g_free (c->uid); - g_free (c); - return; - } - - oa = g_hash_table_lookup (cal->alarms, ai->uid); - if (oa) - oa->alarm_ids = g_list_prepend (oa->alarm_ids, alarm); - else { - oa = g_new (ObjectAlarms, 1); - oa->uid = g_strdup (ai->uid); - oa->alarm_ids = g_list_prepend (NULL, alarm); - - g_hash_table_insert (cal->alarms, oa->uid, oa); - } -} - -static void load_alarms (GnomeCalendar *cal); - -/* Called nightly to refresh the day's alarms */ -static void -midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data) -{ - GnomeCalendar *cal; - - cal = GNOME_CALENDAR (data); - cal->midnight_alarm_refresh_id = NULL; - - load_alarms (cal); -} - -/* Loads and queues the alarms from the current time up to midnight. */ -static void -load_alarms (GnomeCalendar *gcal) -{ - time_t now; - time_t end_of_day; - GList *alarms, *l; - - now = time (NULL); - end_of_day = time_day_end (now); - - /* Queue alarms */ - - alarms = cal_client_get_alarms_in_range (gcal->client, now, end_of_day); - - for (l = alarms; l; l = l->next) - setup_alarm (gcal, l->data); - - cal_alarm_instance_list_free (alarms); - - /* Queue the midnight alarm refresh */ - - gcal->midnight_alarm_refresh_id = alarm_add (end_of_day, midnight_refresh_cb, gcal, NULL); - if (!gcal->midnight_alarm_refresh_id) { - g_message ("load_alarms(): Could not set up the midnight refresh alarm!"); - /* FIXME: what to do? */ - } -} - -/* This tells all components to reload all calendar objects. */ -static void -gnome_calendar_update_all (GnomeCalendar *cal) -{ - load_alarms (cal); - - e_day_view_update_all_events (E_DAY_VIEW (cal->day_view)); - e_day_view_update_all_events (E_DAY_VIEW (cal->work_week_view)); - e_week_view_update_all_events (E_WEEK_VIEW (cal->week_view)); - e_week_view_update_all_events (E_WEEK_VIEW (cal->month_view)); - -#if 0 - gncal_todo_update (GNCAL_TODO (cal->todo), NULL, TRUE); -#endif - gnome_calendar_tag_calendar (cal, cal->gtk_calendar); -} - -/* Removes any queued alarms for the specified UID */ -static void -remove_alarms_for_object (GnomeCalendar *gcal, const char *uid) -{ - ObjectAlarms *oa; - GList *l; - - oa = g_hash_table_lookup (gcal->alarms, uid); - if (!oa) - return; - - for (l = oa->alarm_ids; l; l = l->next) { - gpointer alarm_id; - - alarm_id = l->data; - alarm_remove (alarm_id); - } - - g_hash_table_remove (gcal->alarms, uid); - - g_free (oa->uid); - g_list_free (oa->alarm_ids); - g_free (oa); -} - -/* Adds today's alarms for the specified object */ -static void -add_alarms_for_object (GnomeCalendar *gcal, const char *uid) -{ - GList *alarms; - gboolean result; - time_t now, end_of_day; - GList *l; - - now = time (NULL); - end_of_day = time_day_end (now); - - result = cal_client_get_alarms_for_object (gcal->client, uid, now, end_of_day, &alarms); - if (!result) { - /* FIXME: should we warn here, or is it OK if the object - * disappeared in the meantime? - */ - return; - } - - for (l = alarms; l; l = l->next) - setup_alarm (gcal, l->data); - - cal_alarm_instance_list_free (alarms); -} - -static void -gnome_calendar_object_updated_cb (GtkWidget *cal_client, - const char *uid, - GnomeCalendar *gcal) -{ - g_message ("gnome-cal: got object changed_cb, uid='%s'", - uid?uid:"<NULL>"); - - remove_alarms_for_object (gcal, uid); - add_alarms_for_object (gcal, uid); - - /* FIXME: do we really want each view to reload the event itself? - Maybe we should keep track of events globally, maybe with ref - counts. We also need to sort out where they get freed. */ - e_day_view_update_event (E_DAY_VIEW (gcal->day_view), uid); - e_day_view_update_event (E_DAY_VIEW (gcal->work_week_view), uid); - e_week_view_update_event (E_WEEK_VIEW (gcal->week_view), uid); - e_week_view_update_event (E_WEEK_VIEW (gcal->month_view), uid); - -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, TRUE); -#endif - gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); -} - - -static void -gnome_calendar_object_removed_cb (GtkWidget *cal_client, - const char *uid, - GnomeCalendar *gcal) -{ - g_message ("gnome-cal: got object removed _cb, uid='%s'", - uid?uid:"<NULL>"); - - remove_alarms_for_object (gcal, uid); - - e_day_view_remove_event (E_DAY_VIEW (gcal->day_view), uid); - e_day_view_remove_event (E_DAY_VIEW (gcal->work_week_view), uid); - e_week_view_remove_event (E_WEEK_VIEW (gcal->week_view), uid); - e_week_view_remove_event (E_WEEK_VIEW (gcal->month_view), uid); - -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, CHANGE_ALL); -#endif - gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); -} - - -GtkWidget * -gnome_calendar_new (char *title) -{ - GtkWidget *retval; - GnomeCalendar *gcal; - - retval = gtk_type_new (gnome_calendar_get_type ()); - - gcal = GNOME_CALENDAR (retval); - - gcal->selection_start_time = time_day_begin (time (NULL)); - gcal->selection_end_time = time_add_day (gcal->selection_start_time, 1); - gcal->client = cal_client_new (); - - setup_widgets (gcal); - - gnome_calendar_set_view (gcal, "dayview"); - - gtk_signal_connect (GTK_OBJECT (gcal->client), "obj_updated", - gnome_calendar_object_updated_cb, gcal); - gtk_signal_connect (GTK_OBJECT (gcal->client), "obj_removed", - gnome_calendar_object_removed_cb, gcal); - - return retval; -} - -typedef struct -{ - GnomeCalendar *gcal; - char *uri; - GnomeCalendarOpenMode gcom; - guint signal_handle; -} load_or_create_data; - - -static void -gnome_calendar_load_cb (CalClient *cal_client, - CalClientLoadStatus status, - load_or_create_data *locd) -{ - g_return_if_fail (locd); - g_return_if_fail (GNOME_IS_CALENDAR (locd->gcal)); - - switch (status) { - case CAL_CLIENT_LOAD_SUCCESS: - gnome_calendar_update_all (locd->gcal); - g_message ("gnome_calendar_load_cb: success"); - break; - - case CAL_CLIENT_LOAD_ERROR: - g_message ("gnome_calendar_load_cb: load error"); - if (locd->gcom == CALENDAR_OPEN_OR_CREATE) { - g_message ("gnome_calendar_load_cb: trying create..."); - /* FIXME: connect to the cal_loaded signal of the - * CalClient and get theasynchronous notification - * properly! */ - /*gtk_signal_connect (GTK_OBJECT (gcal->client), - "cal_loaded", - gnome_calendar_create_cb, gcal);*/ - - gtk_signal_disconnect (GTK_OBJECT (locd->gcal->client), - locd->signal_handle); - - cal_client_create_calendar (locd->gcal->client, - locd->uri); - gnome_calendar_update_all (locd->gcal); - } - break; - - case CAL_CLIENT_LOAD_IN_USE: - /* FIXME: what to do? */ - g_message ("gnome_calendar_load_cb: in use"); - break; - - case CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED: - /* FIXME: what to do? */ - g_message ("gnome_calendar_load_cb(): method not supported"); - break; - - default: - g_message ("gnome_calendar_load_cb(): unhandled result code %d!", (int) status); - g_assert_not_reached (); - } - - g_free (locd->uri); - g_free (locd); -} - - -int -gnome_calendar_open (GnomeCalendar *gcal, - char *file, - GnomeCalendarOpenMode gcom) -{ - load_or_create_data *locd; - - g_return_val_if_fail (gcal != NULL, 0); - g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), 0); - g_return_val_if_fail (file != NULL, 0); - - locd = g_new0 (load_or_create_data, 1); - locd->gcal = gcal; - locd->uri = g_strdup (file); - locd->gcom = gcom; - - locd->signal_handle = gtk_signal_connect (GTK_OBJECT (gcal->client), - "cal_loaded", - gnome_calendar_load_cb, - locd); - - if (cal_client_load_calendar (gcal->client, file) == FALSE){ - g_message ("Error loading calendar: %s", file); - return 0; - } - - return 1; -} - -static void -stop_beeping (GtkObject* object, gpointer data) -{ - guint timer_tag, beep_tag; - timer_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "timer_tag")); - beep_tag = GPOINTER_TO_INT (gtk_object_get_data (object, "beep_tag")); - - if (beep_tag > 0) { - gtk_timeout_remove (beep_tag); - gtk_object_set_data (object, "beep_tag", GINT_TO_POINTER (0)); - } - if (timer_tag > 0) { - gtk_timeout_remove (timer_tag); - gtk_object_set_data (object, "timer_tag", GINT_TO_POINTER (0)); - } -} - -static gint -start_beeping (gpointer data) -{ - gdk_beep (); - - return TRUE; -} - -static gint -timeout_beep (gpointer data) -{ - stop_beeping (data, NULL); - return FALSE; -} - -#if 0 - -void -calendar_notify (time_t activation_time, CalendarAlarm *which, void *data) -{ - iCalObject *ico = data; - guint beep_tag, timer_tag; - int ret; - gchar* snooze_button = (enable_snooze ? _("Snooze") : NULL); - time_t now, diff; - - if (&ico->aalarm == which){ - time_t app = ico->aalarm.trigger + ico->aalarm.offset; - GtkWidget *w; - char *msg; - - msg = g_strconcat (_("Reminder of your appointment at "), - ctime (&app), "`", - ico->summary, "'", NULL); - - /* Idea: we need Snooze option :-) */ - w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, _("Ok"), snooze_button, NULL); - beep_tag = gtk_timeout_add (1000, start_beeping, NULL); - if (enable_aalarm_timeout) - timer_tag = gtk_timeout_add (audio_alarm_timeout*1000, - timeout_beep, w); - else - timer_tag = 0; - gtk_object_set_data (GTK_OBJECT (w), "timer_tag", - GINT_TO_POINTER (timer_tag)); - gtk_object_set_data (GTK_OBJECT (w), "beep_tag", - GINT_TO_POINTER (beep_tag)); - gtk_widget_ref (w); - gtk_window_set_modal (GTK_WINDOW (w), FALSE); - ret = gnome_dialog_run (GNOME_DIALOG (w)); - switch (ret) { - case 1: - stop_beeping (GTK_OBJECT (w), NULL); - now = time (NULL); - diff = now - which->trigger; - which->trigger = which->trigger + diff + snooze_secs; - which->offset = which->offset - diff - snooze_secs; - alarm_add (which, &calendar_notify, data); - break; - default: - stop_beeping (GTK_OBJECT (w), NULL); - break; - } - - gtk_widget_unref (w); - return; - } - - if (&ico->palarm == which){ - execute (ico->palarm.data, 0); - return; - } - - if (&ico->malarm == which){ - time_t app = ico->malarm.trigger + ico->malarm.offset; - - mail_notify (ico->malarm.data, ico->summary, app); - return; - } - - if (&ico->dalarm == which){ - time_t app = ico->dalarm.trigger + ico->dalarm.offset; - GtkWidget *w; - char *msg; - - if (beep_on_display) - gdk_beep (); - msg = g_strconcat (_("Reminder of your appointment at "), - ctime (&app), "`", - ico->summary, "'", NULL); - w = gnome_message_box_new (msg, GNOME_MESSAGE_BOX_INFO, - _("Ok"), snooze_button, NULL); - gtk_window_set_modal (GTK_WINDOW (w), FALSE); - ret = gnome_dialog_run (GNOME_DIALOG (w)); - switch (ret) { - case 1: - now = time (NULL); - diff = now - which->trigger; - which->trigger = which->trigger + diff + snooze_secs; - which->offset = which->offset - diff - snooze_secs; - alarm_add (which, &calendar_notify, data); - break; - default: - break; - } - - return; - } -} - -#endif - -/* Marks the specified range in a GtkCalendar */ -static void -mark_gtk_calendar_day (GtkCalendar *calendar, time_t start, time_t end) -{ - time_t t; - - t = time_day_begin (start); - - do { - struct tm tm; - - tm = *localtime (&t); - gtk_calendar_mark_day (calendar, tm.tm_mday); - - t = time_day_end (t); - } while (t < end); -} - -/* - * Tags the dates with appointments in a GtkCalendar based on the - * GnomeCalendar contents - */ -struct calendar_tag_closure -{ - GtkCalendar *gtk_cal; - time_t month_begin; - time_t month_end; -}; - -static gboolean -gnome_calendar_tag_calendar_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - struct calendar_tag_closure *c = data; - - start = MAX (istart, c->month_begin); - end = MIN (iend, c->month_end); - - if (start > end) - return TRUE; - - /* Clip the occurrence's start and end times to the month's limits */ - mark_gtk_calendar_day (c->gtk_cal, start, end); - - return TRUE; -} - -void -gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal) -{ - struct calendar_tag_closure c; - - g_return_if_fail (cal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (cal)); - g_return_if_fail (gtk_cal != NULL); - g_return_if_fail (GTK_IS_CALENDAR (gtk_cal)); - - /* If the GtkCalendar isn't visible, we just return. */ - if (!GTK_WIDGET_VISIBLE (cal->gtk_calendar)) - return; - - c.gtk_cal = gtk_cal; - - c.month_begin = time_from_day (gtk_cal->year, gtk_cal->month, 1); - if (c.month_begin == -1) { - g_message ("gnome_calendar_tag_calendar(): Generated invalid month begin!"); - return; - } - - c.month_end = time_month_end (c.month_begin); - if (c.month_end == -1) { - g_message ("gnome_calendar_tag_calendar(): Generated invalid month end!"); - return; - } - - gtk_calendar_freeze (gtk_cal); - gtk_calendar_clear_marks (gtk_cal); - - cal_client_generate_instances (cal->client, CALOBJ_TYPE_EVENT, - c.month_begin, c.month_end, - gnome_calendar_tag_calendar_cb, &c); - - gtk_calendar_thaw (gtk_cal); -} - -/* This is called when the day begin & end times, the AM/PM flag, or the - week_starts_on_monday flags are changed. - FIXME: Which of these options do we want the new views to support? */ -void -gnome_calendar_time_format_changed (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gtk_calendar_display_options (gcal->gtk_calendar, - (week_starts_on_monday - ? (gcal->gtk_calendar->display_flags - | GTK_CALENDAR_WEEK_START_MONDAY) - : (gcal->gtk_calendar->display_flags - & ~GTK_CALENDAR_WEEK_START_MONDAY))); -} - -/* This is called when any of the color settings are changed. - FIXME: Need to update for the new views. */ -void -gnome_calendar_colors_changed (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - todo_style_changed = 1; -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, 0); -#endif -} - -void -gnome_calendar_todo_properties_changed (GnomeCalendar *gcal) -{ - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - todo_style_changed = 1; -#if 0 - gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, 0); -#endif -} - - -void -gnome_calendar_set_selected_time_range (GnomeCalendar *gcal, - time_t start_time, - time_t end_time) -{ - gcal->selection_start_time = start_time; - gcal->selection_end_time = end_time; - - gnome_calendar_update_gtk_calendar (gcal); -} - -/* Callback used when an event editor finishes editing an object */ -static void -ical_object_released_cb (EventEditor *ee, const char *uid, gpointer data) -{ - GnomeCalendar *gcal; - gboolean result; - gpointer orig_key; - char *orig_uid; - - gcal = GNOME_CALENDAR (data); - - result = g_hash_table_lookup_extended (gcal->object_editor_hash, uid, &orig_key, NULL); - g_assert (result != FALSE); - - orig_uid = orig_key; - - g_hash_table_remove (gcal->object_editor_hash, orig_uid); - g_free (orig_uid); -} - -/* Callback used when an event editor dialog is closed */ -static void -editor_closed_cb (EventEditor *ee, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ee)); -} - -/* Callback used when an event editor requests that an object be saved */ -static void -save_ical_object_cb (EventEditor *ee, CalComponent *comp, gpointer data) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - if (!cal_client_update_object (gcal->client, comp)) - g_message ("save_ical_object_cb(): Could not update the object!"); -} - -void -gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp) -{ - EventEditor *ee; - const char *uid; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (comp != NULL); - - cal_component_get_uid (comp, &uid); - - ee = g_hash_table_lookup (gcal->object_editor_hash, uid); - if (!ee) { - ee = event_editor_new (); - if (!ee) { - g_message ("gnome_calendar_edit_object(): Could not create the event editor"); - return; - } - - /* FIXME: what to do when an event editor wants to switch - * objects? We would need to know about it as well. - */ - - g_hash_table_insert (gcal->object_editor_hash, g_strdup (uid), ee); - gtk_signal_connect (GTK_OBJECT (ee), "ical_object_released", - GTK_SIGNAL_FUNC (ical_object_released_cb), gcal); - - gtk_signal_connect (GTK_OBJECT (ee), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), gcal); - - gtk_signal_connect (GTK_OBJECT (ee), "save_ical_object", - GTK_SIGNAL_FUNC (save_ical_object_cb), gcal); - - event_editor_set_ical_object (EVENT_EDITOR (ee), comp); - } - - event_editor_focus (ee); -} - -/** - * gnome_calendar_new_appointment: - * @gcal: An Evolution calendar. - * - * Opens an event editor dialog for a new appointment. The appointment's start - * and end times are set to the currently selected time range in the calendar - * views. - **/ -void -gnome_calendar_new_appointment (GnomeCalendar *gcal) -{ - CalComponent *comp; - time_t dtstart, dtend; - CalComponentDateTime dt; - struct icaltimetype itt; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - gnome_calendar_get_current_time_range (gcal, &dtstart, &dtend); - dt.value = &itt; - dt.tzid = NULL; - - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - - itt = icaltimetype_from_timet (dtstart, 0); - cal_component_set_dtstart (comp, &dt); - - itt = icaltimetype_from_timet (dtend, 0); - cal_component_set_dtend (comp, &dt); - - gnome_calendar_edit_object (gcal, comp); - gtk_object_unref (GTK_OBJECT (comp)); - -} - -/* Returns the selected time range for the current view. Note that this may be - different from the fields in the GnomeCalendar, since the view may clip - this or choose a more appropriate time. */ -void -gnome_calendar_get_current_time_range (GnomeCalendar *gcal, - time_t *start_time, - time_t *end_time) -{ - GtkWidget *page; - - page = get_current_page (gcal); - - if (page == gcal->day_view - || page == gcal->work_week_view) - e_day_view_get_selected_time_range (E_DAY_VIEW (page), - start_time, end_time); - else if (page == gcal->week_view - || page == gcal->month_view) - e_week_view_get_selected_time_range (E_WEEK_VIEW (page), - start_time, end_time); - else { - g_message ("My penguin is gone!"); - g_assert_not_reached (); - } -} - - - -/* This updates the month shown and the day selected in the calendar, if - necessary. */ -static void -gnome_calendar_update_gtk_calendar (GnomeCalendar *gcal) -{ - GDate date; - guint current_year, current_month, current_day; - guint new_year, new_month, new_day; - gboolean set_day = FALSE; - - /* If the GtkCalendar isn't visible, we just return. */ - if (!GTK_WIDGET_VISIBLE (gcal->gtk_calendar)) - return; - - gtk_calendar_get_date (gcal->gtk_calendar, ¤t_year, - ¤t_month, ¤t_day); - - g_date_clear (&date, 1); - g_date_set_time (&date, gcal->selection_start_time); - new_year = g_date_year (&date); - new_month = g_date_month (&date) - 1; - new_day = g_date_day (&date); - - /* Block the "day_selected" signal while we update the calendar. */ - gtk_signal_handler_block (GTK_OBJECT (gcal->gtk_calendar), - gcal->day_selected_id); - - /* If the year & month don't match, update it. */ - if (new_year != current_year || new_month != current_month) { - /* FIXME: GtkCalendar bug workaround. If we select a month - which has less days than the currently selected day, it - causes a problem next time we set the day. */ - if (current_day > 28) { - gtk_calendar_select_day (gcal->gtk_calendar, 28); - set_day = TRUE; - } - gtk_calendar_select_month (gcal->gtk_calendar, new_month, - new_year); - } - - /* If the day doesn't match, update it. */ - if (new_day != current_day || set_day) - gtk_calendar_select_day (gcal->gtk_calendar, new_day); - - gtk_signal_handler_unblock (GTK_OBJECT (gcal->gtk_calendar), - gcal->day_selected_id); -} - -static void -gnome_calendar_on_day_selected (GtkCalendar *calendar, - GnomeCalendar *gcal) -{ - gint y, m, d; - struct tm tm; - - gtk_calendar_get_date (calendar, &y, &m, &d); - - tm.tm_year = y - 1900; - tm.tm_mon = m; - tm.tm_mday = d; - tm.tm_hour = 5; /* for daylight savings time fix */ - tm.tm_min = 0; - tm.tm_sec = 0; - - gnome_calendar_goto (gcal, mktime (&tm)); -} - - -static void -gnome_calendar_on_month_changed (GtkCalendar *calendar, - GnomeCalendar *gcal) -{ - gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); -} diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h deleted file mode 100644 index df087395e1..0000000000 --- a/calendar/gui/gnome-cal.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * GnomeCalendar widget - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: Miguel de Icaza (miguel@kernel.org) - * Federico Mena-Quintero <federico@helixcode.com> - */ - -#ifndef GNOME_CALENDAR_APP_H -#define GNOME_CALENDAR_APP_H - -#include <time.h> -#include <gtk/gtkcalendar.h> -#include <gtk/gtkvbox.h> -#include <libgnome/gnome-defs.h> -#include <bonobo.h> -#include <cal-client/cal-client.h> - -BEGIN_GNOME_DECLS - - - -#define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar) -#define GNOME_CALENDAR_CLASS(class) GTK_CHECK_CAST_CLASS(class, gnome_calendar_get_type(), GnomeCalendarClass) -#define GNOME_IS_CALENDAR(obj) GTK_CHECK_TYPE(obj, gnome_calendar_get_type()) - -#define GNOME_CALENDAR_NUM_VIEWS 4 - -typedef struct { - GtkVBox vbox; - - CalClient *client; - - BonoboPropertyBag *properties; - BonoboControl *control; - - GHashTable *object_editor_hash; - - time_t selection_start_time; - time_t selection_end_time; - - GtkWidget *main_notebook; - GtkWidget *sub_notebook; - GtkWidget *hpane; - GtkCalendar *gtk_calendar; - GtkWidget *todo; - - GtkWidget *day_view; - GtkWidget *work_week_view; - GtkWidget *week_view; - GtkWidget *month_view; - - GtkWidget *view_toolbar_buttons[GNOME_CALENDAR_NUM_VIEWS]; - - void *event_editor; - - /* The signal handler id for our GtkCalendar "day_selected" handler. */ - guint day_selected_id; - - /* Alarm ID for the midnight refresh function */ - gpointer midnight_alarm_refresh_id; - - /* UID->alarms hash */ - GHashTable *alarms; -} GnomeCalendar; - -typedef struct { - GtkVBoxClass parent_class; -} GnomeCalendarClass; - - -typedef enum { - CALENDAR_OPEN, - CALENDAR_OPEN_OR_CREATE -} GnomeCalendarOpenMode; - -guint gnome_calendar_get_type (void); -GtkWidget *gnome_calendar_new (char *title); -int gnome_calendar_open (GnomeCalendar *gcal, - char *file, - GnomeCalendarOpenMode gcom); -/* -int gnome_calendar_create (GnomeCalendar *gcal, - char *file); -*/ -void gnome_calendar_next (GnomeCalendar *gcal); -void gnome_calendar_previous (GnomeCalendar *gcal); -void gnome_calendar_goto (GnomeCalendar *gcal, - time_t new_time); -void gnome_calendar_dayjump (GnomeCalendar *gcal, - time_t time); -/* Jumps to the current day */ -void gnome_calendar_goto_today (GnomeCalendar *gcal); -void gnome_calendar_tag_calendar (GnomeCalendar *cal, - GtkCalendar *gtk_cal); -char *gnome_calendar_get_current_view_name (GnomeCalendar *gcal); -void gnome_calendar_set_view (GnomeCalendar *gcal, - char *page_name); - -void gnome_calendar_set_selected_time_range (GnomeCalendar *gcal, - time_t start_time, - time_t end_time); - -void gnome_calendar_edit_object (GnomeCalendar *gcal, - CalComponent *comp); - -void gnome_calendar_new_appointment (GnomeCalendar *gcal); - -/* Returns the selected time range for the current view. Note that this may be - different from the fields in the GnomeCalendar, since the view may clip - this or choose a more appropriate time. */ -void gnome_calendar_get_current_time_range (GnomeCalendar *gcal, - time_t *start_time, - time_t *end_time); - - -/* Notifies the calendar that the time format has changed and it must update all its views */ -void gnome_calendar_time_format_changed (GnomeCalendar *gcal); - -/* Notifies the calendar that the todo list properties have changed and its time - * to update the views. - */ -void gnome_calendar_colors_changed (GnomeCalendar *gcal); - -/* Notifies the calendar that the todo list properties have changed and its time - * to update the views. - */ -void gnome_calendar_todo_properties_changed (GnomeCalendar *gcal); - - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/gnome-cal.html b/calendar/gui/gnome-cal.html deleted file mode 100644 index 5a7d0a537f..0000000000 --- a/calendar/gui/gnome-cal.html +++ /dev/null @@ -1,44 +0,0 @@ -<!-- Some simple instructions on how to use the help browser --> -<BODY> -<!-- <TITLE>GNOME Calendar Documentation</TITLE> --> -<H2> GNOME Calendar Documentation </H2> -<p> -The GNOME calendar program is the calendaring program of the GNOME -system. It uses the vCalendar standard for transfering calendar -information (and is also the on-disk format used). - -<p> - -<a name="cmdline"> -<h2>Command line options</h2> - -Several options are available on the command line, they are: -<ul> - <li><tt>--events</tt> Displays the events for the date - specified (or today, if no date is specified). - - <li><tt>--from DATE</tt> Define the beginning of the range for - the event display, or the startup day on the calenday views. - By default, the event will span the whole day specified in - DATE. - - <li><tt>--to DATE</tt> Define the range end for the event - display. If this is not specified, it will default to the end - of the day specified by the <tt>--from</tt> option. - - <li><tt>--file FILE</tt> Set the calendar to the FILE - specified on the command line. - - <li><tt>--todo</tt> Dumps the to-do values to standard output. -</ul> - -<p> - -DATE is interpreted as being in the local time- zone, unless a -specific timezone is specified. Examples of valid date specifications -include: "1 month ago", "2 hours ago", "400000 seconds ago", "last -year", "last Monday", "yesterday", "a fortnight ago", "3/31/92 -10:00:07 PST", "January 23, 1987 10:05pm", "22:00 GMT". - -</BODY> - diff --git a/calendar/gui/gnome-calendar-conduit.png b/calendar/gui/gnome-calendar-conduit.png Binary files differdeleted file mode 100644 index e867ba90b2..0000000000 --- a/calendar/gui/gnome-calendar-conduit.png +++ /dev/null diff --git a/calendar/gui/gnome-month-item.c b/calendar/gui/gnome-month-item.c deleted file mode 100644 index 58e393e4ee..0000000000 --- a/calendar/gui/gnome-month-item.c +++ /dev/null @@ -1,1246 +0,0 @@ -/* General-purpose monthly calendar canvas item for GNOME - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena <federico@nuclecu.unam.mx> - */ - -#include <config.h> -#include <math.h> -#include <time.h> -#include <gnome.h> -#include "gnome-month-item.h" - - -#define DEFAULT_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*" - - -/* Number of days in a month, for normal and leap years */ -static const int days_in_month[2][12] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -/* The weird month of September 1752, where 3 Sep through 13 Sep were eliminated due to the - * Gregorian reformation. - */ -static const int sept_1752[42] = { - 0, 0, 1, 2, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 -}; - -#define REFORMATION_DAY 639787 /* First day of the reformation, counted from 1 Jan 1 */ -#define MISSING_DAYS 11 /* They corrected out 11 days */ -#define THURSDAY 4 /* First day of reformation */ -#define SATURDAY 6 /* Offset value; 1 Jan 1 was a Saturday */ -#define SEPT_1752_START 2 /* Start day within month */ -#define SEPT_1752_END 20 /* End day within month */ - - -enum { - ARG_0, - ARG_YEAR, - ARG_MONTH, - ARG_X, - ARG_Y, - ARG_WIDTH, - ARG_HEIGHT, - ARG_ANCHOR, - ARG_HEAD_PADDING, - ARG_DAY_PADDING, - ARG_DAY_NAMES, - ARG_HEADING_HEIGHT, - ARG_HEADING_ANCHOR, - ARG_DAY_ANCHOR, - ARG_START_ON_MONDAY, - ARG_HEAD_FONT, - ARG_HEAD_FONTSET, - ARG_HEAD_FONT_GDK, - ARG_DAY_FONT, - ARG_DAY_FONTSET, - ARG_DAY_FONT_GDK, - ARG_HEAD_COLOR, - ARG_HEAD_COLOR_GDK, - ARG_OUTLINE_COLOR, - ARG_OUTLINE_COLOR_GDK, - ARG_DAY_BOX_COLOR, - ARG_DAY_BOX_COLOR_GDK, - ARG_DAY_COLOR, - ARG_DAY_COLOR_GDK -}; - - -static void gnome_month_item_class_init (GnomeMonthItemClass *class); -static void gnome_month_item_init (GnomeMonthItem *mitem); -static void gnome_month_item_destroy (GtkObject *object); -static void gnome_month_item_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gnome_month_item_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); - - - -static GnomeCanvasGroupClass *parent_class; - - -GtkType -gnome_month_item_get_type (void) -{ - static GtkType month_item_type = 0; - - if (!month_item_type) { - GtkTypeInfo month_item_info = { - "GnomeMonthItem", - sizeof (GnomeMonthItem), - sizeof (GnomeMonthItemClass), - (GtkClassInitFunc) gnome_month_item_class_init, - (GtkObjectInitFunc) gnome_month_item_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - month_item_type = gtk_type_unique (gnome_canvas_group_get_type (), &month_item_info); - } - - return month_item_type; -} - -static void -gnome_month_item_class_init (GnomeMonthItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass *) class; - item_class = (GnomeCanvasItemClass *) class; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("GnomeMonthItem::year", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_YEAR); - gtk_object_add_arg_type ("GnomeMonthItem::month", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_MONTH); - gtk_object_add_arg_type ("GnomeMonthItem::x", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X); - gtk_object_add_arg_type ("GnomeMonthItem::y", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y); - gtk_object_add_arg_type ("GnomeMonthItem::width", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("GnomeMonthItem::height", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEIGHT); - gtk_object_add_arg_type ("GnomeMonthItem::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR); - gtk_object_add_arg_type ("GnomeMonthItem::heading_padding", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEAD_PADDING); - gtk_object_add_arg_type ("GnomeMonthItem::day_padding", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_DAY_PADDING); - gtk_object_add_arg_type ("GnomeMonthItem::day_names", GTK_TYPE_POINTER, GTK_ARG_WRITABLE, ARG_DAY_NAMES); - gtk_object_add_arg_type ("GnomeMonthItem::heading_height", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_HEADING_HEIGHT); - gtk_object_add_arg_type ("GnomeMonthItem::heading_anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_HEADING_ANCHOR); - gtk_object_add_arg_type ("GnomeMonthItem::day_anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_DAY_ANCHOR); - gtk_object_add_arg_type ("GnomeMonthItem::start_on_monday", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_START_ON_MONDAY); - gtk_object_add_arg_type ("GnomeMonthItem::heading_font", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_FONT); - gtk_object_add_arg_type ("GnomeMonthItem::heading_fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_FONTSET); - gtk_object_add_arg_type ("GnomeMonthItem::heading_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_HEAD_FONT_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::day_font", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_FONT); - gtk_object_add_arg_type ("GnomeMonthItem::day_fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_FONTSET); - gtk_object_add_arg_type ("GnomeMonthItem::day_font_gdk", GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_DAY_FONT_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::heading_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_HEAD_COLOR); - gtk_object_add_arg_type ("GnomeMonthItem::heading_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_HEAD_COLOR_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::outline_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_OUTLINE_COLOR); - gtk_object_add_arg_type ("GnomeMonthItem::outline_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_OUTLINE_COLOR_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::day_box_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_BOX_COLOR); - gtk_object_add_arg_type ("GnomeMonthItem::day_box_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_BOX_COLOR_GDK); - gtk_object_add_arg_type ("GnomeMonthItem::day_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_DAY_COLOR); - gtk_object_add_arg_type ("GnomeMonthItem::day_color_gdk", GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_DAY_COLOR_GDK); - - object_class->destroy = gnome_month_item_destroy; - object_class->set_arg = gnome_month_item_set_arg; - object_class->get_arg = gnome_month_item_get_arg; -} - -/* Calculates the minimum heading height based on the heading font size and padding. It also - * calculates the minimum width of the month item based on the width of the headings. - */ -static void -check_heading_sizes (GnomeMonthItem *mitem) -{ - double m_height; - double m_width; - int width; - int max_width; - int i; - - /* Calculate minimum height */ - - m_height = mitem->head_font->ascent + mitem->head_font->descent + 2 * mitem->head_padding; - - if (mitem->head_height < m_height) - mitem->head_height = m_height; - - /* Go through each heading and remember the widest one */ - - max_width = 0; - - for (i = 0; i < 7; i++) { - width = gdk_string_width (mitem->head_font, mitem->day_names[i]); - if (max_width < width) - max_width = width; - } - - m_width = 7 * (max_width + 2 * mitem->head_padding); - - if (mitem->width < m_width) - mitem->width = m_width; -} - -/* Calculates the minimum width and height of the month item based on the day font size and padding. - * Assumes that the minimum heading height has already been computed. - */ -static void -check_day_sizes (GnomeMonthItem *mitem) -{ - double m_height; - double m_width; - int width; - int max_width; - char buf[100]; - int i; - - /* Calculate minimum height */ - - m_height = mitem->head_height + 6 * (mitem->day_font->ascent + mitem->day_font->descent + 2 * mitem->day_padding); - - if (mitem->height < m_height) - mitem->height = m_height; - - /* Calculate minimum width */ - - max_width = 0; - - for (i = 1; i < 32; i++) { - sprintf (buf, "%d", i); - width = gdk_string_width (mitem->day_font, buf); - if (max_width < width) - max_width = width; - } - - m_width = 7 * (max_width + 2 * mitem->day_padding); - - if (mitem->width < m_width) - mitem->width = m_width; -} - -/* Calculates the minimum size of the month item based on the font sizes and paddings. If the - * current size of the month item is smaller than the required minimum size, this function will - * change the size to the appropriate values. - */ -static void -check_sizes (GnomeMonthItem *mitem) -{ - check_heading_sizes (mitem); - check_day_sizes (mitem); -} - -/* Recalculates the position of the toplevel calendar group based on the logical position and anchor */ -static void -reanchor (GnomeMonthItem *mitem) -{ - double x, y; - - x = mitem->x; - y = mitem->y; - - switch (mitem->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - x -= mitem->width / 2; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - x -= mitem->width; - break; - } - - switch (mitem->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - y -= mitem->height / 2; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - y -= mitem->height; - break; - } - - /* Explicitly use the canvas group class prefix since the month item class has x and y - * arguments as well. - */ - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "GnomeCanvasGroup::x", x, - "GnomeCanvasGroup::y", y, - NULL); -} - -/* Takes an anchor specification and the corners of a rectangle, and returns an anchored point with - * respect to that rectangle. - */ -static void -get_label_anchor (GtkAnchorType anchor, double x1, double y1, double x2, double y2, double *x, double *y) -{ - switch (anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - *x = x1; - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - *x = (x1 + x2) / 2.0; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - *x = x2; - break; - } - - switch (anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - *y = y1; - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - *y = (y1 + y2) / 2.0; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - *y = y2; - break; - } -} - -/* Resets the position of the day name headings in the calendar */ -static void -reshape_headings (GnomeMonthItem *mitem) -{ - double width; - int i; - double x, y; - - width = mitem->width / 7; - - for (i = 0; i < 7; i++) { - /* Group */ - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i], - "x", width * i, - "y", 0.0, - NULL); - - /* Box */ - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i], - "x1", 0.0, - "y1", 0.0, - "x2", width, - "y2", mitem->head_height, - NULL); - - /* Label */ - get_label_anchor (mitem->head_anchor, - mitem->head_padding, - mitem->head_padding, - width - mitem->head_padding, - mitem->head_height - mitem->head_padding, - &x, &y); - - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "x", x, - "y", y, - "anchor", mitem->head_anchor, - NULL); - } -} - -/* Resets the position of the days in the calendar */ -static void -reshape_days (GnomeMonthItem *mitem) -{ - double width, height; - double x, y; - int row, col; - int i; - - width = mitem->width / 7; - height = (mitem->height - mitem->head_height) / 6; - - i = 0; - - for (row = 0; row < 6; row++) - for (col = 0; col < 7; col++) { - /* Group */ - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i], - "x", width * col, - "y", mitem->head_height + height * row, - NULL); - - /* Box */ - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i], - "x1", 0.0, - "y1", 0.0, - "x2", width, - "y2", height, - NULL); - - /* Label */ - get_label_anchor (mitem->day_anchor, - mitem->day_padding, - mitem->day_padding, - width - mitem->day_padding, - height - mitem->day_padding, - &x, &y); - - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "x", x, - "y", y, - "anchor", mitem->day_anchor, - NULL); - - i++; - } -} - -/* Changes the positions and resizes the items in the calendar to match the new size of the - * calendar. - */ -static void -reshape (GnomeMonthItem *mitem) -{ - check_sizes (mitem); - reanchor (mitem); - reshape_headings (mitem); - reshape_days (mitem); -} - -/* Sets the font for all the day headings */ -static void -set_head_font (GnomeMonthItem *mitem) -{ - int i; - - for (i = 0; i < 7; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "font_gdk", mitem->head_font, - NULL); -} - -/* Sets the color for all the headings */ -static void -set_head_color (GnomeMonthItem *mitem) -{ - int i; - GdkColor outline; - GdkColor head; - - outline.pixel = mitem->outline_pixel; - head.pixel = mitem->head_pixel; - - for (i = 0; i < 7; i++) { - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i], - "fill_color_gdk", &outline, - NULL); - - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "fill_color_gdk", &head, - NULL); - } -} - -/* Creates the items for the day name headings */ -static void -create_headings (GnomeMonthItem *mitem) -{ - int i; - - /* Just create the items; they will be positioned and configured by a call to reshape() */ - - for (i = 0; i < 7; i++) { - /* Group */ - mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem), - gnome_canvas_group_get_type (), - NULL); - - /* Box */ - mitem->items[GNOME_MONTH_ITEM_HEAD_BOX + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]), - gnome_canvas_rect_get_type (), - NULL); - - /* Label */ - mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_HEAD_GROUP + i]), - gnome_canvas_text_get_type (), - NULL); - } - - set_head_font (mitem); - set_head_color (mitem); -} - -/* Returns the number of leap years since year 1 up to (but not including) the specified year */ -static int -leap_years_up_to (int year) -{ - return (year / 4 /* trivial leapness */ - - ((year > 1700) ? (year / 100 - 17) : 0) /* minus centuries since 1700 */ - + ((year > 1600) ? ((year - 1600) / 400) : 0)); /* plus centuries since 1700 divisible by 400 */ -} - -/* Returns whether the specified year is a leap year */ -static int -is_leap_year (int year) -{ - if (year <= 1752) - return !(year % 4); - else - return (!(year % 4) && (year % 100)) || !(year % 400); -} - -/* Returns the 1-based day number within the year of the specified date */ -static int -day_in_year (int day, int month, int year) -{ - int is_leap, i; - - is_leap = is_leap_year (year); - - for (i = 0; i < month; i++) - day += days_in_month [is_leap][i]; - - return day; -} - -/* Returns the day of the week (zero-based, zero is Sunday) for the specified date. For the days - * that were removed on the Gregorian reformation, it returns Thursday. - */ -static int -day_in_week (int day, int month, int year) -{ - int n; - - n = (year - 1) * 365 + leap_years_up_to (year - 1) + day_in_year (day, month, year); - - if (n < REFORMATION_DAY) - return (n - 1 + SATURDAY) % 7; - - if (n >= (REFORMATION_DAY + MISSING_DAYS)) - return (n - 1 + SATURDAY - MISSING_DAYS) % 7; - - return THURSDAY; -} - -/* Fills the 42-element days array with the day numbers for the specified month. Slots outside the - * bounds of the month are filled with zeros. The starting and ending indexes of the days are - * returned in the start and end arguments. - */ -static void -build_month (int month, int year, int start_on_monday, int *days, int *start, int *end) -{ - int i; - int d_month, d_week; - - /* Note that months are zero-based, so September is month 8 */ - - if ((year == 1752) && (month == 8)) { - memcpy (days, sept_1752, 42 * sizeof (int)); - - if (start) - *start = SEPT_1752_START; - - if (end) - *end = SEPT_1752_END; - - return; - } - - for (i = 0; i < 42; i++) - days[i] = 0; - - d_month = days_in_month[is_leap_year (year)][month]; - d_week = day_in_week (1, month, year); - - if (start_on_monday) - d_week = (d_week + 6) % 7; - - for (i = 0; i < d_month; i++) - days[d_week + i] = i + 1; - - if (start) - *start = d_week; - - if (end) - *end = d_week + d_month - 1; -} - -/* Set the day numbers in the monthly calendar */ -static void -set_days (GnomeMonthItem *mitem) -{ - int i; - int start, end; - char buf[100]; - - build_month (mitem->month, mitem->year, mitem->start_on_monday, mitem->day_numbers, &start, &end); - - /* Clear days before start of month */ - - for (i = 0; i < start; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "text", NULL, - NULL); - - /* Set days of month */ - - for (; start <= end; start++, i++) { - sprintf (buf, "%d", mitem->day_numbers[start]); - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "text", buf, - NULL); - } - - /* Clear days after end of month */ - - for (; i < 42; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "text", NULL, - NULL); -} - -/* Sets the font for all the day numbers */ -static void -set_day_font (GnomeMonthItem *mitem) -{ - int i; - - for (i = 0; i < 42; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "font_gdk", mitem->day_font, - NULL); -} - -/* Sets the color for all the day items */ -static void -set_day_color (GnomeMonthItem *mitem) -{ - int i; - GdkColor outline; - GdkColor day_box; - GdkColor day; - - outline.pixel = mitem->outline_pixel; - day_box.pixel = mitem->day_box_pixel; - day.pixel = mitem->day_pixel; - - for (i = 0; i < 42; i++) { - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i], - "outline_color_gdk", &outline, - "fill_color_gdk", &day_box, - NULL); - - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i], - "fill_color_gdk", &day, - NULL); - } -} - -/* Creates the items for the days */ -static void -create_days (GnomeMonthItem *mitem) -{ - int i; - - /* Just create the items; they will be positioned and configured by a call to reshape() */ - - for (i = 0; i < 42; i++) { - /* Group */ - mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem), - gnome_canvas_group_get_type (), - NULL); - - /* Box */ - mitem->items[GNOME_MONTH_ITEM_DAY_BOX + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]), - gnome_canvas_rect_get_type (), - NULL); - - /* Label */ - mitem->items[GNOME_MONTH_ITEM_DAY_LABEL + i] = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (mitem->items[GNOME_MONTH_ITEM_DAY_GROUP + i]), - gnome_canvas_text_get_type (), - NULL); - } - - set_day_font (mitem); - set_day_color (mitem); - set_days (mitem); -} - -/* Resets the text of the day name headings */ -static void -set_day_names (GnomeMonthItem *mitem) -{ - int i; - - for (i = 0; i < 7; i++) - gnome_canvas_item_set (mitem->items[GNOME_MONTH_ITEM_HEAD_LABEL + i], - "text", mitem->day_names[mitem->start_on_monday ? ((i + 1) % 7) : i], - NULL); -} - -/* Creates all the canvas items that make up the calendar */ -static void -create_items (GnomeMonthItem *mitem) -{ - mitem->items = g_new (GnomeCanvasItem *, GNOME_MONTH_ITEM_LAST); - - create_headings (mitem); - create_days (mitem); - - /* Initialize by default to three-letter day names */ - - mitem->day_names[0] = g_strdup (_("Sun")); - mitem->day_names[1] = g_strdup (_("Mon")); - mitem->day_names[2] = g_strdup (_("Tue")); - mitem->day_names[3] = g_strdup (_("Wed")); - mitem->day_names[4] = g_strdup (_("Thu")); - mitem->day_names[5] = g_strdup (_("Fri")); - mitem->day_names[6] = g_strdup (_("Sat")); - - set_day_names (mitem); - reshape (mitem); -} - -static void -gnome_month_item_init (GnomeMonthItem *mitem) -{ - time_t t; - struct tm tm; - - /* Initialize to the current month by default */ - - t = time (NULL); - tm = *localtime (&t); - - mitem->year = tm.tm_year + 1900; - mitem->month = tm.tm_mon; - - mitem->x = 0.0; - mitem->y = 0.0; - mitem->width = 150.0; /* not unreasonable defaults, I hope */ - mitem->height = 100.0; - mitem->anchor = GTK_ANCHOR_NW; - mitem->head_padding = 0.0; - mitem->day_padding = 2.0; - mitem->head_height = 14.0; - mitem->head_anchor = GTK_ANCHOR_CENTER; - mitem->day_anchor = GTK_ANCHOR_CENTER; - - /* Load the default fonts */ - - mitem->head_font = gdk_font_load (DEFAULT_FONT); - if (!mitem->head_font) { - mitem->head_font = gdk_font_load ("fixed"); - g_assert (mitem->head_font != NULL); - } - - mitem->day_font = gdk_font_load (DEFAULT_FONT); - if (!mitem->day_font) { - mitem->day_font = gdk_font_load ("fixed"); - g_assert (mitem->day_font != NULL); - } -} - -GnomeCanvasItem * -gnome_month_item_new (GnomeCanvasGroup *parent) -{ - GnomeMonthItem *mitem; - - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (parent), NULL); - - mitem = GNOME_MONTH_ITEM (gnome_canvas_item_new (parent, - gnome_month_item_get_type (), - NULL)); - - gnome_month_item_construct (mitem); - - return GNOME_CANVAS_ITEM (mitem); -} - -void -gnome_month_item_construct (GnomeMonthItem *mitem) -{ - GdkColor color; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - - gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "#d6d6d6d6d6d6", &color); - mitem->head_pixel = color.pixel; - mitem->day_box_pixel = color.pixel; - - gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, "black", &color); - mitem->outline_pixel = color.pixel; - mitem->day_pixel = color.pixel; - - create_items (mitem); -} - -static void -free_day_names (GnomeMonthItem *mitem) -{ - int i; - - if (mitem->day_names[0]) - for (i = 0; i < 7; i++) - g_free (mitem->day_names[i]); -} - -static void -gnome_month_item_destroy (GtkObject *object) -{ - GnomeMonthItem *mitem; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (object)); - - mitem = GNOME_MONTH_ITEM (object); - - free_day_names (mitem); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* Sets the color of the specified pixel value to that of the specified argument, which must be in - * GdkColor format if format is TRUE, otherwise it must be in string format. - */ -static void -set_color_arg (GnomeMonthItem *mitem, gulong *pixel, GtkArg *arg, int gdk_format, int set_head, int set_day) -{ - GdkColor color; - - if (gdk_format) - *pixel = ((GdkColor *) GTK_VALUE_BOXED (*arg))->pixel; - else { - if (gnome_canvas_get_color (GNOME_CANVAS_ITEM (mitem)->canvas, GTK_VALUE_STRING (*arg), &color)) - *pixel = color.pixel; - else - *pixel = 0; - } - - if (set_head) - set_head_color (mitem); - - if (set_day) - set_day_color (mitem); -} - -static void -gnome_month_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GnomeMonthItem *mitem; - char **day_names; - int i; - - mitem = GNOME_MONTH_ITEM (object); - - switch (arg_id) { - case ARG_YEAR: - mitem->year = GTK_VALUE_UINT (*arg); - set_days (mitem); - break; - - case ARG_MONTH: - mitem->month = GTK_VALUE_UINT (*arg); - set_days (mitem); - break; - - case ARG_X: - mitem->x = GTK_VALUE_DOUBLE (*arg); - reanchor (mitem); - break; - - case ARG_Y: - mitem->y = GTK_VALUE_DOUBLE (*arg); - reanchor (mitem); - break; - - case ARG_WIDTH: - mitem->width = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_HEIGHT: - mitem->height = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_ANCHOR: - mitem->anchor = GTK_VALUE_ENUM (*arg); - reanchor (mitem); - break; - - case ARG_HEAD_PADDING: - mitem->head_padding = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_DAY_PADDING: - mitem->day_padding = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_DAY_NAMES: - day_names = GTK_VALUE_POINTER (*arg); - - /* First, check that none of the names is null */ - - for (i = 0; i < 7; i++) - if (!day_names[i]) { - g_warning ("Day number %d was NULL; day names cannot be NULL!", i); - return; - } - - /* Set the new names */ - - free_day_names (mitem); - for (i = 0; i < 7; i++) - mitem->day_names[i] = g_strdup (day_names[i]); - - set_day_names (mitem); - reshape (mitem); - break; - - case ARG_HEADING_HEIGHT: - mitem->head_height = fabs (GTK_VALUE_DOUBLE (*arg)); - reshape (mitem); - break; - - case ARG_HEADING_ANCHOR: - mitem->head_anchor = GTK_VALUE_ENUM (*arg); - reshape (mitem); - break; - - case ARG_DAY_ANCHOR: - mitem->day_anchor = GTK_VALUE_ENUM (*arg); - reshape (mitem); - break; - - case ARG_START_ON_MONDAY: - mitem->start_on_monday = GTK_VALUE_BOOL (*arg); - set_day_names (mitem); - set_days (mitem); - break; - - case ARG_HEAD_FONT: - gdk_font_unref (mitem->head_font); - - mitem->head_font = gdk_font_load (GTK_VALUE_STRING (*arg)); - if (!mitem->head_font) { - mitem->head_font = gdk_font_load ("fixed"); - g_assert (mitem->head_font != NULL); - } - - set_head_font (mitem); - reshape (mitem); - break; - - case ARG_HEAD_FONTSET: - gdk_font_unref (mitem->head_font); - - mitem->head_font = gdk_fontset_load (GTK_VALUE_STRING (*arg)); - if (!mitem->head_font) { - mitem->head_font = - gdk_fontset_load ("-*-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-*"); - g_assert (mitem->head_font != NULL); - } - - set_head_font (mitem); - reshape (mitem); - break; - - case ARG_HEAD_FONT_GDK: - gdk_font_unref (mitem->head_font); - - mitem->head_font = GTK_VALUE_BOXED (*arg); - gdk_font_ref (mitem->head_font); - set_head_font (mitem); - reshape (mitem); - break; - - case ARG_DAY_FONT: - gdk_font_unref (mitem->day_font); - - mitem->day_font = gdk_font_load (GTK_VALUE_STRING (*arg)); - if (!mitem->day_font) { - mitem->day_font = gdk_font_load ("fixed"); - g_assert (mitem->day_font != NULL); - } - - set_day_font (mitem); - reshape (mitem); - break; - - case ARG_DAY_FONTSET: - gdk_font_unref (mitem->day_font); - - mitem->day_font = gdk_fontset_load (GTK_VALUE_STRING (*arg)); - if (!mitem->day_font) { - mitem->day_font = - gdk_fontset_load ("-*-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-*"); - g_assert (mitem->day_font != NULL); - } - - set_day_font (mitem); - reshape (mitem); - break; - - case ARG_DAY_FONT_GDK: - gdk_font_unref (mitem->day_font); - - mitem->day_font = GTK_VALUE_BOXED (*arg); - gdk_font_ref (mitem->day_font); - set_day_font (mitem); - reshape (mitem); - break; - - case ARG_HEAD_COLOR: - set_color_arg (mitem, &mitem->head_pixel, arg, FALSE, TRUE, FALSE); - break; - - case ARG_HEAD_COLOR_GDK: - set_color_arg (mitem, &mitem->head_pixel, arg, TRUE, TRUE, FALSE); - break; - - case ARG_OUTLINE_COLOR: - set_color_arg (mitem, &mitem->outline_pixel, arg, FALSE, TRUE, TRUE); - break; - - case ARG_OUTLINE_COLOR_GDK: - set_color_arg (mitem, &mitem->outline_pixel, arg, TRUE, TRUE, TRUE); - break; - - case ARG_DAY_BOX_COLOR: - set_color_arg (mitem, &mitem->day_box_pixel, arg, FALSE, FALSE, TRUE); - break; - - case ARG_DAY_BOX_COLOR_GDK: - set_color_arg (mitem, &mitem->day_box_pixel, arg, TRUE, FALSE, TRUE); - break; - - case ARG_DAY_COLOR: - set_color_arg (mitem, &mitem->day_pixel, arg, FALSE, FALSE, TRUE); - break; - - case ARG_DAY_COLOR_GDK: - set_color_arg (mitem, &mitem->day_pixel, arg, TRUE, FALSE, TRUE); - break; - - default: - break; - } -} - -/* Allocates a GdkColor structure filled with the specified pixel, and puts it into the specified - * arg for returning it in the get_arg method. - */ -static void -get_color_arg (GnomeMonthItem *mitem, gulong pixel, GtkArg *arg) -{ - GdkColor *color; - - color = g_new (GdkColor, 1); - color->pixel = pixel; - gdk_color_context_query_color (GNOME_CANVAS_ITEM (mitem)->canvas->cc, color); - GTK_VALUE_BOXED (*arg) = color; -} - -static void -gnome_month_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GnomeMonthItem *mitem; - - mitem = GNOME_MONTH_ITEM (object); - - switch (arg_id) { - case ARG_YEAR: - GTK_VALUE_UINT (*arg) = mitem->year; - break; - - case ARG_MONTH: - GTK_VALUE_UINT (*arg) = mitem->month; - break; - - case ARG_X: - GTK_VALUE_DOUBLE (*arg) = mitem->x; - break; - - case ARG_Y: - GTK_VALUE_DOUBLE (*arg) = mitem->y; - break; - - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = mitem->width; - break; - - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = mitem->height; - break; - - case ARG_ANCHOR: - GTK_VALUE_ENUM (*arg) = mitem->anchor; - break; - - case ARG_HEAD_PADDING: - GTK_VALUE_DOUBLE (*arg) = mitem->head_padding; - break; - - case ARG_DAY_PADDING: - GTK_VALUE_DOUBLE (*arg) = mitem->day_padding; - break; - - case ARG_HEADING_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = mitem->head_height; - break; - - case ARG_HEADING_ANCHOR: - GTK_VALUE_ENUM (*arg) = mitem->head_anchor; - break; - - case ARG_DAY_ANCHOR: - GTK_VALUE_ENUM (*arg) = mitem->day_anchor; - break; - - case ARG_START_ON_MONDAY: - GTK_VALUE_BOOL (*arg) = mitem->start_on_monday; - break; - - case ARG_HEAD_FONT_GDK: - GTK_VALUE_BOXED (*arg) = mitem->head_font; - break; - - case ARG_DAY_FONT_GDK: - GTK_VALUE_BOXED (*arg) = mitem->day_font; - break; - - case ARG_HEAD_COLOR_GDK: - get_color_arg (mitem, mitem->head_pixel, arg); - break; - - case ARG_OUTLINE_COLOR_GDK: - get_color_arg (mitem, mitem->outline_pixel, arg); - break; - - case ARG_DAY_BOX_COLOR_GDK: - get_color_arg (mitem, mitem->day_box_pixel, arg); - break; - - case ARG_DAY_COLOR_GDK: - get_color_arg (mitem, mitem->day_pixel, arg); - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -GnomeCanvasItem * -gnome_month_item_num2child (GnomeMonthItem *mitem, int child_num) -{ - g_return_val_if_fail (mitem != NULL, NULL); - g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), NULL); - - return mitem->items[child_num]; -} - -int -gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child) -{ - int i; - - g_return_val_if_fail (mitem != NULL, -1); - g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1); - g_return_val_if_fail (child != NULL, -1); - g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (child), -1); - - for (i = 0; i < GNOME_MONTH_ITEM_LAST; i++) - if (mitem->items[i] == child) - return i; - - return -1; -} - -int -gnome_month_item_num2day (GnomeMonthItem *mitem, int child_num) -{ - g_return_val_if_fail (mitem != NULL, 0); - g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), 0); - - if ((child_num >= GNOME_MONTH_ITEM_DAY_GROUP) && (child_num < GNOME_MONTH_ITEM_LAST)) { - child_num = (child_num - GNOME_MONTH_ITEM_DAY_GROUP) % 42; - return mitem->day_numbers[child_num]; - } else - return 0; -} - -int -gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num) -{ - int i; - - g_return_val_if_fail (mitem != NULL, -1); - g_return_val_if_fail (GNOME_IS_MONTH_ITEM (mitem), -1); - g_return_val_if_fail (day_num >= 1, -1); - - /* Find first day of month */ - - for (i = 0; mitem->day_numbers[i] == 0; i++) - ; - - /* Find the specified day */ - - for (; (mitem->day_numbers[i] != 0) && (i < 42); i++) - if (mitem->day_numbers[i] == day_num) - return i; - - /* Bail out */ - - return -1; -} diff --git a/calendar/gui/gnome-month-item.h b/calendar/gui/gnome-month-item.h deleted file mode 100644 index 0ec4fd484c..0000000000 --- a/calendar/gui/gnome-month-item.h +++ /dev/null @@ -1,165 +0,0 @@ -/* General-purpose monthly calendar canvas item for GNOME - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena <federico@nuclecu.unam.mx> - */ - -#ifndef GNOME_MONTH_ITEM_H -#define GNOME_MONTH_ITEM_H - -#include <libgnome/gnome-defs.h> -#include <gtk/gtkpacker.h> /* why the hell is GtkAnchorType here and not in gtkenums.h? */ -#include <libgnomeui/gnome-canvas.h> - - -BEGIN_GNOME_DECLS - - -/* These values are used to identify the canvas items that make up a complete GnomeMonthItem, which - * is made up of the following "pieces": - * - * Headings line: - * - 7 GnomeCanvasGroups: - * Each group contains one box (GnomeCanvasRectangle) and one label - * (GnomeCanvasText) - * - * Day slots: - * - 42 GnomeCanvasGroups: - * Each group contains one box (GnomeCanvasRectangle) and one label - * (GnomeCanvasText) - * - * The headings are organized from left to right. The day slots are organized as a table in - * row-major order. - * - * If you want to access the individual items of the GnomeMonthItem, you can use these numbers with - * the gnome_month_item_num2child() function. If you want to convert a number into the - * corresponding GnomeCanvasItem, you can use the gnome_month_item_child2num() function. - */ -typedef enum { - GNOME_MONTH_ITEM_HEAD_GROUP = 0, /* 7 groups for headings */ - GNOME_MONTH_ITEM_HEAD_BOX = 7, /* 7 boxes for headings */ - GNOME_MONTH_ITEM_HEAD_LABEL = 14, /* 7 labels for headings */ - GNOME_MONTH_ITEM_DAY_GROUP = 21, /* 42 groups for days */ - GNOME_MONTH_ITEM_DAY_BOX = 63, /* 42 boxes for days */ - GNOME_MONTH_ITEM_DAY_LABEL = 105, /* 42 labels for days */ - GNOME_MONTH_ITEM_LAST = 147 /* total number of items */ -} GnomeMonthItemChild; - -/* The MonthItem canvas item defines a simple monthly calendar. It is made out of a number of - * canvas items, which can be accessed using the functions provided. The monthly calendar is - * anchored with respect to a point. The following arguments are available: - * - * name type read/write description - * ------------------------------------------------------------------------------------------ - * year uint RW Full year (1-9999) - * month uint RW Number of month (0-11) - * x double RW X position of anchor point - * y double RW Y position of anchor point - * width double RW Width of calendar in canvas units - * height double RW Height of calendar in canvas units - * anchor GtkAnchorType RW Anchor side for calendar - * heading_padding double RW Padding inside heading boxes - * day_padding double RW Padding inside day boxes - * day_names char ** W Array of strings corresponding to the day names (sun-sat) - * heading_height double RW Height of headings bar in canvas units - * heading_anchor GtkAnchorType RW Anchor side for headings inside heading boxes - * day_anchor GtkAnchorType RW Anchor side for day numbers inside day boxes - * start_on_monday boolean RW Specifies whether the week starts on Monday or Sunday - * heading_font string W X logical font descriptor for the headings - * heading_fontset string W X logical fontset descriptor for the headings - * heading_font_gdk GdkFont * RW Pointer to GdkFont for the headings - * day_font string W X logical font descriptor for the day numbers - * day_fontset string W X logical fontset descriptor for the day numbers - * day_font_gdk GdkFont * RW Pointer to GdkFont for the day numbers - * heading_color string W X color specification for heading labels - * heading_color_gdk GdkColor * RW Pointer to an allocated GdkColor for heading labels - * outline_color string W X color specification for outline (lines and fill of heading boxes) - * outline_color_gdk GdkColor * RW Pointer to an allocated GdkColor for outline - * day_box_color string W X color specification for day boxes - * day_box_color_gdk GdkColor * RW Pointer to an allocated GdkColor for day boxes - * day_color string W X color specification for day number labels - * day_color_gdk GdkColor * RW Pointer to an allocated GdkColor for day number labels - */ - -#define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ()) -#define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem)) -#define GNOME_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_MONTH_ITEM, GnomeMonthItemClass)) -#define GNOME_IS_MONTH_ITEM(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_MONTH_ITEM)) -#define GNOME_IS_MONTH_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_MONTH_ITEM)) - - -typedef struct _GnomeMonthItem GnomeMonthItem; -typedef struct _GnomeMonthItemClass GnomeMonthItemClass; - -struct _GnomeMonthItem { - GnomeCanvasGroup group; - - int year; /* Year to show (full, no two-digit crap) */ - int month; /* Month to show (0-11) */ - - double x, y; /* Position at anchor */ - double width, height; /* Size of calendar */ - GtkAnchorType anchor; /* Anchor side for calendar */ - - double head_padding; /* Padding to use between heading lines and text */ - double day_padding; /* Padding to use between day number lines and text */ - - char *day_names[7]; /* Names to use for the day labels, starting from Sunday */ - - double head_height; /* Height of the headings row */ - GtkAnchorType head_anchor; /* Anchor side for the heading labels */ - GtkAnchorType day_anchor; /* Anchor side for the day number labels */ - - GnomeCanvasItem **items; /* All the items that make up the calendar */ - int day_numbers[42]; /* The numbers of the days, as they are shown in the display */ - - GdkFont *head_font; /* Font for the headings */ - GdkFont *day_font; /* Font for the day numbers */ - - gulong head_pixel; /* Color for heading labels */ - gulong outline_pixel; /* Color for the outline (lines and heading boxes) */ - gulong day_box_pixel; /* Color for the day boxes */ - gulong day_pixel; /* Color for day number labels */ - - int start_on_monday : 1; /* Start the week on Monday? If false, then start from Sunday */ -}; - -struct _GnomeMonthItemClass { - GnomeCanvasGroupClass parent_class; -}; - - -/* Standard Gtk function */ -GtkType gnome_month_item_get_type (void); - -/* Creates a new month item with the specified group as parent */ -GnomeCanvasItem *gnome_month_item_new (GnomeCanvasGroup *parent); - -/* Constructor function useful for derived classes */ -void gnome_month_item_construct (GnomeMonthItem *mitem); - -/* Returns the child item defined by the child number (as specified on the GnomeMonthItemChild - * enumeration above). - */ -GnomeCanvasItem *gnome_month_item_num2child (GnomeMonthItem *mitem, int child_num); - -/* Returns the number of the specified child item, as defined on the GnomeMonthItemChild enumeration - * above. If the specified object is not found, it returns -1. - */ -int gnome_month_item_child2num (GnomeMonthItem *mitem, GnomeCanvasItem *child); - -/* Returns the number of the day relevant to the specified child item. Day numbers are 1-based. If - * the specified child is outside the range of displayed days, then it returns 0. - */ -int gnome_month_item_num2day (GnomeMonthItem *mitem, int child_num); - -/* Returns the index (0-41) of the specified date within the table of days. If the day number is - * invalid for the current monthly calendar, then -1 is returned. - */ -int gnome_month_item_day2index (GnomeMonthItem *mitem, int day_num); - - -END_GNOME_DECLS - -#endif diff --git a/calendar/gui/gnomecal.gnorba b/calendar/gui/gnomecal.gnorba deleted file mode 100644 index 74df8ecf04..0000000000 --- a/calendar/gui/gnomecal.gnorba +++ /dev/null @@ -1,11 +0,0 @@ -[IDL:GNOME:Calendar:Repository:1.0] -type=factory -repo_id=IDL:Gnome/Calendar/Repository:1.0 -description=Calendar Repository -location_info=IDL:GNOME:Calendar:RepositoryLocator:1.0 - -[IDL:GNOME:Calendar:RepositoryLocator:1.0] -type=exe -repo_id=IDL:GNOME/GenericFactory:1.0 -description=Calendar Server -location_info=gnomecal diff --git a/calendar/gui/gnomecal.oafinfo b/calendar/gui/gnomecal.oafinfo deleted file mode 100644 index c4b91b9dd8..0000000000 --- a/calendar/gui/gnomecal.oafinfo +++ /dev/null @@ -1,27 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:IDL:GNOME:Calendar:Repository:1.0:56989bb6-65a1-430c-86a8-81bbe64bf7ab" - type="factory" - location="OAFIID:IDL:GNOME:Calendar:RepositoryLocator:1.0:83b25bb0-b68b-4c6b-86e7-c303e9897c21"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Gnome/Calendar/Repository:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Calendar Repository"/> -</oaf_server> - -<oaf_server iid="OAFIID:IDL:GNOME:Calendar:RepositoryLocator:1.0:83b25bb0-b68b-4c6b-86e7-c303e9897c21" - type="exe" - location="gnomecal"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/GenericFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" - value="Calendar Server"/> -</oaf_server> - -</oaf_info> diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c deleted file mode 100644 index d6c69016a1..0000000000 --- a/calendar/gui/goto.c +++ /dev/null @@ -1,326 +0,0 @@ -/* Go to date dialog for gnomecal - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena <federico@nuclecu.unam.mx> - */ - -#include <config.h> -#include <gnome.h> -#include <cal-util/timeutil.h> -#include "gnome-cal.h" -#include "gnome-month-item.h" -#include "calendar-commands.h" -#include "mark.h" - - -static GtkWidget *goto_win; /* The goto dialog window */ -static GnomeMonthItem *month_item; /* The month item in the dialog */ -static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */ -static int current_index; /* The index of the day marked as current, or -1 if none */ - - -/* Updates the specified month item by marking it appropriately from the calendar the dialog refers - * to. Also marks the current day if appropriate. - */ -static void -update (void) -{ - GnomeCanvasItem *item; - time_t t; - struct tm tm; - - unmark_month_item (month_item); - mark_month_item (month_item, gnome_calendar); - - if (current_index != -1) { - item = gnome_month_item_num2child (month_item, - GNOME_MONTH_ITEM_DAY_LABEL + current_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG), - "fontset", NORMAL_DAY_FONTSET, - NULL); - current_index = -1; - } - - t = time (NULL); - tm = *localtime (&t); - - if (((tm.tm_year + 1900) == month_item->year) && (tm.tm_mon == month_item->month)) { - current_index = gnome_month_item_day2index (month_item, tm.tm_mday); - g_assert (current_index != -1); - - item = gnome_month_item_num2child (month_item, - GNOME_MONTH_ITEM_DAY_LABEL + current_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG), - "fontset", CURRENT_DAY_FONTSET, - NULL); - } -} - -/* Callback used when the year adjustment is changed */ -static void -year_changed (GtkAdjustment *adj, gpointer data) -{ - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "year", (int) adj->value, - NULL); - update (); -} - -/* Creates the year control with its adjustment */ -static GtkWidget * -create_year (int year) -{ - GtkWidget *hbox; - GtkAdjustment *adj; - GtkWidget *w; - - hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - - w = gtk_label_new (_("Year:")); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - adj = GTK_ADJUSTMENT (gtk_adjustment_new (year, 1900, 9999, 1, 10, 10)); - gtk_signal_connect (GTK_OBJECT (adj), "value_changed", - (GtkSignalFunc) year_changed, - NULL); - - w = gtk_spin_button_new (adj, 1.0, 0); - gtk_widget_set_usize (w, 60, 0); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - return hbox; -} - -/* Callback used when a month button is toggled */ -static void -month_toggled (GtkToggleButton *toggle, gpointer data) -{ - if (!toggle->active) - return; - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "month", GPOINTER_TO_INT (data), - NULL); - update (); -} - -/* Creates the months control */ -static GtkWidget * -create_months (int month) -{ - GtkWidget *table; - GtkWidget *w; - GSList *group; - int i, row, col; - struct tm tm; - char buf[100]; - - tm = *localtime (&gnome_calendar->selection_start_time); - - table = gtk_table_new (2, 6, TRUE); - - group = NULL; - - for (i = 0; i < 12; i++) { - row = i / 6; - col = i % 6; - - tm.tm_mon = i; - strftime (buf, 100, "%b", &tm); - - w = gtk_radio_button_new (group); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (w)); - gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (w), FALSE); - - gtk_container_add (GTK_CONTAINER (w), gtk_label_new (buf)); - - if (i == month) - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (w), TRUE); - - gtk_signal_connect (GTK_OBJECT (w), "toggled", - (GtkSignalFunc) month_toggled, - GINT_TO_POINTER (i)); - gtk_table_attach (GTK_TABLE (table), w, - col, col + 1, - row, row + 1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - gtk_widget_show_all (w); - } - - return table; -} - -/* Sets the scrolling region of the canvas to the allocation size */ -static void -set_scroll_region (GtkWidget *widget, GtkAllocation *allocation) -{ - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "width", (double) (allocation->width - 1), - "height", (double) (allocation->height - 1), - NULL); - - gnome_canvas_set_scroll_region (GNOME_CANVAS (widget), - 0, 0, - allocation->width, allocation->height); -} - -/* Event handler for day groups in the month item. A button press makes the calendar jump to the - * selected day and destroys the Go-to dialog box. - */ -static gint -day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) -{ - int child_num, day; - - child_num = gnome_month_item_child2num (month_item, item); - day = gnome_month_item_num2day (month_item, child_num); - - switch (event->type) { - case GDK_BUTTON_PRESS: - if ((event->button.button == 1) && (day != 0)) { - gnome_calendar_goto (gnome_calendar, - time_from_day (month_item->year, month_item->month, day)); - gtk_widget_destroy (goto_win); - } - break; - - default: - break; - } - - return FALSE; -} - -/* Creates the canvas with the month item for selecting days */ -static GtkWidget * -create_days (int day, int month, int year) -{ - GtkWidget *canvas; - int i; - GnomeCanvasItem *day_group; - - canvas = gnome_canvas_new (); - gtk_widget_set_usize (canvas, 150, 120); - - month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)))); - gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item), - "month", month, - "year", year, - "start_on_monday", week_starts_on_monday, - NULL); - colorify_month_item (month_item, default_color_func, NULL); - month_item_prepare_prelight (month_item, default_color_func, NULL); - update (); - - /* Connect to size_allocate so that we can change the size of the month item and the - * scrolling region appropriately. - */ - - gtk_signal_connect (GTK_OBJECT (canvas), "size_allocate", - (GtkSignalFunc) set_scroll_region, - NULL); - - /* Bind the day groups to our event handler */ - - for (i = 0; i < 42; i++) { - day_group = gnome_month_item_num2child (month_item, i + GNOME_MONTH_ITEM_DAY_GROUP); - gtk_signal_connect (GTK_OBJECT (day_group), "event", - (GtkSignalFunc) day_event, - NULL); - } - - return canvas; -} - -static void -goto_today (GtkWidget *widget, gpointer data) -{ - gnome_calendar_goto_today (gnome_calendar); - gtk_widget_destroy (goto_win); -} - -/* Creates a "goto date" dialog and runs it */ -void -goto_dialog (GnomeCalendar *gcal) -{ - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *w; - GtkWidget *days; - struct tm tm; - - gnome_calendar = gcal; - current_index = -1; - - tm = *localtime (&gnome_calendar->selection_start_time); - - goto_win = gnome_dialog_new (_("Go to date"), - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gnome_dialog_set_parent (GNOME_DIALOG (goto_win), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); - - - vbox = GNOME_DIALOG (goto_win)->vbox; - - /* Instructions */ - - w = gtk_label_new (_("Please select the date you want to go to.\n" - "When you click on a day, you will be taken\n" - "to that date.")); - gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Create month item before creating the year controls, since the - * latter ones need the month_item to be created. - */ - - days = create_days (tm.tm_mday, tm.tm_mon, tm.tm_year + 1900); - - /* Year */ - - w = create_year (tm.tm_year + 1900); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Month */ - - w = create_months (tm.tm_mon); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Days (canvas with month item) */ - - gtk_box_pack_start (GTK_BOX (vbox), days, TRUE, TRUE, 0); - gtk_widget_show (days); - - /* Today button */ - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - w = gtk_button_new_with_label (_("Go to today")); - gtk_signal_connect (GTK_OBJECT (w), "clicked", - (GtkSignalFunc) goto_today, - NULL); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_widget_show (w); - - /* Run! */ - - gtk_window_set_modal (GTK_WINDOW (goto_win), TRUE); - gnome_dialog_set_close (GNOME_DIALOG (goto_win), TRUE); - gnome_dialog_set_parent (GNOME_DIALOG (goto_win), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gnome_calendar)))); - gtk_widget_show (goto_win); -} diff --git a/calendar/gui/jump.xpm b/calendar/gui/jump.xpm deleted file mode 100644 index d974142d9a..0000000000 --- a/calendar/gui/jump.xpm +++ /dev/null @@ -1,14 +0,0 @@ -/* XPM */ -static char * jump_xpm[] = { -"16 8 3 1", -" c None", -". c #000000", -"+ c #FFFF00", -"................", -".++++++++++++++.", -".++++++++++++++.", -".++..++..++..++.", -".++..++..++..++.", -".++++++++++++++.", -".++++++++++++++.", -"................"}; diff --git a/calendar/gui/main.c b/calendar/gui/main.c deleted file mode 100644 index 6876fbd6b5..0000000000 --- a/calendar/gui/main.c +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* control-factory.c - * - * Copyright (C) 2000 Helix Code, 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. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gnome.h> -#include <glade/glade.h> -#include <bonobo.h> -#include <bonobo/bonobo-control.h> -#include <glade/glade.h> - -#ifdef USING_OAF -#include <liboaf/liboaf.h> -#else -#include <libgnorba/gnorba.h> -#endif - -#include <cal-util/timeutil.h> -#include <gui/alarm.h> -#include <gui/gnome-cal.h> -#include <gui/calendar-commands.h> -#include "component-factory.h" -#include "control-factory.h" - - -static void -init_bonobo (int *argc, char **argv) -{ -#ifdef USING_OAF - /* FIXME: VERSION instead of "0.0". */ - gnome_init_with_popt_table ("evolution-calendar", "0.0", - *argc, argv, oaf_popt_options, - 0, NULL); - oaf_init (*argc, argv); -#else - CORBA_Environment ev; - - CORBA_exception_init (&ev); - gnome_CORBA_init_with_popt_table ( - "evolution-calendar", "0.0", - argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - CORBA_exception_free (&ev); -#endif - - if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); -} - - -int -main (int argc, char **argv) -{ - init_bonobo (&argc, argv); - glade_gnome_init (); - alarm_init (); - e_cursors_init (); - - init_calendar (); - -#if 0 - //g_log_set_always_fatal ((GLogLevelFlags) 0xFFFF); - g_log_set_always_fatal (G_LOG_LEVEL_ERROR | - G_LOG_LEVEL_CRITICAL | - G_LOG_LEVEL_WARNING); -#endif - - control_factory_init (); - component_factory_init (); - - bonobo_main (); - fprintf (stderr, "main(): Out of bonobo_main(), we are dying cleanly. Have a nice day.\n"); - - return 0; -} diff --git a/calendar/gui/mark.c b/calendar/gui/mark.c deleted file mode 100644 index 383eca5196..0000000000 --- a/calendar/gui/mark.c +++ /dev/null @@ -1,297 +0,0 @@ -/* Evolution calendar - Functions to mark calendars - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <cal-util/timeutil.h> -#include "gnome-cal.h" -#include "calendar-commands.h" -#include "mark.h" - -/* Closure data */ -struct minfo -{ - GnomeMonthItem *mitem; - time_t start; - time_t end; -}; - - - -/* Frees the specified data when an object is destroyed */ -static void -free_data (GtkObject *object, gpointer data) -{ - g_free (data); -} - -/* If the array of "marked" attributes for the days in a a month item has not been created yet, this - * function creates the array and clears it. Otherwise, it just returns the existing array. - */ -static char * -get_attributes (GnomeMonthItem *mitem) -{ - char *attrs; - - attrs = gtk_object_get_data (GTK_OBJECT (mitem), "day_mark_attributes"); - - if (!attrs) { - attrs = g_new0 (char, 42); - gtk_object_set_data (GTK_OBJECT (mitem), "day_mark_attributes", attrs); - gtk_signal_connect (GTK_OBJECT (mitem), "destroy", - (GtkSignalFunc) free_data, - attrs); - } - - return attrs; -} - -void -colorify_month_item (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data) -{ - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - g_return_if_fail (func != NULL); - - unmark_month_item (mitem); - - /* We have to do this in several calls to gnome_canvas_item_set(), as color_spec_from_prop() - * returns a pointer to a static string -- and we need several values. - */ - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "heading_color", (* func) (COLOR_PROP_HEADING_COLOR, func_data), - NULL); - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "outline_color", (* func) (COLOR_PROP_OUTLINE_COLOR, func_data), - NULL); - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "day_box_color", (* func) (COLOR_PROP_EMPTY_DAY_BG, func_data), - NULL); - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem), - "day_color", (* func) (COLOR_PROP_DAY_FG, func_data), - NULL); -} - -/* In the month item, marks all the days that are touched by the specified time span. Assumes that - * the time span is completely contained within the month. The array of day attributes is modified - * accordingly. - */ -static void -mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end) -{ - struct tm tm; - int day_index; - - tm = *localtime (&start); - - for (; start <= end; start += 60 * 60 * 24) { - mktime (&tm); /* normalize the time */ - - /* Figure out the day index that corresponds to this time */ - - day_index = gnome_month_item_day2index (mitem, tm.tm_mday); - g_assert (day_index >= 0); - - /* Mark the day box */ - - mark_month_item_index (mitem, day_index, default_color_func, NULL); - - /* Next day */ - - tm.tm_mday++; - } -} - -static gboolean -mark_month_item_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - struct minfo *mi = (struct minfo *)data; - - mark_event_in_month (mi->mitem, MAX (istart, mi->start), MIN (iend, mi->end)); - - return TRUE; -} - -void -mark_month_item (GnomeMonthItem *mitem, GnomeCalendar *gcal) -{ - struct minfo mi; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - mi.mitem = mitem; - mi.start = time_month_begin (time_from_day (mitem->year, mitem->month, 1)); - mi.end = time_month_end (mi.start); - - cal_client_generate_instances (gcal->client, CALOBJ_TYPE_EVENT, mi.start, mi.end, - mark_month_item_cb, &mi); -} - - -void -mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data) -{ - char *attrs; - GnomeCanvasItem *item; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - g_return_if_fail ((index >= 0) && (index < 42)); - g_return_if_fail (func != NULL); - - attrs = get_attributes (mitem); - - attrs[index] = TRUE; - - item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + index); - gnome_canvas_item_set (item, - "fill_color", (* func) (COLOR_PROP_MARK_DAY_BG, func_data), - NULL); -} - -void -unmark_month_item (GnomeMonthItem *mitem) -{ - int i; - char *attrs; - GnomeCanvasItem *item; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - - attrs = get_attributes (mitem); - - /* Find marked days and unmark them by turning off their marked attribute flag and changing - * the color. - */ - - for (i = 0; i < 42; i++) - if (attrs[i]) { - attrs[i] = FALSE; - - item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + i); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_EMPTY_DAY_BG), - NULL); - } -} - -/* Handles EnterNotify and LeaveNotify events from the month item's day groups, and performs - * appropriate prelighting. - */ -static gint -day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) -{ - GnomeMonthItem *mitem; - GnomeCanvasItem *box; - int child_num, day; - GetColorFunc func; - gpointer func_data; - char *color; - char *attrs; - - /* We only accept enters and leaves */ - - if (!((event->type == GDK_ENTER_NOTIFY) || (event->type == GDK_LEAVE_NOTIFY))) - return FALSE; - - /* Get index information */ - - mitem = GNOME_MONTH_ITEM (data); - child_num = gnome_month_item_child2num (mitem, item); - day = gnome_month_item_num2day (mitem, child_num); - - if (day == 0) - return FALSE; /* it was a day outside the month's range */ - - child_num -= GNOME_MONTH_ITEM_DAY_GROUP; - box = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + child_num); - - /* Get colors */ - - func = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_func"); - func_data = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_data"); - - /* Now actually set the proper color in the item */ - - switch (event->type) { - case GDK_ENTER_NOTIFY: - color = (* func) (COLOR_PROP_PRELIGHT_DAY_BG, func_data); - gnome_canvas_item_set (box, - "fill_color", color, - NULL); - break; - - case GDK_LEAVE_NOTIFY: - attrs = get_attributes (mitem); - color = (* func) (attrs[child_num] ? COLOR_PROP_MARK_DAY_BG : COLOR_PROP_EMPTY_DAY_BG, - func_data); - gnome_canvas_item_set (box, - "fill_color", color, - NULL); - break; - - default: - g_assert_not_reached (); - } - - return TRUE; -} - -void -month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data) -{ - GnomeCanvasItem *day_group; - int i; - - g_return_if_fail (mitem != NULL); - g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem)); - g_return_if_fail (func != NULL); - - /* Store the function in the object data */ - - gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_func", func); - gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_data", func_data); - - /* Connect the appropriate signals to perform prelighting */ - - for (i = 0; i < 42; i++) { - day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), GNOME_MONTH_ITEM_DAY_GROUP + i); - gtk_signal_connect (GTK_OBJECT (day_group), "event", - (GtkSignalFunc) day_event, - mitem); - } -} - -char * -default_color_func (ColorProp propnum, gpointer data) -{ - return color_spec_from_prop (propnum); -} - - - diff --git a/calendar/gui/mark.h b/calendar/gui/mark.h deleted file mode 100644 index 76c82c580d..0000000000 --- a/calendar/gui/mark.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Evolution calendar - Functions to mark calendars - * - * Copyright (C) 1998 Red Hat Software, Inc. - * - * Author: Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef MARK_H -#define MARK_H - -/*#include "calendar.h"*/ -#include "gnome-month-item.h" - - - -/* These are the fonts used for the montly calendars */ - -#define HEADING_FONTSET "-adobe-helvetica-medium-r-*-*-14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-*-*-14-*-*-*-*-*-ksc5601.1987-0,*" -#define TITLE_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*" -#define DAY_HEADING_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*" -#define NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*" -#define CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*" -#define BIG_DAY_HEADING_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*" -#define BIG_NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*" -#define BIG_CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*" -#define EVENT_FONTSET "-adobe-helvetica-medium-r-*-*-10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*" - - -/* Functions of this type are used by the marking functions to fetch color specifications. Such - * a function must return a color spec based on the property passed to it. - */ -typedef char * (* GetColorFunc) (ColorProp propnum, gpointer data); - - -/* Sets the user-configured colors and font for a month item. It also tags the days as unmarked. */ -void colorify_month_item (GnomeMonthItem *month, GetColorFunc func, gpointer func_data); - -/* Takes a monthly calendar item and marks the days that have events - * scheduled for them in the specified calendar. It also highlights - * the current day. - */ -void mark_month_item (GnomeMonthItem *mitem, GnomeCalendar *cal); - -/* Marks a day specified by index, not by day number */ -void mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data); - -/* Unmarks all the days in the specified month item */ -void unmark_month_item (GnomeMonthItem *mitem); - -/* Prepares a monthly calendar item to prelight when the mouse goes over the days. */ - -void month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data); - -/* This is the default prelight function you can use for most puposes. You can use NULL as the - * func_data. - */ -char *default_color_func (ColorProp prop_num, gpointer data); - - - -#endif diff --git a/calendar/gui/monthview.xpm b/calendar/gui/monthview.xpm deleted file mode 100644 index 1a1b1d936a..0000000000 --- a/calendar/gui/monthview.xpm +++ /dev/null @@ -1,46 +0,0 @@ -/* XPM */ -static char * monthview_xpm[] = { -"24 24 19 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #BABBCC", -"$ c #AAAFE2", -"% c #8B90C3", -"& c #E3E4F5", -"* c #A3A6C7", -"= c #5D66BA", -"- c #3945BB", -"; c #555FC5", -"> c #2E3BB1", -", c #727ACE", -"' c #C7CAEB", -") c #0010A8", -"! c #4550B5", -"~ c #1725AC", -"{ c #8E95D8", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++@++#$$%&+@+$*++@++. ", -" .++@+&=-;>,+@')!++@++. ", -" .@@@@%)%@%)@*~)!@@@@@. ", -" .++@++@'$=-+@+)!++@++. ", -" .++@++@{;>,+@+)!++@++. ", -" .@@@@@@@@%)@@@)!@@@@@. ", -" .++@+$)$+%)+@+)!++@++. ", -" .++@+'>,$=-+#$)>$+@++. ", -" .@@@@@#%%%#@#%%%%@@@@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; diff --git a/calendar/gui/popup-menu.c b/calendar/gui/popup-menu.c deleted file mode 100644 index a90c38d490..0000000000 --- a/calendar/gui/popup-menu.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Popup menu utilities for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#include <config.h> -#include <gnome.h> -#include "popup-menu.h" -#include "../../e-util/e-gui-utils.h" - - -void -popup_menu (struct menu_item *items, int nitems, GdkEventButton *event) -{ - GtkWidget *menu; - GtkWidget *item; - int i; - - menu = gtk_menu_new (); - - /* Make sure the menu is destroyed when it disappears. */ - e_auto_kill_popup_menu_on_hide (GTK_MENU (menu)); - - for (i = 0; i < nitems; i++) { - if (items[i].text) { - item = gtk_menu_item_new_with_label (_(items[i].text)); - gtk_signal_connect (GTK_OBJECT (item), "activate", - items[i].callback, - items[i].data); - gtk_widget_set_sensitive (item, items[i].sensitive); - } else - item = gtk_menu_item_new (); - - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - } - - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time); -} diff --git a/calendar/gui/popup-menu.h b/calendar/gui/popup-menu.h deleted file mode 100644 index a4590dbb98..0000000000 --- a/calendar/gui/popup-menu.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Popup menu utilities for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#ifndef POPUP_MENU_H -#define POPUP_MENU_H - -#include <gdk/gdktypes.h> -#include <gtk/gtksignal.h> - - -struct menu_item { - char *text; - GtkSignalFunc callback; - gpointer data; - int sensitive; -}; - -void popup_menu (struct menu_item *items, int nitems, GdkEventButton *event); - - -#endif diff --git a/calendar/gui/print.c b/calendar/gui/print.c deleted file mode 100644 index 1554be0b96..0000000000 --- a/calendar/gui/print.c +++ /dev/null @@ -1,1313 +0,0 @@ -/* Evolution calendar - Print support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <sys/stat.h> -#include <math.h> -#include <gnome.h> -#include <libgnomeprint/gnome-print.h> -#include <libgnomeprint/gnome-print-copies.h> -#include <libgnomeprint/gnome-print-master.h> -#include <libgnomeprint/gnome-print-master-preview.h> -#include <libgnomeprint/gnome-print-preview.h> -#include <libgnomeprint/gnome-printer-profile.h> -#include <libgnomeprint/gnome-printer-dialog.h> -#include <e-util/e-dialog-widgets.h> -#include <cal-util/timeutil.h> -#include "calendar-commands.h" -#include "gnome-cal.h" -#include "print.h" - - - -/* copied from gnome-month-item.c this should be shared?? */ - -/* Number of days in a month, for normal and leap years */ -static const int days_in_month[2][12] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; - -/* The weird month of September 1752, where 3 Sep through 13 Sep were eliminated due to the - * Gregorian reformation. - */ -static const int sept_1752[42] = { - 0, 0, 1, 2, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 -}; - -#define REFORMATION_DAY 639787 /* First day of the reformation, counted from 1 Jan 1 */ -#define MISSING_DAYS 11 /* They corrected out 11 days */ -#define THURSDAY 4 /* First day of reformation */ -#define SATURDAY 6 /* Offset value; 1 Jan 1 was a Saturday */ -#define SEPT_1752_START 2 /* Start day within month */ -#define SEPT_1752_END 20 /* End day within month */ - -struct pdinfo -{ - GList *slots; -}; - -struct psinfo -{ - GList *events; -}; - -struct ptinfo -{ - GList *todos; -}; - -struct einfo -{ - char *text; - time_t start; - time_t end; - int count; -}; - - -/* Returns the number of leap years since year 1 up to (but not including) the specified year */ -static int -leap_years_up_to (int year) -{ - return (year / 4 /* trivial leapness */ - - ((year > 1700) ? (year / 100 - 17) : 0) /* minus centuries since 1700 */ - + ((year > 1600) ? ((year - 1600) / 400) : 0)); /* plus centuries since 1700 divisible by 400 */ -} - -/* Returns whether the specified year is a leap year */ -static int -is_leap_year (int year) -{ - if (year <= 1752) - return !(year % 4); - else - return (!(year % 4) && (year % 100)) || !(year % 400); -} - -/* Returns the 1-based day number within the year of the specified date */ -static int -day_in_year (int day, int month, int year) -{ - int is_leap, i; - - is_leap = is_leap_year (year); - - for (i = 0; i < month; i++) - day += days_in_month [is_leap][i]; - - return day; -} - -/* Returns the day of the week (zero-based, zero is Sunday) for the specified date. For the days - * that were removed on the Gregorian reformation, it returns Thursday. - */ -static int -day_in_week (int day, int month, int year) -{ - int n; - - n = (year - 1) * 365 + leap_years_up_to (year - 1) + day_in_year (day, month, year); - - if (n < REFORMATION_DAY) - return (n - 1 + SATURDAY) % 7; - - if (n >= (REFORMATION_DAY + MISSING_DAYS)) - return (n - 1 + SATURDAY - MISSING_DAYS) % 7; - - return THURSDAY; -} - -/* Fills the 42-element days array with the day numbers for the specified month. Slots outside the - * bounds of the month are filled with zeros. The starting and ending indexes of the days are - * returned in the start and end arguments. - */ -static void -build_month (int month, int year, int start_on_monday, int *days, int *start, int *end) -{ - int i; - int d_month, d_week; - - /* Note that months are zero-based, so September is month 8 */ - - if ((year == 1752) && (month == 8)) { - memcpy (days, sept_1752, 42 * sizeof (int)); - - if (start) - *start = SEPT_1752_START; - - if (end) - *end = SEPT_1752_END; - - return; - } - - for (i = 0; i < 42; i++) - days[i] = 0; - - d_month = days_in_month[is_leap_year (year)][month]; - d_week = day_in_week (1, month, year); - - if (start_on_monday) - d_week = (d_week + 6) % 7; - - for (i = 0; i < d_month; i++) - days[d_week + i] = i + 1; - - if (start) - *start = d_week; - - if (end) - *end = d_week + d_month - 1; -} - - -enum align_box { - ALIGN_LEFT=1, - ALIGN_RIGHT, - ALIGN_CENTRE, - ALIGN_BORDER= 1<<8 -}; - -/* width = width of border, -'ve is no border - fillcolour = shade of fill, -'ve is no fill */ -static void -print_border(GnomePrintContext *pc, double l, double r, double t, double b, double width, double fillcolour) -{ - int i; - gnome_print_gsave (pc); - if (fillcolour<0.0) - i=1; - else - i=0; - for (;i<2;i++) { - gnome_print_moveto(pc, l, t); - gnome_print_lineto(pc, l, b); - gnome_print_lineto(pc, r, b); - gnome_print_lineto(pc, r, t); - gnome_print_lineto(pc, l, t); - if (i==0) { - gnome_print_setrgbcolor(pc, fillcolour, fillcolour, fillcolour); - gnome_print_fill(pc); - if (width<0.0) - i=2; - } else { - gnome_print_setrgbcolor(pc, 0, 0, 0); - gnome_print_setlinewidth(pc, width); - gnome_print_stroke(pc); - } - } - gnome_print_grestore (pc); -} - -/* outputs 1 line of aligned text in a box */ -static void -print_text(GnomePrintContext *pc, GnomeFont *font, const char *text, enum align_box align, double l, double r, double t, double b) -{ - double w, x; - gnome_print_gsave (pc); - w = gnome_font_get_width_string(font, text); - switch (align&3) { - default: - case ALIGN_LEFT: - x = l; - break; - case ALIGN_RIGHT: - x = l+(r-l)-w-2; - break; - case ALIGN_CENTRE: - x = l+((r-l)-w)/2; - break; - } - gnome_print_moveto(pc, x, t-font->size); - gnome_print_setfont(pc, font); - gnome_print_setrgbcolor (pc, 0,0,0); - gnome_print_show(pc, text); - gnome_print_grestore (pc); -} - -/* gets/frees the font for you, as a bold font */ -static void -print_text_size(GnomePrintContext *pc, double size, const char *text, enum align_box align, double l, double r, double t, double b) -{ - GnomeFont *font; - - font = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, size); - print_text(pc, font, text, align, l, r, t, b); - gtk_object_unref (GTK_OBJECT (font)); -} - -static void -titled_box(GnomePrintContext *pc, const char *text, GnomeFont *font, enum align_box align, double *l, double *r, double *t, double *b, double linewidth) -{ - if (align&ALIGN_BORDER) { - gnome_print_gsave(pc); - print_border(pc, *l, *r, *t, *t-font->size-font->size*0.4, linewidth, 0.9); - print_border(pc, *l, *r, *t-font->size-font->size*0.4, *b, linewidth, -1.0); - gnome_print_grestore(pc); - *l+=2; - *r-=2; - *b+=2; - } - print_text(pc, font, text, align, *l, *r, *t, *b); - *t-=font->size*1.4; -} - -enum datefmt { - DATE_MONTH = 1 << 0, - DATE_DAY = 1 << 1, - DATE_DAYNAME = 1 << 2, - DATE_YEAR = 1 << 3 -}; - -static char *days[] = { - N_("1st"), N_("2nd"), N_("3rd"), N_("4th"), N_("5th"), - N_("6th"), N_("7th"), N_("8th"), N_("9th"), N_("10th"), - N_("11th"), N_("12th"), N_("13th"), N_("14th"), N_("15th"), - N_("16th"), N_("17th"), N_("18th"), N_("19th"), N_("20th"), - N_("21st"), N_("22nd"), N_("23rd"), N_("24th"), N_("25th"), - N_("26th"), N_("27th"), N_("28th"), N_("29th"), N_("30th"), - N_("31st") -}; - -/* - format the date 'nicely' and consistently for various headers -*/ -static char * -format_date(time_t time, int flags, char *buffer, int bufflen) -{ - char fmt[64]; - struct tm tm; - - tm = *localtime(&time); - fmt[0] = 0; - if (flags & DATE_DAYNAME) { - strcat(fmt, "%A"); - } - if (flags & DATE_DAY) { - if (flags & DATE_DAYNAME) - strcat(fmt, " "); - strcat(fmt, gettext(days[tm.tm_mday-1])); - } - if (flags & DATE_MONTH) { - if (flags & (DATE_DAY|DATE_DAYNAME)) - strcat(fmt, " "); - strcat(fmt, "%B"); - if ((flags & (DATE_DAY|DATE_YEAR)) == (DATE_DAY|DATE_YEAR)) - strcat(fmt, ","); - } - if (flags & DATE_YEAR) { - if (flags & (DATE_DAY|DATE_DAYNAME|DATE_MONTH)) - strcat(fmt, " "); - strcat(fmt, "%Y"); - } - strftime(buffer, bufflen, fmt, &tm); - return buffer; -} - - -/* - print out the month small, embolden any days with events. -*/ -static void -print_month_small (GnomePrintContext *pc, GnomeCalendar *gcal, - time_t month, double left, double right, double top, double bottom, - int titleflags, time_t greystart, time_t greyend, int bordertitle) -{ - GnomeFont *font, *font_bold, *font_normal; - time_t now, next; - int x, y; - int days[42]; - int day; - char buf[100]; - struct tm tm; - double xpad, ypad, size; - char *daynames[] = { _("Su"), _("Mo"), _("Tu"), _("We"), _("Th"), _("Fr"), _("Sa") }; - - xpad = (right-left)/7; - ypad = (top-bottom)/8.3; - if (xpad>ypad) - size=ypad; - else - size=xpad; - - size = (xpad+ypad)/3.0; - - tm = *localtime (&month); - - /* get month days */ - build_month(tm.tm_mon, tm.tm_year+1900, week_starts_on_monday, days, 0, 0); - - /* build day-busy bits */ - now = time_month_begin(month); - - /* get title */ - format_date(month, titleflags, buf, 100); - font = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 1, size*1.2); /* title font */ - if (bordertitle) - print_border(pc, - left, left+7*xpad, top, top-font->size*1.3, - 1.0, 0.9); - print_text(pc, font, buf, ALIGN_CENTRE, - left, left+7*xpad, top, top - font->size); - gtk_object_unref (GTK_OBJECT (font)); - - font_normal = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, 0, size); - font_bold = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, size); - - gnome_print_setrgbcolor (pc, 0,0,0); - for (x=0;x<7;x++) { - print_text(pc, font_bold, daynames[(week_starts_on_monday?x+1:x)%7], ALIGN_CENTRE, - left+x*xpad, left+(x+1)*xpad, bottom+7*ypad, bottom+7*ypad-font_bold->size); - } - - for (y=0;y<6;y++) { - for (x=0;x<7;x++) { - day = days[y*7+x]; - if (day!=0) { - GList *uids; - - sprintf(buf, "%d", day); - - /* this is a slow messy way to do this ... but easy ... */ - uids = cal_client_get_objects_in_range (gcal->client, CALOBJ_TYPE_EVENT, now, time_day_end (now)); - font = uids ? font_bold : font_normal; - cal_obj_uid_list_free (uids); - - next = time_add_day(now, 1); - if ((now>=greystart && now<greyend) - || (greystart>=now && greystart<next)) { - print_border(pc, - left+x*xpad+xpad*0.1, - left+(x+1)*xpad+xpad*0.1, - bottom+(5-y)*ypad+font->size-ypad*0.15, - bottom+(5-y)*ypad-ypad*0.15, - -1.0, 0.75); - } - print_text(pc, font, buf, ALIGN_RIGHT, - left+x*xpad, left+(x+1)*xpad, bottom+(5-y)*ypad+font->size, bottom+(5-y)*ypad); - now = next; - } - } - } - gtk_object_unref (GTK_OBJECT (font_normal)); - gtk_object_unref (GTK_OBJECT (font_bold)); -} - - - -/* wraps text into the print context, not taking up more than its allowed space */ -static double -bound_text(GnomePrintContext *pc, GnomeFont *font, char *text, double left, double right, double top, double bottom, double indent) -{ - double maxwidth = right-left; - double width; - char *p; - char *wordstart; - int c; - char *outbuffer, *o, *outbuffendmarker; - int outbufflen; - int dump=0; - int first=1; - - g_return_val_if_fail(text!=NULL, top); - - if (top<bottom) { - /* too much to fit in appointment printout */ - return top; - } - - outbufflen = 1024; - outbuffer = g_malloc(outbufflen); - outbuffendmarker = outbuffer+outbufflen-2; - - top -= font->size; - gnome_print_setfont (pc, font); - - width=0; - p = text; - wordstart = outbuffer; - o = outbuffer; - while ((c=*p)) { - if (c=='\n') { - wordstart=o; - dump=1; - } else { - /* grow output buffer if required */ - if (o>=outbuffendmarker) { - char *newbuf; - outbufflen*=2; - newbuf = g_realloc(outbuffer, outbufflen); - o = newbuf+(o-outbuffer); - wordstart = newbuf+(o-outbuffer); - outbuffer = newbuf; - outbuffendmarker = outbuffer+outbufflen-2; - } - *o++=c; - if (c==' ') - wordstart = o; - width+=gnome_font_get_width(font, c); - if (width>maxwidth) - dump=1; - else - dump=0; - } - if (dump) { - if (wordstart==outbuffer) - wordstart=o; - c=*wordstart; - *wordstart=0; - gnome_print_moveto(pc, left, top); - gnome_print_show(pc, outbuffer); - *wordstart=c; - memcpy(outbuffer, wordstart, o-wordstart); - width = gnome_font_get_width_string_n(font, outbuffer, o-wordstart); - o=outbuffer+(o-wordstart); - wordstart = outbuffer; - top -= font->size; - if (top<bottom) { - /* too much to fit, drop the rest */ - g_free(outbuffer); - return top; - } - if (first) { - left += indent; - maxwidth -= indent; - first=0; - } - } - p++; - } - if (dump==0) { - *o=0; - gnome_print_moveto(pc, left, top); - gnome_print_show(pc, outbuffer); - top -= font->size; - } - g_free(outbuffer); - return top; -} - -/* - * Print Day Details - */ -static gboolean -print_day_details_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - CalComponentText text; - GList *l, *col = NULL; - struct pdinfo *pdi = (struct pdinfo *)data; - struct einfo *ei; - - ei = g_new (struct einfo, 1); - - cal_component_get_summary (comp, &text); - ei->text = g_strdup (text.value); - - ei->start = istart; - ei->end = iend; - ei->count = 0; - - for (l = pdi->slots; l; l = l->next) { - struct einfo *testei; - - col = (GList *)l->data; - testei = (struct einfo *)col->data; - - if (ei->start >= testei->end) { - col = g_list_prepend (col, ei); - l->data = col; - return TRUE; - } - - testei->count++; - ei->count++; - } - - col = NULL; - col = g_list_prepend (col, ei); - pdi->slots = g_list_append (pdi->slots, col); - - return TRUE; -} - -static void -print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom) -{ - struct pdinfo pdi; - time_t start, end; - GList *l; - int num_slots, i; - GnomeFont *font_hour, *font_minute, *font_summary; - double yinc, y, yend, x, xend; - double width=40, slot_width; - char buf[20]; - - yinc = (top-bottom)/24; - - /* fill static detail */ - font_hour = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, yinc/2); - font_minute = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, yinc/3); - font_summary = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, 0, yinc/3); - - gnome_print_setrgbcolor (pc, 0, 0, 0); - - /* internal lines */ - gnome_print_setlinewidth(pc, 0.0); - gnome_print_moveto(pc, left+width, bottom); - gnome_print_lineto(pc, left+width, top); - gnome_print_stroke (pc); - - for (i=0;i<24;i++) { - y = top - yinc*(i+1); - print_border(pc, left+1, left+width-1, y, y+yinc-1, -1.0, 0.9); - gnome_print_setrgbcolor (pc, 0, 0, 0); - - /* the hour label/minute */ - sprintf(buf, "%d", i); - print_text(pc, font_hour, buf, ALIGN_RIGHT, left, left+width/2, y+yinc, y); - switch(i) { - case 12: sprintf(buf, _("pm")); break; - case 0: sprintf(buf, _("am")); break; - default: sprintf(buf, "00"); break; - } - print_text(pc, font_minute, buf, ALIGN_LEFT, left+width/2, left+width/2, y+yinc, y); - - /* internal lines */ - gnome_print_moveto(pc, left+width, y); - gnome_print_lineto(pc, right, y); - gnome_print_stroke (pc); - gnome_print_moveto(pc, left+width/2, y+yinc/2); - gnome_print_lineto(pc, right, y+yinc/2); - gnome_print_stroke (pc); - - } - - start = time_day_begin(whence); - end = time_day_end(start); - - cal_client_generate_instances (gcal->client, CALOBJ_TYPE_EVENT, start, end, - print_day_details_cb, &pdi); - - num_slots = g_list_length (pdi.slots); - slot_width = (right-left-width)/num_slots; - - for (i = num_slots, l = pdi.slots; l; i--, l = l->next) { - GList *e = (GList *)l->data; - - for (; e; e = e->next) { - struct einfo *ei = (struct einfo *)e->data; - - y = top - (top - bottom) * (ei->start - start) / (end - start) - 1; - yend = top - (top - bottom) * (ei->end - start) / (end - start) + 1; - x = left + width + slot_width * (num_slots - i); - - if (num_slots > 0) - x++; - - if (i == 0) - xend = x + (num_slots - ei->count) * slot_width - 2; - else - xend = x + slot_width - 2; - - print_border (pc, x, xend, y, yend, 0.0, 0.9); - - bound_text (pc, font_summary, ei->text, x, xend, y, yend, 0); - - g_free (ei); - } - g_list_free (e); - } - g_list_free (pdi.slots); - - print_border (pc, left, right, top, bottom, 1.0, -1.0); - - gtk_object_unref (GTK_OBJECT (font_hour)); - gtk_object_unref (GTK_OBJECT (font_minute)); - gtk_object_unref (GTK_OBJECT (font_summary)); -} - -/* - * Print Day Summary - */ -#if 0 -#define TIME_FMT "%X" -#else -#define TIME_FMT "%l:%M%p" -#endif - -static gboolean -print_day_summary_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - CalComponentText text; - struct psinfo *psi = (struct psinfo *)data; - struct einfo *ei; - - ei = g_new (struct einfo, 1); - - cal_component_get_summary (comp, &text); - ei->text = g_strdup (text.value); - - ei->start = istart; - ei->end = iend; - ei->count = 0; - - g_list_append (psi->events, ei); - - return TRUE; -} - -static void -print_day_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom, - double size, int totime, int titleformat) -{ - struct psinfo psi; - time_t start, end; - GList *l; - GnomeFont *font_summary; - double y, yend, x, xend, inc, incsmall; - char buf[100]; - double margin; - struct tm tm; - - /* fill static detail */ - font_summary = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, 0, size); - - gnome_print_setfont (pc, font_summary); - - start = time_day_begin(whence); - end = time_day_end(start); - - tm = *localtime(&start); - - format_date(start, titleformat, buf, 100); - titled_box (pc, buf, font_summary, ALIGN_RIGHT | ALIGN_BORDER, - &left, &right, &top, &bottom, 0.0); - - cal_client_generate_instances (gcal->client, CALOBJ_TYPE_EVENT, start, end, - print_day_summary_cb, &psi); - inc = size*0.3; - incsmall = size*0.2; - - y = top-inc; - yend = bottom-incsmall; - - /* do a good rough approximation of the 'widest' time */ - tm.tm_year = 2000; - tm.tm_mon = 12; - tm.tm_mday = 22; - tm.tm_sec = 22; - tm.tm_min = 22; - tm.tm_hour = 23; - strftime(buf, 100, TIME_FMT, &tm); - margin = gnome_font_get_width_string(font_summary, buf); - - for (l = psi.events; l; l = l->next) { - struct einfo *ei = (struct einfo *)l->data; - - x = left + incsmall; - xend = right - inc; - - if (y - font_summary->size < bottom) - break; - - tm = *localtime (&ei->start); - strftime (buf, 100, TIME_FMT, &tm); - gnome_print_moveto (pc, x + (margin - - gnome_font_get_width_string (font_summary, buf)), - y - font_summary->size); - gnome_print_show (pc, buf); - - if (totime) { - tm = *localtime (&ei->end); - strftime (buf, 100, TIME_FMT, &tm); - gnome_print_moveto (pc, - (x + margin + inc - + (margin - - gnome_font_get_width_string (font_summary, buf))), - y - font_summary->size); - gnome_print_show (pc, buf); - - y = bound_text (pc, font_summary, ei->text, - x + margin * 2 + inc * 2, xend, - y, yend, 0); - } else { - /* we also indent back after each time is printed */ - y = bound_text (pc, font_summary, ei->text, - x + margin + inc, xend, - y, yend, -margin + inc); - } - - y += font_summary->size - inc; - - g_free (ei); - } - g_list_free (psi.events); - - gtk_object_unref (GTK_OBJECT (font_summary)); -} - -static void -print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom) -{ - double y, l, r, t, b; - time_t now; - int i; - - l = left; - r = (right-left)/2+left; - t = top; - y = (top-bottom)/3; - b = top-y; - now = time_week_begin(whence); /* returns sunday, we need monday */ - now = time_add_day(now, 1); - for (i = 0; i < 7; i++) { - print_day_summary (pc, gcal, now, l, r, t, b, - 10, TRUE, DATE_DAY | DATE_DAYNAME | DATE_MONTH); - now = time_add_day (now, 1); - switch (i) { - case 5: - y /= 2.0; - b += y; - case 0: - case 1: - case 3: - case 4: - t -= y; - b -= y; - break; - case 2: - l = r; - r = right; - t = top; - b = t-y; - break; - case 6: - break; - } - } -} - -static void -print_year_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom, int morerows) -{ - double y, x, l, r, t, b; - time_t now; - int xx, yy, rows, cols; - - l = left; - t = top; - if (morerows) { - rows=4; - cols=3; - } else { - rows=3; - cols=4; - } - y = (top-bottom)/rows; - x = (right-left)/cols; - r = l+x; - b = top-y; - now = time_year_begin(whence); - for (yy = 0; yy < rows; yy++) { - t = top - y * yy; - b = t - y; - for (xx = 0; xx < cols; xx++) { - l = left + x * xx; - r = l + x; - print_month_small (pc, gcal, now, - l + 8, r - 8, t - 8, b + 8, DATE_MONTH, 0, 0, TRUE); - now = time_add_month (now, 1); - } - } -} - -static void -print_month_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom) -{ - time_t now, today; - int days[42]; - int day; - struct tm tm; - int x, y; - char buf[100]; - GnomeFont *font_days; - - now = time_month_begin(whence); - tm = *localtime (&now); - - /* get month days */ - build_month(tm.tm_mon, tm.tm_year+1900, week_starts_on_monday, days, 0, 0); - - /* a little margin */ - top -= 4; - - /* do day names ... */ - font_days = gnome_font_new_closest ("Times", GNOME_FONT_BOLD, 0, 10); - gnome_print_setfont(pc, font_days); - for (x=0;x<7;x++) { - today = time_add_day(now, days[6+x]); - format_date(today, DATE_DAYNAME, buf, 100); - print_text(pc, font_days, buf, ALIGN_CENTRE, - (right-left)*x/7+left, (right-left)*(x+1)/7+left, - top, top-font_days->size); - } - top -= font_days->size*1.5; - gtk_object_unref (GTK_OBJECT (font_days)); - - for (y=0;y<6;y++) { - for (x=0;x<7;x++) { - day = days[y*7+x]; - if (day!=0) { - print_day_summary (pc, gcal, now, - (right-left)*x/7+left, - (right-left)*(x+1)/7+left, - top - (top-bottom)*y/6, - top - (top-bottom)*(y+1)/6, 6, FALSE, - day==1?(DATE_DAY|DATE_MONTH):DATE_DAY); - now = time_add_day(now, 1); - } - } - } -} - -/* - * Print to do details - */ -static gboolean -print_todo_details_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data) -{ - CalComponentText text; - struct ptinfo *pti = (struct ptinfo *)data; - struct einfo *ei; - - ei = g_new0 (struct einfo, 1); - - cal_component_get_summary (comp, &text); - ei->text = g_strdup (text.value); - - g_list_append (pti->todos, ei); - - return TRUE; -} - -static void -print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t start, time_t end, - double left, double right, double top, double bottom) -{ - struct ptinfo pti; - GList *l; - GnomeFont *font_summary; - double y, yend, x, xend; - - font_summary = gnome_font_new_closest ("Times", GNOME_FONT_BOOK, 0, 10); - - gnome_print_setrgbcolor (pc, 0, 0, 0); - gnome_print_setlinewidth (pc, 0.0); - - titled_box (pc, _("TODO Items"), font_summary, - ALIGN_CENTRE | ALIGN_BORDER, &left, &right, &top, &bottom, 1.0); - - y = top - 3; - yend = bottom - 2; - - cal_client_generate_instances (gcal->client, CALOBJ_TYPE_TODO, start, end, - print_todo_details_cb, &pti); - - for (l = pti.todos; l; l = l->next) { - struct einfo *ei = (struct einfo *)l->data; - - x = left; - xend = right-2; - - if (y < bottom) - break; - - y = bound_text (pc, font_summary, ei->text, x + 2, xend, y, yend, 0); - y += font_summary->size; - gnome_print_moveto (pc, x, y - 3); - gnome_print_lineto (pc, xend, y - 3); - gnome_print_stroke (pc); - y -= 3; - - g_free (ei); - } - g_list_free (pti.todos); - - gtk_object_unref (GTK_OBJECT (font_summary)); -} - -#if 0 - -static GnomePrintContext * -print_context (int preview, char *paper) -{ - GtkWidget *toplevel, *canvas, *sw; - GnomePrinter *printer; - GnomePrintContext *pc; - - if (preview) { - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - gtk_widget_push_visual (gdk_rgb_get_visual ()); - - toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_usize (toplevel, 700, 700); - sw = gtk_scrolled_window_new (NULL, NULL); - canvas = gnome_canvas_new_aa (); - gtk_container_add (GTK_CONTAINER (toplevel), sw); - gtk_container_add (GTK_CONTAINER (sw), canvas); - - gnome_canvas_set_pixels_per_unit((GnomeCanvas *)canvas, 1); - - pc = gnome_print_preview_new ((GnomeCanvas *)canvas, paper); - - gtk_widget_show_all (toplevel); - - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); - } else { - printer = gnome_printer_dialog_new_modal (); - - if (!printer) - return NULL; - - pc = gnome_print_context_new_with_paper_size (printer, paper); - } - - return pc; -} - -#endif - -/* Value for the PrintView enum */ -static const int print_view_map[] = { - PRINT_VIEW_DAY, - PRINT_VIEW_WEEK, - PRINT_VIEW_MONTH, - PRINT_VIEW_YEAR, - -1 -}; - -/* Creates the range selector widget for printing a calendar */ -static GtkWidget * -range_selector_new (GtkWidget *dialog, time_t at, int *view) -{ - GtkWidget *box; - GtkWidget *radio; - GSList *group; - char text[1024]; - struct tm tm; - time_t week_begin, week_end; - struct tm week_begin_tm, week_end_tm; - - box = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - - tm = *localtime (&at); - - /* Day */ - - strftime (text, sizeof (text), _("Current day (%a %b %d %Y)"), &tm); - radio = gtk_radio_button_new_with_label (NULL, text); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0); - - /* Week */ - - week_begin = time_week_begin (at); - week_end = time_add_day (time_week_end (at), -1); - - week_begin_tm = *localtime (&week_begin); - week_end_tm = *localtime (&week_end); - - /* FIXME: how to make this localization-friendly? */ - - if (week_begin_tm.tm_mon == week_end_tm.tm_mon) { - char month[128]; - char day1[128]; - char day2[128]; - - strftime (month, sizeof (month), _("%a"), &week_begin_tm); - strftime (day1, sizeof (day1), _("%b"), &week_begin_tm); - strftime (day2, sizeof (day2), _("%b"), &week_end_tm); - - g_snprintf (text, sizeof (text), _("Current week (%s %s %d - %s %d %d)"), - day1, month, week_begin_tm.tm_mday, - day2, week_end_tm.tm_mday, - week_begin_tm.tm_year + 1900); - } else { - char month1[128]; - char month2[128]; - char day1[128]; - char day2[128]; - - strftime (month1, sizeof (month1), _("%a"), &week_begin_tm); - strftime (month2, sizeof (month2), _("%a"), &week_end_tm); - strftime (day1, sizeof (day1), _("%b"), &week_begin_tm); - strftime (day2, sizeof (day2), _("%b"), &week_end_tm); - - if (week_begin_tm.tm_year == week_end_tm.tm_year) - g_snprintf (text, sizeof (text), - _("Current week (%s %s %d - %s %s %d %d)"), - day1, month1, week_begin_tm.tm_mday, - day2, month2, week_end_tm.tm_mday, - week_begin_tm.tm_year + 1900); - else - g_snprintf (text, sizeof (text), - _("Current week (%s %s %d %d - %s %s %d %d)"), - day1, month1, week_begin_tm.tm_mday, - week_begin_tm.tm_year + 1900, - day2, month2, week_end_tm.tm_mday, - week_end_tm.tm_year + 1900); - } - - radio = gtk_radio_button_new_with_label (group, text); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0); - - /* Month */ - - strftime (text, sizeof (text), _("Current month (%a %Y)"), &tm); - radio = gtk_radio_button_new_with_label (group, text); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0); - - /* Year */ - - strftime (text, sizeof (text), _("Current year (%Y)"), &tm); - radio = gtk_radio_button_new_with_label (group, text); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0); - - /* Select default */ - - e_dialog_widget_hook_value (dialog, radio, view, (gpointer) print_view_map); - - gtk_widget_show_all (box); - return box; -} - -void -print_calendar (GnomeCalendar *gcal, gboolean preview, time_t at, PrintView default_view) -{ - GnomePrinter *printer; - GnomePrintMaster *gpm; - GnomePrintContext *pc; - int copies, collate; - const GnomePaper *paper_info; - double l, r, t, b, todo, header; - char buf[100]; - time_t when; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - printer = NULL; - copies = 1; - collate = FALSE; - - if (!preview) { - GtkWidget *gpd; - GtkWidget *range; - int view; - - gpd = gnome_print_dialog_new (_("Print Calendar"), - GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); - - view = (int) default_view; - range = range_selector_new (gpd, at, &view); - gnome_print_dialog_construct_range_custom (GNOME_PRINT_DIALOG (gpd), range); - - gnome_dialog_set_default (GNOME_DIALOG (gpd), GNOME_PRINT_PRINT); - - /* Run dialog */ - - switch (gnome_dialog_run (GNOME_DIALOG (gpd))) { - case GNOME_PRINT_PRINT: - break; - - case GNOME_PRINT_PREVIEW: - preview = TRUE; - break; - - case -1: - return; - - default: - gnome_dialog_close (GNOME_DIALOG (gpd)); - return; - } - - e_dialog_get_values (gpd); - default_view = (PrintView) view; - - gnome_print_dialog_get_copies (GNOME_PRINT_DIALOG (gpd), &copies, &collate); - printer = gnome_print_dialog_get_printer (GNOME_PRINT_DIALOG (gpd)); - - gnome_dialog_close (GNOME_DIALOG (gpd)); - } - - /* FIXME: allow configuration of paper size */ - - gpm = gnome_print_master_new (); - - paper_info = gnome_paper_with_name (gnome_paper_name_default ()); - gnome_print_master_set_paper (gpm, paper_info); - - if (printer) - gnome_print_master_set_printer (gpm, printer); - - gnome_print_master_set_copies (gpm, copies, collate); - - pc = gnome_print_master_get_context (gpm); - - l = gnome_paper_lmargin (paper_info); - r = gnome_paper_pswidth (paper_info) - gnome_paper_rmargin (paper_info); - t = gnome_paper_psheight (paper_info) - gnome_paper_tmargin (paper_info); - b = gnome_paper_bmargin (paper_info); - - /* depending on the view, do a different output */ - switch (default_view) { - case PRINT_VIEW_DAY: { - int i, days = 1; - - for (i = 0; i < days; i++) { - todo = ((r - l) / 5) * 4 + l; - header = t - 70; - print_todo_details (pc, gcal, 0, INT_MAX, todo, r, header, b); - print_day_details (pc, gcal, at, l, todo - 2.0, header, b); - - print_border (pc, l, r, t, header + 2.0, 1.0, 0.9); - - print_month_small (pc, gcal, at, r - 190, r - 104, t - 4, - header + 8, DATE_MONTH | DATE_YEAR, at, at, FALSE); - print_month_small (pc, gcal, time_add_month (at, 1), r - 90, r - 4, t - 4, - header + 8, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); - - format_date (at, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); - print_text_size (pc, 24, buf, ALIGN_LEFT, l + 3, todo, t - 3, header); - - format_date (at, DATE_DAYNAME, buf, 100); - print_text_size (pc, 18, buf, ALIGN_LEFT, l + 3, todo, t - 27 - 4, header); - gnome_print_showpage (pc); - at = time_add_day (at, 1); - } - break; - } - - case PRINT_VIEW_WEEK: - header = t - 70; - print_week_summary (pc, gcal, at, l, r, header, b); - - /* more solid total outline */ - print_border (pc, l, r, header, b, 1.0, -1.0); - - /* header border */ - print_border (pc, l, r, t, header + 2.0, 1.0, 0.9); - - when = time_week_begin (at); - when = time_add_day (when, 1); - - print_month_small (pc, gcal, at, r - 90, r - 4, t - 4, - header + 8, DATE_MONTH | DATE_YEAR, when, time_add_week (when, 1), - FALSE); - print_month_small (pc, gcal, time_add_month (at, -1), r - 190, r - 104, t - 4, - header + 8, DATE_MONTH | DATE_YEAR, when, time_add_week (when, 1), - FALSE); - - format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); - print_text_size (pc, 24, buf, ALIGN_LEFT, l + 3, r, t - 4, header); - - when = time_add_day (when, 6); - format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); - print_text_size (pc, 24, buf, ALIGN_LEFT, l + 3, r, t - 24 - 3, header); - gnome_print_showpage (pc); - break; - - case PRINT_VIEW_MONTH: - header = t - 70; - gnome_print_rotate (pc, 90); - gnome_print_translate (pc, 0, -gnome_paper_pswidth (paper_info)); - /*print_month_summary(pc, cal, at, l, r, header, b);*/ - print_month_summary (pc, gcal, at, b, t, r - 70, l); - - print_border (pc, b, t, r, r - 72.0, 1.0, 0.9); - - print_month_small (pc, gcal, time_add_month (at, 1), - t - (t - b) / 7 + 2, t - 8, r - 4, r - 68, - DATE_MONTH | DATE_YEAR, 0, 0, FALSE); - print_month_small (pc, gcal, time_add_month (at, -1), - b + 8, b + (t - b) / 7 - 2, r - 4, r - 68, - DATE_MONTH | DATE_YEAR, 0, 0, FALSE); - - /* centered title */ - format_date (at, DATE_MONTH | DATE_YEAR, buf, 100); - print_text_size (pc, 24, buf, ALIGN_CENTRE, b + 3, t, r - 3, l); - gnome_print_showpage (pc); - break; - - case PRINT_VIEW_YEAR: -#if 0 - /* landscape */ - gnome_print_rotate(pc, 90); - gnome_print_translate(pc, 0, -gnome_paper_pswidth(paper_info)); - print_year_summary(pc, gcal, at, b, t, r-50, l, FALSE); - - /* centered title */ - format_date(at, DATE_YEAR, buf, 100); - print_text_size(pc, 24, buf, ALIGN_CENTRE, b+3, t, r-3, l); -#else - /* portrait */ - print_year_summary(pc, gcal, at, l, r, t-50, b, TRUE); - - /* centered title */ - format_date(at, DATE_YEAR, buf, 100); - print_text_size(pc, 24, buf, ALIGN_CENTRE, l+3, r, t-3, b); -#endif - gnome_print_showpage(pc); - break; - - default: - g_assert_not_reached (); - } - - gnome_print_master_close (gpm); - - if (preview) { - GnomePrintMasterPreview *gpmp; - - gpmp = gnome_print_master_preview_new (gpm, _("Print Preview")); - gtk_widget_show (GTK_WIDGET (gpmp)); - } else - gnome_print_master_print (gpm); - - gtk_object_unref (GTK_OBJECT (gpm)); -} diff --git a/calendar/gui/print.h b/calendar/gui/print.h deleted file mode 100644 index e88c4a8e01..0000000000 --- a/calendar/gui/print.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Evolution calendar - Print support - * - * Copyright (C) 2000 Helix Code, Inc. - * - * Authors: Michael Zucchi <notzed@helixcode.com> - * Federico Mena-Quintero <federico@helixcode.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef PRINT_H -#define PRINT_H - -#include "gnome-cal.h" - - - -typedef enum { - PRINT_VIEW_DAY, - PRINT_VIEW_WEEK, - PRINT_VIEW_MONTH, - PRINT_VIEW_YEAR -} PrintView; - -void print_calendar (GnomeCalendar *gcal, gboolean preview, time_t at, PrintView default_view); - - - -#endif diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c deleted file mode 100644 index 2555059af8..0000000000 --- a/calendar/gui/prop.c +++ /dev/null @@ -1,938 +0,0 @@ -/* Calendar properties dialog box - * - * Copyright (C) 1998 the Free Software Foundation - * - * Authors: Miguel de Icaza <miguel@kernel.org> - * Federico Mena <federico@nuclecu.unam.mx> - */ -#include <config.h> -#ifdef HAVE_LANGINGO_H -#include <langinfo.h> -#else -#include <locale.h> -#endif -#include <gnome.h> -#include "gnome-cal.h" -#include "gnome-month-item.h" -#include "calendar-commands.h" -#include "mark.h" - -/* These specify the page numbers in the preferences notebook */ -enum { - PROP_TIME_DISPLAY, - PROP_COLORS, - PROP_TODO, - PROP_ALARMS -}; - -static GtkWidget *prop_win; /* The preferences dialog */ - -/* Widgets for the time display page */ - -static GtkWidget *time_format_12; /* Radio button for 12-hour format */ -static GtkWidget *time_format_24; /* Radio button for 24-hour format */ -static GtkWidget *start_on_sunday; /* Check button for weeks starting on Sunday */ -static GtkWidget *start_on_monday; /* Check button for weeks starting on Monday */ -static GtkWidget *start_omenu; /* Option menu for start of day */ -static GtkWidget *end_omenu; /* Option menu for end of day */ -static GtkWidget *start_items[24]; /* Menu items for start of day menu */ -static GtkWidget *end_items[24]; /* Menu items for end of day menu */ - -/* Widgets for the colors page */ - -static GtkWidget *color_pickers[COLOR_PROP_LAST]; -static GnomeCanvasItem *month_item; - -/* Widgets for the todo page */ -static GtkWidget *due_date_show_button; - -static GtkWidget *todo_item_time_remaining_show_button; - -static GtkWidget *todo_item_highlight_overdue; -static GtkWidget *todo_item_highlight_not_due_yet; -static GtkWidget *todo_item_highlight_due_today; - -static GtkWidget *priority_show_button; - -/* Widgets for the alarm page */ -static GtkWidget *enable_display_beep; -static GtkWidget *to_cb; -static GtkWidget *to_spin; -static GtkWidget *snooze_cb; -static GtkWidget *snooze_spin; - -/* prototypes */ -#if 0 -static void prop_apply_alarms (void); -#endif -static void create_alarm_page (void); -static void to_cb_changed (GtkWidget* object, gpointer data); -static void snooze_cb_changed (GtkWidget* object, gpointer data); - -GtkWidget* make_spin_button (int val, int low, int high); -void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, - enum AlarmType type, int y, gboolean sens, - GtkSignalFunc dirty_func); -void ee_store_alarm (CalendarAlarm *alarm, enum AlarmType type); - -/* Callback used when the property box is closed -- just sets the prop_win variable to null. */ -static int -prop_cancel (void) -{ - prop_win = NULL; - return FALSE; -} - -/* Returns the index of the active item in a menu */ -static int -get_active_index (GtkWidget *menu) -{ - GtkWidget *active; - - active = gtk_menu_get_active (GTK_MENU (menu)); - return GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (active))); -} - -/* Applies the settings in the time display page */ -static void -prop_apply_time_display (void) -{ - /* Day begin/end */ - - day_begin = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu))); - day_end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu))); - gnome_config_set_int ("/calendar/Calendar/Day start", day_begin); - gnome_config_set_int ("/calendar/Calendar/Day end", day_end); - - /* Time format */ - - am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active; - gnome_config_set_bool ("/calendar/Calendar/AM PM flag", am_pm_flag); - - /* Week start */ - - week_starts_on_monday = GTK_TOGGLE_BUTTON (start_on_monday)->active; - gnome_config_set_bool ("/calendar/Calendar/Week starts on Monday", week_starts_on_monday); - - gnome_config_sync (); - time_format_changed (); -} - -/* Applies the settings in the colors page */ -static void -prop_apply_colors (void) -{ - int i; - char *cspec; - gushort r, g, b; - - for (i = 0; i < COLOR_PROP_LAST; i++) { - gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), &r, &g, &b, NULL); - color_props[i].r = r; - color_props[i].g = g; - color_props[i].b = b; - - cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b); - gnome_config_set_string (color_props[i].key, cspec); - } - - gnome_config_sync (); - colors_changed (); -} -/* Applies the settings in the todo page (FIX THIS IF ITS NOT WRITTEN) */ -static void -prop_apply_todo(void) -{ - todo_show_due_date = GTK_TOGGLE_BUTTON (due_date_show_button)->active; - - todo_item_dstatus_highlight_overdue = GTK_TOGGLE_BUTTON(todo_item_highlight_overdue)->active; - todo_item_dstatus_highlight_not_due_yet = GTK_TOGGLE_BUTTON(todo_item_highlight_not_due_yet)->active; - todo_item_dstatus_highlight_due_today = GTK_TOGGLE_BUTTON(todo_item_highlight_due_today)->active; - - todo_show_priority = GTK_TOGGLE_BUTTON (priority_show_button)->active; - - todo_show_time_remaining = GTK_TOGGLE_BUTTON (todo_item_time_remaining_show_button)->active; - - /* storing the values */ - - gnome_config_set_bool("/calendar/Todo/show_time_remain", todo_show_time_remaining); - gnome_config_set_bool("/calendar/Todo/highlight_overdue", todo_item_dstatus_highlight_overdue); - - gnome_config_set_bool("/calendar/Todo/highlight_due_today", todo_item_dstatus_highlight_due_today); - - gnome_config_set_bool("/calendar/Todo/highlight_not_due_yet", todo_item_dstatus_highlight_not_due_yet); - gnome_config_set_bool("/calendar/Todo/show_due_date", todo_show_due_date); - gnome_config_set_bool("/calendar/Todo/show_priority", todo_show_priority); - /* need to sync our config changes. */ - gnome_config_sync (); - - /* apply the current changes */ - todo_properties_changed(); -} - - -/* Callback used when the Apply button is clicked. */ -static void -prop_apply (GtkWidget *w, int page) -{ - switch (page) { - case PROP_TIME_DISPLAY: - prop_apply_time_display (); - break; - - case PROP_COLORS: - prop_apply_colors (); - break; - - case PROP_TODO: - prop_apply_todo (); - break; - - case PROP_ALARMS: -#if 0 - prop_apply_alarms (); -#endif - break; - - case -1: - break; - - default: - g_warning ("We have a loose penguin!"); - g_assert_not_reached (); - } -} - -/* Notifies the property box that the data has changed */ -static void -prop_changed (void) -{ - gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win)); -} - -/* Builds and returns a two-element radio button group surrounded by a frame. The radio buttons are - * stored in the specified variables, and the first radio button's state is set according to the - * specified flag value. The buttons are connected to the prop_changed() function to update the property - * box's dirty state. - */ -static GtkWidget * -build_two_radio_group (char *title, - char *radio_1_title, GtkWidget **radio_1_widget, - char *radio_2_title, GtkWidget **radio_2_widget, - int radio_1_value) -{ - GtkWidget *frame; - GtkWidget *vbox; - - frame = gtk_frame_new (title); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - *radio_1_widget = gtk_radio_button_new_with_label (NULL, radio_1_title); - gtk_box_pack_start (GTK_BOX (vbox), *radio_1_widget, FALSE, FALSE, 0); - - *radio_2_widget = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (*radio_1_widget), - radio_2_title); - gtk_box_pack_start (GTK_BOX (vbox), *radio_2_widget, FALSE, FALSE, 0); - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_1_widget), radio_1_value); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_2_widget), !radio_1_value); - - gtk_signal_connect (GTK_OBJECT (*radio_1_widget), "toggled", - (GtkSignalFunc) prop_changed, - NULL); - - return frame; -} - -/* Callback invoked when a menu item from the start/end time option menus is selected. It adjusts - * the other menu to the proper time, if needed. - */ -static void -hour_activated (GtkWidget *widget, gpointer data) -{ - int start, end; - - if (data == start_omenu) { - /* Adjust the end menu */ - - start = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget))); - end = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (end_omenu))); - - if (end < start) - gtk_option_menu_set_history (GTK_OPTION_MENU (end_omenu), start); - } else if (data == end_omenu) { - /* Adjust the start menu */ - - end = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget))); - start = get_active_index (gtk_option_menu_get_menu (GTK_OPTION_MENU (start_omenu))); - - if (start > end) - gtk_option_menu_set_history (GTK_OPTION_MENU (start_omenu), end); - } else - g_assert_not_reached (); - - gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win)); -} - -/* Builds an option menu of 24 hours */ -static GtkWidget * -build_hours_menu (GtkWidget **items, int active) -{ - GtkWidget *omenu; - GtkWidget *menu; - int i; - char buf[100]; - struct tm tm; - int am_pm_flag; - - omenu = gtk_option_menu_new (); - menu = gtk_menu_new (); - am_pm_flag = GTK_TOGGLE_BUTTON (time_format_12)->active; - - memset (&tm, 0, sizeof (tm)); - - for (i = 0; i < 24; i++) { - tm.tm_hour = i; - if (am_pm_flag) - strftime (buf, 100, "%I:%M %p", &tm); - else - strftime (buf, 100, "%H:%M", &tm); - - items[i] = gtk_menu_item_new_with_label (buf); - gtk_object_set_user_data (GTK_OBJECT (items[i]), GINT_TO_POINTER (i)); - gtk_signal_connect (GTK_OBJECT (items[i]), "activate", - (GtkSignalFunc) hour_activated, - omenu); - - gtk_menu_append (GTK_MENU (menu), items[i]); - gtk_widget_show (items[i]); - } - - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), active); - return omenu; -} - -/* Creates the time display page in the preferences dialog */ -static void -create_time_display_page (void) -{ - GtkWidget *table; - GtkWidget *vbox; - GtkWidget *frame; - GtkWidget *hbox2; - GtkWidget *hbox3; - GtkWidget *w; - - table = gtk_table_new (2, 2, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL); - gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), table, - gtk_label_new (_("Time display"))); - - /* Time format */ - - w = build_two_radio_group (_("Time format"), - _("12-hour (AM/PM)"), &time_format_12, - _("24-hour"), &time_format_24, - am_pm_flag); - gtk_table_attach (GTK_TABLE (table), w, - 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - - /* Weeks start on */ - - w = build_two_radio_group (_("Weeks start on"), - _("Sunday"), &start_on_sunday, - _("Monday"), &start_on_monday, - !week_starts_on_monday); - gtk_table_attach (GTK_TABLE (table), w, - 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - - /* Day range */ - - frame = gtk_frame_new (_("Day range")); - gtk_table_attach (GTK_TABLE (table), frame, - 1, 2, 0, 2, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, 0); - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - w = gtk_label_new (_("Please select the start and end hours you want\n" - "to be displayed in the day view and week view.\n" - "Times outside this range will not be displayed\n" - "by default.")); - gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); - gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0); - - hbox2 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0); - - /* Day start */ - - hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0); - - w = gtk_label_new (_("Day start:")); - gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0); - - start_omenu = build_hours_menu (start_items, day_begin); - gtk_box_pack_start (GTK_BOX (hbox3), start_omenu, FALSE, FALSE, 0); - - /* Day end */ - - hbox3 = gtk_hbox_new (FALSE, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, FALSE, 0); - - w = gtk_label_new (_("Day end:")); - gtk_box_pack_start (GTK_BOX (hbox3), w, FALSE, FALSE, 0); - - end_omenu = build_hours_menu (end_items, day_end); - gtk_box_pack_start (GTK_BOX (hbox3), end_omenu, FALSE, FALSE, 0); -} - -/* Called when the canvas for the month item is size allocated. We use this to change the canvas' - * scrolling region and the month item's size. - */ -static void -canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) -{ - gnome_canvas_item_set (month_item, - "width", (double) (allocation->width - 1), - "height", (double) (allocation->height - 1), - NULL); - - gnome_canvas_set_scroll_region (GNOME_CANVAS (widget), - 0, 0, - allocation->width, allocation->height); -} - -/* Returns a color spec based on the color pickers */ -static char * -color_spec_from_picker (int num) -{ - gushort r, g, b; - - gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[num]), &r, &g, &b, NULL); - - return build_color_spec (r, g, b); -} - -/* Callback used to query color information for the properties box */ -static char * -fetch_color_spec (ColorProp propnum, gpointer data) -{ - return color_spec_from_picker (propnum); -} - -/* Marks fake event days in the month item sample */ -static void -fake_mark_days (void) -{ - static int day_nums[] = { 1, 4, 8, 16, 17, 18, 20, 25, 28 }; /* some random days */ - int first_day_index; - int i; - - first_day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (month_item), 1); - - for (i = 0; i < (sizeof (day_nums) / sizeof (day_nums[0])); i++) - mark_month_item_index (GNOME_MONTH_ITEM (month_item), first_day_index + day_nums[i] - 1, - fetch_color_spec, NULL); -} - -/* Switches the month item to the current date and highlights the current day's number */ -static void -set_current_day (void) -{ - struct tm tm; - time_t t; - GnomeCanvasItem *item; - int day_index; - - /* Set the date */ - - t = time (NULL); - tm = *localtime (&t); - - gnome_canvas_item_set (month_item, - "year", tm.tm_year + 1900, - "month", tm.tm_mon, - NULL); - - /* Highlight current day */ - - day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (month_item), tm.tm_mday); - item = gnome_month_item_num2child (GNOME_MONTH_ITEM (month_item), GNOME_MONTH_ITEM_DAY_LABEL + day_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_picker (COLOR_PROP_CURRENT_DAY_FG), - "fontset", CURRENT_DAY_FONTSET, - NULL); -} - -/* This is the version of a color spec query function that is appropriate for the preferences dialog */ -static char * -prop_color_func (ColorProp propnum, gpointer data) -{ - return color_spec_from_picker (propnum); -} - -/* Sets the colors of the month item to the current prerences */ -static void -reconfigure_month (void) -{ - colorify_month_item (GNOME_MONTH_ITEM (month_item), prop_color_func, NULL); - fake_mark_days (); - set_current_day (); - - /* Reset prelighting information */ - - month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), fetch_color_spec, NULL); -} - -/* Callback used when a color is changed */ -static void -color_set (void) -{ - reconfigure_month (); - prop_changed (); -} - -/* Creates the colors page in the preferences dialog */ -static void -create_colors_page (void) -{ - GtkWidget *frame; - GtkWidget *hbox; - GtkWidget *table; - GtkWidget *w; - int i; - - frame = gtk_frame_new (_("Colors for display")); - gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL); - gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame, - gtk_label_new (_("Colors"))); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - table = gtk_table_new (COLOR_PROP_LAST, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); - - /* Create the color pickers */ - - for (i = 0; i < COLOR_PROP_LAST; i++) { - /* Label */ - - w = gtk_label_new (_(color_props[i].label)); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), w, - 0, 1, i, i + 1, - GTK_FILL, 0, - 0, 0); - - /* Color picker */ - - color_pickers[i] = gnome_color_picker_new (); - gnome_color_picker_set_title (GNOME_COLOR_PICKER (color_pickers[i]), _(color_props[i].label)); - gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (color_pickers[i]), - color_props[i].r, color_props[i].g, color_props[i].b, 0); - gtk_table_attach (GTK_TABLE (table), color_pickers[i], - 1, 2, i, i + 1, - 0, 0, - 0, 0); - gtk_signal_connect (GTK_OBJECT (color_pickers[i]), "color_set", - (GtkSignalFunc) color_set, - NULL); - } - - /* Create the sample calendar */ - - w = gnome_canvas_new (); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - - month_item = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (w))); - gnome_canvas_item_set (month_item, - "start_on_monday", week_starts_on_monday, - NULL); - reconfigure_month (); - - gtk_signal_connect (GTK_OBJECT (w), "size_allocate", - canvas_size_allocate, - NULL); - -} - - -static void -set_todo_page_options(void) -{ - - - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -static void -todo_option_set (void) -{ - prop_changed (); - set_todo_page_options (); -} - -/* Creates the colors page in the preferences dialog */ -static GtkWidget * -build_list_options_frame(void) -{ - GtkWidget *frame; - GtkWidget *vbox; - frame = gtk_frame_new (_("Show on TODO List:")); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - due_date_show_button = gtk_check_button_new_with_label (_("Due Date")); - priority_show_button = gtk_check_button_new_with_label (_("Priority")); - todo_item_time_remaining_show_button = gtk_check_button_new_with_label (_("Time Until Due")); - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_show_button), todo_show_due_date); - gtk_signal_connect (GTK_OBJECT(due_date_show_button), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_box_pack_start (GTK_BOX (vbox), due_date_show_button, FALSE, FALSE, 0); - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_time_remaining_show_button), todo_show_time_remaining); - gtk_signal_connect (GTK_OBJECT(todo_item_time_remaining_show_button), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_box_pack_start (GTK_BOX (vbox), todo_item_time_remaining_show_button, FALSE, FALSE, 0); - - - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(priority_show_button), todo_show_priority); - gtk_signal_connect (GTK_OBJECT(priority_show_button), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_box_pack_start (GTK_BOX (vbox), priority_show_button, FALSE, FALSE, 0); - return frame; -} -static GtkWidget * -build_style_list_options_frame(void) -{ - GtkWidget *frame; - GtkWidget *vbox; - - frame = gtk_frame_new (_("To Do List style options:")); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - todo_item_highlight_overdue = gtk_check_button_new_with_label (_("Highlight overdue items")); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_overdue), - todo_item_dstatus_highlight_overdue); - todo_item_highlight_not_due_yet = gtk_check_button_new_with_label (_("Highlight not yet due items")); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_not_due_yet), - todo_item_dstatus_highlight_overdue); - todo_item_highlight_due_today = gtk_check_button_new_with_label (_("Highlight items due today")); - gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(todo_item_highlight_due_today), - todo_item_dstatus_highlight_overdue); - - gtk_signal_connect (GTK_OBJECT(todo_item_highlight_overdue), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_signal_connect (GTK_OBJECT(todo_item_highlight_not_due_yet), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - gtk_signal_connect (GTK_OBJECT(todo_item_highlight_due_today), - "clicked", - (GtkSignalFunc) todo_option_set, - NULL); - - gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_overdue, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_due_today, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), todo_item_highlight_not_due_yet, FALSE, FALSE, 0); - return frame; -} -static void -create_todo_page (void) -{ - GtkWidget *frame; - GtkWidget *main_box; - GtkWidget *hbox; - - - frame = gtk_frame_new (_("To Do List Properties")); - gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL); - gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame, - gtk_label_new (_("To Do List"))); - - /* first vbox*/ - main_box = gtk_vbox_new(FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), main_box); - - - /* first hbox*/ - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (main_box), hbox); - - gtk_box_pack_start (GTK_BOX(hbox), build_list_options_frame(), FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(hbox), build_style_list_options_frame(), FALSE, FALSE, 0); - - set_todo_page_options(); -} - -/* Creates and displays the preferences dialog for the whole application */ -void -properties (GtkWidget *toplevel) -{ - static GnomeHelpMenuEntry help_entry = { NULL, "properties" }; - - help_entry.name = gnome_app_id; - - if (prop_win) - return; - - prop_win = gnome_property_box_new (); - gtk_window_set_title (GTK_WINDOW (prop_win), _("Preferences")); - gnome_dialog_set_parent (GNOME_DIALOG (prop_win), - GTK_WINDOW (gtk_widget_get_toplevel (toplevel))); - - create_time_display_page (); - create_colors_page (); - create_todo_page (); - create_alarm_page (); - - gtk_signal_connect (GTK_OBJECT (prop_win), "destroy", - (GtkSignalFunc) prop_cancel, NULL); - - gtk_signal_connect (GTK_OBJECT (prop_win), "delete_event", - (GtkSignalFunc) prop_cancel, NULL); - - gtk_signal_connect (GTK_OBJECT (prop_win), "apply", - (GtkSignalFunc) prop_apply, NULL); - - gtk_signal_connect (GTK_OBJECT (prop_win), "help", - GTK_SIGNAL_FUNC (gnome_help_pbox_display), - &help_entry); - - gtk_widget_show_all (prop_win); -} - -char * -build_color_spec (int r, int g, int b) -{ - static char spec[100]; - - sprintf (spec, "#%04x%04x%04x", r, g, b); - return spec; -} - -void -parse_color_spec (char *spec, int *r, int *g, int *b) -{ - g_return_if_fail (spec != NULL); - g_return_if_fail (r != NULL); - g_return_if_fail (r != NULL); - g_return_if_fail (r != NULL); - - if (sscanf (spec, "#%04x%04x%04x", r, g, b) != 3) { - g_warning ("Invalid color specification %s, returning black", spec); - - *r = *g = *b = 0; - } -} - -char * -color_spec_from_prop (ColorProp propnum) -{ - return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b); -} - -static void -create_alarm_page (void) -{ - GtkWidget *main_box; - GtkWidget *default_frame; - GtkWidget *default_table; - GtkWidget *misc_frame; - GtkWidget *misc_box; - GtkWidget *box, *l; - - main_box = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL); - gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), - main_box, gtk_label_new (_("Alarms"))); - - /* build miscellaneous box */ - misc_frame = gtk_frame_new (_("Alarm Properties")); - gtk_container_set_border_width (GTK_CONTAINER (misc_frame), - GNOME_PAD_SMALL); - misc_box = gtk_vbox_new (FALSE, GNOME_PAD); - - gtk_container_set_border_width (GTK_CONTAINER (misc_frame), GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (misc_frame), misc_box); - - gtk_box_pack_start (GTK_BOX (main_box), misc_frame, FALSE, FALSE, 0); - - enable_display_beep = gtk_check_button_new_with_label (_("Beep on display alarms")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_display_beep), - beep_on_display); - gtk_box_pack_start (GTK_BOX (misc_box), enable_display_beep, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (enable_display_beep), "toggled", - (GtkSignalFunc) prop_changed, - NULL); - - /* audio timeout widgets */ - box = gtk_hbox_new (FALSE, GNOME_PAD); - to_cb = gtk_check_button_new_with_label (_("Audio alarms timeout after")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (to_cb), - enable_aalarm_timeout); - gtk_signal_connect (GTK_OBJECT (to_cb), "toggled", - (GtkSignalFunc) to_cb_changed, NULL); - gtk_box_pack_start (GTK_BOX (box), to_cb, FALSE, FALSE, 0); - to_spin = make_spin_button (audio_alarm_timeout, 1, MAX_AALARM_TIMEOUT); - gtk_widget_set_sensitive (to_spin, enable_aalarm_timeout); - gtk_signal_connect (GTK_OBJECT (to_spin), "changed", - (GtkSignalFunc) prop_changed, NULL); - gtk_box_pack_start (GTK_BOX (box), to_spin, FALSE, FALSE, 0); - l = gtk_label_new (_(" seconds")); - gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0); - - /* snooze widgets */ - box = gtk_hbox_new (FALSE, GNOME_PAD); - snooze_cb = gtk_check_button_new_with_label (_("Enable snoozing for ")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (snooze_cb), - enable_snooze); - gtk_signal_connect (GTK_OBJECT (snooze_cb), "toggled", - (GtkSignalFunc) snooze_cb_changed, NULL); - gtk_box_pack_start (GTK_BOX (box), snooze_cb, FALSE, FALSE, 0); - snooze_spin = make_spin_button (snooze_secs, 1, MAX_SNOOZE_SECS); - gtk_widget_set_sensitive (snooze_spin, enable_snooze); - gtk_signal_connect (GTK_OBJECT (snooze_spin), "changed", - (GtkSignalFunc) prop_changed, NULL); - gtk_box_pack_start (GTK_BOX (box), snooze_spin, FALSE, FALSE, 0); - l = gtk_label_new (_(" seconds")); - gtk_box_pack_start (GTK_BOX (box), l, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (misc_box), box, FALSE, FALSE, 0); - - /* populate default frame/box */ - default_frame = gtk_frame_new (_("Defaults")); - gtk_container_set_border_width (GTK_CONTAINER (default_frame), GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (main_box), default_frame, FALSE, FALSE, 0); - default_table = gtk_table_new (1, 1, 0); - gtk_container_set_border_width (GTK_CONTAINER (default_table), 4); - gtk_table_set_row_spacings (GTK_TABLE (default_table), 4); - gtk_table_set_col_spacings (GTK_TABLE (default_table), 4); - gtk_container_add (GTK_CONTAINER (default_frame), default_table); - -#warning "FIX ME" - /* - ee_create_ae (GTK_TABLE (default_table), _("Display"), - &alarm_defaults [ALARM_DISPLAY], ALARM_DISPLAY, 1, - FALSE, prop_changed); - ee_create_ae (GTK_TABLE (default_table), _("Audio"), - &alarm_defaults [ALARM_AUDIO], ALARM_AUDIO, 2, - FALSE, prop_changed); - ee_create_ae (GTK_TABLE (default_table), _("Program"), - &alarm_defaults [ALARM_PROGRAM], ALARM_PROGRAM, 3, - FALSE, prop_changed); - ee_create_ae (GTK_TABLE (default_table), _("Mail"), - &alarm_defaults [ALARM_MAIL], ALARM_MAIL, 4, - FALSE, prop_changed); - */ -} - -static void -prop_store_alarm_default_values (CalendarAlarm* alarm) -{ -#warning "FIX ME" - // ee_store_alarm (alarm, alarm->type); - - switch (alarm->type) { - case ALARM_DISPLAY: - gnome_config_push_prefix ("/calendar/alarms/def_disp_"); - break; - case ALARM_AUDIO: - gnome_config_push_prefix ("/calendar/alarms/def_audio_"); - break; - case ALARM_PROGRAM: - gnome_config_push_prefix ("/calendar/alarms/def_prog_"); - break; - case ALARM_MAIL: - gnome_config_push_prefix ("/calendar/alarms/def_mail_"); - break; - } - - gnome_config_set_int ("enabled", alarm->enabled); - gnome_config_set_int ("count", alarm->count); - gnome_config_set_int ("units", alarm->units); - if (alarm->data) - gnome_config_set_string ("data", alarm->data); - - gnome_config_pop_prefix (); - gnome_config_sync (); -} - -#if 0 -static void -prop_apply_alarms () -{ - int i; - for (i=0; i < 4; i++) - prop_store_alarm_default_values (&alarm_defaults [i]); - - beep_on_display = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enable_display_beep)); - gnome_config_set_bool ("/calendar/alarms/beep_on_display", beep_on_display); - enable_aalarm_timeout = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb)); - gnome_config_set_bool ("/calendar/alarms/enable_audio_timeout", enable_aalarm_timeout); - audio_alarm_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (to_spin)); - gnome_config_set_int ("/calendar/alarms/audio_alarm_timeout", audio_alarm_timeout); - enable_snooze = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb)); - gnome_config_set_bool ("/calendar/alarms/enable_snooze", enable_snooze); - snooze_secs = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (snooze_spin)); - gnome_config_set_int ("/calendar/alarms/snooze_secs", snooze_secs); - - gnome_config_sync(); -} -#endif - -static void -to_cb_changed (GtkWidget *object, gpointer data) -{ - gboolean active = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (to_cb)); - gtk_widget_set_sensitive (to_spin, active); - prop_changed (); -} - -static void -snooze_cb_changed (GtkWidget *object, gpointer data) -{ - gboolean active = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (snooze_cb)); - gtk_widget_set_sensitive (snooze_spin, active); - prop_changed (); -} - - diff --git a/calendar/gui/recur.xpm b/calendar/gui/recur.xpm deleted file mode 100644 index 49836b62e7..0000000000 --- a/calendar/gui/recur.xpm +++ /dev/null @@ -1,83 +0,0 @@ -/* XPM */ -static char * recur_xpm[] = { -"16 16 64 1", -" c None", -". c #350000", -"+ c #2A0000", -"@ c #1B0000", -"# c #280000", -"$ c #430000", -"% c #090000", -"& c #160000", -"* c #250000", -"= c #460000", -"- c #550000", -"; c #610000", -"> c #0D0000", -", c #1F0000", -"' c #4B0000", -") c #5E0000", -"! c #6B0000", -"~ c #750000", -"{ c #790000", -"] c #810000", -"^ c #FFFF83", -"/ c #FFFF89", -"( c #FFFF93", -"_ c #8B0000", -": c #900000", -"< c #930000", -"[ c #FFFF62", -"} c #A10000", -"| c #FFFF41", -"1 c #FFFF3B", -"2 c #FFFF31", -"3 c #B70000", -"4 c #B20000", -"5 c #AE0000", -"6 c #FFFF22", -"7 c #FFFF16", -"8 c #FFFF06", -"9 c #C90000", -"0 c #C10000", -"a c #BB0000", -"b c #FFF600", -"c c #FFE100", -"d c #FFC500", -"e c #E40000", -"f c #D70000", -"g c #CD0000", -"h c #FFDB00", -"i c #FFA900", -"j c #FF8500", -"k c #FF5900", -"l c #FF2800", -"m c #FC0000", -"n c #ED0000", -"o c #E10000", -"p c #FFAF00", -"q c #FF9400", -"r c #FF7400", -"s c #FF5000", -"t c #FF0100", -"u c #F30000", -"v c #E80000", -"w c #FF6900", -"x c #FF4900", -"y c #FF0800", -" ", -" . ", -" +. ", -" @#.$ ", -" %&*.=-; ", -" >,.')!~ ", -" &. !{] ", -" ^/( . _:< ", -" [[[ }}} ", -" |12 345 ", -" 678 90a ", -" bcd efg ", -" hdijklmnof ", -" pqrsltuv ", -" wxly ", -" "}; diff --git a/calendar/gui/task-assigned-to.xpm b/calendar/gui/task-assigned-to.xpm deleted file mode 100644 index f5b0ab6f25..0000000000 --- a/calendar/gui/task-assigned-to.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * task_assigned_to_xpm[] = { -"16 16 101 2", -" c None", -". c #0F0E0D", -"+ c #3B2F22", -"@ c #080808", -"# c #292623", -"$ c #CBBFAD", -"% c #BEA47E", -"& c #AD9A7E", -"* c #000000", -"= c #232221", -"- c #CDC8C1", -"; c #CBC5BF", -"> c #766D62", -", c #887053", -"' c #A38664", -") c #A49887", -"! c #F6DEBC", -"~ c #957D59", -"{ c #151211", -"] c #F3EFEA", -"^ c #BBB7B0", -"/ c #A69E97", -"( c #FEFEFE", -"_ c #F8F7F5", -": c #524C45", -"< c #BBA382", -"[ c #A59176", -"} c #F6DBB8", -"| c #E79E3C", -"1 c #CB783E", -"2 c #171716", -"3 c #EFE8DF", -"4 c #716A61", -"5 c #FDFCFC", -"6 c #605D57", -"7 c #26221F", -"8 c #86735E", -"9 c #D5C0A0", -"0 c #C4AD8B", -"a c #F9E9D5", -"b c #C97138", -"c c #121110", -"d c #E9E8E7", -"e c #73604D", -"f c #332F29", -"g c #534C40", -"h c #D3BFA0", -"i c #D0BB98", -"j c #D0BA96", -"k c #F9E7D1", -"l c #CA773D", -"m c #090807", -"n c #B1B1AF", -"o c #FBFBF9", -"p c #CAB290", -"q c #D5C0A1", -"r c #D0BA97", -"s c #FBEFDF", -"t c #CB793E", -"u c #272625", -"v c #F4F4F4", -"w c #F4EFE7", -"x c #D0BA98", -"y c #CFB896", -"z c #F9EAD5", -"A c #CC793A", -"B c #0F0F0D", -"C c #100F0E", -"D c #494949", -"E c #FDFCFB", -"F c #DACBB0", -"G c #F5D9B4", -"H c #CA7537", -"I c #B79F80", -"J c #B0A693", -"K c #262525", -"L c #939292", -"M c #ECE3D5", -"N c #FBF3E8", -"O c #CA7337", -"P c #C7B08E", -"Q c #D3C2A5", -"R c #918776", -"S c #0B0A0A", -"T c #555453", -"U c #828282", -"V c #A09179", -"W c #897C67", -"X c #5B5245", -"Y c #191716", -"Z c #413E3C", -"` c #978368", -" . c #867C6A", -".. c #70685D", -"+. c #1C1B18", -"@. c #1D1C1A", -"#. c #575654", -"$. c #887B68", -"%. c #676055", -"&. c #141211", -"*. c #0F0F0E", -" ", -" . + @ @ ", -" @ # $ % & @ * * ", -" @ = - ; > , ' ) @ * ! ~ * ", -" { ] ^ / ( _ : < [ @ * } | 1 * ", -" 2 3 4 5 6 7 8 9 0 * a | b * ", -" c d e f g h i j * k | l * ", -" m n o p q r j * s | t * ", -" u v w x y * z | A * B ", -" C D E F * G | H * I J @ ", -" K L M * N O * P Q R S ", -" @ T * U * * V W X Y @ ", -" Z * * ` ...+.@ @ ", -" @.#.$.%.&.@ @ ", -" * *.@ @ ", -" @ @ "}; diff --git a/calendar/gui/task-assigned.xpm b/calendar/gui/task-assigned.xpm deleted file mode 100644 index 89faae95f1..0000000000 --- a/calendar/gui/task-assigned.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * task_assigned_xpm[] = { -"16 16 101 2", -" c None", -". c #0F0E0D", -"+ c #3B2F22", -"@ c #080808", -"# c #292623", -"$ c #CBBFAD", -"% c #BEA47E", -"& c #AD9A7E", -"* c #000000", -"= c #232221", -"- c #CDC8C1", -"; c #CBC5BF", -"> c #766D62", -", c #887053", -"' c #A38664", -") c #A49887", -"! c #F6DEBC", -"~ c #957D59", -"{ c #151211", -"] c #F3EFEA", -"^ c #BBB7B0", -"/ c #A69E97", -"( c #FEFEFE", -"_ c #F8F7F5", -": c #524C45", -"< c #BBA382", -"[ c #A59176", -"} c #F6DBB8", -"| c #E79E3C", -"1 c #CB783E", -"2 c #171716", -"3 c #EFE8DF", -"4 c #716A61", -"5 c #FDFCFC", -"6 c #605D57", -"7 c #26221F", -"8 c #86735E", -"9 c #D5C0A0", -"0 c #C4AD8B", -"a c #F9E9D5", -"b c #C97138", -"c c #121110", -"d c #E9E8E7", -"e c #73604D", -"f c #332F29", -"g c #534C40", -"h c #D3BFA0", -"i c #D0BB98", -"j c #D0BA96", -"k c #F9E7D1", -"l c #CA773D", -"m c #090807", -"n c #B1B1AF", -"o c #FBFBF9", -"p c #CAB290", -"q c #D5C0A1", -"r c #D0BA97", -"s c #FBEFDF", -"t c #CB793E", -"u c #272625", -"v c #F4F4F4", -"w c #F4EFE7", -"x c #D0BA98", -"y c #CFB896", -"z c #F9EAD5", -"A c #CC793A", -"B c #0F0F0D", -"C c #100F0E", -"D c #494949", -"E c #FDFCFB", -"F c #DACBB0", -"G c #F5D9B4", -"H c #CA7537", -"I c #B79F80", -"J c #B0A693", -"K c #262525", -"L c #939292", -"M c #ECE3D5", -"N c #FBF3E8", -"O c #CA7337", -"P c #C7B08E", -"Q c #D3C2A5", -"R c #918776", -"S c #0B0A0A", -"T c #555453", -"U c #828282", -"V c #A09179", -"W c #897C67", -"X c #5B5245", -"Y c #191716", -"Z c #413E3C", -"` c #978368", -" . c #867C6A", -".. c #70685D", -"+. c #1C1B18", -"@. c #1D1C1A", -"#. c #575654", -"$. c #887B68", -"%. c #676055", -"&. c #141211", -"*. c #0F0F0E", -" ", -" . + @ @ ", -" @ # $ % & @ * * ", -" @ = - ; > , ' ) @ * ! ~ * ", -" { ] ^ / ( _ : < [ @ * } | 1 * ", -" 2 3 4 5 6 7 8 9 0 * a | b * ", -" c d e f g h i j * k | l * ", -" m n o p q r j * s | t * ", -" u v w x y * z | A * B ", -" C D E F * G | H * I J @ ", -" K L M * N O * P Q R S ", -" @ T * U * * V W X Y @ ", -" Z * * ` ...+.@ @ ", -" @.#.$.%.&.@ @ ", -" * *.@ @ ", -" @ @ "}; diff --git a/calendar/gui/task-recurring.xpm b/calendar/gui/task-recurring.xpm deleted file mode 100644 index b3c6126e03..0000000000 --- a/calendar/gui/task-recurring.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * task_recurring_xpm[] = { -"16 16 101 2", -" c None", -". c #0F0E0D", -"+ c #3B2F22", -"@ c #080808", -"# c #292623", -"$ c #CBBFAD", -"% c #BEA47E", -"& c #AD9A7E", -"* c #000000", -"= c #232221", -"- c #CDC8C1", -"; c #CBC5BF", -"> c #766D62", -", c #887053", -"' c #A38664", -") c #A49887", -"! c #F6DEBC", -"~ c #957D59", -"{ c #151211", -"] c #F3EFEA", -"^ c #BBB7B0", -"/ c #A69E97", -"( c #FEFEFE", -"_ c #F8F7F5", -": c #524C45", -"< c #BBA382", -"[ c #A59176", -"} c #F6DBB8", -"| c #E79E3C", -"1 c #CB783E", -"2 c #171716", -"3 c #EFE8DF", -"4 c #716A61", -"5 c #FDFCFC", -"6 c #605D57", -"7 c #26221F", -"8 c #86735E", -"9 c #D5C0A0", -"0 c #C4AD8B", -"a c #F9E9D5", -"b c #C97138", -"c c #121110", -"d c #E9E8E7", -"e c #73604D", -"f c #332F29", -"g c #534C40", -"h c #D3BFA0", -"i c #D0BB98", -"j c #D0BA96", -"k c #F9E7D1", -"l c #CA773D", -"m c #090807", -"n c #B1B1AF", -"o c #FBFBF9", -"p c #CAB290", -"q c #D5C0A1", -"r c #D0BA97", -"s c #FBEFDF", -"t c #CB793E", -"u c #272625", -"v c #F4F4F4", -"w c #F4EFE7", -"x c #D0BA98", -"y c #CFB896", -"z c #F9EAD5", -"A c #CC793A", -"B c #0F0F0D", -"C c #100F0E", -"D c #494949", -"E c #FDFCFB", -"F c #DACBB0", -"G c #F5D9B4", -"H c #CA7537", -"I c #B79F80", -"J c #B0A693", -"K c #262525", -"L c #939292", -"M c #ECE3D5", -"N c #FBF3E8", -"O c #CA7337", -"P c #C7B08E", -"Q c #D3C2A5", -"R c #918776", -"S c #0B0A0A", -"T c #555453", -"U c #828282", -"V c #A09179", -"W c #897C67", -"X c #5B5245", -"Y c #191716", -"Z c #413E3C", -"` c #978368", -" . c #867C6A", -".. c #70685D", -"+. c #1C1B18", -"@. c #1D1C1A", -"#. c #575654", -"$. c #887B68", -"%. c #676055", -"&. c #141211", -"*. c #0F0F0E", -" ", -" . + @ @ ", -" @ # $ % & @ * * ", -" @ = - ; > , ' ) @ * ! ~ * ", -" { ] ^ / ( _ : < [ @ * } | 1 * ", -" 2 3 4 5 6 7 8 9 0 * a | b * ", -" c d e f g h i j * k | l * ", -" m n o p q r j * s | t * ", -" u v w x y * z | A * B ", -" C D E F * G | H * I J @ ", -" K L M * N O * P Q R S ", -" @ T * U * * V W X Y @ ", -" Z * * ` ...+.@ @ ", -" @.#.$.%.&.@ @ ", -" * *.@ @ ", -" @ @ "}; diff --git a/calendar/gui/task.xpm b/calendar/gui/task.xpm deleted file mode 100644 index 8115025e20..0000000000 --- a/calendar/gui/task.xpm +++ /dev/null @@ -1,120 +0,0 @@ -/* XPM */ -static char * task_xpm[] = { -"16 16 101 2", -" c None", -". c #0F0E0D", -"+ c #3B2F22", -"@ c #080808", -"# c #292623", -"$ c #CBBFAD", -"% c #BEA47E", -"& c #AD9A7E", -"* c #000000", -"= c #232221", -"- c #CDC8C1", -"; c #CBC5BF", -"> c #766D62", -", c #887053", -"' c #A38664", -") c #A49887", -"! c #F6DEBC", -"~ c #957D59", -"{ c #151211", -"] c #F3EFEA", -"^ c #BBB7B0", -"/ c #A69E97", -"( c #FEFEFE", -"_ c #F8F7F5", -": c #524C45", -"< c #BBA382", -"[ c #A59176", -"} c #F6DBB8", -"| c #E79E3C", -"1 c #CB783E", -"2 c #171716", -"3 c #EFE8DF", -"4 c #716A61", -"5 c #FDFCFC", -"6 c #605D57", -"7 c #26221F", -"8 c #86735E", -"9 c #D5C0A0", -"0 c #C4AD8B", -"a c #F9E9D5", -"b c #C97138", -"c c #121110", -"d c #E9E8E7", -"e c #73604D", -"f c #332F29", -"g c #534C40", -"h c #D3BFA0", -"i c #D0BB98", -"j c #D0BA96", -"k c #F9E7D1", -"l c #CA773D", -"m c #090807", -"n c #B1B1AF", -"o c #FBFBF9", -"p c #CAB290", -"q c #D5C0A1", -"r c #D0BA97", -"s c #FBEFDF", -"t c #CB793E", -"u c #272625", -"v c #F4F4F4", -"w c #F4EFE7", -"x c #D0BA98", -"y c #CFB896", -"z c #F9EAD5", -"A c #CC793A", -"B c #0F0F0D", -"C c #100F0E", -"D c #494949", -"E c #FDFCFB", -"F c #DACBB0", -"G c #F5D9B4", -"H c #CA7537", -"I c #B79F80", -"J c #B0A693", -"K c #262525", -"L c #939292", -"M c #ECE3D5", -"N c #FBF3E8", -"O c #CA7337", -"P c #C7B08E", -"Q c #D3C2A5", -"R c #918776", -"S c #0B0A0A", -"T c #555453", -"U c #828282", -"V c #A09179", -"W c #897C67", -"X c #5B5245", -"Y c #191716", -"Z c #413E3C", -"` c #978368", -" . c #867C6A", -".. c #70685D", -"+. c #1C1B18", -"@. c #1D1C1A", -"#. c #575654", -"$. c #887B68", -"%. c #676055", -"&. c #141211", -"*. c #0F0F0E", -" ", -" . + @ @ ", -" @ # $ % & @ * * ", -" @ = - ; > , ' ) @ * ! ~ * ", -" { ] ^ / ( _ : < [ @ * } | 1 * ", -" 2 3 4 5 6 7 8 9 0 * a | b * ", -" c d e f g h i j * k | l * ", -" m n o p q r j * s | t * ", -" u v w x y * z | A * B ", -" C D E F * G | H * I J @ ", -" K L M * N O * P Q R S ", -" @ T * U * * V W X Y @ ", -" Z * * ` ...+.@ @ ", -" @.#.$.%.&.@ @ ", -" * *.@ @ ", -" @ @ "}; diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf deleted file mode 100644 index bfe93b3c14..0000000000 --- a/calendar/gui/test.vcf +++ /dev/null @@ -1,133 +0,0 @@ -BEGIN:VCALENDAR -PRODID:-//GNOME//NONSGML GnomeCalendar//EN -TZ:MST -VERSION:0.13 -BEGIN:VEVENT -UID:KOrganizer - 846930886 -SEQUENCE:1 -DTSTART:19980601T150000 -DTEND:19980601T150000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:Cada dos dias de 06/01 al 07/01 -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D2 19980701T140000 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 846930886 -SEQUENCE:1 -DTSTART:19980501T140000 -DTEND:19980501T140000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:5 dias. -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 846930886 -SEQUENCE:1 -DTSTART:19980501T140000 -DTEND:19980501T150000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980429T004635 -SUMMARY:Diariamente de 05/01 al 06/01 -STATUS:NEEDS ACTION -CLASS:PRIVATE -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 19980601T000000 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 1804289383 -SEQUENCE:1 -DTSTART:19980415T010000 -DTEND:19980415T013000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Diario durante 5 dias -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 1804289383 -SEQUENCE:1 -DTSTART:19980415T010000 -DTEND:19980415T013000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Diario durante 5 dias -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VTODO -UID:KOrganizer - 846930886 -SEQUENCE:1 -DTSTART:19980415T140000 -DUE:19691231T180000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:Normal -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -END:VTODO - -BEGIN:VTODO -UID:KOrganizer - 1804289383 -SEQUENCE:1 -DTSTART:19980415T120000 -DUE:19691231T180000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Semanal -- 4 semanas -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:W1 WE #4 -END:VTODO - -BEGIN:VTODO -UID:KOrganizer - 1804289383 -SEQUENCE:1 -DTSTART:19980415T003000 -DUE:19691231T180000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Semana: Mi, Ju, Vi, Dom (10 veces) -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:W1 SU WE TH FR #10 -END:VTODO - -END:VCALENDAR - diff --git a/calendar/gui/test2.vcf b/calendar/gui/test2.vcf deleted file mode 100644 index 6446507989..0000000000 --- a/calendar/gui/test2.vcf +++ /dev/null @@ -1,133 +0,0 @@ -BEGIN:VCALENDAR -PRODID:-//GNOME//NONSGML GnomeCalendar//EN -TZ:MST -VERSION:0.13 -BEGIN:VEVENT -UID:KOrganizer - 8469308861 -SEQUENCE:1 -DTSTART:19980601T150000 -DTEND:19980601T150000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:Cada dos dias de 06/01 al 07/01 -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D2 19980701T140000 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 8469308862 -SEQUENCE:1 -DTSTART:19980501T140000 -DTEND:19980501T140000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:5 dias. -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 8469308863 -SEQUENCE:1 -DTSTART:19980501T140000 -DTEND:19980501T150000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980429T004635 -SUMMARY:Diariamente de 05/01 al 06/01 -STATUS:NEEDS ACTION -CLASS:PRIVATE -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 19980601T000000 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 18042893834 -SEQUENCE:1 -DTSTART:19980415T010000 -DTEND:19980415T013000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Diario durante 5 dias -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VEVENT -UID:KOrganizer - 18042893835 -SEQUENCE:1 -DTSTART:19980415T010000 -DTEND:19980415T013000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Diario durante 5 dias -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:D1 #5 -END:VEVENT - -BEGIN:VTODO -UID:KOrganizer - 8469308866 -SEQUENCE:1 -DTSTART:19980415T140000 -DUE:19691231T180000 -DCREATED:19980402T023558 -LAST-MODIFIED:19980402T023558 -SUMMARY:Normal -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -END:VTODO - -BEGIN:VTODO -UID:KOrganizer - 18042893837 -SEQUENCE:1 -DTSTART:19980415T120000 -DUE:19691231T180000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Semanal -- 4 semanas -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:W1 WE #4 -END:VTODO - -BEGIN:VTODO -UID:KOrganizer - 18042893838 -SEQUENCE:1 -DTSTART:19980415T003000 -DUE:19691231T180000 -DCREATED:19980402T023552 -LAST-MODIFIED:19980330T225948 -SUMMARY:Semana: Mi, Ju, Vi, Dom (10 veces) -STATUS:NEEDS ACTION -CLASS:PUBLIC -PRIORITY:0 -TRANSP:0 -RELATED-TO:0 -RRULE:W1 SU WE TH FR #10 -END:VTODO - -END:VCALENDAR - diff --git a/calendar/gui/topic.dat b/calendar/gui/topic.dat deleted file mode 100644 index edc7813b26..0000000000 --- a/calendar/gui/topic.dat +++ /dev/null @@ -1,2 +0,0 @@ -gnome-cal.html Manual -gnome-cal.html#cmdline Command line options
\ No newline at end of file diff --git a/calendar/gui/weekview.xpm b/calendar/gui/weekview.xpm deleted file mode 100644 index f4900856eb..0000000000 --- a/calendar/gui/weekview.xpm +++ /dev/null @@ -1,41 +0,0 @@ -/* XPM */ -static char * weekview_xpm[] = { -"24 24 14 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #E3E4F5", -"$ c #8B90C3", -"% c #AAAFE2", -"& c #C7CAEB", -"* c #4550B5", -"= c #555FC5", -"- c #2E3BB1", -"; c #0010A8", -"> c #BABBCC", -", c #A3A6C7", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++@++@+#$%%$%+@++@++. ", -" .++@++@+&*==-;+@++@++. ", -" .@@@@@@@@@@@$;@@@@@@@. ", -" .++@++@++@+%;%+@++@++. ", -" .++@++@++@+%;%+@++@++. ", -" .@@@@@@@@@@-->@@@@@@@. ", -" .++@++@++@+;*++@++@++. ", -" .++@++@++@+;*++@++@++. ", -" .@@@@@@@@@@$,@@@@@@@@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; diff --git a/calendar/gui/workweekview.xpm b/calendar/gui/workweekview.xpm deleted file mode 100644 index f47061589c..0000000000 --- a/calendar/gui/workweekview.xpm +++ /dev/null @@ -1,43 +0,0 @@ -/* XPM */ -static char * workweekview_xpm[] = { -"24 24 16 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #E3E4F5", -"$ c #8B90C3", -"% c #AAAFE2", -"& c #0010A8", -"* c #3945BB", -"= c #555FC5", -"- c #4550B5", -"; c #727ACE", -"> c #C7CAEB", -", c #2E3BB1", -"' c #5D66BA", -") c #BABBCC", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++@++@+#$%%$%+@++@++. ", -" .++@++@+%&*=-=+@++@++. ", -" .@@@@@@@$&$@@@@@@@@@@. ", -" .++@++@+%&;%$#+@++@++. ", -" .++@++@+>-==,;+@++@++. ", -" .@@@@@@@@@@@$&@@@@@@@. ", -" .++@++@+#$#+$&+@++@++. ", -" .++@++@+>,;%'*+@++@++. ", -" .@@@@@@@@)$$$)@@@@@@@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; diff --git a/calendar/gui/yearview.xpm b/calendar/gui/yearview.xpm deleted file mode 100644 index 9629150417..0000000000 --- a/calendar/gui/yearview.xpm +++ /dev/null @@ -1,45 +0,0 @@ -/* XPM */ -static char * yearview_xpm[] = { -"24 24 18 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #D1D1D1", -"# c #BABBCC", -"$ c #AAAFE2", -"% c #8B90C3", -"& c #E3E4F5", -"* c #C7CAEB", -"= c #5D66BA", -"- c #3945BB", -"; c #555FC5", -"> c #2E3BB1", -", c #727ACE", -"' c #4550B5", -") c #0010A8", -"! c #A3A6C7", -"~ c #8E95D8", -" ", -" ", -" ", -" ", -" ...................... ", -" .............+.++.++.. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" .@@@@@@@@@@@@@@@@@@@@. ", -" .++#$$%&+@*$%&&%$$%$+. ", -" .+&=-;>,+#-;'*$)-;';+. ", -" .@%)%@%)!>=@@@%)%@@@@. ", -" .++@*$=-$),$%&$),$%&+. ", -" .++@~;>,$)-;>,*';;>,+. ", -" .@@@@@%)%)%@%)@@@@%)@. ", -" .+$)$+%)$)$+%)&%&+%)+. ", -" .+*>,$=-*>,$=-*>,$=-+. ", -" .@@#%%%#@#%%%#@#%%%#@. ", -" .++@++@++@++@++@++@++. ", -" .++@++@++@++@++@++@++. ", -" ...................... ", -" ", -" ", -" "}; |