aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog8
-rw-r--r--calendar/gncal-week-view.c58
-rw-r--r--calendar/gui/gncal-week-view.c58
-rw-r--r--calendar/gui/year-view.c5
-rw-r--r--calendar/year-view.c5
5 files changed, 116 insertions, 18 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 8450a82bed..4c67173a2c 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,13 @@
1998-04-18 Miguel de Icaza <miguel@nuclecu.unam.mx>
+ * gncal-year-view.c (double_click): Fix this routine as well.
+
+ * gncal-week-view.c (jump_to_day): Bind the gtkcalendar signals to
+ the week.
+
+ * gncal-year-view.c (gncal_year_view_set_year): Put things in the
+ proper range. Now the year view actually matches this year.
+
* gnome-cal.html: Added small documentation.
* main.c: Add more icons to the menus; Rename some menubar
diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c
index 59252baa0c..ef3b2b9fc8 100644
--- a/calendar/gncal-week-view.c
+++ b/calendar/gncal-week-view.c
@@ -2,7 +2,8 @@
*
* Copyright (C) 1998 The Free Software Foundation
*
- * Author: Federico Mena <quartic@gimp.org>
+ * Authors: Federico Mena <quartic@gimp.org>
+ * Miguel de Icaza <miguel@kernel.org>
*/
#include <string.h>
@@ -48,6 +49,46 @@ gncal_week_view_init (GncalWeekView *wview)
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);
+}
+
+static void
+double_click_on_weekday (GtkWidget *widget, GdkEvent *e, GncalWeekView *wview)
+{
+}
+
GtkWidget *
gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
{
@@ -64,7 +105,9 @@ gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
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_CONNECT(double_click_on_weekday), wview);
+
if (i < 5)
gtk_table_attach (GTK_TABLE (wview), GTK_WIDGET (wview->days[i]),
i, i + 1,
@@ -83,12 +126,13 @@ gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
gtk_widget_show (GTK_WIDGET (wview->days[i]));
}
- /* FIXME: for now this is a plain calendar (for not having anything better to put
- * there). In the final version it should be a nice days/hours matrix with
- * "event density" display as in Sun's "cm" program.
- */
-
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_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);
gtk_table_attach (GTK_TABLE (wview), GTK_WIDGET (wview->gtk_calendar),
diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c
index 59252baa0c..ef3b2b9fc8 100644
--- a/calendar/gui/gncal-week-view.c
+++ b/calendar/gui/gncal-week-view.c
@@ -2,7 +2,8 @@
*
* Copyright (C) 1998 The Free Software Foundation
*
- * Author: Federico Mena <quartic@gimp.org>
+ * Authors: Federico Mena <quartic@gimp.org>
+ * Miguel de Icaza <miguel@kernel.org>
*/
#include <string.h>
@@ -48,6 +49,46 @@ gncal_week_view_init (GncalWeekView *wview)
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);
+}
+
+static void
+double_click_on_weekday (GtkWidget *widget, GdkEvent *e, GncalWeekView *wview)
+{
+}
+
GtkWidget *
gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
{
@@ -64,7 +105,9 @@ gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
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_CONNECT(double_click_on_weekday), wview);
+
if (i < 5)
gtk_table_attach (GTK_TABLE (wview), GTK_WIDGET (wview->days[i]),
i, i + 1,
@@ -83,12 +126,13 @@ gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week)
gtk_widget_show (GTK_WIDGET (wview->days[i]));
}
- /* FIXME: for now this is a plain calendar (for not having anything better to put
- * there). In the final version it should be a nice days/hours matrix with
- * "event density" display as in Sun's "cm" program.
- */
-
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_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);
gtk_table_attach (GTK_TABLE (wview), GTK_WIDGET (wview->gtk_calendar),
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
index 5376826239..dd1a963d52 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -22,10 +22,11 @@ double_click(GtkCalendar *gc, GncalYearView *yview)
tm.tm_mday = gc->selected_day;
tm.tm_mon = gc->month;
- tm.tm_year = gc->year;
+ tm.tm_year = gc->year - 1900;
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
+ tm.tm_isdst = -1;
t = mktime (&tm);
gnome_calendar_dayjump (yview->gcal, t);
@@ -199,7 +200,7 @@ gncal_year_view_set_year (GncalYearView *yview, int year)
gtk_label_set(GTK_LABEL(yview->year_label), buff);
for (i = 0; i < 12; i++) {
- gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
+ gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year + 1900);
gtk_calendar_clear_marks (GTK_CALENDAR (yview->calendar[i]));
}
diff --git a/calendar/year-view.c b/calendar/year-view.c
index 5376826239..dd1a963d52 100644
--- a/calendar/year-view.c
+++ b/calendar/year-view.c
@@ -22,10 +22,11 @@ double_click(GtkCalendar *gc, GncalYearView *yview)
tm.tm_mday = gc->selected_day;
tm.tm_mon = gc->month;
- tm.tm_year = gc->year;
+ tm.tm_year = gc->year - 1900;
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
+ tm.tm_isdst = -1;
t = mktime (&tm);
gnome_calendar_dayjump (yview->gcal, t);
@@ -199,7 +200,7 @@ gncal_year_view_set_year (GncalYearView *yview, int year)
gtk_label_set(GTK_LABEL(yview->year_label), buff);
for (i = 0; i < 12; i++) {
- gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
+ gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year + 1900);
gtk_calendar_clear_marks (GTK_CALENDAR (yview->calendar[i]));
}