-
Notifications
You must be signed in to change notification settings - Fork 511
Pre-populate file dialogs with sensible defaults #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-populate file dialogs with sensible defaults #562
Conversation
8d75b90
to
cc6926b
Compare
Thanks for the PR! I'm going to test it on Linux a bit later and merge. |
Could you please test it on Windows with Explorer configured to show file extensions? |
That won't work quite right either because the file type selector is remembered between uses of a dialog, so the extension should actually be taken from the selector. I think this might need a new method, something like |
I've managed to build SolveSpace on my laptop, and the GTK backend doesn't seem to honour the This working diff: diff --git a/src/platform/guigtk.cpp b/src/platform/guigtk.cpp
index 73fb01e..81e0c0d 100644
--- a/src/platform/guigtk.cpp
+++ b/src/platform/guigtk.cpp
@@ -1242,7 +1242,11 @@ public:
}
void SetFilename(Platform::Path path) override {
+ printf("SetFilename1(%s -> %s)\n", gtkChooser->get_filename().c_str(), path.raw.c_str());
gtkChooser->set_filename(path.raw);
+ // printf("SetFilename1(%s -> %s)\n", gtkChooser->get_filename().c_str(), path.FileStem().c_str());
+ // gtkChooser->set_filename(path.FileStem());
+ printf("SetFilename2(%s)\n", gtkChooser->get_filename().c_str());
}
void AddFilter(std::string name, std::vector<std::string> extensions) override {
@@ -1296,6 +1300,7 @@ public:
return;
Platform::Path path = GetFilename();
+ printf("FilterChanged(%s -> %s)\n", path.raw.c_str(), extension.c_str());
SetCurrentName(path.WithExtension(extension).FileName());
}
@@ -1311,10 +1316,12 @@ public:
}
void CheckForUntitledFile() {
+ printf("CheckForUntitledFile()1: %s\n", gtkChooser->get_current_name().c_str());
if(gtkChooser->get_action() == Gtk::FILE_CHOOSER_ACTION_SAVE &&
Path::From(gtkChooser->get_current_name()).FileStem().empty()) {
gtkChooser->set_current_name(std::string(_("untitled")) + "." + GetExtension());
}
+ printf("CheckForUntitledFile()2: %s\n", gtkChooser->get_current_name().c_str());
}
}; Yields
and likewise with the commented block being in. |
The documentation then goes on to reference an example, which seems to be missing from the header as well as the doc. I don't really know what to do about this… |
It does. The problem is that the semantics of |
15508f4
to
8088256
Compare
Right, I made |
8088256
to
4a73dd7
Compare
4a73dd7
to
ef26dc6
Compare
ef26dc6
to
4148757
Compare
@nabijaczleweli where do we stand with this one? |
4148757
to
c289d17
Compare
Rebased and fixed on Win32. See TODO in |
I can test on Linux/GTK, but it will probably have to wait until tomorrow. Fixing it if it isn't right is another story... So you have OSX and Windows covered? |
I wrote this on Windows so that should be fine. The OSX implementation is a stub, which should work going by the Cocoa docs, but I don't even know if it builds, let alone funxions. |
I tried this on Linux / GTK and it doesn't solve the problem there. The suggested export filenames I get remain the same as before: "untitled.stl" or "untitled.step". |
Indeed, the GTK implementation does need to be written. |
dfb96de
to
3f09eaf
Compare
@vespakoen and @ruevs can you guys have a look at this and possibly #545 and #650. Somewhere in these 3 is a good thing - I think mostly in this one. |
Went through first the diff of the referenced commit, then all instances of "Create(Open|Save)FileDialog"; added SuggestFilename() calls where a default exists This has been previously removed in 6b5db58 Closes solvespace#538
c289d17
to
0d6df5d
Compare
@phkahler As a start I rebased it on master. Builds and runs on Windows. All the Export options offer a file name the same as the opened .slvs and with the correct extension. Now I need to look at the actual code and what it does... |
On Linux I tried:
But that suggests the file name with no extension at all. The original commented out give unknown.xxx where xxx is the correct extension. Some of these function names make little sense ;-) |
OK, this looks like it works with GTK:
|
@vespakoen can you verify/fix the macOS version of this? |
Example:
Tested on Windows only, with the assumption that other platforms'
Platform::FileDialog
behaves the same.Ref: #538