~ubuntu-branches/ubuntu/trusty/gnome-themes-standard/trusty-proposed

« back to all changes in this revision

Viewing changes to src/adwaita_engine.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Sjoerd Simons, Michael Biebl
  • Date: 2011-10-29 12:46:48 UTC
  • mfrom: (1.2.1) (14.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20111029124648-a2yi87sofmin1gq5
Tags: 3.2.1-1
[ Sjoerd Simons ]
* New upstream release
* debian/control.in: Update libgtk-3-dev depends and add librsvg2-dev
  build-depends

[ Michael Biebl ]
* debian/watch:
  - Switch to .xz tarballs.
  - Track stable releases.
  - Don't run uupdate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
1
/* Adwaita - a GTK+ engine
3
2
 *
4
3
 * Copyright (C) 2011 Carlos Garnacho <carlosg@gnome.org>
29
28
#include <math.h>
30
29
#include <cairo-gobject.h>
31
30
 
 
31
#include "adwaita_utils.h"
 
32
 
32
33
#define ADWAITA_NAMESPACE "adwaita"
33
34
 
34
35
typedef struct _AdwaitaEngine AdwaitaEngine;
59
60
void
60
61
adwaita_engine_register_types (GTypeModule *module)
61
62
{
62
 
        adwaita_engine_register_type (module);
 
63
  adwaita_engine_register_type (module);
63
64
}
64
65
 
65
66
static void
68
69
}
69
70
 
70
71
static void
71
 
_cairo_round_rectangle (cairo_t *cr,
72
 
                        gdouble   x,
73
 
                        gdouble   y,
74
 
                        gdouble   w,
75
 
                        gdouble   h,
76
 
                        gdouble   radius)
77
 
{
78
 
        g_return_if_fail (cr != NULL);
79
 
 
80
 
        if (radius < 0.0001)
81
 
        {
82
 
                cairo_rectangle (cr, x, y, w, h);
83
 
                return;
84
 
        }
85
 
 
86
 
        cairo_move_to (cr, x+radius, y);
87
 
        cairo_arc (cr, x+w-radius, y+radius, radius, G_PI * 1.5, G_PI * 2);
88
 
        cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, G_PI * 0.5);
89
 
        cairo_arc (cr, x+radius,   y+h-radius, radius, G_PI * 0.5, G_PI);
90
 
        cairo_arc (cr, x+radius,   y+radius,   radius, G_PI, G_PI * 1.5);
91
 
}
92
 
 
93
 
/* Set the appropriate matrix for
94
 
 * patterns coming from the style context
95
 
 */
96
 
static void
97
 
style_pattern_set_matrix (cairo_pattern_t *pattern,
98
 
                          gdouble          width,
99
 
                          gdouble          height)
100
 
{
101
 
  cairo_matrix_t matrix;
102
 
  gint w, h;
103
 
 
104
 
  if (cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SURFACE)
105
 
    {
106
 
      cairo_surface_t *surface;
107
 
 
108
 
      cairo_pattern_get_surface (pattern, &surface);
109
 
      w = cairo_image_surface_get_width (surface);
110
 
      h = cairo_image_surface_get_height (surface);
111
 
    }
112
 
  else
113
 
    w = h = 1;
114
 
 
115
 
  cairo_matrix_init_scale (&matrix, (gdouble) w / width, (gdouble) h / height);
116
 
  cairo_pattern_set_matrix (pattern, &matrix);
117
 
}
118
 
 
119
 
static void
120
72
adwaita_engine_render_arrow (GtkThemingEngine *engine,
121
 
                             cairo_t          *cr,
122
 
                             gdouble           angle,
123
 
                             gdouble           x,
124
 
                             gdouble           y,
125
 
                             gdouble           size)
 
73
                             cairo_t          *cr,
 
74
                             gdouble           angle,
 
75
                             gdouble           x,
 
76
                             gdouble           y,
 
77
                             gdouble           size)
126
78
{
127
 
        double line_width;
128
 
        GtkStateFlags state;
129
 
        GdkRGBA color;
130
 
 
131
 
        cairo_save (cr);
132
 
 
133
 
        line_width = size / 3.0 / sqrt (2);
134
 
        cairo_set_line_width (cr, line_width);
135
 
        cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
136
 
        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
137
 
 
138
 
        cairo_translate (cr, x + size / 2.0, y + size / 2.0);
139
 
        cairo_rotate (cr, angle - G_PI_2);
140
 
        cairo_translate (cr, size / 4.0, 0);
 
79
  double line_width;
 
80
  GtkStateFlags state;
 
81
  GdkRGBA color;
 
82
 
 
83
  cairo_save (cr);
 
84
 
 
85
  line_width = size / 3.0 / sqrt (2);
 
86
  cairo_set_line_width (cr, line_width);
 
87
  cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
 
88
  cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
 
89
 
 
90
  cairo_translate (cr, x + size / 2.0, y + size / 2.0);
 
91
  cairo_rotate (cr, angle - G_PI_2);
 
92
  cairo_translate (cr, size / 4.0, 0);
141
93
 
142
 
        cairo_scale (cr,
143
 
                     (size / (size + line_width)),
144
 
                     (size / (size + line_width)));
145
 
 
146
 
        cairo_move_to (cr, -size / 2.0, -size / 2.0);
147
 
        cairo_rel_line_to (cr, size / 2.0, size / 2.0);
148
 
        cairo_rel_line_to (cr, - size / 2.0, size / 2.0);
149
 
 
150
 
        state = gtk_theming_engine_get_state (engine);
151
 
        gtk_theming_engine_get_color (engine, state, &color);
152
 
 
153
 
        if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
154
 
            !(state & GTK_STATE_FLAG_INSENSITIVE) && !(state & GTK_STATE_FLAG_PRELIGHT)) {
155
 
                GdkRGBA *arrow_color;
156
 
 
157
 
                gtk_theming_engine_get (engine, state,
158
 
                                        "-adwaita-menuitem-arrow-color", &arrow_color,
159
 
                                        NULL);
160
 
 
161
 
                if (arrow_color != NULL) {
162
 
                        color = *arrow_color;
163
 
                }
164
 
 
165
 
                gdk_rgba_free (arrow_color);
166
 
        }
167
 
 
168
 
        gdk_cairo_set_source_rgba (cr, &color);
169
 
        cairo_stroke (cr);
170
 
        
171
 
        cairo_restore (cr);
 
94
  cairo_scale (cr,
 
95
               (size / (size + line_width)),
 
96
               (size / (size + line_width)));
 
97
 
 
98
  cairo_move_to (cr, -size / 2.0, -size / 2.0);
 
99
  cairo_rel_line_to (cr, size / 2.0, size / 2.0);
 
100
  cairo_rel_line_to (cr, - size / 2.0, size / 2.0);
 
101
 
 
102
  state = gtk_theming_engine_get_state (engine);
 
103
  gtk_theming_engine_get_color (engine, state, &color);
 
104
 
 
105
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
 
106
      !(state & GTK_STATE_FLAG_INSENSITIVE) && !(state & GTK_STATE_FLAG_PRELIGHT))
 
107
    {
 
108
      GdkRGBA *arrow_color;
 
109
 
 
110
      gtk_theming_engine_get (engine, state,
 
111
                              "-adwaita-menuitem-arrow-color", &arrow_color,
 
112
                              NULL);
 
113
 
 
114
      if (arrow_color != NULL)
 
115
        color = *arrow_color;
 
116
 
 
117
      gdk_rgba_free (arrow_color);
 
118
    }
 
119
 
 
120
  gdk_cairo_set_source_rgba (cr, &color);
 
121
  cairo_stroke (cr);
 
122
 
 
123
  cairo_restore (cr);
172
124
}
173
125
 
174
126
static void
175
127
adwaita_engine_render_focus (GtkThemingEngine *engine,
176
 
                             cairo_t          *cr,
177
 
                             gdouble           x,
178
 
                             gdouble           y,
179
 
                             gdouble           width,
180
 
                             gdouble           height)
181
 
{
182
 
        GdkRGBA *fill_color, *border_color = NULL;
183
 
        cairo_pattern_t *pattern = NULL;
184
 
        GtkStateFlags state;
185
 
        gint line_width, focus_pad;
186
 
        gint border_radius;
187
 
        gboolean use_dashes;
188
 
        double dashes[2] = { 2.0, 0.2 };
189
 
 
190
 
        state = gtk_theming_engine_get_state (engine);
191
 
        gtk_theming_engine_get (engine, state,
192
 
                                "-adwaita-focus-border-color", &border_color,
193
 
                                "-adwaita-focus-fill-color", &fill_color,
194
 
                                "-adwaita-focus-border-radius", &border_radius,
195
 
                                "-adwaita-focus-border-gradient", &pattern,
196
 
                                "-adwaita-focus-border-dashes", &use_dashes,
197
 
                                NULL);
198
 
 
199
 
        gtk_theming_engine_get_style (engine,
200
 
                                      "focus-line-width", &line_width,
201
 
                                      "focus-padding", &focus_pad,
202
 
                                      NULL);
203
 
 
204
 
        if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) &&
205
 
            gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_TAB, NULL)) {
206
 
                /* as we render the tab smaller than the whole allocation, we need
207
 
                 * to recenter and resize the focus on the tab.
208
 
                 */
209
 
                y += 3.0;
210
 
                height -= 3.0;
211
 
        }
212
 
 
213
 
        cairo_save (cr);
214
 
        cairo_set_line_width (cr, line_width);
215
 
 
216
 
        if (line_width > 1) {
217
 
                _cairo_round_rectangle (cr, x, y,
218
 
                                        width, height, border_radius);
219
 
        } else {
220
 
                _cairo_round_rectangle (cr, x + 0.5, y + 0.5,
221
 
                                        width - 1, height - 1, border_radius);
222
 
        }
223
 
 
224
 
        /* if we have a fill color, draw the fill */
225
 
        if (fill_color != NULL) {
226
 
                gdk_cairo_set_source_rgba (cr, fill_color);
227
 
                cairo_fill_preserve (cr);
228
 
        }
229
 
 
230
 
        if (use_dashes) {
231
 
                cairo_set_dash (cr, dashes, 1, 0.0);
232
 
        }
233
 
 
234
 
        /* if we have a gradient, draw the gradient, otherwise
235
 
         * draw the line if we have a color for it.
236
 
         */
237
 
        if (pattern != NULL) {
238
 
                style_pattern_set_matrix (pattern, width, height);
239
 
 
240
 
                cairo_set_source (cr, pattern);
241
 
        } else if (border_color != NULL) {
242
 
                gdk_cairo_set_source_rgba (cr, border_color);
243
 
        }
244
 
 
245
 
        cairo_stroke (cr);
246
 
        cairo_restore (cr);
247
 
 
248
 
        if (pattern != NULL) {
249
 
                cairo_pattern_destroy (pattern);
250
 
        }
251
 
 
252
 
        if (border_color != NULL) {
253
 
                gdk_rgba_free (border_color);
254
 
        }
255
 
 
256
 
        if (fill_color != NULL) {
257
 
                gdk_rgba_free (fill_color);
258
 
        }
259
 
}
260
 
 
261
 
static gboolean
262
 
render_from_assets_common (GtkThemingEngine *engine,
263
 
                           cairo_t *cr,
264
 
                           gdouble x,
265
 
                           gdouble y,
266
 
                           gdouble width,
267
 
                           gdouble height)
268
 
{
269
 
        gboolean retval = FALSE;
270
 
        GtkStateFlags state;
271
 
        GValue value = { 0, };
272
 
        cairo_pattern_t *asset = NULL;
273
 
        cairo_surface_t *surface = NULL;
274
 
 
275
 
        state = gtk_theming_engine_get_state (engine);
276
 
        gtk_theming_engine_get_property (engine,
277
 
                                         "background-image",
278
 
                                         state,
279
 
                                         &value);
280
 
 
281
 
        asset = g_value_dup_boxed (&value);
282
 
        g_value_unset (&value);
283
 
 
284
 
        if (asset != NULL) {
285
 
                cairo_pattern_get_surface (asset, &surface);
286
 
        }
287
 
 
288
 
        if (surface != NULL) {
289
 
                cairo_save (cr);
290
 
 
291
 
                cairo_set_source_surface (cr, surface, x, y);
292
 
                cairo_scale (cr,
293
 
                             width / cairo_image_surface_get_width (surface),
294
 
                             height / cairo_image_surface_get_height (surface));
295
 
 
296
 
                cairo_paint (cr);
297
 
 
298
 
                cairo_restore (cr);
299
 
                retval = TRUE;
300
 
        }
301
 
 
302
 
        if (asset != NULL) {
303
 
                cairo_pattern_destroy (asset);
304
 
        }
305
 
 
306
 
        return retval;
307
 
}
308
 
 
309
 
