~unico-team/unico/trunk

« back to all changes in this revision

Viewing changes to unico/unico-engine.c

  • Committer: Ken VanDine
  • Date: 2012-08-08 16:28:32 UTC
  • mfrom: (139 refactor)
  • mto: (139.1.1 unico)
  • mto: This revision was merged to the branch mainline in revision 140.
  • Revision ID: ken.vandine@canonical.com-20120808162832-vmgto6docfq65f4d
New snapshot from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
G_DEFINE_DYNAMIC_TYPE (UnicoEngine, unico_engine, GTK_TYPE_THEMING_ENGINE)
42
42
 
43
43
static void
44
 
unico_engine_render_activity (GtkThemingEngine *engine,
45
 
                              cairo_t          *cr,
46
 
                              gdouble           x,
47
 
                              gdouble           y,
48
 
                              gdouble           width,
49
 
                              gdouble           height)
50
 
{
51
 
  UnicoStyleFunctions *style_functions;
52
 
  const GtkWidgetPath *path;
53
 
 
54
 
  UNICO_CAIRO_INIT
55
 
 
56
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
57
 
  path = gtk_theming_engine_get_path (engine);
58
 
 
59
 
  if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE))
60
 
    unico_trim_scale_allocation (engine, &x, &y, &width, &height);
61
 
 
62
 
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER))
63
 
    GTK_THEMING_ENGINE_CLASS (unico_engine_parent_class)->render_activity (engine, cr, x, y, width, height);
64
 
  else
65
 
    style_functions->draw_activity (engine, cr, x, y, width, height);
66
 
}
67
 
 
68
 
static void
69
44
unico_engine_render_arrow (GtkThemingEngine *engine,
70
45
                           cairo_t          *cr,
71
46
                           gdouble           angle,
83
58
}
84
59
 
85
60
static void
86
 
unico_engine_render_background (GtkThemingEngine *engine,
87
 
                                cairo_t          *cr,
88
 
                                gdouble           x,
89
 
                                gdouble           y,
90
 
                                gdouble           width,
91
 
                                gdouble           height)
92
 
{
93
 
  UnicoStyleFunctions *style_functions;
94
 
  const GtkWidgetPath *path;
95
 
  GtkRegionFlags flags;
96
 
 
97
 
  UNICO_CAIRO_INIT
98
 
 
99
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
100
 
  path = gtk_theming_engine_get_path (engine);
101
 
 
102
 
  if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
103
 
      gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
104
 
    unico_trim_scale_allocation (engine, &x, &y, &width, &height);
105
 
 
106
 
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON) &&
107
 
      gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON))
108
 
    style_functions->draw_spinbutton_background (engine, cr, x, y, width, height);
109
 
  else if (!gtk_widget_path_is_type (path, GTK_TYPE_ICON_VIEW) &&
110
 
           gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VIEW) &&
111
 
           gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags))
112
 
    style_functions->draw_cell_background (engine, cr, x, y, width, height, flags);
113
 
  else
114
 
    style_functions->draw_common_background (engine, cr, x, y, width, height);
115
 
}
116
 
 
117
 
static void
118
 
unico_engine_render_check (GtkThemingEngine *engine,
119
 
                           cairo_t          *cr,
120
 
                           gdouble           x,
121
 
                           gdouble           y,
122
 
                           gdouble           width,
123
 
                           gdouble           height)
124
 
{
125
 
  UnicoStyleFunctions *style_functions;
126
 
 
127
 
  UNICO_CAIRO_INIT
128
 
 
129
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
130
 
 
131
 
  if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM))
132
 
    {
133
 
      if (unico_cairo_draw_from_texture (engine, cr, x, y, width, height))
134
 
        return;
135
 
    }
136
 
 
137
 
  style_functions->draw_check (engine, cr, x, y, width, height);
138
 
}
139
 
 
140
 
static void
141
61
unico_engine_render_expander (GtkThemingEngine *engine,
142
62
                              cairo_t          *cr,
143
63
                              gdouble           x,
155
75
}
156
76
 
157
77
static void
158
 
unico_engine_render_extension (GtkThemingEngine *engine,
159
 
                               cairo_t          *cr,
160
 
                               gdouble           x,
161
 
                               gdouble           y,
162
 
                               gdouble           width,
163
 
                               gdouble           height,
164
 
                               GtkPositionType   gap_side)
165
 
{
166
 
  UnicoStyleFunctions *style_functions;
167
 
 
168
 
  UNICO_CAIRO_INIT
169
 
 
170
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
171
 
 
172
 
  style_functions->draw_extension (engine, cr, x, y, width, height, gap_side);
173
 
}
174
 
 
175
 
static void
176
78
unico_engine_render_focus (GtkThemingEngine *engine,
177
79
                           cairo_t          *cr,
178
80
                           gdouble           x,
189
91
  style_functions->draw_focus (engine, cr, x, y, width, height);
190
92
}
191
93
 
192
 
static void
193
 
unico_engine_render_frame (GtkThemingEngine *engine,
194
 
                           cairo_t          *cr,
195
 
                           gdouble           x,
196
 
                           gdouble           y,
197
 
                           gdouble           width,
198
 
                           gdouble           height)
199
 
{
200
 
  UnicoStyleFunctions *style_functions;
201
 
  const GtkWidgetPath *path;
202
 
  GtkRegionFlags flags;
203
 
 
204
 
  UNICO_CAIRO_INIT
205
 
 
206
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
207
 
  path = gtk_theming_engine_get_path (engine);
208
 
 
209
 
  if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
210
 
      gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
211
 
    unico_trim_scale_allocation (engine, &x, &y, &width, &height);
212
 
 
213
 
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SEPARATOR))
214
 
    style_functions->draw_separator (engine, cr, x, y, width, height);
215
 
  else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON) &&
216
 
           gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON))
217
 
    style_functions->draw_spinbutton_frame (engine, cr, x, y, width, height);
218
 
  else if (!gtk_widget_path_is_type (path, GTK_TYPE_ICON_VIEW) &&
219
 
           gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VIEW) &&
220
 
           gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags))
221
 
    style_functions->draw_cell_frame (engine, cr, x, y, width, height, flags);
222
 
  else
223
 
    style_functions->draw_common_frame (engine, cr, x, y, width, height);
224
 
}
225
 
 
226
 
static void
227
 
unico_engine_render_frame_gap (GtkThemingEngine *engine,
228
 
                               cairo_t          *cr,
229
 
                               gdouble           x,
230
 
                               gdouble           y,
231
 
                               gdouble           width,
232
 
                               gdouble           height,
233
 
                               GtkPositionType   gap_side,
234
 
                               gdouble           xy0_gap,
235
 
                               gdouble           xy1_gap)
236
 
{
237
 
  UnicoStyleFunctions *style_functions;
238
 
 
239
 
  UNICO_CAIRO_INIT
240
 
 
241
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
242
 
 
243
 
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK))
244
 
    style_functions->draw_notebook (engine, cr, x, y, width, height, gap_side, xy0_gap, xy1_gap);
245
 
  else
246
 
    style_functions->draw_frame_gap (engine, cr, x, y, width, height, gap_side, xy0_gap, xy1_gap);
247
 
}
248
 
 
249
 
static void
250
 
unico_engine_render_handle (GtkThemingEngine *engine,
251
 
                            cairo_t          *cr,
252
 
                            gdouble           x,
253
 
                            gdouble           y,
254
 
                            gdouble           width,
255
 
                            gdouble           height)
256
 
{
257
 
  UnicoStyleFunctions *style_functions;
258
 
 
259
 
  UNICO_CAIRO_INIT
260
 
 
261
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
262
 
 
263
 
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
264
 
    style_functions->draw_grip (engine, cr, x, y, width, height);
265
 
  else
266
 
    style_functions->draw_handle (engine, cr, x, y, width, height);
267
 
}
268
 
 
269
 
static void
270
 
unico_engine_render_line (GtkThemingEngine *engine,
271
 
                          cairo_t          *cr,
272
 
                          gdouble           x0,
273
 
                          gdouble           y0,
274
 
                          gdouble           x1,
275
 
                          gdouble           y1)
276
 
{
277
 
  UnicoStyleFunctions *style_functions;
278
 
 
279
 
  UNICO_CAIRO_INIT
280
 
 
281
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
282
 
 
283
 
  style_functions->draw_line (engine, cr, x0, y0, x1, y1);
284
 
}
285
 
 
286
 
static void
287
 
unico_engine_render_option (GtkThemingEngine *engine,
288
 
                            cairo_t          *cr,
289
 
                            gdouble           x,
290
 
                            gdouble           y,
291
 
                            gdouble           width,
292
 
                            gdouble           height)
