Adding Combobox to Toolbar? [SOLVED]

Linux specific forum
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Adding Combobox to Toolbar? [SOLVED]

Post 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
Last edited by garretthylltun on Sat Aug 02, 2014 5:11 pm, edited 1 time in total.
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
· Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
· http://www.freewarehome.com/ <-- Freeware listings since 1996
User avatar
kernadec
Enthusiast
Enthusiast
Posts: 146
Joined: Tue Jan 05, 2010 10:35 am

Re: Adding Combobox to Toolbar?

Post 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
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Adding Combobox to Toolbar?

Post 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
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Re: Adding Combobox to Toolbar?

Post by garretthylltun »

Thank you very much.

BTW, where would I find documentations regarding "gtk_"??

~Garrett
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
· Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
· http://www.freewarehome.com/ <-- Freeware listings since 1996
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Adding Combobox to Toolbar?

Post by Shardik »

garretthylltun wrote:BTW, where would I find documentations regarding "gtk_"??
GTK+ 2 Reference Manual
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Re: Adding Combobox to Toolbar?

Post by garretthylltun »

Yup, just found it, but the GTK3 docs. Need to use GTK2 then I see.

Thanks a bunch,
~Garrett
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
· Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
· http://www.freewarehome.com/ <-- Freeware listings since 1996
Post Reply