diff --git a/uppsrc/CtrlLib/Cocoa.mm b/uppsrc/CtrlLib/Cocoa.mm index 8f1d1924b..7c0d3c59e 100644 --- a/uppsrc/CtrlLib/Cocoa.mm +++ b/uppsrc/CtrlLib/Cocoa.mm @@ -25,7 +25,7 @@ bool FileSelNative::Execute0(int open, const char *title) Ctrl::ReleaseCtrlCapture(); if(!title) title = open ? t_("Open") : t_("Save as"); - CFRef mmtitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8); + CFRef mmtitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8); NSWindow *window = nil; Ctrl *win = Ctrl::GetActiveWindow(); diff --git a/uppsrc/CtrlLib/CtrlUtil.h b/uppsrc/CtrlLib/CtrlUtil.h index 61e0d6423..8b96094ca 100644 --- a/uppsrc/CtrlLib/CtrlUtil.h +++ b/uppsrc/CtrlLib/CtrlUtil.h @@ -341,7 +341,12 @@ class FileSelNative { bool Execute0(int mode, const char *title); public: - bool Execute(bool open, const char *title = NULL) { return Execute0(open, title); } + void Serialize(Stream& s); + + void New() { path.Clear(); } + bool IsNew() const { return path.IsEmpty(); } + + bool Execute(bool open, const char *title = NULL) { return Execute0(open, title); } bool ExecuteOpen(const char *title = NULL) { return Execute(true, title); } bool ExecuteSaveAs(const char *title = NULL) { return Execute(false, title); } bool ExecuteSelectDir(const char *title = NULL) { return Execute0(2, title); } @@ -357,6 +362,8 @@ public: int GetCount() const { return path.GetCount(); } const String& operator[](int i) const { return path[i]; } + String GetActiveDir() const { return ipath; } + FileSelNative& Type(const char *name, const char *ext) { type.Add(MakeTuple(String(name), String(ext))); return *this; } FileSelNative& AllFilesType(); FileSelNative& Asking(bool b = true) { confirm = b; return *this; } diff --git a/uppsrc/CtrlLib/Gtk.cpp b/uppsrc/CtrlLib/Gtk.cpp index e0c3cf4cc..2f7983ab3 100644 --- a/uppsrc/CtrlLib/Gtk.cpp +++ b/uppsrc/CtrlLib/Gtk.cpp @@ -15,6 +15,12 @@ FileSelNative& FileSelNative::AllFilesType() { return Type(t_("All files"), "*.*"); } +void FileSelNative::Serialize(Stream& s) { + int version = 1; + s / version; + s / activetype % ipath; +} + bool FileSelNative::Execute0(int mode, const char *title) { Ctrl::ReleaseCtrlCapture(); @@ -70,6 +76,9 @@ bool FileSelNative::Execute0(int mode, const char *title) g_slist_free (list); } ret = true; + gchar *h = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(fc)); + ipath = h; + g_free(h); } gtk_widget_destroy(fc); return ret; diff --git a/uppsrc/CtrlLib/Win32.cpp b/uppsrc/CtrlLib/Win32.cpp index 6db0c35f2..eaa43099a 100644 --- a/uppsrc/CtrlLib/Win32.cpp +++ b/uppsrc/CtrlLib/Win32.cpp @@ -1,4 +1,5 @@ #include "CtrlLib.h" +#include "CtrlLib.h" #ifdef GUI_WIN #ifndef PLATFORM_WINCE diff --git a/upptst/FileSelNative/main.cpp b/upptst/FileSelNative/main.cpp index af24f0896..3194a3c42 100644 --- a/upptst/FileSelNative/main.cpp +++ b/upptst/FileSelNative/main.cpp @@ -7,7 +7,7 @@ GUI_APP_MAIN FileSelNative sel; sel.ActiveDir(GetHomeDirectory()); while(sel.ExecuteSelectDir("Just a test")) - PromptOK(sel.Get()); + PromptOK(sel.Get() + "&" + "active dir: " + sel.GetActiveDir()); sel.AllFilesType(); sel.Type("Test2", "*.tst");