293
 
{
294
 
  UnicoStyleFunctions *style_functions;
295
 
 
296
 
  UNICO_CAIRO_INIT
297
 
 
298
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
299
 
 
300
 
  if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM))
301
 
    {
302
 
      if (unico_cairo_draw_from_texture (engine, cr, x, y, width, height))
303
 
        return;
304
 
    }
305
 
 
306
 
  style_functions->draw_radio (engine, cr, x, y, width, height);
307
 
}
308
 
 
309
 
static void
310
 
unico_engine_render_slider (GtkThemingEngine *engine,
311
 
                            cairo_t          *cr,
312
 
                            gdouble           x,
313
 
                            gdouble           y,
314
 
                            gdouble           width,
315
 
                            gdouble           height,
316
 
                            GtkOrientation    orientation)
317
 
{
318
 
  UnicoStyleFunctions *style_functions;
319
 
 
320
 
  UNICO_CAIRO_INIT
321
 
 
322
 
  unico_lookup_functions (UNICO_ENGINE (engine), &style_functions);
323
 
 
324
 
  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SCALE))
325
 
    {
326
 
      if (unico_cairo_draw_from_texture (engine, cr, x, y, width, height))
327
 
        return;
328
 
    }
329
 
 
330
 
  style_functions->draw_slider (engine, cr, x, y, width, height, orientation);
331
 
}
332
 
 
333
94
void
334
95
unico_engine_register_types (GTypeModule *module)
335
96
{
347
108
{
348
109
  GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
349
110
 
350
 
  engine_class->render_activity    = unico_engine_render_activity;
351
111
  engine_class->render_arrow       = unico_engine_render_arrow;
352
 
  engine_class->render_background  = unico_engine_render_background;
353
 
  engine_class->render_check       = unico_engine_render_check;
354
112
  engine_class->render_expander    = unico_engine_render_expander;
355
 
  engine_class->render_extension   = unico_engine_render_extension;
356
113
  engine_class->render_focus       = unico_engine_render_focus;
357
 
  engine_class->render_frame       = unico_engine_render_frame;
358
 
  engine_class->render_frame_gap   = unico_engine_render_frame_gap;
359
 
  engine_class->render_handle      = unico_engine_render_handle;
360
 
  engine_class->render_line        = unico_engine_render_line;
361
 
  engine_class->render_option      = unico_engine_render_option;
362
 
  engine_class->render_slider      = unico_engine_render_slider;
363
 
 
364
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
365
 
                                        g_param_spec_boxed ("background-texture",
366
 
                                                            "Background texture",
367
 
                                                            "Background texture",
368
 
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
369
 
 
370
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
371
 
                                        g_param_spec_boxed ("border-gradient",
372
 
                                                            "Border gradient",
373
 
                                                            "Border gradient",
374
 
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
375
 
 
376
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
377
 
                                        g_param_spec_boxed ("bullet-color",
378
 
                                                            "Bullet color",
379
 
                                                            "Bullet color",
380
 
                                                            GDK_TYPE_RGBA, 0));
381
 
 
382
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
383
 
                                        g_param_spec_boxed ("bullet-outline-color",
384
 
                                                            "Bullet outline color",
385
 
                                                            "Bullet outline color",
386
 
                                                            GDK_TYPE_RGBA, 0));
387
 
 
388
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
389
 
                                        g_param_spec_boxed ("centroid-texture",
390
 
                                                            "Centroid texture",
391
 
                                                            "Centroid texture",
392
 
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
393
 
 
 
114
 
 
115
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
 
116
                                        g_param_spec_boxed ("arrow-texture",
 
117
                                                            "Arrow texture",
 
118
                                                            "Arrow texture",
 
119
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
394
120
 
395
121
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
396
122
                                        g_param_spec_boxed ("focus-border-color",
409
135
                                                            "Focus fill color",
410
136
                                                            "Focus fill color",
411
137
                                                            GDK_TYPE_RGBA, 0));
412
 
 
413
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
414
 
                                        g_param_spec_boxed ("focus-outer-stroke-color",
415
 
                                                            "Focus outer stroke color",
416
 
                                                            "Focus outer stroke color",
417
 
                                                            GDK_TYPE_RGBA, 0));
418
 
 
419
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
420
 
                                        g_param_spec_int ("glow-radius",
421
 
                                                          "Glow radius",
422
 
                                                          "Glow radius",
423
 
                                                          0, G_MAXINT, 0, 0));
424
 
 
425
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
426
 
                                        g_param_spec_boxed ("glow-color",
427
 
                                                            "Glow color",
428
 
                                                            "Glow color",
429
 
                                                            GDK_TYPE_RGBA, 0));
