[Git][wxwidgets/wxwidgets][master] Fix wxDirPickerCtrl with GTK >= 3.20

1 view
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Oct 21, 2025, 10:34:07 AMOct 21
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • ded7c610
    by Paul Cornett at 2025-10-21T07:09:38-07:00
    Fix wxDirPickerCtrl with GTK >= 3.20
    
    GtkFileChooserNative will not be used when wxDirDialog is used by
    wxDirPickerCtrl, so make sure values will be retrieved from
    GtkFileChooserDialog and not the unused "native" chooser.
    See #25901
    

2 changed files:

Changes:

  • include/wx/gtk/dirdlg.h
    ... ... @@ -45,6 +45,7 @@ public:
    45 45
     
    
    46 46
         void GTKOnAccept();
    
    47 47
         void GTKOnCancel();
    
    48
    +    void GTKDropNative();
    
    48 49
     
    
    49 50
     protected:
    
    50 51
         // override this from wxTLW since the native
    

  • src/gtk/dirdlg.cpp
    ... ... @@ -44,6 +44,15 @@ static void gtk_dirdialog_response_callback(GtkWidget * WXUNUSED(w),
    44 44
         else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE
    
    45 45
             dialog->GTKOnCancel();
    
    46 46
     }
    
    47
    +
    
    48
    +#if GTK_CHECK_VERSION(3,20,0)
    
    49
    +static void wx_dirdialog_show(GtkWidget*, wxDirDialog* win)
    
    50
    +{
    
    51
    +    // If m_widget is shown, then GtkFileChooserNative is not being used.
    
    52
    +    // This happens when using wxDirPickerCtrl, for example.
    
    53
    +    win->GTKDropNative();
    
    54
    +}
    
    55
    +#endif
    
    47 56
     }
    
    48 57
     
    
    49 58
     //-----------------------------------------------------------------------------
    
    ... ... @@ -118,6 +127,7 @@ bool wxDirDialog::Create(wxWindow* parent,
    118 127
                 gtk_parent,
    
    119 128
                 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
    
    120 129
                 nullptr, nullptr));
    
    130
    +        g_signal_connect(m_widget, "show", G_CALLBACK(wx_dirdialog_show), this);
    
    121 131
         }
    
    122 132
         else
    
    123 133
     #endif
    
    ... ... @@ -201,6 +211,16 @@ void wxDirDialog::GTKOnCancel()
    201 211
         EndDialog(wxID_CANCEL);
    
    202 212
     }
    
    203 213
     
    
    214
    +void wxDirDialog::GTKDropNative()
    
    215
    +{
    
    216
    +    if (m_fileChooser != (GtkFileChooser*)m_widget)
    
    217
    +    {
    
    218
    +        g_object_unref(m_fileChooser);
    
    219
    +        m_fileChooser = (GtkFileChooser*)m_widget;
    
    220
    +        g_object_ref(m_fileChooser);
    
    221
    +    }
    
    222
    +}
    
    223
    +
    
    204 224
     int wxDirDialog::ShowModal()
    
    205 225
     {
    
    206 226
         WX_HOOK_MODAL_DIALOG();
    
    ... ... @@ -252,6 +272,8 @@ void wxDirDialog::SetPath(const wxString& dir)
    252 272
         if (wxDirExists(dir))
    
    253 273
         {
    
    254 274
             gtk_file_chooser_set_current_folder(m_fileChooser, wxGTK_CONV_FN(dir));
    
    275
    +        if (m_fileChooser != (GtkFileChooser*)m_widget)
    
    276
    +            gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxGTK_CONV_FN(dir));
    
    255 277
         }
    
    256 278
     }
    
    257 279
     
    


View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help Notification message regarding https://gitlab.com/wxwidgets/wxwidgets/-/commit/ded7c61096a5491dd24276156ba16e3100f92a31 at 1761057241

Reply all
Reply to author
Forward
0 new messages