diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-01-20 17:27:12 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-01-20 21:27:18 +0100 |
commit | f7c838f3d112727cc9cdba610f862355998ee009 (patch) | |
tree | 7863c8ddfe544dbb043bd2fddd39c2ec5d4311ee | |
parent | 177387fa50e9e95a436584bea74613d4aee0be26 (diff) |
gtk4: implement SalGtkFilePicker::SetCurFilter
Change-Id: Ia147336c52422fb76600760526f3f020a052fd1c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128700
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx index 3c52b7ca3981..be3edd0306aa 100644 --- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx @@ -1831,14 +1831,24 @@ void SAL_CALL SalGtkFilePicker::cancel() void SalGtkFilePicker::SetCurFilter( const OUString& rFilter ) { -#if !GTK_CHECK_VERSION(4, 0, 0) // Get all the filters already added - GSList *filters = gtk_file_chooser_list_filters ( GTK_FILE_CHOOSER( m_pDialog ) ); - bool bFound = false; +#if GTK_CHECK_VERSION(4, 0, 0) + GListModel *filters = gtk_file_chooser_get_filters(GTK_FILE_CHOOSER(m_pDialog)); +#else + GSList *filters = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(m_pDialog)); +#endif - for( GSList *iter = filters; !bFound && iter; iter = iter->next ) +#if GTK_CHECK_VERSION(4, 0, 0) + int nIndex = 0; + while (gpointer pElem = g_list_model_get_item(filters, nIndex)) { - GtkFileFilter* pFilter = static_cast<GtkFileFilter *>( iter->data ); + GtkFileFilter* pFilter = static_cast<GtkFileFilter*>(pElem); + ++nIndex; +#else + for( GSList *iter = filters; iter; iter = iter->next ) + { + GtkFileFilter* pFilter = static_cast<GtkFileFilter*>( iter->data ); +#endif const gchar * filtername = gtk_file_filter_get_name( pFilter ); OUString sFilterName( filtername, strlen( filtername ), RTL_TEXTENCODING_UTF8 ); @@ -1847,13 +1857,14 @@ void SalGtkFilePicker::SetCurFilter( const OUString& rFilter ) { SAL_INFO( "vcl.gtk", "actually setting " << filtername ); gtk_file_chooser_set_filter( GTK_FILE_CHOOSER( m_pDialog ), pFilter ); - bFound = true; + break; } } +#if !GTK_CHECK_VERSION(4, 0, 0) g_slist_free( filters ); #else - (void)rFilter; + g_object_unref (filters); #endif } |