Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Maemo: Developers

How to make a image in a button displayed in its original size

 

 

Maemo developers RSS feed   Index | Next | Previous | View Threaded


peter.j.zhu at intel

Oct 18, 2007, 2:45 AM

Post #1 of 3 (303 views)
Permalink
How to make a image in a button displayed in its original size

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.

Anybody here has such experience for such issue?

Thanks,
Peter
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


xan.lopez at gmail

Oct 18, 2007, 5:29 AM

Post #2 of 3 (273 views)
Permalink
Re: How to make a image in a button displayed in its original size [In reply to]

On 10/18/07, Zhu, Peter J <peter.j.zhu [at] intel> 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.

Hope it helps,

Cheers Xan

> Anybody here has such experience for such issue?
>
> Thanks,
> Peter
> _______________________________________________
> maemo-developers mailing list
> maemo-developers [at] maemo
> https://lists.maemo.org/mailman/listinfo/maemo-developers
>
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


peter.j.zhu at intel

Oct 18, 2007, 6:48 AM

Post #3 of 3 (267 views)
Permalink
RE: How to make a image in a button displayed in its original size [In reply to]

Xan wrote:
> On 10/18/07, Zhu, Peter J <peter.j.zhu [at] intel> 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
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers

Maemo developers RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.