¿Cómo hago que un GtkComboBox(Text) se expanda horizontalmente (hexpand) dentro de un GtkToolItem?
Estoy intentando incrustar un GtkComboBoxText en una GtkToolbar (similar a un campo de URL) a través de un GtkToolItem. Es la parte más importante de la barra de herramientas, por lo que me gustaría que ocupara todo el espacio disponible.
He intentado establecer hexpand
como true en varios niveles de la cadena de contenedores, desde la toolbar hasta el GtkComboBoxText (ejemplo a continuación) y también en el GtkEntry y GtkCellAreaBox incrustados en cada contenedor intermedio al que pude acceder.
Al resaltar con el inspector, parece que la toolbar está bien con la toma de todo el espacio horizontal, pero no el toolitem, sin importar lo que contenga. Pero eso es suposición.
(Mi código está en Haskell, gi-gtk-3.0.37, enlazado dinámicamente a gtk3.22.30, pero no supongo que eso cambie algo)
main :: IO ()
main = do
Gtk.init Nothing
win <- new Gtk.Window [ #title := "win" ]
on win #destroy Gtk.mainQuit
vbox <- new Gtk.Box [ #orientation := Gtk.OrientationVertical ]
#add win vbox
hbox <- new Gtk.Box [ #orientation := Gtk.OrientationHorizontal ]
#add vbox hbox
f1 <- new Gtk.Label [ #label := "filler 1" ]
#add hbox f1
cb1 <- new Gtk.ComboBoxText [ #hexpand := True ]
#add hbox cb1
f2 <- new Gtk.Label [ #label := "filler 2" ]
#add hbox f2
tb <- new Gtk.Toolbar []
#add vbox tb
f3 <- new Gtk.ToolButton [ #label := "filler 3" ]
#add tb f3
tbi <- new Gtk.ToolItem [ #hexpand := True ]
#add tb tbi
cb2 <- new Gtk.ComboBoxText [ #hexpand := True ]
#add tbi cb2
f4 <- new Gtk.ToolButton [ #label := "filler 4" ]
#add tb f4
#showAll win
Gtk.main
Mi objetivo es obtener resultados similares entre el hbox (arriba) y la toolbar (abajo).
¿Es posible este tipo de comportamiento? ¿Estoy usando GtkToolbar de forma incorrecta?
davy.ai
Para hacer que el
GtkComboBoxText
ocupe tanto espacio como sea posible dentro de laGtkToolbar
, establezca la propiedadexpand
delGtkToolItem
enTrue
y la propiedadfill
enTrue
. Esto hará que elGtkComboBoxText
se expanda para ocupar el espacio disponible dentro de laGtkToolbar
. Aquí está el código modificado:Esto debería producir el comportamiento deseado, con el
GtkComboBoxText
ocupando tanto espacio como sea posible dentro de laGtkToolbar
.