GTK+ Api & StatusBar

Linux specific forum
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

GTK+ Api & StatusBar

Post by Progi1984 »

hello all,

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

Have someone some clues or code ?
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post 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 ....
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

The PB statusbar is just a vbox with labels inside.
quidquid Latine dictum sit altum videtur
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post 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
Post Reply