/* dash-box.c generated by valac 0.16.1, the Vala compiler
* generated from dash-box.vala, do not modify */
/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*-
*
* Copyright (C) 2011,2012 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* 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 .
*
* Authored by: Michael Terry
*/
#include
#include
#include
#include
#include
#include
#define TYPE_DASH_BOX (dash_box_get_type ())
#define DASH_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DASH_BOX, DashBox))
#define DASH_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DASH_BOX, DashBoxClass))
#define IS_DASH_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DASH_BOX))
#define IS_DASH_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DASH_BOX))
#define DASH_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DASH_BOX, DashBoxClass))
typedef struct _DashBox DashBox;
typedef struct _DashBoxClass DashBoxClass;
typedef struct _DashBoxPrivate DashBoxPrivate;
#define TYPE_BACKGROUND (background_get_type ())
#define BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BACKGROUND, Background))
#define BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BACKGROUND, BackgroundClass))
#define IS_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BACKGROUND))
#define IS_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BACKGROUND))
#define BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BACKGROUND, BackgroundClass))
typedef struct _Background Background;
typedef struct _BackgroundClass BackgroundClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define BACKGROUND_TYPE_DRAW_FLAGS (background_draw_flags_get_type ())
struct _DashBox {
GtkBox parent_instance;
DashBoxPrivate * priv;
};
struct _DashBoxClass {
GtkBoxClass parent_class;
};
struct _DashBoxPrivate {
Background* _background;
};
typedef enum {
BACKGROUND_DRAW_FLAGS_NONE,
BACKGROUND_DRAW_FLAGS_GRID
} BackgroundDrawFlags;
static gpointer dash_box_parent_class = NULL;
GType dash_box_get_type (void) G_GNUC_CONST;
GType background_get_type (void) G_GNUC_CONST;
#define DASH_BOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_DASH_BOX, DashBoxPrivate))
enum {
DASH_BOX_DUMMY_PROPERTY,
DASH_BOX_BACKGROUND
};
DashBox* dash_box_new (Background* bg);
DashBox* dash_box_construct (GType object_type, Background* bg);
static gboolean dash_box_real_draw (GtkWidget* base, cairo_t* c);
Background* dash_box_get_background (DashBox* self);
GType background_draw_flags_get_type (void) G_GNUC_CONST;
void background_draw_full (Background* self, cairo_t* c, BackgroundDrawFlags flags);
#define grid_size 40
static void dash_box_cairo_rounded_rectangle (DashBox* self, cairo_t* c, gdouble x, gdouble y, gdouble width, gdouble height, gdouble radius);
static void dash_box_set_background (DashBox* self, Background* value);
static GObject * dash_box_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void dash_box_finalize (GObject* obj);
static void _vala_dash_box_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_dash_box_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
DashBox* dash_box_construct (GType object_type, Background* bg) {
DashBox * self = NULL;
Background* _tmp0_;
g_return_val_if_fail (bg != NULL, NULL);
_tmp0_ = bg;
self = (DashBox*) g_object_new (object_type, "background", _tmp0_, NULL);
return self;
}
DashBox* dash_box_new (Background* bg) {
return dash_box_construct (TYPE_DASH_BOX, bg);
}
static gboolean dash_box_real_draw (GtkWidget* base, cairo_t* c) {
DashBox * self;
gboolean result = FALSE;
Background* _tmp0_;
cairo_t* _tmp11_;
GtkAllocation allocation = {0};
GtkAllocation _tmp12_ = {0};
GtkAllocation _tmp13_;
gint _tmp14_;
gint box_w;
GtkAllocation _tmp15_;
gint _tmp16_;
gint box_h;
gdouble box_r;
cairo_t* _tmp17_;
cairo_t* _tmp18_;
cairo_t* _tmp19_;
cairo_t* _tmp20_;
cairo_t* _tmp21_;
cairo_t* _tmp22_;
cairo_t* _tmp23_;
cairo_t* _tmp24_;
gboolean _tmp25_ = FALSE;
self = (DashBox*) base;
g_return_val_if_fail (c != NULL, FALSE);
_tmp0_ = self->priv->_background;
if (_tmp0_ != NULL) {
gint x = 0;
gint y = 0;
Background* _tmp1_;
gint _tmp2_ = 0;
gint _tmp3_ = 0;
cairo_t* _tmp4_;
cairo_t* _tmp5_;
gint _tmp6_;
gint _tmp7_;
Background* _tmp8_;
cairo_t* _tmp9_;
cairo_t* _tmp10_;
_tmp1_ = self->priv->_background;
gtk_widget_translate_coordinates ((GtkWidget*) _tmp1_, (GtkWidget*) self, 0, 0, &_tmp2_, &_tmp3_);
x = _tmp2_;
y = _tmp3_;
_tmp4_ = c;
cairo_save (_tmp4_);
_tmp5_ = c;
_tmp6_ = x;
_tmp7_ = y;
cairo_translate (_tmp5_, (gdouble) _tmp6_, (gdouble) _tmp7_);
_tmp8_ = self->priv->_background;
_tmp9_ = c;
background_draw_full (_tmp8_, _tmp9_, BACKGROUND_DRAW_FLAGS_NONE);
_tmp10_ = c;
cairo_restore (_tmp10_);
}
_tmp11_ = c;
cairo_save (_tmp11_);
gtk_widget_get_allocation ((GtkWidget*) self, &_tmp12_);
allocation = _tmp12_;
_tmp13_ = allocation;
_tmp14_ = _tmp13_.width;
box_w = _tmp14_;
_tmp15_ = allocation;
_tmp16_ = _tmp15_.height;
box_h = _tmp16_;
box_r = 0.2 * grid_size;
_tmp17_ = c;
dash_box_cairo_rounded_rectangle (self, _tmp17_, (gdouble) 0, (gdouble) 0, (gdouble) box_w, (gdouble) box_h, box_r);
_tmp18_ = c;
cairo_set_source_rgba (_tmp18_, 0.1, 0.1, 0.1, 0.4);
_tmp19_ = c;
cairo_fill_preserve (_tmp19_);
_tmp20_ = c;
cairo_set_source_rgba (_tmp20_, 0.4, 0.4, 0.4, 0.4);
_tmp21_ = c;
cairo_set_line_width (_tmp21_, (gdouble) 1);
_tmp22_ = c;
cairo_stroke (_tmp22_);
_tmp23_ = c;
cairo_restore (_tmp23_);
_tmp24_ = c;
_tmp25_ = GTK_WIDGET_CLASS (dash_box_parent_class)->draw ((GtkWidget*) GTK_BOX (self), _tmp24_);
result = _tmp25_;
return result;
}
static void dash_box_cairo_rounded_rectangle (DashBox* self, cairo_t* c, gdouble x, gdouble y, gdouble width, gdouble height, gdouble radius) {
gdouble _tmp0_;
gdouble _tmp1_;
gdouble w;
gdouble _tmp2_;
gdouble _tmp3_;
gdouble h;
gdouble _tmp4_;
gdouble kappa;
cairo_t* _tmp5_;
gdouble _tmp6_;
gdouble _tmp7_;
gdouble _tmp8_;
cairo_t* _tmp9_;
cairo_t* _tmp10_;
gdouble _tmp11_;
gdouble _tmp12_;
gdouble _tmp13_;
gdouble _tmp14_;
cairo_t* _tmp15_;
cairo_t* _tmp16_;
gdouble _tmp17_;
gdouble _tmp18_;
gdouble _tmp19_;
gdouble _tmp20_;
cairo_t* _tmp21_;
cairo_t* _tmp22_;
gdouble _tmp23_;
gdouble _tmp24_;
gdouble _tmp25_;
gdouble _tmp26_;
cairo_t* _tmp27_;
cairo_t* _tmp28_;
gdouble _tmp29_;
gdouble _tmp30_;
gdouble _tmp31_;
gdouble _tmp32_;
g_return_if_fail (self != NULL);
g_return_if_fail (c != NULL);
_tmp0_ = width;
_tmp1_ = radius;
w = _tmp0_ - (_tmp1_ * 2);
_tmp2_ = height;
_tmp3_ = radius;
h = _tmp2_ - (_tmp3_ * 2);
_tmp4_ = radius;
kappa = 0.5522847498 * _tmp4_;
_tmp5_ = c;
_tmp6_ = x;
_tmp7_ = radius;
_tmp8_ = y;
cairo_move_to (_tmp5_, _tmp6_ + _tmp7_, _tmp8_);
_tmp9_ = c;
cairo_rel_line_to (_tmp9_, w, (gdouble) 0);
_tmp10_ = c;
_tmp11_ = radius;
_tmp12_ = radius;
_tmp13_ = radius;
_tmp14_ = radius;
cairo_rel_curve_to (_tmp10_, kappa, (gdouble) 0, _tmp11_, _tmp12_ - kappa, _tmp13_, _tmp14_);
_tmp15_ = c;
cairo_rel_line_to (_tmp15_, (gdouble) 0, h);
_tmp16_ = c;
_tmp17_ = radius;
_tmp18_ = radius;
_tmp19_ = radius;
_tmp20_ = radius;
cairo_rel_curve_to (_tmp16_, (gdouble) 0, kappa, kappa - _tmp17_, _tmp18_, -_tmp19_, _tmp20_);
_tmp21_ = c;
cairo_rel_line_to (_tmp21_, -w, (gdouble) 0);
_tmp22_ = c;
_tmp23_ = radius;
_tmp24_ = radius;
_tmp25_ = radius;
_tmp26_ = radius;
cairo_rel_curve_to (_tmp22_, -kappa, (gdouble) 0, -_tmp23_, kappa - _tmp24_, -_tmp25_, -_tmp26_);
_tmp27_ = c;
cairo_rel_line_to (_tmp27_, (gdouble) 0, -h);
_tmp28_ = c;
_tmp29_ = radius;
_tmp30_ = radius;
_tmp31_ = radius;
_tmp32_ = radius;
cairo_rel_curve_to (_tmp28_, (gdouble) 0, -kappa, _tmp29_ - kappa, -_tmp30_, _tmp31_, -_tmp32_);
}
Background* dash_box_get_background (DashBox* self) {
Background* result;
Background* _tmp0_;
g_return_val_if_fail (self != NULL, NULL);
_tmp0_ = self->priv->_background;
result = _tmp0_;
return result;
}
static gpointer _g_object_ref0 (gpointer self) {
return self ? g_object_ref (self) : NULL;
}
static void dash_box_set_background (DashBox* self, Background* value) {
Background* _tmp0_;
Background* _tmp1_;
g_return_if_fail (self != NULL);
_tmp0_ = value;
_tmp1_ = _g_object_ref0 (_tmp0_);
_g_object_unref0 (self->priv->_background);
self->priv->_background = _tmp1_;
g_object_notify ((GObject *) self, "background");
}
static GObject * dash_box_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
GObject * obj;
GObjectClass * parent_class;
DashBox * self;
parent_class = G_OBJECT_CLASS (dash_box_parent_class);
obj = parent_class->constructor (type, n_construct_properties, construct_properties);
self = DASH_BOX (obj);
gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
return obj;
}
static void dash_box_class_init (DashBoxClass * klass) {
dash_box_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (DashBoxPrivate));
GTK_WIDGET_CLASS (klass)->draw = dash_box_real_draw;
G_OBJECT_CLASS (klass)->get_property = _vala_dash_box_get_property;
G_OBJECT_CLASS (klass)->set_property = _vala_dash_box_set_property;
G_OBJECT_CLASS (klass)->constructor = dash_box_constructor;
G_OBJECT_CLASS (klass)->finalize = dash_box_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), DASH_BOX_BACKGROUND, g_param_spec_object ("background", "background", "background", TYPE_BACKGROUND, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}
static void dash_box_instance_init (DashBox * self) {
self->priv = DASH_BOX_GET_PRIVATE (self);
self->priv->_background = NULL;
}
static void dash_box_finalize (GObject* obj) {
DashBox * self;
self = DASH_BOX (obj);
_g_object_unref0 (self->priv->_background);
G_OBJECT_CLASS (dash_box_parent_class)->finalize (obj);
}
GType dash_box_get_type (void) {
static volatile gsize dash_box_type_id__volatile = 0;
if (g_once_init_enter (&dash_box_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (DashBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dash_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DashBox), 0, (GInstanceInitFunc) dash_box_instance_init, NULL };
GType dash_box_type_id;
dash_box_type_id = g_type_register_static (GTK_TYPE_BOX, "DashBox", &g_define_type_info, 0);
g_once_init_leave (&dash_box_type_id__volatile, dash_box_type_id);
}
return dash_box_type_id__volatile;
}
static void _vala_dash_box_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
DashBox * self;
self = DASH_BOX (object);
switch (property_id) {
case DASH_BOX_BACKGROUND:
g_value_set_object (value, dash_box_get_background (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void _vala_dash_box_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
DashBox * self;
self = DASH_BOX (object);
switch (property_id) {
case DASH_BOX_BACKGROUND:
dash_box_set_background (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}