static void
310
 
render_check_menuitem (GtkThemingEngine *engine,
311
 
                       cairo_t *cr,
312
 
                       gdouble x,
313
 
                       gdouble y,
314
 
                       gdouble width,
315
 
                       gdouble height)
316
 
{
317
 
        GdkRGBA color;
318
 
        GtkStateFlags state;
319
 
 
320
 
        state = gtk_theming_engine_get_state (engine);
321
 
        gtk_theming_engine_get_color (engine, state, &color);
322
 
 
323
 
        if (!(state & GTK_STATE_FLAG_ACTIVE))
324
 
                return;
325
 
 
326
 
        cairo_save (cr);
327
 
 
328
 
        cairo_translate (cr, x, y);
329
 
 
330
 
        cairo_set_line_width (cr, 2.0);
331
 
        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
332
 
        cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
333
 
 
334
 
        cairo_move_to (cr, 0.5 + (width * 0.08), (height * 0.67));
335
 
        cairo_line_to (cr, 0.5 + (width * 0.32), (height * 0.90));
336
 
        cairo_line_to (cr, 0.5 + (width * 0.80), (height * 0.33));
337
 
 
338
 
        gdk_cairo_set_source_rgba (cr, &color);
339
 
        cairo_stroke (cr);
340
 
 
341
 
        cairo_restore (cr);
 
128
                             cairo_t          *cr,
 
129
                             gdouble           x,
 
130
                             gdouble           y,
 
131
                             gdouble           width,
 
132
                             gdouble           height)
 
133
{
 
134
  GdkRGBA *fill_color, *border_color = NULL;
 
135
  cairo_pattern_t *pattern = NULL;
 
136
  GtkStateFlags state;
 
137
  gint line_width, focus_pad;
 
138
  gint border_radius;
 
139
  gboolean use_dashes;
 
140
  double dashes[2] = { 2.0, 0.2 };
 
141
  const GtkWidgetPath *path;
 
142
 
 
143
  path = gtk_theming_engine_get_path (engine);
 
144
  state = gtk_theming_engine_get_state (engine);
 
145
  gtk_theming_engine_get (engine, state,
 
146
                          "-adwaita-focus-border-color", &border_color,
 
147
                          "-adwaita-focus-fill-color", &fill_color,
 
148
                          "-adwaita-focus-border-radius", &border_radius,
 
149
                          "-adwaita-focus-border-gradient", &pattern,
 
150
                          "-adwaita-focus-border-dashes", &use_dashes,
 
151
                          NULL);
 
152
 
 
153
  gtk_theming_engine_get_style (engine,
 
154
                                "focus-line-width", &line_width,
 
155
                                "focus-padding", &focus_pad,
 
156
                                NULL);
 
157
 
 
158
  /* as we render the tab smaller than the whole allocation, we need
 
159
   * to recenter and resize the focus on the tab.
 
160
   */
 
161
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) &&
 
162
      gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_TAB, NULL))
 
163
    {
 
164
      y += 3.0;
 
165
      height -= 3.0;
 
166
    }
 
167
 
 
168
  /* the treeview rows don't change allocation when modifying focus-padding,
 
169
   * so we have to move the focus ring inside the allocated area manually.
 
170
   */
 
171
  if (gtk_widget_path_is_type (path, GTK_TYPE_TREE_VIEW))
 
172
    {
 
173
      x += focus_pad;
 
174
      y += focus_pad;
 
175
      width -= 2 * focus_pad;
 
176
      height -= 2 * focus_pad;
 
177
    }
 
178
 
 
179
  cairo_save (cr);
 
180
  cairo_set_line_width (cr, line_width);
 
181
 
 
182
  if (line_width > 1)
 
183
    _cairo_round_rectangle_sides (cr, border_radius,
 
184
                                  x, y, width, height,
 
185
                                  SIDE_ALL, GTK_JUNCTION_NONE);
 
186
  else
 
187
    _cairo_round_rectangle_sides (cr, border_radius,
 
188
                                  x + 0.5, y + 0.5,
 
189
                                  width - 1, height - 1,
 
190
                                  SIDE_ALL, GTK_JUNCTION_NONE);
 
191
 
 
192
  /* if we have a fill color, draw the fill */
 
193
  if (fill_color != NULL)
 
194
    {
 
195
      gdk_cairo_set_source_rgba (cr, fill_color);
 
196
      cairo_fill_preserve (cr);
 
197
    }
 
198
 
 
199
  if (use_dashes)
 
200
    cairo_set_dash (cr, dashes, 1, 0.0);
 
201
 
 
202
  /* if we have a gradient, draw the gradient, otherwise
 
203
   * draw the line if we have a color for it.
 
204
   */
 
205
  if (pattern != NULL)
 
206
    {
 
207
      style_pattern_set_matrix (pattern, width, height, FALSE);
 
208
      cairo_set_source (cr, pattern);
 
209
    }
 
210
  else if (border_color != NULL)
 
211
    {
 
212
      gdk_cairo_set_source_rgba (cr, border_color);
 
213
    }
 
214
 
 
215
  cairo_stroke (cr);
 
216
  cairo_restore (cr);
 
217
 
 
218
  if (pattern != NULL)
 
219
    cairo_pattern_destroy (pattern);
 
220
 
 
221
  if (border_color != NULL)
 
222
    gdk_rgba_free (border_color);
 
223
 
 
224
  if (fill_color != NULL)
 
225
    gdk_rgba_free (fill_color);
342
226
}
343
227
 
344
228
static void
345
229
adwaita_engine_render_check (GtkThemingEngine *engine,
346
 
                             cairo_t          *cr,
347
 
                             gdouble           x,
348
 
                             gdouble           y,
349
 
                             gdouble           width,
350
 
                             gdouble           height)
351
 
{
352
 
        GdkRGBA *bg, *border, *fg;
353
 
        gboolean inconsistent = FALSE;
354
 
        gboolean draw_bullet;
355
 
        GtkStateFlags state;
356
 
        gint radius;
357
 
 
358
 
        if (gtk_theming_engine_has_class (engine,
359
 
                                          GTK_STYLE_CLASS_MENUITEM))
360
 
        {
361
 
                render_check_menuitem (engine, cr,
362
 
                                       x, y, width, height);
363
 
 
364
 
                return;
365
 
        }
366
 
 
367
 
        if (render_from_assets_common (engine, cr,
368
 
                                       x, y + 2.0, width, height)) {
369
 
                return;
370
 
        }
371
 
 
372
 
        /* fallback to old code path */
373
 
        state = gtk_theming_engine_get_state (engine);
374
 
        inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
375
 
        draw_bullet = (state & GTK_STATE_FLAG_ACTIVE);
376
 
        draw_bullet |= inconsistent;
377
 
 
378
 
        cairo_save (cr);
379
 
 
380
 
        gtk_theming_engine_get (engine, state,
381
 
                                "border-radius", &radius,
382
 
                                "background-color", &bg,
383
 
                                "border-color", &border,
384
 
                                "color", &fg,
385
 
                                NULL);
386
 
 
387
 
        cairo_translate (cr, x, y);
388
 
        cairo_set_line_width (cr, 1);
389
 
 
390
 
        _cairo_round_rectangle (cr, 0.5, 0.5, width-1, height-1, 2);
391
 
 
392
 
        if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
393
 
        {
394
 
                gdk_cairo_set_source_rgba (cr, bg);
395
 
                cairo_fill_preserve (cr);
396
 
        }
397
 
 
398
 
        gdk_cairo_set_source_rgba (cr, border);
399
 
        cairo_stroke (cr);
400
 
 
401
 
        if (draw_bullet)
402
 
        {
403
 
                if (inconsistent) /* Inconsistent */
404
 
                {
405
 
                        cairo_set_line_width (cr, 2.0);
406
 
                        cairo_move_to (cr, 3, height*0.5);
407
 
                        cairo_line_to (cr, width-3, height*0.5);
408
 
                }
409
 
                else
410
 
                {
411
 
                        cairo_set_line_width (cr, 1.7);
412
 
                        cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
413
 
                        cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
414
 
 
415
 
                        cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
416
 
                                            0.5 + (width*0.5), (height*0.4),
417
 
                                            0.5 + (width*0.70), (height*0.25));
418
 
 
419
 
                }
420
 
 
421
 
                gdk_cairo_set_source_rgba (cr, fg);
422
 
                cairo_stroke (cr);
423
 
        }
424
 
 
425
 
        cairo_restore (cr);
426
 
 
427
 
        gdk_rgba_free (bg);
428
 
        gdk_rgba_free (fg);
429
 
        gdk_rgba_free (border);
430
 
}
431
 
 
432
 
static void
433
 
render_radio_menuitem (GtkThemingEngine *engine,
434
 
                       cairo_t *cr,
435
 
                       gdouble x,
436
 
                       gdouble y,
437
 
                       gdouble width,
438
 
                       gdouble height)
439
 
{
440
 
        GdkRGBA color;
441
 
        GtkStateFlags state;
442
 
        double radius;
443
 
 
444
 
        state = gtk_theming_engine_get_state (engine);
445
 
 
446
 
        if (!(state & GTK_STATE_FLAG_ACTIVE))
447
 
                return;
448
 
 
449
 
        gtk_theming_engine_get_color (engine, state, &color);
450
 
 
451
 
        radius = MAX (height / 2.0, width / 2.0) * 0.58;
452
 
 
453
 
        cairo_save (cr);
454
 
 
455
 
        cairo_translate (cr, x + width / 2.0, y + height * 0.67);
456
 
        cairo_arc (cr,
457
 
                   0, 0,
458
 
                   radius,
459
 
                   0, 4 * G_PI);
460
 
 
461
 
        gdk_cairo_set_source_rgba (cr, &color);
462
 
        cairo_fill (cr);
463
 
 
464
 
        cairo_restore (cr);
 
230
                             cairo_t          *cr,
 
231
                             gdouble           x,
 
232
                             gdouble           y,
 
233
                             gdouble           width,
 
234
                             gdouble           height)
 
235
{
 
236
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
 
237
    (engine, cr, x, y, width, height);
465
238
}
466
239
 
467
240
static void
468
241
adwaita_engine_render_option (GtkThemingEngine *engine,
469
 
                              cairo_t          *cr,
470
 
                              gdouble           x,
471
 
                              gdouble           y,
472
 
                              gdouble           width,
473
 
                              gdouble           height)
 
242
                              cairo_t          *cr,
 
243
                              gdouble           x,
 
244
                              gdouble           y,
 
245
                              gdouble           width,
 
246
                              gdouble           height)
