Page 1 of 1
Graphic on Button - how?
Posted: Fri Oct 06, 2006 8:08 pm
by Straker
How can I get the graphic on the button without using the ButtonImageGadget? Basically I want them just like the GTK defaults:
Thanks
Posted: Sat Oct 07, 2006 1:31 am
by freak
Try gtk_button_set_image_().
I'm not sure if that works if the button had no image when it was created though.
The docs say nothing about that.
The alternative is to simply remove the label widget from the button and put an
image and a new label inside (with a packing widget)
Use gtk_image_new_from_stock_() to get the default images.
Posted: Sat Oct 07, 2006 3:22 am
by Straker
Ok thanks. I'll give it a shot. I saw the examples in C relating packing but it seems like a lot of code to do it...
I'll post my results here.
Thanks
Posted: Sat Oct 07, 2006 1:14 pm
by walker
Hi,
this can be achieved like this:
Code: Select all
IncludeFile "/media/sda2/pb_source/glade2pb/missing_functions.pb"
*hwnd=OpenWindow(0,0,0,400,300,"Test",#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
*button1=ButtonGadget(#PB_Any,10,10,100,30,"")
*buttonp=PeekL(*button1)
*image1 = gtk_image_new_from_stock_("gtk-cancel", #GTK_ICON_SIZE_BUTTON);
gtk_button_set_image_(*buttonp,*image1)
gtk_button_set_label_(*buttonp,"MyText")
CloseGadgetList()
EndIf
Repeat
ev = WaitWindowEvent()
ForEver
you need either the "missing_functions.pb" found here:
http://home.arcor.de/x-linux/pure/missing_functions.pb
or you have to declare the gtk_button_set_image() funktion by yourself (Openlibrary())
It seems that the
#PB_Any returns a pointer to a pointer to a structure and not the pointer to the structure (gtk_button) itself...??

Posted: Sat Oct 07, 2006 1:49 pm
by freak
> It seems that the #PB_Any returns a pointer to a pointer to a structure and not the pointer to the structure (gtk_button) itself...??
It returns the internal PB gadget structure, just like on windows.
Simply use GadgetID(). It returns the GtkButton pointer.
Posted: Sat Oct 07, 2006 1:56 pm
by walker
...gmmpf... sometimes I'm thinking to complicated... didn't thought about GadgetID()... anyway...
