[Xfce4-commits] <xfce4-notes-plugin:master> Button effect for IconButton on mouse hover (only GTK+3)
Mike Massonnet
noreply at xfce.org
Sun Nov 11 16:34:07 CET 2012
Updating branch refs/heads/master
to b4fbbd60e6b44b350baca709126f2fc82c5906e6 (commit)
from 00e6df9fcdb4ef3b23dd4eca33d0d94d9a2a18a4 (commit)
commit b4fbbd60e6b44b350baca709126f2fc82c5906e6
Author: Mike Massonnet <mmassonnet at gmail.com>
Date: Sun Nov 11 00:05:14 2012 +0100
Button effect for IconButton on mouse hover (only GTK+3)
Since GTK+3 has only background and foreground colors, the icon-button class
has a button like effect on mouse hover when sensitive.
lib/icon-button.vala | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/icon-button.vala b/lib/icon-button.vala
index 670691f..5b7fb7f 100644
--- a/lib/icon-button.vala
+++ b/lib/icon-button.vala
@@ -31,7 +31,9 @@ namespace Xnp {
set_visible_window (false);
set_above_child (true);
set_size_request (22, 22);
+#if !ENABLE_GTK3
set_border_width (2);
+#endif
enter_notify_event.connect (on_enter_notify_event);
leave_notify_event.connect (on_leave_notify_event);
@@ -42,8 +44,17 @@ namespace Xnp {
protected void set_widget_source_color (Cairo.Context cr) {
#if ENABLE_GTK3
- if (sensitive && active)
- Gdk.cairo_set_source_rgba (cr, get_style_context ().get_color (Gtk.StateFlags.PRELIGHT));
+ if (sensitive && active) {
+ int width = get_allocated_width ();
+ int height = get_allocated_height ();
+ var style_context = get_style_context ();
+ style_context.save ();
+ style_context.add_class (Gtk.STYLE_CLASS_BUTTON);
+ style_context.render_frame (cr, 0, 0, width, height);
+ style_context.render_background (cr, 0, 0, width, height);
+ style_context.restore ();
+ Gdk.cairo_set_source_rgba (cr, style_context.get_color (Gtk.StateFlags.PRELIGHT));
+ }
else if (sensitive && !active)
Gdk.cairo_set_source_rgba (cr, get_style_context ().get_color (Gtk.StateFlags.NORMAL));
else if (!sensitive)
More information about the Xfce4-commits
mailing list