474
247
{
475
 
        GdkRGBA *bg, *border, *fg, highlight;
476
 
        GtkSymbolicColor *sym, *shade;
477
 
        gboolean inconsistent;
478
 
        gboolean draw_bullet;
479
 
        gdouble cx, cy, radius;
480
 
        GtkStateFlags state;
481
 
 
482
 
        if (gtk_theming_engine_has_class (engine,
483
 
                                          GTK_STYLE_CLASS_MENUITEM))
484
 
        {
485
 
                render_radio_menuitem (engine, cr, x, y, width, height);
486
 
                return;
487
 
        }
488
 
 
489
 
        if (render_from_assets_common (engine, cr,
490
 
                                       x, y + 2.0, width, height)) {
491
 
                return;
492
 
        }
493
 
 
494
 
        /* fallback to old code path */
495
 
        cx = width / 2.0;
496
 
        cy = height / 2.0;
497
 
        radius = MIN (width, height) / 2.0;
498
 
 
499
 
        cairo_save (cr);
500
 
 
501
 
        state = gtk_theming_engine_get_state (engine);
502
 
 
503
 
        gtk_theming_engine_get (engine, state,
504
 
                                "background-color", &bg,
505
 
                                "border-color", &border,
506
 
                                "color", &fg,
507
 
                                NULL);
508
 
 
509
 
        inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
510
 
        draw_bullet = (state & GTK_STATE_FLAG_ACTIVE) != 0;
511
 
        draw_bullet |= inconsistent;
512
 
 
513
 
        sym = gtk_symbolic_color_new_literal (bg);
514
 
        shade = gtk_symbolic_color_new_shade (sym, 1.1);
515
 
        gtk_symbolic_color_resolve (shade, NULL, &highlight);
516
 
 
517
 
        cairo_translate (cr, x, y);
518
 
        cairo_set_line_width (cr, MAX (1.0, floor (radius/6)));
519
 
 
520
 
        cairo_new_sub_path (cr);
521
 
        cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
522
 
 
523
 
        if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
524
 
        {
525
 
                gdk_cairo_set_source_rgba (cr, bg);
526
 
                cairo_fill_preserve (cr);
527
 
        }
528
 
 
529
 
        gdk_cairo_set_source_rgba (cr, border);
530
 
        cairo_stroke (cr);
531
 
 
532
 
        if (draw_bullet)
533
 
        {
534
 
                if (inconsistent)
535
 
                {
536
 
                        gdouble line_width = floor (radius * 2 / 3);
537
 
 
538
 
                        cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
539
 
                        cairo_set_line_width (cr, line_width);
540
 
 
541
 
                        cairo_move_to (cr, ceil (cx - radius/3.0 - line_width) + line_width, ceil (cy - line_width) + line_width);
542
 
                        cairo_line_to (cr, floor (cx + radius/3.0 + line_width) - line_width, ceil (cy - line_width) + line_width);
543
 
 
544
 
                        gdk_cairo_set_source_rgba (cr, fg);
545
 
                        cairo_stroke (cr);
546
 
                }
547
 
                else
548
 
                {
549
 
                        cairo_new_sub_path (cr);
550
 
                        cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
551
 
                        gdk_cairo_set_source_rgba (cr, fg);
552
 
                        cairo_fill (cr);
553
 
 
554
 
                        cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
555
 
                        cairo_set_source_rgba (cr, highlight.red, highlight.green, highlight.blue, 0.5);
556
 
                        cairo_fill (cr);
557
 
                }
558
 
        }
559
 
 
560
 
        cairo_restore (cr);
561
 
 
562
 
        gdk_rgba_free (bg);
563
 
        gdk_rgba_free (fg);
564
 
        gdk_rgba_free (border);
565
 
 
566
 
        gtk_symbolic_color_unref (sym);
567
 
        gtk_symbolic_color_unref (shade);
 
248
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
 
249
      (engine, cr, x, y, width, height);
568
250
}
569
251
 
570
252
static void
571
253
draw_tab_arcs (cairo_t *cr,
572
 
               gdouble curve_width,
573
 
               gdouble x,
574
 
               gdouble y,
575
 
               gdouble width,
576
 
               gdouble height)
 
254
               gdouble curve_width,
 
255
               gdouble x,
 
256
               gdouble y,
 
257
               gdouble width,
 
258
               gdouble height)
577
259
{
578
 
        cairo_arc (cr, 
579
 
                   curve_width, 6.0,
580
 
                   2.5,
581
 
                   G_PI, G_PI + G_PI_2);
 
260
  cairo_arc (cr, 
 
261
             curve_width, 6.0,
 
262
             2.5,
 
263
             G_PI, G_PI + G_PI_2);
582
264
 
583
 
        cairo_arc (cr,
584
 
                   width - curve_width, 6.0,
585
 
                   2.5,
586
 
                   G_PI + G_PI_2, 2 * G_PI);
 
265
  cairo_arc (cr,
 
266
             width - curve_width, 6.0,
 
267
             2.5,
 
268
             G_PI + G_PI_2, 2 * G_PI);
587
269
}
588
270
 
589
271
static void
590
272
draw_tab_shape_active (cairo_t *cr,
591
 
                       gdouble curve_width,
592
 
                       gdouble x,
593
 
                       gdouble y,
594
 
                       gdouble width,
595
 
                       gdouble height)
 
273
                       gdouble curve_width,
 
274
                       gdouble x,
 
275
                       gdouble y,
 
276
                       gdouble width,
 
277
                       gdouble height)
596
278
{
597
 
        cairo_move_to (cr, 0, height);
598
 
 
599
 
        draw_tab_arcs (cr, curve_width, x, y, width, height);
600
 
 
601
 
        cairo_line_to (cr, width, height);
 
279
  cairo_move_to (cr, 0, height);
 
280
 
 
281
  draw_tab_arcs (cr, curve_width, x, y, width, height);
 
282
 
 
283
  cairo_line_to (cr, width, height);
602
284
}
603
285
 
604
286
static void
605
287
render_notebook_extension (GtkThemingEngine *engine,
606
 
                           cairo_t        *cr,
607
 
                           gdouble         x,
608
 
                           gdouble         y,
609
 
                           gdouble         width,
610
 
                           gdouble         height,
611
 
                           GtkPositionType   gap_side)
 
288
                           cairo_t          *cr,
 
289
                           gdouble           x,
 
290
                           gdouble           y,
 
291
                           gdouble           width,
 
292
                           gdouble           height,
 
293
                           GtkPositionType   gap_side)
612
294
{
613
 
        gint tab_curvature;
614
 
        GdkRGBA *color, border_color, background_color;
615
 
        GtkStateFlags state;
616
 
        gdouble angle = 0;
617
 
        cairo_pattern_t *pattern = NULL, *background_pattern = NULL;
618
 
        cairo_matrix_t matrix;
619
 
 
620
 
        gtk_theming_engine_get_style (engine,
621
 
                                      "tab-curvature", &tab_curvature,
622
 
                                      NULL);
623
 
        state = gtk_theming_engine_get_state (engine);
624
 
        gtk_theming_engine_get_background_color (engine, state, &background_color);
625
 
        gtk_theming_engine_get_border_color (engine, state, &border_color);
626
 
        gtk_theming_engine_get (engine, state,
627
 
                                "-adwaita-selected-tab-color", &color,
628
 
                                "-adwaita-border-gradient", &pattern,
629
 
                                "background-image", &background_pattern,
630
 
                                NULL);
631
 
 
632
 
        cairo_save (cr);
633
 
        cairo_set_line_width (cr, 1.0);
634
 
 
635
 
        if (gap_side == GTK_POS_TOP) {
636
 
                angle = G_PI;
637
 
                cairo_translate (cr, width, height);
638
 
        }
639
 
 
640
 
        if (gap_side == GTK_POS_BOTTOM) {
641
 
                cairo_translate (cr,
642
 
                                 x + 0.5,
643
 
                                 (state & GTK_STATE_FLAG_ACTIVE) ?
644
 
                                 y + 1.0 : y);
645
 
        } else if (gap_side == GTK_POS_TOP) {
646
 
                cairo_translate (cr,
647
 
                                 x - 0.5,
648
 
                                 (state & GTK_STATE_FLAG_ACTIVE) ?
649
 
                                 y - 1.0 : y);
650
 
        }
651
 
 
652
 
        cairo_rotate (cr, angle);
653
 
 
654
 
        width -= 1.0;
655
 
        draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height);
656
 
 
657
 
        if (background_pattern != NULL) {
658
 
                cairo_matrix_init_scale (&matrix,
659
 
                                         1. / width,
660
 
                                         1. / height);
661
 
                cairo_pattern_set_matrix (background_pattern, &matrix);
662
 
                cairo_set_source (cr, background_pattern);
663
 
        } else {
664
 
                gdk_cairo_set_source_rgba (cr, &background_color);
665
 
        }
666
 
 
667
 
        cairo_fill (cr);
668
 
 
669
 
        if (state & GTK_STATE_FLAG_ACTIVE) {
670
 
                draw_tab_shape_active (cr, tab_curvature, 0, 0, width, 6.0);
671
 
                gdk_cairo_set_source_rgba (cr, color);
672
 
                cairo_fill (cr);
673
 
        }
674
 
 
675
 
        draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height);
676
 
 
677
 
        if (state & GTK_STATE_FLAG_ACTIVE) {
678
 
                style_pattern_set_matrix (pattern, width, height - 6.0);
679
 
                cairo_set_source (cr, pattern);
680
 
        } else {
681
 
                gdk_cairo_set_source_rgba (cr, &border_color);
682
 
        }
683
 
 
684
 
        cairo_stroke (cr);
685
 
 
686
 
        gdk_rgba_free (color);
687
 
 
688
 
        if (pattern != NULL) {
689
 
                cairo_pattern_destroy (pattern);
690
 
        }
691
 
 
692
 
        if (background_pattern != NULL) {
693
 
                cairo_pattern_destroy (background_pattern);
694
 
        }
695
 
        
696
 
        cairo_restore (cr);
 
295
  gint tab_curvature;
 
296
  GdkRGBA *color, border_color, background_color;
 
297
  GtkStateFlags state;
 
298
  gdouble angle = 0;
 
299
  cairo_pattern_t *pattern = NULL, *background_pattern = NULL;
 
300
  cairo_matrix_t matrix;
 
301
 
 
302
  gtk_theming_engine_get_style (engine,
 
303
                                "tab-curvature", &tab_curvature,
 
304
                                NULL);
 
305
  state = gtk_theming_engine_get_state (engine);
 
306
  gtk_theming_engine_get_background_color (engine, state, &background_color);
 
307
  gtk_theming_engine_get_border_color (engine, state, &border_color);
 
308
  gtk_theming_engine_get (engine, state,
 
309
                          "-adwaita-selected-tab-color", &color,
 
310
                          "-adwaita-border-gradient", &pattern,
 
311
                          "background-image", &background_pattern,
 
312
                          NULL);
 
313
 
 
314
  cairo_save (cr);
 
315
  cairo_set_line_width (cr, 1.0);
 
316
 
 
317
  if (gap_side == GTK_POS_TOP)
 
318
    {
 
319
      angle = G_PI;
 
320
      cairo_translate (cr, width, height);
 
321
    }
 
322
 
 
323
  if (gap_side == GTK_POS_BOTTOM)
 
324
    cairo_translate (cr,
 
325
                     x + 0.5,
 
326
                     (state & GTK_STATE_FLAG_ACTIVE) ?
 
327
                     y + 1.0 : y);
 
328
  else if (gap_side == GTK_POS_TOP)
 
329
    cairo_translate (cr,
 
330
                     x - 0.5,
 
331
                     (state & GTK_STATE_FLAG_ACTIVE) ?
 
332
                     y - 1.0 : y);
 
333
 
 
334
  cairo_rotate (cr, angle);
 
335
 
 
336
  width -= 1.0;
 
337
  draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height);
 
338
 
 
339
  if (background_pattern != NULL)
 
340
    {
 
341
      cairo_matrix_init_scale (&matrix,
 
342
                               1. / width,
 
343
                               1. / height);
 
344
      cairo_pattern_set_matrix (background_pattern, &matrix);
 
345
      cairo_set_source (cr, background_pattern);
 
346
    }
 
347
  else
 
348
    {
 
349
      gdk_cairo_set_source_rgba (cr, &background_color);
 
350
    }
 
351
 
 
352
  cairo_fill (cr);
 
353
 
 
354
  if (state & GTK_STATE_FLAG_ACTIVE)
 
355
    {
 
356
      draw_tab_shape_active (cr, tab_curvature, 0, 0, width, 6.0);
 
357
      gdk_cairo_set_source_rgba (cr, color);
 
358
      cairo_fill (cr);
 
359
    }
 
360
 
 
361
  draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height);
 
362
 
 
363
  if (state & GTK_STATE_FLAG_ACTIVE)
 
364
    {
 
365
      style_pattern_set_matrix (pattern, width, height - 6.0, FALSE);
 
366
      cairo_set_source (cr, pattern);
 
367
    }
 
368
  else
 
369
    {
 
370
      gdk_cairo_set_source_rgba (cr, &border_color);
 
371
    }
 
372
 
 
373
  cairo_stroke (cr);
 
374
 
 
375
  gdk_rgba_free (color);
 
376
 
 
377
  if (pattern != NULL)
 
378
    cairo_pattern_destroy (pattern);
 
379
 
 
380
  if (background_pattern != NULL)
 
381
    cairo_pattern_destroy (background_pattern);
 
382
 
 
383
  cairo_restore (cr);
697
384
}
698
385
 
699
386
static void
700
387
adwaita_engine_render_extension (GtkThemingEngine *engine,
701
 
                                 cairo_t          *cr,
702
 
                                 gdouble           x,
703
 
                                 gdouble           y,
704
 
                                 gdouble           width,
705
 
                                 gdouble           height,
706
 
                                 GtkPositionType   gap_side)
707
 
{
708
 
        GtkStateFlags state;
709
 
 
710
 
        if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) &&
711
 
            ((gap_side == GTK_POS_TOP) || (gap_side == GTK_POS_BOTTOM))) {
712
 
                render_notebook_extension (engine, cr, x, y, width, height, gap_side);
713
 
 
714
 
                return;
715
 
        }
