From 1596825b7da24002e23d90a236d6def417d7dd58 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 11 Aug 1998 04:22:05 +0000 Subject: Start of the month view widget. This will use the generic month item and 1998-08-10 Federico Mena Quintero * month-view.[ch]: Start of the month view widget. This will use the generic month item and extend it to have the semantics desired for the gnomecal month view. * gnome-month-item.[ch]: New generic canvas item for the month view and the "small calendars". This is intended to be a high-level display engine for monthly calendars. This is a work in progress. * gnome-cal.h (GnomeCalendar): Added a month_view field. * gnome-cal.c (setup_widgets): Create the month view and insert it into the notebook. * Makefile.am: Added month-view.[ch] and gnome-month-item.[ch] to the sources. svn path=/trunk/; revision=307 --- calendar/month-view.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 calendar/month-view.c (limited to 'calendar/month-view.c') diff --git a/calendar/month-view.c b/calendar/month-view.c new file mode 100644 index 0000000000..78eec0c91d --- /dev/null +++ b/calendar/month-view.c @@ -0,0 +1,118 @@ +/* Month view display for gncal + * + * Copyright (C) 1998 Red Hat Software, Inc. + * + * Author: Federico Mena + */ + +#include +#include "month-view.h" + + +static void month_view_class_init (MonthViewClass *class); +static void month_view_init (MonthView *mv); +static void month_view_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void month_view_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + + +static GnomeCanvasClass *parent_class; + + +GtkType +month_view_get_type (void) +{ + static GtkType month_view_type = 0; + + if (!month_view_type) { + GtkTypeInfo month_view_info = { + "MonthView", + sizeof (MonthView), + sizeof (MonthViewClass), + (GtkClassInitFunc) month_view_class_init, + (GtkObjectInitFunc) month_view_init, + NULL, /* reserved_1 */ + NULL, /* reserved_2 */ + (GtkClassInitFunc) NULL + }; + + month_view_type = gtk_type_unique (gnome_canvas_get_type (), &month_view_info); + } + + return month_view_type; +} + +static void +month_view_class_init (MonthViewClass *class) +{ + GtkWidgetClass *widget_class; + + widget_class = (GtkWidgetClass *) class; + + parent_class = gtk_type_class (gnome_canvas_get_type ()); + + widget_class->size_request = month_view_size_request; + widget_class->size_allocate = month_view_size_allocate; +} + +static void +month_view_init (MonthView *mv) +{ + mv->mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (mv->canvas.root)); + gnome_canvas_item_set (mv->mitem, + "x", 0.0, + "y", 0.0, + "anchor", GTK_ANCHOR_NW, + NULL); +} + +GtkWidget * +month_view_new (GnomeCalendar *calendar) +{ + MonthView *mv; + + g_return_val_if_fail (calendar != NULL, NULL); + + mv = gtk_type_new (month_view_get_type ()); + + mv->calendar = calendar; + + return GTK_WIDGET (mv); +} + +static void +month_view_size_request (GtkWidget *widget, GtkRequisition *requisition) +{ + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (requisition != NULL); + + if (GTK_WIDGET_CLASS (parent_class)->size_request) + (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition); + + requisition->width = 200; + requisition->height = 150; +} + +static void +month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) +{ + MonthView *mv; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (allocation != NULL); + + mv = MONTH_VIEW (widget); + + if (GTK_WIDGET_CLASS (parent_class)->size_allocate) + (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); + + gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height); + + gnome_canvas_item_set (mv->mitem, + "width", (double) allocation->width, + "height", (double) allocation->height, + NULL); +} -- cgit v1.2.3