[maemo-developers] How to make a image in a button displayed in its original size

From: Zhu, Peter J peter.j.zhu at intel.com
Date: Thu Oct 18 16:48:44 EEST 2007
Xan wrote:
> On 10/18/07, Zhu, Peter J <peter.j.zhu at intel.com> wrote:
>> Hi,
>> 
>> I met a disgusting issue as applying a image defined in a gtkrc
>> style to a GtkButton. It can't be displayed as original picture size
>> but a very small size. The GtkButton doesn't have a child of
>> GtkImage because sapwood gtk engine only supports BOX paint for
>> button, no pic/image paint for gtkimage in my experience. To make it
>> seen, the only way I found is of using gtk_widget_set_size_request()
>> on the button. But this is ugly and can't change size dynamically
>> with change of picture. 
>> 
> 
> I'm not entirely sure of what is your problem, but packing a GtkImage
> inside a button works just fine in maemo and it won't do any hidden
> scaling as long as you don't ask it to AFAIK. Something like:
> 
>   image = gtk_image_new_from_file ("foo.png");
>   button = gtk_button_new ();
>   gtk_container_add (GTK_CONTAINER (button), image);
> 
> should work.
> 
Thanks for your mail. But I can't use GtkImage inside button for my case
because I want to use gtkrc mechanism to change button picture with
change of theme like below

style "bar"
   {
        GtkButton::child_displacement_x = 0    
        GtkButton::child_displacement_y = 0    
        engine "sapwood" {
                 image {
                           function = BOX
                           state = NORMAL
                           file = "../images/bar.png"
                 }
        }
   }
   widget "*.bar.*" style: hightest "bar"

I want to apply button named after "bar" to a special style with a
special picture. If I use a GtkImage of foo.png contained within this
button,  the picture of "bar.png" will be overlayed by foo.png. Any
ideas?

Thanks,
Peter

More information about the maemo-developers mailing list