716
 
 
717
 
        GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_extension (engine, cr,
718
 
                                                                                  x, y, width, height,
719
 
                                                                                  gap_side);
720
 
 
721
 
        state = gtk_theming_engine_get_state (engine);
722
 
 
723
 
        if (state & GTK_STATE_FLAG_ACTIVE)
724
 
        {
725
 
                GdkRGBA *fill;
726
 
 
727
 
                gtk_theming_engine_get (engine, state,
728
 
                                        "-adwaita-selected-tab-color", &fill,
729
 
                                        NULL);
730
 
 
731
 
                switch (gap_side)
732
 
                {
733
 
                case GTK_POS_BOTTOM:
734
 
                        _cairo_round_rectangle (cr, x + 1, y + 1, width - 2, 3, 0);
735
 
                        break;
736
 
                case GTK_POS_TOP:
737
 
                        _cairo_round_rectangle (cr, x + 1, y + height - 4, width - 2, 3, 0);
738
 
                        break;
739
 
                case GTK_POS_RIGHT:
740
 
                        _cairo_round_rectangle (cr, x + 1, y + 1, 3, height - 2, 0);
741
 
                        break;
742
 
                case GTK_POS_LEFT:
743
 
                        _cairo_round_rectangle (cr, x + width - 4, y + 1, 3, height - 2, 0);
744
 
                        break;
745
 
                }
746
 
 
747
 
                gdk_cairo_set_source_rgba (cr, fill);
748
 
                cairo_fill (cr);
749
 
 
750
 
                gdk_rgba_free (fill);
751
 
        }
752
 
}
753
 
 
754
 
static void
755
 
draw_menu_bar_item_shape (cairo_t *cr,
756
 
                          gdouble radius,
757
 
                          gdouble x,
758
 
                          gdouble y,
759
 
                          gdouble w,
760
 
                          gdouble h,
761
 
                          gboolean for_fill)
762
 
{
763
 
        /* draw a round rectangle without the bottom side */
764
 
        cairo_move_to (cr, x+radius, y);
765
 
        cairo_arc (cr, x+w-radius, y+radius, radius, G_PI * 1.5, G_PI * 2);
766
 
        cairo_line_to (cr, x+w, y+h);
767
 
 
768
 
        if (for_fill) {
769
 
                cairo_line_to (cr, x, y+h);
770
 
        } else {
771
 
                cairo_move_to (cr, x, y+h);
772
 
        }
773
 
 
774
 
        cairo_arc (cr, x+radius, y+radius, radius, G_PI, G_PI * 1.5);
775
 
}
776
 
 
777
 
static void
778
 
render_menubar_active_frame (GtkThemingEngine *engine,
779
 
                             cairo_t          *cr,
780
 
                             gdouble           x,
781
 
                             gdouble           y,
782
 
                             gdouble           w,
783
 
                             gdouble           h)
784
 
{
785
 
        GtkStateFlags state;
786
 
        GdkRGBA color;
787
 
        gint radius, border_width;
788
 
        GtkBorder *border;
789
 
 
790
 
        state = gtk_theming_engine_get_state (engine);
791
 
        gtk_theming_engine_get_border_color (engine, state, &color);
792
 
        gtk_theming_engine_get (engine, state,
793
 
                                "border-radius", &radius,
794
 
                                "border-width", &border,
795
 
                                NULL);
796
 
 
797
 
        border_width = MIN (MIN (border->top, border->bottom),
798
 
                            MIN (border->left, border->right));
799
 
 
800
 
        if (border_width > 1) {
801
 
                x += (gdouble) border_width / 2;
802
 
                y += (gdouble) border_width / 2;
803
 
                w -= border_width;
804
 
                h -= border_width;
805
 
        } else if (border_width == 1) {
806
 
                x += 0.5;
807
 
                y += 0.5;
808
 
                w -= 1;
809
 
                h -= 1;
 
388
                                 cairo_t          *cr,
 
389
                                 gdouble           x,
 
390
                                 gdouble           y,
 
391
                                 gdouble           width,
 
392
                                 gdouble           height,
 
393
                                 GtkPositionType   gap_side)
 
394
{
 
395
  GtkStateFlags state;
 
396
 
 
397
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) &&
 
398
      ((gap_side == GTK_POS_TOP) || (gap_side == GTK_POS_BOTTOM)))
 
399
    {
 
400
      render_notebook_extension (engine, cr, x, y, width, height, gap_side);
 
401
      return;
 
402
    }
 
403
 
 
404
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_extension
 
405
    (engine, cr,
 
406
     x, y, width, height,
 
407
     gap_side);
 
408
 
 
409
  state = gtk_theming_engine_get_state (engine);
 
410
 
 
411
  if (state & GTK_STATE_FLAG_ACTIVE)
 
412
    {
 
413
      GdkRGBA *fill;
 
414
 
 
415
      gtk_theming_engine_get (engine, state,
 
416
                              "-adwaita-selected-tab-color", &fill,
 
417
                              NULL);
 
418
 
 
419
      switch (gap_side)
 
420
        {
 
421
        case GTK_POS_BOTTOM:
 
422
          cairo_rectangle (cr,
 
423
                           x + 1, y + 1,
 
424
                           width - 2, 3);
 
425
          break;
 
426
        case GTK_POS_TOP:
 
427
          cairo_rectangle (cr,
 
428
                           x + 1, y + height - 4,
 
429
                           width - 2, 3);
 
430
          break;
 
431
        case GTK_POS_RIGHT:
 
432
          cairo_rectangle (cr,
 
433
                           x + 1, y + 1,
 
434
                           3, height - 2);
 
435
          break;
 
436
        case GTK_POS_LEFT:
 
437
          cairo_rectangle (cr,
 
438
                           x + width - 4, y + 1,
 
439
                           3, height - 2);
 
440
          break;
810
441
        }
811
442
 
812
 
        cairo_save (cr);
813
 
 
814
 
        cairo_set_line_width (cr, border_width);
815
 
        draw_menu_bar_item_shape (cr, radius, x, y, w, h, FALSE);
816
 
 
817
 
        gdk_cairo_set_source_rgba (cr, &color);
818
 
        cairo_stroke (cr);
819
 
 
820
 
        cairo_restore (cr);
821
 
 
822
 
        gtk_border_free (border);
823
 
}
824
 
 
825
 
static void
826
 
render_frame_default (GtkThemingEngine *engine,
827
 
                      cairo_t *cr,
828
 
                      gdouble x,
829
 
                      gdouble y,
830
 
                      gdouble width,
831
 
                      gdouble height)
832
 
{
833
 
        cairo_pattern_t *pattern = NULL;
834
 
        GtkStateFlags state;
835
 
        GtkBorder *border;
836
 
        gint line_width, border_radius;
837
 
        GtkBorderStyle border_style;
838
 
 
839
 
        state = gtk_theming_engine_get_state (engine);
840
 
 
841
 
        gtk_theming_engine_get (engine, state,
842
 
                                "-adwaita-border-gradient", &pattern,
843
 
                                "border-style", &border_style,
844
 
                                NULL);
845
 
 
846
 
        if (pattern == NULL || border_style == GTK_BORDER_STYLE_NONE) {
847
 
                GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
848
 
                        (engine, cr,
849
 
                         x, y, width, height);
850
 
 
851
 
                return;
852
 
        }
853
 
 
854
 
        cairo_save (cr);
855
 
 
856
 
        gtk_theming_engine_get (engine, state,
857
 
                                "border-radius", &border_radius,
858
 
                                "border-width", &border,
859
 
                                NULL);
860
 
 
861
 
        line_width = MIN (MIN (border->top, border->bottom),
862
 
                          MIN (border->left, border->right));
863
 
        style_pattern_set_matrix (pattern, width, height);
864
 
 
865
 
        cairo_set_line_width (cr, line_width);
866
 
        _cairo_round_rectangle (cr,
867
 
                                x + line_width / 2.0,
868
 
                                y + line_width / 2.0,
869
 
                                width - line_width,
870
 
                                height - line_width,
871
 
                                border_radius);
872
 
        cairo_set_source (cr, pattern);
873
 
 
874
 
        cairo_stroke (cr);
875
 
 
876
 
        cairo_restore (cr);
877
 
 
878
 
        cairo_pattern_destroy (pattern);
879
 
        gtk_border_free (border);
 
443
      gdk_cairo_set_source_rgba (cr, fill);
 
444
      cairo_fill (cr);
 
445
 
 
446
      gdk_rgba_free (fill);
 
447
    }
880
448
}
881
449
 
882
450
static void
883
451
adwaita_engine_render_frame (GtkThemingEngine *engine,
884
 
                             cairo_t          *cr,
885
 
                             gdouble           x,
886
 
                             gdouble           y,
887
 
                             gdouble           width,
888
 
                             gdouble           height)
889
 
{
890
 
        const GtkWidgetPath *path;
891
 
        GtkRegionFlags flags = 0;
892
 
        gint len;
893
 
        GtkStateFlags state;    
894
 
 
895
 
        state = gtk_theming_engine_get_state (engine);
896
 
 
897
 
        if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
898
 
            gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUBAR)) {
899
 
                render_menubar_active_frame (engine, cr, x, y, width, height);
900
 
 
901
 
                return;
902
 
        }
903
 
        
904
 
        path = gtk_theming_engine_get_path (engine);
905
 
        len = gtk_widget_path_length (path);
906
 
 
907
 
        cairo_save (cr);
908
 
 
909
 
        if (gtk_widget_path_iter_has_region (path, len - 2,
910
 
                                             GTK_STYLE_REGION_COLUMN_HEADER,
911
 
                                             &flags))
912
 
        {
913
 
                GdkRGBA color;
914
 
 
915
 
                if ((flags & GTK_REGION_LAST) != 0)
916
 
                        goto out;
917
 
 
918
 
                /* Column header */
919
 
                if (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL)
920
 
                {
921
 
                        cairo_move_to (cr, x + 0.5, y + 2);
922
 
                        cairo_line_to (cr, x + 0.5, y + height - 4);
923
 
                }
924
 
                else
925
 
                {
926
 
                        cairo_move_to (cr, x + width - 0.5, y + 2);
927
 
                        cairo_line_to (cr, x + width - 0.5, y + height - 4);
928
 
                }
929
 
 
930
 
                gtk_theming_engine_get_border_color (engine, state, &color);
931
 
 
932
 
                cairo_set_line_width (cr, 1);
933
 
                gdk_cairo_set_source_rgba (cr, &color);
934
 
                cairo_stroke (cr);
935
 
        }
936
 
        else
937
 
        {
938
 
                if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
939
 
                    gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
940
 
                {
941
 
                        /* Render GtkScale trough thinner */
942
 
                        if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
943
 
                        {
944
 
                                y += height / 2.0 - 2.0;
945
 
                                height = 4;
946
 
                        }
947
 
                        else
948
 
                        {
949
 
                                x += width / 2.0 - 2.0;
950
 
                                width = 4;
951
 
                        }
952
 
                }
953
 
 
954
 
                if (gtk_widget_path_is_type (path, GTK_TYPE_PROGRESS_BAR) &&
955
 
                    gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH)) {
956
 
                        GtkBorder *border_width;
957
 
                        gint border_line;
958
 
 
959
 
                        /* draw the border inside the trough itself, so it will
960
 
                         * be overdrawn by the fill.
961
 
                         */
962
 
                        gtk_theming_engine_get (engine, state,
963
 
                                                "border-width", &border_width,
964
 
                                                NULL);
965
 
 
966
 
                        border_line = MIN (MIN (border_width->top, border_width->bottom),
967
 
                                           MIN (border_width->left, border_width->right));
968
 
 
969
 
                        y += border_line;
970
 
                        x += border_line;
971
 
                        width -= 2 * border_line;
972
 
                        height -= 2 * border_line;
973
 
 
974
 
                        gtk_border_free (border_width);
975
 
                }
976
 
 
977
 
                render_frame_default (engine, cr, x, y, width, height);
978
 
        }
979
 
 
980
 
out:
981
 
        cairo_restore (cr);
982
 
}
983
 
 
984
 
static void
985
 
render_menubar_active_background (GtkThemingEngine *engine,
986
 
                                  cairo_t          *cr,
987
 
                                  gdouble           x,
988
 
                                  gdouble           y,
989
 
                                  gdouble           w,
990
 
                                  gdouble           h)
991
 
