Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-10-17 12:31:42 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-10-30 14:13:48 (GMT)
commitf5b96e1fbd1d3e8fc2b781b159820ac56be68062 (patch)
tree837cd70801f1bdc118a90b37e5e0c11166001d3d
parent63a34191b18c23338752d4f4f16636a99398aaea (diff)
CellRendererIcon: add prelight state and render background - SL #3989
This is to provide feedback on mouse over. The styling needs to be done in the artwork component. Because cell renderers don't inherit GtkWidget anymore, the styling can't be done using the __gtype_name__ . Instead, it has to be done adding a css class [1] to the style context, and rendering the background in the reimplementation of the do_render method. For reference, see how GtkCellRendererToggle implements render [2] and how Baobab app does it [3]. [1] http://developer.gnome.org/gtk3/3.2/GtkStyleContext.html#gtk-style-context-add-class [2] http://git.gnome.org/browse/gtk+/tree/gtk/gtkcellrenderertoggle.c#n338 [3] http://git.gnome.org/browse/baobab/tree/src/baobab-cellrenderers.vala#n125 Signed-off-by: Manuel Quiñones <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r--src/sugar3/graphics/icon.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
index 2d66cf9..60c1804 100644
--- a/src/sugar3/graphics/icon.py
+++ b/src/sugar3/graphics/icon.py
@@ -760,7 +760,7 @@ class CellRendererIcon(Gtk.CellRenderer):
self._prelit_stroke_color = None
self._palette_invoker = CellRendererInvoker()
- GObject.GObject.__init__(self)
+ Gtk.CellRenderer.__init__(self)
self._palette_invoker.attach_cell_renderer(tree_view, self)
@@ -882,6 +882,23 @@ class CellRendererIcon(Gtk.CellRenderer):
return False
def do_render(self, cr, widget, background_area, cell_area, flags):
+ context = widget.get_style_context()
+ context.save()
+ context.add_class("sugar-icon-cell")
+
+ # The context will have prelight state if the mouse pointer is
+ # in the entire row, but we want that state if the pointer is
+ # in this cell only:
+ if flags & Gtk.CellRendererState.PRELIT:
+ if not self._is_prelit(widget):
+ context.set_state(Gtk.StateFlags.NORMAL)
+
+ Gtk.render_background(context, cr, background_area.x, background_area.y,
+ background_area.width, background_area.height)
+
+ Gtk.render_frame(context, cr, background_area.x, background_area.y,
+ background_area.width, background_area.height)
+
if self._xo_color is not None:
stroke_color = self._xo_color.get_stroke_color()
fill_color = self._xo_color.get_fill_color()