Don't use stock items in wxFileDialog

Stock items are deprecated since GTK+ 3.10 so corresponding labels
should be used instead of them.
This commit is contained in:
Artur Wieczorek
2017-12-16 23:54:06 +01:00
parent 77756fae5d
commit da1d45e8bb

View File

@@ -21,6 +21,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include "wx/gtk/private/mnemonics.h"
#ifdef __UNIX__ #ifdef __UNIX__
#include <unistd.h> // chdir #include <unistd.h> // chdir
@@ -213,24 +214,37 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
if (parent) if (parent)
gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
const gchar* ok_btn_stock; wxString ok_btn_stock;
if ( style & wxFD_SAVE ) if ( style & wxFD_SAVE )
{ {
gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE; gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE;
#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0)
ok_btn_stock = wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_SAVE));
#else
ok_btn_stock = GTK_STOCK_SAVE; ok_btn_stock = GTK_STOCK_SAVE;
#endif // GTK >= 3.10 / < 3.10
} }
else else
{ {
gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN; gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN;
#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0)
ok_btn_stock = wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_OPEN));
#else
ok_btn_stock = GTK_STOCK_OPEN; ok_btn_stock = GTK_STOCK_OPEN;
#endif // GTK >= 3.10 / < 3.10
} }
m_widget = gtk_file_chooser_dialog_new( m_widget = gtk_file_chooser_dialog_new(
wxGTK_CONV(m_message), wxGTK_CONV(m_message),
gtk_parent, gtk_parent,
gtk_action, gtk_action,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, #if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0)
ok_btn_stock, GTK_RESPONSE_ACCEPT, static_cast<const gchar*>(wxGTK_CONV(wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_CANCEL)))),
#else
GTK_STOCK_CANCEL,
#endif // GTK >= 3.10 / < 3.10
GTK_RESPONSE_CANCEL,
static_cast<const gchar*>(wxGTK_CONV(ok_btn_stock)), GTK_RESPONSE_ACCEPT,
NULL); NULL);
g_object_ref(m_widget); g_object_ref(m_widget);
GtkFileChooser* file_chooser = GTK_FILE_CHOOSER(m_widget); GtkFileChooser* file_chooser = GTK_FILE_CHOOSER(m_widget);