{
992
 
        GtkStateFlags state;
993
 
        GdkRGBA color;
994
 
        gint radius;
995
 
        GtkBorder *border;
996
 
 
997
 
        state = gtk_theming_engine_get_state (engine);
998
 
        gtk_theming_engine_get_border_color (engine, state, &color);
999
 
        gtk_theming_engine_get (engine, state,
1000
 
                                "border-radius", &radius,
1001
 
                                "border-width", &border,
1002
 
                                NULL);
1003
 
 
1004
 
        gtk_theming_engine_get_background_color (engine, state, &color);
1005
 
 
1006
 
        /* omit all the border but the bottom line */
1007
 
        x += border->left;
1008
 
        y += border->top;
1009
 
        w -= border->left + border->right;
1010
 
        h -= border->top;
1011
 
 
1012
 
        cairo_save (cr);
1013
 
        cairo_translate (cr, x, y);
1014
 
 
1015
 
        draw_menu_bar_item_shape (cr, radius, 0, 0, w, h, TRUE);
1016
 
 
1017
 
        gdk_cairo_set_source_rgba (cr, &color);
1018
 
        cairo_fill (cr);
1019
 
 
1020
 
        cairo_restore (cr);
1021
 
 
1022
 
        gtk_border_free (border);
 
452
                             cairo_t          *cr,
 
453
                             gdouble           x,
 
454
                             gdouble           y,
 
455
                             gdouble           width,
 
456
                             gdouble           height)
 
457
{
 
458
  adwaita_trim_allocation_for_scale (engine,
 
459
                                     &x, &y,
 
460
                                     &width, &height);
 
461
 
 
462
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
 
463
    (engine, cr, x, y,
 
464
     width, height);
1023
465
}
1024
466
 
1025
467
static void
1026
468
adwaita_engine_render_background (GtkThemingEngine *engine,
1027
 
                                  cairo_t          *cr,
1028
 
                                  gdouble           x,
1029
 
                                  gdouble           y,
1030
 
                                  gdouble           width,
1031
 
                                  gdouble           height)
 
469
                                  cairo_t          *cr,
 
470
                                  gdouble           x,
 
471
                                  gdouble           y,
 
472
                                  gdouble           width,
 
473
                                  gdouble           height)
1032
474
{
1033
 
        const GtkWidgetPath *path;
1034
 
        GtkStateFlags state;
1035
 
 
1036
 
        path = gtk_theming_engine_get_path (engine);
1037
 
        state = gtk_theming_engine_get_state (engine);
1038
 
 
1039
 
        if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
1040
 
            gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUBAR)) {
1041
 
                render_menubar_active_background (engine, cr, x, y, width, height);
1042
 
 
1043
 
                return;
1044
 
        }
1045
 
 
1046
 
        if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
1047
 
            gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
1048
 
        {
1049
 
                /* Render GtkScale trough thinner */
1050
 
                if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
1051
 
                {
1052
 
                        y += height / 2 - 2;
1053
 
                        height = 4;
1054
 
                }
1055
 
                else
1056
 
                {
1057
 
                        x += width / 2 - 2;
1058
 
                        width = 4;
1059
 
                }
1060
 
        }
1061
 
 
1062
 
        if (gtk_widget_path_is_type (path, GTK_TYPE_PROGRESS_BAR) &&
1063
 
            gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH)) {
1064
 
                GtkBorder *border_width;
1065
 
                gint border_line;
1066
 
 
1067
 
                /* draw the border inside the trough itself, so it will
1068
 
                 * be overdrawn by the fill.
1069
 
                 */
1070
 
                gtk_theming_engine_get (engine, state,
1071
 
                                        "border-width", &border_width,
1072
 
                                        NULL);
1073
 
 
1074
 
                border_line = MIN (MIN (border_width->top, border_width->bottom),
1075
 
                                   MIN (border_width->left, border_width->right));
1076
 
 
1077
 
                y += border_line;
1078
 
                x += border_line;
1079
 
                width -= 2 * border_line;
1080
 
                height -= 2 * border_line;
1081
 
 
1082
 
                gtk_border_free (border_width);
1083
 
        }
1084
 
 
1085
 
        GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background (engine, cr, x, y,
1086
 
                                                                                   width, height);
 
475
  adwaita_trim_allocation_for_scale (engine,
 
476
                                     &x, &y,
 
477
                                     &width, &height);
 
478
 
 
479
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
 
480
    (engine, cr, x, y,
 
481
     width, height);
1087
482
}
1088
483
 
1089
484
static void
1090
485
adwaita_engine_render_expander (GtkThemingEngine *engine,
1091
 
                                cairo_t          *cr,
1092
 
                                gdouble           x,
1093
 
                                gdouble           y,
1094
 
                                gdouble           width,
1095
 
                                gdouble           height)
 
486
                                cairo_t          *cr,
 
487
                                gdouble           x,
 
488
                                gdouble           y,
 
489
                                gdouble           width,
 
490
                                gdouble           height)
1096
491
{
1097
 
        GdkRGBA border, bg, fg;
1098
 
        GtkStateFlags state;
1099
 
        gint side;
1100
 
 
1101
 
        side = MIN (width, height);
1102
 
 
1103
 
        x += ((int) width / 2) - (side / 2);
1104
 
        y += ((int) height / 2) - (side / 2);
1105
 
 
1106
 
        state = gtk_theming_engine_get_state (engine);
1107
 
 
1108
 
        gtk_theming_engine_get_border_color (engine, state, &border);
1109
 
        gtk_theming_engine_get_background_color (engine, state, &bg);
1110
 
        gtk_theming_engine_get_color (engine, state, &fg);
1111
 
 
1112
 
        cairo_save (cr);
1113
 
 
1114
 
        cairo_set_line_width (cr, 1);
1115
 
 
1116
 
        _cairo_round_rectangle (cr, x + 0.5, y + 0.5, side, side, 2);
1117
 
        gdk_cairo_set_source_rgba (cr, &bg);
1118
 
        cairo_fill_preserve (cr);
1119
 
 
1120
 
        gdk_cairo_set_source_rgba (cr, &border);
1121
 
        cairo_stroke (cr);
1122
 
 
1123
 
        cairo_set_line_width (cr, 1);
1124
 
        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1125
 
        gdk_cairo_set_source_rgba (cr, &fg);
1126
 
 
1127
 
        cairo_move_to (cr, x + 3, y + side / 2 + 0.5);
1128
 
        cairo_line_to (cr, x + side - 2, y + side / 2 + 0.5);
1129
 
 
1130
 
        if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
1131
 
        {
1132
 
                cairo_move_to (cr, x + side / 2 + 0.5, y + 3);
1133
 
                cairo_line_to (cr, x + side / 2 + 0.5, y + side - 2);
1134
 
        }
1135
 
 
1136
 
        cairo_stroke (cr);
1137
 
 
1138
 
        cairo_restore (cr);
 
492
  GdkRGBA fg;
 
493
  GtkStateFlags state;
 
494
  gdouble side, offset;
 
495
  gint line_width;
 
496
  GtkBorder border;
 
497
  const GtkWidgetPath *path = gtk_theming_engine_get_path (engine);
 
498
 
 
499
  side = floor (MIN (width, height));
 
500
 
 
501
  if (gtk_widget_path_is_type (path, GTK_TYPE_TREE_VIEW) &&
 
502
      (side == 17))
 
503
    {
 
504
      /* HACK: draw the expander as if it was 11px instead of the allocated 17px,
 
505
       * so that we can have a bit of padding between the view edge and the
 
506
       * expander itself.
 
507
       */
 
508
      x += 3;
 
509
      y += 3;
 
510
      width -= 6;
 
511
      height -= 6;
 
512
      side -= 6;
 
513
    }
 
514
 
 
515
  x += width / 2 - side / 2;
 
516
  y += height / 2 - side / 2;
 
517
 
 
518
  x = floor (x);
 
519
  y = floor (y);
 
520
 
 
521
  /* make sure the rendered side length is always odd */
 
522
  if (((gint) side % 2) == 0)
 
523
    side -= 1.0;
 
524
 
 
525
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
 
526
    (engine, cr, x, y, side, side);
 
527
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
 
528
    (engine, cr, x, y, side, side);
 
529
 
 
530
  state = gtk_theming_engine_get_state (engine);
 
531
  gtk_theming_engine_get_color (engine, state, &fg);
 
532
  gtk_theming_engine_get_border (engine, state, &border);
 
533
 
 
534
  line_width = 1;
 
535
  offset = (1 + line_width / 2.0);
 
536
 
 
537
  cairo_save (cr);
 
538
 
 
539
  cairo_set_line_width (cr, line_width);
 
540
  cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
 
541
  gdk_cairo_set_source_rgba (cr, &fg);
 
542
 
 
543
  cairo_move_to (cr,
 
544
                 x + border.left + offset,
 
545
                 y + side / 2);
 
546
  cairo_line_to (cr,
 
547
                 x + side - (border.right + offset),
 
548
                 y + side / 2);
 
549
 
 
550
  if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
 
551
    {
 
552
      cairo_move_to (cr,
 
553
                     x + side / 2,
 
554
                     y + border.top + offset);
 
555
      cairo_line_to (cr,
 
556
                     x + side / 2,
 
557
                     y + side - (border.bottom + offset));
 
558
    }
 
559
 
 
560
  cairo_stroke (cr);
 
561
 
 
562
  cairo_restore (cr);
1139
563
}
1140
564
 
1141
565
static void
1142
566
adwaita_engine_render_activity (GtkThemingEngine *engine,
1143
 
                                cairo_t          *cr,
1144
 
                                gdouble           x,
1145
 
                                gdouble           y,
1146
 
                                gdouble           width,
1147
 
                                gdouble           height)
1148
 
