Editable ComboBoxGadgets don't seem to have this problem.
I may have found a solution that can work around this problem. Tested with gtk3 on Xubuntu x32 14.04 + 17.04 and Mint KDE 18.3.
The editable ComboBoxGadget is converted to' not editable'.
Requirement: The ComboBox must be created with the flag '#PB_ComboBox_Editable', and for each ComboBoxGadget 'ComboBoxGadgetGadgetGtk3Tweak(#Gadget)' must be called.
Try it sometime. Maybe it will bypass a major gtk3 problem.
Code: Select all
ImportC ""
gtk_widget_set_can_focus(*widget.GtkWidget, can_focus)
EndImport
UsePNGImageDecoder()
; Object constants
#Win_Main = 0
#CBox1 = 0
#CBox2 = 1
#Img1 = 0
#Img2 = 1
Global.i gEvent, gQuit
Procedure ComboBoxGadget_Gtk3Tweak(Gadget)
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
If GadgetType(Gadget) = #PB_GadgetType_ComboBox
Protected *entry.GtkEntry = gtk_bin_get_child_(GadgetID(Gadget))
If *entry
If PeekS(gtk_widget_get_name_(*entry), -1, #PB_UTF8) = "GtkEntry"
gtk_editable_set_editable_(*entry, #False)
gtk_widget_set_can_focus(*entry, #False)
EndIf
EndIf
EndIf
CompilerEndIf
EndProcedure
Procedure Create_WinMain()
If OpenWindow(#Win_Main, 0, 0, 500, 180, "ComboBoxGadget gtk3 width fix", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget (#PB_Any, 5, 5, 490, 40, "Tweaked ComboBoxGadget 'editable' as 'non editable'." + #LF$ + "Watch the width-behaviour! It's similar to gtk2.")
ComboBoxGadget(#CBox1, 5, 50, 100, 21, #PB_ComboBox_Editable | #PB_ComboBox_Image)
If LoadImage(#Img1, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png")
AddGadgetItem (#CBox1, -1, "Tweaked 'ComboBox editable' as", ImageID(#Img1))
EndIf
AddGadgetItem (#CBox1, -1, "replacement for a non editable")
AddGadgetItem (#CBox1, -1, "Gtk3-ComboBoxGadget.")
SetGadgetState(#CBox1, 0)
TextGadget (#PB_Any, 5, 90, 490, 40, "The same ComboBoxGadget as PB-Standard 'non editable'." + #LF$ + "The width corresponds to the widest item text in the popup.")
ComboBoxGadget(#CBox2, 5, 130, 100, 21, #PB_ComboBox_Image)
If LoadImage(#Img2, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png")
AddGadgetItem (#CBox2, -1, "PureBasic gtk3-ComboBox, which", ImageID(#Img2))
EndIf
AddGadgetItem (#CBox2, -1, "has always the width of the widest")
AddGadgetItem (#CBox2, -1, "item text.")
SetGadgetState(#CBox2, 0)
ComboBoxGadget_Gtk3Tweak(#CBox1)
EndIf
EndProcedure
Create_WinMain()
Repeat
gEvent= WaitWindowEvent()
Select gEvent
Case #PB_Event_CloseWindow
gQuit= #True
EndSelect
Until gQuit