aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamon Chaplin <damon@helixcode.com>2000-05-06 18:56:58 +0800
committerDamon Chaplin <damon@src.gnome.org>2000-05-06 18:56:58 +0800
commitc827b0e2b1199d1808fef231e2f79af75dac1234 (patch)
treec76a2d6ba32216e3fbc6f8ad51b331fb62f20a9c
parentab3408927461d33221119be8f7cb2884f0b0eb05 (diff)
downloadgsoc2013-evolution-c827b0e2b1199d1808fef231e2f79af75dac1234.tar
gsoc2013-evolution-c827b0e2b1199d1808fef231e2f79af75dac1234.tar.gz
gsoc2013-evolution-c827b0e2b1199d1808fef231e2f79af75dac1234.tar.bz2
gsoc2013-evolution-c827b0e2b1199d1808fef231e2f79af75dac1234.tar.lz
gsoc2013-evolution-c827b0e2b1199d1808fef231e2f79af75dac1234.tar.xz
gsoc2013-evolution-c827b0e2b1199d1808fef231e2f79af75dac1234.tar.zst
gsoc2013-evolution-c827b0e2b1199d1808fef231e2f79af75dac1234.zip
removed old calendar view files.
2000-05-06 Damon Chaplin <damon@helixcode.com> * gui/gncal-day-panel.[hc]: * gui/gncal-day-view.[hc]: * gui/gncal-full-day.[hc]: * gui/gncal-week-view.[hc]: * gui/layout.[hc]: * gui/view-utils.[hc]: removed old calendar view files. svn path=/trunk/; revision=2825
-rw-r--r--calendar/ChangeLog9
-rw-r--r--calendar/gui/gncal-day-panel.c276
-rw-r--r--calendar/gui/gncal-day-panel.h66
-rw-r--r--calendar/gui/gncal-day-view.c414
-rw-r--r--calendar/gui/gncal-day-view.h56
-rw-r--r--calendar/gui/gncal-full-day.c2321
-rw-r--r--calendar/gui/gncal-full-day.h74
-rw-r--r--calendar/gui/gncal-week-view.c255
-rw-r--r--calendar/gui/gncal-week-view.h57
-rw-r--r--calendar/gui/layout.c288
-rw-r--r--calendar/gui/layout.h37
-rw-r--r--calendar/gui/view-utils.c203
-rw-r--r--calendar/gui/view-utils.h28
13 files changed, 9 insertions, 4075 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 397b9c43d8..4da5967660 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,14 @@
2000-05-06 Damon Chaplin <damon@helixcode.com>
+ * gui/gncal-day-panel.[hc]:
+ * gui/gncal-day-view.[hc]:
+ * gui/gncal-full-day.[hc]:
+ * gui/gncal-week-view.[hc]:
+ * gui/layout.[hc]:
+ * gui/view-utils.[hc]: removed old calendar view files.
+
+2000-05-06 Damon Chaplin <damon@helixcode.com>
+
* cal-util/calobj.[hc]: added guint ref_count to iCalObject struct,
and ical_object_ref/unref() functions. I've updated all the gui/
stuff to use ref_counts but I haven't touched the pcs/ stuff. Maybe
diff --git a/calendar/gui/gncal-day-panel.c b/calendar/gui/gncal-day-panel.c
deleted file mode 100644
index d0556f5d94..0000000000
--- a/calendar/gui/gncal-day-panel.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <gtk/gtkhseparator.h>
-#include <cal-util/timeutil.h>
-#include "gncal-day-panel.h"
-#include "calendar-commands.h"
-
-
-guint
-gncal_day_panel_get_type (void)
-{
- static guint day_panel_type = 0;
-
- if (!day_panel_type) {
- GtkTypeInfo day_panel_info = {
- "GncalDayPanel",
- sizeof (GncalDayPanel),
- sizeof (GncalDayPanelClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) NULL,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_panel_type = gtk_type_unique (gtk_table_get_type (), &day_panel_info);
- }
-
- return day_panel_type;
-}
-
-static void
-day_view_range_activated (GncalFullDay *fullday, GncalDayPanel *dpanel)
-{
- iCalObject *ical;
-
- ical = ical_new ("", user_name, "");
- ical->new = 1;
-
- gncal_full_day_selection_range (fullday, &ical->dtstart, &ical->dtend);
-
- gnome_calendar_add_object (dpanel->calendar, ical);
- gncal_full_day_focus_child (fullday, ical);
-}
-
-static void
-full_day_size_allocated (GtkWidget *widget, GtkAllocation *allocation, GncalDayPanel *dpanel)
-{
- GtkAdjustment *adj;
- int yoffset;
- gfloat newval;
-
- adj = gtk_scrolled_window_get_vadjustment (dpanel->fullday_sw);
-
- yoffset = gncal_full_day_get_day_start_yoffset (GNCAL_FULL_DAY (widget));
-
- newval = adj->lower + (adj->upper - adj->lower) * (double) yoffset / allocation->height;
- if (newval != adj->value)
- gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
-}
-
-static void
-calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- 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 (dpanel->calendar, mktime (&tm));
-}
-
-static void
-retag_calendar (GtkCalendar *calendar, GncalDayPanel *dpanel)
-{
- gnome_calendar_tag_calendar (dpanel->calendar, GTK_CALENDAR (dpanel->gtk_calendar));
-}
-
-GtkWidget *
-gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day)
-{
- GncalDayPanel *dpanel;
- GtkWidget *w;
- GtkWidget *hpane, *vpane;
- gint start_pos = 265;
- struct tm tm;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dpanel = gtk_type_new (gncal_day_panel_get_type ());
-
- gtk_container_border_width (GTK_CONTAINER (dpanel), 4);
- gtk_table_set_row_spacings (GTK_TABLE (dpanel), 4);
- gtk_table_set_col_spacings (GTK_TABLE (dpanel), 4);
-
- dpanel->calendar = calendar;
-
- /* Date label */
-
- w = gtk_label_new ("");
- dpanel->date_label = GTK_LABEL (w);
- gtk_table_attach (GTK_TABLE (dpanel), w,
- 0, 1, 0, 1,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
- gtk_widget_show (w);
-
- /* Create horizontal pane */
-
- hpane = gtk_hpaned_new ();
- gtk_table_attach (GTK_TABLE (dpanel), hpane,
- 0, 1, 2, 4,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- /* Full day */
-
- w = gtk_scrolled_window_new (NULL, NULL);
- dpanel->fullday_sw = GTK_SCROLLED_WINDOW (w);
- gtk_scrolled_window_set_policy (dpanel->fullday_sw,
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_paned_pack1 (GTK_PANED (hpane), w, FALSE, TRUE);
- /*gtk_paned_add1 (GTK_PANED (hpane), w);*/
- gtk_widget_show (w);
-
- w = gncal_full_day_new (calendar, time_day_begin (start_of_day), time_day_end (start_of_day));
- dpanel->fullday = GNCAL_FULL_DAY (w);
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "range_activated",
- (GtkSignalFunc) day_view_range_activated,
- dpanel);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (dpanel->fullday_sw), w);
- gtk_widget_show (w);
-
- /* We'll scroll the list to the proper initial position */
-
- gtk_signal_connect (GTK_OBJECT (dpanel->fullday), "size_allocate",
- (GtkSignalFunc) full_day_size_allocated,
- dpanel);
-
- /* Create vertical pane */
-
- vpane = gtk_vpaned_new ();
- gtk_paned_pack2 (GTK_PANED (hpane), GTK_WIDGET (vpane), TRUE, TRUE);
- /*gtk_paned_add2 (GTK_PANED (hpane), GTK_WIDGET (vpane));*/
-
- /* Gtk calendar */
-
- tm = *localtime (&start_of_day);
-
- w = gtk_calendar_new ();
- dpanel->gtk_calendar = GTK_CALENDAR (w);
- gtk_calendar_display_options (dpanel->gtk_calendar,
- (GTK_CALENDAR_SHOW_HEADING
- | GTK_CALENDAR_SHOW_DAY_NAMES
- | (week_starts_on_monday
- ? GTK_CALENDAR_WEEK_START_MONDAY : 0)));
- gtk_calendar_select_month (dpanel->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
- gtk_calendar_select_day (dpanel->gtk_calendar, tm.tm_mday);
- dpanel->day_selected_id = gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar),
- "day_selected_double_click",
- (GtkSignalFunc) calendar_day_selected,
- dpanel);
- gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC (retag_calendar), dpanel);
- gtk_paned_add1 (GTK_PANED (vpane), w);
- gtk_widget_show (w);
-
- /* To-do */
-
- w = gncal_todo_new (calendar);
- dpanel->todo = GNCAL_TODO (w);
- gtk_paned_add2 (GTK_PANED (vpane), w);
- gtk_widget_show (w);
-
- /* Done */
-
- gncal_day_panel_set (dpanel, start_of_day);
-
- gtk_paned_set_position (GTK_PANED (hpane), start_pos);
-
- return GTK_WIDGET (dpanel);
-}
-
-static void
-update (GncalDayPanel *dpanel, int update_fullday, iCalObject *ico, int flags)
-{
- char buf [80];
-
- if (update_fullday){
- gncal_full_day_update (dpanel->fullday, ico, flags);
- retag_calendar (dpanel->gtk_calendar, dpanel);
- }
- gncal_todo_update (dpanel->todo, ico, flags);
-
- strftime (buf, sizeof (buf), _("%a %b %d %Y"), localtime (&dpanel->start_of_day));
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-}
-
-void
-gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- update (dpanel, TRUE, ico, flags);
-}
-
-void
-gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day)
-{
- char buf[80];
- struct tm tm;
-
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- dpanel->start_of_day = time_day_begin(start_of_day);
- if (dpanel->fullday->lower == dpanel->start_of_day)
- return;
-
- tm = *localtime (&dpanel->start_of_day);
- strftime (buf, sizeof (buf), _("%a %b %d %Y"), &tm);
- gtk_label_set (GTK_LABEL (dpanel->date_label), buf);
-
- gncal_full_day_set_bounds (dpanel->fullday, dpanel->start_of_day, time_day_end (dpanel->start_of_day));
-
- gtk_calendar_select_month (dpanel->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- gtk_signal_handler_block (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
- gtk_calendar_select_day (dpanel->gtk_calendar, tm.tm_mday);
- gtk_signal_handler_unblock (GTK_OBJECT (dpanel->gtk_calendar), dpanel->day_selected_id);
-
- update (dpanel, FALSE, NULL, 0);
-}
-
-void
-gncal_day_panel_time_format_changed (GncalDayPanel *dpanel)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- gtk_calendar_display_options (dpanel->gtk_calendar,
- (week_starts_on_monday
- ? (dpanel->gtk_calendar->display_flags
- | GTK_CALENDAR_WEEK_START_MONDAY)
- : (dpanel->gtk_calendar->display_flags
- & ~GTK_CALENDAR_WEEK_START_MONDAY)));
-}
-
-void
-todo_list_properties_changed (GncalDayPanel *dpanel)
-{
- g_return_if_fail (dpanel != NULL);
- g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
-
- gncal_todo_update (dpanel->todo, NULL, 0);
-}
-
-
-
diff --git a/calendar/gui/gncal-day-panel.h b/calendar/gui/gncal-day-panel.h
deleted file mode 100644
index cb1fba5a5a..0000000000
--- a/calendar/gui/gncal-day-panel.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Day view notebook panel for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_PANEL_H
-#define GNCAL_DAY_PANEL_H
-
-#include <gtk/gtkcalendar.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktable.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gncal-full-day.h"
-#include "gncal-todo.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_PANEL(obj) GTK_CHECK_CAST (obj, gncal_day_panel_get_type (), GncalDayPanel)
-#define GNCAL_DAY_PANEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_panel_get_type (), GncalDayPanelClass)
-#define GNCAL_IS_DAY_PANEL(obj) GTK_CHECK_TYPE (obj, gncal_day_panel_get_type ())
-
-
-typedef struct _GncalDayPanel GncalDayPanel;
-typedef struct _GncalDayPanelClass GncalDayPanelClass;
-
-struct _GncalDayPanel {
- GtkTable table;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t start_of_day;
-
- GtkLabel *date_label;
- GncalFullDay *fullday;
- GtkScrolledWindow *fullday_sw;
- GtkCalendar *gtk_calendar;
- GncalTodo *todo;
-
- guint day_selected_id;
-};
-
-struct _GncalDayPanelClass {
- GtkTableClass parent_class;
-};
-
-
-guint gncal_day_panel_get_type (void);
-GtkWidget *gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day);
-
-void gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags);
-void gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day);
-void gncal_day_panel_time_format_changed (GncalDayPanel *dpanel);
-
-void todo_list_properties_changed (GncalDayPanel *dpanel);
-
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c
deleted file mode 100644
index 54347c52b8..0000000000
--- a/calendar/gui/gncal-day-view.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <gnome.h>
-#include "gncal-day-view.h"
-#include <cal-util/timeutil.h>
-#include "view-utils.h"
-#include "calendar-commands.h"
-#include "eventedit.h"
-#include "popup-menu.h"
-#include "quick-view.h"
-
-#define TEXT_BORDER 2
-#define MIN_INFO_WIDTH 50
-
-
-static void gncal_day_view_class_init (GncalDayViewClass *class);
-static void gncal_day_view_init (GncalDayView *dview);
-static void gncal_day_view_destroy (GtkObject *object);
-static void gncal_day_view_realize (GtkWidget *widget);
-static void gncal_day_view_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static gint gncal_day_view_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_day_view_button_press (GtkWidget *widget,
- GdkEventButton *event);
-
-
-static GtkWidgetClass *parent_class;
-
-
-guint
-gncal_day_view_get_type (void)
-{
- static guint day_view_type = 0;
-
- if (!day_view_type) {
- GtkTypeInfo day_view_info = {
- "GncalDayView",
- sizeof (GncalDayView),
- sizeof (GncalDayViewClass),
- (GtkClassInitFunc) gncal_day_view_class_init,
- (GtkObjectInitFunc) gncal_day_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- day_view_type = gtk_type_unique (gtk_widget_get_type (), &day_view_info);
- }
-
- return day_view_type;
-}
-
-static void
-gncal_day_view_class_init (GncalDayViewClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gtk_widget_get_type ());
-
- object_class->destroy = gncal_day_view_destroy;
-
- widget_class->realize = gncal_day_view_realize;
- widget_class->size_request = gncal_day_view_size_request;
- widget_class->expose_event = gncal_day_view_expose;
- widget_class->button_press_event = gncal_day_view_button_press;
-}
-
-static void
-gncal_day_view_init (GncalDayView *dview)
-{
- GTK_WIDGET_UNSET_FLAGS (dview, GTK_NO_WINDOW);
-
- dview->calendar = NULL;
-
- dview->lower = 0;
- dview->upper = 0;
-
- dview->shadow_type = GTK_SHADOW_ETCHED_IN;
-}
-
-static void
-gncal_day_view_destroy (GtkObject *object)
-{
- GncalDayView *dview;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (object));
-
- dview = GNCAL_DAY_VIEW (object);
-
- if (dview->day_str)
- g_free (dview->day_str);
- /* DELETE
- if (dview->events)
- calendar_destroy_event_list (dview->events);
- */
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static int
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalDayView *dayview = GNCAL_DAY_VIEW (data);
- iCalObject *ico;
- GtkWidget *ee;
- struct tm tm;
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- tm = *localtime (&dayview->lower);
- tm.tm_hour = day_begin;
- ico->dtstart = mktime (&tm);
- tm.tm_hour++;
- ico->dtend = mktime (&tm);
- ee = event_editor_new (dayview->calendar, ico);
- gtk_widget_show (ee);
- return 1;
-}
-
-static void
-context_menu (GncalDayView *dayview, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- main_items [0].data = dayview;
- popup_menu (main_items, 1, event);
-}
-
-static gint
-gncal_day_view_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalDayView *dayview;
-
- dayview = GNCAL_DAY_VIEW (widget);
-
- if (event->button == 3)
- context_menu (dayview, event);
-
- if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
- gnome_calendar_dayjump (dayview->calendar, dayview->lower);
-
-#if 0
- else if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
- time_t day_begin_time, day_end_time;
- GList *list;
- GtkWidget *qv;
- char date_str [256];
-
- strftime (date_str, sizeof (date_str), _("%a %b %d %Y"),
- localtime (&dayview->lower));
- qv = quick_view_new (dayview->calendar, date_str, dayview->events);
- quick_view_do_popup (QUICK_VIEW (qv), event);
- gtk_widget_destroy (qv);
- }
-#endif
-
- return TRUE;
-}
-
-GtkWidget *
-gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalDayView *dview;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- dview = gtk_type_new (gncal_day_view_get_type ());
-
- dview->calendar = calendar;
- dview->lower = lower;
- dview->upper = upper;
- dview->events = 0;
-
- gncal_day_view_update (dview, NULL, 0);
-
- return GTK_WIDGET (dview);
-}
-
-static void
-gncal_day_view_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-}
-
-static void
-gncal_day_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalDayView *dview;
- int str_width, width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (widget));
- g_return_if_fail (requisition != NULL);
-
- dview = GNCAL_DAY_VIEW (widget);
-
- /* border and min width */
-
- str_width = gdk_string_width (widget->style->font, dview->day_str);
-
- width = MAX (MIN_INFO_WIDTH, str_width);
-
- requisition->width = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + width;
- requisition->height = 2 * (widget->style->klass->ythickness + TEXT_BORDER);
-
- /* division line */
-
- requisition->height += 2 * TEXT_BORDER + widget->style->klass->ythickness;
-
- /* title and at least one line of text */
-
- requisition->height += 2 * (widget->style->font->ascent + widget->style->font->descent);
-}
-
-static gint
-gncal_day_view_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalDayView *dview;
- int x1, y1, width, height;
- GdkRectangle rect, dest;
- GdkFont *font;
- int str_width;
- GdkGC *gc;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_DAY_VIEW (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- gc = widget->style->fg_gc [GTK_STATE_NORMAL];
- dview = GNCAL_DAY_VIEW (widget);
-
- x1 = widget->style->klass->xthickness;
- y1 = widget->style->klass->ythickness;
- width = widget->allocation.width - 2 * x1;
- height = widget->allocation.height - 2 * y1;
-
- /* Clear and paint frame shadow */
-
- gdk_window_clear_area (widget->window,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, dview->shadow_type,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- /* Clear and paint title */
-
- font = widget->style->font;
-
- rect.x = x1;
- rect.y = y1;
- rect.width = width;
- rect.height = 2 * TEXT_BORDER + font->ascent + font->descent;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest)) {
- gdk_draw_rectangle (widget->window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- dest = rect;
-
- dest.x += TEXT_BORDER;
- dest.y += TEXT_BORDER;
- dest.width -= 2 * TEXT_BORDER;
- dest.height -= 2 * TEXT_BORDER;
-
- gdk_gc_set_clip_rectangle (gc, &dest);
-
- str_width = gdk_string_width (font, dview->day_str);
-
- gdk_draw_string (widget->window, font, gc,
- dest.x + (dest.width - str_width) / 2,
- dest.y + font->ascent,
- dview->day_str);
-
- gdk_gc_set_clip_rectangle (gc, NULL);
- }
-
- /* Division line */
-
- gtk_draw_hline (widget->style,
- widget->window,
- GTK_STATE_NORMAL,
- rect.x,
- rect.x + rect.width - 1,
- rect.y + rect.height);
-
- /* Text */
-
- if (dview->events != NULL){
- rect.x = x1 + TEXT_BORDER;
- rect.y = y1 + 3 * TEXT_BORDER +
- font->ascent + font->descent +
- widget->style->klass->ythickness;
- rect.width = width - 2 * TEXT_BORDER;
- rect.height = height - (rect.y - y1) - TEXT_BORDER;
-
- if (gdk_rectangle_intersect (&rect, &event->area, &dest))
- view_utils_draw_events (
- widget, widget->window, gc,
- &rect,
- VIEW_UTILS_DRAW_END | VIEW_UTILS_DRAW_SPLIT,
- dview->events,
- dview->lower,
- dview->upper);
- }
-
- return FALSE;
-}
-
-void
-gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
-{
- struct tm tm;
- char buf[256];
-
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if (dview->day_str)
- g_free (dview->day_str);
-
- tm = *localtime (&dview->lower);
- strftime (buf, sizeof (buf)-1, "%A %d", &tm);
- dview->day_str = g_strdup (buf);
-
- /*
- if (dview->events) DELETE
- calendar_destroy_event_list (dview->events);
- */
-
- dview->events = calendar_get_events_in_range (dview->calendar->client,
- dview->lower,
- dview->upper);
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
-}
-
-void
-gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if ((lower != dview->lower) || (upper != dview->upper)) {
- dview->lower = lower;
- dview->upper = upper;
-
- gncal_day_view_update (dview, NULL, 0);
- }
-}
-
-void
-gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type)
-{
- g_return_if_fail (dview != NULL);
- g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
-
- if (shadow_type != dview->shadow_type) {
- dview->shadow_type = shadow_type;
-
- gtk_widget_draw (GTK_WIDGET (dview), NULL);
- }
-}
diff --git a/calendar/gui/gncal-day-view.h b/calendar/gui/gncal-day-view.h
deleted file mode 100644
index dae1897fb6..0000000000
--- a/calendar/gui/gncal-day-view.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Day view widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_DAY_VIEW_H
-#define GNCAL_DAY_VIEW_H
-
-
-#include <gtk/gtkwidget.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_DAY_VIEW(obj) GTK_CHECK_CAST (obj, gncal_day_view_get_type (), GncalDayView)
-#define GNCAL_DAY_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_day_view_get_type (), GncalDayViewClass)
-#define GNCAL_IS_DAY_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_day_view_get_type ())
-
-
-typedef struct _GncalDayView GncalDayView;
-typedef struct _GncalDayViewClass GncalDayViewClass;
-
-struct _GncalDayView {
- GtkWidget widget;
-
- GnomeCalendar *calendar;/* the calendar we are associated to */
-
- time_t lower; /* lower and upper times to display */
- time_t upper; /* these include the full day */
-
- char *day_str; /* what day is it? */
- GList *events; /* the events for the this day */
- GtkShadowType shadow_type;
-};
-
-struct _GncalDayViewClass {
- GtkWidgetClass parent_class;
-};
-
-
-guint gncal_day_view_get_type (void);
-GtkWidget *gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags);
-void gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper);
-
-void gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
deleted file mode 100644
index de3372b55f..0000000000
--- a/calendar/gui/gncal-full-day.c
+++ /dev/null
@@ -1,2321 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-#include <config.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
-#include <gnome.h>
-#include "eventedit.h"
-#include "gncal-full-day.h"
-#include "view-utils.h"
-#include "layout.h"
-#include "calendar-commands.h"
-#include "popup-menu.h"
-
-/* Images */
-#include "bell.xpm"
-#include "recur.xpm"
-
-#define TEXT_BORDER 2
-#define HANDLE_SIZE 8
-#define MIN_WIDTH 200
-#define XOR_RECT_WIDTH 2
-#define UNSELECT_TIMEOUT 0 /* ms */
-
-/* Size of the pixmaps */
-#define DECOR_WIDTH 16
-#define DECOR_HEIGHT 16
-
-typedef struct {
- iCalObject *ico;
- GtkWidget *widget;
- GdkWindow *window;
- GdkWindow *decor_window;
- guint focus_out_id;
- int lower_row; /* zero is first displayed row */
- int rows_used;
- int x; /* coords of child's window */
- int y;
- int width;
- int height;
- int decor_width;
- int decor_height;
- int items; /* number of decoration bitmaps */
- time_t start, end;
-} Child;
-
-struct drag_info {
- enum {
- DRAG_NONE,
- DRAG_SELECT, /* selecting a range in the main window */
- DRAG_MOVE, /* moving a child */
- DRAG_SIZE_TOP, /* resizing a child */
- DRAG_SIZE_BOTTOM
- } drag_mode;
-
- Child *child;
- int child_click_y;
- int child_start_row;
- int child_rows_used;
-
- int sel_click_row;
- int sel_start_row;
- int sel_rows_used;
- guint32 click_time;
-};
-
-
-enum {
- RANGE_ACTIVATED,
- LAST_SIGNAL
-};
-
-
-static void gncal_full_day_class_init (GncalFullDayClass *class);
-static void gncal_full_day_init (GncalFullDay *fullday);
-static void gncal_full_day_destroy (GtkObject *object);
-static void gncal_full_day_map (GtkWidget *widget);
-static void gncal_full_day_unmap (GtkWidget *widget);
-static void gncal_full_day_realize (GtkWidget *widget);
-static void gncal_full_day_unrealize (GtkWidget *widget);
-static void gncal_full_day_draw (GtkWidget *widget,
- GdkRectangle *area);
-static void gncal_full_day_draw_focus (GtkWidget *widget);
-static void gncal_full_day_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gncal_full_day_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint gncal_full_day_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gint gncal_full_day_motion (GtkWidget *widget,
- GdkEventMotion *event);
-static gint gncal_full_day_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gncal_full_day_key_press (GtkWidget *widget,
- GdkEventKey *event);
-static gint gncal_full_day_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint gncal_full_day_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-static void gncal_full_day_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-static void range_activated (GncalFullDay *fullday);
-
-static GtkContainerClass *parent_class;
-
-static int fullday_signals[LAST_SIGNAL] = { 0 };
-
-/* The little images */
-static GdkPixmap *pixmap_bell, *pixmap_recur;
-
-static void
-get_tm_range (GncalFullDay *fullday,
- time_t time_lower, time_t time_upper,
- struct tm *lower, struct tm *upper,
- int *lower_row, int *rows_used)
-{
- struct tm tm_lower, tm_upper;
- int lmin, umin;
- int lrow;
-
- /* Lower */
-
- tm_lower = *localtime (&time_lower);
-
- if ((tm_lower.tm_min % fullday->interval) != 0) {
- tm_lower.tm_min -= tm_lower.tm_min % fullday->interval; /* round down */
- mktime (&tm_lower);
- }
-
- /* Upper */
-
- tm_upper = *localtime (&time_upper);
-
- if ((tm_upper.tm_min % fullday->interval) != 0) {
- tm_upper.tm_min += fullday->interval - (tm_upper.tm_min % fullday->interval); /* round up */
- mktime (&tm_upper);
- }
-
- if (lower)
- *lower = tm_lower;
-
- if (upper)
- *upper = tm_upper;
-
- lmin = 60 * tm_lower.tm_hour + tm_lower.tm_min;
- umin = 60 * tm_upper.tm_hour + tm_upper.tm_min;
-
- if (umin == 0) /* midnight of next day? */
- umin = 60 * 24;
-
- lrow = lmin / fullday->interval;
-
- if (lower_row)
- *lower_row = lrow;
-
- if (rows_used)
- *rows_used = (umin - lmin) / fullday->interval;
-}
-
-static void
-child_map (GncalFullDay *fullday, Child *child)
-{
- gdk_window_show (child->window);
- if (child->decor_width)
- gdk_window_show (child->decor_window);
- gtk_widget_show (child->widget); /* OK, not just a map... */
-}
-
-static void
-child_unmap (GncalFullDay *fullday, Child *child)
-{
- gdk_window_hide (child->window);
- gdk_window_hide (child->decor_window);
- if (GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
-}
-
-static void
-child_set_text_pos (Child *child)
-{
- GtkAllocation allocation;
- int has_focus;
- int handle_size;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- handle_size = (child->ico->recur) ? 0 : HANDLE_SIZE;
-
- allocation.x = handle_size;
- allocation.y = has_focus ? handle_size : 0;
- allocation.width = child->width - handle_size - child->decor_width;
- allocation.height = child->height - (has_focus ? (2 * handle_size) : 0);
-
- gtk_widget_size_request (child->widget, NULL);
- gtk_widget_size_allocate (child->widget, &allocation);
-}
-
-static void
-child_realize (GncalFullDay *fullday, Child *child)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkWidget *widget;
- GdkColor c;
-
- widget = GTK_WIDGET (fullday);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = child->x;
- attributes.y = child->y;
- attributes.width = child->width - child->decor_width;;
- attributes.height = child->height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.cursor = fullday->up_down_cursor;
- attributes.event_mask = (GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_KEY_PRESS_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR;
- child->window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_window_set_user_data (child->window, widget);
- gtk_style_set_background (widget->style, child->window, GTK_STATE_NORMAL);
- gtk_widget_set_parent_window (child->widget, child->window);
-
- /* Create the decoration window */
- attributes.x = child->x + child->width - child->decor_width;
- attributes.width = child->decor_width ? child->decor_width : 1;
- attributes.height = child->decor_height ? child->decor_height : 1;
- attributes.visual = gdk_imlib_get_visual ();
- attributes.colormap = gdk_imlib_get_colormap ();
- attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- child->decor_window = gdk_window_new (widget->window, &attributes, attributes_mask);
- gdk_color_white (gdk_imlib_get_colormap (), &c);
- gdk_window_set_background (child->decor_window, &c);
- gdk_window_set_user_data (child->decor_window, widget);
-
- /*
- if (!pixmap_bell){
- GdkImlibImage *imlib_bell, *imlib_recur;
- GdkPixmap *mask;
-
- imlib_bell = gdk_imlib_create_image_from_xpm_data (bell_xpm);
- gdk_imlib_render (imlib_bell, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_bell = gdk_imlib_move_image (imlib_bell);
- mask = gdk_imlib_move_mask (imlib_bell);
- gdk_imlib_destroy_image (imlib_bell);
- fullday->bell_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->bell_gc, mask);
-
- imlib_recur = gdk_imlib_create_image_from_xpm_data (recur_xpm);
- gdk_imlib_render (imlib_recur, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_recur = gdk_imlib_move_image (imlib_recur);
- mask = gdk_imlib_move_mask (imlib_recur);
- gdk_imlib_destroy_image (imlib_recur);
- fullday->recur_gc = gdk_gc_new (child->decor_window);
- if (mask)
- gdk_gc_set_clip_mask (fullday->recur_gc, mask);
- }
- */
-
- if (!pixmap_bell){
- GdkPixmap *mask;
-
- GdkImlibImage *imlib_bell;
- GdkImlibImage *imlib_recur;
-
- imlib_bell = gdk_imlib_create_image_from_xpm_data (bell_xpm);
- gdk_imlib_render (imlib_bell, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_bell = gdk_imlib_move_image (imlib_bell);
-
- mask = gdk_imlib_move_mask (imlib_bell);
- gdk_imlib_destroy_image (imlib_bell);
-
- imlib_recur = gdk_imlib_create_image_from_xpm_data (recur_xpm);
- gdk_imlib_render (imlib_recur, DECOR_WIDTH, DECOR_HEIGHT);
- pixmap_recur = gdk_imlib_move_image (imlib_recur);
- mask = gdk_imlib_move_mask (imlib_recur);
- gdk_imlib_destroy_image (imlib_recur);
- }
-
-#warning "fix this"
-
- fullday->bell_gc = gdk_gc_new (child->decor_window);
- /*
- if (mask)
- gdk_gc_set_clip_mask (fullday->bell_gc, mask);
- */
-
- fullday->recur_gc = gdk_gc_new (child->decor_window);
- /*
- if (mask)
- gdk_gc_set_clip_mask (fullday->recur_gc, mask);
- */
-
- child_set_text_pos (child);
-}
-
-static void
-child_unrealize (GncalFullDay *fullday, Child *child)
-{
- if (GTK_WIDGET_REALIZED (child->widget))
- gtk_widget_unrealize (child->widget);
-
- gdk_window_set_user_data (child->window, NULL);
- gdk_window_destroy (child->window);
- child->window = NULL;
-}
-
-static void
-child_draw_decor (GncalFullDay *fullday, Child *child)
-{
- iCalObject *ico = child->ico;
- int ry = 0;
-
- if (ico->recur) {
- gdk_gc_set_clip_origin (fullday->recur_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->recur_gc,
- pixmap_recur,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-
- if (ico->dalarm.enabled || ico->malarm.enabled || ico->palarm.enabled || ico->aalarm.enabled) {
- gdk_gc_set_clip_origin (fullday->bell_gc, 0, ry);
- gdk_draw_pixmap (child->decor_window,
- fullday->bell_gc,
- pixmap_bell,
- 0, 0,
- 0, ry,
- DECOR_WIDTH, DECOR_HEIGHT);
- ry += DECOR_HEIGHT;
- }
-}
-
-static void
-child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, GdkWindow *window, int draw_child)
-{
- GdkRectangle arect, rect, dest;
- int has_focus;
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (!window || (window == child->window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->width;
- arect.height = child->height;
-
- area = &arect;
- }
-
- /* Left handle */
-
- rect.x = 0;
- rect.y = has_focus ? HANDLE_SIZE : 0;
- rect.width = HANDLE_SIZE;
- rect.height = has_focus ? (child->height - 2 * HANDLE_SIZE) : child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT);
-
- if (has_focus) {
- /* Top handle */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = child->width - child->decor_width;
- rect.height = HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
-
- /* Bottom handle */
-
- rect.y = child->height - HANDLE_SIZE;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window,
- &rect, GTK_SHADOW_OUT);
- }
-
- } else if (!window || (window == child->decor_window)) {
- if (!area) {
- arect.x = 0;
- arect.y = 0;
- arect.width = child->decor_width;
- arect.height = child->decor_height;
-
- area = &arect;
- }
-
- child_draw_decor (fullday, child);
- }
-
- if (draw_child)
- gtk_widget_draw (child->widget, NULL);
-}
-
-static void
-child_range_changed (GncalFullDay *fullday, Child *child)
-{
- struct tm start, end;
- int lower_row, rows_used;
- int f_lower_row;
-
- /* Calc display range for event */
-
- get_tm_range (fullday, child->start, child->end, &start, &end, &lower_row, &rows_used);
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, &f_lower_row, NULL);
-
- child->lower_row = lower_row - f_lower_row;
- child->rows_used = rows_used;
-}
-
-static void
-new_appointment (GtkWidget *widget, gpointer data)
-{
- GncalFullDay *fullday;
- GtkWidget *ee;
- iCalObject *ico;
-
- fullday = GNCAL_FULL_DAY (data);
-
- ico = ical_new ("", user_name, "");
- ico->new = 1;
-
- gncal_full_day_selection_range (fullday, &ico->dtstart, &ico->dtend);
- ee = event_editor_new (fullday->calendar, ico);
- gtk_widget_show (ee);
-}
-
-static void
-edit_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GtkWidget *ee;
-
- child = data;
-
- ee = event_editor_new (GNCAL_FULL_DAY (child->widget->parent)->calendar, child->ico);
- gtk_widget_show (ee);
-}
-
-static void
-delete_occurance (GtkWidget *widget, gpointer data)
-{
- Child *child = data;
- iCalObject *ical;
- time_t *t;
- GnomeCalendar *gcal = GNCAL_FULL_DAY (child->widget->parent)->calendar;
-
- child = data;
- ical = child->ico;
- t = g_new(time_t, 1);
- *t = child->start;
- ical->exdate = g_list_prepend(ical->exdate, t);
- gnome_calendar_object_changed (gcal, child->ico, CHANGE_DATES);
-
-}
-
-static void
-delete_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- gnome_calendar_remove_object (fullday->calendar, child->ico);
-}
-
-static void
-unrecur_appointment (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- iCalObject *new;
-
- child = data;
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- /* New object */
- new = ical_object_duplicate (child->ico);
- g_free (new->recur);
- new->recur = 0;
- new->dtstart = child->start;
- new->dtend = child->end;
-
- /* Duplicate, and eliminate the recurrency fields */
- ical_object_add_exdate (child->ico, child->start);
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_ALL);
-
- gnome_calendar_add_object (fullday->calendar, new);
-}
-
-static void
-child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
-{
- int sensitive, items;
- struct menu_item *context_menu;
-
- static struct menu_item child_items[] = {
- { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
- { N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
- { NULL, NULL, NULL, TRUE },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- static struct menu_item recur_child_items[] = {
- { N_("Make this appointment movable"), (GtkSignalFunc) unrecur_appointment, NULL, TRUE },
- { N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
- { N_("Delete this occurance"), (GtkSignalFunc) delete_occurance, NULL, TRUE },
- { N_("Delete all occurances"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
- { NULL, NULL, NULL, TRUE },
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- sensitive = (child->ico->user_data == NULL);
-
- if (child->ico->recur){
- items = 6;
- context_menu = &recur_child_items[0];
- context_menu[2].data = child;
- context_menu[3].data = child;
- context_menu[3].sensitive = sensitive;
- context_menu[4].data = fullday;
- context_menu[5].data = fullday;
- } else {
- items = 4;
- context_menu = &child_items[0];
- context_menu[3].data = fullday;
- }
- /* These settings are common for each context sensitive menu */
- context_menu[0].data = child;
- context_menu[1].data = child;
- context_menu[0].sensitive = sensitive;
- context_menu[1].sensitive = sensitive;
- context_menu[2].sensitive = sensitive;
-
- popup_menu (context_menu, items, event);
-}
-
-static void
-child_realized_setup (GtkWidget *widget, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gdk_window_set_cursor (widget->window, fullday->beam_cursor);
-}
-
-static void
-child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int height)
-{
- const int decor_width = child->decor_width;
-
- child->x = x;
- child->y = y;
- child->width = width;
- child->height = height;
-
- if (!child->window) /* realized? */
- return;
-
- child_set_text_pos (child);
- gdk_window_move_resize (child->window, x, y, width - decor_width, height);
-
- if (decor_width){
- gdk_window_move_resize (child->decor_window, x + width - decor_width, y,
- decor_width, child->decor_height);
- }
-}
-
-static int
-calc_row_height (GncalFullDay *fullday)
-{
- int f_rows;
- GtkWidget *widget;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- widget = GTK_WIDGET (fullday);
-
- return (widget->allocation.height - 2 * widget->style->klass->ythickness) / f_rows;
-}
-
-static void
-child_set_size (Child *child)
-{
- int row_height;
- int x, y, width, height;
- GncalFullDay *fullday;
-
- fullday = GNCAL_FULL_DAY (child->widget->parent);
-
- row_height = calc_row_height (fullday);
-
- x = child->x;
- y = child->lower_row * row_height + GTK_WIDGET (fullday)->style->klass->ythickness;
- width = child->width;
- height = child->rows_used * row_height;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget) && !child->ico->recur) {
- y -= HANDLE_SIZE;
- height += 2 * HANDLE_SIZE;
- }
-
- child_set_pos (fullday, child, x, y, width, height);
-}
-
-static gint
-child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- child_set_size (data);
- return FALSE;
-}
-
-static gint
-child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
- char *text;
-
- child = data;
-
- child_set_size (child);
-
- /* Update summary in calendar object */
-
- text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
- if (child->ico->summary && strcmp (text, child->ico->summary) == 0)
- return FALSE;
-
- if (child->ico->summary)
- g_free (child->ico->summary);
-
- child->ico->summary = text;
-
- /* Notify calendar of change */
-
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY);
-
- return FALSE;
-}
-
-static gint
-child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
-{
- if (event->keyval != GDK_Escape)
- return FALSE;
-
- /* If user pressed Esc, un-focus the child by focusing the fullday widget */
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
- gtk_widget_grab_focus (widget->parent);
-
- return FALSE;
-}
-
-static gint
-child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
- Child *child;
- GncalFullDay *fullday;
-
- if (event->button != 3)
- return FALSE;
-
- child = data;
- fullday = GNCAL_FULL_DAY (widget->parent);
-
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "button_press_event");
- gtk_widget_grab_focus (widget);
- child_popup_menu (fullday, child, event);
-
- return TRUE;
-}
-
-/*
- * compute the space required to display the decorations
- */
-static void
-child_compute_decor (Child *child)
-{
- iCalObject *ico = child->ico;
- int rows_used;
-
- child->items = 0;
- rows_used = (child->rows_used < 1) ? 1 : child->rows_used;
- if (ico->recur)
- child->items++;
- if (ico->dalarm.enabled || ico->aalarm.enabled || ico->palarm.enabled || ico->malarm.enabled)
- child->items++;
-
- if (child->items > rows_used){
- child->decor_width = DECOR_WIDTH * 2;
- child->decor_height = DECOR_HEIGHT;
- } else {
- child->decor_width = DECOR_WIDTH * (child->items ? 1 : 0);
- child->decor_height = DECOR_HEIGHT * child->items;
- }
-}
-
-static Child *
-child_new (GncalFullDay *fullday, time_t start, time_t end, iCalObject *ico)
-{
- Child *child;
-
- child = g_new (Child, 1);
-
- child->ico = ico;
- child->widget = gtk_text_new (NULL, NULL);
- child->window = NULL;
- child->x = 0;
- child->y = 0;
- child->width = 0;
- child->height = 0;
- child->start = start;
- child->end = end;
- child_range_changed (fullday, child);
- child_compute_decor (child);
-
- if (ico->summary)
- gtk_text_insert (GTK_TEXT (child->widget), NULL, NULL, NULL,
- ico->summary,
- strlen (ico->summary));
-
- /* We set the i-beam cursor of the text widget upon realization */
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "realize",
- (GtkSignalFunc) child_realized_setup,
- child);
-
- gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_in_event",
- (GtkSignalFunc) child_focus_in,
- child);
-
- child->focus_out_id = gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_out_event",
- (GtkSignalFunc) child_focus_out,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "key_press_event",
- (GtkSignalFunc) child_key_press,
- child);
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "button_press_event",
- (GtkSignalFunc) child_button_press,
- child);
-
- /* Finish setup */
-
- gtk_text_set_editable (GTK_TEXT (child->widget), TRUE);
- gtk_text_set_word_wrap (GTK_TEXT (child->widget), TRUE);
-
- gtk_widget_set_parent (child->widget, GTK_WIDGET (fullday));
-
- return child;
-}
-
-static void
-squick (GtkWidget *widget, gpointer data)
-{
-}
-
-static void
-child_destroy (GncalFullDay *fullday, Child *child)
-{
- /* Disconnect the focus_out_event signal since we will get such an event
- * from the destroy call.
- */
- gtk_signal_disconnect (GTK_OBJECT (child->widget), child->focus_out_id);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_unmap (fullday, child);
-
- if (GTK_WIDGET_REALIZED (fullday))
- child_unrealize (fullday, child);
-
- /* Unparent the child widget manually as we don't have a remove method */
-
- gtk_signal_connect (GTK_OBJECT (child->widget), "destroy",
- (GtkSignalFunc) squick,
- NULL);
-
- gtk_widget_unparent (child->widget);
- g_free (child);
-}
-
-static int
-calc_labels_width (GncalFullDay *fullday)
-{
- struct tm cur, upper;
- time_t tim, time_upper;
- int width, max_w;
- char buf[40];
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &cur, &upper, NULL, NULL);
-
- max_w = 0;
-
- tim = mktime (&cur);
- time_upper = mktime (&upper);
-
- while (tim < time_upper) {
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &cur);
- else
- strftime (buf, sizeof (buf), "%H:%M", &cur);
-
-
- width = gdk_string_width (GTK_WIDGET (fullday)->style->font, buf);
-
- if (width > max_w)
- max_w = width;
-
- cur.tm_min += fullday->interval;
- tim = mktime (&cur);
- }
-
- return max_w;
-}
-
-/* Used with layout_events(), takes in a list element and returns the start and end times for the
- * event corresponding to that element.
- */
-static void
-child_layout_query_func (GList *event, time_t *start, time_t *end)
-{
- Child *child;
-
- child = event->data;
-
- *start = child->start;
- *end = child->end;
-}
-
-/* Takes the list of children in the full day view and lays them out nicely without overlapping.
- * Basically it calls the layout_events() function in layout.c and resizes the fullday's children.
- */
-static void
-layout_children (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- GList *children;
- Child *child;
- int num_slots;
- int *allocations;
- int *slots;
- int left_x;
- int usable_pixels, pixels_per_col, extra_pixels;
- int i;
-
- if (!fullday->children)
- return;
-
- layout_events (fullday->children, child_layout_query_func, &num_slots, &allocations, &slots);
-
- /* Set the size and position of each child */
-
- widget = GTK_WIDGET (fullday);
- left_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + calc_labels_width (fullday);
-
- usable_pixels = widget->allocation.width - left_x - widget->style->klass->xthickness;
- pixels_per_col = usable_pixels / num_slots;
- extra_pixels = usable_pixels % num_slots;
-
- for (children = fullday->children, i = 0; children; children = children->next, i++) {
- child = children->data;
-
- child->x = left_x + pixels_per_col * allocations[i];
- child->width = pixels_per_col * slots[i];
-
- if ((allocations[i] + slots[i]) == num_slots)
- child->width += extra_pixels;
-
- child_set_size (child);
- }
-
- g_free (allocations);
- g_free (slots);
-}
-
-guint
-gncal_full_day_get_type (void)
-{
- static guint full_day_type = 0;
-
- if (!full_day_type) {
- GtkTypeInfo full_day_info = {
- "GncalFullDay",
- sizeof (GncalFullDay),
- sizeof (GncalFullDayClass),
- (GtkClassInitFunc) gncal_full_day_class_init,
- (GtkObjectInitFunc) gncal_full_day_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- full_day_type = gtk_type_unique (gtk_container_get_type (), &full_day_info);
- }
-
- return full_day_type;
-}
-
-static void
-gncal_full_day_class_init (GncalFullDayClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- parent_class = gtk_type_class (gtk_container_get_type ());
-
- fullday_signals[RANGE_ACTIVATED] =
- gtk_signal_new ("range_activated",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GncalFullDayClass, range_activated),
- gtk_signal_default_marshaller,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, fullday_signals, LAST_SIGNAL);
-
- object_class->destroy = gncal_full_day_destroy;
-
- widget_class->map = gncal_full_day_map;
- widget_class->unmap = gncal_full_day_unmap;
- widget_class->realize = gncal_full_day_realize;
- widget_class->unrealize = gncal_full_day_unrealize;
- widget_class->draw = gncal_full_day_draw;
- widget_class->draw_focus = gncal_full_day_draw_focus;
- widget_class->size_request = gncal_full_day_size_request;
- widget_class->size_allocate = gncal_full_day_size_allocate;
- widget_class->button_press_event = gncal_full_day_button_press;
- widget_class->button_release_event = gncal_full_day_button_release;
- widget_class->motion_notify_event = gncal_full_day_motion;
- widget_class->expose_event = gncal_full_day_expose;
- widget_class->key_press_event = gncal_full_day_key_press;
- widget_class->focus_in_event = gncal_full_day_focus_in;
- widget_class->focus_out_event = gncal_full_day_focus_out;
-
- container_class->forall = gncal_full_day_forall;
-
- class->range_activated = range_activated;
-}
-
-static void
-gncal_full_day_init (GncalFullDay *fullday)
-{
- GTK_WIDGET_UNSET_FLAGS (fullday, GTK_NO_WINDOW);
- GTK_WIDGET_SET_FLAGS (fullday, GTK_CAN_FOCUS);
-
- fullday->calendar = NULL;
-
- fullday->lower = 0;
- fullday->upper = 0;
- fullday->interval = 30; /* 30 minutes by default */
-
- fullday->children = NULL;
- fullday->drag_info = g_new0 (struct drag_info, 1);
-
- fullday->up_down_cursor = NULL;
- fullday->beam_cursor = NULL;
- fullday->recur_gc = NULL;
- fullday->bell_gc = NULL;
-}
-
-/* Destroys all the children in the full day widget */
-static void
-destroy_children (GncalFullDay *fullday)
-{
- GList *children;
-
- for (children = fullday->children; children; children = children->next)
- child_destroy (fullday, children->data);
-
- g_list_free (fullday->children);
- fullday->children = NULL;
-}
-
-static void
-gncal_full_day_destroy (GtkObject *object)
-{
- GncalFullDay *fullday;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (object));
-
- fullday = GNCAL_FULL_DAY (object);
-
- destroy_children (fullday);
-
- g_free (fullday->drag_info);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-GtkWidget *
-gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- fullday = gtk_type_new (gncal_full_day_get_type ());
-
- fullday->calendar = calendar;
-
- gncal_full_day_set_bounds (fullday, lower, upper);
-
- return GTK_WIDGET (fullday);
-}
-
-static void
-gncal_full_day_map (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_show (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_map (fullday, children->data);
-}
-
-static void
-gncal_full_day_unmap (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- gdk_window_hide (widget->window);
-
- for (children = fullday->children; children; children = children->next)
- child_unmap (fullday, children->data);
-}
-
-static void
-gncal_full_day_realize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget)
- | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]);
-
- fullday->up_down_cursor = gdk_cursor_new (GDK_DOUBLE_ARROW);
- fullday->beam_cursor = gdk_cursor_new (GDK_XTERM);
-
- for (children = fullday->children; children; children = children->next)
- child_realize (fullday, children->data);
-
-}
-
-static void
-gncal_full_day_unrealize (GtkWidget *widget)
-{
- GncalFullDay *fullday;
- GList *children;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- fullday = GNCAL_FULL_DAY (widget);
-
- for (children = fullday->children; children; children = children->next)
- child_unrealize (fullday, children->data);
-
- gdk_cursor_destroy (fullday->up_down_cursor);
- fullday->up_down_cursor = NULL;
-
- gdk_cursor_destroy (fullday->beam_cursor);
- fullday->beam_cursor = NULL;
-
- if (fullday->bell_gc)
- gdk_gc_destroy (fullday->bell_gc);
- if (fullday->recur_gc)
- gdk_gc_destroy (fullday->recur_gc);
-
- if (pixmap_bell){
- gdk_pixmap_unref (pixmap_bell);
- pixmap_bell = NULL;
- }
-
- if (pixmap_recur){
- gdk_pixmap_unref (pixmap_recur);
- pixmap_recur = NULL;
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-struct paint_info {
- GtkWidget *widget;
- struct drag_info *di;
- GdkRectangle *area;
- int x1, y1, width, height;
- int labels_width;
- int row_height;
- struct tm start_tm;
-};
-
-static void
-paint_row (GncalFullDay *fullday, int row, struct paint_info *p)
-{
- GdkRectangle rect, dest;
- GdkGC *left_gc, *right_gc, *text_gc;
- int begin_row, end_row;
- struct tm tm;
- char buf[40];
-
- begin_row = (day_begin * 60) / fullday->interval;
- end_row = (day_end * 60) / fullday->interval;
-
- /* See which GCs we will use */
-
- if ((p->di->sel_rows_used != 0)
- && (row >= p->di->sel_start_row)
- && (row < (p->di->sel_start_row + p->di->sel_rows_used))) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_SELECTED];
- right_gc = left_gc;
- text_gc = p->widget->style->fg_gc[GTK_STATE_SELECTED];
- } else if ((row < begin_row) || (row >= end_row)) {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_ACTIVE];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- } else {
- left_gc = p->widget->style->bg_gc[GTK_STATE_NORMAL];
- right_gc = p->widget->style->bg_gc[GTK_STATE_PRELIGHT];
- text_gc = p->widget->style->fg_gc[GTK_STATE_NORMAL];
- }
-
- /* Left background and text */
-
- rect.x = p->x1;
- rect.y = p->y1 + row * p->row_height;
- rect.width = 2 * TEXT_BORDER + p->labels_width;
- rect.height = p->row_height - 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest)) {
- gdk_draw_rectangle (p->widget->window,
- left_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- tm = p->start_tm;
- tm.tm_min += row * fullday->interval;
- mktime (&tm);
-
- if (am_pm_flag)
- strftime (buf, sizeof (buf), "%I:%M%p", &tm);
- else
- strftime (buf, sizeof (buf), "%H:%M", &tm);
-
- gdk_draw_string (p->widget->window,
- p->widget->style->font,
- text_gc,
- rect.x + TEXT_BORDER,
- rect.y + TEXT_BORDER + p->widget->style->font->ascent,
- buf);
- }
-
- /* Right background */
-
- rect.x += rect.width + p->widget->style->klass->xthickness;
- rect.width = p->width - (rect.x - p->x1);
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_rectangle (p->widget->window,
- right_gc,
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Horizontal division at bottom of row */
-
- rect.x = p->x1;
- rect.y += rect.height;
- rect.width = p->width;
- rect.height = 1;
-
- if (gdk_rectangle_intersect (&rect, p->area, &dest))
- gdk_draw_line (p->widget->window,
- p->widget->style->black_gc,
- rect.x, rect.y,
- rect.x + rect.width - 1, rect.y);
-}
-
-static void
-paint_back (GncalFullDay *fullday, GdkRectangle *area)
-{
- struct paint_info p;
- int start_row, end_row;
- int i;
- GdkRectangle rect, dest, aarea;
- int f_rows;
- int draw_focus;
-
- p.widget = GTK_WIDGET (fullday);
- p.di = fullday->drag_info;
-
- if (!area) {
- area = &aarea;
-
- area->x = 0;
- area->y = 0;
- area->width = p.widget->allocation.width;
- area->height = p.widget->allocation.height;
- }
- p.area = area;
-
- p.x1 = p.widget->style->klass->xthickness;
- p.y1 = p.widget->style->klass->ythickness;
- p.width = p.widget->allocation.width - 2 * p.x1;
- p.height = p.widget->allocation.height - 2 * p.y1;
-
- p.labels_width = calc_labels_width (fullday);
- p.row_height = calc_row_height (fullday);
- get_tm_range (fullday, fullday->lower, fullday->upper, &p.start_tm, NULL, NULL, &f_rows);
-
- /* Frame shadow */
-
- rect.x = 0;
- rect.y = 0;
- rect.width = p.widget->allocation.width;
- rect.height = p.widget->style->klass->ythickness;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
-
- if (!draw_focus) {
- rect.y = p.widget->allocation.height - rect.height;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.y = p.widget->style->klass->ythickness;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.widget->allocation.height - 2 * rect.y;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (!draw_focus) {
- rect.x = p.widget->allocation.width - rect.width;
-
- draw_focus = gdk_rectangle_intersect (&rect, area, &dest);
- }
-
- if (draw_focus)
- gtk_widget_draw_focus (p.widget);
-
- /* Rows */
-
- start_row = (area->y - p.y1) / p.row_height;
- end_row = (area->y + area->height - 1 - p.y1) / p.row_height;
-
- if (end_row >= f_rows)
- end_row = f_rows - 1;
-
- for (i = start_row; i <= end_row; i++)
- paint_row (fullday, i, &p);
-
- /* Slack area at bottom of widget */
-
- rect.x = p.x1;
- rect.y = p.y1 + f_rows * p.row_height;
- rect.width = p.width;
- rect.height = p.height - (rect.y - p.y1);
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gdk_draw_rectangle (p.widget->window,
- p.widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- dest.x, dest.y,
- dest.width, dest.height);
-
- /* Vertical division */
-
- rect.x = p.x1 + 2 * TEXT_BORDER + p.labels_width;
- rect.y = p.y1;
- rect.width = p.widget->style->klass->xthickness;
- rect.height = p.height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest))
- gtk_draw_vline (p.widget->style, p.widget->window,
- GTK_STATE_NORMAL,
- rect.y,
- rect.y + rect.height - 1,
- rect.x);
-}
-
-static void
-paint_back_rows (GncalFullDay *fullday, int start_row, int rows_used)
-{
- int row_height;
- int xthickness, ythickness;
- GtkWidget *widget;
- GdkRectangle area;
-
- widget = GTK_WIDGET (fullday);
-
- row_height = calc_row_height (fullday);
-
- xthickness = widget->style->klass->xthickness;
- ythickness = widget->style->klass->ythickness;
-
- area.x = xthickness;
- area.y = ythickness + start_row * row_height;
- area.width = widget->allocation.width - 2 * xthickness;
- area.height = rows_used * row_height;
-
- paint_back (fullday, &area);
-}
-
-static void
-gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
- GdkRectangle rect, dest;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (area != NULL);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- paint_back (fullday, area);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- rect.x = child->x;
- rect.y = child->y;
- rect.width = child->width;
- rect.height = child->height;
-
- if (gdk_rectangle_intersect (&rect, area, &dest)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- }
- }
-}
-
-static void
-gncal_full_day_draw_focus (GtkWidget *widget)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return;
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- if (GTK_WIDGET_HAS_FOCUS (widget))
- gdk_draw_rectangle (widget->window,
- widget->style->black_gc,
- FALSE,
- 0, 0,
- widget->allocation.width - 1,
- widget->allocation.height - 1);
-}
-
-static void
-gncal_full_day_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GncalFullDay *fullday;
- int labels_width;
- int rows;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (requisition != NULL);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- /* Border and min width */
-
- labels_width = calc_labels_width (fullday);
-
- requisition->width = 2 * widget->style->klass->xthickness + 4 * TEXT_BORDER + labels_width + MIN_WIDTH;
- requisition->height = 2 * widget->style->klass->ythickness;
-
- /* Rows */
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &rows);
-
- requisition->height += (rows * (2 * TEXT_BORDER + widget->style->font->ascent + widget->style->font->descent)
- + (rows - 1)); /* division lines */
-}
-
-static void
-gncal_full_day_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- GncalFullDay *fullday;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (widget));
- g_return_if_fail (allocation != NULL);
-
- widget->allocation = *allocation;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- layout_children (fullday);
-}
-
-static Child *
-find_child_by_window (GncalFullDay *fullday, GdkWindow *window, int *on_text)
-{
- GList *children;
- Child *child;
- GtkWidget *owner;
-
- *on_text = FALSE;
-
- gdk_window_get_user_data (window, (gpointer *) &owner);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->window == window || child->decor_window == window)
- return child;
-
- if (child->widget == owner) {
- *on_text = TRUE;
- return child;
- }
- }
-
- return NULL;
-}
-
-static void
-draw_xor_rect (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- struct drag_info *di;
- int i;
- int row_height;
- int ythickness;
-
- widget = GTK_WIDGET (fullday);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_INVERT);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_INCLUDE_INFERIORS);
-
- ythickness = widget->style->klass->ythickness;
-
- di = fullday->drag_info;
-
- row_height = calc_row_height (fullday);
-
- for (i = 0; i < XOR_RECT_WIDTH; i++)
- gdk_draw_rectangle (widget->window,
- widget->style->white_gc,
- FALSE,
- di->child->x + i,
- di->child_start_row * row_height + ythickness + i,
- di->child->width - 2 * i - 1,
- di->child_rows_used * row_height - 2 - 2 * i);
-
- gdk_gc_set_function (widget->style->white_gc, GDK_COPY);
- gdk_gc_set_subwindow (widget->style->white_gc, GDK_CLIP_BY_CHILDREN);
-}
-
-static int
-get_row_from_y (GncalFullDay *fullday, int y, int round)
-{
- GtkWidget *widget;
- int row_height;
- int f_rows;
- int ythickness;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- row_height = calc_row_height (fullday);
-
- widget = GTK_WIDGET (fullday);
-
- ythickness = widget->style->klass->ythickness;
-
- y -= ythickness;
-
- if (y < 0)
- y = 0;
- else if (y >= (f_rows * row_height))
- y = f_rows * row_height - 1;
-
- if (round)
- y += row_height / 2;
-
- y /= row_height;
-
- if (y > f_rows)
- y = f_rows; /* note that this is 1 more than the last row's index */
-
- return y;
-}
-
-static int
-button_1 (GncalFullDay *fullday, GdkEventButton *event)
-{
- GtkWidget *widget;
- Child *child;
- int on_text;
- struct drag_info *di;
- gint y;
- int row_height;
- int has_focus;
- int old_start_row, old_rows_used;
- int old_max;
- int paint_start_row, paint_rows_used;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- di->drag_mode = DRAG_SELECT;
-
- old_start_row = di->sel_start_row;
- old_rows_used = di->sel_rows_used;
-
- di->sel_click_row = get_row_from_y (fullday, event->y, FALSE);
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = 1;
-
- di->click_time = event->time;
-
- gdk_pointer_grab (widget->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- if (old_rows_used == 0) {
- paint_start_row = di->sel_start_row;
- paint_rows_used = di->sel_rows_used;
- } else {
- paint_start_row = MIN (old_start_row, di->sel_start_row);
- old_max = old_start_row + old_rows_used - 1;
- paint_rows_used = MAX (old_max, di->sel_start_row) - paint_start_row + 1;
- }
-
- paint_back_rows (fullday, paint_start_row, paint_rows_used);
-
- return TRUE;
- } else {
- /* Clicked on a child? */
-
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text || child->ico->recur)
- return FALSE;
-
- /* Prepare for drag */
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- has_focus = GTK_WIDGET_HAS_FOCUS (child->widget);
-
- if (has_focus) {
- if (event->y < HANDLE_SIZE)
- di->drag_mode = DRAG_SIZE_TOP;
- else if (event->y >= (child->height - HANDLE_SIZE))
- di->drag_mode = DRAG_SIZE_BOTTOM;
- else
- di->drag_mode = DRAG_MOVE;
- } else
- di->drag_mode = DRAG_MOVE;
-
- row_height = calc_row_height (fullday);
-
- di->child = child;
-
- di->child_click_y = event->y;
- di->child_start_row = child->lower_row;
- di->child_rows_used = child->rows_used;
-
- gdk_pointer_grab (child->window, FALSE,
- (GDK_BUTTON_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- fullday->up_down_cursor,
- event->time);
-
- draw_xor_rect (fullday);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static int
-button_3 (GncalFullDay *fullday, GdkEventButton *event)
-{
- static struct menu_item main_items[] = {
- { N_("New appointment..."), (GtkSignalFunc) new_appointment, NULL, TRUE }
- };
-
- GtkWidget *widget;
- Child *child;
- int on_text;
-
- widget = GTK_WIDGET (fullday);
-
- if (event->window == widget->window) {
- /* Clicked on main window */
-
- if (!GTK_WIDGET_HAS_FOCUS (widget))
- gtk_widget_grab_focus (widget);
-
- main_items[0].data = fullday;
-
- popup_menu (main_items, sizeof (main_items) / sizeof (main_items[0]), event);
-
- return TRUE;
- } else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (!child || on_text)
- return FALSE;
-
- child_popup_menu (fullday, child, event);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- switch (event->button) {
- case 1:
- return button_1 (fullday, event);
-
- case 3:
- return button_3 (fullday, event);
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-static void
-recompute_motion (GncalFullDay *fullday, int y)
-{
- struct drag_info *di;
- int f_rows;
- int row;
- int has_focus;
-
- di = fullday->drag_info;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows);
-
- switch (di->drag_mode) {
- case DRAG_SELECT:
- row = get_row_from_y (fullday, y, FALSE);
-
- if (row >= f_rows)
- row = f_rows - 1;
-
- if (row < di->sel_click_row) {
- di->sel_start_row = row;
- di->sel_rows_used = di->sel_click_row - row + 1;
- } else {
- di->sel_start_row = di->sel_click_row;
- di->sel_rows_used = row - di->sel_start_row + 1;
- }
-
- break;
-
- case DRAG_MOVE:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y - di->child_click_y + (has_focus ? HANDLE_SIZE : 0), TRUE);
-
- if (row > (f_rows - di->child_rows_used))
- row = f_rows - di->child_rows_used;
-
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_TOP:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y + HANDLE_SIZE, TRUE);
-
- if (row > (di->child_start_row + di->child_rows_used - 1))
- row = di->child_start_row + di->child_rows_used - 1;
-
- di->child_rows_used = (di->child_start_row + di->child_rows_used) - row;
- di->child_start_row = row;
-
- break;
-
- case DRAG_SIZE_BOTTOM:
- has_focus = GTK_WIDGET_HAS_FOCUS (di->child->widget);
-
- if (has_focus)
- child_focus_out (di->child->widget, NULL, di->child);
-
- row = get_row_from_y (fullday, y - HANDLE_SIZE, TRUE);
-
- if (row <= di->child_start_row)
- row = di->child_start_row + 1;
- else if (row > f_rows)
- row = f_rows;
-
- di->child_rows_used = row - di->child_start_row;
-
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-get_time_from_rows (GncalFullDay *fullday, int start_row, int rows_used, time_t *t_lower, time_t *t_upper)
-{
- struct tm tm;
- int row_height;
-
- get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, NULL);
-
- row_height = calc_row_height (fullday);
-
- tm.tm_min += fullday->interval * start_row;
- *t_lower = mktime (&tm);
-
- tm.tm_min += fullday->interval * rows_used;
- *t_upper = mktime (&tm);
-}
-
-static void
-update_from_drag_info (GncalFullDay *fullday)
-{
- struct drag_info *di;
- GtkWidget *widget;
-
- di = fullday->drag_info;
-
- widget = GTK_WIDGET (fullday);
-
- get_time_from_rows (fullday, di->child_start_row, di->child_rows_used,
- &di->child->ico->dtstart,
- &di->child->ico->dtend);
-
- child_range_changed (fullday, di->child);
-
- /* Notify calendar of change */
-
- gnome_calendar_object_changed (fullday->calendar, di->child->ico, CHANGE_DATES);
-}
-
-static gint
-gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int retval;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- retval = FALSE;
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- if ((event->time - di->click_time) < UNSELECT_TIMEOUT)
- di->sel_rows_used = 0;
- else
- recompute_motion (fullday, y);
-
- gdk_pointer_ungrab (event->time);
-
- paint_back_rows (fullday, di->sel_start_row, MAX (di->sel_rows_used, 1));
-
- retval = TRUE;
- break;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- gdk_pointer_ungrab (event->time);
-
- update_from_drag_info (fullday);
-
- di->child_rows_used = 0;
-
- retval = TRUE;
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- di->drag_mode = DRAG_NONE;
- di->child = NULL;
-
- return retval;
-}
-
-static gint
-gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- gint y;
- int old_min, old_max;
- int new_min, new_max;
- int new_start_row, new_rows_used;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
- di = fullday->drag_info;
-
- gtk_widget_get_pointer (widget, NULL, &y);
-
- switch (di->drag_mode) {
- case DRAG_NONE:
- break;
-
- case DRAG_SELECT:
- old_min = di->sel_start_row;
- old_max = di->sel_start_row + di->sel_rows_used - 1;
-
- recompute_motion (fullday, y);
-
- new_min = di->sel_start_row;
- new_max = di->sel_start_row + di->sel_rows_used - 1;
-
- new_start_row = MIN (old_min, new_min);
- new_rows_used = MAX (old_max, new_max) - new_start_row + 1;
-
- paint_back_rows (fullday, new_start_row, new_rows_used);
-
- return TRUE;
-
- case DRAG_MOVE:
- case DRAG_SIZE_TOP:
- case DRAG_SIZE_BOTTOM:
- draw_xor_rect (fullday);
- recompute_motion (fullday, y);
- draw_xor_rect (fullday);
-
- return TRUE;
-
- default:
- g_assert_not_reached ();
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GncalFullDay *fullday;
- Child *child;
- int on_text;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (!GTK_WIDGET_DRAWABLE (widget))
- return FALSE;
-
- fullday = GNCAL_FULL_DAY (widget);
-
- if (event->window == widget->window)
- paint_back (fullday, &event->area);
- else {
- child = find_child_by_window (fullday, event->window, &on_text);
-
- if (child && !on_text)
- child_draw (fullday, child, &event->area, event->window, FALSE);
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_key_press (GtkWidget *widget, GdkEventKey *event)
-{
- GncalFullDay *fullday;
- struct drag_info *di;
- GList *children;
- Child *child;
- gint pos;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- fullday = GNCAL_FULL_DAY (widget);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0)
- return FALSE;
-
- if (event->keyval == GDK_Return) {
- gtk_signal_emit (GTK_OBJECT (fullday), fullday_signals[RANGE_ACTIVATED]);
- return TRUE;
- }
-
- /*
- * If a non-printable key was pressed, bail. Otherwise, begin
- * editing the appointment.
- */
- if ((event->keyval < 0x20) || (event->keyval > 0xFF)
- || (event->length == 0) || (event->state & GDK_CONTROL_MASK)
- || (event->state & GDK_MOD1_MASK))
- return FALSE;
-
- gtk_signal_emit (GTK_OBJECT (fullday),
- fullday_signals[RANGE_ACTIVATED]);
-
- /*
- * Find the new child, which should hopefully be focused, and
- * insert the keypress.
- */
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (GTK_WIDGET_HAS_FOCUS (child->widget)) {
- pos = gtk_text_get_length (GTK_TEXT (child->widget));
-
- gtk_editable_insert_text (GTK_EDITABLE (child->widget),
- event->string,
- event->length,
- &pos);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_in (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static gint
-gncal_full_day_focus_out (GtkWidget *widget, GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
- gtk_widget_draw_focus (widget);
-
- return FALSE;
-}
-
-static void
-gncal_full_day_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
-{
- GncalFullDay *fullday;
- GList *children;
- Child *child;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (container));
- g_return_if_fail (callback != NULL);
-
- fullday = GNCAL_FULL_DAY (container);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- (*callback) (child->widget, callback_data);
- }
-}
-
-static gint
-child_compare (gconstpointer a, gconstpointer b)
-{
- const Child *ca = a;
- const Child *cb = b;
- time_t diff;
-
- diff = ca->start - cb->start;
-
- if (diff == 0)
- diff = cb->end - ca->end;
-
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-static int
-fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GncalFullDay *fullday = c;
- Child *child;
-
- child = child_new (fullday, start, end, obj);
- fullday->children = g_list_insert_sorted (fullday->children, child, child_compare);
-
- return 1;
-}
-
-void
-gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags)
-{
- GList *children;
- Child *child;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if (!fullday->calendar->client)
- return;
-
- /* Try to find child that changed */
-
- for (children=fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico)
- break;
- }
-
- /* If child was found and nothing but the summary changed,
- we can just paint the child and return */
-
- if (children && !(flags & ~CHANGE_SUMMARY)) {
- child_draw (fullday, child, NULL, NULL, TRUE);
- return;
- }
-
- /* We have to regenerate and layout our list of children */
-
- destroy_children (fullday);
-
- calendar_iterate (fullday->calendar,
- fullday->lower,
- fullday->upper,
- fullday_add_children,
- fullday);
-
- layout_children (fullday);
-
- /* Realize and map children */
-
- for (children = fullday->children; children; children = children->next) {
- if (GTK_WIDGET_REALIZED (fullday))
- child_realize (fullday, children->data);
-
- if (GTK_WIDGET_MAPPED (fullday))
- child_map (fullday, children->data);
- }
-
- gtk_widget_draw (GTK_WIDGET (fullday), NULL);
-}
-
-void
-gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- if ((lower != fullday->lower) || (upper != fullday->upper)) {
- fullday->lower = lower;
- fullday->upper = upper;
-
- di = fullday->drag_info;
-
- di->sel_rows_used = 0; /* clear selection */
-
- gncal_full_day_update (fullday, NULL, 0);
- }
-}
-
-int
-gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper)
-{
- struct drag_info *di;
- time_t alower, aupper;
-
- g_return_val_if_fail (fullday != NULL, FALSE);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), FALSE);
-
- di = fullday->drag_info;
-
- if (di->sel_rows_used == 0){
- time_t now = time (NULL);
- struct tm tm = *localtime (&now);
- struct tm thisd = *localtime (&fullday->lower);
-
- thisd.tm_hour = tm.tm_hour;
- thisd.tm_min = tm.tm_min;
- thisd.tm_sec = 0;
- *lower = mktime (&thisd);
- thisd.tm_hour++;
- *upper = mktime (&thisd);
- return FALSE;
- }
-
- get_time_from_rows (fullday, di->sel_start_row, di->sel_rows_used, &alower, &aupper);
-
- if (lower)
- *lower = alower;
-
- if (upper)
- *upper= aupper;
-
- return TRUE;
-}
-
-void
-gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico)
-{
- GList *children;
- Child *child;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (ico != NULL);
-
- for (children = fullday->children; children; children = children->next) {
- child = children->data;
-
- if (child->ico == ico) {
- gtk_widget_grab_focus (child->widget);
- break;
- }
- }
-}
-
-int
-gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday)
-{
- GtkWidget *widget;
- int begin_row;
-
- g_return_val_if_fail (fullday != NULL, 0);
- g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), 0);
-
- widget = GTK_WIDGET (fullday);
-
- begin_row = (day_begin * 60) / fullday->interval;
-
- return widget->style->klass->ythickness + begin_row * calc_row_height (fullday);
-}
-
-static void
-range_activated (GncalFullDay *fullday)
-{
- struct drag_info *di;
-
- g_return_if_fail (fullday != NULL);
- g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
-
- di = fullday->drag_info;
-
- /* Remove selection; at this point someone should already have added an appointment */
-
- di->sel_rows_used = 0;
-
- paint_back (fullday, NULL);
-}
diff --git a/calendar/gui/gncal-full-day.h b/calendar/gui/gncal-full-day.h
deleted file mode 100644
index b616308f24..0000000000
--- a/calendar/gui/gncal-full-day.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Full day widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef GNCAL_FULL_DAY_H
-#define GNCAL_FULL_DAY_H
-
-
-#include <gtk/gtkcontainer.h>
-#include <libgnome/gnome-defs.h>
-/*#include "calendar.h"*/
-#include "gnome-cal.h"
-
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_FULL_DAY(obj) GTK_CHECK_CAST (obj, gncal_full_day_get_type (), GncalFullDay)
-#define GNCAL_FULL_DAY_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_full_day_get_type (), GncalFullDayClass)
-#define GNCAL_IS_FULL_DAY(obj) GTK_CHECK_TYPE (obj, gncal_full_day_get_type ())
-
-
-typedef struct _GncalFullDay GncalFullDay;
-typedef struct _GncalFullDayClass GncalFullDayClass;
-
-struct _GncalFullDay {
- GtkContainer container;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- time_t lower; /* lower time to display */
- time_t upper; /* upper time to display */
- int interval; /* interval between rows in minutes */
-
- GList *children; /* container children */
- gpointer drag_info; /* internal drag information */
-
- GdkCursor *up_down_cursor; /* for dragging children */
- GdkCursor *beam_cursor; /* for the text widgets */
- GdkGC *recur_gc; /* The gc used to draw the recur image */
- GdkGC *bell_gc; /* The gc used to draw on imlib windows */
-
-};
-
-struct _GncalFullDayClass {
- GtkContainerClass parent_class;
-
- void (* range_activated) (GncalFullDay *fullday);
-};
-
-
-guint gncal_full_day_get_type (void);
-GtkWidget *gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper);
-
-void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags);
-void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper);
-
-/* Returns the selected range in lower and upper. If nothing is
- * selected, return value is FALSE, otherwise it is TRUE.
- * The lower and upper values are always set to proper values, regardless of
- * the selection value
- */
-int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper);
-
-void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico);
-
-int gncal_full_day_get_day_start_yoffset (GncalFullDay *fullday);
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c
deleted file mode 100644
index bd3091a54a..0000000000
--- a/calendar/gui/gncal-week-view.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <config.h>
-#include <gnome.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include <cal-util/timeutil.h>
-#include "gncal-week-view.h"
-#include "calendar-commands.h"
-
-static void gncal_week_view_init (GncalWeekView *wview);
-
-
-guint
-gncal_week_view_get_type (void)
-{
- static guint week_view_type = 0;
-
- if (!week_view_type) {
- GtkTypeInfo week_view_info = {
- "GncalWeekView",
- sizeof (GncalWeekView),
- sizeof (GncalWeekViewClass),
- (GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gncal_week_view_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
- };
-
- week_view_type = gtk_type_unique (gtk_vbox_get_type (), &week_view_info);
- }
-
- return week_view_type;
-}
-
-static void
-gncal_week_view_init (GncalWeekView *wview)
-{
- int i;
-
- wview->calendar = NULL;
- memset (&wview->start_of_week, 0, sizeof (wview->start_of_week));
-
- for (i = 0; i < 7; i++)
- wview->days[i] = NULL;
-
- wview->gtk_calendar = NULL;
-}
-
-static void
-jump_to_day (GtkCalendar *cal, GncalWeekView *wview, int day)
-{
- struct tm tm;
- time_t t;
- static int inside;
-
- if (inside)
- return;
- inside = 1;
- tm.tm_mday = day;
- tm.tm_mon = cal->month;
- tm.tm_year = cal->year - 1900;
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- t = mktime (&tm);
-
- gncal_week_view_set (wview, t);
- inside = 0;
-}
-
-static void
-jump_to_day_click (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, cal->selected_day);
-}
-
-static void
-sync_week (GtkCalendar *cal, GncalWeekView *wview)
-{
- jump_to_day (cal, wview, wview->start_of_week.tm_mday + 7);
- gnome_calendar_tag_calendar (wview->calendar, wview->gtk_calendar);
-}
-
-static void
-double_click_on_weekday (GtkWidget *widget, GdkEvent *e, GncalWeekView *wview)
-{
-}
-
-GtkWidget *
-gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
-{
- GncalWeekView *wview;
- GtkWidget *table;
- int i;
-
- g_return_val_if_fail (calendar != NULL, NULL);
-
- wview = gtk_type_new (gncal_week_view_get_type ());
-
- table = gtk_table_new (0, 0, 0);
- gtk_table_set_homogeneous (GTK_TABLE (table), TRUE);
- wview->label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (wview), wview->label, 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (wview), table, 1, 1, 0);
- wview->calendar = calendar;
- for (i = 0; i < 7; i++) {
- wview->days[i] = GNCAL_DAY_VIEW (gncal_day_view_new (calendar, 0, 0));
- gtk_signal_connect (GTK_OBJECT (wview->days [i]), "button_press_event",
- GTK_SIGNAL_FUNC(double_click_on_weekday), wview);
-
- if (i < 5)
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i, i + 1,
- 0, 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
- else
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->days[i]),
- i - 2, i - 1,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- gtk_widget_show (GTK_WIDGET (wview->days[i]));
- }
-
- wview->gtk_calendar = GTK_CALENDAR (gtk_calendar_new ());
-
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "day_selected_double_click",
- GTK_SIGNAL_FUNC(jump_to_day_click), wview);
- gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "month_changed",
- GTK_SIGNAL_FUNC(sync_week), wview);
-
- gtk_calendar_display_options (wview->gtk_calendar,
- (GTK_CALENDAR_SHOW_HEADING
- | GTK_CALENDAR_SHOW_DAY_NAMES
- | (week_starts_on_monday
- ? GTK_CALENDAR_WEEK_START_MONDAY : 0)));
-
- gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (wview->gtk_calendar),
- 0, 3,
- 1, 2,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK,
- 4, 4);
- gtk_widget_show (GTK_WIDGET (wview->gtk_calendar));
-
- gncal_week_view_set (wview, start_of_week);
-
- return GTK_WIDGET (wview);
-}
-
-static void
-update (GncalWeekView *wview, int update_days, iCalObject *object, int flags)
-{
- int i;
-
- if (update_days)
- for (i = 0; i < 7; i++)
- gncal_day_view_update (wview->days[i], object, flags);
-
- /* FIXME: update extra widgets */
-}
-
-void
-gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags)
-{
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- update (wview, TRUE, ico, flags);
-}
-
-void
-gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
-{
- struct tm tm;
- time_t day_start, day_end, week_start, week_end;
- int i;
-
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- tm = *localtime (&start_of_week);
-
- /* back up to start of week (Monday) */
-
- tm.tm_mday -= (tm.tm_wday == 0) ? 6 : (tm.tm_wday - 1);
-
- /* Start of day */
-
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- day_start = week_start = mktime (&tm);
-
- /* Calendar */
-
- gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
-
- /* Day views */
-
- for (i = 0; i < 7; i++) { /* rest of days */
- tm.tm_mday++;
- day_end = mktime (&tm);
-
- gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
-
- day_start = day_end;
- }
-
- update (wview, FALSE, NULL, 0);
-
- /* The label */
- {
- char buf [3][100];
-
- week_end = time_add_day (week_start, 6);
-
- strftime (buf[0], sizeof (buf[0]), _("%a %b %d %Y"),
- localtime(&week_start));
-
- strftime (buf[1], sizeof (buf[1]), _("%a %b %d %Y"),
- localtime(&week_end));
-
- g_snprintf(buf[2], sizeof(buf[2]), "%s - %s", buf[0], buf[1]);
- gtk_label_set (GTK_LABEL (wview->label), buf[2]);
-
- }
-}
-
-void
-gncal_week_view_time_format_changed (GncalWeekView *wview)
-{
- g_return_if_fail (wview != NULL);
- g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
-
- gtk_calendar_display_options (wview->gtk_calendar,
- (week_starts_on_monday
- ? (wview->gtk_calendar->display_flags
- | GTK_CALENDAR_WEEK_START_MONDAY)
- : (wview->gtk_calendar->display_flags
- & ~GTK_CALENDAR_WEEK_START_MONDAY)));
-}
diff --git a/calendar/gui/gncal-week-view.h b/calendar/gui/gncal-week-view.h
deleted file mode 100644
index ab06161844..0000000000
--- a/calendar/gui/gncal-week-view.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Week view composite widget for gncal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef WEEK_VIEW_H
-#define WEEK_VIEW_H
-
-
-#include <gtk/gtkvbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkvbox.h>
-#include <libgnome/gnome-defs.h>
-#include "gnome-cal.h"
-#include "gncal-day-view.h"
-
-BEGIN_GNOME_DECLS
-
-
-#define GNCAL_WEEK_VIEW(obj) GTK_CHECK_CAST (obj, gncal_week_view_get_type (), GncalWeekView)
-#define GNCAL_WEEK_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_week_view_get_type (), GncalWeekViewClass)
-#define GNCAL_IS_WEEK_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_week_view_get_type ())
-
-
-typedef struct _GncalWeekView GncalWeekView;
-typedef struct _GncalWeekViewClass GncalWeekViewClass;
-
-struct _GncalWeekView {
- GtkVBox box;
-
- GnomeCalendar *calendar; /* the calendar we are associated to */
-
- struct tm start_of_week;
-
- GncalDayView *days[7]; /* the day view widgets */
- GtkCalendar *gtk_calendar; /* At least for now; see the FIXME comments in the .c file */
- GtkWidget *label;
-};
-
-struct _GncalWeekViewClass {
- GtkVBoxClass parent_class;
-};
-
-
-guint gncal_week_view_get_type (void);
-GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week);
-
-void gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags);
-void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week);
-void gncal_week_view_time_format_changed (GncalWeekView *wview);
-
-
-END_GNOME_DECLS
-
-#endif
diff --git a/calendar/gui/layout.c b/calendar/gui/layout.c
deleted file mode 100644
index 4195c464ae..0000000000
--- a/calendar/gui/layout.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/* Event layout engine for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#include <config.h>
-#include <stdlib.h>
-#include "layout.h"
-
-
-/* This structure is used to pass around layout information among the internal layout functions */
-struct layout_info {
- GList *events; /* List of events from client */
- int num_events; /* The number of events (length of the list) */
- LayoutQueryTimeFunc func; /* Function to convert a list item to a start/end time pair */
- int num_rows; /* Size of the time partition */
- time_t *partition; /* The time partition containing start and end time values */
- int *array; /* Working array of free and allocated time slots */
- int *allocations; /* Returned array of slot allocations */
- int *slots; /* Returned array of slots used */
- int num_slots; /* Number of slots used */
-};
-
-
-/* This defines the maximum number of events to overlap per row. More than that number of events
- * will not be displayed. This is not ideal, so sue me.
- */
-#define MAX_EVENTS_PER_ROW 32
-
-
-/* Compares two time_t values, used for qsort() */
-static int
-compare_time_t (const void *a, const void *b)
-{
- time_t ta, tb;
-
- ta = *((time_t *) a);
- tb = *((time_t *) b);
-
- if (ta < tb)
- return -1;
- else if (ta > tb)
- return 1;
- else
- return 0;
-}
-
-/* Builds a partition of the time range occupied by the events in the list. It returns an array
- * with the times that define the partition and the number of items in the partition.
- */
-static void
-build_partition (struct layout_info *li)
-{
- time_t *rows, *p, *q;
- GList *list;
- int i, unique_vals;
-
- /* This is the maximum number of rows we would need */
-
- li->num_rows = li->num_events * 2;
-
- /* Fill the rows with the times */
-
- rows = g_new (time_t, li->num_rows);
-
- for (list = li->events, p = rows; list; list = list->next) {
- (* li->func) (list, &p[0], &p[1]);
- p += 2;
- }
-
- /* Do a sort | uniq on the array */
-
- qsort (rows, li->num_rows, sizeof (time_t), compare_time_t);
-
- p = rows;
- q = rows + 1;
- unique_vals = 1;
-
- for (i = 1; i < li->num_rows; i++, q++)
- if (*q != *p) {
- unique_vals++;
- p++;
- *p = *q;
- }
-
- /* Return the number of unique values in the partition and the partition array itself */
-
- li->num_rows = unique_vals;
- li->partition = rows;
-}
-
-/* Returns the index of the element in the partition that corresponds to the specified time */
-static int
-find_index (struct layout_info *li, time_t t)
-{
- int i;
-
- for (i = 0; ; i++)
- if (li->partition[i] == t)
- return i;
-
- g_assert_not_reached ();
-}
-
-#define xy(li, x, y) li->array[(y * MAX_EVENTS_PER_ROW) + (x)]
-
-/* Checks that all the cells in the slot array at the specified slot column are free to use by an
- * event that has the specified range.
- */
-static int
-range_is_empty (struct layout_info *li, int slot, time_t start, time_t end)
-{
- int i;
-
- for (i = find_index (li, start); li->partition[i] < end; i++)
- if (xy (li, slot, i) != -1)
- return FALSE;
-
- return TRUE;
-}
-
-/* Allocates a time in the slot array for the specified event's index */
-static void
-range_allocate (struct layout_info *li, int slot, time_t start, time_t end, int ev_num)
-{
- int i;
-
- for (i = find_index (li, start); li->partition[i] < end; i++)
- xy (li, slot, i) = ev_num;
-}
-
-/* Performs the initial allocation of slots for events. Each event gets one column; they will be
- * expanded in a later stage. Returns the number of columns used.
- */
-static void
-initial_allocate (struct layout_info *li)
-{
- GList *events;
- int i;
- int slot;
- int num_slots;
- time_t start, end;
-
- num_slots = 0;
-
- for (i = 0, events = li->events; events; events = events->next, i++) {
- (* li->func) (events, &start, &end);
-
- /* Start with no allocation, no columns */
-
- li->allocations[i] = -1;
- li->slots[i] = 0;
-
- /* Find a free column for the event */
-
- for (slot = 0; slot < MAX_EVENTS_PER_ROW; slot++)
- if (range_is_empty (li, slot, start, end)) {
- range_allocate (li, slot, start, end, i);
-
- li->allocations[i] = slot;
- li->slots[i] = 1;
-
- if ((slot + 1) > num_slots)
- num_slots = slot + 1;
-
- break;
- }
- }
-
- li->num_slots = num_slots;
-}
-
-/* Returns the maximum number of columns that an event can expanded by in the slot array */
-static int
-columns_to_expand (struct layout_info *li, int ev_num, time_t start, time_t end)
-{
- int cols;
- int slot;
- int i_start;
- int i;
-
- cols = 0;
-
- i_start = find_index (li, start);
-
- for (slot = li->allocations[ev_num] + 1; slot < li->num_slots; slot++) {
- for (i = i_start; li->partition[i] < end; i++)
- if (xy (li, slot, i) != -1)
- return cols;
-
- cols++;
- }
-
- return cols;
-}
-
-/* Expands an event by the specified number of columns */
-static void
-do_expansion (struct layout_info *li, int ev_num, time_t start, time_t end, int num_cols)
-{
- int i, j;
- int slot;
-
- for (i = find_index (li, start); li->partition[i] < end; i++) {
- slot = li->allocations[ev_num] + 1;
-
- for (j = 0; j < num_cols; j++)
- xy (li, slot + j, i) = ev_num;
- }
-}
-
-/* Expands the events in the slot array to occupy as many columns as possible. This is the second
- * pass of the layout algorithm.
- */
-static void
-expand_events (struct layout_info *li)
-{
- GList *events;
- time_t start, end;
- int i;
- int cols;
-
- for (i = 0, events = li->events; events; events = events->next, i++) {
- (* li->func) (events, &start, &end);
-
- cols = columns_to_expand (li, i, start, end);
-
- if (cols == 0)
- continue; /* We can't expand this event */
-
- do_expansion (li, i, start, end, cols);
-
- li->slots[i] += cols;
- }
-}
-
-void
-layout_events (GList *events, LayoutQueryTimeFunc func, int *num_slots, int **allocations, int **slots)
-{
- struct layout_info li;
- int i;
-
- g_return_if_fail (num_slots != NULL);
- g_return_if_fail (allocations != NULL);
- g_return_if_fail (slots != NULL);
-
- if (!events) {
- *num_slots = 0;
- *allocations = NULL;
- *slots = NULL;
-
- return;
- }
-
- li.events = events;
- li.num_events = g_list_length (events);
- li.func = func;
-
- /* Build the partition of the time range, and then build the array of slots */
-
- build_partition (&li);
-
- li.array = g_new (int, li.num_rows * MAX_EVENTS_PER_ROW);
- for (i = 0; i < (li.num_rows * MAX_EVENTS_PER_ROW); i++)
- li.array[i] = -1; /* This is our 'empty' value */
-
- /* Build the arrays for allocations and columns used */
-
- li.allocations = g_new (int, li.num_events);
- li.slots = g_new (int, li.num_events);
-
- /* Perform initial allocation and then expand the events to as many slots as they can occupy */
-
- initial_allocate (&li);
- expand_events (&li);
-
- /* Clean up and return values */
-
- g_free (li.partition);
- g_free (li.array);
-
- *num_slots = li.num_slots;
- *allocations = li.allocations;
- *slots = li.slots;
-}
diff --git a/calendar/gui/layout.h b/calendar/gui/layout.h
deleted file mode 100644
index 734b720b8b..0000000000
--- a/calendar/gui/layout.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Event layout engine for Gnomecal
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-
-#ifndef LAYOUT_H
-#define LAYOUT_H
-
-#include <glib.h>
-#include <time.h>
-
-
-/* Functions of this type must translate the list item into two time_t values for the start and end
- * of an event.
- */
-typedef void (* LayoutQueryTimeFunc) (GList *event, time_t *start, time_t *end);
-
-
-/* This is the main layout function for overlapping events. You pass in a list of (presumably)
- * events and a function that should take a list element and return the start and end times for the
- * event corresponding to that list element.
- *
- * It returns the number of slots ("columns") that you need to take into account when actually
- * painting the events, the array of the first slot index that each event occupies, and the array of
- * number of slots that each event occupies. You have to free both arrays.
- *
- * You will get somewhat better-looking results if the list of events is sorted by using the start
- * time as the primary sort key and the end time as the secondary sort key -- so that "longer"
- * events go first in the list.
- */
-void layout_events (GList *events, LayoutQueryTimeFunc func, int *num_slots, int **allocations, int **slots);
-
-
-#endif
diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c
deleted file mode 100644
index 2de95a4781..0000000000
--- a/calendar/gui/view-utils.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Authors: Federico Mena <quartic@gimp.org>
- * Miguel de Icaza <miguel@kernel.org>
- */
-
-#include <string.h>
-#include "view-utils.h"
-#include <libgnomeui/gnome-icon-text.h>
-#include "gnome-cal.h"
-#include "calendar-commands.h"
-
-int am_pm_flag = 0;
-
-static char *
-nicetime (struct tm *tm)
-{
- static char buf [20];
- char *p = buf;
-
- if (am_pm_flag){
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%l:%M%p", tm);
- else
- strftime (buf, sizeof (buf), "%l%p", tm);
- } else {
- if (tm->tm_min)
- strftime (buf, sizeof (buf), "%H:%M", tm);
- else
- strftime (buf, sizeof (buf), "%H", tm);
- }
- while (*p == ' ')
- p++;
- return p;
-}
-
-typedef struct {
- GnomeIconTextInfo *layout;
- int lines;
- int assigned_lines;
-} line_info_t;
-
-void
-view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end)
-{
- GdkFont *font = widget->style->font;
- int font_height;
- int y, max_y, items, i, need_more, nlines, base, extra;
- GList *list;
- line_info_t *lines;
-
- if (events == NULL)
- return;
-
- items = g_list_length (events);
- lines = g_new0 (line_info_t, items);
-
- font_height = font->ascent + font->descent;
- max_y = area->y + area->height - font_height * ((flags & VIEW_UTILS_DRAW_SPLIT) ? 2 : 1);
-
- /*
- * Layout all the lines, measure the space needs
- */
- for (i = 0, list = events; list; list = list->next, i++){
- CalendarObject *co = list->data;
- struct tm tm_start, tm_end;
- iCalObject *ico = co->ico;
- char buf [60];
- char *full_text;
-
- tm_start = *localtime (&co->ev_start);
- tm_end = *localtime (&co->ev_end);
-
- strcpy (buf, nicetime (&tm_start));
-
- if (flags & VIEW_UTILS_DRAW_END){
- strcat (buf, "-");
- strcat (buf, nicetime (&tm_end));
- }
-
- full_text = g_strconcat (buf, ": ", ico->summary, NULL);
- lines [i].layout = gnome_icon_layout_text (
- font, full_text, "\n -,.;:=#", area->width, TRUE);
- lines [i].lines = g_list_length (lines [i].layout->rows);
-
- g_free (full_text);
- }
-
- /*
- * Compute how many lines we will give to each row
- */
- nlines = 1 + max_y / font_height;
- base = nlines / items;
- extra = nlines % items;
- need_more = 0;
-
- for (i = 0; i < items; i++){
- if (lines [i].lines <= base){
- extra += base - lines [i].lines;
- lines [i].assigned_lines = lines [i].lines;
- } else {
- need_more++;
- lines [i].assigned_lines = base;
- }
- }
-
- /*
- * use any extra space
- */
- while (need_more && extra > 0){
- need_more = 0;
-
- for (i = 0; i < items; i++){
- if (lines [i].lines > lines [i].assigned_lines){
- lines [i].assigned_lines++;
- extra--;
- }
-
- if (extra == 0)
- break;
-
- if (lines [i].lines > lines [i].assigned_lines)
- need_more = 1;
- }
- }
-
- /*
- * Draw the information
- */
- gdk_gc_set_clip_rectangle (gc, area);
- y = area->y;
- for (i = 0; i < items; i++){
- int line;
-
- list = lines [i].layout->rows;
-
- for (line = 0; line < lines [i].assigned_lines; line++){
- GnomeIconTextInfoRow *row = list->data;
-
- list = list->next;
-
- if (row)
- gdk_draw_string (
- window, font, gc,
- area->x, y + font->ascent,
- row->text);
- y += font_height;
- }
- }
-
- gdk_gc_set_clip_rectangle (gc, NULL);
-
- /*
- * Free resources.
- */
-
- for (i = 0; i < items; i++)
- gnome_icon_text_info_free (lines [i].layout);
- g_free (lines);
-}
-
-void
-view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow)
-{
- int x, y;
- int xthick, ythick;
- GdkGC *light_gc, *dark_gc;
-
- gdk_draw_rectangle (window,
- widget->style->bg_gc[GTK_STATE_NORMAL],
- TRUE,
- rect->x, rect->y,
- rect->width, rect->height);
-
- light_gc = widget->style->light_gc[GTK_STATE_NORMAL];
- dark_gc = widget->style->dark_gc[GTK_STATE_NORMAL];
-
- xthick = widget->style->klass->xthickness;
- ythick = widget->style->klass->ythickness;
-
- gdk_gc_set_clip_rectangle (light_gc, rect);
- gdk_gc_set_clip_rectangle (dark_gc, rect);
-
- for (y = rect->y + ythick; y < (rect->y + rect->height - ythick); y += 3)
- for (x = rect->x + xthick; x < (rect->x + rect->width - xthick); x += 6) {
- gdk_draw_point (window, light_gc, x, y);
- gdk_draw_point (window, dark_gc, x + 1, y + 1);
-
- gdk_draw_point (window, light_gc, x + 3, y + 1);
- gdk_draw_point (window, dark_gc, x + 4, y + 2);
- }
-
- gdk_gc_set_clip_rectangle (light_gc, NULL);
- gdk_gc_set_clip_rectangle (dark_gc, NULL);
-
- gtk_draw_shadow (widget->style, window,
- GTK_STATE_NORMAL, shadow,
- rect->x, rect->y,
- rect->width, rect->height);
-}
diff --git a/calendar/gui/view-utils.h b/calendar/gui/view-utils.h
deleted file mode 100644
index af9f52fec1..0000000000
--- a/calendar/gui/view-utils.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Miscellaneous utility functions for the calendar view widgets
- *
- * Copyright (C) 1998 The Free Software Foundation
- *
- * Author: Federico Mena <quartic@gimp.org>
- */
-
-#ifndef VIEW_UTILS_H
-#define VIEW_UTILS_H
-
-
-#include <gtk/gtk.h>
-#include <cal-util/calobj.h>
-
-
-enum {
- VIEW_UTILS_DRAW_END = 1 << 0,
- VIEW_UTILS_DRAW_SPLIT = 1 << 1
-};
-
-
-void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area,
- int flags, GList *events, time_t start, time_t end);
-
-void view_utils_draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow);
-
-
-#endif