430
 
 
431
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
432
 
                                        g_param_spec_boxed ("inner-stroke-color",
433
 
                                                            "Inner stroke color",
434
 
                                                            "Inner stroke color",
435
 
                                                            GDK_TYPE_RGBA, 0));
436
 
 
437
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
438
 
                                        g_param_spec_boxed ("inner-stroke-top-color",
439
 
                                                            "Inner stroke top color",
440
 
                                                            "Inner stroke top color",
441
 
                                                            GDK_TYPE_RGBA, 0));
442
 
 
443
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
444
 
                                        g_param_spec_boxed ("inner-stroke-right-color",
445
 
                                                            "Inner stroke right color",
446
 
                                                            "Inner stroke right color",
447
 
                                                            GDK_TYPE_RGBA, 0));
448
 
 
449
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
450
 
                                        g_param_spec_boxed ("inner-stroke-bottom-color",
451
 
                                                            "Inner stroke bottom color",
452
 
                                                            "Inner stroke bottom color",
453
 
                                                            GDK_TYPE_RGBA, 0));
454
 
 
455
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
456
 
                                        g_param_spec_boxed ("inner-stroke-left-color",
457
 
                                                            "Inner stroke left color",
458
 
                                                            "Inner stroke left color",
459
 
                                                            GDK_TYPE_RGBA, 0));
460
 
 
461
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
462
 
                                        g_param_spec_boxed ("inner-stroke-gradient",
463
 
                                                            "Inner stroke gradient",
464
 
                                                            "Inner stroke gradient",
465
 
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
466
 
 
467
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
468
 
                                        g_param_spec_boxed ("inner-stroke-width",
469
 
                                                            "Inner stroke width",
470
 
                                                            "Inner stroke width",
471
 
                                                            GTK_TYPE_BORDER, 0));
472
 
 
473
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
474
 
                                        g_param_spec_boxed ("outer-stroke-color",
475
 
                                                            "Outer stroke color",
476
 
                                                            "Outer stroke color",
477
 
                                                            GDK_TYPE_RGBA, 0));
478
 
 
479
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
480
 
                                        g_param_spec_boxed ("outer-stroke-top-color",
481
 
                                                            "Outer stroke top color",
482
 
                                                            "Outer stroke top color",
483
 
                                                            GDK_TYPE_RGBA, 0));
484
 
 
485
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
486
 
                                        g_param_spec_boxed ("outer-stroke-right-color",
487
 
                                                            "Outer stroke right color",
488
 
                                                            "Outer stroke right color",
489
 
                                                            GDK_TYPE_RGBA, 0));
490
 
 
491
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
492
 
                                        g_param_spec_boxed ("outer-stroke-bottom-color",
493
 
                                                            "Outer stroke bottom color",
494
 
                                                            "Outer stroke bottom color",
495
 
                                                            GDK_TYPE_RGBA, 0));
496
 
 
497
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
498
 
                                        g_param_spec_boxed ("outer-stroke-left-color",
499
 
                                                            "Outer stroke left color",
500
 
                                                            "Outer stroke left color",
501
 
                                                            GDK_TYPE_RGBA, 0));
502
 
 
503
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
504
 
                                        g_param_spec_boxed ("outer-stroke-gradient",
505
 
                                                            "Outer stroke gradient",
506
 
                                                            "Outer stroke gradient",
507
 
                                                            CAIRO_GOBJECT_TYPE_PATTERN, 0));
508
 
 
509
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
510
 
                                        g_param_spec_boxed ("outer-stroke-width",
511
 
                                                            "Outer stroke width",
512
 
                                                            "Outer stroke width",
513
 
                                                            GTK_TYPE_BORDER, 0));
514
 
 
515
 
  gtk_theming_engine_register_property (UNICO_NAMESPACE, NULL,
516
 
                                        g_param_spec_boxed ("text-shadow-color",
517
 
                                                            "Text shadow color",
518
 
                                                            "Text shadow color",
519
 
                                                            GDK_TYPE_RGBA, 0));
520
138
}
521
139
 
522
140
static void