1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
5
#include "shell-arrow.h"
7
#include <clutter/clutter.h>
17
G_DEFINE_TYPE(ShellArrow, shell_arrow, CLUTTER_TYPE_CAIRO_TEXTURE);
19
struct _ShellArrowPrivate {
20
GtkArrowType direction;
23
static void shell_arrow_redraw (ShellArrow *self);
26
shell_arrow_set_property (GObject *object,
31
ShellArrow *self = SHELL_ARROW (object);
36
self->priv->direction = g_value_get_enum (value);
40
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
44
shell_arrow_redraw (self);
48
shell_arrow_get_property (GObject *object,
53
ShellArrow *self = SHELL_ARROW (object);
58
g_value_set_enum (value, self->priv->direction);
62
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
68
shell_arrow_redraw (ShellArrow *self)
73
g_object_get (G_OBJECT (self), "surface-width", &width,
74
"surface-height", &height,
80
cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (self));
82
cairo_set_source_rgb (cr, 1, 1, 1);
84
switch (self->priv->direction)
87
cairo_move_to (cr, 0, 0);
88
cairo_line_to (cr, width, height*0.5);
89
cairo_line_to (cr, 0, height);
92
cairo_move_to (cr, width, 0);
93
cairo_line_to (cr, 0, height*0.5);
94
cairo_line_to (cr, width, height);
97
cairo_move_to (cr, 0, height);
98
cairo_line_to (cr, width*0.5, 0);
99
cairo_line_to (cr, width, height);
102
cairo_move_to (cr, 0, 0);
103
cairo_line_to (cr, width*0.5, height);
104
cairo_line_to (cr, width, height);
111
cairo_close_path (cr);
118
shell_arrow_class_init (ShellArrowClass *klass)
120
GObjectClass *object_class = G_OBJECT_CLASS (klass);
122
g_type_class_add_private (klass, sizeof (ShellArrowPrivate));
124
object_class->get_property = shell_arrow_get_property;
125
object_class->set_property = shell_arrow_set_property;
127
g_object_class_install_property (object_class,
129
g_param_spec_enum ("direction",
138
shell_arrow_init (ShellArrow *actor)
140
actor->priv = G_TYPE_INSTANCE_GET_PRIVATE (actor, SHELL_TYPE_ARROW,
142
g_signal_connect (actor, "notify::surface-width", G_CALLBACK (shell_arrow_redraw), NULL);