aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog14
-rw-r--r--calendar/gui/Makefile.am3
-rw-r--r--calendar/gui/calendar-commands.c13
-rw-r--r--calendar/gui/goto.c40
-rw-r--r--calendar/gui/mark.c300
-rw-r--r--calendar/gui/mark.h75
-rw-r--r--calendar/gui/prop.c46
7 files changed, 40 insertions, 451 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 19dff51e65..749deb02c0 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,19 @@
2000-12-22 JP Rosevear <jpr@helixcode.com>
+ * gui/goto.c (ecal_date_range_changed): New function to keep the
+ ecal marked properly
+ (create_ecal): move more creation code here, update marks
+ (goto_dialog_init_widgets): listen for date_range_changed signal
+ in the ecal
+
+ * gui/calendar-commands.c (init_calendar): Remove ancient gnomecal
+ cruft
+
+ * gui/mark.[hc], gui/prop.c: Remove ancient gnomecal code that is
+ no longer needed, last bit of bug 904
+
+2000-12-22 JP Rosevear <jpr@helixcode.com>
+
* gui/goto-dialog.glade.h: translations
* gui/goto-dialog.glade: new glade file for goto dialog
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 67422a9af3..db2da7da5d 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -116,13 +116,10 @@ evolution_calendar_SOURCES = \
itip-utils.c \
itip-utils.h \
main.c \
- mark.c \
- mark.h \
popup-menu.c \
popup-menu.h \
print.c \
print.h \
- prop.c \
tag-calendar.c \
tag-calendar.h \
weekday-picker.c \
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index f538885a3c..94fc3aa57d 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -599,19 +599,6 @@ init_calendar (void)
day_end = 17;
}
- /* Read color settings */
-
- for (i = 0; i < COLOR_PROP_LAST; i++) {
- cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b);
- str = g_strconcat (color_props[i].key, "=", cspec, NULL);
-
- color = gnome_config_get_string (str);
- parse_color_spec (color, &color_props[i].r, &color_props[i].g, &color_props[i].b);
-
- g_free (str);
- g_free (color);
- }
-
/* read alarm settings */
beep_on_display = gnome_config_get_bool ("/calendar/alarms/beep_on_display=FALSE");
enable_aalarm_timeout = gnome_config_get_bool ("/calendar/alarms/enable_audio_timeout=FALSE");
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index 71d377f2b8..d726544f98 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -11,6 +11,7 @@
#include <gnome.h>
#include <glade/glade.h>
#include "calendar-commands.h"
+#include "tag-calendar.h"
#include "goto.h"
typedef struct
@@ -56,6 +57,17 @@ month_changed (GtkToggleButton *toggle, gpointer data)
e_calendar_item_set_first_month (dlg->ecal->calitem, dlg->year_val, dlg->month_val);
}
+static void
+ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data)
+{
+ GoToDialog *dlg = user_data;
+ CalClient *client;
+
+ client = gnome_calendar_get_cal_client (dlg->gcal);
+ if (client)
+ tag_calendar_by_client (dlg->ecal, client);
+}
+
/* Event handler for day groups in the month item. A button press makes the calendar jump to the
* selected day and destroys the Go-to dialog box.
*/
@@ -76,17 +88,16 @@ ecal_event (ECalendarItem *calitem, gpointer user_data)
gnome_dialog_close (GNOME_DIALOG (dlg->dialog));
}
-/* Creates the canvas with the month item for selecting days */
-static ECalendar *
-create_ecal (void)
+/* Creates the ecalendar */
+static void
+create_ecal (GoToDialog *dlg)
{
- ECalendar *ecal;
-
- ecal = E_CALENDAR (e_calendar_new ());
+ dlg->ecal = E_CALENDAR (e_calendar_new ());
+ e_calendar_item_set_display_popup (dlg->ecal->calitem, FALSE);
+ gtk_widget_show (GTK_WIDGET (dlg->ecal));
+ gtk_box_pack_start (GTK_BOX (dlg->vbox), GTK_WIDGET (dlg->ecal), TRUE, TRUE, 0);
- e_calendar_item_set_display_popup (ecal->calitem, FALSE);
-
- return ecal;
+ ecal_date_range_changed (dlg->ecal->calitem, dlg);
}
static void
@@ -95,8 +106,7 @@ goto_today (GoToDialog *dlg)
gnome_calendar_goto_today (dlg->gcal);
}
-/* Gets the widgets from the XML file and returns if they are all available.
- */
+/* Gets the widgets from the XML file and returns if they are all available. */
static gboolean
get_widgets (GoToDialog *dlg)
{
@@ -133,6 +143,10 @@ goto_dialog_init_widgets (GoToDialog *dlg)
(GtkSignalFunc) year_changed, dlg);
gtk_signal_connect (GTK_OBJECT (dlg->ecal->calitem),
+ "date_range_changed",
+ GTK_SIGNAL_FUNC (ecal_date_range_changed),
+ dlg);
+ gtk_signal_connect (GTK_OBJECT (dlg->ecal->calitem),
"selection_changed",
(GtkSignalFunc) ecal_event,
dlg);
@@ -176,9 +190,7 @@ goto_dialog (GnomeCalendar *gcal)
gtk_option_menu_set_history (GTK_OPTION_MENU (dlg->month), dlg->month_val);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->year), dlg->year_val);
- dlg->ecal = create_ecal ();
- gtk_box_pack_start (GTK_BOX (dlg->vbox), GTK_WIDGET (dlg->ecal), TRUE, TRUE, 0);
- gtk_widget_show (GTK_WIDGET (dlg->ecal));
+ create_ecal (dlg);
goto_dialog_init_widgets (dlg);
diff --git a/calendar/gui/mark.c b/calendar/gui/mark.c
deleted file mode 100644
index 1b90d390dd..0000000000
--- a/calendar/gui/mark.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/* Evolution calendar - Functions to mark calendars
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <cal-util/timeutil.h>
-#include "gnome-cal.h"
-#include "calendar-commands.h"
-#include "mark.h"
-
-/* Closure data */
-struct minfo
-{
- GnomeMonthItem *mitem;
- time_t start;
- time_t end;
-};
-
-
-
-/* Frees the specified data when an object is destroyed */
-static void
-free_data (GtkObject *object, gpointer data)
-{
- g_free (data);
-}
-
-/* If the array of "marked" attributes for the days in a a month item has not been created yet, this
- * function creates the array and clears it. Otherwise, it just returns the existing array.
- */
-static char *
-get_attributes (GnomeMonthItem *mitem)
-{
- char *attrs;
-
- attrs = gtk_object_get_data (GTK_OBJECT (mitem), "day_mark_attributes");
-
- if (!attrs) {
- attrs = g_new0 (char, 42);
- gtk_object_set_data (GTK_OBJECT (mitem), "day_mark_attributes", attrs);
- gtk_signal_connect (GTK_OBJECT (mitem), "destroy",
- (GtkSignalFunc) free_data,
- attrs);
- }
-
- return attrs;
-}
-
-void
-colorify_month_item (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data)
-{
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (func != NULL);
-
- unmark_month_item (mitem);
-
- /* We have to do this in several calls to gnome_canvas_item_set(), as color_spec_from_prop()
- * returns a pointer to a static string -- and we need several values.
- */
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "heading_color", (* func) (COLOR_PROP_HEADING_COLOR, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "outline_color", (* func) (COLOR_PROP_OUTLINE_COLOR, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "day_box_color", (* func) (COLOR_PROP_EMPTY_DAY_BG, func_data),
- NULL);
-
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (mitem),
- "day_color", (* func) (COLOR_PROP_DAY_FG, func_data),
- NULL);
-}
-
-/* In the month item, marks all the days that are touched by the specified time span. Assumes that
- * the time span is completely contained within the month. The array of day attributes is modified
- * accordingly.
- */
-static void
-mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end)
-{
- struct tm tm;
- int day_index;
-
- tm = *localtime (&start);
-
- for (; start <= end; start += 60 * 60 * 24) {
- mktime (&tm); /* normalize the time */
-
- /* Figure out the day index that corresponds to this time */
-
- day_index = gnome_month_item_day2index (mitem, tm.tm_mday);
- g_assert (day_index >= 0);
-
- /* Mark the day box */
-
- mark_month_item_index (mitem, day_index, default_color_func, NULL);
-
- /* Next day */
-
- tm.tm_mday++;
- }
-}
-
-static gboolean
-mark_month_item_cb (CalComponent *comp, time_t istart, time_t iend, gpointer data)
-{
- struct minfo *mi = (struct minfo *)data;
-
- mark_event_in_month (mi->mitem, MAX (istart, mi->start), MIN (iend, mi->end));
-
- return TRUE;
-}
-
-void
-mark_month_item (GnomeMonthItem *mitem, GnomeCalendar *gcal)
-{
- CalClient *client;
- struct minfo mi;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
- client = gnome_calendar_get_cal_client (gcal);
-
- mi.mitem = mitem;
- mi.start = time_month_begin (time_from_day (mitem->year, mitem->month, 1));
- mi.end = time_month_end (mi.start);
-
- cal_client_generate_instances (client, CALOBJ_TYPE_EVENT, mi.start, mi.end,
- mark_month_item_cb, &mi);
-}
-
-
-void
-mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data)
-{
- char *attrs;
- GnomeCanvasItem *item;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail ((index >= 0) && (index < 42));
- g_return_if_fail (func != NULL);
-
- attrs = get_attributes (mitem);
-
- attrs[index] = TRUE;
-
- item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + index);
- gnome_canvas_item_set (item,
- "fill_color", (* func) (COLOR_PROP_MARK_DAY_BG, func_data),
- NULL);
-}
-
-void
-unmark_month_item (GnomeMonthItem *mitem)
-{
- int i;
- char *attrs;
- GnomeCanvasItem *item;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
-
- attrs = get_attributes (mitem);
-
- /* Find marked days and unmark them by turning off their marked attribute flag and changing
- * the color.
- */
-
- for (i = 0; i < 42; i++)
- if (attrs[i]) {
- attrs[i] = FALSE;
-
- item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + i);
- gnome_canvas_item_set (item,
- "fill_color", color_spec_from_prop (COLOR_PROP_EMPTY_DAY_BG),
- NULL);
- }
-}
-
-/* Handles EnterNotify and LeaveNotify events from the month item's day groups, and performs
- * appropriate prelighting.
- */
-static gint
-day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
-{
- GnomeMonthItem *mitem;
- GnomeCanvasItem *box;
- int child_num, day;
- GetColorFunc func;
- gpointer func_data;
- char *color;
- char *attrs;
-
- /* We only accept enters and leaves */
-
- if (!((event->type == GDK_ENTER_NOTIFY) || (event->type == GDK_LEAVE_NOTIFY)))
- return FALSE;
-
- /* Get index information */
-
- mitem = GNOME_MONTH_ITEM (data);
- child_num = gnome_month_item_child2num (mitem, item);
- day = gnome_month_item_num2day (mitem, child_num);
-
- if (day == 0)
- return FALSE; /* it was a day outside the month's range */
-
- child_num -= GNOME_MONTH_ITEM_DAY_GROUP;
- box = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_BOX + child_num);
-
- /* Get colors */
-
- func = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_func");
- func_data = gtk_object_get_data (GTK_OBJECT (mitem), "prelight_color_data");
-
- /* Now actually set the proper color in the item */
-
- switch (event->type) {
- case GDK_ENTER_NOTIFY:
- color = (* func) (COLOR_PROP_PRELIGHT_DAY_BG, func_data);
- gnome_canvas_item_set (box,
- "fill_color", color,
- NULL);
- break;
-
- case GDK_LEAVE_NOTIFY:
- attrs = get_attributes (mitem);
- color = (* func) (attrs[child_num] ? COLOR_PROP_MARK_DAY_BG : COLOR_PROP_EMPTY_DAY_BG,
- func_data);
- gnome_canvas_item_set (box,
- "fill_color", color,
- NULL);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- return TRUE;
-}
-
-void
-month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data)
-{
- GnomeCanvasItem *day_group;
- int i;
-
- g_return_if_fail (mitem != NULL);
- g_return_if_fail (GNOME_IS_MONTH_ITEM (mitem));
- g_return_if_fail (func != NULL);
-
- /* Store the function in the object data */
-
- gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_func", func);
- gtk_object_set_data (GTK_OBJECT (mitem), "prelight_color_data", func_data);
-
- /* Connect the appropriate signals to perform prelighting */
-
- for (i = 0; i < 42; i++) {
- day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), GNOME_MONTH_ITEM_DAY_GROUP + i);
- gtk_signal_connect (GTK_OBJECT (day_group), "event",
- (GtkSignalFunc) day_event,
- mitem);
- }
-}
-
-char *
-default_color_func (ColorProp propnum, gpointer data)
-{
- return color_spec_from_prop (propnum);
-}
-
-
-
diff --git a/calendar/gui/mark.h b/calendar/gui/mark.h
deleted file mode 100644
index 76c82c580d..0000000000
--- a/calendar/gui/mark.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Evolution calendar - Functions to mark calendars
- *
- * Copyright (C) 1998 Red Hat Software, Inc.
- *
- * Author: Federico Mena-Quintero <federico@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef MARK_H
-#define MARK_H
-
-/*#include "calendar.h"*/
-#include "gnome-month-item.h"
-
-
-
-/* These are the fonts used for the montly calendars */
-
-#define HEADING_FONTSET "-adobe-helvetica-medium-r-*-*-14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-*-*-14-*-*-*-*-*-ksc5601.1987-0,*"
-#define TITLE_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*"
-#define DAY_HEADING_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-#define NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-#define CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--12-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-14-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--12-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_DAY_HEADING_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_NORMAL_DAY_FONTSET "-adobe-helvetica-medium-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define BIG_CURRENT_DAY_FONTSET "-adobe-helvetica-bold-r-normal--14-*-*-*-p-*-*-*,-cronyx-helvetica-bold-r-normal-*-17-*-*-*-p-*-koi8-r,-*-*-bold-r-normal--14-*-*-*-*-*-ksc5601.1987-0,*"
-#define EVENT_FONTSET "-adobe-helvetica-medium-r-*-*-10-*-*-*-p-*-*-*,-cronyx-helvetica-medium-r-normal-*-11-*-*-*-p-*-koi8-r,-*-*-medium-r-normal--10-*-*-*-*-*-ksc5601.1987-0,*"
-
-
-/* Functions of this type are used by the marking functions to fetch color specifications. Such
- * a function must return a color spec based on the property passed to it.
- */
-typedef char * (* GetColorFunc) (ColorProp propnum, gpointer data);
-
-
-/* Sets the user-configured colors and font for a month item. It also tags the days as unmarked. */
-void colorify_month_item (GnomeMonthItem *month, GetColorFunc func, gpointer func_data);
-
-/* Takes a monthly calendar item and marks the days that have events
- * scheduled for them in the specified calendar. It also highlights
- * the current day.
- */
-void mark_month_item (GnomeMonthItem *mitem, GnomeCalendar *cal);
-
-/* Marks a day specified by index, not by day number */
-void mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data);
-
-/* Unmarks all the days in the specified month item */
-void unmark_month_item (GnomeMonthItem *mitem);
-
-/* Prepares a monthly calendar item to prelight when the mouse goes over the days. */
-
-void month_item_prepare_prelight (GnomeMonthItem *mitem, GetColorFunc func, gpointer func_data);
-
-/* This is the default prelight function you can use for most puposes. You can use NULL as the
- * func_data.
- */
-char *default_color_func (ColorProp prop_num, gpointer data);
-
-
-
-#endif
diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c
deleted file mode 100644
index 41ee5edb39..0000000000
--- a/calendar/gui/prop.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Calendar properties dialog box
- *
- * Copyright (C) 1998 the Free Software Foundation
- *
- * Authors: Miguel de Icaza <miguel@kernel.org>
- * Federico Mena <federico@nuclecu.unam.mx>
- */
-#include <config.h>
-#ifdef HAVE_LANGINGO_H
-#include <langinfo.h>
-#else
-#include <locale.h>
-#endif
-#include <gnome.h>
-#include "calendar-commands.h"
-
-
-char *
-build_color_spec (int r, int g, int b)
-{
- static char spec[100];
-
- sprintf (spec, "#%04x%04x%04x", r, g, b);
- return spec;
-}
-
-void
-parse_color_spec (char *spec, int *r, int *g, int *b)
-{
- g_return_if_fail (spec != NULL);
- g_return_if_fail (r != NULL);
- g_return_if_fail (r != NULL);
- g_return_if_fail (r != NULL);
-
- if (sscanf (spec, "#%04x%04x%04x", r, g, b) != 3) {
- g_warning ("Invalid color specification %s, returning black", spec);
-
- *r = *g = *b = 0;
- }
-}
-
-char *
-color_spec_from_prop (ColorProp propnum)
-{
- return build_color_spec (color_props[propnum].r, color_props[propnum].g, color_props[propnum].b);
-}