aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-04 11:29:36 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-04 11:29:36 +0800
commitbacbb085895ae69e7f443cc39e04b686128a63a3 (patch)
tree63d7b824dc9827888fb1b77960e3971bcc390e25 /calendar
parentf4295ffe09c2994a93eff4d4c73505f2bc291a59 (diff)
downloadgsoc2013-evolution-bacbb085895ae69e7f443cc39e04b686128a63a3.tar
gsoc2013-evolution-bacbb085895ae69e7f443cc39e04b686128a63a3.tar.gz
gsoc2013-evolution-bacbb085895ae69e7f443cc39e04b686128a63a3.tar.bz2
gsoc2013-evolution-bacbb085895ae69e7f443cc39e04b686128a63a3.tar.lz
gsoc2013-evolution-bacbb085895ae69e7f443cc39e04b686128a63a3.tar.xz
gsoc2013-evolution-bacbb085895ae69e7f443cc39e04b686128a63a3.tar.zst
gsoc2013-evolution-bacbb085895ae69e7f443cc39e04b686128a63a3.zip
more and more fixes -mig
svn path=/trunk/; revision=104
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog3
-rw-r--r--calendar/gncal-week-view.c4
-rw-r--r--calendar/gnome-cal.c42
-rw-r--r--calendar/gnome-cal.h4
-rw-r--r--calendar/gui/gncal-week-view.c4
-rw-r--r--calendar/gui/gnome-cal.c42
-rw-r--r--calendar/gui/gnome-cal.h4
-rw-r--r--calendar/gui/main.c15
-rw-r--r--calendar/main.c15
-rw-r--r--calendar/timeutil.c29
10 files changed, 119 insertions, 43 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index fbd5003dc9..b72da59fdc 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,8 @@
1998-04-03 Miguel de Icaza <miguel@nuclecu.unam.mx>
+ * timeutil.c (time_add_year, time_add_year, time_add_week):
+ Routines for time manipulation.
+
* calobj.c (ical_object_destroy): Full destruction of the object.
* eventedit.c: Finished the main event editor form; It still
diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c
index f7d3222cfe..f837b3b2d8 100644
--- a/calendar/gncal-week-view.c
+++ b/calendar/gncal-week-view.c
@@ -151,7 +151,7 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
/* Calendar */
- gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon + 1, tm.tm_year + 1900);
+ gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
/* Day views */
@@ -159,6 +159,8 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
tm.tm_mday++;
day_end = mktime (&tm);
+ printf ("Boundary: ");
+ print_time_t (day_start);
gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
day_start = day_end;
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 4c0806357d..6e6c17ed21 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -93,21 +93,51 @@ get_current_page (GnomeCalendar *gcal)
return GTK_NOTEBOOK (gcal->notebook)->cur_page->child;
}
-GtkWidget *
-gnome_calendar_next (GnomeCalendar *gcal)
+void
+gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
+{
+ GtkWidget *current = get_current_page (gcal);
+ g_assert (new_time != -1);
+
+ if (current == gcal->week_view)
+ gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
+ else if (current == gcal->day_view)
+ printf ("updating day view\n");
+ else if (current == gcal->year_view)
+ printf ("updating year view\n");
+ else
+ printf ("My penguin is gone!\n");
+ gcal->current_display = new_time;
+}
+
+static void
+gnome_calendar_direction (GnomeCalendar *gcal, int direction)
{
GtkWidget *cp = get_current_page (gcal);
time_t new_time;
if (cp == gcal->week_view)
- new_time = time_add_week (gcal->current_display, 1);
+ new_time = time_add_day (gcal->current_display, 7 * direction);
else if (cp == gcal->day_view)
- new_time = time_add_day (gcal->current_display, 1);
+ new_time = time_add_day (gcal->current_display, 1 * direction);
else if (cp == gcal->year_view)
- new_time = time_add_year (gcal->current_display, 1);
+ new_time = time_add_year (gcal->current_display, 1 * direction);
else
g_warning ("Weee! Where did the penguin go?");
+
+ gnome_calendar_goto (gcal, new_time);
+}
+
+void
+gnome_calendar_next (GnomeCalendar *gcal)
+{
+ gnome_calendar_direction (gcal, 1);
+}
+void
+gnome_calendar_previous (GnomeCalendar *gcal)
+{
+ gnome_calendar_direction (gcal, -1);
}
GtkWidget *
@@ -147,6 +177,8 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file)
void
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
{
+ printf ("Adding object at: ");
+ print_time_t (obj->dtstart);
calendar_add_object (gcal->cal, obj);
gnome_calendar_update_all (gcal);
}
diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h
index 8168c26ec8..c13162ef65 100644
--- a/calendar/gnome-cal.h
+++ b/calendar/gnome-cal.h
@@ -39,6 +39,10 @@ guint gnome_calendar_get_type (void);
GtkWidget *gnome_calendar_new (char *title);
void gnome_calendar_load (GnomeCalendar *gcal, char *file);
void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj);
+void gnome_calendar_next (GnomeCalendar *gcal);
+void gnome_calendar_previous (GnomeCalendar *gcal);
+void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time);
+
END_GNOME_DECLS
#endif
diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c
index f7d3222cfe..f837b3b2d8 100644
--- a/calendar/gui/gncal-week-view.c
+++ b/calendar/gui/gncal-week-view.c
@@ -151,7 +151,7 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
/* Calendar */
- gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon + 1, tm.tm_year + 1900);
+ gtk_calendar_select_month (wview->gtk_calendar, tm.tm_mon, tm.tm_year + 1900);
/* Day views */
@@ -159,6 +159,8 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
tm.tm_mday++;
day_end = mktime (&tm);
+ printf ("Boundary: ");
+ print_time_t (day_start);
gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
day_start = day_end;
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 4c0806357d..6e6c17ed21 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -93,21 +93,51 @@ get_current_page (GnomeCalendar *gcal)
return GTK_NOTEBOOK (gcal->notebook)->cur_page->child;
}
-GtkWidget *
-gnome_calendar_next (GnomeCalendar *gcal)
+void
+gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
+{
+ GtkWidget *current = get_current_page (gcal);
+ g_assert (new_time != -1);
+
+ if (current == gcal->week_view)
+ gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
+ else if (current == gcal->day_view)
+ printf ("updating day view\n");
+ else if (current == gcal->year_view)
+ printf ("updating year view\n");
+ else
+ printf ("My penguin is gone!\n");
+ gcal->current_display = new_time;
+}
+
+static void
+gnome_calendar_direction (GnomeCalendar *gcal, int direction)
{
GtkWidget *cp = get_current_page (gcal);
time_t new_time;
if (cp == gcal->week_view)
- new_time = time_add_week (gcal->current_display, 1);
+ new_time = time_add_day (gcal->current_display, 7 * direction);
else if (cp == gcal->day_view)
- new_time = time_add_day (gcal->current_display, 1);
+ new_time = time_add_day (gcal->current_display, 1 * direction);
else if (cp == gcal->year_view)
- new_time = time_add_year (gcal->current_display, 1);
+ new_time = time_add_year (gcal->current_display, 1 * direction);
else
g_warning ("Weee! Where did the penguin go?");
+
+ gnome_calendar_goto (gcal, new_time);
+}
+
+void
+gnome_calendar_next (GnomeCalendar *gcal)
+{
+ gnome_calendar_direction (gcal, 1);
+}
+void
+gnome_calendar_previous (GnomeCalendar *gcal)
+{
+ gnome_calendar_direction (gcal, -1);
}
GtkWidget *
@@ -147,6 +177,8 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file)
void
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
{
+ printf ("Adding object at: ");
+ print_time_t (obj->dtstart);
calendar_add_object (gcal->cal, obj);
gnome_calendar_update_all (gcal);
}
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 8168c26ec8..c13162ef65 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -39,6 +39,10 @@ guint gnome_calendar_get_type (void);
GtkWidget *gnome_calendar_new (char *title);
void gnome_calendar_load (GnomeCalendar *gcal, char *file);
void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj);
+void gnome_calendar_next (GnomeCalendar *gcal);
+void gnome_calendar_previous (GnomeCalendar *gcal);
+void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time);
+
END_GNOME_DECLS
#endif
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index eb272c1246..b8e3f2fb9e 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -151,31 +151,22 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
gtk_main_quit ();
}
-static GtkWidget *
-get_current_page (GnomeCalendar *gcal)
-{
- return GTK_NOTEBOOK (gcal->notebook)->cur_page->child;
-}
-
void
previous_clicked (GtkWidget *widget, GnomeCalendar *gcal)
{
- GtkWidget *current_page = get_current_page (gcal);
-
- if (current_page == gcal->week_view){
- }
+ gnome_calendar_previous (gcal);
}
void
next_clicked (GtkWidget *widget, GnomeCalendar *gcal)
{
- GtkWidget *current_page = get_current_page (gcal);
+ gnome_calendar_next (gcal);
}
void
today_clicked (GtkWidget *widget, GnomeCalendar *gcal)
{
- GtkWidget *current_page = get_current_page (gcal);
+ gnome_calendar_goto (gcal, time (NULL));
}
GnomeUIInfo gnome_cal_file_menu [] = {
diff --git a/calendar/main.c b/calendar/main.c
index eb272c1246..b8e3f2fb9e 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -151,31 +151,22 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
gtk_main_quit ();
}
-static GtkWidget *
-get_current_page (GnomeCalendar *gcal)
-{
- return GTK_NOTEBOOK (gcal->notebook)->cur_page->child;
-}
-
void
previous_clicked (GtkWidget *widget, GnomeCalendar *gcal)
{
- GtkWidget *current_page = get_current_page (gcal);
-
- if (current_page == gcal->week_view){
- }
+ gnome_calendar_previous (gcal);
}
void
next_clicked (GtkWidget *widget, GnomeCalendar *gcal)
{
- GtkWidget *current_page = get_current_page (gcal);
+ gnome_calendar_next (gcal);
}
void
today_clicked (GtkWidget *widget, GnomeCalendar *gcal)
{
- GtkWidget *current_page = get_current_page (gcal);
+ gnome_calendar_goto (gcal, time (NULL));
}
GnomeUIInfo gnome_cal_file_menu [] = {
diff --git a/calendar/timeutil.c b/calendar/timeutil.c
index 3a78bf2b4f..20d6fa7990 100644
--- a/calendar/timeutil.c
+++ b/calendar/timeutil.c
@@ -37,7 +37,7 @@ print_time_t (time_t t)
struct tm *tm = localtime (&t);
printf ("TIEMPO: %d/%d/%d %d:%d:%d\n",
- tm->tm_mday, tm->tm_mon, tm->tm_year,
+ tm->tm_mon+1, tm->tm_mday, tm->tm_year,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
@@ -89,17 +89,32 @@ format_simple_hour (int hour, int use_am_pm)
}
time_t
-time_add_week (time_t time, int weeks)
-{
-}
-
-time_t
-time_add_day (time_t time, int weeks)
+time_add_day (time_t time, int days)
{
+ struct tm *tm = localtime (&time);
+ time_t new_time;
+
+ tm->tm_mday += days;
+ if ((new_time = mktime (tm)) == -1){
+ g_warning ("mktime could not handling adding a day with\n");
+ print_time_t (time);
+ return time;
+ }
+ return new_time;
}
time_t
time_add_year (time_t time, int years)
{
+ struct tm *tm = localtime (&time);
+ time_t new_time;
+
+ tm->tm_year += years;
+ if ((new_time = mktime (tm)) == -1){
+ g_warning ("mktime could not handling adding a year with\n");
+ print_time_t (time);
+ return time;
+ }
+ return new_time;
}