aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gncal-week-view.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-04-02 14:12:25 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-02 14:12:25 +0800
commit23463e22bcec65cf1013ae036dc126be0e1903d6 (patch)
treecde4f870b0cd6e88301f1558efbcff788df993c3 /calendar/gncal-week-view.c
parent4750b90ad18f4f59fa19b839550d6397f5dffbfd (diff)
downloadgsoc2013-evolution-23463e22bcec65cf1013ae036dc126be0e1903d6.tar
gsoc2013-evolution-23463e22bcec65cf1013ae036dc126be0e1903d6.tar.gz
gsoc2013-evolution-23463e22bcec65cf1013ae036dc126be0e1903d6.tar.bz2
gsoc2013-evolution-23463e22bcec65cf1013ae036dc126be0e1903d6.tar.lz
gsoc2013-evolution-23463e22bcec65cf1013ae036dc126be0e1903d6.tar.xz
gsoc2013-evolution-23463e22bcec65cf1013ae036dc126be0e1903d6.tar.zst
gsoc2013-evolution-23463e22bcec65cf1013ae036dc126be0e1903d6.zip
New week view composite widget. This provides a full week view (7 day
1998-04-02 Federico Mena Quintero <federico@nuclecu.unam.mx> * gncal-week-view.[ch]: New week view composite widget. This provides a full week view (7 day views plus busy time display -- the latter is currently unimplemented). 1998-04-01 Federico Mena Quintero <federico@nuclecu.unam.mx> * gncal-day-view.c: New day view widget. It is intended to be a child widget of the week view composite widget. svn path=/trunk/; revision=90
Diffstat (limited to 'calendar/gncal-week-view.c')
-rw-r--r--calendar/gncal-week-view.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c
new file mode 100644
index 0000000000..98b73ae521
--- /dev/null
+++ b/calendar/gncal-week-view.c
@@ -0,0 +1,142 @@
+/* Week view composite widget for gncal
+ *
+ * Copyright (C) 1998 The Free Software Foundation
+ *
+ * Author: Federico Mena <federico@nuclecu.unam.mx>
+ */
+
+#include "gncal-week-view.h"
+
+
+static void gncal_week_view_init (GncalWeekView *wview);
+
+
+guint
+gncal_week_view_get_type (void)
+{
+ static guint week_view_type = 0;
+
+ if (!week_view_type) {
+ GtkTypeInfo week_view_info = {
+ "GncalWeekView",
+ sizeof (GncalWeekView),
+ sizeof (GncalWeekViewClass),
+ (GtkClassInitFunc) NULL,
+ (GtkObjectInitFunc) gncal_week_view_init,
+ (GtkArgSetFunc) NULL,
+ (GtkArgGetFunc) NULL
+ };
+
+ week_view_type = gtk_type_unique (gtk_table_get_type (), &week_view_info);
+ }
+
+ return week_view_type;
+}
+
+static void
+gncal_week_view_init (GncalWeekView *wview)
+{
+ int i;
+
+ wview->calendar = NULL;
+ memset (&wview->start_of_week, 0, sizeof (wview->start_of_week));
+
+ for (i = 0; i < 7; i++)
+ wview->days[i] = NULL;
+}
+
+GtkWidget *
+gncal_week_view_new (Calendar *calendar, time_t start_of_week)
+{
+ GncalWeekView *wview;
+ int i;
+#if 0
+ g_return_val_if_fail (calendar != NULL, NULL);
+#endif
+ wview = gtk_type_new (gncal_week_view_get_type ());
+
+ wview->table.homogeneous = TRUE; /* FIXME: eeeeeeeeeek, GtkTable does not have a function to set this */
+
+ wview->calendar = calendar;
+
+ for (i = 0; i < 7; i++) {
+ wview->days[i] = GNCAL_DAY_VIEW (gncal_day_view_new (calendar, 0, 0));
+
+ if (i < 5)
+ gtk_table_attach (GTK_TABLE (wview), GTK_WIDGET (wview->days[i]),
+ i, i + 1,
+ 0, 1,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+ 0, 0);
+ else
+ gtk_table_attach (GTK_TABLE (wview), GTK_WIDGET (wview->days[i]),
+ i - 2, i - 1,
+ 1, 2,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+ 0, 0);
+
+ gtk_widget_show (GTK_WIDGET (wview->days[i]));
+ }
+
+ gncal_week_view_set (wview, start_of_week);
+
+ return GTK_WIDGET (wview);
+}
+
+static void
+update (GncalWeekView *wview, int update_days)
+{
+ int i;
+
+ if (update_days)
+ for (i = 0; i < 7; i++)
+ gncal_day_view_update (wview->days[i]);
+
+ /* FIXME: update extra widgets */
+}
+
+void
+gncal_week_view_update (GncalWeekView *wview)
+{
+ g_return_if_fail (wview != NULL);
+ g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
+
+ update (wview, TRUE);
+}
+
+void
+gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
+{
+ struct tm tm;
+ time_t day_start, day_end;
+
+ g_return_if_fail (wview != NULL);
+ g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview));
+
+ tm = *localtime (&start_of_week);
+
+ /* back up to start of week */
+
+ tm.tm_mday -= tm.tm_wday;
+
+ /* Start of day */
+
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+
+ day_start = mktime (&tm);
+
+ for (i = 0; i < 7; i++) { /* rest of days */
+ tm.tm_mday++;
+ day_end = mktime (&tm);
+
+ gncal_day_view_set_bounds (days[i], day_start, day_end - 1);
+
+ day_start = day_end;
+ }
+
+ update (wview, FALSE);
+}