{
1149
 
        const GtkWidgetPath *path;
1150
 
 
1151
 
        cairo_save (cr);
1152
 
        path = gtk_theming_engine_get_path (engine);
1153
 
 
1154
 
        if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
1155
 
            gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
1156
 
        {
1157
 
                /* Render GtkScale fill level thinner */
1158
 
                if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
1159
 
                {
1160
 
                        y += height / 2.0 - 2.0;
1161
 
                        height = 4;
1162
 
                }
1163
 
                else
1164
 
                {
1165
 
                        x += width / 2.0 - 2.0;
1166
 
                        width = 4;
1167
 
                }
1168
 
        }
1169
 
 
1170
 
        GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_activity (engine, cr,
1171
 
                                                                                 x, y, width, height);
1172
 
 
1173
 
        if (gtk_widget_path_is_type (path, GTK_TYPE_PROGRESS_BAR) &&
1174
 
            gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
1175
 
        {
1176
 
                cairo_pattern_t *pattern;
1177
 
 
1178
 
                pattern = cairo_pattern_create_linear (0, 0, 20, 20);
1179
 
                cairo_pattern_add_color_stop_rgba (pattern, 0, 0, 0, 0, 0);
1180
 
                cairo_pattern_add_color_stop_rgba (pattern, 0.49, 0, 0, 0, 0);
1181
 
                cairo_pattern_add_color_stop_rgba (pattern, 0.5, 0, 0, 0, 0.1);
1182
 
                cairo_pattern_add_color_stop_rgba (pattern, 0.99, 0, 0, 0, 0.1);
1183
 
 
1184
 
                cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
1185
 
                cairo_rectangle (cr, x, y, width, height);
1186
 
                cairo_set_source (cr, pattern);
1187
 
                cairo_fill (cr);
1188
 
 
1189
 
                cairo_pattern_destroy (pattern);
1190
 
        }
1191
 
 
1192
 
        cairo_restore (cr);
1193
 
}
1194
 
 
1195
 
static void
1196
 
draw_round_slider (cairo_t *cr,
1197
 
                   gdouble  width,
1198
 
                   gdouble  height)
1199
 
{
1200
 
        cairo_arc (cr, (width) / 2.0, (height) / 2.0,
1201
 
                   MIN (height / 2.0, width / 2.0) - 0.5,
1202
 
                   0, 2 * G_PI);
1203
 
        cairo_close_path (cr);  
1204
 
}
1205
 
 
1206
 
static void
1207
 
draw_mark_slider (cairo_t *cr,
1208
 
                  gdouble  width,
1209
 
                  gdouble  height,
1210
 
                  gboolean marks_below,
1211
 
                  GtkOrientation orientation)
1212
 
{
1213
 
        cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
1214
 
 
1215
 
        if (marks_below) {
1216
 
                if (orientation == GTK_ORIENTATION_HORIZONTAL) {
1217
 
                        cairo_move_to (cr, 0, height / 2.0 + 3.0);
1218
 
                        cairo_arc (cr, 2.5, 3.5,
1219
 
                                   2.0,
1220
 
                                   G_PI, G_PI + G_PI_2);
1221
 
                        
1222
 
                        cairo_arc (cr, width - 2.5, 3.5,
1223
 
                                   2.0,
1224
 
                                   G_PI + G_PI_2, 2 * G_PI);
1225
 
 
1226
 
                        cairo_line_to (cr, width, height / 2.0 + 3.0);
1227
 
                        cairo_line_to (cr, width / 2.0, height);
1228
 
                        cairo_line_to (cr, 0, height / 2.0 + 3.0);
1229
 
 
1230
 
                        cairo_close_path (cr);
1231
 
                } else {
1232
 
                        cairo_move_to (cr, width / 2.0, 0);
1233
 
                        cairo_arc (cr, width - 2.5, 2.5,
1234
 
                                   2.0,
1235
 
                                   G_PI + G_PI_2, 2 * G_PI);
1236
 
 
1237
 
                        cairo_arc (cr, width - 2.5, height - 2.5,
1238
 
                                   2.0,
1239
 
                                   0, G_PI_2);
1240
 
 
1241
 
                        cairo_line_to (cr, width / 2.0, height);
1242
 
                        cairo_line_to (cr, 0, height / 2.0);
1243
 
                        cairo_line_to (cr, width / 2.0, 0);
1244
 
 
1245
 
                        cairo_close_path (cr);
1246
 
                }
1247
 
        } else {
1248
 
                if (orientation == GTK_ORIENTATION_HORIZONTAL) {
1249
 
                        cairo_move_to (cr, width, height / 2.0 - 3.0);
1250
 
                        cairo_arc (cr, width - 2.5, height - 3.5,
1251
 
                                   2.0,
1252
 
                                   0, G_PI_2);
1253
 
 
1254
 
                        cairo_arc (cr, 2.5, height - 3.5,
1255
 
                                   2.0,
1256
 
                                   G_PI_2, G_PI);
1257
 
 
1258
 
                        cairo_line_to (cr, 0, height / 2.0 - 3.0);
1259
 
                        cairo_line_to (cr, width / 2.0, 0);
1260
 
                        cairo_line_to (cr, width, height / 2.0 - 3.0);
1261
 
 
1262
 
                        cairo_close_path (cr);
1263
 
                } else {
1264
 
                        cairo_move_to (cr, width / 2.0, height);
1265
 
                        cairo_arc (cr, 2.5, height - 2.5,
1266
 
                                   2.0,
1267
 
                                   G_PI_2, G_PI);
1268
 
 
1269
 
                        cairo_arc (cr, 2.5, 2.5,
1270
 
                                   2.0,
1271
 
                                   G_PI, G_PI + G_PI_2);
1272
 
 
1273
 
                        cairo_line_to (cr, width / 2.0, 0);
1274
 
                        cairo_line_to (cr, width, height / 2.0);
1275
 
                        cairo_line_to (cr, width / 2.0, height);
1276
 
 
1277
 
                        cairo_close_path (cr);
1278
 
                }
1279
 
        }
 
567
                                cairo_t          *cr,
 
568
                                gdouble           x,
 
569
                                gdouble           y,
 
570
                                gdouble           width,
 
571
                                gdouble           height)
 
572
{
 
573
  GtkStateFlags state;
 
574
 
 
575
  cairo_save (cr);
 
576
  state = gtk_theming_engine_get_state (engine);
 
577
 
 
578
  adwaita_trim_allocation_for_scale (engine,
 
579
                                     &x, &y,
 
580
                                     &width, &height);
 
581
 
 
582
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_activity
 
583
    (engine, cr,
 
584
     x, y, width, height);
 
585
 
 
586
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
 
587
    {
 
588
      cairo_pattern_t *pattern = NULL;
 
589
 
 
590
      gtk_theming_engine_get (engine, state,
 
591
                              "-adwaita-progressbar-pattern", &pattern,
 
592
                              NULL);
 
593
 
 
594
      if (pattern != NULL)
 
595
        {
 
596
          style_pattern_set_matrix (pattern, 20, 20, TRUE);
 
597
          cairo_rectangle (cr, x, y, width, height);
 
598
          cairo_set_source (cr, pattern);
 
599
          cairo_fill (cr);
 
600
 
 
601
          cairo_pattern_destroy (pattern);
 
602
        }
 
603
    }
 
604
 
 
605
  cairo_restore (cr);
1280
606
}
1281
607
 
1282
608
static void
1283
609
render_switch_lines (GtkThemingEngine *engine,
1284
 
                     cairo_t *cr,
1285
 
                     gdouble x,
1286
 
                     gdouble y,
1287
 
                     gdouble width,
1288
 
                     gdouble height,
1289
 
                     GtkOrientation orientation)
 
610
                     cairo_t *cr,
 
611
                     gdouble x,
 
612
                     gdouble y,
 
613
                     gdouble width,
 
614
                     gdouble height,
 
615
                     GtkOrientation orientation)
1290
616
{
1291
 
        GtkStateFlags state;
1292
 
        GdkRGBA *lines_color;
1293
 
 
1294
 
        state = gtk_theming_engine_get_state (engine);
1295
 
 
1296
 
        if (state & GTK_STATE_FLAG_INSENSITIVE) {
1297
 
                return;
1298
 
        }
1299
 
 
1300
 
        gtk_theming_engine_get (engine, state,
1301
 
                                "-adwaita-switch-grip-color", &lines_color,
1302
 
                                NULL);
1303
 
 
1304
 
        cairo_save (cr);
1305
 
 
1306
 
        cairo_translate (cr,
1307
 
                         x + width / 2.0 - 4.0,
1308
 
                         y + height / 2.0 - 3.0);
1309
 
 
1310
 
        cairo_move_to (cr, 0.0, 0.0);
1311
 
        cairo_set_line_width (cr, 2.0);
1312
 
        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1313
 
 
1314
 
        cairo_line_to (cr, 0.0, 6.0);
1315
 
        cairo_move_to (cr, 4.0, 0.0);
1316
 
        cairo_line_to (cr, 4.0, 6.0);
1317
 
        cairo_move_to (cr, 8.0, 0.0);
1318
 
        cairo_line_to (cr, 8.0, 6.0);
1319
 
 
1320
 
        gdk_cairo_set_source_rgba (cr, lines_color);
1321
 
        cairo_stroke (cr);
1322
 
 
1323
 
        cairo_restore (cr);
1324
 
 
1325
 
        gdk_rgba_free (lines_color);
 
617
  GtkStateFlags state;
 
618
  GdkRGBA *lines_color;
 
619
 
 
620
  state = gtk_theming_engine_get_state (engine);
 
621
 
 
622
  if (state & GTK_STATE_FLAG_INSENSITIVE)
 
623
    return;
 
624
 
 
625
  gtk_theming_engine_get (engine, state,
 
626
                          "-adwaita-switch-grip-color", &lines_color,
 
627
                          NULL);
 
628
 
 
629
  cairo_save (cr);
 
630
 
 
631
  cairo_translate (cr,
 
632
                   x + width / 2.0 - 4.0,
 
633
                   y + height / 2.0 - 3.0);
 
634
 
 
635
  cairo_move_to (cr, 0.0, 0.0);
 
636
  cairo_set_line_width (cr, 2.0);
 
637
  cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
 
638
 
 
639
  cairo_line_to (cr, 0.0, 6.0);
 
640
  cairo_move_to (cr, 4.0, 0.0);
 
641
  cairo_line_to (cr, 4.0, 6.0);
 
642
  cairo_move_to (cr, 8.0, 0.0);
 
643
  cairo_line_to (cr, 8.0, 6.0);
 
644
 
 
645
  gdk_cairo_set_source_rgba (cr, lines_color);
 
646
  cairo_stroke (cr);
 
647
 
 
648
  cairo_restore (cr);
 
649
 
 
650
  gdk_rgba_free (lines_color);
1326
651
}
1327
652
 
1328
653
static void
1329
654
adwaita_engine_render_slider (GtkThemingEngine *engine,
1330
 
                              cairo_t          *cr,
1331
 
                              gdouble           x,
1332
 
                              gdouble           y,
1333
 
                              gdouble           width,
1334
 
                              gdouble           height,
1335
 
                              GtkOrientation    orientation)
 
655
                              cairo_t          *cr,
 
656
                              gdouble           x,
 
657
                              gdouble           y,
 
658
                              gdouble           width,
 
659
                              gdouble           height,
 
660
                              GtkOrientation    orientation)
1336
661
{
1337
 
        const GtkWidgetPath *path;
1338
 
 
1339
 
        path = gtk_theming_engine_get_path (engine);
1340
 
        cairo_save (cr);
1341
 
 
1342
 
        if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE))
1343
 
        {
1344
 
                cairo_pattern_t *pattern, *border_pattern;
1345
 
                cairo_matrix_t matrix;
1346
 
                GtkStateFlags state;
1347
 
                GdkRGBA color;
1348
 
                gboolean marks_above = FALSE, marks_below = FALSE;
1349
 
 
1350
 
                if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE)) {
1351
 
                        marks_above = TRUE;
1352
 
                } else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW)) {
1353
 
                        marks_below = TRUE;
1354
 
                }
1355
 
 
1356
 
                cairo_translate (cr, x, y);
1357
 
 
1358
 
                if ((marks_above && marks_below) || (!marks_above && !marks_below)) {
1359
 
                        draw_round_slider (cr, width, height);
1360
 
                } else {
1361
 
                        draw_mark_slider (cr, width, height, marks_below, orientation);
1362
 
                }
1363
 
 
1364
 
                state = gtk_theming_engine_get_state (engine);
1365
 
                cairo_set_line_width (cr, 1.0);
1366
 
 
1367
 
                gtk_theming_engine_get (engine, state,
1368
 
                                        "background-image", &pattern,
1369
 
                                        NULL);
1370
 
 
1371
 
                if (pattern != NULL) {
1372
 
                        style_pattern_set_matrix (pattern, width, height);
1373
 
                        cairo_set_source (cr, pattern);
1374
 
                } else {
1375
 
                        gtk_theming_engine_get_background_color (engine, state, &color);
1376
 
                        gdk_cairo_set_source_rgba (cr, &color);
1377
 
                }
1378
 
 
1379
 
                cairo_fill_preserve (cr);
1380
 
 
1381
 
                gtk_theming_engine_get (engine, state,
1382
 
                                        "-adwaita-border-gradient", &border_pattern,
1383
 
                                        NULL);
1384
 
 
1385
 
                if (border_pattern != NULL) {
1386
 
                        style_pattern_set_matrix (border_pattern, width, height);
1387
 
                        cairo_set_source (cr, border_pattern);
1388
 
                } else {
1389
 
                        gtk_theming_engine_get_border_color (engine, state, &color);
1390
 
                        gdk_cairo_set_source_rgba (cr, &color);
1391
 
                }
1392
 
 
1393
 
                cairo_stroke (cr);
1394
 
 
1395
 
                if (pattern != NULL) {
1396
 
                        cairo_pattern_destroy (pattern);
1397
 
                }
1398
 
 
1399
 
                if (border_pattern != NULL) {
1400
 
                        cairo_pattern_destroy (border_pattern);
1401
 
                }
1402
 
        }
1403
 
        else
1404
 
        {
1405
 
                GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_slider (engine, cr,
1406
 
                                                                                       x, y, width, height,
1407
 
                                                                                       orientation);
1408
 
 
1409
 
                if (gtk_widget_path_is_type (path, GTK_TYPE_SWITCH)) {
1410
 
                        render_switch_lines (engine, cr, x, y, width, height, orientation);
1411
 
                }
1412
 
        }
1413
 
 
1414
 
        cairo_restore (cr);
 
662
  const GtkWidgetPath *path;
 
663
 
 
664
  GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_slider
 
665
    (engine, cr,
 
666
     x, y, width, height,
 
667
     orientation);
 
668
 
 
669
  path = gtk_theming_engine_get_path (engine);
 
670
 
 
671
  if (gtk_widget_path_is_type (path, GTK_TYPE_SWITCH))
 
672
    render_switch_lines (engine, cr, x, y, width, height, orientation);
1415
673
}
1416
674
 
1417
675
static void
1418
676
adwaita_engine_render_handle (GtkThemingEngine *engine,
1419
 
                              cairo_t          *cr,
1420
 
                              gdouble           x,
1421
 
                              gdouble           y,
1422
 
                              gdouble           width,
1423
 
                              gdouble           height)
1424
 
