aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-05 19:12:55 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-05 19:12:55 +0000
commit0fe1ea5250b65826ef26195c5e87c340f7798f67 (patch)
tree6ff5804cd744e6cb16ab167f9ee3b5e7e2c6901d
parent80454b910a4644e216eee7b5ac08bd032836c5f7 (diff)
downloadpaludis-0fe1ea5250b65826ef26195c5e87c340f7798f67.tar.gz
paludis-0fe1ea5250b65826ef26195c5e87c340f7798f67.tar.xz
Improve CellRendererButton somewhat more
-rw-r--r--src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc26
-rw-r--r--src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh5
2 files changed, 25 insertions, 6 deletions
diff --git a/src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc b/src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc
index cf01443..c7a6ab1 100644
--- a/src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc
+++ b/src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc
@@ -19,9 +19,25 @@
#include "cellrendererbutton.hh"
#include <gtkmm/enums.h>
+#include <iomanip>
+#include <sstream>
using namespace gtkpaludis;
+namespace
+{
+ std::string
+ gdk_color_to_colour_string(const Gdk::Color & c)
+ {
+ std::stringstream rs, gs, bs;
+ rs << std::hex << std::setw(4) << std::setfill('0') << c.get_red();
+ gs << std::hex << std::setw(4) << std::setfill('0') << c.get_green();
+ bs << std::hex << std::setw(4) << std::setfill('0') << c.get_blue();
+
+ return "#" + rs.str() + gs.str() + bs.str();
+ }
+}
+
CellRendererButton::CellRendererButton() :
Glib::ObjectBase(typeid(CellRendererButton)),
Gtk::CellRendererText()
@@ -81,10 +97,13 @@ CellRendererButton::render_vfunc(const Glib::RefPtr<Gdk::Drawable> & window,
if (width <= 0 || height <= 0)
return;
+#if 0
Gtk::StateType state = Gtk::STATE_INSENSITIVE;
if (flags & Gtk::CELL_RENDERER_SELECTED)
state = widget.has_focus() ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
-
+#else
+ Gtk::StateType state(Gtk::STATE_ACTIVE);
+#endif
const Gtk::ShadowType shadow = Gtk::SHADOW_OUT;
Glib::RefPtr<Gdk::Window> window_casted = Glib::RefPtr<Gdk::Window>::cast_dynamic<>(window);
@@ -94,6 +113,11 @@ CellRendererButton::render_vfunc(const Glib::RefPtr<Gdk::Drawable> & window,
widget, "button", cell_area.get_x() + x_offset + cell_x_pad,
cell_area.get_y() + y_offset + cell_y_pad, width - 1, height - 1);
+ /* using property_attributes() sometimes breaks on redraws */
+ widget.ensure_style();
+ std::string colour_string(gdk_color_to_colour_string(widget.get_style()->get_fg(state)));
+ property_markup() = "<markup><span foreground=\"" + colour_string +
+ "\">" + property_text() + "</span></markup>";
CellRendererText::render_vfunc(window, widget, r, cell_area, rr, flags);
}
}
diff --git a/src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh b/src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh
index 12254e7..3da4791 100644
--- a/src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh
+++ b/src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh
@@ -32,11 +32,6 @@ namespace gtkpaludis
class CellRendererButton :
public Gtk::CellRendererText
{
- private:
- static const unsigned int _button_width = 80;
- static const unsigned int _button_height = 30;
-
-
protected:
virtual void get_size_vfunc(Gtk::Widget & widget, const Gdk::Rectangle * cell_area,
int * x_offset, int * y_offset, int * width, int * height) const;