diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 09aef7482f..76ecf8644f 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -18,6 +18,7 @@ #include "wx/gtk/private.h" #include "wx/gtk/private/eventsdisabler.h" +#include "wx/gtk/private/list.h" #include "wx/gtk/private/value.h" // ---------------------------------------------------------------------------- @@ -78,6 +79,17 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, #ifdef __WXGTK3__ m_widget = gtk_combo_box_text_new(); + + // If any choices don't fit into the available space (in the always visible + // part of the control, not the dropdown), GTK shows just the tail of the + // string which does fit, which is bad for long strings and even worse for + // the shorter ones, as they may end up being shown as completely blank. + // Work around this brokenness by enabling ellipsization, especially as it + // seems to be safe to do it unconditionally, i.e. there doesn't seem to be + // any ill effects from having it on if everything does fit. + const wxGtkList cells(gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_widget))); + if (GTK_IS_CELL_RENDERER_TEXT(cells->data)) + g_object_set(G_OBJECT(cells->data), "ellipsize", PANGO_ELLIPSIZE_END, NULL); #else m_widget = gtk_combo_box_new_text(); #endif