add on_name_changed() virtual method to CairoWidget

If a CairoWidget does not a GtkRC-defined style, then changing its name does not trigger on_style_changed(). Since we want to use CairoWidget::set_name()
to trigger changes in the rendering of a widget, this is ... bad. Adding on_name_changed() provides a workaround for that.
This commit is contained in:
Paul Davis 2014-03-06 09:44:33 -05:00
parent 4a915ee541
commit e4e6010cd4
2 changed files with 13 additions and 1 deletions

View file

@ -20,14 +20,17 @@
#include "gtkmm2ext/cairo_widget.h"
#include "gtkmm2ext/gui_thread.h"
#include "i18n.h"
static const char* has_cairo_widget_background_info = "has_cairo_widget_background_info";
CairoWidget::CairoWidget ()
: _active_state (Gtkmm2ext::Off)
, _visual_state (Gtkmm2ext::NoVisualState)
, _need_bg (true)
, _name_proxy (this, X_("name"))
{
_name_proxy.connect (sigc::mem_fun (*this, &CairoWidget::on_name_changed));
}
CairoWidget::~CairoWidget ()

View file

@ -75,9 +75,18 @@ protected:
void on_state_changed (Gtk::StateType);
Gdk::Color get_parent_bg ();
/* this is an additional virtual "on_..." method. Glibmm does not
provide a direct signal for name changes, so this acts as a proxy.
*/
virtual void on_name_changed () {};
Gtkmm2ext::ActiveState _active_state;
Gtkmm2ext::VisualState _visual_state;
bool _need_bg;
private:
Glib::SignalProxyProperty _name_proxy;
};
#endif