[solang] Simplified the CellRendererThumbnail
- From: Debarshi Ray <debarshir src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [solang] Simplified the CellRendererThumbnail
- Date: Fri, 22 Jan 2010 21:13:19 +0000 (UTC)
commit 8aeabe7684734c59cf32692141bd572b445a6561
Author: Debarshi Ray <rishi gnu org>
Date: Thu Jan 21 22:17:15 2010 +0200
Simplified the CellRendererThumbnail
+ Removed CellRendererThumbnail::extraHeight_ because it is not used
any more. Previously we needed it to cover the area of the
Gtk::CellRendererText when drawing the frame or highlighting a
selected cell. However we do not show any text now and hence it is
useless.
+ Recent versions of Gtk::IconView nicely highlights selected cells in
a way similar to what we do. Therefore, we can remove that code.
src/common/types.h | 4 ++
src/renderer/cell-renderer-thumbnail.cpp | 70 +++++------------------------
src/renderer/cell-renderer-thumbnail.h | 7 +---
3 files changed, 17 insertions(+), 64 deletions(-)
---
diff --git a/src/common/types.h b/src/common/types.h
index db09c33..879a0a8 100644
--- a/src/common/types.h
+++ b/src/common/types.h
@@ -66,6 +66,7 @@ class IconTheme;
class ListStore;
class Menu;
class Settings;
+class Style;
class ToggleAction;
class TreeModel;
class TreeModelFilter;
@@ -311,6 +312,9 @@ typedef std::vector<SearchCriterionSourcePtr> SearchCriterionSourceList;
typedef Glib::RefPtr<const Gtk::Settings> ConstSettingsPtr;
typedef Glib::RefPtr<Gtk::Settings> SettingsPtr;
+typedef Glib::RefPtr<const Gtk::Style> ConstStylePtr;
+typedef Glib::RefPtr<Gtk::Style> StylePtr;
+
typedef Glib::RefPtr<const Gtk::ToggleAction> ConstToggleActionPtr;
typedef Glib::RefPtr<Gtk::ToggleAction> ToggleActionPtr;
diff --git a/src/renderer/cell-renderer-thumbnail.cpp b/src/renderer/cell-renderer-thumbnail.cpp
index 548452e..9cc2ff4 100644
--- a/src/renderer/cell-renderer-thumbnail.cpp
+++ b/src/renderer/cell-renderer-thumbnail.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
- * Copyright (C) Debarshi Ray 2009 <rishi gnu org>
+ * Copyright (C) Debarshi Ray 2009, 2010 <rishi gnu org>
*
* Solang is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -34,7 +34,6 @@ namespace Solang
{
CellRendererThumbnail::CellRendererThumbnail() throw() :
Gtk::CellRendererPixbuf(),
- extraHeight_(0),
photo_(),
imageLoading_(0)
{
@@ -138,64 +137,25 @@ CellRendererThumbnail::render_vfunc(
cell_area.get_width() - 12);
}
- const gint height = background_area.get_height() + extraHeight_;
- const gint width = background_area.get_width();
-
- // Sometimes width is -1 - not sure what to do here.
- if (width == -1)
- {
- return;
- }
-
- const gint x = background_area.get_x();
- const gint y = background_area.get_y();
-
- const Cairo::RefPtr<Cairo::Context> context
- = window->create_cairo_context();
- const Glib::RefPtr<const Gtk::Style> style = widget.get_style();
-
- if (0 != (flags & (Gtk::CELL_RENDERER_SELECTED
+ if (0 == (flags & (Gtk::CELL_RENDERER_SELECTED
| Gtk::CELL_RENDERER_PRELIT)))
{
+ const gint height = background_area.get_height();
+ const gint width = background_area.get_width();
- Gtk::StateType state;
-
- if (0 != (flags & Gtk::CELL_RENDERER_SELECTED))
- {
- if (true == widget.has_focus())
- {
- state = Gtk::STATE_SELECTED;
- }
- else
- {
- state = Gtk::STATE_ACTIVE;
- }
- }
- else
+ // Sometimes width is -1 - not sure what to do here.
+ if (width == -1)
{
- state = Gtk::STATE_PRELIGHT;
+ return;
}
- const Gdk::Color color = style->get_base(state);
- Gdk::Cairo::set_source_color(context, color);
-
- const gint radius = 3;
+ const gint x = background_area.get_x();
+ const gint y = background_area.get_y();
- context->arc(x + radius, y + radius, radius,
- M_PI, M_PI * 1.5);
- context->arc(x + width - radius, y + radius, radius,
- M_PI * 1.5, 0);
- context->arc(x + width - radius, y + height - radius, radius,
- 0, M_PI * 0.5);
- context->arc(x + radius, y + height - radius, radius,
- M_PI * 0.5, M_PI);
- context->close_path();
+ const Cairo::RefPtr<Cairo::Context> context
+ = window->create_cairo_context();
+ const StylePtr style = widget.get_style();
- context->set_fill_rule(Cairo::FILL_RULE_WINDING);
- context->fill();
- }
- else
- {
const Gdk::Color color = style->get_dark(Gtk::STATE_NORMAL);
Gdk::Cairo::set_source_color(context, color);
@@ -211,12 +171,6 @@ CellRendererThumbnail::render_vfunc(
}
void
-CellRendererThumbnail::set_extra_height(guint height) throw()
-{
- extraHeight_ = height;
-}
-
-void
CellRendererThumbnail::set_photo(const PhotoPtr & photo) throw()
{
photo_ = photo;
diff --git a/src/renderer/cell-renderer-thumbnail.h b/src/renderer/cell-renderer-thumbnail.h
index 173568f..da4d1e9 100644
--- a/src/renderer/cell-renderer-thumbnail.h
+++ b/src/renderer/cell-renderer-thumbnail.h
@@ -1,6 +1,6 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
- * Copyright (C) Debarshi Ray 2009 <rishi gnu org>
+ * Copyright (C) Debarshi Ray 2009, 2010 <rishi gnu org>
*
* Solang is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -38,9 +38,6 @@ class CellRendererThumbnail :
~CellRendererThumbnail() throw();
void
- set_extra_height(guint height) throw();
-
- void
set_photo(const PhotoPtr & photo) throw();
protected:
@@ -62,8 +59,6 @@ class CellRendererThumbnail :
void
on_icon_theme_changed() throw();
- guint extraHeight_;
-
PhotoPtr photo_;
PixbufPtr imageLoading_;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]