diff options
author | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-30 06:19:39 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-30 06:19:39 +0800 |
commit | 5c1c9710338cb7f3b29ed1eac1006bb95f39c048 (patch) | |
tree | dacbe29633e17a82ac619ea4c0a2fd67a650d56d | |
parent | b14e3c892ce8feac4e72ab80800fb7b6e0408002 (diff) | |
download | gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.gz gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.bz2 gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.lz gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.xz gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.zst gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.zip |
Various fixes and optimizations; Tagging of the days with appointements.
Various fixes and optimizations; Tagging of the days with
appointements. the 1969 bug is gone. Really.
Miguel.
svn path=/trunk/; revision=201
-rw-r--r-- | calendar/ChangeLog | 10 | ||||
-rw-r--r-- | calendar/gncal-day-panel.c | 17 | ||||
-rw-r--r-- | calendar/gncal-day-view.c | 2 | ||||
-rw-r--r-- | calendar/gncal-full-day.c | 5 | ||||
-rw-r--r-- | calendar/gncal-week-view.c | 4 | ||||
-rw-r--r-- | calendar/gnome-cal.c | 53 | ||||
-rw-r--r-- | calendar/gnome-cal.h | 1 | ||||
-rw-r--r-- | calendar/gui/gncal-day-panel.c | 17 | ||||
-rw-r--r-- | calendar/gui/gncal-day-view.c | 2 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 5 | ||||
-rw-r--r-- | calendar/gui/gncal-week-view.c | 4 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 53 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 1 | ||||
-rw-r--r-- | calendar/timeutil.h | 2 |
14 files changed, 160 insertions, 16 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 7ac734b022..81cec3d366 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,13 @@ +1998-04-29 Miguel de Icaza <miguel@nuclecu.unam.mx> + + * gncal-week-view.c (sync_week): Use gnome_calendar_tag_calendar. + + * gnome-cal.c (gnome_calendar_tag_calendar): New routine used to + fill a gtk_calendar with the events on a GnomeCalendar object. + + * gncal-week-view.c (gncal_week_view_new): Set the week to the day + we double clicked. + 1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx> * gnome-cal.c (calendar_notify): Apply black magic to get mail diff --git a/calendar/gncal-day-panel.c b/calendar/gncal-day-panel.c index 26347428a6..5a5a052f73 100644 --- a/calendar/gncal-day-panel.c +++ b/calendar/gncal-day-panel.c @@ -78,6 +78,12 @@ calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel) 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) { @@ -142,6 +148,8 @@ gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day) dpanel->day_selected_id = gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "day_selected", (GtkSignalFunc) calendar_day_selected, dpanel); + gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "month_changed", + GTK_SIGNAL_FUNC (retag_calendar), dpanel); gtk_table_attach (GTK_TABLE (dpanel), w, 1, 2, 1, 2, GTK_FILL | GTK_SHRINK, @@ -180,9 +188,10 @@ gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day) static void update (GncalDayPanel *dpanel, int update_fullday, iCalObject *ico, int flags) { - if (update_fullday) + if (update_fullday){ gncal_full_day_update (dpanel->fullday, ico, flags); - + retag_calendar (dpanel->gtk_calendar, dpanel); + } gncal_todo_update (dpanel->todo, ico, flags); } @@ -205,7 +214,9 @@ gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day) g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel)); dpanel->start_of_day = time_start_of_day (start_of_day); - + if (dpanel->fullday->lower == dpanel->start_of_day) + return; + strftime (buf, sizeof (buf), "%a %b %d %Y", localtime (&dpanel->start_of_day)); gtk_label_set (GTK_LABEL (dpanel->date_label), buf); diff --git a/calendar/gncal-day-view.c b/calendar/gncal-day-view.c index f513d65b83..85d61292f1 100644 --- a/calendar/gncal-day-view.c +++ b/calendar/gncal-day-view.c @@ -6,7 +6,7 @@ * Miguel de Icaza <miguel@kernel.org> */ -#include <gtk/gtksignal.h> +#include <gnome.h> #include "gncal-day-view.h" #include "timeutil.h" #include "view-utils.h" diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index 335cc2f17a..6b30d15a77 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -5,11 +5,12 @@ * Authors: Federico Mena <quartic@gimp.org> * Miguel de Icaza <miguel@kernel.org> */ - +#include <config.h> #include <string.h> #include <gdk/gdkkeysyms.h> #include <gtk/gtkdrawingarea.h> #include <gtk/gtktext.h> +#include <libgnomeui/gtkcalendar.h> #include "eventedit.h" #include "gncal-full-day.h" #include "view-utils.h" @@ -465,7 +466,7 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); if (child->ico->summary && strcmp (text, child->ico->summary) == 0) - return; + return FALSE; if (child->ico->summary) g_free (child->ico->summary); diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c index 2a389f5fe5..0e280163d9 100644 --- a/calendar/gncal-week-view.c +++ b/calendar/gncal-week-view.c @@ -6,6 +6,7 @@ * Miguel de Icaza <miguel@kernel.org> */ +#include <config.h> #include <string.h> #include "gncal-week-view.h" #include "timeutil.h" @@ -82,6 +83,7 @@ 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 @@ -132,7 +134,7 @@ gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week) 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), wview); + GTK_SIGNAL_FUNC(jump_to_day_click), wview); gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "month_changed", GTK_SIGNAL_FUNC(sync_week), wview); diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c index d37d4156a8..e4312e9341 100644 --- a/calendar/gnome-cal.c +++ b/calendar/gnome-cal.c @@ -275,7 +275,7 @@ mail_notify (char *mail_address, char *text, time_t app_time) pid = fork (); if (pid == 0){ const int top = max_open_files (); - int dev_null, i; + int dev_null; dev_null = open ("/dev/null", O_RDWR); dup2 (p [0], 0); @@ -329,3 +329,54 @@ calendar_notify (time_t time, void *data) } } +/* + * called from the calendar_iterate routine to mark the days of a GtkCalendar + */ +static int +mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c) +{ + GtkCalendar *gtk_cal = c; + struct tm *tm_s; + int days, day; + + tm_s = localtime (&start); + days = difftime (end, start) / (60*60*24); + + for (day = 0; day <= days; day++){ + time_t new = mktime (tm_s); + struct tm *tm_day; + + tm_day = localtime (&new); + gtk_calendar_mark_day (gtk_cal, tm_day->tm_mday); + tm_s->tm_mday++; + } + return TRUE; +} + +/* + * Tags the dates with appointments in a GtkCalendar based on the + * GnomeCalendar contents + */ +void +gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal) +{ + time_t month_begin, month_end; + struct tm tm; + GList *l; + + /* compute month_begin */ + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_mday = 0; + tm.tm_mon = gtk_cal->month; + tm.tm_year = gtk_cal->year - 1900; + tm.tm_isdst= -1; + + month_begin = mktime (&tm); + tm.tm_mon++; + month_end = mktime (&tm); + + gtk_calendar_clear_marks (gtk_cal); + calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal); +} diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h index 653244b075..513bf88ad3 100644 --- a/calendar/gnome-cal.h +++ b/calendar/gnome-cal.h @@ -45,6 +45,7 @@ void gnome_calendar_next (GnomeCalendar *gcal); void gnome_calendar_previous (GnomeCalendar *gcal); void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time); void gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time); +void gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal); /* Flags is a bitmask of CalObjectChange values */ void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags); diff --git a/calendar/gui/gncal-day-panel.c b/calendar/gui/gncal-day-panel.c index 26347428a6..5a5a052f73 100644 --- a/calendar/gui/gncal-day-panel.c +++ b/calendar/gui/gncal-day-panel.c @@ -78,6 +78,12 @@ calendar_day_selected (GtkCalendar *calendar, GncalDayPanel *dpanel) 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) { @@ -142,6 +148,8 @@ gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day) dpanel->day_selected_id = gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "day_selected", (GtkSignalFunc) calendar_day_selected, dpanel); + gtk_signal_connect (GTK_OBJECT (dpanel->gtk_calendar), "month_changed", + GTK_SIGNAL_FUNC (retag_calendar), dpanel); gtk_table_attach (GTK_TABLE (dpanel), w, 1, 2, 1, 2, GTK_FILL | GTK_SHRINK, @@ -180,9 +188,10 @@ gncal_day_panel_new (GnomeCalendar *calendar, time_t start_of_day) static void update (GncalDayPanel *dpanel, int update_fullday, iCalObject *ico, int flags) { - if (update_fullday) + if (update_fullday){ gncal_full_day_update (dpanel->fullday, ico, flags); - + retag_calendar (dpanel->gtk_calendar, dpanel); + } gncal_todo_update (dpanel->todo, ico, flags); } @@ -205,7 +214,9 @@ gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day) g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel)); dpanel->start_of_day = time_start_of_day (start_of_day); - + if (dpanel->fullday->lower == dpanel->start_of_day) + return; + strftime (buf, sizeof (buf), "%a %b %d %Y", localtime (&dpanel->start_of_day)); gtk_label_set (GTK_LABEL (dpanel->date_label), buf); diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c index f513d65b83..85d61292f1 100644 --- a/calendar/gui/gncal-day-view.c +++ b/calendar/gui/gncal-day-view.c @@ -6,7 +6,7 @@ * Miguel de Icaza <miguel@kernel.org> */ -#include <gtk/gtksignal.h> +#include <gnome.h> #include "gncal-day-view.h" #include "timeutil.h" #include "view-utils.h" diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index 335cc2f17a..6b30d15a77 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -5,11 +5,12 @@ * Authors: Federico Mena <quartic@gimp.org> * Miguel de Icaza <miguel@kernel.org> */ - +#include <config.h> #include <string.h> #include <gdk/gdkkeysyms.h> #include <gtk/gtkdrawingarea.h> #include <gtk/gtktext.h> +#include <libgnomeui/gtkcalendar.h> #include "eventedit.h" #include "gncal-full-day.h" #include "view-utils.h" @@ -465,7 +466,7 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); if (child->ico->summary && strcmp (text, child->ico->summary) == 0) - return; + return FALSE; if (child->ico->summary) g_free (child->ico->summary); diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c index 2a389f5fe5..0e280163d9 100644 --- a/calendar/gui/gncal-week-view.c +++ b/calendar/gui/gncal-week-view.c @@ -6,6 +6,7 @@ * Miguel de Icaza <miguel@kernel.org> */ +#include <config.h> #include <string.h> #include "gncal-week-view.h" #include "timeutil.h" @@ -82,6 +83,7 @@ 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 @@ -132,7 +134,7 @@ gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week) 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), wview); + GTK_SIGNAL_FUNC(jump_to_day_click), wview); gtk_signal_connect (GTK_OBJECT (wview->gtk_calendar), "month_changed", GTK_SIGNAL_FUNC(sync_week), wview); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index d37d4156a8..e4312e9341 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -275,7 +275,7 @@ mail_notify (char *mail_address, char *text, time_t app_time) pid = fork (); if (pid == 0){ const int top = max_open_files (); - int dev_null, i; + int dev_null; dev_null = open ("/dev/null", O_RDWR); dup2 (p [0], 0); @@ -329,3 +329,54 @@ calendar_notify (time_t time, void *data) } } +/* + * called from the calendar_iterate routine to mark the days of a GtkCalendar + */ +static int +mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c) +{ + GtkCalendar *gtk_cal = c; + struct tm *tm_s; + int days, day; + + tm_s = localtime (&start); + days = difftime (end, start) / (60*60*24); + + for (day = 0; day <= days; day++){ + time_t new = mktime (tm_s); + struct tm *tm_day; + + tm_day = localtime (&new); + gtk_calendar_mark_day (gtk_cal, tm_day->tm_mday); + tm_s->tm_mday++; + } + return TRUE; +} + +/* + * Tags the dates with appointments in a GtkCalendar based on the + * GnomeCalendar contents + */ +void +gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal) +{ + time_t month_begin, month_end; + struct tm tm; + GList *l; + + /* compute month_begin */ + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_mday = 0; + tm.tm_mon = gtk_cal->month; + tm.tm_year = gtk_cal->year - 1900; + tm.tm_isdst= -1; + + month_begin = mktime (&tm); + tm.tm_mon++; + month_end = mktime (&tm); + + gtk_calendar_clear_marks (gtk_cal); + calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal); +} diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 653244b075..513bf88ad3 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -45,6 +45,7 @@ void gnome_calendar_next (GnomeCalendar *gcal); void gnome_calendar_previous (GnomeCalendar *gcal); void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time); void gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time); +void gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal); /* Flags is a bitmask of CalObjectChange values */ void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags); diff --git a/calendar/timeutil.h b/calendar/timeutil.h index 73b7e607dc..a5a6d7b2d7 100644 --- a/calendar/timeutil.h +++ b/calendar/timeutil.h @@ -39,6 +39,8 @@ time_t time_year_begin (int year); time_t time_year_end (int year); time_t time_week_begin (time_t t); time_t parse_date (char *str); +time_t time_month_begin (time_t t); +time_t time_month_end (time_t t); void print_time_t (time_t t); |