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

Re: changing label in a gtk2 stock item



On Mon, 28 Jan 2008 00:45:12 -0500
muppet <scott asofyet org> wrote:

>
>On Jan 26, 2008, at 10:39 AM, zentara wrote:
>
>> Someone asked this on perlmonks, and I thought it would be easy.....
>> but not. :-)
>>
>> They want to change just the Label of a button from stock_id.
>
>Would you mind linking to the original post for some context?  I'd  
>really like to know *why* you'd want to change the label of a stock  
>item, since it's generally a bad thing to do.  (E.g., you hose  
>translations and other uses in code you didn't write, etc, etc.)
>
>On the other hand, if all you mean is that you want to create a new  
>stock item that differs from an existing one by only the label and id,  
>then that's another thing.
>
>Or, if you mean that you want to change the label on a button that has  
>already been created from a stock id, that one's easy --- $button- 
> >set_label ($new_string);.  If you want to change the text but not  
>the image, then you're back to the warnings above about translations,  
>and the extra need to dig through the widget tree with crazy code like  
>this...
>
>	sub find_and_set_label_in {
>		my ($widget, $text) = @_;
>		print "@_\n";
>		if ($widget->isa (Gtk2::Container::)) {
>			$widget->foreach (sub { find_and_set_label_in ($_[0], $text); });
>		} elsif ($widget->isa (Gtk2::Label::)) {
>			$widget->set_text ($text);
>		}
>	}
>	find_and_set_label_in ($button->child, "Something");
>
>
>So, info needed.
>

Hi, thanks for responding. What I think the question was meant to be..
"how can I change the label on a stock_id button, while keeping the same icon"?

If I set_label on a stock_id button, the icon disappears.

I know I can find the icon, and use Item::Factory to make a custom
stock_id button, with the icon and a new label.  So the question
is not a problem, other than a curiosity.

As I thought about it, I guess the question is: can you subclass 
a stock_id item, and change it's label?

zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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