diff --git a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp index f4e9a72367..90385dc2fa 100644 --- a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp +++ b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp @@ -35,6 +35,8 @@ #include #include +#include + DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, MODULE_3D_SETTINGS* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ) : @@ -117,6 +119,12 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana m_FileTree->SetFilterIndex( 0 ); } + // Fix the filter box on the file selector widget so that it always shows the start of the filter + // string in the combobox. Otherwise it will only show the end of the string, which is empty for + // all but the all supported filters option. + wxChoice* filterBox = m_FileTree->GetFilterListCtrl(); + KIPLATFORM::UI::EllipsizeChoiceBox( filterBox ); + m_FileTree->SetPath( m_previousDir ); updateDirChoiceList(); diff --git a/libs/kiplatform/gtk/ui.cpp b/libs/kiplatform/gtk/ui.cpp index c14c473abe..60fbc8fda9 100644 --- a/libs/kiplatform/gtk/ui.cpp +++ b/libs/kiplatform/gtk/ui.cpp @@ -20,10 +20,13 @@ #include +#include #include #include #include +#include + bool KIPLATFORM::UI::IsDarkTheme() { @@ -68,3 +71,23 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor ) return false; } } + + +void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice ) +{ + // This function is based on the code inside the function post_process_ui in gtkfilechooserwidget.c + GList* cells = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( aChoice->m_widget ) ); + + if( !cells ) + return; + + GtkCellRenderer* cell = (GtkCellRenderer*) cells->data; + + if( !cell ) + return; + + g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, NULL ); + + // Only the list of cells must be freed, the renderer isn't ours to free + g_list_free( cells ); +} diff --git a/libs/kiplatform/include/kiplatform/ui.h b/libs/kiplatform/include/kiplatform/ui.h index 9ddd28d96f..6978c3bfb6 100644 --- a/libs/kiplatform/include/kiplatform/ui.h +++ b/libs/kiplatform/include/kiplatform/ui.h @@ -23,6 +23,7 @@ #include +class wxChoice; class wxNonOwnedWindow; class wxWindow; @@ -76,6 +77,14 @@ namespace KIPLATFORM * @param aCursor is wxStockCursor we want to see if its acceptable */ bool IsStockCursorOk( wxStockCursor aCursor ); + + /** + * Configure a wxChoice control to ellipsize the shown text in the button with the ellipses + * placed at the end of the string. + * + * @param aChoice is the choice box to ellipsize + */ + void EllipsizeChoiceBox( wxChoice* aChoice ); } } diff --git a/libs/kiplatform/msw/ui.cpp b/libs/kiplatform/msw/ui.cpp index 1a180b55b3..9dfa0310c4 100644 --- a/libs/kiplatform/msw/ui.cpp +++ b/libs/kiplatform/msw/ui.cpp @@ -47,7 +47,7 @@ bool KIPLATFORM::UI::IsDarkTheme() return false; long val = 0; - + if( !themeKey.QueryValue( lightModeKey, &val ) ) return false; @@ -88,4 +88,10 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor ) default: return false; } -} \ No newline at end of file +} + + +void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice ) +{ + // Not implemented +} diff --git a/libs/kiplatform/osx/ui.mm b/libs/kiplatform/osx/ui.mm index 0c1a0ad72a..61d4d4c88c 100644 --- a/libs/kiplatform/osx/ui.mm +++ b/libs/kiplatform/osx/ui.mm @@ -84,4 +84,10 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor ) default: return false; } -} \ No newline at end of file +} + + +void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice ) +{ + // Not implemented +}