Another option which I used in my Gtk days is to declare the styles in a normal rc-string and declare a style with a symbolic name e.g. "title" as follows:
Gtk::Rc->parse_string(<<__); style "title" { font = "-itc-zapfchancery-medium-i-normal-*-*-300-*-*-p-*-iso8859-1" } style "red" { bg[NORMAL] = "#ff0000" fg[NORMAL] = "#000000" bg[ACTIVE] = "#ff0000" bg[PRELIGHT] = "#ff0000" base[NORMAL] = "#ff0000" font = "nil2" } widget "*title" style "title" widget "*red*" style "red" __ } and then use this style in a widget by setting its name to the symbolic name. $label->set_name("title"); $label_red->set_name("red"); The same technique works in Gtk2 as well, and is as far as I understand the preferable way of controlling appearance, since your appearance gets concentrated into a single place, the style definition. Regards, Dov On Fri, Apr 15, 2005 at 08:36:30AM -0400, muppet wrote: > > On Apr 15, 2005, at 7:10 AM, David Morel wrote: > > >All I want is have an individual text label turn red in a window ! How > >simpler can it get ? It would most certainly be so easy in GTK2+, but I > >have no choice right now :-( > > That's unfortunate. It's trivial in gtk2. You should port at the > earliest opportunity. > > Your problem is likely that the Gtk::Label is just inheriting its > parent's style, and thus doesn't have one of its own for you to dork > with. I can't seem to find a copy of this code that hasn't been ported > to gtk2-perl, but it goes something like this: > > # dupe parent widget's style -- a label isn't guaranteed to have one > of its own > my $newstyle = $window->get_style-copy; > # set up the new style the way you want. > $font = Gtk::Gdk::Font->load > ("-*-helvetica-bold-r-normal--*-120-*-*-*-*-*"); > $newstyle->font ($font); > $newstyle->fg (0, $newcolor); # labels draw text in fg color > # explicitly tell the label to use this new style > $label->set_style ($newstyle); > > the new style object can be shared among all the labels you want to > look the same. > > -- > The door is locked. I tried to open it, but the lock is harder to pick > than a broken nose. > -- Sensei, on 'I, Ninja' > > _______________________________________________ > gtk-perl-list mailing list > gtk-perl-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-perl-list _______________________________________________ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list