{
1425
 
        if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
1426
 
        {
1427
 
                GdkRGBA bg;
1428
 
                GtkJunctionSides sides;
1429
 
                GtkStateFlags state;
1430
 
                int lx, ly;
1431
 
                int x_down;
1432
 
                int y_down;
1433
 
                int dots;
1434
 
 
1435
 
                state = gtk_theming_engine_get_state (engine);
1436
 
                gtk_theming_engine_get_background_color (engine, state, &bg);
1437
 
 
1438
 
                /* The number of dots fitting into the area. Just hardcoded to 3 right now. */
1439
 
                /* dots = MIN (width - 2, height - 2) / 3; */
1440
 
                dots = 3;
1441
 
 
1442
 
                cairo_save (cr);
1443
 
 
1444
 
                sides = gtk_theming_engine_get_junction_sides (engine);
1445
 
 
1446
 
                switch (sides)
1447
 
                {
1448
 
                case GTK_JUNCTION_CORNER_TOPRIGHT:
1449
 
                        x_down = 0;
1450
 
                        y_down = 0;
1451
 
                        cairo_translate (cr, x + width - 4*dots, y + 1);
1452
 
                        break;
1453
 
                case GTK_JUNCTION_CORNER_BOTTOMRIGHT:
1454
 
                        x_down = 0;
1455
 
                        y_down = 1;
1456
 
                        cairo_translate (cr, x + width - 4*dots, y + height + 1 - 4*dots);
1457
 
                        break;
1458
 
                case GTK_JUNCTION_CORNER_BOTTOMLEFT:
1459
 
                        x_down = 1;
1460
 
                        y_down = 1;
1461
 
                        cairo_translate (cr, x + 2, y + height + 1 - 4*dots);
1462
 
                        break;
1463
 
                case GTK_JUNCTION_CORNER_TOPLEFT:
1464
 
                        x_down = 1;
1465
 
                        y_down = 0;
1466
 
                        cairo_translate (cr, x + 2, y + 1);
1467
 
                        break;
1468
 
                default:
1469
 
                        /* Not implemented. */
1470
 
                        return;
1471
 
                }
1472
 
 
1473
 
                for (lx = 0; lx < dots; lx++) /* horizontally */
1474
 
                {
1475
 
                        for (ly = 0; ly <= lx; ly++) /* vertically */
1476
 
                        {
1477
 
                                int mx, my;
1478
 
                                mx = x_down * dots + (1 - x_down * 2) * lx - x_down;
1479
 
                                my = y_down * dots + (1 - y_down * 2) * ly - y_down;
1480
 
 
1481
 
                                gdk_cairo_set_source_rgba (cr, &bg);
1482
 
                                cairo_arc (cr,
1483
 
                                           mx * 4 - 1 + 1.5,
1484
 
                                           my * 4 - 1 + 1.5,
1485
 
                                           1.5,
1486
 
                                           0, G_PI * 2.0);
1487
 
 
1488
 
                                cairo_fill (cr);
1489
 
                        }
1490
 
                }
1491
 
 
1492
 
                cairo_restore (cr);
1493
 
        } else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR)) {
1494
 
                GdkRGBA bg, fg;
1495
 
                GtkStateFlags state;
1496
 
                gdouble xx, yy;
1497
 
 
1498
 
                state = gtk_theming_engine_get_state (engine);
1499
 
                gtk_theming_engine_get_background_color (engine, state, &bg);
1500
 
                gtk_theming_engine_get_color (engine, state, &fg);
1501
 
 
1502
 
                cairo_save (cr);
1503
 
 
1504
 
                cairo_rectangle (cr, x, y,
1505
 
                                 width, height);
1506
 
                gdk_cairo_set_source_rgba (cr, &bg);
1507
 
                cairo_fill (cr);
1508
 
 
1509
 
                gdk_cairo_set_source_rgba (cr, &fg);
1510
 
                cairo_set_line_width (cr, 2.0);
1511
 
                cairo_line_to (cr, x + width, y + height);
1512
 
                cairo_stroke (cr);
1513
 
 
1514
 
                if (width > height) {
1515
 
                        for (xx = x + width / 2 - 12; xx <= x + width / 2 + 12; xx += 6) {
1516
 
                                cairo_arc (cr, xx, y + height / 2 - 1,
1517
 
                                           1.5,
1518
 
                                           0, G_PI * 2.0);
1519
 
                                cairo_fill (cr);
1520
 
                        }
1521
 
                } else {
1522
 
                        for (yy = y + height / 2 - 12; yy <= y + height / 2 + 12; yy += 6) {
1523
 
                                cairo_arc (cr, x + width / 2.0, yy,
1524
 
                                           1.0,
1525
 
                                           0, G_PI * 2.0);
1526
 
                                cairo_fill (cr);
1527
 
                        }
1528
 
                }
1529
 
 
1530
 
                cairo_restore (cr);
1531
 
        } else {
1532
 
                GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_handle (engine, cr,
1533
 
                                                                                       x, y, width, height);
1534
 
        }
1535
 
}
1536
 
 
1537
 
/* taken from gtkthemingengine.c */
1538
 
static GdkPixbuf *
1539
 
scale_or_ref (GdkPixbuf *src,
1540
 
              gint       width,
1541
 
              gint       height)
1542
 
{
1543
 
        if (width == gdk_pixbuf_get_width (src) &&
1544
 
            height == gdk_pixbuf_get_height (src)) {
1545
 
                return g_object_ref (src);
1546
 
        } else {
1547
 
                return gdk_pixbuf_scale_simple (src,
1548
 
                                                width, height,
1549
 
                                                GDK_INTERP_BILINEAR);
1550
 
        }
1551
 
}
1552
 
 
1553
 
static gboolean
1554
 
lookup_icon_size (GtkThemingEngine *engine,
1555
 
                  GtkIconSize       size,
1556
 
                  gint             *width,
1557
 
                  gint             *height)
1558
 
{
1559
 
        GdkScreen *screen;
1560
 
        GtkSettings *settings;
1561
 
 
1562
 
        screen = gtk_theming_engine_get_screen (engine);
1563
 
        settings = gtk_settings_get_for_screen (screen);
1564
 
 
1565
 
        return gtk_icon_size_lookup_for_settings (settings, size, width, height);
1566
 
}
1567
 
 
1568
 
/* Kudos to the gnome-panel guys. */
1569
 
static void
1570
 
colorshift_pixbuf (GdkPixbuf *src,
1571
 
                   GdkPixbuf *dest,
1572
 
                   gint       shift)
1573
 
{
1574
 
        gint i, j;
1575
 
        gint width, height, has_alpha, src_rowstride, dest_rowstride;
1576
 
        guchar *target_pixels;
1577
 
        guchar *original_pixels;
1578
 
        guchar *pix_src;
1579
 
        guchar *pix_dest;
1580
 
        int val;
1581
 
        guchar r, g, b;
1582
 
 
1583
 
        has_alpha       = gdk_pixbuf_get_has_alpha (src);
1584
 
        width           = gdk_pixbuf_get_width (src);
1585
 
        height          = gdk_pixbuf_get_height (src);
1586
 
        src_rowstride   = gdk_pixbuf_get_rowstride (src);
1587
 
        dest_rowstride  = gdk_pixbuf_get_rowstride (dest);
1588
 
        original_pixels = gdk_pixbuf_get_pixels (src);
1589
 
        target_pixels   = gdk_pixbuf_get_pixels (dest);
1590
 
 
1591
 
        for (i = 0; i < height; i++) {
1592
 
                pix_dest = target_pixels   + i * dest_rowstride;
1593
 
                pix_src  = original_pixels + i * src_rowstride;
1594
 
 
1595
 
                for (j = 0; j < width; j++) {
1596
 
                        r = *(pix_src++);
1597
 
                        g = *(pix_src++);
1598
 
                        b = *(pix_src++);
1599
 
 
1600
 
                        val = r + shift;
1601
 
                        *(pix_dest++) = CLAMP (val, 0, 255);
1602
 
 
1603
 
                        val = g + shift;
1604
 
                        *(pix_dest++) = CLAMP (val, 0, 255);
1605
 
 
1606
 
                        val = b + shift;
1607
 
                        *(pix_dest++) = CLAMP (val, 0, 255);
1608
 
 
1609
 
                        if (has_alpha) {
1610
 
                                *(pix_dest++) = *(pix_src++);
1611
 
                        }
1612
 
                }
1613
 
        }
1614
 
}
1615
 
 
1616
 
static GdkPixbuf *
1617
 
adwaita_engine_render_icon_pixbuf (GtkThemingEngine    *engine,
1618
 
                                   const GtkIconSource *source,
1619
 
                                   GtkIconSize          size)
1620
 
{
1621
 
        GdkPixbuf *base_pixbuf;
1622
 
        GdkPixbuf *scaled;
1623
 
        GdkPixbuf *stated;
1624
 
        GtkStateFlags state;
1625
 
        gint width = 1;
1626
 
        gint height = 1;
1627
 
 
1628
 
        cairo_surface_t *stated_surface;
1629
 
        cairo_t *cr;
1630
 
 
1631
 
        base_pixbuf = gtk_icon_source_get_pixbuf (source);
1632
 
        state = gtk_theming_engine_get_state (engine);
1633
 
 
1634
 
        g_return_val_if_fail (base_pixbuf != NULL, NULL);
1635
 
 
1636
 
        if (size != (GtkIconSize) -1 &&
1637
 
            !lookup_icon_size (engine, size, &width, &height)) {
1638
 
                g_warning (G_STRLOC ": invalid icon size '%d'", size);
1639
 
                return NULL;
1640
 
        }
1641
 
 
1642
 
        /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise,
1643
 
         * leave it alone.
1644
 
         */
1645
 
        if (size != (GtkIconSize) -1 &&
1646
 
            gtk_icon_source_get_size_wildcarded (source)) {
1647
 
                scaled = scale_or_ref (base_pixbuf, width, height);
1648
 
        } else {
1649
 
                scaled = g_object_ref (base_pixbuf);
1650
 
        }
1651
 
 
1652
 
        /* If the state was wildcarded, then generate a state. */
1653
 
        if (gtk_icon_source_get_state_wildcarded (source)) {
1654
 
                if (state & GTK_STATE_FLAG_INSENSITIVE) {
1655
 
                        /* dim the pixbuf with a 0.5 alpha black layer */
1656
 
                        stated_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
1657
 
                                                                     gdk_pixbuf_get_width (scaled),
1658
 
                                                                     gdk_pixbuf_get_height (scaled));
1659
 
                        cr = cairo_create (stated_surface);
1660
 
 
1661
 
                        gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
1662
 
                        cairo_paint (cr);
1663
 
 
1664
 
                        cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5);
1665
 
                        cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
1666
 
                        cairo_paint (cr);
1667
 
 
1668
 
                        stated = gdk_pixbuf_get_from_surface (stated_surface,
1669
 
                                                              0, 0,
1670
 
                                                              cairo_image_surface_get_width (stated_surface),
1671
 
                                                              cairo_image_surface_get_height (stated_surface));
1672
 
 
1673
 
                        g_object_unref (scaled);
1674
 
                        cairo_destroy (cr);
1675
 
                        cairo_surface_destroy (stated_surface);
1676
 
                } else if (state & GTK_STATE_FLAG_PRELIGHT) {
1677
 
                        stated = gdk_pixbuf_copy (scaled);
1678
 
                        colorshift_pixbuf (scaled, stated, 30);
1679
 
                        g_object_unref (scaled);
1680
 
                } else {
1681
 
                        stated = scaled;
1682
 
                }
1683
 
        } else {
1684
 
                stated = scaled;
1685
 
        }
1686
 
 
1687
 
        return stated;
1688
 
}
1689
 
 
1690
 
static void
1691
 
adwaita_engine_render_line (GtkThemingEngine *engine,
1692
 
                            cairo_t *cr,
1693
 
                            gdouble x0,
1694
 
                            gdouble y0,
1695
 
                            gdouble x1,
1696
 
                            gdouble y1)
1697
 
{
1698
 
        const GtkWidgetPath *path;
1699
 
 
1700
 
        path = gtk_theming_engine_get_path (engine);
1701
 
 
1702
 
        if ((gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MARK) &&
1703
 
             gtk_widget_path_is_type (path, GTK_TYPE_SCALE)) ||
1704
 
            (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SEPARATOR) &&
1705
 
             gtk_widget_path_is_type (path, GTK_TYPE_TREE_VIEW))) {
1706
 
                GtkStateFlags state;
1707
 
                GdkRGBA bg;
1708
 
 
1709
 
                state = gtk_theming_engine_get_state (engine);
1710
 
                gtk_theming_engine_get_background_color (engine, state, &bg);
1711
 
 
1712
 
                cairo_save (cr);
1713
 
 
1714
 
                cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
1715
 
                cairo_set_line_width (cr, 1);
1716
 
 
1717
 
                cairo_move_to (cr, x0 + 0.5, y0 + 0.5);
1718
 
                cairo_line_to (cr, x1 + 0.5, y1 + 0.5);
1719
 
 
1720
 
                gdk_cairo_set_source_rgba (cr, &bg);
1721
 
                cairo_stroke (cr);
1722
 
 
1723
 
                cairo_restore (cr);
1724
 
        } else {
1725
 
                GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_line (engine, cr,
1726
 
                                                                                     x0, y0, x1, y1);
1727
 
        }
 
