diff --git a/src/Makefile.am b/src/Makefile.am
index 20d38a7b..b7dbcb30 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,14 +27,10 @@ gnome_calendar_SOURCES = \
main.c \
gcal-application.h \
gcal-application.c \
- gcal-floating-container.c \
- gcal-floating-container.h \
gcal-window.h \
gcal-window.c \
gcal-view.c \
gcal-view.h \
- gcal-day-view.c \
- gcal-day-view.h \
gcal-month-view.c \
gcal-month-view.h \
gcal-week-view.c \
@@ -55,12 +51,6 @@ gnome_calendar_SOURCES = \
gcal-manager.h \
gcal-nav-bar.h \
gcal-nav-bar.c \
- gcal-viewport.c \
- gcal-viewport.h \
- gcal-all-day-grid.c \
- gcal-all-day-grid.h \
- gcal-days-grid.c \
- gcal-days-grid.h \
gcal-utils.c \
gcal-utils.h
diff --git a/src/gcal-all-day-grid.c b/src/gcal-all-day-grid.c
deleted file mode 100644
index 41eb4661..00000000
--- a/src/gcal-all-day-grid.c
+++ /dev/null
@@ -1,1054 +0,0 @@
-/* -*- mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * gcal-all-day-grid.c
- *
- * Copyright (C) 2012 - Erick Pérez Castellanos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "gcal-all-day-grid.h"
-#include "gcal-event-widget.h"
-
-#include
-
-enum
-{
- PROP_0,
- PROP_COLUMNS,
-};
-
-struct _ChildInfo
-{
- GtkWidget *widget;
-
- guint column_span;
-};
-
-typedef struct _ChildInfo ChildInfo;
-
-typedef struct
-{
- /* property */
- guint columns_nr;
-
- GList *column_headers;
- GList *children;
-
- GdkWindow *event_window;
-
- /* button_down/up flags */
- gint clicked_cell;
- gint start_mark_cell;
- gint end_mark_cell;
-
-} GcalAllDayGridPrivate;
-
-enum
-{
- MARKED,
- NUM_SIGNALS
-};
-
-static guint signals[NUM_SIGNALS] = { 0, };
-
-/* Helpers and private */
-static void gcal_all_day_grid_finalize (GObject *object);
-
-static void gcal_all_day_grid_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void gcal_all_day_grid_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gcal_all_day_grid_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural);
-
-static void gcal_all_day_grid_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural);
-
-static void gcal_all_day_grid_realize (GtkWidget *widget);
-
-static void gcal_all_day_grid_unrealize (GtkWidget *widget);
-
-static void gcal_all_day_grid_map (GtkWidget *widget);
-
-static void gcal_all_day_grid_unmap (GtkWidget *widget);
-
-static void gcal_all_day_grid_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-static gboolean gcal_all_day_grid_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static gboolean gcal_all_day_grid_button_press_event (GtkWidget *widget,
- GdkEventButton *event);
-
-static gboolean gcal_all_day_grid_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event);
-
-static gboolean gcal_all_day_grid_button_release_event (GtkWidget *widget,
- GdkEventButton *event);
-
-static void gcal_all_day_grid_add (GtkContainer *container,
- GtkWidget *widget);
-
-static void gcal_all_day_grid_remove (GtkContainer *container,
- GtkWidget *widget);
-
-static void gcal_all_day_grid_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-G_DEFINE_TYPE_WITH_PRIVATE (GcalAllDayGrid,gcal_all_day_grid, GTK_TYPE_CONTAINER);
-
-static void
-gcal_all_day_grid_class_init (GcalAllDayGridClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gcal_all_day_grid_finalize;
- object_class->set_property = gcal_all_day_grid_set_property;
- object_class->get_property = gcal_all_day_grid_get_property;
-
- widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->get_preferred_width = gcal_all_day_grid_get_preferred_width;
- widget_class->get_preferred_height = gcal_all_day_grid_get_preferred_height;
- widget_class->realize = gcal_all_day_grid_realize;
- widget_class->unrealize = gcal_all_day_grid_unrealize;
- widget_class->map = gcal_all_day_grid_map;
- widget_class->unmap = gcal_all_day_grid_unmap;
- widget_class->size_allocate = gcal_all_day_grid_size_allocate;
- widget_class->draw = gcal_all_day_grid_draw;
- widget_class->button_press_event = gcal_all_day_grid_button_press_event;
- widget_class->motion_notify_event = gcal_all_day_grid_motion_notify_event;
- widget_class->button_release_event = gcal_all_day_grid_button_release_event;
-
- container_class = GTK_CONTAINER_CLASS (klass);
- container_class->add = gcal_all_day_grid_add;
- container_class->remove = gcal_all_day_grid_remove;
- container_class->forall = gcal_all_day_grid_forall;
- gtk_container_class_handle_border_width (container_class);
-
- g_object_class_install_property (
- object_class,
- PROP_COLUMNS,
- g_param_spec_uint ("columns",
- "Columns",
- "The number of columns in which to split the grid",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE));
-
- /* comunicate to its parent view the marking */
- signals[MARKED] = g_signal_new ("marked",
- GCAL_TYPE_ALL_DAY_GRID,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GcalAllDayGridClass,
- marked),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_UINT,
- G_TYPE_UINT);
-}
-
-
-
-static void
-gcal_all_day_grid_init (GcalAllDayGrid *self)
-{
- GcalAllDayGridPrivate *priv;
-
- gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
-
- priv = gcal_all_day_grid_get_instance_private (self);
- priv->column_headers = NULL;
- priv->children = NULL;
-
- priv->clicked_cell = -1;
- priv->start_mark_cell = -1;
- priv->end_mark_cell = -1;
-
- gtk_style_context_add_class (
- gtk_widget_get_style_context (GTK_WIDGET (self)),
- "calendar-view");
-}
-
-static void
-gcal_all_day_grid_finalize (GObject *object)
-{
- GcalAllDayGridPrivate *priv;
- GList *column;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (object));
-
- if (priv->children != NULL)
- {
- column = priv->children;
- while (column)
- {
- g_list_free_full (column->data, (GDestroyNotify) g_free);
- column = column->next;
- }
- }
- g_list_free (priv->children);
-
- if (priv->column_headers != NULL)
- g_list_free_full (priv->column_headers, g_free);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (gcal_all_day_grid_parent_class)->finalize (object);
-}
-
-static void
-gcal_all_day_grid_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GcalAllDayGridPrivate *priv;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (object));
-
- switch (property_id)
- {
- case PROP_COLUMNS:
- {
- gint i;
- priv->columns_nr = g_value_get_uint (value);
- for (i = 0; i < priv->columns_nr; ++i)
- {
- priv->children = g_list_prepend (priv->children, NULL);
- }
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-gcal_all_day_grid_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GcalAllDayGridPrivate *priv;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (object));
-
- switch (property_id)
- {
- case PROP_COLUMNS:
- g_value_set_uint (value, priv->columns_nr);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-/* GtkWidget API */
-static void
-gcal_all_day_grid_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GcalAllDayGridPrivate* priv;
-
- GtkBorder padding;
-
- GList *headers;
- gchar *longest_header;
- gint length;
-
- PangoLayout *layout;
- PangoRectangle logical_rect;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
-
- length = 0;
- longest_header = NULL;
- for (headers = priv->column_headers;
- headers != NULL;
- headers = g_list_next (headers))
- {
- gchar *header = (gchar*) headers->data;
- if (length < strlen (header))
- {
- length = strlen (header);
- longest_header = header;
- }
- }
-
- layout = gtk_widget_create_pango_layout (widget, longest_header);
-
- pango_layout_get_extents (layout, NULL, &logical_rect);
- pango_extents_to_pixels (&logical_rect, NULL);
-
- gtk_style_context_get_padding (gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- if (minimum != NULL)
- {
- *minimum =
- (priv->columns_nr * logical_rect.width) + padding.left + padding.right;
- }
- if (natural != NULL)
- {
- *natural =
- (priv->columns_nr * logical_rect.width) + padding.left + padding.right;
- }
-
- g_object_unref (layout);
-}
-
-static void
-gcal_all_day_grid_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GcalAllDayGridPrivate* priv;
-
- GList *columns;
-
- gint min_height;
- guint min_keeper;
- gint nat_height;
- guint nat_keeper;
-
- GtkBorder padding;
- PangoLayout *layout;
- PangoRectangle logical_rect;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
-
- layout = gtk_widget_create_pango_layout (widget, "0");
-
- pango_layout_get_extents (layout, NULL, &logical_rect);
- pango_extents_to_pixels (&logical_rect, NULL);
-
- gtk_style_context_get_padding (gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
- g_object_unref (layout);
-
- min_keeper = G_MAXUINT;
- nat_keeper = 0;
-
- for (columns = priv->children;
- columns != NULL;
- columns = g_list_next (columns))
- {
- GList *column_children = (GList*) columns->data;
- gint column_height;
-
- for (;column_children != NULL;
- column_children = g_list_next (column_children))
- {
- ChildInfo *info;
- info = (ChildInfo*) column_children->data;
-
- gtk_widget_get_preferred_height (info->widget, &min_height, &nat_height);
-
- /* minimum is calculated as the minimum required
- by any child */
- if (min_keeper < min_height)
- min_keeper = min_height;
-
- column_height += nat_height;
- }
-
- if (nat_keeper < column_height)
- nat_keeper = column_height;
- }
-
- if (minimum != NULL)
- {
- *minimum = min_keeper + logical_rect.height + padding.top + padding.bottom;
- }
- if (natural != NULL)
- {
- *natural = nat_keeper + logical_rect.height + padding.top + padding.bottom;
- }
-}
-
-static void
-gcal_all_day_grid_realize (GtkWidget *widget)
-{
- GcalAllDayGridPrivate *priv;
- GdkWindow *parent_window;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkAllocation allocation;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
- gtk_widget_set_realized (widget, TRUE);
-
- parent_window = gtk_widget_get_parent_window (widget);
- gtk_widget_set_window (widget, parent_window);
- g_object_ref (parent_window);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_ONLY;
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- priv->event_window = gdk_window_new (parent_window,
- &attributes,
- attributes_mask);
- gdk_window_set_user_data (priv->event_window, widget);
-}
-
-static void
-gcal_all_day_grid_unrealize (GtkWidget *widget)
-{
- GcalAllDayGridPrivate *priv;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
- if (priv->event_window != NULL)
- {
- gdk_window_set_user_data (priv->event_window, NULL);
- gdk_window_destroy (priv->event_window);
- priv->event_window = NULL;
- }
-
- GTK_WIDGET_CLASS (gcal_all_day_grid_parent_class)->unrealize (widget);
-}
-
-static void
-gcal_all_day_grid_map (GtkWidget *widget)
-{
- GcalAllDayGridPrivate *priv;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
- if (priv->event_window != NULL)
- gdk_window_show (priv->event_window);
-
- GTK_WIDGET_CLASS (gcal_all_day_grid_parent_class)->map (widget);
-}
-
-static void
-gcal_all_day_grid_unmap (GtkWidget *widget)
-{
- GcalAllDayGridPrivate *priv;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
- if (priv->event_window != NULL)
- gdk_window_hide (priv->event_window);
-
- GTK_WIDGET_CLASS (gcal_all_day_grid_parent_class)->unmap (widget);
-}
-
-static void
-gcal_all_day_grid_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GcalAllDayGridPrivate *priv;
-
- gint y_gap;
-
- GtkBorder padding;
- PangoLayout *layout;
- PangoRectangle logical_rect;
-
- GList *columns;
- gint idx;
- gint i;
-
- gint width_block;
-
- GArray *last_y;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
- gtk_widget_set_allocation (widget, allocation);
-
- width_block = allocation->width / priv->columns_nr;
-
- layout = gtk_widget_create_pango_layout (widget, "0");
-
- gtk_style_context_get_padding (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
- pango_layout_get_extents (layout, NULL, &logical_rect);
- pango_extents_to_pixels (&logical_rect, NULL);
- y_gap = allocation->y + padding.top + logical_rect.height + padding.bottom;
-
- g_object_unref (layout);
-
- /* Placing the event_window */
- if (gtk_widget_get_realized (widget))
- {
- gdk_window_move_resize (priv->event_window,
- allocation->x,
- y_gap,
- allocation->width,
- allocation->height - y_gap);
- }
-
- /* last_y value for each column,
- will keep the amount of columns as well */
- last_y = g_array_new (FALSE, TRUE, sizeof (guint));
- g_array_set_size (last_y, priv->columns_nr);
-
- /* Placing children */
- for (columns = priv->children, idx = 0;
- columns != NULL;
- columns = g_list_next (columns), ++idx)
- {
- GtkAllocation child_allocation;
- GList *column;
-
- column = (GList*) columns->data;
-
- child_allocation.x = idx * width_block + allocation->x;
-
- y_gap += g_array_index (last_y, guint, idx);
-
- for (; column != NULL; column = g_list_next (column))
- {
- gint natural_height;
- ChildInfo *info;
- GtkWidget *item;
-
- info = (ChildInfo*) column->data;
- item = info->widget;
- gtk_widget_get_preferred_height (item, NULL, &natural_height);
-
- child_allocation.width = width_block * info->column_span;
- child_allocation.y = y_gap;
- child_allocation.height = natural_height;
-
- y_gap += natural_height;
-
- gtk_widget_size_allocate (item, &child_allocation);
-
- /* updating y spacings */
- for (i = 0; i < info->column_span; ++i)
- {
- g_array_index (last_y, guint, idx + i) = natural_height;
- }
- }
-
- y_gap = allocation->y + padding.top + logical_rect.height + padding.bottom;
- }
-
- g_array_free (last_y, TRUE);
-}
-
-static gboolean
-gcal_all_day_grid_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GcalAllDayGridPrivate *priv;
-
- GtkBorder padding;
- GtkAllocation alloc;
- gint y_gap;
-
- PangoLayout *layout;
- PangoRectangle logical_rect;
- PangoFontDescription *font_desc;
-
- GList *header;
- gint i;
-
- GdkRGBA ligther_color;
- GdkRGBA background_selected_color;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
-
- gtk_style_context_get_padding (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- gtk_widget_get_allocation (widget, &alloc);
-
- gtk_style_context_get (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- "font", &font_desc, NULL);
-
- cairo_save (cr);
-
- layout = pango_cairo_create_layout (cr);
- pango_layout_set_font_description (layout, font_desc);
-
- pango_layout_get_extents (layout, NULL, &logical_rect);
- pango_extents_to_pixels (&logical_rect, NULL);
- y_gap = logical_rect.height + padding.top + padding.bottom;
-
- for (header = priv->column_headers, i = 0;
- header != NULL;
- header = g_list_next (header), i++)
- {
- gchar *text = (gchar*) header->data;
- pango_layout_set_text (layout, text, -1);
- pango_cairo_update_layout (cr, layout);
-
- cairo_move_to (cr,
- (alloc.width / priv->columns_nr) * i + padding.left,
- padding.top);
- pango_cairo_show_layout (cr, layout);
- }
-
- /* drawing marked cells */
- if (priv->start_mark_cell != -1 &&
- priv->end_mark_cell != -1)
- {
- gint first_cell;
- gint last_cell;
-
- gtk_style_context_get_background_color (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget) | GTK_STATE_FLAG_SELECTED,
- &background_selected_color);
-
- if (priv->start_mark_cell < priv->end_mark_cell)
- {
- first_cell = priv->start_mark_cell;
- last_cell = priv->end_mark_cell;
- }
- else
- {
- first_cell = priv->end_mark_cell;
- last_cell = priv->start_mark_cell;
- }
-
- cairo_save (cr);
- cairo_set_source_rgba (cr,
- background_selected_color.red,
- background_selected_color.green,
- background_selected_color.blue,
- background_selected_color.alpha);
-
- cairo_rectangle (cr,
- (alloc.width / priv->columns_nr) * first_cell, y_gap,
- (alloc.width / priv->columns_nr) * (last_cell + 1), alloc.height - y_gap);
- cairo_fill (cr);
- cairo_restore (cr);
- }
-
- /* drawing lines */
- gtk_style_context_get_color (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget) | GTK_STATE_FLAG_INSENSITIVE,
- &ligther_color);
- cairo_set_source_rgb (cr,
- ligther_color.red,
- ligther_color.green,
- ligther_color.blue);
- cairo_set_line_width (cr, 0.3);
-
- cairo_move_to (cr, 0, y_gap + 0.4);
- cairo_rel_line_to (cr, alloc.width, 0);
-
- for (i = 0; i < priv->columns_nr + 1; ++i)
- {
- cairo_move_to (cr, i * (alloc.width / priv->columns_nr) + 0.4, y_gap);
- cairo_rel_line_to (cr, 0, alloc.height - y_gap);
- }
-
- cairo_stroke (cr);
- cairo_restore (cr);
-
- pango_font_description_free (font_desc);
- g_object_unref (layout);
-
- /* drawing children */
- if (GTK_WIDGET_CLASS (gcal_all_day_grid_parent_class)->draw != NULL)
- GTK_WIDGET_CLASS (gcal_all_day_grid_parent_class)->draw (widget, cr);
-
- return FALSE;
-}
-
-static gboolean
-gcal_all_day_grid_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- GcalAllDayGridPrivate *priv;
-
- gint width_block;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
-
- width_block = gtk_widget_get_allocated_width (widget) / priv->columns_nr;
-
- priv->clicked_cell = event->x / width_block;
- priv->start_mark_cell = priv->clicked_cell;
-
- return TRUE;
-}
-
-static gboolean
-gcal_all_day_grid_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event)
-{
- GcalAllDayGridPrivate *priv;
-
- gint width_block;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
-
- if (priv->clicked_cell == -1)
- return FALSE;
-
- width_block = gtk_widget_get_allocated_width (widget) / priv->columns_nr;
- priv->end_mark_cell = event->x / width_block;
-
- gtk_widget_queue_draw (widget);
- return TRUE;
-}
-
-static gboolean
-gcal_all_day_grid_button_release_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- GcalAllDayGridPrivate *priv;
-
- gint width_block;
-
- gint cell_temp;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (widget));
-
- if (priv->clicked_cell == -1)
- return FALSE;
-
- width_block = gtk_widget_get_allocated_width (widget) / priv->columns_nr;
-
- priv->end_mark_cell = event->x / width_block;
-
- gtk_widget_queue_draw (widget);
-
- priv->clicked_cell = -1;
-
- if (priv->start_mark_cell > priv->end_mark_cell)
- {
- cell_temp = priv->end_mark_cell;
- priv->end_mark_cell = priv->start_mark_cell;
- priv->start_mark_cell = cell_temp;
- }
-
- g_signal_emit (GCAL_ALL_DAY_GRID (widget),
- signals[MARKED], 0,
- priv->start_mark_cell, priv->end_mark_cell);
-
- return TRUE;
-}
-
-/* GtkContainer API */
-/**
- * gcal_all_day_grid_add:
- * @container: a #GcalAllDayGrid
- * @widget: a widget to add
- *
- * @gtk_container_add implementation. It assumes the widget will go
- * to the first column.
- *
- **/
-static void
-gcal_all_day_grid_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GcalAllDayGridPrivate* priv;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (container));
- g_return_if_fail (priv->columns_nr != 0);
-
- gcal_all_day_grid_place (GCAL_ALL_DAY_GRID (container),
- widget,
- 0, 0);
-}
-
-static void
-gcal_all_day_grid_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GcalAllDayGridPrivate *priv;
-
- GList *columns;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (container));
-
- for (columns = priv->children;
- columns != NULL;
- columns = g_list_next (columns))
- {
- GList* column = (GList*) columns->data;
- for (;column != NULL; column = g_list_next (column))
- {
- ChildInfo *info = (ChildInfo*) column->data;
- if (widget == info->widget)
- {
- GList* orig = (GList*) columns->data;
- orig = g_list_delete_link (orig, column);
-
- gtk_widget_unparent (widget);
-
- columns->data = orig;
-
- columns = NULL;
- break;
- }
- }
- }
-}
-
-static void
-gcal_all_day_grid_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GcalAllDayGridPrivate *priv;
-
- GList* columns;
-
- priv = gcal_all_day_grid_get_instance_private (GCAL_ALL_DAY_GRID (container));
-
- columns = priv->children;
- while (columns)
- {
- GList *column;
-
- column = columns->data;
- columns = columns->next;
-
- while (column)
- {
- ChildInfo *info = (ChildInfo*) column->data;
- column = column->next;
-
- (* callback) (info->widget, callback_data);
- }
- }
-}
-
-/* Public API */
-/**
- * gcal_all_day_grid_new:
- *
- * Since: 0.1
- * Return value: A new #GcalAllDayGrid
- * Returns: (transfer full):
- **/
-GtkWidget*
-gcal_all_day_grid_new (guint columns)
-{
- return g_object_new (GCAL_TYPE_ALL_DAY_GRID, "columns", columns, NULL);
-}
-
-/**
- * gcal_all_day_grid_set_column_headers:
- * @all_day: A #GcalAllDayGrid
- * @...: a list of strings
- *
- * Set the columns headers. If #GcalAllDayGrid:columns property
- * has not been set, this function does nothing.
- **/
-void
-gcal_all_day_grid_set_column_headers (GcalAllDayGrid *all_day,
- ...)
-{
- GcalAllDayGridPrivate *priv;
- va_list args;
- gint i;
-
- priv = gcal_all_day_grid_get_instance_private (all_day);
-
- if (priv->columns_nr == 0)
- return;
-
- if (priv->column_headers != NULL)
- g_list_free_full (priv->column_headers, g_free);
-
- va_start (args, all_day);
- for (i = 0; i < priv->columns_nr; ++i)
- {
- gchar *header;
- header = g_strdup (va_arg(args, gchar*));
-
- priv->column_headers = g_list_append (priv->column_headers,
- header);
- }
-
- va_end (args);
-}
-
-/**
- * gcal_all_day_grid_place:
- * @all_day: A #GcalAllDayGrid widget
- * @widget: The child widget to add
- * @column_idx: The index of the column, starting with zero
- * @column_span: The columns the widgets should expand
- *
- * Adding a widget to a specified column. If the column index
- * is bigger than the #GcalAllDayGrid:columns property set,
- * it will do nothing.
- **/
-void
-gcal_all_day_grid_place (GcalAllDayGrid *all_day,
- GtkWidget *widget,
- guint column_idx,
- guint column_span)
-{
- GcalAllDayGridPrivate *priv;
- GList* children_link;
- GList* column;
- ChildInfo *info;
-
- priv = gcal_all_day_grid_get_instance_private (all_day);
-
- g_return_if_fail (column_idx < priv->columns_nr);
-
- children_link = g_list_nth (priv->children, column_idx);
- column = (GList*) children_link->data;
-
- info = g_new0 (ChildInfo, 1);
- info->widget = widget;
- info->column_span = column_span;
- children_link->data = g_list_append (column, info);
-
- gtk_widget_set_parent (widget, GTK_WIDGET (all_day));
-}
-
-GtkWidget*
-gcal_all_day_grid_get_by_uuid (GcalAllDayGrid *all_day,
- const gchar *uuid)
-{
- GcalAllDayGridPrivate *priv;
-
- GList* columns;
-
- priv = gcal_all_day_grid_get_instance_private (all_day);
-
- columns = priv->children;
- while (columns)
- {
- GList *column;
-
- column = columns->data;
- columns = columns->next;
-
- while (column)
- {
- ChildInfo *info;
- GcalEventWidget *child;
-
- info = ((ChildInfo*) column->data);
- child = GCAL_EVENT_WIDGET (info->widget);
- column = column->next;
-
- if (g_strcmp0 (uuid,
- gcal_event_widget_peek_uuid (child)) == 0)
- {
- return (GtkWidget*) child;
- }
- }
- }
-
- return NULL;
-}
-
-/**
- * gcal_all_day_grid_clear_marks:
- * @all_day: a #GcalAllDayGrid
- *
- * Clear the value of the markings and queue a draw to update
- the widget looking
- **/
-void
-gcal_all_day_grid_clear_marks (GcalAllDayGrid *all_day)
-{
- GcalAllDayGridPrivate *priv;
-
- priv = gcal_all_day_grid_get_instance_private (all_day);
-
- priv->start_mark_cell = -1;
- priv->end_mark_cell = -1;
- gtk_widget_queue_draw (GTK_WIDGET (all_day));
-}
-
-void
-gcal_all_day_grid_get_cell_position (GcalAllDayGrid *all_day,
- guint cell,
- gint *x,
- gint *y)
-{
- GcalAllDayGridPrivate *priv;
-
- GtkWidget *widget;
-
- GtkBorder padding;
- PangoLayout *layout;
- PangoRectangle logical_rect;
- gint y_gap;
-
- gint width_block;
-
- priv = gcal_all_day_grid_get_instance_private (all_day);
-
- widget = GTK_WIDGET (all_day);
- width_block = gtk_widget_get_allocated_width (widget) / priv->columns_nr;
-
- if (x != NULL)
- *x = cell * width_block + width_block / 2;
-
- if (y != NULL)
- {
- layout = gtk_widget_create_pango_layout (widget, "0");
-
- gtk_style_context_get_padding (gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
- pango_layout_get_extents (layout, NULL, &logical_rect);
- pango_extents_to_pixels (&logical_rect, NULL);
-
- y_gap = padding.top + logical_rect.height + padding.bottom;
- *y = y_gap + (gtk_widget_get_allocated_height (widget) - y_gap) / 2;
-
- g_object_unref (layout);
- }
-}
diff --git a/src/gcal-all-day-grid.h b/src/gcal-all-day-grid.h
deleted file mode 100644
index f152118b..00000000
--- a/src/gcal-all-day-grid.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * gcal-all-day-grid.h
- *
- * Copyright (C) 2012 - Erick Pérez Castellanos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef __GCAL_ALL_DAY_GRID_H__
-#define __GCAL_ALL_DAY_GRID_H__
-
-#include
-
-G_BEGIN_DECLS
-
-#define GCAL_TYPE_ALL_DAY_GRID (gcal_all_day_grid_get_type ())
-#define GCAL_ALL_DAY_GRID(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_ALL_DAY_GRID, GcalAllDayGrid))
-#define GCAL_ALL_DAY_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_ALL_DAY_GRID, GcalAllDayGridClass))
-#define GCAL_IS_ALL_DAY_GRID(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_ALL_DAY_GRID))
-#define GCAL_IS_ALL_DAY_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_ALL_DAY_GRID))
-#define GCAL_ALL_DAY_GRID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_ALL_DAY_GRID, GcalAllDayGridClass))
-
-typedef struct _GcalAllDayGrid GcalAllDayGrid;
-typedef struct _GcalAllDayGridClass GcalAllDayGridClass;
-
-struct _GcalAllDayGrid
-{
- GtkContainer parent;
-};
-
-struct _GcalAllDayGridClass
-{
- GtkContainerClass parent_class;
-
- /* signals */
- void (*marked) (guint start_cell, guint end_cell);
-};
-
-GType gcal_all_day_grid_get_type (void);
-
-GtkWidget* gcal_all_day_grid_new (guint columns);
-
-void gcal_all_day_grid_set_column_headers (GcalAllDayGrid *all_day,
- ...);
-
-void gcal_all_day_grid_place (GcalAllDayGrid *all_day,
- GtkWidget *widget,
- guint column_idx,
- guint column_span);
-
-GtkWidget* gcal_all_day_grid_get_by_uuid (GcalAllDayGrid *all_day,
- const gchar *uuid);
-
-void gcal_all_day_grid_clear_marks (GcalAllDayGrid *all_day);
-
-void gcal_all_day_grid_get_cell_position (GcalAllDayGrid *all_day,
- guint cell,
- gint *x,
- gint *y);
-
-G_END_DECLS
-
-#endif /* __GCAL_ALL_DAY_GRID_H__ */
diff --git a/src/gcal-day-view.c b/src/gcal-day-view.c
deleted file mode 100644
index 626412d6..00000000
--- a/src/gcal-day-view.c
+++ /dev/null
@@ -1,690 +0,0 @@
-/* -*- mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * gcal-day-view.c
- *
- * Copyright (C) 2013 - Erick Pérez Castellanos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "gcal-day-view.h"
-#include "gcal-all-day-grid.h"
-#include "gcal-days-grid.h"
-#include "gcal-viewport.h"
-#include "gcal-utils.h"
-#include "gcal-view.h"
-#include "gcal-event-widget.h"
-
-#include
-
-#include
-
-enum
-{
- PROP_0,
- PROP_DATE
-};
-
-typedef struct
-{
- /* property */
- icaltimetype *date;
-
- GtkWidget *viewport;
- GtkWidget *fold_button;
-
- /* events widgets parents */
- GtkWidget *all_day_grid;
- GtkWidget *day_grid;
-} GcalDayViewPrivate;
-
-static void viewport_shown (GtkWidget *widget,
- gpointer user_data);
-
-static void days_grid_clicked (GcalDaysGrid *days_grid,
- guint start_cell,
- guint end_cell,
- gpointer user_data);
-
-static void all_day_grid_clicked (GcalAllDayGrid *all_day_grid,
- guint start_cell,
- guint end_cell,
- gpointer user_data);
-
-static void gcal_view_interface_init (GcalViewIface *iface);
-
-static void gcal_day_view_constructed (GObject *object);
-
-static void gcal_day_view_finalize (GObject *object);
-
-static void gcal_day_view_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void gcal_day_view_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gcal_day_view_add (GtkContainer *container,
- GtkWidget *widget);
-
-static void gcal_day_view_remove (GtkContainer *container,
- GtkWidget *widget);
-
-static icaltimetype* gcal_day_view_get_initial_date (GcalView *view);
-
-static icaltimetype* gcal_day_view_get_final_date (GcalView *view);
-
-static void gcal_day_view_mark_current_unit (GcalView *view,
- gint *x,
- gint *y);
-
-static void gcal_day_view_clear_marks (GcalView *view);
-
-static gchar* gcal_day_view_get_left_header (GcalView *view);
-
-static gchar* gcal_day_view_get_right_header (GcalView *view);
-
-static gboolean gcal_day_view_draw_event (GcalView *view,
- icaltimetype *start_date,
- icaltimetype *end_date);
-
-static GtkWidget* gcal_day_view_get_by_uuid (GcalView *view,
- const gchar *uuid);
-
-static void gcal_day_view_clear (GcalView *view);
-
-G_DEFINE_TYPE_WITH_CODE (GcalDayView,
- gcal_day_view,
- GTK_TYPE_GRID,
- G_ADD_PRIVATE (GcalDayView)
- G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,
- gcal_view_interface_init));
-
-static void
-viewport_shown (GtkWidget *widget,
- gpointer user_data)
-{
- GcalDayViewPrivate *priv;
- icaltimetype date;
- gdouble value;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (user_data));
-
- if (priv->date == NULL)
- return;
-
- date = icaltime_current_time_with_zone (priv->date->zone);
-
- /* FIXME: This isn't working as expected */
- /* - 2.0 is spacing to the let running hour show */
- value = ((gdouble) date.hour - 2.0) / 24.0;
-
- g_debug ("Getting into here, with value: %f", value);
- gcal_viewport_scroll_to (GCAL_VIEWPORT (priv->viewport), value);
-}
-
-static void
-days_grid_clicked (GcalDaysGrid *days_grid,
- guint start_cell,
- guint end_cell,
- gpointer user_data)
-{
- GcalDayViewPrivate *priv;
-
- icaltimetype *start_date;
- icaltimetype *end_date;
-
- gint x, y;
- gint new_x, new_y;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (user_data));
-
- g_debug ("Cells positions: %d, %d", start_cell, end_cell);
-
- start_date = gcal_dup_icaltime (priv->date);
- end_date = gcal_dup_icaltime (priv->date);
-
- start_date->hour = start_cell / 2;
- start_date->minute = 0;
- start_date->second = 0;
- *start_date = icaltime_normalize (*start_date);
- if (start_cell % 2 == 1)
- start_date->minute = 30;
-
- end_date->hour = end_cell / 2;
- end_date->minute = 0;
- end_date->second = 0;
- if (end_cell % 2 == 1)
- end_date->hour++;
- else
- end_date->minute = 30;
- *end_date = icaltime_normalize (*end_date);
-
- gcal_days_grid_get_cell_position (GCAL_DAYS_GRID (priv->day_grid),
- start_cell, &x, &y);
- g_debug ("Click Position: %d, %d", x, y);
-
- gtk_widget_translate_coordinates (priv->day_grid,
- GTK_WIDGET (user_data),
- x, y,
- &new_x, &new_y);
- g_debug ("Translated Click Position: %d, %d", new_x, new_y);
-
- g_signal_emit_by_name (GCAL_VIEW (user_data),
- "create-event",
- start_date, end_date,
- (gdouble) new_x, (gdouble) new_y);
-
- g_free (start_date);
- g_free (end_date);
-}
-
-static void
-all_day_grid_clicked (GcalAllDayGrid *all_day_grid,
- guint start_cell,
- guint end_cell,
- gpointer user_data)
-{
- GcalDayViewPrivate *priv;
-
- icaltimetype *start_date;
- icaltimetype *end_date;
-
- gint x, y;
- gint new_x, new_y;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (user_data));
-
- g_debug ("Receiving marked signal in day-view from all-day-grid");
- g_debug ("Cells positions: %d, %d", start_cell, end_cell);
-
- start_date = gcal_dup_icaltime (priv->date);
- end_date = gcal_dup_icaltime (priv->date);
-
- start_date->is_date = 1;
- end_date->is_date = 1;
-
- if (start_cell != end_cell)
- {
- end_date->day++;
- *end_date = icaltime_normalize (*end_date);
- }
- else if (start_cell == 1)
- {
- start_date->day++;
- *start_date = icaltime_normalize (*start_date);
- end_date->day++;
- *end_date = icaltime_normalize (*end_date);
- }
-
- gcal_all_day_grid_get_cell_position (GCAL_ALL_DAY_GRID (priv->all_day_grid),
- start_cell, &x, &y);
- g_debug ("Click Position: %d, %d", x, y);
-
- gtk_widget_translate_coordinates (priv->all_day_grid,
- GTK_WIDGET (user_data),
- x, y,
- &new_x, &new_y);
- g_debug ("Translated Click Position: %d, %d", new_x, new_y);
-
- g_signal_emit_by_name (GCAL_VIEW (user_data),
- "create-event",
- start_date, end_date,
- (gdouble) new_x, (gdouble) new_y);
-
- g_debug ("start_date: %s", icaltime_as_ical_string (*start_date));
- g_debug ("end_date: %s", icaltime_as_ical_string (*end_date));
-
- g_free (start_date);
- g_free (end_date);
-}
-
-static void
-gcal_day_view_class_init (GcalDayViewClass *klass)
-{
- GObjectClass *object_class;
- GtkContainerClass *container_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->constructed = gcal_day_view_constructed;
- object_class->finalize = gcal_day_view_finalize;
- object_class->set_property = gcal_day_view_set_property;
- object_class->get_property = gcal_day_view_get_property;
-
- container_class = GTK_CONTAINER_CLASS (klass);
- container_class->add = gcal_day_view_add;
- container_class->remove = gcal_day_view_remove;
- /* FIXME: Uncomment stuff here */
- /* gtk_container_class_handle_border_width (container_class); */
-
- g_object_class_override_property (object_class, PROP_DATE, "active-date");
-}
-
-static void
-gcal_day_view_init (GcalDayView *self)
-{
-}
-
-static void
-gcal_view_interface_init (GcalViewIface *iface)
-{
- /* New API */
- iface->get_initial_date = gcal_day_view_get_initial_date;
- iface->get_final_date = gcal_day_view_get_final_date;
-
- iface->mark_current_unit = gcal_day_view_mark_current_unit;
- iface->clear_marks = gcal_day_view_clear_marks;
-
- iface->get_left_header = gcal_day_view_get_left_header;
- iface->get_right_header = gcal_day_view_get_right_header;
-
- iface->draw_event = gcal_day_view_draw_event;
- iface->get_by_uuid = gcal_day_view_get_by_uuid;
- iface->clear = gcal_day_view_clear;
-}
-
-static void
-gcal_day_view_constructed (GObject *object)
-{
- GcalDayViewPrivate *priv;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (object));
-
- if (G_OBJECT_CLASS (gcal_day_view_parent_class)->constructed != NULL)
- G_OBJECT_CLASS (gcal_day_view_parent_class)->constructed (object);
-
- priv->fold_button = gtk_button_new_with_label (_("Fold"));
- g_object_set (priv->fold_button,
- "valign", GTK_ALIGN_END,
- "margin", 6,
- NULL);
- gtk_style_context_add_class (
- gtk_widget_get_style_context (priv->fold_button),
- "nav-button");
- gtk_grid_attach (GTK_GRID (object), priv->fold_button, 0, 0, 1, 1);
-
- /* event widget holders */
- priv->all_day_grid = gcal_all_day_grid_new (2);
- gcal_all_day_grid_set_column_headers (GCAL_ALL_DAY_GRID (priv->all_day_grid),
- _("Today"),
- _("Tomorrow"));
- gtk_widget_set_size_request (priv->all_day_grid, -1, 64);
- gtk_widget_set_hexpand (priv->all_day_grid, TRUE);
-
- priv->day_grid = gcal_days_grid_new (2);
- gcal_days_grid_set_preferred_cell_height (GCAL_DAYS_GRID (priv->day_grid), 60);
-
- gtk_widget_set_hexpand (priv->day_grid, TRUE);
- gtk_widget_set_vexpand (priv->day_grid, TRUE);
-
- gtk_grid_attach (GTK_GRID (object), priv->all_day_grid, 1, 0, 1, 1);
-
- priv->viewport = gcal_viewport_new ();
- gcal_viewport_add (GCAL_VIEWPORT (priv->viewport), priv->day_grid);
- gtk_grid_attach (GTK_GRID (object), priv->viewport, 0, 1, 2, 1);
-
- /* binding sizes */
- gtk_widget_set_size_request (
- priv->fold_button,
- gcal_days_grid_get_scale_width (GCAL_DAYS_GRID (priv->day_grid)) - 12,
- -1);
-
- gtk_widget_show_all (GTK_WIDGET (object));
-
- /* signal handling */
- g_signal_connect_after (object, "map", G_CALLBACK (viewport_shown), object);
- g_signal_connect (priv->day_grid, "marked",
- G_CALLBACK (days_grid_clicked), object);
- g_signal_connect (priv->all_day_grid, "marked",
- G_CALLBACK (all_day_grid_clicked), object);
-}
-
-static void
-gcal_day_view_finalize (GObject *object)
-{
- GcalDayViewPrivate *priv;
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (object));
-
- if (priv->date != NULL)
- g_free (priv->date);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (gcal_day_view_parent_class)->finalize (object);
-}
-
-static void
-gcal_day_view_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GcalDayViewPrivate *priv;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (object));
-
- switch (property_id)
- {
- case PROP_DATE:
- if (priv->date != NULL)
- g_free (priv->date);
-
- priv->date = g_value_dup_boxed (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-gcal_day_view_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GcalDayViewPrivate *priv;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (object));
-
- switch (property_id)
- {
- case PROP_DATE:
- g_value_set_boxed (value, priv->date);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-/* GtkContainer API */
-static void
-gcal_day_view_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GcalDayViewPrivate *priv;
- icaltimetype *tomorrow;
- icaltimetype *dt_start;
- icaltimetype *dt_end;
- gchar* summ;
-
- g_return_if_fail (GCAL_IS_EVENT_WIDGET (widget));
- g_return_if_fail (gtk_widget_get_parent (widget) == NULL);
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (container));
-
- summ = gcal_event_widget_get_summary (GCAL_EVENT_WIDGET (widget));
-
- tomorrow = gcal_day_view_get_final_date (GCAL_VIEW (container));
- dt_start = gcal_event_widget_get_date (GCAL_EVENT_WIDGET (widget));
- dt_end = gcal_event_widget_get_end_date (GCAL_EVENT_WIDGET (widget));
-
- /* FIXME: recheck conditions to add, what, where */
- /* Maybe, should be good to add, inside days views only contained events */
- g_debug ("[processing] %s from %s to %s",
- summ,
- icaltime_as_ical_string (*dt_start),
- icaltime_as_ical_string (*dt_end));
-
- if (! gcal_event_widget_get_all_day (GCAL_EVENT_WIDGET (widget)) &&
- (dt_start->day == dt_end->day) &&
- (dt_start->day == priv->date->day ||
- dt_start->day == tomorrow->day))
- {
- g_debug ("[days-grid] %s from %s to %s",
- summ,
- icaltime_as_ical_string (*dt_start),
- icaltime_as_ical_string (*dt_end));
-
- gcal_days_grid_place (GCAL_DAYS_GRID (priv->day_grid),
- widget,
- priv->date->day == dt_start->day ? 0 : 1,
- dt_start->hour * 2 + (dt_start->minute / 30),
- dt_end->hour * 2 + (dt_end->minute / 30)); /* FIXME Include half hour and length */
- }
- else
- {
- gboolean start_tomorrow;
- guint length;
- g_debug ("[all-day-grid] %s from %s to %s",
- summ,
- icaltime_as_ical_string (*dt_start),
- icaltime_as_ical_string (*dt_end));
- start_tomorrow = icaltime_compare_date_only (*dt_start, *tomorrow) == 0;
-
- if (start_tomorrow)
- length = 1;
- else if (dt_start->day != dt_end->day)
- length = 2;
- else
- length = 1;
- gcal_all_day_grid_place (GCAL_ALL_DAY_GRID (priv->all_day_grid),
- widget,
- start_tomorrow ? 1 : 0, length);
- }
-
- g_free (tomorrow);
- g_free (dt_start);
- g_free (dt_end);
- g_free (summ);
-}
-
-static void
-gcal_day_view_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GcalDayViewPrivate *priv;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (container));
-
- if (gtk_widget_get_parent (widget) == (GtkWidget*) container)
- {
- GTK_CONTAINER_CLASS (gcal_day_view_parent_class)->remove (container,
- widget);
- }
- else
- {
- gtk_container_remove (GTK_CONTAINER (priv->all_day_grid), widget);
- gtk_container_remove (GTK_CONTAINER (priv->day_grid), widget);
- }
-}
-
-/* GcalView API */
-static icaltimetype*
-gcal_day_view_get_initial_date (GcalView *view)
-{
- GcalDayViewPrivate *priv;
- icaltimetype *new_date;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
- new_date = g_new0 (icaltimetype, 1);
- *new_date = *(priv->date);
- new_date->hour = 0;
- new_date->minute = 0;
- new_date->second = 0;
-
- return new_date;
-}
-
-/**
- * gcal_day_view_get_final_date:
- * @view: a #GcalDayView
- *
- * Returns the date of "tomorrow" at 23:59
- *
- * Returns:
- **/
-static icaltimetype*
-gcal_day_view_get_final_date (GcalView *view)
-{
- GcalDayViewPrivate *priv;
- icaltimetype *new_date;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
- new_date = g_new0 (icaltimetype, 1);
- *new_date = *(priv->date);
-
- icaltime_adjust (new_date, 1, 0, 0, 0);
-
- new_date->hour = 23;
- new_date->minute = 59;
- new_date->second = 59;
-
- return new_date;
-}
-
-static void
-gcal_day_view_mark_current_unit (GcalView *view,
- gint *x,
- gint *y)
-{
- GcalDayViewPrivate *priv;
-
- guint cell;
- gint orig_x, orig_y;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
-
- cell = priv->date->hour * 2 + (priv->date->minute / 30);
- gcal_days_grid_mark_cell (GCAL_DAYS_GRID (priv->day_grid), cell);
- gcal_days_grid_get_cell_position (GCAL_DAYS_GRID (priv->day_grid),
- cell, &orig_x, &orig_y);
- g_debug ("Click Position: %d, %d", orig_x, orig_y);
-
- gtk_widget_translate_coordinates (priv->day_grid,
- GTK_WIDGET (view),
- orig_x, orig_y,
- x, y);
- g_debug ("Translated Click Position: %d, %d", *x, *y);
-}
-
-static void
-gcal_day_view_clear_marks (GcalView *view)
-{
- GcalDayViewPrivate *priv;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
- gcal_days_grid_clear_marks (GCAL_DAYS_GRID (priv->day_grid));
- gcal_all_day_grid_clear_marks (GCAL_ALL_DAY_GRID (priv->all_day_grid));
-}
-
-static gchar*
-gcal_day_view_get_left_header (GcalView *view)
-{
- GcalDayViewPrivate *priv;
-
- gchar str_date[64];
-
- struct tm tm_date;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
-
- tm_date = icaltimetype_to_tm (priv->date);
- e_utf8_strftime_fix_am_pm (str_date, 64, "%A %B", &tm_date);
-
- return g_strdup_printf ("%s, %d", str_date, priv->date->day);
-}
-
-static gchar*
-gcal_day_view_get_right_header (GcalView *view)
-{
- GcalDayViewPrivate *priv;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
-
- return g_strdup_printf ("%d", priv->date->year);
-}
-
-static gboolean
-gcal_day_view_draw_event (GcalView *view,
- icaltimetype *start_date,
- icaltimetype *end_date)
-{
- GcalDayViewPrivate *priv;
-
- icaltimetype *first_day;
- icaltimetype *last_day;
- gint left_boundary;
- gint right_boundary;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
- first_day = gcal_day_view_get_initial_date (view);
- last_day = gcal_day_view_get_final_date (view);
-
- if (priv->date == NULL)
- return FALSE;
-
- /* XXX: Check for date_only comparison since might drop timezone info */
- left_boundary = icaltime_compare_date_only (*end_date, *first_day);
- right_boundary = icaltime_compare_date_only (*last_day, *start_date);
-
- if (left_boundary == -1 || right_boundary == -1)
- return FALSE;
-
- return TRUE;
-}
-
-static GtkWidget*
-gcal_day_view_get_by_uuid (GcalView *view,
- const gchar *uuid)
-{
- GcalDayViewPrivate *priv;
- GtkWidget *widget;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
-
- widget =
- gcal_all_day_grid_get_by_uuid (GCAL_ALL_DAY_GRID (priv->all_day_grid),
- uuid);
- if (widget != NULL)
- return widget;
-
- widget =
- gcal_days_grid_get_by_uuid (GCAL_DAYS_GRID (priv->day_grid),
- uuid);
- if (widget != NULL)
- return widget;
-
- return NULL;
-}
-
-static void
-gcal_day_view_clear (GcalView *view)
-{
- GcalDayViewPrivate *priv;
-
- priv = gcal_day_view_get_instance_private (GCAL_DAY_VIEW (view));
-
- gtk_container_foreach (GTK_CONTAINER (priv->all_day_grid),
- (GtkCallback) gtk_widget_destroy, NULL);
- gtk_container_foreach (GTK_CONTAINER (priv->day_grid),
- (GtkCallback) gtk_widget_destroy, NULL);
-}
-
-/* Public API */
-/**
- * gcal_day_view_new:
- * @date:
- *
- * Since: 0.1
- * Return value: A new #GcalDayView
- * Returns: (transfer full):
- **/
-GtkWidget*
-gcal_day_view_new (void)
-{
- return g_object_new (GCAL_TYPE_DAY_VIEW, NULL);
-}
diff --git a/src/gcal-day-view.h b/src/gcal-day-view.h
deleted file mode 100644
index c564cd32..00000000
--- a/src/gcal-day-view.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * gcal-day-view.h
- *
- * Copyright (C) 2013 - Erick Pérez Castellanos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef __GCAL_DAY_VIEW_H__
-#define __GCAL_DAY_VIEW_H__
-
-#include
-
-G_BEGIN_DECLS
-
-#define GCAL_TYPE_DAY_VIEW (gcal_day_view_get_type ())
-#define GCAL_DAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_DAY_VIEW, GcalDayView))
-#define GCAL_DAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_DAY_VIEW, GcalDayViewClass))
-#define GCAL_IS_DAY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_DAY_VIEW))
-#define GCAL_IS_DAY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_DAY_VIEW))
-#define GCAL_DAY_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_DAY_VIEW, GcalDayViewClass))
-
-typedef struct _GcalDayView GcalDayView;
-typedef struct _GcalDayViewClass GcalDayViewClass;
-
-struct _GcalDayView
-{
- GtkGrid parent;
-};
-
-struct _GcalDayViewClass
-{
- GtkGridClass parent_class;
-};
-
-GType gcal_day_view_get_type (void);
-
-GtkWidget* gcal_day_view_new (void);
-
-G_END_DECLS
-
-#endif /* __GCAL_DAY_VIEW_H__ */
diff --git a/src/gcal-days-grid.c b/src/gcal-days-grid.c
deleted file mode 100644
index b48acf8a..00000000
--- a/src/gcal-days-grid.c
+++ /dev/null
@@ -1,1178 +0,0 @@
-/* -*- mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * gcal-days-grid.c
- *
- * Copyright (C) 2012 - Erick Pérez Castellanos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "gcal-days-grid.h"
-#include "gcal-event-widget.h"
-
-#include
-
-#include
-#include
-
-/*
- * Notes:
- * 1. the widget's height is divided between 48 cells
- * representing each a half-hour of the day.
- * the preferred value of the cell is kept is req_cell_heigth
- * private field.
- */
-
-static const double dashed [] =
-{
- 1.0,
- 1.0
-};
-
-enum
-{
- PROP_0,
- PROP_COLUMNS,
- PROP_FOLDED
-};
-
-struct _ChildInfo
-{
- GtkWidget *widget;
-
- guint start_cell;
- guint end_cell;
- guint sub_column;
-
- gboolean hidden;
-};
-
-typedef struct _ChildInfo ChildInfo;
-
-typedef struct
-{
- /* property */
- guint columns_nr;
- guint spacing;
- gboolean folded;
-
- guint scale_width;
- guint req_cell_height;
-
- GList *children;
-
- GdkWindow *event_window;
-
- /* button_down/up flags */
- gint clicked_cell;
- gint start_mark_cell;
- gint end_mark_cell;
-
-} GcalDaysGridPrivate;
-
-enum
-{
- MARKED,
- NUM_SIGNALS
-};
-
-static guint signals[NUM_SIGNALS] = { 0, };
-
-/* Helpers and private */
-static gint compare_child_info (gconstpointer a,
- gconstpointer b);
-
-static void gcal_days_grid_finalize (GObject *object);
-
-static void gcal_days_grid_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void gcal_days_grid_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gcal_days_grid_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural);
-
-static void gcal_days_grid_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural);
-
-static void gcal_days_grid_realize (GtkWidget *widget);
-
-static void gcal_days_grid_unrealize (GtkWidget *widget);
-
-static void gcal_days_grid_map (GtkWidget *widget);
-
-static void gcal_days_grid_unmap (GtkWidget *widget);
-
-static void gcal_days_grid_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-static gboolean gcal_days_grid_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static gboolean gcal_days_grid_button_press_event (GtkWidget *widget,
- GdkEventButton *event);
-
-static gboolean gcal_days_grid_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event);
-
-static gboolean gcal_days_grid_button_release_event (GtkWidget *widget,
- GdkEventButton *event);
-
-static void gcal_days_grid_add (GtkContainer *container,
- GtkWidget *widget);
-
-static void gcal_days_grid_remove (GtkContainer *container,
- GtkWidget *widget);
-
-static void gcal_days_grid_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-
-G_DEFINE_TYPE_WITH_PRIVATE (GcalDaysGrid,gcal_days_grid, GTK_TYPE_CONTAINER);
-
-/* Helpers and private */
-static gint
-compare_child_info (gconstpointer a,
- gconstpointer b)
-{
- ChildInfo *ac = (ChildInfo*) a;
- ChildInfo *bc = (ChildInfo*) b;
-
- if (ac->start_cell < bc->start_cell)
- return -1;
- else if (ac->start_cell == bc->start_cell)
- return 0;
- else
- return 1;
-}
-
-
-static void
-gcal_days_grid_class_init (GcalDaysGridClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gcal_days_grid_finalize;
- object_class->set_property = gcal_days_grid_set_property;
- object_class->get_property = gcal_days_grid_get_property;
-
- widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->get_preferred_width = gcal_days_grid_get_preferred_width;
- widget_class->get_preferred_height = gcal_days_grid_get_preferred_height;
- widget_class->realize = gcal_days_grid_realize;
- widget_class->unrealize = gcal_days_grid_unrealize;
- widget_class->map = gcal_days_grid_map;
- widget_class->unmap = gcal_days_grid_unmap;
- widget_class->size_allocate = gcal_days_grid_size_allocate;
- widget_class->draw = gcal_days_grid_draw;
- widget_class->button_press_event = gcal_days_grid_button_press_event;
- widget_class->motion_notify_event = gcal_days_grid_motion_notify_event;
- widget_class->button_release_event = gcal_days_grid_button_release_event;
-
- container_class = GTK_CONTAINER_CLASS (klass);
- container_class->add = gcal_days_grid_add;
- container_class->remove = gcal_days_grid_remove;
- container_class->forall = gcal_days_grid_forall;
- gtk_container_class_handle_border_width (container_class);
-
- g_object_class_install_property (
- object_class,
- PROP_COLUMNS,
- g_param_spec_uint ("columns",
- "Columns",
- "The number of columns in which to split the grid",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- object_class,
- PROP_FOLDED,
- g_param_spec_boolean ("folded",
- "Folded status",
- "Whether the view is folded or not",
- FALSE,
- G_PARAM_CONSTRUCT |
- G_PARAM_READWRITE));
-
- /* comunicate to its parent view the marking */
- signals[MARKED] = g_signal_new ("marked",
- GCAL_TYPE_DAYS_GRID,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GcalDaysGridClass,
- marked),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_UINT,
- G_TYPE_UINT);
-}
-
-
-
-static void
-gcal_days_grid_init (GcalDaysGrid *self)
-{
- GcalDaysGridPrivate *priv;
-
- gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
-
- priv = gcal_days_grid_get_instance_private (self);
- priv->scale_width = 0;
- priv->req_cell_height = 0;
-
- priv->children = NULL;
-
- priv->clicked_cell = -1;
- priv->start_mark_cell = -1;
- priv->end_mark_cell = -1;
-
- gtk_style_context_add_class (
- gtk_widget_get_style_context (GTK_WIDGET (self)),
- "calendar-view");
-}
-
-static void
-gcal_days_grid_finalize (GObject *object)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (object));
-
- if (priv->children != NULL)
- g_list_free_full (priv->children, (GDestroyNotify) g_list_free);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (gcal_days_grid_parent_class)->finalize (object);
-}
-
-static void
-gcal_days_grid_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (object));
-
- switch (property_id)
- {
- case PROP_COLUMNS:
- {
- gint i;
- priv->columns_nr = g_value_get_uint (value);
- for (i = 0; i < priv->columns_nr; ++i)
- {
- priv->children = g_list_prepend (priv->children, NULL);
- }
- break;
- }
- case PROP_FOLDED:
- priv->folded = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-gcal_days_grid_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (object));
-
- switch (property_id)
- {
- case PROP_COLUMNS:
- g_value_set_uint (value, priv->columns_nr);
- break;
- case PROP_FOLDED:
- g_value_set_boolean (value, priv->folded);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-/* GtkWidget API */
-static void
-gcal_days_grid_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GcalDaysGridPrivate* priv;
-
- GList *columns;
-
- gint nat_keeper;
- gint nat_width;
-
- gint min_keeper;
- gint min_width;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
-
- gcal_days_grid_get_scale_width (GCAL_DAYS_GRID (widget));
-
- nat_keeper = 0;
- min_keeper = G_MAXINT;
-
- for (columns = priv->children;
- columns != NULL;
- columns = g_list_next (columns))
- {
- GList *column;
-
- column = (GList*) columns->data;
- while (column)
- {
- ChildInfo *info = (ChildInfo*) column->data;
- column = column->next;
-
- gtk_widget_get_preferred_width (info->widget, &min_width, &nat_width);
- if (nat_keeper < nat_width)
- nat_keeper = nat_width;
- if (min_keeper > min_width)
- min_keeper = min_width;
- }
- }
-
- if (min_keeper == G_MAXINT)
- min_keeper = 0;
-
- if (minimum != NULL)
- {
- *minimum = (priv->columns_nr * min_keeper) + priv->scale_width;
- }
- if (natural != NULL)
- {
- *natural = (priv->columns_nr * nat_keeper) + priv->scale_width;
- }
-}
-
-static void
-gcal_days_grid_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GcalDaysGridPrivate* priv;
-
- GtkBorder padding;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
-
- gtk_style_context_get_padding (gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- if (minimum != NULL)
- {
- *minimum = priv->req_cell_height * 48 + padding.top + padding.bottom;
- }
- if (natural != NULL)
- {
- *natural = priv->req_cell_height * 48 + padding.top + padding.bottom;
- }
-}
-
-static void
-gcal_days_grid_realize (GtkWidget *widget)
-{
- GcalDaysGridPrivate *priv;
- GdkWindow *parent_window;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkAllocation allocation;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
- gtk_widget_set_realized (widget, TRUE);
-
- parent_window = gtk_widget_get_parent_window (widget);
- gtk_widget_set_window (widget, parent_window);
- g_object_ref (parent_window);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_ONLY;
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- priv->event_window = gdk_window_new (parent_window,
- &attributes,
- attributes_mask);
- gdk_window_set_user_data (priv->event_window, widget);
-}
-
-static void
-gcal_days_grid_unrealize (GtkWidget *widget)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
- if (priv->event_window != NULL)
- {
- gdk_window_set_user_data (priv->event_window, NULL);
- gdk_window_destroy (priv->event_window);
- priv->event_window = NULL;
- }
-
- GTK_WIDGET_CLASS (gcal_days_grid_parent_class)->unrealize (widget);
-}
-
-static void
-gcal_days_grid_map (GtkWidget *widget)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
- if (priv->event_window != NULL)
- gdk_window_show (priv->event_window);
-
- GTK_WIDGET_CLASS (gcal_days_grid_parent_class)->map (widget);
-}
-
-static void
-gcal_days_grid_unmap (GtkWidget *widget)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
- if (priv->event_window != NULL)
- gdk_window_hide (priv->event_window);
-
- GTK_WIDGET_CLASS (gcal_days_grid_parent_class)->unmap (widget);
-}
-
-static void
-gcal_days_grid_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GcalDaysGridPrivate *priv;
-
- GtkBorder padding;
- gint width_block;
- gint height_block;
-
- GList *columns;
- gint idx;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
- gtk_widget_set_allocation (widget, allocation);
-
- /* Placing the event_window */
- if (gtk_widget_get_realized (widget))
- {
- gdk_window_move_resize (priv->event_window,
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
- }
-
- gtk_style_context_get_padding (gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- width_block = (allocation->width - priv->scale_width) / priv->columns_nr;
- height_block = (allocation->height - (padding.top + padding.bottom)) / 48;
-
- /* detecting columns and allocs */
- for (columns = priv->children, idx = 0;
- columns != NULL;
- columns = g_list_next (columns), ++idx)
- {
- GtkAllocation child_allocation;
- GArray *last_y;
- GList* column = (GList*) columns->data;
-
- /* last_y value for each column,
- will keep the amount of columns as well */
- last_y = g_array_new (FALSE, FALSE, sizeof (guint));
-
- /* going through widgets */
- for (;column != NULL; column = g_list_next (column))
- {
- ChildInfo *info;
- gboolean new_column = TRUE;
- gint i;
-
- info = (ChildInfo*) column->data;
-
- for (i = 0; i < last_y->len; ++i)
- {
- /* start before */
- if (info->start_cell > g_array_index (last_y, guint, i))
- {
- info->sub_column = i;
- new_column = FALSE;
- break;
- }
- }
-
- if (new_column)
- {
- /* adding column to array */
- g_array_append_val (last_y, info->end_cell);
- info->sub_column = last_y->len - 1;
- }
- else
- {
- g_array_index (last_y, guint, info->sub_column) = info->end_cell;
- }
- }
-
- /* allocating */
- for (column = (GList*) columns->data;
- column != NULL;
- column = g_list_next (column))
- {
- ChildInfo *info;
- guint sub_column_block;
-
- info = (ChildInfo*) column->data;
- sub_column_block = width_block / last_y->len;
-
- child_allocation.x = allocation->x + priv->scale_width +
- idx * width_block + sub_column_block * info->sub_column;
- child_allocation.y = info->start_cell * height_block;
- child_allocation.width = sub_column_block;
- child_allocation.height = (info->end_cell - info->start_cell) * height_block;
-
- gtk_widget_size_allocate (info->widget, &child_allocation);
- }
-
- g_array_free (last_y, TRUE);
- }
-}
-
-static gboolean
-gcal_days_grid_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GcalDaysGridPrivate *priv;
-
- GtkBorder padding;
- GtkAllocation alloc;
- gint width;
-
- GdkRGBA ligther_color;
- GdkRGBA background_selected_color;
- GdkRGBA font_color;
-
- PangoLayout *layout;
- PangoFontDescription *font_desc;
-
- gint i;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
-
- gtk_style_context_get_padding (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- gtk_widget_get_allocation (widget, &alloc);
- width = alloc.width - (priv->scale_width);
-
- gtk_style_context_get_color (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &font_color);
-
- gtk_style_context_get_color (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget) | GTK_STATE_FLAG_INSENSITIVE,
- &ligther_color);
-
- gtk_style_context_get (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- "font", &font_desc, NULL);
-
- cairo_save (cr);
-
- /* drawing text of the sidebar */
- layout = pango_cairo_create_layout (cr);
- pango_layout_set_font_description (layout, font_desc);
-
- cairo_set_source_rgb (cr,
- font_color.red,
- font_color.green,
- font_color.blue);
-
- for (i = 0; i < 24; i++)
- {
- gchar *hours;
- hours = g_strdup_printf ("%d:00 %s", i % 12, i < 12 ? _("AM") : _("PM"));
-
- if (i == 0)
- pango_layout_set_text (layout, _("Midnight"), -1);
- else if (i == 12)
- pango_layout_set_text (layout, _("Noon"), -1);
- else
- pango_layout_set_text (layout, hours, -1);
-
- pango_cairo_update_layout (cr, layout);
- cairo_move_to (cr,
- padding.left,
- padding.top + (alloc.height / 24) * i);
- pango_cairo_show_layout (cr, layout);
-
- g_free (hours);
- }
-
- /* drawing new-event mark */
- if (priv->start_mark_cell != -1 &&
- priv->end_mark_cell != -1)
- {
- gint first_cell;
- gint last_cell;
- gint columns;
-
- gtk_style_context_get_background_color (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget) | GTK_STATE_FLAG_SELECTED,
- &background_selected_color);
-
- if (priv->start_mark_cell < priv->end_mark_cell)
- {
- first_cell = priv->start_mark_cell;
- last_cell = priv->end_mark_cell;
- }
- else
- {
- first_cell = priv->end_mark_cell;
- last_cell = priv->start_mark_cell;
- }
-
- cairo_save (cr);
- cairo_set_source_rgba (cr,
- background_selected_color.red,
- background_selected_color.green,
- background_selected_color.blue,
- background_selected_color.alpha);
-
- for (columns = 0; columns < last_cell / 48 - first_cell / 48 + 1; columns++)
- {
- gint first_point;
- gint last_point;
-
- first_point = (columns == 0) ? first_cell : ((first_cell / 48) + columns) * 48;
- last_point = (columns == (last_cell / 48 - first_cell / 48)) ? last_cell : ((first_cell / 48) + columns) * 48 + 47;
-
- cairo_rectangle (cr,
- priv->scale_width + (width / priv->columns_nr) * (first_point / 48),
- (first_point % 48) * (alloc.height / 48),
- (width / priv->columns_nr),
- (last_point - first_point + 1) * (alloc.height / 48));
- cairo_fill (cr);
-
- }
- cairo_restore (cr);
- }
-
- /* drawing lines */
- cairo_set_source_rgb (cr,
- ligther_color.red,
- ligther_color.green,
- ligther_color.blue);
- cairo_set_line_width (cr, 0.3);
-
- /* grid, vertical lines first */
- for (i = 0; i < priv->columns_nr + 1; i++)
- {
- cairo_move_to (cr,
- priv->scale_width + (width / priv->columns_nr) * i + 0.4,
- 0);
- cairo_rel_line_to (cr, 0, alloc.height);
- }
-
- /* rest of the lines */
- for (i = 0; i < 24; i++)
- {
- /* hours lines */
- cairo_move_to (cr, 0, (alloc.height / 24) * i + 0.4);
- cairo_rel_line_to (cr, width + priv->scale_width, 0);
- }
-
- cairo_stroke (cr);
-
- /* 30 minutes lines */
- cairo_set_dash (cr, dashed, 2, 0);
- for (i = 0; i < 24; i++)
- {
- cairo_move_to (cr, priv->scale_width, (alloc.height / 24) * i + (alloc.height / 48) + 0.4);
- cairo_rel_line_to (cr, width + priv->scale_width, 0);
- }
-
- cairo_stroke (cr);
- cairo_restore (cr);
-
- pango_font_description_free (font_desc);
- g_object_unref (layout);
-
- /* drawing children */
- if (GTK_WIDGET_CLASS (gcal_days_grid_parent_class)->draw != NULL)
- GTK_WIDGET_CLASS (gcal_days_grid_parent_class)->draw (widget, cr);
-
- return FALSE;
-}
-
-static gboolean
-gcal_days_grid_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- GcalDaysGridPrivate *priv;
-
- GtkBorder padding;
- GtkAllocation alloc;
- gint width_block;
- gint height_block;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
-
- gtk_style_context_get_padding (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- /* XXX: an improvement will be scroll to that position when
- click the scale at the side */
- if (event->x < priv->scale_width)
- return FALSE;
-
- gtk_widget_get_allocation (widget, &alloc);
- width_block = (alloc.width - priv->scale_width) / priv->columns_nr;
- height_block = (alloc.height - (padding.top + padding.bottom)) / 48;
-
- priv->clicked_cell = 48 * (((gint) event->x - priv->scale_width) / width_block) + event->y / height_block;
- priv->start_mark_cell = priv->clicked_cell;
-
- return TRUE;
-}
-
-static gboolean
-gcal_days_grid_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event)
-{
- GcalDaysGridPrivate *priv;
-
- GtkBorder padding;
- GtkAllocation alloc;
- gint width_block;
- gint height_block;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
-
- if (priv->clicked_cell == -1)
- return FALSE;
-
- gtk_style_context_get_padding (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- gtk_widget_get_allocation (widget, &alloc);
- width_block = (alloc.width - priv->scale_width) / priv->columns_nr;
- height_block = (alloc.height - (padding.top + padding.bottom)) / 48;
-
- priv->end_mark_cell = 48 * (((gint) event->x - priv->scale_width) / width_block) + event->y / height_block;
-
- gtk_widget_queue_draw (widget);
- return TRUE;
-}
-
-static gboolean
-gcal_days_grid_button_release_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- GcalDaysGridPrivate *priv;
-
- GtkBorder padding;
- GtkAllocation alloc;
- gint width_block;
- gint height_block;
-
- gint cell_temp;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (widget));
-
- if (priv->clicked_cell == -1)
- return FALSE;
-
- gtk_style_context_get_padding (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- if (event->x < priv->scale_width)
- {
- priv->start_mark_cell = -1;
- priv->end_mark_cell = -1;
- return FALSE;
- }
-
- gtk_widget_get_allocation (widget, &alloc);
- width_block = (alloc.width - priv->scale_width) / priv->columns_nr;
- height_block = (alloc.height - (padding.top + padding.bottom)) / 48;
-
- priv->end_mark_cell = 48 * (((gint) event->x - priv->scale_width) / width_block) + event->y / height_block;
-
- gtk_widget_queue_draw (widget);
-
- if (priv->start_mark_cell > priv->end_mark_cell)
- {
- cell_temp = priv->end_mark_cell;
- priv->end_mark_cell = priv->start_mark_cell;
- priv->start_mark_cell = cell_temp;
- }
-
- g_signal_emit (GCAL_DAYS_GRID (widget),
- signals[MARKED], 0,
- priv->start_mark_cell, priv->end_mark_cell);
-
- priv->clicked_cell = -1;
- return TRUE;
-}
-
-/* GtkContainer API */
-/**
- * gcal_days_grid_add:
- * @container:
- * @widget:
- *
- * @gtk_container_add implementation. It assumes the widget will go
- * to the first column. If there's no column set, will set columns to 1
- *
- **/
-static void
-gcal_days_grid_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GcalDaysGridPrivate* priv;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (container));
- g_return_if_fail (priv->columns_nr != 0);
-
- gcal_days_grid_place (GCAL_DAYS_GRID (container),
- widget,
- 0, 0, 0);
-}
-
-static void
-gcal_days_grid_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GcalDaysGridPrivate *priv;
-
- GList *columns;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (container));
-
- for (columns = priv->children;
- columns != NULL;
- columns = g_list_next (columns))
- {
- GList* column = (GList*) columns->data;
- for (;column != NULL; column = g_list_next (column))
- {
- ChildInfo *info = (ChildInfo*) column->data;
- if (widget == info->widget)
- {
- GList* orig = (GList*) columns->data;
- orig = g_list_delete_link (orig, column);
-
- gtk_widget_unparent (widget);
-
- columns->data = orig;
-
- columns = NULL;
- break;
- }
- }
- }
-}
-
-static void
-gcal_days_grid_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GcalDaysGridPrivate *priv;
-
- GList* columns;
-
- priv = gcal_days_grid_get_instance_private (GCAL_DAYS_GRID (container));
-
- columns = priv->children;
- while (columns)
- {
- GList *column;
-
- column = columns->data;
- columns = columns->next;
-
- while (column)
- {
- ChildInfo *info = (ChildInfo*) column->data;
- column = column->next;
-
- (* callback) (info->widget, callback_data);
- }
- }
-}
-
-/* Public API */
-/**
- * gcal_days_grid_new:
- *
- * Since: 0.1
- * Return value: A new #GcalDaysGrid
- * Returns: (transfer full):
- **/
-GtkWidget*
-gcal_days_grid_new (guint columns)
-{
- return g_object_new (GCAL_TYPE_DAYS_GRID, "columns", columns, NULL);
-}
-
-void
-gcal_days_grid_set_preferred_cell_height (GcalDaysGrid *days_grid,
- guint cell_height)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (days_grid);
-
- priv->req_cell_height = cell_height;
-}
-
-/**
- * gcal_days_grid_get_scale_width:
- * @days_grid: a #GcalDaysGrid widget
- *
- * Retrieve the size of the scale in the left size
- * of the widget. The value is calculated the first
- * time the function is called. After that, the value
- * is cached internally.
- *
- * Returns: the size of the scale
- **/
-guint
-gcal_days_grid_get_scale_width (GcalDaysGrid *days_grid)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (days_grid);
-
- if (priv->scale_width == 0)
- {
- GtkWidget *widget;
-
- GtkBorder padding;
- PangoLayout *layout;
- PangoFontDescription *font_desc;
-
- gint mid_width;
-
- widget = GTK_WIDGET (days_grid);
-
- gtk_style_context_get_padding (gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- layout = gtk_widget_create_pango_layout (widget, "00:00 0000");
- gtk_style_context_get (gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- "font", &font_desc,
- NULL);
- pango_layout_set_font_description (layout, font_desc);
-
- pango_layout_get_pixel_size (layout, &mid_width, NULL);
-
- priv->scale_width = mid_width + padding.left + padding.right;
-
- pango_font_description_free (font_desc);
- g_object_unref (layout);
- }
-
- return priv->scale_width;
-}
-
-/**
- * gcal_days_grid_place:
- * @days_grid: a #GcalDaysGrid widget
- * @widget: the child widget to add
- * @column_idx: the index of the column, starting with zero
- * @start_cell: the start-cell, refering the hour, starting with zero
- * @end_cell: the end-cell, refering the hour, starting with zero
- *
- * Adding a widget to a specified column. If the column index
- * is bigger than the #GcalDaysGrid:columns property set,
- * it will do nothing.
- **/
-void
-gcal_days_grid_place (GcalDaysGrid *days_grid,
- GtkWidget *widget,
- guint column_idx,
- guint start_cell,
- guint end_cell)
-{
- GcalDaysGridPrivate *priv;
- GList* children_link;
- GList* column;
- ChildInfo *info;
-
- priv = gcal_days_grid_get_instance_private (days_grid);
-
- g_return_if_fail (column_idx < priv->columns_nr);
-
- children_link = g_list_nth (priv->children, column_idx);
- column = (GList*) children_link->data;
-
- info = g_new0 (ChildInfo, 1);
- info->widget = widget;
- info->hidden = FALSE;
- info->start_cell = start_cell;
- info->end_cell = end_cell == 0 ? start_cell + 1 : end_cell;
- info->sub_column = 0;
- children_link->data = g_list_insert_sorted (column, info, compare_child_info);
-
- gtk_widget_set_parent (widget, GTK_WIDGET (days_grid));
-}
-
-GtkWidget*
-gcal_days_grid_get_by_uuid (GcalDaysGrid *days_grid,
- const gchar *uuid)
-{
- GcalDaysGridPrivate *priv;
-
- GList* columns;
-
- priv = gcal_days_grid_get_instance_private (days_grid);
-
- columns = priv->children;
- while (columns)
- {
- GList *column;
-
- column = columns->data;
- columns = columns->next;
-
- while (column)
- {
- GcalEventWidget *event;
-
- ChildInfo *info = (ChildInfo*) column->data;
- column = column->next;
-
- event = GCAL_EVENT_WIDGET (info->widget);
-
- if (g_strcmp0 (uuid,
- gcal_event_widget_peek_uuid (event)) == 0)
- {
- return info->widget;
- }
- }
- }
-
- return NULL;
-}
-
-void
-gcal_days_grid_clear_marks (GcalDaysGrid *days_grid)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (days_grid);
-
- priv->start_mark_cell = -1;
- priv->end_mark_cell = -1;
- gtk_widget_queue_draw (GTK_WIDGET (days_grid));
-}
-
-void
-gcal_days_grid_mark_cell (GcalDaysGrid *days_grid,
- guint cell)
-{
- GcalDaysGridPrivate *priv;
-
- priv = gcal_days_grid_get_instance_private (days_grid);
-
- priv->start_mark_cell = cell;
- priv->end_mark_cell = cell;
- gtk_widget_queue_draw (GTK_WIDGET (days_grid));
-}
-
-void
-gcal_days_grid_get_cell_position (GcalDaysGrid *days_grid,
- guint cell,
- gint *x,
- gint *y)
-{
- GcalDaysGridPrivate *priv;
-
- GtkWidget *widget;
- GtkBorder padding;
- gint width;
- gint height;
-
- priv = gcal_days_grid_get_instance_private (days_grid);
- widget = GTK_WIDGET (days_grid);
-
- gtk_style_context_get_padding (
- gtk_widget_get_style_context (widget),
- gtk_widget_get_state_flags (widget),
- &padding);
-
- width = gtk_widget_get_allocated_width (widget) - priv->scale_width;
- height = gtk_widget_get_allocated_height (widget) - (padding.top + padding.bottom);
-
- *x = (gint) priv->scale_width + (width / priv->columns_nr) * (cell / 48 + 0.5);
- *y = (gint) (height / 48) * ((cell % 48) + 0.5);
-}
diff --git a/src/gcal-days-grid.h b/src/gcal-days-grid.h
deleted file mode 100644
index bd3b256e..00000000
--- a/src/gcal-days-grid.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * gcal-days-grid.h
- *
- * Copyright (C) 2012 - Erick Pérez Castellanos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef __GCAL_DAYS_GRID_H__
-#define __GCAL_DAYS_GRID_H__
-
-#include
-
-G_BEGIN_DECLS
-
-#define GCAL_TYPE_DAYS_GRID (gcal_days_grid_get_type ())
-#define GCAL_DAYS_GRID(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_DAYS_GRID, GcalDaysGrid))
-#define GCAL_DAYS_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_DAYS_GRID, GcalDaysGridClass))
-#define GCAL_IS_DAYS_GRID(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_DAYS_GRID))
-#define GCAL_IS_DAYS_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_DAYS_GRID))
-#define GCAL_DAYS_GRID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_DAYS_GRID, GcalDaysGridClass))
-
-typedef struct _GcalDaysGrid GcalDaysGrid;
-typedef struct _GcalDaysGridClass GcalDaysGridClass;
-
-struct _GcalDaysGrid
-{
- GtkContainer parent;
-};
-
-struct _GcalDaysGridClass
-{
- GtkContainerClass parent_class;
-
- /* signals */
- void (*marked) (guint start_cell, guint end_cell);
-};
-
-GType gcal_days_grid_get_type (void);
-
-GtkWidget* gcal_days_grid_new (guint columns);
-
-void gcal_days_grid_set_preferred_cell_height (GcalDaysGrid *days_grid,
- guint cell_height);
-
-guint gcal_days_grid_get_scale_width (GcalDaysGrid *days_grid);
-
-void gcal_days_grid_place (GcalDaysGrid *days_grid,
- GtkWidget *widget,
- guint column_idx,
- guint start_cell,
- guint end_cell);
-
-/* GcalView API helpers */
-GtkWidget* gcal_days_grid_get_by_uuid (GcalDaysGrid *days_grid,
- const gchar *uuid);
-
-void gcal_days_grid_clear_marks (GcalDaysGrid *days_grid);
-
-void gcal_days_grid_mark_cell (GcalDaysGrid *days_grid,
- guint cell);
-
-void gcal_days_grid_get_cell_position (GcalDaysGrid *days_grid,
- guint cell,
- gint *x,
- gint *y);
-
-G_END_DECLS
-
-#endif /* __GCAL_DAYS_GRID_H__ */
diff --git a/src/gcal-floating-container.c b/src/gcal-floating-container.c
deleted file mode 100644
index 11904fa8..00000000
--- a/src/gcal-floating-container.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/* -*- mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * gcal-floating-container.c
- * Copyright (C) 2012 Erick Pérez Castellanos
- *
- * gnome-calendar is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * gnome-calendar is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see .
- */
-
-#include "gcal-floating-container.h"
-
-struct _GcalFloatingContainerPrivate
-{
- guint border;
-};
-
-static void gcal_floating_container_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width);
-
-static void gcal_floating_container_get_preferred_height_for_width (GtkWidget *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-
-static void gcal_floating_container_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height);
-
-static void gcal_floating_container_get_preferred_width_for_height (GtkWidget *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width);
-
-static void gcal_floating_container_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-static gboolean gcal_floating_container_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static void gcal_floating_container_add (GtkContainer *container,
- GtkWidget *child);
-
-static void gcal_floating_container_get_padding_and_border (GtkWidget *widget,
- GtkBorder *border);
-
-G_DEFINE_TYPE(GcalFloatingContainer, gcal_floating_container, GTK_TYPE_BIN)
-
-static void
-gcal_floating_container_class_init (GcalFloatingContainerClass *klass)
-{
- GtkWidgetClass* widget_class;
- GtkContainerClass *container_class;
-
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
-
- widget_class->get_preferred_width =
- gcal_floating_container_get_preferred_width;
- widget_class->get_preferred_height_for_width =
- gcal_floating_container_get_preferred_height_for_width;
- widget_class->get_preferred_height =
- gcal_floating_container_get_preferred_height;
- widget_class->get_preferred_width_for_height =
- gcal_floating_container_get_preferred_width_for_height;
- widget_class->size_allocate = gcal_floating_container_size_allocate;
- widget_class->draw = gcal_floating_container_draw;
-
- container_class->add = gcal_floating_container_add;
-
- g_type_class_add_private ((gpointer)klass, sizeof (GcalFloatingContainerPrivate));
-}
-
-
-
-static void
-gcal_floating_container_init (GcalFloatingContainer *self)
-{
- gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
-
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- GCAL_TYPE_FLOATING_CONTAINER,
- GcalFloatingContainerPrivate);
-}
-
-static void
-gcal_floating_container_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
-{
- gint child_min, child_nat;
- GtkWidget *child;
- GtkBorder padding;
- gint minimum, natural;
-
- gcal_floating_container_get_padding_and_border (widget, &padding);
-
- minimum = 0;
- natural = 0;
-
- child = gtk_bin_get_child (GTK_BIN (widget));
- if (child && gtk_widget_get_visible (child))
- {
- gtk_widget_get_preferred_width (child,
- &child_min, &child_nat);
- minimum += child_min;
- natural += child_nat;
- }
-
- minimum += padding.left + padding.right;
- natural += padding.left + padding.right;
-
- if (minimum_width)
- *minimum_width = minimum;
-
- if (natural_width)
- *natural_width = natural;
-}
-
-static void
-gcal_floating_container_get_preferred_height_for_width (GtkWidget *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height)
-{
- gint child_min, child_nat, child_width;
- GtkWidget *child;
- GtkBorder padding;
- gint minimum;
- gint natural;
-
- gcal_floating_container_get_padding_and_border (widget, &padding);
-
- minimum = 0;
- natural = 0;
-
- child = gtk_bin_get_child (GTK_BIN (widget));
- if (child && gtk_widget_get_visible (child))
- {
- child_width = width - padding.left - padding.top;
-
- gtk_widget_get_preferred_height_for_width (child, child_width,
- &child_min, &child_nat);
- minimum = MAX (minimum, child_min);
- natural = MAX (natural, child_nat);
- }
-
- minimum += padding.top + padding.top;
- natural += padding.top + padding.top;
-
- if (minimum_height)
- *minimum_height = minimum;
-
- if (natural_height)
- *natural_height = natural;
-}
-
-static void
-gcal_floating_container_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height)
-{
- gint child_min, child_nat;
- GtkWidget *child;
- GtkBorder padding;
- gint minimum;
- gint natural;
-
- gcal_floating_container_get_padding_and_border (widget, &padding);
-
- minimum = 0;
- natural = 0;
-
- child = gtk_bin_get_child (GTK_BIN (widget));
- if (child && gtk_widget_get_visible (child))
- {
- gtk_widget_get_preferred_height (child,
- &child_min, &child_nat);
- minimum = child_min;
- natural = child_nat;
- }
-
- minimum += padding.top + padding.top;
- natural += padding.top + padding.top;
-
- if (minimum_height)
- *minimum_height = minimum;
-
- if (natural_height)
- *natural_height = natural;
-}
-
-static void
-gcal_floating_container_get_preferred_width_for_height (GtkWidget *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
-{
- gint child_min, child_nat, child_height;
- GtkWidget *child;
- GtkBorder padding;
- gint minimum;
- gint natural;
-
- gcal_floating_container_get_padding_and_border (widget, &padding);
-
- minimum = 0;
- natural = 0;
-
- child_height = height - padding.top - padding.bottom;
-
- child = gtk_bin_get_child (GTK_BIN (widget));
- if (child && gtk_widget_get_visible (child))
- {
- gtk_widget_get_preferred_width_for_height (child, child_height,
- &child_min, &child_nat);
- minimum += child_min;
- natural += child_nat;
- }
-
- minimum += padding.left + padding.right;
- natural += padding.left + padding.right;
-
- if (minimum_width)
- *minimum_width = minimum;
-
- if (natural_width)
- *natural_width = natural;
-}
-
-static void
-gcal_floating_container_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkAllocation child_allocation;
- GtkBorder padding;
- GtkWidget *child;
-
- gtk_widget_set_allocation (widget, allocation);
-
- gcal_floating_container_get_padding_and_border (widget, &padding);
-
- if (gtk_widget_get_realized (widget))
- {
- gdk_window_move_resize (gtk_widget_get_window (widget),
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
- }
-
- child_allocation.x = padding.left;
- child_allocation.y = padding.top;
- child_allocation.height =
- MAX (1,
- allocation->height - padding.top - padding.bottom);
-
- child_allocation.width =
- MAX (1,
- allocation->width - padding.left - padding.right);
-
- child = gtk_bin_get_child (GTK_BIN (widget));
- if (child && gtk_widget_get_visible (child))
- gtk_widget_size_allocate (child, &child_allocation);
-}
-
-static gboolean
-gcal_floating_container_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GtkStyleContext *context;
- guint border_width;
-
- context = gtk_widget_get_style_context (widget);
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- gtk_render_background (context, cr,
- border_width, border_width,
- gtk_widget_get_allocated_width (widget) - 2 * border_width,
- gtk_widget_get_allocated_height (widget) - 2 * border_width);
- gtk_render_frame (context, cr,
- border_width, border_width,
- gtk_widget_get_allocated_width (widget) - 2 * border_width,
- gtk_widget_get_allocated_height (widget) - 2 * border_width);
- if (GTK_WIDGET_CLASS (gcal_floating_container_parent_class)->draw != NULL)
- GTK_WIDGET_CLASS (gcal_floating_container_parent_class)->draw (widget, cr);
-
- return FALSE;
-}
-
-static void
-gcal_floating_container_add (GtkContainer *container,
- GtkWidget *child)
-{
- g_return_if_fail (gtk_bin_get_child (GTK_BIN (container)) == NULL);
-
- GTK_CONTAINER_CLASS (gcal_floating_container_parent_class)->add (container, child);
-}
-
-static void
-gcal_floating_container_get_padding_and_border (GtkWidget *widget,
- GtkBorder *border)
-{
- GtkStyleContext *context;
- GtkStateFlags state;
- GtkBorder tmp;
-
- guint border_width;
-
- context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
-
- gtk_style_context_get_padding (context, state, border);
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- gtk_style_context_get_border (context, state, &tmp);
- border->top += tmp.top + border_width;
- border->right += tmp.right + border_width;
- border->bottom += tmp.bottom + border_width;
- border->left += tmp.left + border_width;
-}
-
-GtkWidget*
-gcal_floating_container_new (void)
-{
- return g_object_new (GCAL_TYPE_FLOATING_CONTAINER, NULL);
-}
diff --git a/src/gcal-floating-container.h b/src/gcal-floating-container.h
deleted file mode 100644
index 1b0f89c7..00000000
--- a/src/gcal-floating-container.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * gcal-floating-container.h
- * Copyright (C) 2012 Erick Pérez Castellanos
- *
- * gnome-calendar is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * gnome-calendar is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see .
- */
-
-#ifndef __GCAL_FLOATING_CONTAINER_H__
-#define __GCAL_FLOATING_CONTAINER_H__
-
-#include
-
-G_BEGIN_DECLS
-
-
-#define GCAL_TYPE_FLOATING_CONTAINER (gcal_floating_container_get_type ())
-#define GCAL_FLOATING_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_FLOATING_CONTAINER, GcalFloatingContainer))
-#define GCAL_FLOATING_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_FLOATING_CONTAINER, GcalFloatingContainerClass))
-#define GCAL_IS_FLOATING_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_FLOATING_CONTAINER))
-#define GCAL_IS_FLOATING_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_FLOATING_CONTAINER))
-#define GCAL_FLOATING_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_FLOATING_CONTAINER, GcalFloatingContainerClass))
-
-typedef struct _GcalFloatingContainer GcalFloatingContainer;
-typedef struct _GcalFloatingContainerClass GcalFloatingContainerClass;
-typedef struct _GcalFloatingContainerPrivate GcalFloatingContainerPrivate;
-
-struct _GcalFloatingContainer
-{
- GtkBin parent;
- /* add your public declarations here */
-
- GcalFloatingContainerPrivate *priv;
-};
-
-struct _GcalFloatingContainerClass
-{
- GtkBinClass parent_class;
-};
-
-
-GType gcal_floating_container_get_type (void);
-GtkWidget* gcal_floating_container_new (void);
-
-
-G_END_DECLS
-
-#endif /* __GCAL_FLOATING_CONTAINER_H__ */
diff --git a/src/gcal-viewport.c b/src/gcal-viewport.c
deleted file mode 100644
index 219389f1..00000000
--- a/src/gcal-viewport.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/* -*- mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * gcal-viewport.c
- *
- * Copyright (C) 2012 - Erick Pérez Castellanos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "gcal-viewport.h"
-
-#include
-
-#include
-
-typedef struct
-{
- /* property */
- GtkWidget *viewport;
- GtkWidget *hscrollbar;
- GtkWidget *vscrollbar;
-} GcalViewportPrivate;
-
-static void gcal_viewport_constructed (GObject *object);
-
-static void gcal_viewport_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural);
-
-static void gcal_viewport_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural);
-
-static gboolean gcal_viewport_scroll_event (GtkWidget *widget,
- GdkEventScroll *event);
-
-static void gcal_viewport_child_allocated (GtkWidget *widget,
- GdkRectangle *allocation,
- gpointer user_data);
-
-G_DEFINE_TYPE_WITH_PRIVATE (GcalViewport,gcal_viewport, GTK_TYPE_OVERLAY);
-
-static void
-gcal_viewport_class_init (GcalViewportClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->constructed = gcal_viewport_constructed;
-
- widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->get_preferred_width = gcal_viewport_get_preferred_width;
- widget_class->get_preferred_height = gcal_viewport_get_preferred_height;
- widget_class->scroll_event = gcal_viewport_scroll_event;
-
- /* Setup the template GtkBuilder xml for this class */
- gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/viewport.ui");
-
- /* Bind internals widgets */
- gtk_widget_class_bind_template_child_private (widget_class, GcalViewport, hscrollbar);
- gtk_widget_class_bind_template_child_private (widget_class, GcalViewport, vscrollbar);
- gtk_widget_class_bind_template_child_private (widget_class, GcalViewport, viewport);
-}
-
-
-
-static void
-gcal_viewport_init (GcalViewport *self)
-{
- gtk_widget_init_template (GTK_WIDGET (self));
-}
-
-static void
-gcal_viewport_constructed (GObject *object)
-{
- GcalViewportPrivate *priv;
-
- GtkAdjustment *adj;
-
- priv = gcal_viewport_get_instance_private (GCAL_VIEWPORT (object));
-
- adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (priv->viewport));
- gtk_range_set_adjustment (GTK_RANGE (priv->hscrollbar), adj);
-
- adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (priv->viewport));
- gtk_range_set_adjustment (GTK_RANGE (priv->vscrollbar), adj);
-}
-
-static void
-gcal_viewport_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- if (minimum != NULL)
- *minimum = 12;
- if (natural != NULL)
- *natural = 12;
-}
-
-static void
-gcal_viewport_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- if (minimum != NULL)
- *minimum = 12;
- if (natural != NULL)
- *natural = 12;
-}
-
-static gboolean
-gcal_viewport_scroll_event (GtkWidget *widget,
- GdkEventScroll *event)
-{
- GcalViewportPrivate *priv;
-
- gdouble delta_y;
- gdouble delta;
-
- g_return_val_if_fail (event != NULL, FALSE);
-
- priv = gcal_viewport_get_instance_private (GCAL_VIEWPORT (widget));
-
- if (gdk_event_get_scroll_deltas ((GdkEvent *) event, NULL, &delta_y))
- {
- if (delta_y != 0.0 &&
- priv->vscrollbar != NULL &&
- gtk_widget_get_visible (priv->vscrollbar))
- {
- GtkAdjustment *adj;
- gdouble new_value;
- gdouble page_size;
- gdouble scroll_unit;
-
- adj = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));
- page_size = gtk_adjustment_get_page_size (adj);
- scroll_unit = pow (page_size, 2.0 / 3.0);
-
- new_value = CLAMP (gtk_adjustment_get_value (adj) + delta_y * scroll_unit,
- gtk_adjustment_get_lower (adj),
- gtk_adjustment_get_upper (adj) -
- gtk_adjustment_get_page_size (adj));
-
- gtk_adjustment_set_value (adj, new_value);
-
- return TRUE;
- }
- }
- else
- {
- GtkWidget *range = NULL;
-
- if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_DOWN)
- range = priv->vscrollbar;
-
- if (range != NULL && gtk_widget_get_visible (range))
- {
- GtkAdjustment *adj;
- gdouble new_value;
- gdouble page_size;
-
- adj = gtk_range_get_adjustment (GTK_RANGE (range));
- page_size = gtk_adjustment_get_page_size (adj);
- delta = pow (page_size, 2.0 / 3.0);
-
- new_value = CLAMP (gtk_adjustment_get_value (adj) + delta,
- gtk_adjustment_get_lower (adj),
- gtk_adjustment_get_upper (adj) -
- gtk_adjustment_get_page_size (adj));
-
- gtk_adjustment_set_value (adj, new_value);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static void
-gcal_viewport_child_allocated (GtkWidget *widget,
- GdkRectangle *allocation,
- gpointer user_data)
-{
- GcalViewportPrivate *priv;
- gint width, height;
-
- priv = gcal_viewport_get_instance_private (GCAL_VIEWPORT (user_data));
-
- width = gtk_widget_get_allocated_width (GTK_WIDGET (user_data));
- height = gtk_widget_get_allocated_height (GTK_WIDGET (user_data));
-
- if (width >= allocation->width)
- gtk_widget_hide (priv->hscrollbar);
- else
- gtk_widget_show (priv->hscrollbar);
-
- if (height >= allocation->height)
- gtk_widget_hide (priv->vscrollbar);
- else
- gtk_widget_show (priv->vscrollbar);
-}
-
-/* Public API */
-/**
- * gcal_viewport_new:
- *
- * Since: 0.1
- * Return value: A new #GcalViewport
- * Returns: (transfer full):
- **/
-GtkWidget*
-gcal_viewport_new ()
-{
- return g_object_new (GCAL_TYPE_VIEWPORT, NULL);
-}
-
-/**
- * gcal_viewport_add:
- * @viewport: a #GcalViewport
- * @widget: the widget to add
- *
- * Add @widget to internal viewport of #GcalViewport
- **/
-void
-gcal_viewport_add (GcalViewport *viewport,
- GtkWidget *widget)
-{
- GcalViewportPrivate *priv;
-
- priv = gcal_viewport_get_instance_private (viewport);
- gtk_container_add (GTK_CONTAINER (priv->viewport), widget);
-
- /* signals handlers */
- g_signal_connect_after (widget, "size-allocate",
- G_CALLBACK (gcal_viewport_child_allocated), viewport);
-}
-
-/**
- * gcal_viewport_scroll_to:
- * @viewport: a #GcalViewport
- * @value: a value between 0 and 1.0 for scrolling the child.
- *
- * If no scrollbar is shown, this method does nothing
- **/
-void
-gcal_viewport_scroll_to (GcalViewport *viewport,
- gdouble value)
-{
- GcalViewportPrivate *priv;
- GtkAdjustment *adj;
- gdouble lower, upper, page_size;
-
- priv = gcal_viewport_get_instance_private (viewport);
-
- value = CLAMP (value, 0.0, 1.0);
-
- adj = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));
- page_size = gtk_adjustment_get_page_size (adj);
- lower = gtk_adjustment_get_lower (adj);
- upper = gtk_adjustment_get_upper (adj);
-
- value = ((upper - page_size) - lower) * value;
- gtk_adjustment_set_value (adj, value);
-}
diff --git a/src/gcal-viewport.h b/src/gcal-viewport.h
deleted file mode 100644
index d8d3aaff..00000000
--- a/src/gcal-viewport.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * gcal-viewport.h
- *
- * Copyright (C) 2012 - Erick Pérez Castellanos
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef __GCAL_VIEWPORT_H__
-#define __GCAL_VIEWPORT_H__
-
-#include
-
-G_BEGIN_DECLS
-
-#define GCAL_TYPE_VIEWPORT (gcal_viewport_get_type ())
-#define GCAL_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_VIEWPORT, GcalViewport))
-#define GCAL_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_VIEWPORT, GcalViewportClass))
-#define GCAL_IS_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_VIEWPORT))
-#define GCAL_IS_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_VIEWPORT))
-#define GCAL_VIEWPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_VIEWPORT, GcalViewportClass))
-
-typedef struct _GcalViewport GcalViewport;
-typedef struct _GcalViewportClass GcalViewportClass;
-
-struct _GcalViewport
-{
- GtkOverlay parent;
-};
-
-struct _GcalViewportClass
-{
- GtkOverlayClass parent_class;
-};
-
-GType gcal_viewport_get_type (void);
-
-GtkWidget* gcal_viewport_new (void);
-
-void gcal_viewport_add (GcalViewport *viewport,
- GtkWidget *widget);
-
-void gcal_viewport_scroll_to (GcalViewport *viewport,
- gdouble value);
-
-G_END_DECLS
-
-#endif /* __GCAL_VIEWPORT_H__ */
diff --git a/src/gcal-window.c b/src/gcal-window.c
index fe0a3a0e..b6de465c 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -22,9 +22,7 @@
#include "gcal-nav-bar.h"
#include "gcal-manager.h"
-#include "gcal-floating-container.h"
#include "gcal-view.h"
-#include "gcal-day-view.h"
#include "gcal-month-view.h"
#include "gcal-week-view.h"
#include "gcal-year-view.h"
@@ -995,14 +993,6 @@ gcal_window_constructed (GObject *object)
gtk_widget_get_style_context (priv->views_stack),
"views");
- priv->views[GCAL_WINDOW_VIEW_DAY] = gcal_day_view_new ();
- gtk_stack_add_titled (GTK_STACK (priv->views_stack),
- priv->views[GCAL_WINDOW_VIEW_DAY],
- "day", _("Day"));
- g_object_bind_property (GCAL_WINDOW (object), "active-date",
- priv->views[GCAL_WINDOW_VIEW_DAY], "active-date",
- G_BINDING_DEFAULT);
-
priv->views[GCAL_WINDOW_VIEW_WEEK] = gcal_week_view_new ();
gtk_stack_add_titled (GTK_STACK (priv->views_stack),
priv->views[GCAL_WINDOW_VIEW_WEEK],