diff options
Diffstat (limited to 'calendar/gui/month-view.c')
-rw-r--r-- | calendar/gui/month-view.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c new file mode 100644 index 0000000000..78eec0c91d --- /dev/null +++ b/calendar/gui/month-view.c @@ -0,0 +1,118 @@ +/* Month view display for gncal + * + * Copyright (C) 1998 Red Hat Software, Inc. + * + * Author: Federico Mena <federico@nuclecu.unam.mx> + */ + +#include <config.h> +#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); +} |