aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/month-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/month-view.c')
-rw-r--r--calendar/gui/month-view.c91
1 files changed, 88 insertions, 3 deletions
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c
index de6b89db2b..0abc717366 100644
--- a/calendar/gui/month-view.c
+++ b/calendar/gui/month-view.c
@@ -6,10 +6,14 @@
*/
#include <config.h>
+#include <libgnomeui/gnome-canvas-text.h>
#include "month-view.h"
#include "main.h"
+#define SPACING 4 /* Spacing between title and calendar */
+
+
static void month_view_class_init (MonthViewClass *class);
static void month_view_init (MonthView *mv);
static void month_view_size_request (GtkWidget *widget,
@@ -60,6 +64,17 @@ month_view_class_init (MonthViewClass *class)
static void
month_view_init (MonthView *mv)
{
+ /* Title */
+
+ mv->title = gnome_canvas_item_new (GNOME_CANVAS_GROUP (mv->canvas.root),
+ gnome_canvas_text_get_type (),
+ "anchor", GTK_ANCHOR_N,
+ "font", "-*-helvetica-bold-r-normal--18-*-*-*-p-*-iso8859-1",
+ "fill_color", "black",
+ NULL);
+
+ /* Month item */
+
mv->mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (mv->canvas.root));
gnome_canvas_item_set (mv->mitem,
"x", 0.0,
@@ -71,16 +86,17 @@ month_view_init (MonthView *mv)
}
GtkWidget *
-month_view_new (GnomeCalendar *calendar)
+month_view_new (GnomeCalendar *calendar, time_t month)
{
MonthView *mv;
g_return_val_if_fail (calendar != NULL, NULL);
mv = gtk_type_new (month_view_get_type ());
-
mv->calendar = calendar;
+ month_view_set (mv, month);
+
return GTK_WIDGET (mv);
}
@@ -102,6 +118,9 @@ static void
month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
MonthView *mv;
+ GdkFont *font;
+ GtkArg arg;
+ int y;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -113,8 +132,74 @@ month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height);
+
+ /* Adjust items to new size */
+
+ arg.name = "font_gdk";
+ gtk_object_getv (GTK_OBJECT (mv->title), 1, &arg);
+ font = GTK_VALUE_BOXED (arg);
+
+ gnome_canvas_item_set (mv->title,
+ "x", (double) allocation->width / 2.0,
+ "y", (double) SPACING,
+ NULL);
+
+ y = font->ascent + font->descent + 2 * SPACING;
gnome_canvas_item_set (mv->mitem,
+ "y", (double) y,
"width", (double) (allocation->width - 1),
- "height", (double) (allocation->height - 1),
+ "height", (double) (allocation->height - y - 1),
+ NULL);
+
+ /* FIXME: adjust events */
+}
+
+void
+month_view_update (MonthView *mv, iCalObject *object, int flags)
+{
+ g_return_if_fail (mv != NULL);
+ g_return_if_fail (IS_MONTH_VIEW (mv));
+
+ /* FIXME */
+}
+
+void
+month_view_set (MonthView *mv, time_t month)
+{
+ struct tm *tm;
+ char buf[100];
+
+ g_return_if_fail (mv != NULL);
+ g_return_if_fail (IS_MONTH_VIEW (mv));
+
+ /* Title */
+
+ tm = localtime (&month);
+ strftime (buf, 100, "%B %Y", tm);
+
+ gnome_canvas_item_set (mv->title,
+ "text", buf,
+ NULL);
+
+ /* Month item */
+
+ gnome_canvas_item_set (mv->mitem,
+ "year", tm->tm_year + 1900,
+ "month", tm->tm_mon,
NULL);
+
+ /* FIXME: update events */
+}
+
+void
+month_view_time_format_changed (MonthView *mv)
+{
+ g_return_if_fail (mv != NULL);
+ g_return_if_fail (IS_MONTH_VIEW (mv));
+
+ gnome_canvas_item_set (mv->mitem,
+ "start_on_monday", week_starts_on_monday,
+ NULL);
+
+ /* FIXME: update events */
}