Page 1 of 1

GTK+ Api & StatusBar

Posted: Sat Apr 11, 2009 7:51 pm
by Progi1984
hello all,

I'm looking for how to modify status bar and its fields with API.

Have someone some clues or code ?

Posted: Tue Apr 14, 2009 1:24 pm
by walker
it would be very interesting, how Fred has implemented this in PB.
The GTK status bar itself only supports (AFAIK) one field.. this can be modified with

Code: Select all

gtk_statusbar_push ()
gtk_statusbar_pop()
gtk_statusbar_remove ()
my guess is that the parent of the statusbar is an vbox and therefore you can add textfields (or every other widget!) to this vbox if you know it's handle .... (I think, that is the way it's implemented in PB)

i will verify this in the evening (no time atm) at home ....

Posted: Tue Apr 14, 2009 1:28 pm
by freak
The PB statusbar is just a vbox with labels inside.

Posted: Tue Apr 14, 2009 5:23 pm
by walker
...as I thought ... and a gtk_fixed - I guess - as otherwise no fixed length of the statusbarfields are possible...? anyway

as I found out, CreateStatusbar() returns the ID of the vbox ... so its extremely easy to create a statusbar containing all types of widgets.... :D

a small example:

Code: Select all

Procedure to_utf8(txt.s)
    mem=AllocateMemory(Len(txt)*6)
    PokeS(mem,txt,-1,#PB_UTF8)
    ProcedureReturn mem
EndProcedure

OpenWindow(0,0,0,500,500,"statusbar-test",#PB_Window_SystemMenu)
st=CreateStatusBar(0,WindowID(0))

 *button2 = gtk_button_new_();
  gtk_widget_show_(*button2);
  gtk_box_pack_start_(st, *button2, #False, #False, 0);
  gtk_button_set_relief_(*button2, #GTK_RELIEF_NONE);
  
  icon=to_utf8("gtk-media-play")
  *image7 = gtk_image_new_from_stock_(icon, #GTK_ICON_SIZE_MENU);
  FreeMemory(icon)
  gtk_widget_show_(*image7);
  gtk_container_add_(*button2, *image7);
  
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow