From 65c8f83e811c00010c724759ebd7b8f9b512932c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Mon, 10 Sep 2012 10:29:41 -0400 Subject: [PATCH] Renamed GcalArrowContainer to GcalArrowBin. --- data/theme/gtk-styles.css | 2 +- src/Makefile.am | 4 +- src/gcal-arrow-bin.c | 806 +++++++++++++++++++++++++++++++++++++ src/gcal-arrow-bin.h | 68 ++++ src/gcal-arrow-container.c | 744 ---------------------------------- src/gcal-arrow-container.h | 59 --- src/gcal-event-overlay.c | 4 +- 7 files changed, 879 insertions(+), 808 deletions(-) create mode 100644 src/gcal-arrow-bin.c create mode 100644 src/gcal-arrow-bin.h delete mode 100644 src/gcal-arrow-container.c delete mode 100644 src/gcal-arrow-container.h diff --git a/data/theme/gtk-styles.css b/data/theme/gtk-styles.css index a273303a..847c07af 100644 --- a/data/theme/gtk-styles.css +++ b/data/theme/gtk-styles.css @@ -112,6 +112,6 @@ GtkOverlay > GtkButton { border: darker(@borders) 1px solid; color: @theme_fg_color; background-color: @theme_bg_color; - -GcalArrowContainer-arrow-size: 12px; + -GcalArrowBin-arrow-size: 12px; -GcalArrowContainer-shadow-span: 3px; } diff --git a/src/Makefile.am b/src/Makefile.am index 21ac81f3..691f0f38 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,8 +23,8 @@ gnome_calendar_SOURCES = \ main.c \ gcal-application.h \ gcal-application.c \ - gcal-arrow-container.c \ - gcal-arrow-container.h \ + gcal-arrow-bin.c \ + gcal-arrow-bin.h \ gcal-floating-container.c \ gcal-floating-container.h \ gcal-toolbar.h \ diff --git a/src/gcal-arrow-bin.c b/src/gcal-arrow-bin.c new file mode 100644 index 00000000..882adc5f --- /dev/null +++ b/src/gcal-arrow-bin.c @@ -0,0 +1,806 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ +/* + * gcal-arrow-bin.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-arrow-bin.h" + +struct _GPoint +{ + gdouble x; + gdouble y; +}; + +typedef struct _GPoint GPoint; + +struct _GcalArrowBinPrivate +{ + GtkPositionType arrow_position; + gdouble arrow_align; +}; + +enum +{ + PROP_0, + PROP_ARROW_POSITION, + PROP_ARROW_ALIGN +}; + +static void gcal_arrow_bin_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); + +static void gcal_arrow_bin_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static void gcal_arrow_bin_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width); + +static void gcal_arrow_bin_get_preferred_height_for_width (GtkWidget *widget, + gint width, + gint *minimum_height, + gint *natural_height); + +static void gcal_arrow_bin_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height); + +static void gcal_arrow_bin_get_preferred_width_for_height (GtkWidget *widget, + gint height, + gint *minimum_width, + gint *natural_width); + +static void gcal_arrow_bin_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); + +static gboolean gcal_arrow_bin_draw (GtkWidget *widget, + cairo_t *cr); + +static void gcal_arrow_bin_draw_arrow (GtkWidget *widget, + cairo_t *cr); + +static void gcal_arrow_bin_get_padding_and_border (GtkWidget *widget, + GtkBorder *border, + guint *border_width, + guint *arrow_size); + +G_DEFINE_TYPE(GcalArrowBin, gcal_arrow_bin, GTK_TYPE_BIN) + +static void +gcal_arrow_bin_class_init (GcalArrowBinClass *klass) +{ + GObjectClass *object_class; + GtkWidgetClass* widget_class; + + object_class = G_OBJECT_CLASS (klass); + widget_class = GTK_WIDGET_CLASS (klass); + + object_class->set_property = gcal_arrow_bin_set_property; + object_class->get_property = gcal_arrow_bin_get_property; + + widget_class->get_preferred_width = + gcal_arrow_bin_get_preferred_width; + widget_class->get_preferred_height_for_width = + gcal_arrow_bin_get_preferred_height_for_width; + widget_class->get_preferred_height = + gcal_arrow_bin_get_preferred_height; + widget_class->get_preferred_width_for_height = + gcal_arrow_bin_get_preferred_width_for_height; + widget_class->size_allocate = gcal_arrow_bin_size_allocate; + widget_class->draw = gcal_arrow_bin_draw; + + /* Properties */ + g_object_class_install_property ( + object_class, + PROP_ARROW_POSITION, + g_param_spec_enum ("arrow-position", + "Arrow position", + "The position of the arrow in the container", + GTK_TYPE_POSITION_TYPE, + GTK_POS_BOTTOM, + G_PARAM_CONSTRUCT | + G_PARAM_READWRITE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + g_object_class_install_property ( + object_class, + PROP_ARROW_ALIGN, + g_param_spec_double ("arrow-align", + "Arrow alignment", + "The alignment of the arrow in its side", + 0.0, + 1.0, + 0.5, + G_PARAM_CONSTRUCT | + G_PARAM_READWRITE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + /* Style properties */ + gtk_widget_class_install_style_property ( + widget_class, + g_param_spec_uint ("arrow-size", + "Arrow width and height", + "The width and height of the arrow", + 0, + G_MAXUINT32, + 0, + G_PARAM_READABLE)); + + g_type_class_add_private ((gpointer)klass, sizeof(GcalArrowBinPrivate)); +} + +static void +gcal_arrow_bin_init (GcalArrowBin *self) +{ + gtk_widget_set_has_window (GTK_WIDGET (self), FALSE); + + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + GCAL_TYPE_ARROW_BIN, + GcalArrowBinPrivate); +} + +static void +gcal_arrow_bin_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GcalArrowBinPrivate *priv; + + priv = GCAL_ARROW_BIN (object)->priv; + + switch (property_id) + { + case PROP_ARROW_POSITION: + priv->arrow_position = g_value_get_enum (value); + break; + case PROP_ARROW_ALIGN: + priv->arrow_align = g_value_get_double (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + return; + } +} + +static void +gcal_arrow_bin_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GcalArrowBinPrivate *priv; + + priv = GCAL_ARROW_BIN (object)->priv; + + switch (property_id) + { + case PROP_ARROW_POSITION: + g_value_set_enum (value, priv->arrow_position); + break; + case PROP_ARROW_ALIGN: + g_value_set_double (value, priv->arrow_align); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + return; + } +} + +static void +gcal_arrow_bin_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GcalArrowBinPrivate *priv; + gint child_min, child_nat; + GtkWidget *child; + GtkBorder padding; + gint minimum, natural; + guint arrow_size; + + priv = GCAL_ARROW_BIN (widget)->priv; + + gcal_arrow_bin_get_padding_and_border (widget, + &padding, + NULL, + &arrow_size); + + 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 (priv->arrow_position == GTK_POS_LEFT || + priv->arrow_position == GTK_POS_RIGHT) + { + minimum += arrow_size; + natural += arrow_size; + } + + if (minimum_width) + *minimum_width = minimum; + + if (natural_width) + *natural_width = natural; +} + +static void +gcal_arrow_bin_get_preferred_height_for_width (GtkWidget *widget, + gint width, + gint *minimum_height, + gint *natural_height) +{ + GcalArrowBinPrivate *priv; + gint child_min, child_nat, child_width; + GtkWidget *child; + GtkBorder padding; + guint arrow_size; + gint minimum; + gint natural; + + priv = GCAL_ARROW_BIN (widget)->priv; + + gcal_arrow_bin_get_padding_and_border (widget, + &padding, + NULL, + &arrow_size); + + 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.bottom; + natural += padding.top + padding.bottom; + + if (priv->arrow_position == GTK_POS_TOP || + priv->arrow_position == GTK_POS_BOTTOM) + { + minimum += arrow_size; + natural += arrow_size; + } + + if (minimum_height) + *minimum_height = minimum; + + if (natural_height) + *natural_height = natural; +} + +static void +gcal_arrow_bin_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GcalArrowBinPrivate *priv; + gint child_min, child_nat; + GtkWidget *child; + GtkBorder padding; + guint arrow_size; + gint minimum; + gint natural; + + priv = GCAL_ARROW_BIN (widget)->priv; + + gcal_arrow_bin_get_padding_and_border (widget, + &padding, + NULL, + &arrow_size); + + 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.bottom; + natural += padding.top + padding.bottom; + + if (priv->arrow_position == GTK_POS_TOP || + priv->arrow_position == GTK_POS_BOTTOM) + { + minimum += arrow_size; + natural += arrow_size; + } + + if (minimum_height) + *minimum_height = minimum; + + if (natural_height) + *natural_height = natural; +} + +static void +gcal_arrow_bin_get_preferred_width_for_height (GtkWidget *widget, + gint height, + gint *minimum_width, + gint *natural_width) +{ + GcalArrowBinPrivate *priv; + + gint child_min, child_nat, child_height; + GtkWidget *child; + GtkBorder padding; + guint arrow_size; + gint minimum; + gint natural; + + priv = GCAL_ARROW_BIN (widget)->priv; + + gcal_arrow_bin_get_padding_and_border (widget, + &padding, + NULL, + &arrow_size); + + 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 (priv->arrow_position == GTK_POS_LEFT || + priv->arrow_position == GTK_POS_RIGHT) + { + minimum += arrow_size; + natural += arrow_size; + } + + if (minimum_width) + *minimum_width = minimum; + + if (natural_width) + *natural_width = natural; +} + +static void +gcal_arrow_bin_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GcalArrowBinPrivate *priv; + GtkAllocation child_allocation; + GtkBorder padding; + GtkWidget *child; + guint arrow_size; + + priv = GCAL_ARROW_BIN (widget)->priv; + + gtk_widget_set_allocation (widget, allocation); + + gcal_arrow_bin_get_padding_and_border (widget, + &padding, + NULL, + &arrow_size); + + 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 + (priv->arrow_position == GTK_POS_LEFT ? arrow_size : 0); + child_allocation.y = padding.top + (priv->arrow_position == GTK_POS_TOP ? arrow_size : 0); + + child_allocation.height = + MAX (1, + allocation->height - padding.top - padding.bottom); + + child_allocation.width = + MAX (1, + allocation->width - padding.left - padding.right); + + if (priv->arrow_position == GTK_POS_LEFT || + priv->arrow_position == GTK_POS_RIGHT) + { + child_allocation.width -= arrow_size; + } + else + { + child_allocation.height -= arrow_size; + } + + 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_arrow_bin_draw (GtkWidget *widget, + cairo_t *cr) +{ + GcalArrowBinPrivate *priv; + + GtkBorder border; + guint border_width; + gdouble selected_border; + gint selected_border_radius; + guint width; + guint height; + guint arrow_size; + gdouble arrow_start_point; + gdouble x, y; + + priv = GCAL_ARROW_BIN (widget)->priv; + + gtk_style_context_get_border ( + gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget), + &border); + + gtk_style_context_get ( + gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget), + "border-radius", &selected_border_radius, + NULL); + + gcal_arrow_bin_get_padding_and_border (widget, + NULL, + &border_width, + &arrow_size); + + width = gtk_widget_get_allocated_width (widget) - 2 * border_width; + height = gtk_widget_get_allocated_height (widget) - 2 * border_width; + + x = y = border_width; + if (priv->arrow_position == GTK_POS_LEFT) + x += arrow_size; + if (priv->arrow_position == GTK_POS_TOP) + y += arrow_size; + + switch (priv->arrow_position) + { + case GTK_POS_TOP: + selected_border = border.top; + break; + case GTK_POS_BOTTOM: + selected_border = border.bottom; + break; + case GTK_POS_LEFT: + selected_border = border.left; + break; + case GTK_POS_RIGHT: + selected_border = border.right; + break; + } + + if (priv->arrow_position == GTK_POS_LEFT || + priv->arrow_position == GTK_POS_RIGHT) + { + width -= arrow_size; + arrow_start_point = arrow_size + selected_border / 2 + selected_border_radius + + (height - 2 * (arrow_size + selected_border / 2 + selected_border_radius)) * priv->arrow_align; + } + else + { + height -= arrow_size; + arrow_start_point = arrow_size + selected_border / 2 + selected_border_radius + + (width - 2 * (arrow_size + selected_border / 2 + selected_border_radius)) * priv->arrow_align; + } + + gtk_render_background (gtk_widget_get_style_context (widget), + cr, + x, y, + width, height); + gtk_render_frame_gap (gtk_widget_get_style_context (widget), + cr, + x, y, + width, height, + priv->arrow_position, + arrow_start_point - arrow_size, + arrow_start_point + arrow_size); + + gcal_arrow_bin_draw_arrow (widget, cr); + + GTK_WIDGET_CLASS (gcal_arrow_bin_parent_class)->draw (widget, cr); + + return FALSE; +} + +static void +gcal_arrow_bin_draw_arrow (GtkWidget *widget, + cairo_t *cr) +{ + GcalArrowBinPrivate *priv; + + GdkRGBA color; + GtkBorder border; + guint arrow_size; + guint border_width; + gdouble selected_border; + gint selected_border_radius; + guint width; + guint height; + gdouble arrow_start_point; + + GPoint p0; + GPoint p1; + GPoint p2; + GPoint p3; + GPoint p4; + + priv = GCAL_ARROW_BIN (widget)->priv; + + gtk_style_context_get_border ( + gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget), + &border); + + gtk_style_context_get ( + gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget), + "border-radius", &selected_border_radius, + NULL); + + gcal_arrow_bin_get_padding_and_border (widget, + NULL, + &border_width, + &arrow_size); + + width = gtk_widget_get_allocated_width (widget) - 2 * border_width; + height = gtk_widget_get_allocated_height (widget) - 2 * border_width; + + switch (priv->arrow_position) + { + case GTK_POS_TOP: + selected_border = border.top; + break; + case GTK_POS_BOTTOM: + selected_border = border.bottom; + break; + case GTK_POS_LEFT: + selected_border = border.left; + break; + case GTK_POS_RIGHT: + selected_border = border.right; + break; + } + + if (priv->arrow_position == GTK_POS_LEFT || + priv->arrow_position == GTK_POS_RIGHT) + { + width -= arrow_size; + arrow_start_point = arrow_size + selected_border / 2 + selected_border_radius + + (height - 2 * (arrow_size + selected_border / 2 + selected_border_radius)) * priv->arrow_align; + } + else + { + height -= arrow_size; + arrow_start_point = arrow_size + selected_border / 2 + selected_border_radius + + (width - 2 * (arrow_size + selected_border / 2 + selected_border_radius)) * priv->arrow_align; + } + + switch (priv->arrow_position) + { + case GTK_POS_TOP: + p0.x = border_width + arrow_start_point - arrow_size; + p0.y = border_width + border.top + arrow_size; + p1.x = p0.x; + p1.y = p0.y - border.top; + p2.x = p1.x + arrow_size; + p2.y = p1.y - arrow_size; + p3.x = p2.x + arrow_size; + p3.y = p1.y; + p4.x = p3.x; + p4.y = p0.y; + break; + case GTK_POS_BOTTOM: + p0.x = border_width + arrow_start_point - arrow_size; + p0.y = border_width + height - border.bottom; + p1.x = p0.x; + p1.y = p0.y + border.bottom; + p2.x = p1.x + arrow_size; + p2.y = p1.y + arrow_size; + p3.x = p2.x + arrow_size; + p3.y = p1.y; + p4.x = p3.x; + p4.y = p0.y; + break; + case GTK_POS_LEFT: + p0.x = border_width + arrow_size + border.left; + p0.y = border_width + arrow_start_point - arrow_size; + p1.x = p0.x - border.left; + p1.y = p0.y; + p2.x = p1.x - arrow_size; + p2.y = p1.y + arrow_size; + p3.x = p1.x; + p3.y = p2.y + arrow_size; + p4.x = p0.x; + p4.y = p3.y; + break; + case GTK_POS_RIGHT: + p0.x = border_width + width - border.left; + p0.y = border_width + arrow_start_point - arrow_size; + p1.x = p0.x + border.left; + p1.y = p0.y; + p2.x = p1.x + arrow_size; + p2.y = p1.y + arrow_size; + p3.x = p1.x; + p3.y = p2.y + arrow_size; + p4.x = p0.x; + p4.y = p3.y; + break; + } + + cairo_save (cr); + cairo_set_line_width (cr, border.bottom); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); + + cairo_move_to (cr, p0.x, p0.y); + cairo_line_to (cr, p1.x, p1.y); + cairo_line_to (cr, p2.x, p2.y); + cairo_line_to (cr, p3.x, p3.y); + cairo_line_to (cr, p4.x, p4.y); + + gtk_style_context_get_background_color ( + gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget), + &color); + cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha); + cairo_fill (cr); + + cairo_move_to (cr, p1.x, p1.y); + cairo_line_to (cr, p2.x, p2.y); + cairo_line_to (cr, p3.x, p3.y); + + gtk_style_context_get_border_color ( + gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget), + &color); + cairo_set_source_rgb (cr, color.red, color.green, color.blue); + cairo_stroke (cr); + cairo_restore (cr); +} + +static void +gcal_arrow_bin_get_padding_and_border (GtkWidget *widget, + GtkBorder *border, + guint *border_width, + guint *arrow_size) +{ + GtkBorder tmp; + guint bd_width; + + bd_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + if (border != NULL) + { + gtk_style_context_get_padding ( + gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget), + border); + + gtk_style_context_get_border ( + gtk_widget_get_style_context (widget), + gtk_widget_get_state_flags (widget), + &tmp); + + border->top += tmp.top + bd_width; + border->right += tmp.right + bd_width; + border->bottom += tmp.bottom + bd_width; + border->left += tmp.left + bd_width; + } + + if (arrow_size != NULL) + { + gtk_style_context_get_style ( + gtk_widget_get_style_context (widget), + "arrow-size", arrow_size, + NULL); + } + + if (border_width != NULL) + *border_width = bd_width; +} + +GtkWidget* +gcal_arrow_bin_new (void) +{ + return g_object_new (GCAL_TYPE_ARROW_BIN, NULL); +} + +void +gcal_arrow_bin_set_arrow_pos (GcalArrowBin *arrow, + GtkPositionType arrow_pos) +{ + g_return_if_fail (GCAL_IS_ARROW_BIN (arrow)); + + g_object_set (arrow, "arrow-position", arrow_pos, NULL); +} + +GtkPositionType +gcal_arrow_bin_get_arrow_pos (GcalArrowBin *arrow) +{ + GtkPositionType pos; + + g_return_val_if_fail (GCAL_IS_ARROW_BIN (arrow), GTK_POS_BOTTOM); + + g_object_get (arrow, "arrow-position", &pos, NULL); + return pos; +} + +void +gcal_arrow_bin_set_arrow_align (GcalArrowBin *arrow, + gdouble align) +{ + g_return_if_fail (GCAL_IS_ARROW_BIN (arrow)); + + g_object_set (arrow, "arrow-align", align, NULL); +} + +gdouble +gcal_arrow_bin_get_arrow_align (GcalArrowBin *arrow) +{ + gdouble align; + + g_return_val_if_fail (GCAL_IS_ARROW_BIN (arrow), 0.5); + + g_object_get (arrow, "arrow-align", &align, NULL); + return align; +} diff --git a/src/gcal-arrow-bin.h b/src/gcal-arrow-bin.h new file mode 100644 index 00000000..7915d30c --- /dev/null +++ b/src/gcal-arrow-bin.h @@ -0,0 +1,68 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ +/* + * gcal-arrow-bin.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_ARROW_BIN_H__ +#define __GCAL_ARROW_BIN_H__ + +#include + +G_BEGIN_DECLS + + +#define GCAL_TYPE_ARROW_BIN (gcal_arrow_bin_get_type ()) +#define GCAL_ARROW_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_ARROW_BIN, GcalArrowBin)) +#define GCAL_ARROW_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_ARROW_BIN, GcalArrowBinClass)) +#define GCAL_IS_ARROW_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_ARROW_BIN)) +#define GCAL_IS_ARROW_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_ARROW_BIN)) +#define GCAL_ARROW_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_ARROW_BIN, GcalArrowBinClass)) + +typedef struct _GcalArrowBin GcalArrowBin; +typedef struct _GcalArrowBinClass GcalArrowBinClass; +typedef struct _GcalArrowBinPrivate GcalArrowBinPrivate; + +struct _GcalArrowBin +{ + GtkBin parent; + /* add your public declarations here */ + + GcalArrowBinPrivate *priv; +}; + +struct _GcalArrowBinClass +{ + GtkBinClass parent_class; +}; + +GType gcal_arrow_bin_get_type (void); + +GtkWidget* gcal_arrow_bin_new (void); + +void gcal_arrow_bin_set_arrow_pos (GcalArrowBin *arrow, + GtkPositionType arrow_pos); + +GtkPositionType gcal_arrow_bin_get_arrow_pos (GcalArrowBin *arrow); + +void gcal_arrow_bin_set_arrow_align (GcalArrowBin *arrow, + gdouble align); + +gdouble gcal_arrow_bin_get_arrow_align (GcalArrowBin *arrow); + +G_END_DECLS + +#endif /* __GCAL_ARROW_BIN_H__ */ diff --git a/src/gcal-arrow-container.c b/src/gcal-arrow-container.c deleted file mode 100644 index 47496836..00000000 --- a/src/gcal-arrow-container.c +++ /dev/null @@ -1,744 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ -/* - * gcal-arrow-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-arrow-container.h" -#include - -struct _GcalArrowContainerPrivate -{ - guint arrow_size; -}; - -static void gcal_arrow_container_get_preferred_width (GtkWidget *widget, - gint *minimum_width, - gint *natural_width); - -static void gcal_arrow_container_get_preferred_height_for_width (GtkWidget *widget, - gint width, - gint *minimum_height, - gint *natural_height); - -static void gcal_arrow_container_get_preferred_height (GtkWidget *widget, - gint *minimum_height, - gint *natural_height); - -static void gcal_arrow_container_get_preferred_width_for_height (GtkWidget *widget, - gint height, - gint *minimum_width, - gint *natural_width); - -static void gcal_arrow_container_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); - -static gboolean gcal_arrow_container_draw (GtkWidget *widget, - cairo_t *cr); - -static void gcal_arrow_container_draw_arrow (GtkWidget *widget, - cairo_t *cr); - -static void gcal_arrow_container_draw_shadow (GtkWidget *widget, - cairo_t *cr); - -static void gcal_arrow_container_get_padding_and_border (GtkWidget *widget, - GtkBorder *border, - guint *border_width, - guint *arrow_size, - guint *shadow); - -G_DEFINE_TYPE(GcalArrowContainer, gcal_arrow_container, GTK_TYPE_BIN) - -static void -gcal_arrow_container_class_init (GcalArrowContainerClass *klass) -{ - GtkWidgetClass* widget_class; - - widget_class = GTK_WIDGET_CLASS (klass); - - widget_class->get_preferred_width = - gcal_arrow_container_get_preferred_width; - widget_class->get_preferred_height_for_width = - gcal_arrow_container_get_preferred_height_for_width; - widget_class->get_preferred_height = - gcal_arrow_container_get_preferred_height; - widget_class->get_preferred_width_for_height = - gcal_arrow_container_get_preferred_width_for_height; - widget_class->size_allocate = gcal_arrow_container_size_allocate; - widget_class->draw = gcal_arrow_container_draw; - - /* Style properties */ - gtk_widget_class_install_style_property ( - widget_class, - g_param_spec_uint ("arrow-size", - "Arrow width and height", - "The width and height of the arrow", - 0, - G_MAXUINT32, - 0, - G_PARAM_READABLE)); - - gtk_widget_class_install_style_property ( - widget_class, - g_param_spec_uint ("shadow-span", - "Shadow span", - "Shadow span", - 0, - G_MAXUINT32, - 0, - G_PARAM_READABLE)); - - g_type_class_add_private ((gpointer)klass, sizeof(GcalArrowContainerPrivate)); -} - -static void -gcal_arrow_container_init (GcalArrowContainer *self) -{ - gtk_widget_set_has_window (GTK_WIDGET (self), FALSE); - - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - GCAL_TYPE_ARROW_CONTAINER, - GcalArrowContainerPrivate); -} - -static void -gcal_arrow_container_get_preferred_width (GtkWidget *widget, - gint *minimum_width, - gint *natural_width) -{ - gint child_min, child_nat; - GtkWidget *child; - GtkBorder padding; - gint minimum, natural; - guint shadow; - - gcal_arrow_container_get_padding_and_border (widget, - &padding, - NULL, - NULL, - &shadow); - - 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 + 2 * shadow; - natural += padding.left + padding.right + 2 * shadow; - - if (minimum_width) - *minimum_width = minimum; - - if (natural_width) - *natural_width = natural; -} - -static void -gcal_arrow_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; - guint shadow; - guint arrow_size; - gint minimum; - gint natural; - - gcal_arrow_container_get_padding_and_border (widget, - &padding, - NULL, - &arrow_size, - &shadow); - - 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 - 2 * shadow; - - 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.bottom + arrow_size + 2 * shadow; - natural += padding.top + padding.bottom + arrow_size + 2 * shadow; - - if (minimum_height) - *minimum_height = minimum; - - if (natural_height) - *natural_height = natural; -} - -static void -gcal_arrow_container_get_preferred_height (GtkWidget *widget, - gint *minimum_height, - gint *natural_height) -{ - gint child_min, child_nat; - GtkWidget *child; - GtkBorder padding; - guint shadow; - guint arrow_size; - gint minimum; - gint natural; - - gcal_arrow_container_get_padding_and_border (widget, - &padding, - NULL, - &arrow_size, - &shadow); - - 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.bottom + arrow_size + 2 * shadow; - natural += padding.top + padding.bottom + arrow_size + 2 * shadow; - - if (minimum_height) - *minimum_height = minimum; - - if (natural_height) - *natural_height = natural; -} - -static void -gcal_arrow_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; - guint shadow; - gint minimum; - gint natural; - - gcal_arrow_container_get_padding_and_border (widget, - &padding, - NULL, - NULL, - &shadow); - - minimum = 0; - natural = 0; - - child_height = height - padding.top - padding.bottom - 2 * shadow; - - 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 + 2 * shadow; - natural += padding.left + padding.right + 2 * shadow; - - if (minimum_width) - *minimum_width = minimum; - - if (natural_width) - *natural_width = natural; -} - -static void -gcal_arrow_container_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkAllocation child_allocation; - GtkBorder padding; - GtkWidget *child; - guint arrow_size; - guint shadow; - - gtk_widget_set_allocation (widget, allocation); - - gcal_arrow_container_get_padding_and_border (widget, - &padding, - NULL, - &arrow_size, - &shadow); - - 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 + shadow; - child_allocation.y = padding.top + shadow; - child_allocation.height = - MAX (1, - allocation->height - padding.top - padding.bottom - 2 * shadow - arrow_size); - - child_allocation.width = - MAX (1, - allocation->width - padding.left - padding.right - 2 * shadow); - - 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_arrow_container_draw (GtkWidget *widget, - cairo_t *cr) -{ - GtkBorder border; - guint border_width; - guint width; - guint height; - guint arrow_size; - guint shadow; - - gtk_style_context_get_border ( - gtk_widget_get_style_context (widget), - gtk_widget_get_state_flags (widget), - &border); - - gcal_arrow_container_get_padding_and_border (widget, - NULL, - &border_width, - &arrow_size, - &shadow); - - width = gtk_widget_get_allocated_width (widget) - 2 * border_width - 2 * shadow; - height = gtk_widget_get_allocated_height (widget) - 2 * border_width - arrow_size - 2 * shadow; - - gcal_arrow_container_draw_shadow (widget, cr); - - gtk_render_background (gtk_widget_get_style_context (widget), - cr, - border_width + shadow, border_width + shadow, - width, height); - gtk_render_frame_gap (gtk_widget_get_style_context (widget), - cr, - border_width + shadow, border_width + shadow, - width, height, - GTK_POS_BOTTOM, - width / 2 - arrow_size - border.bottom, - width / 2 + arrow_size + border.bottom); - - gcal_arrow_container_draw_arrow (widget, cr); - - GTK_WIDGET_CLASS (gcal_arrow_container_parent_class)->draw (widget, cr); - - return FALSE; -} - -static void -gcal_arrow_container_draw_arrow (GtkWidget *widget, - cairo_t *cr) -{ - GdkRGBA color; - GtkBorder border; - guint arrow_size; - guint border_width; - guint shadow; - guint width; - guint height; - - gtk_style_context_get_border ( - gtk_widget_get_style_context (widget), - gtk_widget_get_state_flags (widget), - &border); - - gcal_arrow_container_get_padding_and_border (widget, - NULL, - &border_width, - &arrow_size, - &shadow); - - width = gtk_widget_get_allocated_width (widget) - 2 * border_width - 2 * shadow; - height = gtk_widget_get_allocated_height (widget) - 2 * border_width - arrow_size - 2 * shadow; - - cairo_save (cr); - cairo_move_to (cr, - border_width + shadow + width / 2 - arrow_size, - border_width + shadow + height - border.bottom); - cairo_rel_line_to (cr, 0, border.bottom); - cairo_rel_line_to (cr, arrow_size, arrow_size); - cairo_rel_line_to (cr, arrow_size, - arrow_size); - cairo_rel_line_to (cr, 0, - border.bottom); - - gtk_style_context_get_background_color ( - gtk_widget_get_style_context (widget), - gtk_widget_get_state_flags (widget), - &color); - cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha); - cairo_fill (cr); - - cairo_set_line_width (cr, border.bottom); - cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); - cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); - cairo_move_to (cr, - border_width + shadow + width / 2 - arrow_size, - border_width + shadow + height); - cairo_rel_line_to (cr, arrow_size, arrow_size); - cairo_rel_line_to (cr, arrow_size, - arrow_size); - - gtk_style_context_get_border_color ( - gtk_widget_get_style_context (widget), - gtk_widget_get_state_flags (widget), - &color); - cairo_set_source_rgb (cr, color.red, color.green, color.blue); - cairo_stroke (cr); - cairo_restore (cr); -} - -static void -gcal_arrow_container_draw_shadow (GtkWidget *widget, - cairo_t *cr) -{ - cairo_pattern_t *pattern; - gdouble inner_alpha; - gint width; - gint height; - guint arrow_size; - guint shadow_span; - guint border_width; - gdouble shadow_span_tan; - - gcal_arrow_container_get_padding_and_border (widget, - NULL, - &border_width, - &arrow_size, - &shadow_span); - - width = gtk_widget_get_allocated_width (widget); - height = gtk_widget_get_allocated_height (widget); - shadow_span_tan = shadow_span / tan (G_PI_4 / 2 + G_PI_4); - - inner_alpha = 0.8; - - cairo_save (cr); - - /* Top border */ - pattern = cairo_pattern_create_linear (0, border_width, - 0, border_width + 3 * shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, 0.0); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, inner_alpha); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - border_width + shadow_span, border_width, - width - 2 * border_width - 2 * shadow_span, shadow_span); - cairo_fill (cr); - - /* Left border */ - pattern = cairo_pattern_create_linear (border_width, 0, - border_width + 3 * shadow_span, 0); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, 0.0); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, inner_alpha); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - border_width, border_width + shadow_span, - shadow_span, height - 2 * border_width - 2 * shadow_span - arrow_size); - cairo_fill (cr); - - /* Right border */ - pattern = cairo_pattern_create_linear (width - (border_width + 3 * shadow_span), 0, - width - border_width, 0); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, inner_alpha); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - width - (border_width + shadow_span), border_width + shadow_span, - shadow_span, height - 2 * border_width - 2 * shadow_span - arrow_size); - cairo_fill (cr); - - /* Bottom border */ - pattern = cairo_pattern_create_linear (0, height - border_width - 3 * shadow_span - arrow_size, - 0, height - border_width - arrow_size); - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, inner_alpha); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - border_width + shadow_span, height - border_width - shadow_span - arrow_size, - width / 2 - arrow_size - border_width - shadow_span - shadow_span_tan, shadow_span); - cairo_rectangle (cr, - width / 2 + arrow_size + shadow_span_tan, height - border_width - shadow_span - arrow_size, - width / 2 - arrow_size - border_width - shadow_span - shadow_span_tan, shadow_span); - cairo_fill (cr); - - /* NW corner */ - pattern = cairo_pattern_create_radial ( - border_width + shadow_span, border_width + shadow_span, 0, - border_width + shadow_span, border_width + shadow_span, shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, inner_alpha / 3); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - border_width, border_width, - shadow_span, shadow_span); - cairo_fill (cr); - - /* SE corner */ - pattern = cairo_pattern_create_radial ( - border_width + shadow_span, height - border_width - shadow_span - arrow_size, 0, - border_width + shadow_span, height - border_width - shadow_span - arrow_size, shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, inner_alpha / 3); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - border_width, height - border_width - shadow_span - arrow_size, - shadow_span, shadow_span); - cairo_fill (cr); - - /* SW corner */ - pattern = cairo_pattern_create_radial ( - width - border_width - shadow_span, height - border_width - shadow_span - arrow_size, 0, - width - border_width - shadow_span, height - border_width - shadow_span - arrow_size, shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, inner_alpha / 3); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - width - border_width - shadow_span, height - border_width - shadow_span - arrow_size, - shadow_span, shadow_span); - cairo_fill (cr); - - /* Arrow left joint */ - pattern = cairo_pattern_create_radial ( - width / 2 - arrow_size - shadow_span_tan, height - border_width - arrow_size, 0, - width / 2 - arrow_size - shadow_span_tan, height - border_width - arrow_size, shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, 0.0); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, inner_alpha / 3); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_move_to (cr, - width / 2 - arrow_size - shadow_span_tan, - height - border_width - arrow_size); - cairo_arc (cr, - width / 2 - arrow_size - shadow_span_tan, - height - border_width - arrow_size, - shadow_span + 2, - G_PI_2 + G_PI, - 2 * G_PI - G_PI_4); - - cairo_fill (cr); - - /* Arrow right joint */ - pattern = cairo_pattern_create_radial ( - width / 2 + arrow_size + shadow_span_tan, height - border_width - arrow_size, 0, - width / 2 + arrow_size + shadow_span_tan, height - border_width - arrow_size, shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, 0.0); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, inner_alpha / 3); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_move_to (cr, - width / 2 + arrow_size + shadow_span_tan, - height - border_width - arrow_size); - cairo_arc (cr, - width / 2 + arrow_size + shadow_span_tan, - height - border_width - arrow_size, - shadow_span + 2, - G_PI_4 + G_PI, - G_PI + G_PI_2); - - cairo_fill (cr); - - /* Arrow left side */ - cairo_save (cr); - cairo_translate (cr, - width / 2 - arrow_size, - height - border_width - shadow_span - arrow_size); - cairo_rotate(cr, G_PI_4); - - pattern = cairo_pattern_create_linear ( - 0, 0, - 0, shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, inner_alpha / 3); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - shadow_span_tan, 0, - arrow_size * G_SQRT2 - shadow_span_tan, shadow_span); - - cairo_fill (cr); - cairo_restore (cr); - - /* Arrow right side */ - cairo_save (cr); - cairo_translate (cr, - width / 2, - height - border_width - shadow_span); - cairo_rotate (cr, - G_PI_4); - - pattern = cairo_pattern_create_linear ( - 0, 0, - 0, shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, inner_alpha / 3); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_rectangle (cr, - 0, - 0, - arrow_size * G_SQRT2 - shadow_span_tan, - shadow_span); - - cairo_fill (cr); - cairo_restore (cr); - - /* Arrow point */ - pattern = cairo_pattern_create_radial ( - width / 2, height - border_width - shadow_span, 0, - width / 2, height - border_width - shadow_span, shadow_span); - - cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0, 0, 0, inner_alpha / 3); - cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); - - cairo_set_source (cr, pattern); - cairo_pattern_destroy (pattern); - - cairo_move_to (cr, - width / 2, - height - border_width - shadow_span); - cairo_arc (cr, - width / 2, - height - border_width - shadow_span, - shadow_span, - G_PI_4, - G_PI_2 + G_PI_4); - cairo_fill (cr); - - cairo_restore (cr); -} - -static void -gcal_arrow_container_get_padding_and_border (GtkWidget *widget, - GtkBorder *border, - guint *border_width, - guint *arrow_size, - guint *shadow) -{ - GtkBorder tmp; - guint bd_width; - - bd_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - if (border != NULL) - { - gtk_style_context_get_padding ( - gtk_widget_get_style_context (widget), - gtk_widget_get_state_flags (widget), - border); - - gtk_style_context_get_border ( - gtk_widget_get_style_context (widget), - gtk_widget_get_state_flags (widget), - &tmp); - - border->top += tmp.top + bd_width; - border->right += tmp.right + bd_width; - border->bottom += tmp.bottom + bd_width; - border->left += tmp.left + bd_width; - } - - if (arrow_size != NULL) - { - gtk_style_context_get_style ( - gtk_widget_get_style_context (widget), - "arrow-size", arrow_size, - NULL); - } - - if (border_width != NULL) - *border_width = bd_width; - - if (shadow != NULL) - { - gtk_style_context_get_style ( - gtk_widget_get_style_context (widget), - "shadow-span", shadow, - NULL); - } -} - -GtkWidget* -gcal_arrow_container_new (void) -{ - return g_object_new (GCAL_TYPE_ARROW_CONTAINER, NULL); -} diff --git a/src/gcal-arrow-container.h b/src/gcal-arrow-container.h deleted file mode 100644 index 422e5060..00000000 --- a/src/gcal-arrow-container.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ -/* - * gcal-arrow-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_ARROW_CONTAINER_H__ -#define __GCAL_ARROW_CONTAINER_H__ - -#include - -G_BEGIN_DECLS - - -#define GCAL_TYPE_ARROW_CONTAINER (gcal_arrow_container_get_type ()) -#define GCAL_ARROW_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_ARROW_CONTAINER, GcalArrowContainer)) -#define GCAL_ARROW_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_ARROW_CONTAINER, GcalArrowContainerClass)) -#define GCAL_IS_ARROW_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_ARROW_CONTAINER)) -#define GCAL_IS_ARROW_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_ARROW_CONTAINER)) -#define GCAL_ARROW_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_ARROW_CONTAINER, GcalArrowContainerClass)) - -typedef struct _GcalArrowContainer GcalArrowContainer; -typedef struct _GcalArrowContainerClass GcalArrowContainerClass; -typedef struct _GcalArrowContainerPrivate GcalArrowContainerPrivate; - -struct _GcalArrowContainer -{ - GtkBin parent; - /* add your public declarations here */ - - GcalArrowContainerPrivate *priv; -}; - -struct _GcalArrowContainerClass -{ - GtkBinClass parent_class; -}; - - -GType gcal_arrow_container_get_type (void); -GtkWidget* gcal_arrow_container_new (void); - - -G_END_DECLS - -#endif /* __GCAL_ARROW_CONTAINER_H__ */ diff --git a/src/gcal-event-overlay.c b/src/gcal-event-overlay.c index a5038ee2..c3729b02 100644 --- a/src/gcal-event-overlay.c +++ b/src/gcal-event-overlay.c @@ -18,7 +18,7 @@ */ #include "gcal-event-overlay.h" -#include "gcal-arrow-container.h" +#include "gcal-arrow-bin.h" #include "gcal-utils.h" #include @@ -135,7 +135,7 @@ gcal_event_overlay_constructed (GObject* object) overlay = gtk_overlay_new (); - priv->container = gcal_arrow_container_new (); + priv->container = gcal_arrow_bin_new (); gtk_container_set_border_width (GTK_CONTAINER (priv->container), 14); gtk_style_context_add_class ( gtk_widget_get_style_context (priv->container),