~ubuntu-branches/ubuntu/trusty/thunar/trusty

« back to all changes in this revision

Viewing changes to thunar/thunar-icon-renderer.c

  • Committer: Package Import Robot
  • Author(s): Lionel Le Folgoc
  • Date: 2012-12-30 13:43:31 UTC
  • mfrom: (1.3.6)
  • Revision ID: package-import@ubuntu.com-20121230134331-gh7yww1d4wtjpfwo
Tags: 1.6.2-0ubuntu1
New upstream stable release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
 
310
310
 
311
311
static void
 
312
thunar_icon_renderer_color_selected (cairo_t   *cr,
 
313
                                     GtkWidget *widget)
 
314
{
 
315
  cairo_pattern_t *source;
 
316
  GtkStateType     state;
 
317
 
 
318
  cairo_save (cr);
 
319
 
 
320
  source = cairo_pattern_reference (cairo_get_source (cr));
 
321
  state = gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
 
322
  gdk_cairo_set_source_color (cr, &widget->style->base[state]);
 
323
  cairo_set_operator (cr, CAIRO_OPERATOR_MULTIPLY);
 
324
 
 
325
  cairo_mask (cr, source);
 
326
 
 
327
  cairo_pattern_destroy (source);
 
328
  cairo_restore (cr);
 
329
}
 
330
 
 
331
 
 
332
 
 
333
static void
 
334
thunar_icon_renderer_color_lighten (cairo_t   *cr,
 
335
                                    GtkWidget *widget)
 
336
{
 
337
  cairo_pattern_t *source;
 
338
 
 
339
  cairo_save (cr);
 
340
 
 
341
  source = cairo_pattern_reference (cairo_get_source (cr));
 
342
  cairo_set_source_rgb (cr, .15, .15, .15);
 
343
  cairo_set_operator (cr, CAIRO_OPERATOR_COLOR_DODGE);
 
344
 
 
345
  cairo_mask (cr, source);
 
346
 
 
347
  cairo_pattern_destroy (source);
 
348
  cairo_restore (cr);
 
349
}
 
350
 
 
351
 
 
352
 
 
353
static void
312
354
thunar_icon_renderer_render (GtkCellRenderer     *renderer,
313
355
                             GdkWindow           *window,
314
356
                             GtkWidget           *widget,
326
368
  GdkRectangle            emblem_area;
327
369
  GdkRectangle            icon_area;
328
370
  GdkRectangle            draw_area;
329
 
  GtkStateType            state;
330
371
  GdkPixbuf              *emblem;
331
372
  GdkPixbuf              *icon;
332
373
  GdkPixbuf              *temp;
337
378
  cairo_t                *cr;
338
379
  gdouble                 alpha;
339
380
  gint                    emblem_size;
 
381
  gboolean                color_selected;
 
382
  gboolean                color_lighten;
340
383
 
341
384
  if (G_UNLIKELY (icon_renderer->file == NULL))
342
385
    return;
382
425
  icon_area.x = cell_area->x + (cell_area->width - icon_area.width) / 2;
383
426
  icon_area.y = cell_area->y + (cell_area->height - icon_area.height) / 2;
384
427
 
 
428
  /* bools for cairo transformations */
 
429
  color_selected = (flags & GTK_CELL_RENDERER_SELECTED) != 0 && icon_renderer->follow_state;
 
430
  color_lighten = (flags & GTK_CELL_RENDERER_PRELIT) != 0 && icon_renderer->follow_state;
 
431
 
385
432
  /* create the context */
386
433
  cr = gdk_cairo_create (window);
387
434
 
406
453
        }
407
454
      g_object_unref (G_OBJECT (clipboard));
408
455
 
409
 
      /* colorize the icon if we should follow the selection state */
410
 
      if ((flags & (GTK_CELL_RENDERER_SELECTED | GTK_CELL_RENDERER_PRELIT)) != 0 && icon_renderer->follow_state)
411
 
        {
412
 
          if ((flags & GTK_CELL_RENDERER_SELECTED) != 0)
413
 
            {
414
 
              state = gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
415
 
              temp = exo_gdk_pixbuf_colorize (icon, &widget->style->base[state]);
416
 
              g_object_unref (G_OBJECT (icon));
417
 
              icon = temp;
418
 
            }
419
 
 
420
 
          if ((flags & GTK_CELL_RENDERER_PRELIT) != 0)
421
 
            {
422
 
              temp = exo_gdk_pixbuf_spotlight (icon);
423
 
              g_object_unref (G_OBJECT (icon));
424
 
              icon = temp;
425
 
            }
426
 
        }
427
 
 
428
456
      /* check if we should render an insensitive icon */
429
457
      if (G_UNLIKELY (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE || !renderer->sensitive))
430
458
        {
448
476
      thunar_gdk_cairo_set_source_pixbuf (cr, icon, icon_area.x, icon_area.y);
449
477
      gdk_cairo_rectangle (cr, &draw_area);
450
478
      cairo_paint_with_alpha (cr, alpha);
 
479
 
 
480
      /* paint the lighten mask */
 
481
      if (color_lighten)
 
482
        thunar_icon_renderer_color_lighten (cr, widget);
 
483
 
 
484
      /* paint the selected mask */
 
485
      if (color_selected)
 
486
        thunar_icon_renderer_color_selected (cr, widget);
451
487
    }
452
488
 
453
489
  /* release the file's icon */
533
569
                  thunar_gdk_cairo_set_source_pixbuf (cr, emblem, emblem_area.x, emblem_area.y);
534
570
                  gdk_cairo_rectangle (cr, &draw_area);
535
571
                  cairo_paint (cr);
 
572
 
 
573
                  /* paint the lighten mask */
 
574
                  if (color_lighten)
 
575
                    thunar_icon_renderer_color_lighten (cr, widget);
 
576
 
 
577
                  /* paint the selected mask */
 
578
                  if (color_selected)
 
579
                    thunar_icon_renderer_color_selected (cr, widget);
536
580
                }
537
581
 
538
582
              /* release the emblem */