677
                              cairo_t          *cr,
 
678
                              gdouble           x,
 
679
                              gdouble           y,
 
680
                              gdouble           width,
 
681
                              gdouble           height)
 
682
{
 
683
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
 
684
    {
 
685
      GdkRGBA bg;
 
686
      GtkJunctionSides sides;
 
687
      GtkStateFlags state;
 
688
      int lx, ly;
 
689
      int x_down;
 
690
      int y_down;
 
691
      int dots;
 
692
 
 
693
      state = gtk_theming_engine_get_state (engine);
 
694
      gtk_theming_engine_get_background_color (engine, state, &bg);
 
695
 
 
696
      /* The number of dots fitting into the area. Just hardcoded to 3 right now. */
 
697
      /* dots = MIN (width - 2, height - 2) / 3; */
 
698
      dots = 3;
 
699
 
 
700
      cairo_save (cr);
 
701
 
 
702
      sides = gtk_theming_engine_get_junction_sides (engine);
 
703
 
 
704
      switch (sides)
 
705
        {
 
706
        case GTK_JUNCTION_CORNER_TOPRIGHT:
 
707
          x_down = 0;
 
708
          y_down = 0;
 
709
          cairo_translate (cr, x + width - 4*dots, y + 1);
 
710
          break;
 
711
        case GTK_JUNCTION_CORNER_BOTTOMRIGHT:
 
712
          x_down = 0;
 
713
          y_down = 1;
 
714
          cairo_translate (cr, x + width - 4*dots, y + height + 1 - 4*dots);
 
715
          break;
 
716
        case GTK_JUNCTION_CORNER_BOTTOMLEFT:
 
717
          x_down = 1;
 
718
          y_down = 1;
 
719
          cairo_translate (cr, x + 2, y + height + 1 - 4*dots);
 
720
          break;
 
721
        case GTK_JUNCTION_CORNER_TOPLEFT:
 
722
          x_down = 1;
 
723
          y_down = 0;
 
724
          cairo_translate (cr, x + 2, y + 1);
 
725
          break;
 
726
        default:
 
727
          /* Not implemented. */
 
728
          cairo_restore (cr);
 
729
          return;
 
730
        }
 
731
 
 
732
      for (lx = 0; lx < dots; lx++) /* horizontally */
 
733
        {
 
734
          for (ly = 0; ly <= lx; ly++) /* vertically */
 
735
            {
 
736
              int mx, my;
 
737
              mx = x_down * dots + (1 - x_down * 2) * lx - x_down;
 
738
              my = y_down * dots + (1 - y_down * 2) * ly - y_down;
 
739
 
 
740
              gdk_cairo_set_source_rgba (cr, &bg);
 
741
              cairo_arc (cr,
 
742
                         mx * 4 - 1 + 1.5,
 
743
                         my * 4 - 1 + 1.5,
 
744
                         1.5,
 
745
                         0, G_PI * 2.0);
 
746
 
 
747
              cairo_fill (cr);
 
748
            }
 
749
        }
 
750
 
 
751
      cairo_restore (cr);
 
752
    }
 
753
  else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR))
 
754
    {
 
755
      GdkRGBA fg;
 
756
      GtkStateFlags state;
 
757
      gdouble xx, yy;
 
758
 
 
759
      state = gtk_theming_engine_get_state (engine);
 
760
      gtk_theming_engine_get_color (engine, state, &fg);
 
761
 
 
762
      GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
 
763
        (engine, cr, x, y, width, height);
 
764
      GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
 
765
        (engine, cr, x, y, width, height);
 
766
 
 
767
      cairo_save (cr);
 
768
      cairo_set_line_width (cr, 2.0);
 
769
      gdk_cairo_set_source_rgba (cr, &fg);
 
770
 
 
771
      if (width > height)
 
772
        {
 
773
          for (xx = x + width / 2 - 12; xx <= x + width / 2 + 12; xx += 6)
 
774
            {
 
775
              cairo_arc (cr, xx, y + height / 2.0,
 
776
                         1.0,
 
777
                         0, G_PI * 2.0);
 
778
              cairo_fill (cr);
 
779
            }
 
780
        }
 
781
      else
 
782
        {
 
783
          for (yy = y + height / 2 - 12; yy <= y + height / 2 + 12; yy += 6)
 
784
            {
 
785
              cairo_arc (cr, x + width / 2.0, yy,
 
786
                         1.0,
 
787
                         0, G_PI * 2.0);
 
788
              cairo_fill (cr);
 
789
            }
 
790
        }
 
791
 
 
792
      cairo_restore (cr);
 
793
    }
 
794
  else
 
795
    {
 
796
      GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_handle
 
797
        (engine, cr,
 
798
         x, y, width, height);
 
799
    }
1728
800
}
1729
801
 
1730
802
static void
1731
803
adwaita_engine_class_init (AdwaitaEngineClass *klass)
1732
804
{
1733
 
        GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
1734
 
 
1735
 
        engine_class->render_arrow = adwaita_engine_render_arrow;
1736
 
        engine_class->render_focus = adwaita_engine_render_focus;
1737
 
        engine_class->render_check = adwaita_engine_render_check;
1738
 
        engine_class->render_option = adwaita_engine_render_option;
1739
 
        engine_class->render_extension = adwaita_engine_render_extension;
1740
 
        engine_class->render_frame = adwaita_engine_render_frame;
1741
 
        engine_class->render_background = adwaita_engine_render_background;
1742
 
        engine_class->render_expander = adwaita_engine_render_expander;
1743
 
        engine_class->render_activity = adwaita_engine_render_activity;
1744
 
        engine_class->render_slider = adwaita_engine_render_slider;
1745
 
        engine_class->render_handle = adwaita_engine_render_handle;
1746
 
        engine_class->render_icon_pixbuf = adwaita_engine_render_icon_pixbuf;
1747
 
        engine_class->render_line = adwaita_engine_render_line;
1748
 
 
1749
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1750
 
                                              g_param_spec_boxed ("focus-border-color",
1751
 
                                                                  "Focus border color",
1752
 
                                                                  "Focus border color",
1753
 
                                                                  GDK_TYPE_RGBA, 0));
1754
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1755
 
                                              g_param_spec_int ("focus-border-radius",
1756
 
                                                                "Focus border radius",
1757
 
                                                                "Focus border radius",
1758
 
                                                                0, G_MAXINT, 0,
1759
 
                                                                0));
1760
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1761
 
                                              g_param_spec_boxed ("focus-border-gradient",
1762
 
                                                                  "Focus border gradient",
1763
 
                                                                  "Focus border gradient",
1764
 
                                                                  CAIRO_GOBJECT_TYPE_PATTERN, 0));
1765
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1766
 
                                              g_param_spec_boxed ("focus-fill-color",
1767
 
                                                                  "Focus fill color",
1768
 
                                                                  "Focus fill color",
1769
 
                                                                  GDK_TYPE_RGBA, 0));
1770
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1771
 
                                              g_param_spec_boxed ("selected-tab-color",
1772
 
                                                                  "Selected tab color",
1773
 
                                                                  "Selected tab color",
1774
 
                                                                  GDK_TYPE_RGBA, 0));
1775
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1776
 
                                              g_param_spec_boxed ("border-gradient",
1777
 
                                                                  "Border gradient",
1778
 
                                                                  "Border gradient",
1779
 
                                                                  CAIRO_GOBJECT_TYPE_PATTERN, 0));
1780
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1781
 
                                              g_param_spec_boolean ("focus-border-dashes",
1782
 
                                                                    "Focus border uses dashes",
1783
 
                                                                    "Focus border uses dashes",
1784
 
                                                                    FALSE, 0));
1785
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1786
 
                                              g_param_spec_boxed ("menuitem-arrow-color",
1787
 
                                                                  "Menuitem arrow color",
1788
 
                                                                  "Menuitem arrow color",
1789
 
                                                                  GDK_TYPE_RGBA, 0));
1790
 
        gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1791
 
                                              g_param_spec_boxed ("switch-grip-color",
1792
 
                                                                  "Switch grip color",
1793
 
                                                                  "Switch grip color",
1794
 
                                                                  GDK_TYPE_RGBA, 0));
 
805
  GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
 
806
 
 
807
  engine_class->render_arrow = adwaita_engine_render_arrow;
 
808
  engine_class->render_focus = adwaita_engine_render_focus;
 
809
  engine_class->render_check = adwaita_engine_render_check;
 
810
  engine_class->render_option = adwaita_engine_render_option;
 
811
  engine_class->render_extension = adwaita_engine_render_extension;
 
812
  engine_class->render_frame = adwaita_engine_render_frame;
 
813
  engine_class->render_background = adwaita_engine_render_background;
 
814
  engine_class->render_expander = adwaita_engine_render_expander;
 
815
  engine_class->render_activity = adwaita_engine_render_activity;
 
816
  engine_class->render_slider = adwaita_engine_render_slider;
 
817
  engine_class->render_handle = adwaita_engine_render_handle;
 
818
 
 
819
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
820
                                        g_param_spec_boxed ("focus-border-color",
 
821
                                                            "Focus border color",
 
822
                                                            "Focus border color",
 
823
                                                            GDK_TYPE_RGBA, 0));
 
824
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
825
                                        g_param_spec_int ("focus-border-radius",
 
826
                                                          "Focus border radius",
 
827
                                                          "Focus border radius",
 
828
                                                          0, G_MAXINT, 0,
 
829
                                                          0));
 
830
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
831
                                        g_param_spec_boxed ("focus-border-gradient",
 
832
                                                            "Focus border gradient",
 
833
                                                            "Focus border gradient",
 
834
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
 
835
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
836
                                        g_param_spec_boxed ("focus-fill-color",
 
837
                                                            "Focus fill color",
 
838
                                                            "Focus fill color",
 
839
                                                            GDK_TYPE_RGBA, 0));
 
840
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
841
                                        g_param_spec_boxed ("selected-tab-color",
 
842
                                                            "Selected tab color",
 
843
                                                            "Selected tab color",
 
844
                                                            GDK_TYPE_RGBA, 0));
 
845
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
846
                                        g_param_spec_boxed ("border-gradient",
 
847
                                                            "Border gradient",
 
848
                                                            "Border gradient",
 
849
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
 
850
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
851
                                        g_param_spec_boolean ("focus-border-dashes",
 
852
                                                              "Focus border uses dashes",
 
853
                                                              "Focus border uses dashes",
 
854
                                                              FALSE, 0));
 
855
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
856
                                        g_param_spec_boxed ("menuitem-arrow-color",
 
857
                                                            "Menuitem arrow color",
 
858
                                                            "Menuitem arrow color",
 
859
                                                            GDK_TYPE_RGBA, 0));
 
860
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
861
                                        g_param_spec_boxed ("switch-grip-color",
 
862
                                                            "Switch grip color",
 
863
                                                            "Switch grip color",
 
864
                                                            GDK_TYPE_RGBA, 0));
 
865
  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
 
866
                                        g_param_spec_boxed ("progressbar-pattern",
 
867
                                                            "Progressbar pattern",
 
868
                                                            "Progressbar pattern",
 
869
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
1795
870
}
1796
871
 
1797
872
static void
1802
877
G_MODULE_EXPORT void
1803
878
theme_init (GTypeModule *module)
1804
879
{
1805
 
        adwaita_engine_register_types (module);
 
880
  adwaita_engine_register_types (module);
1806
881
}
1807
882
 
1808
883
G_MODULE_EXPORT void
1813
888
G_MODULE_EXPORT GtkThemingEngine *
1814
889
create_engine (void)
1815
890
{
1816
 
        return GTK_THEMING_ENGINE (g_object_new (ADWAITA_TYPE_ENGINE,
1817
 
                                                 "name", "adwaita",
1818
 
                                                 NULL));
 
891
  return GTK_THEMING_ENGINE (g_object_new (ADWAITA_TYPE_ENGINE,
 
892
                                           "name", "adwaita",
 
893
                                           NULL));
1819
894
}