1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/* The Unico Theming Engine for Gtk+.
* Copyright (C) 2011 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* Authored by Andrea Cimitan <andrea.cimitan@canonical.com>
*
*/
#include <cairo.h>
#include <cairo-gobject.h>
#include <gtk/gtk.h>
#include "unico.h"
#include "unico-cairo-support.h"
#include "unico-draw.h"
#include "unico-engine.h"
#include "unico-support.h"
#include "unico-types.h"
#define UNICO_NAMESPACE "unico"
#define UNICO_CAIRO_INIT \
cairo_set_line_width (cr, 1.0); \
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); \
cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
G_DEFINE_DYNAMIC_TYPE (UnicoEngine, unico_engine, GTK_TYPE_THEMING_ENGINE)
static void
unico_engine_render_arrow (GtkThemingEngine *engine,
cairo_t *cr,
gdouble angle,
gdouble x,
gdouble y,
gdouble size)
{
UnicoStyleFunctions *style_functions;
UNICO_CAIRO_INIT
unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
style_functions->draw_arrow (engine, cr, angle, x, y, size);
}
static void
unico_engine_render_expander (GtkThemingEngine *engine,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
UnicoStyleFunctions *style_functions;
UNICO_CAIRO_INIT
unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
style_functions->draw_expander (engine, cr, x, y, width, height);
}
static void
unico_engine_render_focus (GtkThemingEngine *engine,
cairo_t *cr,
gdouble x,
gdouble y,
gdouble width,
gdouble height)
{
UnicoStyleFunctions *style_functions;
UNICO_CAIRO_INIT
unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
style_functions->draw_focus (engine, cr, x, y, width, height);
}
void
unico_engine_register_types (GTypeModule *module)
{
unico_engine_register_type (module);
}
static void
unico_engine_init (UnicoEngine *engine)
{
unico_register_style_default (&engine->style_functions[UNICO_STYLE_DEFAULT]);
}
static void
unico_engine_class_init (UnicoEngineClass *klass)
{
GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
engine_class->render_arrow = unico_engine_render_arrow;
engine_class->render_expander = unico_engine_render_expander;
engine_class->render_focus = unico_engine_render_focus;
gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
g_param_spec_boxed ("arrow-texture",
"Arrow texture",
"Arrow texture",
CAIRO_GOBJECT_TYPE_PATTERN, 0));
gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
g_param_spec_boxed ("focus-border-color",
"Focus border color",
"Focus border color",
GDK_TYPE_RGBA, 0));
gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
g_param_spec_int ("focus-border-radius",
"Focus border radius",
"Focus border radius",
0, G_MAXINT, 0, 0));
gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
g_param_spec_boxed ("focus-fill-color",
"Focus fill color",
"Focus fill color",
GDK_TYPE_RGBA, 0));
}
static void
unico_engine_class_finalize (UnicoEngineClass *klass)
{
}
|