Page 1 of 1
Adding Combobox to Toolbar? [SOLVED]
Posted: Fri Aug 01, 2014 5:33 pm
by garretthylltun
I saw that in the past there was a userlib for a toolbar that allowed one to add various gadgets beyond the standard toolbar included in PB. Unfortunately that userlib no longer works, likely due to outdated code.
Does anyone know how to add a combobox or any other gadgets to the default toolbar gadget in PB for linux?
Thanks,
~Garrett
Re: Adding Combobox to Toolbar?
Posted: Sat Aug 02, 2014 8:06 am
by kernadec
hi,
With Linux I have Not tested maybe use a ContainerGadget on toolbargadget To insert the comboboxgadget
post look code n°3
http://www.purebasic.fr/french/viewtopi ... =6&t=13352
best regards
Re: Adding Combobox to Toolbar?
Posted: Sat Aug 02, 2014 12:19 pm
by Shardik
You may try this small code example for displaying a ComboBox in the ToolBar. I have tested it with PB 5.22 on these systems:
- Ubuntu 12.04 x64 with KDE, Unity and Enlightenment
- Lubuntu 14.04 x86 with LXDE
Code: Select all
OpenWindow(0, 100, 100, 150, 80, "ToolBar", #PB_Window_SystemMenu)
CreateToolBar(0, WindowID(0))
; ----- Create ComboBoxGadget
ComboBoxGadget(0, 0, 0, 80, 25)
AddGadgetItem(0, -1, "Item 1")
AddGadgetItem(0, -1, "Item 2")
SetGadgetState(0, 0)
; ----- Create tool item and move ComboBox into tool item
ToolItem = gtk_tool_item_new_()
gtk_tool_item_set_visible_horizontal_(ToolItem, #True)
gtk_toolbar_insert_(ToolBarID(0), ToolItem, -1)
gtk_widget_reparent_(GadgetID(0), ToolItem)
; ----- Fix for KDE (not neccessary for Unity, LXDE or Enlightenment):
; Let menu drop down and up again to enable selection on entire width of
; ComboBox (without this action the first click onto the down arrow won't
; be detected in KDE although a click onto the item text will work!)
gtk_combo_box_popup_(GadgetID(0))
gtk_combo_box_popdown_(GadgetID(0))
; ----- Redisplay window to show modified ToolBar
gtk_widget_show_all_(WindowID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_Change
Debug "ComboBox item selected: " + GetGadgetText(0)
EndIf
EndSelect
ForEver
Re: Adding Combobox to Toolbar?
Posted: Sat Aug 02, 2014 4:17 pm
by garretthylltun
Thank you very much.
BTW, where would I find documentations regarding "gtk_"??
~Garrett
Re: Adding Combobox to Toolbar?
Posted: Sat Aug 02, 2014 4:35 pm
by Shardik
garretthylltun wrote:BTW, where would I find documentations regarding "gtk_"??
GTK+ 2 Reference Manual
Re: Adding Combobox to Toolbar?
Posted: Sat Aug 02, 2014 4:45 pm
by garretthylltun
Yup, just found it, but the GTK3 docs. Need to use GTK2 then I see.
Thanks a bunch,
~Garrett