From 9755e73bd971fcf2fcde0330df98dbd0e5e607ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 19 Nov 2004 00:30:24 +0000 Subject: [PATCH] applied modified patch with native GTK wxFileDialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30622 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 195 ++++++++++---------- build/bakefiles/files.bkl | 1 + configure | 70 +++++++- configure.in | 20 +++ docs/changes.txt | 1 + include/wx/filedlg.h | 4 + include/wx/gtk/filedlg.h | 12 +- include/wx/gtk1/filedlg.h | 12 +- setup.h.in | 5 +- setup.h_vms | 5 +- src/generic/filedlgg.cpp | 4 +- src/gtk/filedlg.cpp | 363 +++++++++++++++++++++++++++++--------- src/gtk1/filedlg.cpp | 363 +++++++++++++++++++++++++++++--------- 13 files changed, 784 insertions(+), 271 deletions(-) diff --git a/Makefile.in b/Makefile.in index 3874841940..4472a3a600 100644 --- a/Makefile.in +++ b/Makefile.in @@ -219,6 +219,7 @@ ALL_BASE_HEADERS = \ wx/afterstd.h \ wx/app.h \ wx/apptrait.h \ + wx/archive.h \ wx/arrimpl.cpp \ wx/arrstr.h \ wx/beforestd.h \ @@ -341,6 +342,7 @@ ALL_HEADERS = \ $(ALL_GUI_HEADERS) ALL_BASE_SOURCES = \ src/common/appbase.cpp \ + src/common/archive.cpp \ src/common/clntdata.cpp \ src/common/cmdline.cpp \ src/common/config.cpp \ @@ -386,7 +388,6 @@ ALL_BASE_SOURCES = \ src/common/textfile.cpp \ src/common/tokenzr.cpp \ src/common/txtstrm.cpp \ - src/common/archive.cpp \ src/common/uri.cpp \ src/common/variant.cpp \ src/common/wfstream.cpp \ @@ -466,6 +467,7 @@ MONODLL_CXXFLAGS = $(__monodll_PCH_INC) -D__WX$(TOOLKIT)__ \ -DwxUSE_BASE=1 -DWXMAKINGDLL $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS) MONODLL_OBJECTS = \ monodll_appbase.o \ + monodll_archive.o \ monodll_clntdata.o \ monodll_cmdline.o \ monodll_config.o \ @@ -511,7 +513,6 @@ MONODLL_OBJECTS = \ monodll_textfile.o \ monodll_tokenzr.o \ monodll_txtstrm.o \ - monodll_archive.o \ monodll_uri.o \ monodll_variant.o \ monodll_wfstream.o \ @@ -553,6 +554,7 @@ MONOLIB_CXXFLAGS = $(__monolib_PCH_INC) -D__WX$(TOOLKIT)__ \ -DwxUSE_BASE=1 $(CPPFLAGS) $(CXXFLAGS) MONOLIB_OBJECTS = \ monolib_appbase.o \ + monolib_archive.o \ monolib_clntdata.o \ monolib_cmdline.o \ monolib_config.o \ @@ -598,7 +600,6 @@ MONOLIB_OBJECTS = \ monolib_textfile.o \ monolib_tokenzr.o \ monolib_txtstrm.o \ - monolib_archive.o \ monolib_uri.o \ monolib_variant.o \ monolib_wfstream.o \ @@ -641,6 +642,7 @@ BASEDLL_CXXFLAGS = $(__basedll_PCH_INC) -D__WX$(TOOLKIT)__ \ $(CXXFLAGS) BASEDLL_OBJECTS = \ basedll_appbase.o \ + basedll_archive.o \ basedll_clntdata.o \ basedll_cmdline.o \ basedll_config.o \ @@ -686,7 +688,6 @@ BASEDLL_OBJECTS = \ basedll_textfile.o \ basedll_tokenzr.o \ basedll_txtstrm.o \ - basedll_archive.o \ basedll_uri.o \ basedll_variant.o \ basedll_wfstream.o \ @@ -713,6 +714,7 @@ BASELIB_CXXFLAGS = $(__baselib_PCH_INC) -D__WX$(TOOLKIT)__ \ -DwxUSE_GUI=0 -DwxUSE_BASE=1 $(CPPFLAGS) $(CXXFLAGS) BASELIB_OBJECTS = \ baselib_appbase.o \ + baselib_archive.o \ baselib_clntdata.o \ baselib_cmdline.o \ baselib_config.o \ @@ -758,7 +760,6 @@ BASELIB_OBJECTS = \ baselib_textfile.o \ baselib_tokenzr.o \ baselib_txtstrm.o \ - baselib_archive.o \ baselib_uri.o \ baselib_variant.o \ baselib_wfstream.o \ @@ -3219,6 +3220,7 @@ COND_TOOLKIT_GTK___GUI_SRC_OBJECTS = \ monodll_combobox.o \ monodll_control.o \ monodll_dialog.o \ + monodll_filedlg.o \ monodll_fontdlg.o \ monodll_frame.o \ monodll_gauge.o \ @@ -4659,6 +4661,7 @@ COND_TOOLKIT_GTK___GUI_SRC_OBJECTS_1 = \ monolib_combobox.o \ monolib_control.o \ monolib_dialog.o \ + monolib_filedlg.o \ monolib_fontdlg.o \ monolib_frame.o \ monolib_gauge.o \ @@ -6293,6 +6296,7 @@ COND_TOOLKIT_GTK___GUI_SRC_OBJECTS_2 = \ coredll_combobox.o \ coredll_control.o \ coredll_dialog.o \ + coredll_filedlg.o \ coredll_fontdlg.o \ coredll_frame.o \ coredll_gauge.o \ @@ -7483,6 +7487,7 @@ COND_TOOLKIT_GTK___GUI_SRC_OBJECTS_3 = \ corelib_combobox.o \ corelib_control.o \ corelib_dialog.o \ + corelib_filedlg.o \ corelib_fontdlg.o \ corelib_frame.o \ corelib_gauge.o \ @@ -9607,6 +9612,9 @@ wxexpat_xmltok.o: $(srcdir)/src/expat/lib/xmltok.c monodll_appbase.o: $(srcdir)/src/common/appbase.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< +monodll_archive.o: $(srcdir)/src/common/archive.cpp $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + monodll_clntdata.o: $(srcdir)/src/common/clntdata.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< @@ -9742,9 +9750,6 @@ monodll_tokenzr.o: $(srcdir)/src/common/tokenzr.cpp $(MONODLL_ODEP) monodll_txtstrm.o: $(srcdir)/src/common/txtstrm.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< -monodll_archive.o: $(srcdir)/src/common/archive.cpp $(MONODLL_ODEP) - $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< - monodll_uri.o: $(srcdir)/src/common/uri.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< @@ -11956,6 +11961,27 @@ monodll_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONODLL_ODEP) @COND_USE_GUI_1_WXUNIV_1@monodll_dialog.o: $(srcdir)/src/univ/dialog.cpp $(MONODLL_ODEP) @COND_USE_GUI_1_WXUNIV_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< +@COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/gtk/filedlg.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + +@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/motif/filedlg.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/mac/carbon/filedlg.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + +@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/cocoa/filedlg.mm $(MONODLL_ODEP) +@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + +@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/os2/filedlg.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + @COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@monodll_fontdlg.o: $(srcdir)/src/gtk/fontdlg.cpp $(MONODLL_ODEP) @COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< @@ -12373,24 +12399,6 @@ monodll_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_tglbtn.o: $(srcdir)/src/mac/carbon/tglbtn.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< -@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/motif/filedlg.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< - -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< - -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< - -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/mac/carbon/filedlg.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< - -@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/cocoa/filedlg.mm $(MONODLL_ODEP) -@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< - -@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_filedlg.o: $(srcdir)/src/os2/filedlg.cpp $(MONODLL_ODEP) -@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< - @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monodll_menuitem.o: $(srcdir)/src/motif/menuitem.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< @@ -12931,6 +12939,9 @@ monodll_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONODLL_ODEP) monolib_appbase.o: $(srcdir)/src/common/appbase.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< +monolib_archive.o: $(srcdir)/src/common/archive.cpp $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + monolib_clntdata.o: $(srcdir)/src/common/clntdata.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< @@ -13066,9 +13077,6 @@ monolib_tokenzr.o: $(srcdir)/src/common/tokenzr.cpp $(MONOLIB_ODEP) monolib_txtstrm.o: $(srcdir)/src/common/txtstrm.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< -monolib_archive.o: $(srcdir)/src/common/archive.cpp $(MONOLIB_ODEP) - $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< - monolib_uri.o: $(srcdir)/src/common/uri.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< @@ -15280,6 +15288,27 @@ monolib_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1_WXUNIV_1@monolib_dialog.o: $(srcdir)/src/univ/dialog.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1_WXUNIV_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< +@COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/gtk/filedlg.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + +@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/motif/filedlg.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/mac/carbon/filedlg.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + +@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/cocoa/filedlg.mm $(MONOLIB_ODEP) +@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + +@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/os2/filedlg.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + @COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@monolib_fontdlg.o: $(srcdir)/src/gtk/fontdlg.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< @@ -15697,24 +15726,6 @@ monolib_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_tglbtn.o: $(srcdir)/src/mac/carbon/tglbtn.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< -@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/motif/filedlg.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< - -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< - -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< - -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/mac/carbon/filedlg.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< - -@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/cocoa/filedlg.mm $(MONOLIB_ODEP) -@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< - -@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_filedlg.o: $(srcdir)/src/os2/filedlg.cpp $(MONOLIB_ODEP) -@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< - @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monolib_menuitem.o: $(srcdir)/src/motif/menuitem.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< @@ -16255,6 +16266,9 @@ monolib_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONOLIB_ODEP) basedll_appbase.o: $(srcdir)/src/common/appbase.cpp $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $< +basedll_archive.o: $(srcdir)/src/common/archive.cpp $(BASEDLL_ODEP) + $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $< + basedll_clntdata.o: $(srcdir)/src/common/clntdata.cpp $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $< @@ -16390,9 +16404,6 @@ basedll_tokenzr.o: $(srcdir)/src/common/tokenzr.cpp $(BASEDLL_ODEP) basedll_txtstrm.o: $(srcdir)/src/common/txtstrm.cpp $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $< -basedll_archive.o: $(srcdir)/src/common/archive.cpp $(BASEDLL_ODEP) - $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $< - basedll_uri.o: $(srcdir)/src/common/uri.cpp $(BASEDLL_ODEP) $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $< @@ -16729,6 +16740,9 @@ basedll_uma.o: $(srcdir)/src/mac/carbon/uma.cpp $(BASEDLL_ODEP) baselib_appbase.o: $(srcdir)/src/common/appbase.cpp $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $< +baselib_archive.o: $(srcdir)/src/common/archive.cpp $(BASELIB_ODEP) + $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $< + baselib_clntdata.o: $(srcdir)/src/common/clntdata.cpp $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $< @@ -16864,9 +16878,6 @@ baselib_tokenzr.o: $(srcdir)/src/common/tokenzr.cpp $(BASELIB_ODEP) baselib_txtstrm.o: $(srcdir)/src/common/txtstrm.cpp $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $< -baselib_archive.o: $(srcdir)/src/common/archive.cpp $(BASELIB_ODEP) - $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $< - baselib_uri.o: $(srcdir)/src/common/uri.cpp $(BASELIB_ODEP) $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $< @@ -18928,6 +18939,27 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_USE_GUI_1_WXUNIV_1@coredll_dialog.o: $(srcdir)/src/univ/dialog.cpp $(COREDLL_ODEP) @COND_USE_GUI_1_WXUNIV_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< +@COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/gtk/filedlg.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + +@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/motif/filedlg.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/mac/carbon/filedlg.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + +@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/cocoa/filedlg.mm $(COREDLL_ODEP) +@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + +@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/os2/filedlg.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + @COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@coredll_fontdlg.o: $(srcdir)/src/gtk/fontdlg.cpp $(COREDLL_ODEP) @COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< @@ -19345,24 +19377,6 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_tglbtn.o: $(srcdir)/src/mac/carbon/tglbtn.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< -@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/motif/filedlg.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< - -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< - -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< - -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/mac/carbon/filedlg.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< - -@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/cocoa/filedlg.mm $(COREDLL_ODEP) -@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< - -@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_filedlg.o: $(srcdir)/src/os2/filedlg.cpp $(COREDLL_ODEP) -@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< - @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@coredll_menuitem.o: $(srcdir)/src/motif/menuitem.cpp $(COREDLL_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< @@ -21418,6 +21432,27 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_USE_GUI_1_WXUNIV_1@corelib_dialog.o: $(srcdir)/src/univ/dialog.cpp $(CORELIB_ODEP) @COND_USE_GUI_1_WXUNIV_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< +@COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/gtk/filedlg.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + +@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/motif/filedlg.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/mac/carbon/filedlg.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + +@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/cocoa/filedlg.mm $(CORELIB_ODEP) +@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + +@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/os2/filedlg.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + @COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@corelib_fontdlg.o: $(srcdir)/src/gtk/fontdlg.cpp $(CORELIB_ODEP) @COND_TOOLKIT_GTK_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< @@ -21835,24 +21870,6 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_tglbtn.o: $(srcdir)/src/mac/carbon/tglbtn.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< -@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/motif/filedlg.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< - -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< - -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/msw/filedlg.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< - -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/mac/carbon/filedlg.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< - -@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/cocoa/filedlg.mm $(CORELIB_ODEP) -@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< - -@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_filedlg.o: $(srcdir)/src/os2/filedlg.cpp $(CORELIB_ODEP) -@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< - @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@corelib_menuitem.o: $(srcdir)/src/motif/menuitem.cpp $(CORELIB_ODEP) @COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index ca2dc8d131..4cee3f736d 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -835,6 +835,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/gtk/combobox.cpp src/gtk/control.cpp src/gtk/dialog.cpp + src/gtk/filedlg.cpp src/gtk/fontdlg.cpp src/gtk/frame.cpp src/gtk/gauge.cpp diff --git a/configure b/configure index 9f626fec50..0f904c5d97 100755 --- a/configure +++ b/configure @@ -23712,6 +23712,7 @@ equivalent variable and GTK+ is version 1.2.3 or above. CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" + for ac_func in pango_font_family_is_monospace do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -23813,6 +23814,71 @@ _ACEOF fi done + + echo "$as_me:$LINENO: checking if GTK+ is version >= 2.4" >&5 +echo $ECHO_N "checking if GTK+ is version >= 2.4... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + +int +main () +{ + + #if !GTK_CHECK_VERSION(2,4,0) + #error "Not GTK+ 2.4" + #endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + cat >>confdefs.h <<\_ACEOF +#define __WXGTK24__ 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$save_CFLAGS" LIBS="$save_LIBS" else @@ -38939,11 +39005,7 @@ fi case ${BAKEFILE_HOST} in *-hp-hpux* ) -<<<<<<< aclocal.m4 - INSTALL_DIR="mkdir" -======= INSTALL_DIR="mkdir -p" ->>>>>>> 1.69 ;; *) INSTALL_DIR="$INSTALL -d" ;; diff --git a/configure.in b/configure.in index bdbb0a656c..31f0dbad54 100644 --- a/configure.in +++ b/configure.in @@ -2543,7 +2543,27 @@ equivalent variable and GTK+ is version 1.2.3 or above. save_LIBS="$LIBS" CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" + AC_CHECK_FUNCS([pango_font_family_is_monospace]) + + dnl test if we have at least GTK+ 2.4: + AC_MSG_CHECKING([if GTK+ is version >= 2.4]) + AC_TRY_COMPILE([ + #include + ], + [ + #if !GTK_CHECK_VERSION(2,4,0) + #error "Not GTK+ 2.4" + #endif + ], + [ + AC_DEFINE(__WXGTK24__) + AC_MSG_RESULT([yes]) + ], + [ + AC_MSG_RESULT([no]) + ]) + CFLAGS="$save_CFLAGS" LIBS="$save_LIBS" else diff --git a/docs/changes.txt b/docs/changes.txt index 97778494ec..8d3876fed5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -38,6 +38,7 @@ Unix: wxGTK: - fixed wxFileDialog::SetWildcard() +- native file dialog is now used if available (Zbigniew Zagorski) wxMac: diff --git a/include/wx/filedlg.h b/include/wx/filedlg.h index 0b83e13601..21bd2595d5 100644 --- a/include/wx/filedlg.h +++ b/include/wx/filedlg.h @@ -159,7 +159,11 @@ wxSaveFileSelector(const wxChar *what, #elif defined(__WXMOTIF__) #include "wx/motif/filedlg.h" #elif defined(__WXGTK__) +#ifdef __WXGTK24__ +#include "wx/gtk/filedlg.h" +#else #include "wx/generic/filedlgg.h" +#endif #elif defined(__WXX11__) #include "wx/generic/filedlgg.h" #elif defined(__WXMGL__) diff --git a/include/wx/gtk/filedlg.h b/include/wx/gtk/filedlg.h index 2b3fd479f7..51daa86bfc 100644 --- a/include/wx/gtk/filedlg.h +++ b/include/wx/gtk/filedlg.h @@ -32,8 +32,18 @@ public: long style = 0, const wxPoint& pos = wxDefaultPosition); - virtual void SetPath(const wxString& path); + virtual void GetPaths(wxArrayString& paths) const; + virtual void GetFilenames(wxArrayString& files) const; + virtual void SetMessage(const wxString& message); + virtual void SetPath(const wxString& path); + virtual void SetDirectory(const wxString& dir); + virtual void SetFilename(const wxString& name); + virtual void SetWildcard(const wxString& wildCard); + virtual void SetFilterIndex(int filterIndex); + void UpdateFromDialog(); + void UpdateDialog(); + void DoSetPath(const wxString& path); private: DECLARE_DYNAMIC_CLASS(wxFileDialog) }; diff --git a/include/wx/gtk1/filedlg.h b/include/wx/gtk1/filedlg.h index 2b3fd479f7..51daa86bfc 100644 --- a/include/wx/gtk1/filedlg.h +++ b/include/wx/gtk1/filedlg.h @@ -32,8 +32,18 @@ public: long style = 0, const wxPoint& pos = wxDefaultPosition); - virtual void SetPath(const wxString& path); + virtual void GetPaths(wxArrayString& paths) const; + virtual void GetFilenames(wxArrayString& files) const; + virtual void SetMessage(const wxString& message); + virtual void SetPath(const wxString& path); + virtual void SetDirectory(const wxString& dir); + virtual void SetFilename(const wxString& name); + virtual void SetWildcard(const wxString& wildCard); + virtual void SetFilterIndex(int filterIndex); + void UpdateFromDialog(); + void UpdateDialog(); + void DoSetPath(const wxString& path); private: DECLARE_DYNAMIC_CLASS(wxFileDialog) }; diff --git a/setup.h.in b/setup.h.in index 9961b65d93..895fb518b4 100644 --- a/setup.h.in +++ b/setup.h.in @@ -61,9 +61,12 @@ /* Define this if your version of GTK+ is greater than 1.2.7 */ #undef __WXGTK127__ -/* Define this if your version of GTK+ is greater than 1.3 */ +/* Define this if your version of GTK+ is greater than 2.0 */ #undef __WXGTK20__ +/* Define this if your version of GTK+ is greater than 2.4 */ +#undef __WXGTK24__ + /* Define this if you want to use GPE features */ #undef __WXGPE__ diff --git a/setup.h_vms b/setup.h_vms index e5634e5e9c..4c91ef0653 100644 --- a/setup.h_vms +++ b/setup.h_vms @@ -79,8 +79,11 @@ /* Define this if your version of GTK+ is greater than 1.2.7 */ #define __WXGTK127__ 1 -/* Define this if your version of GTK+ is greater than 1.3 */ +/* Define this if your version of GTK+ is greater than 2.0 */ /* #undef __WXGTK20__ */ + +/* Define this if your version of GTK+ is greater than 2.4 */ +/* #undef __WXGTK24__ */ #endif /* diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 644fbe5576..3a6c9b3381 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -20,7 +20,7 @@ #pragma hdrstop #endif -#if wxUSE_FILEDLG +#if wxUSE_FILEDLG && !defined(__WXGTK24__) // NOTE : it probably also supports MAC, untested #if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__) && !defined(__OS2__) @@ -1416,5 +1416,5 @@ IMPLEMENT_DYNAMIC_CLASS(wxFileDialog, wxGenericFileDialog); #endif // USE_GENERIC_FILEDIALOG -#endif // wxUSE_FILEDLG +#endif // wxUSE_FILEDLG && !defined(__WXGTK24__) diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index a3fcec04f1..a9f92c274f 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -1,9 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// // Name: gtk/filedlg.cpp -// Purpose: -// Author: Robert Roebling +// Purpose: native implementation of wxFileDialog +// Author: Robert Roebling, Zbigniew Zagorski // Id: $Id$ -// Copyright: (c) 1998 Robert Roebling +// Copyright: (c) 1998 Robert Roebling, 2004 Zbigniew Zagorski // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,12 +14,15 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_FILEDLG && defined(__WXGTK24__) + #include "wx/filedlg.h" #include "wx/utils.h" #include "wx/intl.h" -#include "wx/generic/msgdlgg.h" +#include "wx/filename.h" #include +#include "wx/gtk/private.h" //----------------------------------------------------------------------------- // idle system @@ -28,94 +31,86 @@ extern void wxapp_install_idle_handler(); extern bool g_isIdle; -//----------------------------------------------------------------------------- -// "delete_event" -//----------------------------------------------------------------------------- - -static -bool gtk_filedialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - -/* - printf( "OnDelete from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - - win->Close(); - - return TRUE; -} - //----------------------------------------------------------------------------- // "clicked" for OK-button //----------------------------------------------------------------------------- -static -void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dialog ) +static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog) { - if (g_isIdle) wxapp_install_idle_handler(); - int style = dialog->GetStyle(); + gchar* text = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); + wxString filename(wxGTK_CONV_BACK(text)); - GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget); - char *filename = gtk_file_selection_get_filename(filedlg); - - if ( (style & wxSAVE) && ( style & wxOVERWRITE_PROMPT ) ) + if ((style & wxSAVE) && (style & wxOVERWRITE_PROMPT)) { - if (wxFileExists( filename )) + if (wxFileExists(filename)) { wxString msg; - msg.Printf( _("File '%s' already exists, do you really want to " - "overwrite it?"), filename); + msg.Printf( + _("File '%s' already exists, do you really want to overwrite it?"), + filename.c_str()); - if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES) + wxMessageDialog dlg(dialog, msg, _("Confirm"), + wxYES_NO | wxICON_QUESTION); + if (dlg.ShowModal() != wxID_YES) return; } } - else if ( (style & wxOPEN) && ( style & wxFILE_MUST_EXIST) ) + else if ((style & wxOPEN) && ( style & wxFILE_MUST_EXIST)) { - if ( !wxFileExists( filename ) ) + if (!wxFileExists( filename )) { - wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK); + wxMessageDialog dlg(dialog, + _("Please choose an existing file."), + _("Error"), wxOK | wxICON_ERROR); + dlg.ShowModal(); return; } } // change to the directory where the user went if asked - if ( style & wxCHANGE_DIR ) + if (style & wxCHANGE_DIR) { wxString cwd; wxSplitPath(filename, &cwd, NULL, NULL); - if ( cwd != wxGetCwd() ) + if (cwd != wxGetCwd()) { wxSetWorkingDirectory(cwd); } } - dialog->SetPath( filename ); - + dialog->DoSetPath(filename); + dialog->UpdateFromDialog(); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); - event.SetEventObject( dialog ); - dialog->GetEventHandler()->ProcessEvent( event ); + event.SetEventObject(dialog); + dialog->GetEventHandler()->ProcessEvent(event); } //----------------------------------------------------------------------------- // "clicked" for Cancel-button //----------------------------------------------------------------------------- -static -void gtk_filedialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFileDialog *dialog ) +static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w), + wxFileDialog *dialog) { - if (g_isIdle) wxapp_install_idle_handler(); - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - event.SetEventObject( dialog ); - dialog->GetEventHandler()->ProcessEvent( event ); + event.SetEventObject(dialog); + dialog->GetEventHandler()->ProcessEvent(event); +} + +static void gtk_filedialog_response_callback(GtkWidget *w, + int response, + wxFileDialog *dialog) +{ + wxapp_install_idle_handler(); + + if (response == GTK_RESPONSE_CANCEL) + gtk_filedialog_cancel_callback(w, dialog); + else + gtk_filedialog_ok_callback(w, dialog); } //----------------------------------------------------------------------------- @@ -124,66 +119,262 @@ void gtk_filedialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFileDialog *dialo IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxFileDialogBase) -wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message, - const wxString& defaultDir, const wxString& defaultFileName, - const wxString& wildCard, - long style, const wxPoint& pos ) - :wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos) +wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, + const wxString& defaultDir, + const wxString& defaultFileName, + const wxString& wildCard, + long style, const wxPoint& pos) + : wxFileDialogBase(parent, message, defaultDir, defaultFileName, + wildCard, style, pos) { m_needParent = FALSE; - if (!PreCreation( parent, pos, wxDefaultSize ) || - !CreateBase( parent, wxID_ANY, pos, wxDefaultSize, style, wxDefaultValidator, wxT("filedialog") )) + if (!PreCreation(parent, pos, wxDefaultSize) || + !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, + wxDefaultValidator, wxT("filedialog"))) { - wxFAIL_MSG( wxT("wxXX creation failed") ); + wxFAIL_MSG( wxT("wxFileDialog creation failed") ); return; } - m_widget = gtk_file_selection_new( m_message.mbc_str() ); + bool multiple = (style & wxMULTIPLE) == wxMULTIPLE; + GtkFileChooserAction gtk_action; + GtkWindow* gtk_parent = NULL; + if (parent) + gtk_parent = GTK_WINDOW(parent->m_widget); + + gchar* ok_btn_stock; + if ((style & wxSAVE) == wxSAVE) + { + gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE; + ok_btn_stock = GTK_STOCK_SAVE; + } + else + { + gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN; + ok_btn_stock = GTK_STOCK_OPEN; + } + m_widget = gtk_file_chooser_dialog_new( + wxGTK_CONV(m_message), + gtk_parent, + gtk_action, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + ok_btn_stock, GTK_RESPONSE_ACCEPT, + NULL); + + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(m_widget), multiple); + + gtk_signal_connect(GTK_OBJECT(m_widget), + "response", + GTK_SIGNAL_FUNC(gtk_filedialog_response_callback), + (gpointer*)this); + + m_path = m_dir; + if (!m_path.empty() && m_path.Last() != wxT('/')) + m_path += wxT('/'); + m_path += m_fileName; + SetPath(m_path); + + SetWildcard(wildCard); + SetFilterIndex(0); +} - int x = (gdk_screen_width () - 400) / 2; - int y = (gdk_screen_height () - 400) / 2; - gtk_widget_set_uposition( m_widget, x, y ); +void wxFileDialog::SetPath(const wxString& path) +{ + DoSetPath(path); + UpdateDialog(); +} - GtkFileSelection *sel = GTK_FILE_SELECTION(m_widget); - gtk_file_selection_hide_fileop_buttons( sel ); // they don't work anyway +void wxFileDialog::GetFilenames(wxArrayString& files) const +{ + GetPaths(files); + for (size_t n = 0; n < files.GetCount(); n++ ) + { + wxString name,ext; + wxSplitPath(files[n], NULL, &name, &ext); + if (!ext.IsEmpty()) + { + name += wxT("."); + name += ext; + } + files[n] = name; + } +} +void wxFileDialog::GetPaths(wxArrayString& paths) const +{ + paths.Empty(); + if (GetWindowStyle() & wxMULTIPLE) + { + GSList *gpathsi = + gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_widget)); + GSList *gpaths = gpathsi; + while (gpathsi) + { + wxString file = wxGTK_CONV_BACK((gchar*) gpathsi->data); + paths.Add(file); + g_free(gpathsi->data); + gpathsi = gpathsi->next; + } + if (gpaths) + g_slist_free(gpaths); + } + else + { + paths.Add(m_fileName); + } +} - m_path.Append(m_dir); - if( ! m_path.IsEmpty() && m_path.Last()!=wxT('/') ) - m_path.Append('/'); - m_path.Append(m_fileName); +void wxFileDialog::SetMessage(const wxString& message) +{ + m_message = message; + SetTitle(message); +} + +void wxFileDialog::SetDirectory(const wxString& dir) +{ + wxFileName fn(dir,m_fileName); + SetPath(fn.GetFullPath()); +} + +void wxFileDialog::SetFilename(const wxString& name) +{ + m_fileName = name; + wxFileName fn(m_dir,name); + SetPath(fn.GetFullPath()); +} - if(m_path.Length()>1) gtk_file_selection_set_filename(sel,m_path.mbc_str()); +void wxFileDialog::SetWildcard(const wxString& wildCard) +{ + m_wildCard = wildCard; + + GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget); + + // empty current filter list: + GSList* ifilters = gtk_file_chooser_list_filters(chooser); + GSList* filters = ifilters; + while (ifilters) + { + gtk_file_chooser_remove_filter(chooser,GTK_FILE_FILTER(ifilters->data)); + ifilters = ifilters->next; + } + g_slist_free(filters); + + // parse filters + wxArrayString wildDescriptions, wildFilters; + if (!wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, wildFilters)) + { + wxFAIL_MSG( wxT("Wrong file type description") ); + } + else + { + // add parsed to GtkChooser + for (size_t n = 0; n < wildFilters.GetCount(); n++) + { + GtkFileFilter* filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter,wxGTK_CONV(wildDescriptions[n])); + wxString after = wildFilters[n]; + do + { + wxString ext = after.BeforeFirst(wxT(';')); + gtk_file_filter_add_pattern(filter,wxGTK_CONV(ext)); + if (after.Find(wxT(';')) == wxNOT_FOUND) + break; + after = after.AfterLast(wxT(';')); + } + while (!after.empty()); + + gtk_file_chooser_add_filter(chooser, filter); + } + } +} - gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", - GTK_SIGNAL_FUNC(gtk_filedialog_ok_callback), (gpointer*)this ); +void wxFileDialog::SetFilterIndex(int filterIndex) +{ + m_filterIndex = filterIndex; - // strange way to internationalize - gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->ok_button)->child ), wxConvCurrent->cWX2MB(_("OK")) ); + GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget); + GSList *fnode = gtk_file_chooser_list_filters(chooser); + GSList *filters = fnode; + int i = 0; + while (fnode) + { + if (i == filterIndex) + { + gtk_file_chooser_set_filter(chooser, GTK_FILE_FILTER(fnode->data)); + m_filterIndex = i; + break; + } + i++; + fnode = fnode->next; + } + g_slist_free(filters); +} - gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked", - GTK_SIGNAL_FUNC(gtk_filedialog_cancel_callback), (gpointer*)this ); +void wxFileDialog::UpdateFromDialog() +{ + // update filterIndex + GSList *fnode = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(m_widget)); + GSList *filters = fnode; + GtkFileFilter *current = + gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_widget)); + + int i = 0; + m_filterIndex = 0; + while (fnode) + { + if (fnode->data == (gpointer)current) + { + m_filterIndex = i; + break; + } + i++; + fnode = fnode->next; + } + g_slist_free(filters); +} - // strange way to internationalize - gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->cancel_button)->child ), wxConvCurrent->cWX2MB(_("Cancel")) ); +void wxFileDialog::UpdateDialog() +{ + + if (wxDirExists(m_path)) + { + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), + wxGTK_CONV(m_path)); + } + else + { + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), + wxGTK_CONV(m_path)); - gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", - GTK_SIGNAL_FUNC(gtk_filedialog_delete_callback), (gpointer)this ); + // pre-fill the filename, too: + if (GetWindowStyle() & wxSAVE) + { + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), + wxGTK_CONV(m_fileName)); + } + } } -void wxFileDialog::SetPath(const wxString& path) +void wxFileDialog::DoSetPath(const wxString& path) { - // not only set the full path but also update filename and dir - m_path = path; - if ( !!path ) + if (!path.empty()) { + wxFileName fn(path); + fn.MakeAbsolute(); + m_path = fn.GetFullPath(); + wxString ext; wxSplitPath(path, &m_dir, &m_fileName, &ext); - if (!ext.IsEmpty()) + if (!ext.empty()) { m_fileName += wxT("."); m_fileName += ext; } } + else + { + m_path = path; + } } +#endif // wxUSE_FILEDLG && defined(__WXGTK24__) diff --git a/src/gtk1/filedlg.cpp b/src/gtk1/filedlg.cpp index a3fcec04f1..a9f92c274f 100644 --- a/src/gtk1/filedlg.cpp +++ b/src/gtk1/filedlg.cpp @@ -1,9 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// // Name: gtk/filedlg.cpp -// Purpose: -// Author: Robert Roebling +// Purpose: native implementation of wxFileDialog +// Author: Robert Roebling, Zbigniew Zagorski // Id: $Id$ -// Copyright: (c) 1998 Robert Roebling +// Copyright: (c) 1998 Robert Roebling, 2004 Zbigniew Zagorski // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,12 +14,15 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_FILEDLG && defined(__WXGTK24__) + #include "wx/filedlg.h" #include "wx/utils.h" #include "wx/intl.h" -#include "wx/generic/msgdlgg.h" +#include "wx/filename.h" #include +#include "wx/gtk/private.h" //----------------------------------------------------------------------------- // idle system @@ -28,94 +31,86 @@ extern void wxapp_install_idle_handler(); extern bool g_isIdle; -//----------------------------------------------------------------------------- -// "delete_event" -//----------------------------------------------------------------------------- - -static -bool gtk_filedialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - -/* - printf( "OnDelete from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - - win->Close(); - - return TRUE; -} - //----------------------------------------------------------------------------- // "clicked" for OK-button //----------------------------------------------------------------------------- -static -void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dialog ) +static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog) { - if (g_isIdle) wxapp_install_idle_handler(); - int style = dialog->GetStyle(); + gchar* text = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); + wxString filename(wxGTK_CONV_BACK(text)); - GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget); - char *filename = gtk_file_selection_get_filename(filedlg); - - if ( (style & wxSAVE) && ( style & wxOVERWRITE_PROMPT ) ) + if ((style & wxSAVE) && (style & wxOVERWRITE_PROMPT)) { - if (wxFileExists( filename )) + if (wxFileExists(filename)) { wxString msg; - msg.Printf( _("File '%s' already exists, do you really want to " - "overwrite it?"), filename); + msg.Printf( + _("File '%s' already exists, do you really want to overwrite it?"), + filename.c_str()); - if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES) + wxMessageDialog dlg(dialog, msg, _("Confirm"), + wxYES_NO | wxICON_QUESTION); + if (dlg.ShowModal() != wxID_YES) return; } } - else if ( (style & wxOPEN) && ( style & wxFILE_MUST_EXIST) ) + else if ((style & wxOPEN) && ( style & wxFILE_MUST_EXIST)) { - if ( !wxFileExists( filename ) ) + if (!wxFileExists( filename )) { - wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK); + wxMessageDialog dlg(dialog, + _("Please choose an existing file."), + _("Error"), wxOK | wxICON_ERROR); + dlg.ShowModal(); return; } } // change to the directory where the user went if asked - if ( style & wxCHANGE_DIR ) + if (style & wxCHANGE_DIR) { wxString cwd; wxSplitPath(filename, &cwd, NULL, NULL); - if ( cwd != wxGetCwd() ) + if (cwd != wxGetCwd()) { wxSetWorkingDirectory(cwd); } } - dialog->SetPath( filename ); - + dialog->DoSetPath(filename); + dialog->UpdateFromDialog(); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); - event.SetEventObject( dialog ); - dialog->GetEventHandler()->ProcessEvent( event ); + event.SetEventObject(dialog); + dialog->GetEventHandler()->ProcessEvent(event); } //----------------------------------------------------------------------------- // "clicked" for Cancel-button //----------------------------------------------------------------------------- -static -void gtk_filedialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFileDialog *dialog ) +static void gtk_filedialog_cancel_callback(GtkWidget *WXUNUSED(w), + wxFileDialog *dialog) { - if (g_isIdle) wxapp_install_idle_handler(); - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - event.SetEventObject( dialog ); - dialog->GetEventHandler()->ProcessEvent( event ); + event.SetEventObject(dialog); + dialog->GetEventHandler()->ProcessEvent(event); +} + +static void gtk_filedialog_response_callback(GtkWidget *w, + int response, + wxFileDialog *dialog) +{ + wxapp_install_idle_handler(); + + if (response == GTK_RESPONSE_CANCEL) + gtk_filedialog_cancel_callback(w, dialog); + else + gtk_filedialog_ok_callback(w, dialog); } //----------------------------------------------------------------------------- @@ -124,66 +119,262 @@ void gtk_filedialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFileDialog *dialo IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxFileDialogBase) -wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message, - const wxString& defaultDir, const wxString& defaultFileName, - const wxString& wildCard, - long style, const wxPoint& pos ) - :wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos) +wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, + const wxString& defaultDir, + const wxString& defaultFileName, + const wxString& wildCard, + long style, const wxPoint& pos) + : wxFileDialogBase(parent, message, defaultDir, defaultFileName, + wildCard, style, pos) { m_needParent = FALSE; - if (!PreCreation( parent, pos, wxDefaultSize ) || - !CreateBase( parent, wxID_ANY, pos, wxDefaultSize, style, wxDefaultValidator, wxT("filedialog") )) + if (!PreCreation(parent, pos, wxDefaultSize) || + !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, + wxDefaultValidator, wxT("filedialog"))) { - wxFAIL_MSG( wxT("wxXX creation failed") ); + wxFAIL_MSG( wxT("wxFileDialog creation failed") ); return; } - m_widget = gtk_file_selection_new( m_message.mbc_str() ); + bool multiple = (style & wxMULTIPLE) == wxMULTIPLE; + GtkFileChooserAction gtk_action; + GtkWindow* gtk_parent = NULL; + if (parent) + gtk_parent = GTK_WINDOW(parent->m_widget); + + gchar* ok_btn_stock; + if ((style & wxSAVE) == wxSAVE) + { + gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE; + ok_btn_stock = GTK_STOCK_SAVE; + } + else + { + gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN; + ok_btn_stock = GTK_STOCK_OPEN; + } + m_widget = gtk_file_chooser_dialog_new( + wxGTK_CONV(m_message), + gtk_parent, + gtk_action, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + ok_btn_stock, GTK_RESPONSE_ACCEPT, + NULL); + + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(m_widget), multiple); + + gtk_signal_connect(GTK_OBJECT(m_widget), + "response", + GTK_SIGNAL_FUNC(gtk_filedialog_response_callback), + (gpointer*)this); + + m_path = m_dir; + if (!m_path.empty() && m_path.Last() != wxT('/')) + m_path += wxT('/'); + m_path += m_fileName; + SetPath(m_path); + + SetWildcard(wildCard); + SetFilterIndex(0); +} - int x = (gdk_screen_width () - 400) / 2; - int y = (gdk_screen_height () - 400) / 2; - gtk_widget_set_uposition( m_widget, x, y ); +void wxFileDialog::SetPath(const wxString& path) +{ + DoSetPath(path); + UpdateDialog(); +} - GtkFileSelection *sel = GTK_FILE_SELECTION(m_widget); - gtk_file_selection_hide_fileop_buttons( sel ); // they don't work anyway +void wxFileDialog::GetFilenames(wxArrayString& files) const +{ + GetPaths(files); + for (size_t n = 0; n < files.GetCount(); n++ ) + { + wxString name,ext; + wxSplitPath(files[n], NULL, &name, &ext); + if (!ext.IsEmpty()) + { + name += wxT("."); + name += ext; + } + files[n] = name; + } +} +void wxFileDialog::GetPaths(wxArrayString& paths) const +{ + paths.Empty(); + if (GetWindowStyle() & wxMULTIPLE) + { + GSList *gpathsi = + gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_widget)); + GSList *gpaths = gpathsi; + while (gpathsi) + { + wxString file = wxGTK_CONV_BACK((gchar*) gpathsi->data); + paths.Add(file); + g_free(gpathsi->data); + gpathsi = gpathsi->next; + } + if (gpaths) + g_slist_free(gpaths); + } + else + { + paths.Add(m_fileName); + } +} - m_path.Append(m_dir); - if( ! m_path.IsEmpty() && m_path.Last()!=wxT('/') ) - m_path.Append('/'); - m_path.Append(m_fileName); +void wxFileDialog::SetMessage(const wxString& message) +{ + m_message = message; + SetTitle(message); +} + +void wxFileDialog::SetDirectory(const wxString& dir) +{ + wxFileName fn(dir,m_fileName); + SetPath(fn.GetFullPath()); +} + +void wxFileDialog::SetFilename(const wxString& name) +{ + m_fileName = name; + wxFileName fn(m_dir,name); + SetPath(fn.GetFullPath()); +} - if(m_path.Length()>1) gtk_file_selection_set_filename(sel,m_path.mbc_str()); +void wxFileDialog::SetWildcard(const wxString& wildCard) +{ + m_wildCard = wildCard; + + GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget); + + // empty current filter list: + GSList* ifilters = gtk_file_chooser_list_filters(chooser); + GSList* filters = ifilters; + while (ifilters) + { + gtk_file_chooser_remove_filter(chooser,GTK_FILE_FILTER(ifilters->data)); + ifilters = ifilters->next; + } + g_slist_free(filters); + + // parse filters + wxArrayString wildDescriptions, wildFilters; + if (!wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, wildFilters)) + { + wxFAIL_MSG( wxT("Wrong file type description") ); + } + else + { + // add parsed to GtkChooser + for (size_t n = 0; n < wildFilters.GetCount(); n++) + { + GtkFileFilter* filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter,wxGTK_CONV(wildDescriptions[n])); + wxString after = wildFilters[n]; + do + { + wxString ext = after.BeforeFirst(wxT(';')); + gtk_file_filter_add_pattern(filter,wxGTK_CONV(ext)); + if (after.Find(wxT(';')) == wxNOT_FOUND) + break; + after = after.AfterLast(wxT(';')); + } + while (!after.empty()); + + gtk_file_chooser_add_filter(chooser, filter); + } + } +} - gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", - GTK_SIGNAL_FUNC(gtk_filedialog_ok_callback), (gpointer*)this ); +void wxFileDialog::SetFilterIndex(int filterIndex) +{ + m_filterIndex = filterIndex; - // strange way to internationalize - gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->ok_button)->child ), wxConvCurrent->cWX2MB(_("OK")) ); + GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget); + GSList *fnode = gtk_file_chooser_list_filters(chooser); + GSList *filters = fnode; + int i = 0; + while (fnode) + { + if (i == filterIndex) + { + gtk_file_chooser_set_filter(chooser, GTK_FILE_FILTER(fnode->data)); + m_filterIndex = i; + break; + } + i++; + fnode = fnode->next; + } + g_slist_free(filters); +} - gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked", - GTK_SIGNAL_FUNC(gtk_filedialog_cancel_callback), (gpointer*)this ); +void wxFileDialog::UpdateFromDialog() +{ + // update filterIndex + GSList *fnode = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(m_widget)); + GSList *filters = fnode; + GtkFileFilter *current = + gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_widget)); + + int i = 0; + m_filterIndex = 0; + while (fnode) + { + if (fnode->data == (gpointer)current) + { + m_filterIndex = i; + break; + } + i++; + fnode = fnode->next; + } + g_slist_free(filters); +} - // strange way to internationalize - gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->cancel_button)->child ), wxConvCurrent->cWX2MB(_("Cancel")) ); +void wxFileDialog::UpdateDialog() +{ + + if (wxDirExists(m_path)) + { + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), + wxGTK_CONV(m_path)); + } + else + { + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), + wxGTK_CONV(m_path)); - gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", - GTK_SIGNAL_FUNC(gtk_filedialog_delete_callback), (gpointer)this ); + // pre-fill the filename, too: + if (GetWindowStyle() & wxSAVE) + { + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget), + wxGTK_CONV(m_fileName)); + } + } } -void wxFileDialog::SetPath(const wxString& path) +void wxFileDialog::DoSetPath(const wxString& path) { - // not only set the full path but also update filename and dir - m_path = path; - if ( !!path ) + if (!path.empty()) { + wxFileName fn(path); + fn.MakeAbsolute(); + m_path = fn.GetFullPath(); + wxString ext; wxSplitPath(path, &m_dir, &m_fileName, &ext); - if (!ext.IsEmpty()) + if (!ext.empty()) { m_fileName += wxT("."); m_fileName += ext; } } + else + { + m_path = path; + } } +#endif // wxUSE_FILEDLG && defined(__WXGTK24__) -- 2.45.2