changing a widget's color at runtime

Once again a gtk-- questions on gtk-list ...

My question was anserwed last time and nobody complained about the fact
that it was gtk--, please tell me to go away (and preferably where to go)
if gtk-- questions bug you.

I'm changing a widget's (label in particular) color at run time and am
using the following code to do so:

void some_cute_class_name::set_status_lbl_color(const Gdk_Color &color) {

  Gtk::Style *cur_style = status_lbl_1->get_style();

  cur_style = cur_style->copy();             
  cur_style->set_fg(GTK_STATE_NORMAL, color);



This works, but it leaves me with these questions:

Calling set_style() when leaving out the call to copy() doesn't update the
appearance, is this because set_style() comparse the style's address, as
opposed to members to determine if anything has changed?

When learning how to make runtime color changes possible I ran into a
function called ensure_style() (before I discovered that a call to copy()
makes it behave as expected I had something like this:

lbl->get_style()->set_fg(GTK_STATE_NORMAL, color);

which didn't produce the desired results ... am I misinterpreting the
function name?

am I introducing a memory leak by making a copy of the style and never
disposing of the original?

should I make two copies of the style beacuse I'm calling set_style() for
two different widgets?

thank you for answers to any of these questions!

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]