aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/goto.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-08-30 09:29:19 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-08-30 09:29:19 +0800
commite0d99122ab17d9bf356cf793b41aec6b6d6016b1 (patch)
treeb2f202ce6ea0b927a8fa4929034c84af223ef782 /calendar/goto.c
parent9b6991077bd564348e9dd229ca523bdaa8239ed1 (diff)
downloadgsoc2013-evolution-e0d99122ab17d9bf356cf793b41aec6b6d6016b1.tar.gz
gsoc2013-evolution-e0d99122ab17d9bf356cf793b41aec6b6d6016b1.tar.zst
gsoc2013-evolution-e0d99122ab17d9bf356cf793b41aec6b6d6016b1.zip
Centralized marking of month items. We now have a little utility function
Centralized marking of month items. We now have a little utility function to colorify the days in a month item that have events scheduled for them. This is currently used by the year view and the go-to dialog. Fixed buglets here and there. 1998-08-29 Federico Mena Quintero <federico@nuclecu.unam.mx> * mark.[ch]: New files with utility functions to mark calendars with their events. * mark.c (mark_month_item): New public function to mark a month item with events. (unmark_month_item): New public function to unmark all the days in a month item to their default appearance. * year-view.c (year_view_set): Use the new unmark_month_item() and mark_month_item() to mark the months with events. * goto.c (update): New function that updates the calendar in the Go-to dialog by marking the days. * timeutil.c (time_year_begin): Modified to take a time_t value. (time_year_end): Likewise. (time_month_begin): Actually implemented this function, which was in the header file but not here. (time_days_in_month): New public function that returns the number of days in a month. * Makefile.am (gnomecal_SOURCES): Added mark.[ch] to the sources. * year-view.c (unmark_days): Use unmark_month_item(). * gncal-full-day.c (gncal_full_day_destroy): Fixed crash when destroying the full day view. The full day's destroy method is unusual in that it destroys the list of child widgets itself, as it does not have a remove method, so it needs to reset the list to NULL. svn path=/trunk/; revision=351
Diffstat (limited to 'calendar/goto.c')
-rw-r--r--calendar/goto.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/calendar/goto.c b/calendar/goto.c
index c3ac3a157e..c312189ce7 100644
--- a/calendar/goto.c
+++ b/calendar/goto.c
@@ -10,38 +10,21 @@
#include "gnome-cal.h"
#include "gnome-month-item.h"
#include "main.h"
+#include "mark.h"
#include "timeutil.h"
+/* Updates the specified month item by marking it appropriately from the calendar the dialog refers
+ * to. */
static void
-highlight_current_day (GnomeMonthItem *mitem)
+update (GnomeMonthItem *mitem, GtkWidget *dialog)
{
- struct tm *tm;
- time_t t;
- GnomeCanvasItem *label;
- int i;
-
- t = time (NULL);
- tm = localtime (&t);
-
- /* First clear all the days to normal */
-
- for (i = 0; i < 42; i++) {
- label = gnome_month_item_num2child (mitem, i + GNOME_MONTH_ITEM_DAY_LABEL);
- gnome_canvas_item_set (label,
- "fill_color", "black",
- NULL);
- }
+ GnomeCalendar *gcal;
- /* Highlight the current day, if appropriate */
+ gcal = GNOME_CALENDAR (gtk_object_get_data (GTK_OBJECT (dialog), "gnome_calendar"));
- if ((mitem->year == (tm->tm_year + 1900)) && (mitem->month == tm->tm_mon)) {
- i = gnome_month_item_day2index (mitem, tm->tm_mday);
- label = gnome_month_item_num2child (mitem, i + GNOME_MONTH_ITEM_DAY_LABEL);
- gnome_canvas_item_set (label,
- "fill_color", "blue",
- NULL);
- }
+ unmark_month_item (mitem);
+ mark_month_item (mitem, gcal->cal);
}
/* Callback used when the year adjustment is changed */
@@ -54,7 +37,7 @@ year_changed (GtkAdjustment *adj, GtkWidget *dialog)
gnome_canvas_item_set (mitem,
"year", (int) adj->value,
NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
+ update (GNOME_MONTH_ITEM (mitem), dialog);
}
/* Creates the year control with its adjustment */
@@ -99,7 +82,7 @@ month_toggled (GtkToggleButton *toggle, gpointer data)
gnome_canvas_item_set (mitem,
"month", GPOINTER_TO_INT (data),
NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
+ update (GNOME_MONTH_ITEM (mitem), dialog);
}
/* Creates the months control */
@@ -236,7 +219,7 @@ create_days (GtkWidget *dialog, GnomeCalendar *gcal, int day, int month, int yea
"start_on_monday", week_starts_on_monday,
"heading_color", "white",
NULL);
- highlight_current_day (GNOME_MONTH_ITEM (mitem));
+ update (GNOME_MONTH_ITEM (mitem), dialog);
gtk_object_set_data (GTK_OBJECT (dialog), "month_item", mitem);