shoes/shoes3

Suggest file / folder save location or name

Opened this issue ยท 5 comments

Is there a way to suggest a file name or location when using 'ask_save_file' for example? If not, it would be a useful feature to have in future releases...

The last time I looked at this problem I found that it wasn't an easy to do or not portable. FWIW, osx and gtk (and windows) have opposite defaults. One opens the same as the last selection and one open somewhere else. Depending on what you want, both are a disappoint. They are incredibly slow too as they cache all the icons. Let's keep this issue open.

In Gtk3 (Linux and Windows) this does seem doable although the gnome wizards think it's not good policy - like they've never been wrong before! I haven't checked cocoa docs yet for OSX but it's one of those options that doesn't have to be cross platform, IMO. We already accept a option hash for those dialogs so dir: <dir_path> and file: <filename>. On the native side of things there is some work since that code is troublesome and to use a technical term, 'limping on life support'. It needs a rethink/rework.

@JDsnyke , For a workaround the panel for the file chooser is pretty flexible. You can add directories to it and they stick through a reboot. Just right click the directory and "bookmark" it.

I love finding undocumented things in Shoes! There was code in there to filter by file types. I added the suggest 'dir:' and while I was there I added a 'hidden:' option to show the hidden dot files. I've wanted that option frequently.
Here's a little test script

Shoes.app do
  stack do
    flow do
		  para "Start Here: "
		  @el = edit_line 
		  #@el.text = Dir.getwd
		  button "Open" do
		    fp = ask_open_file title: "My App wants", dir: @el.text, 
            types: {"Ruby" => "*.rb", "All" => "*"}, hidden: true 
		    if fp 
		      @el.text = File.dirname(fp)
		      @msgbox.append fp+"\n"
		    end
		  end
		end
	  @msgbox = edit_box width: 300
	end
end

One other change. If you don't specify any options, it's likely to open in your HOME folder. Also the 'types' option doesn't work on OSX but that's OK. Beta's at the usual place - The 64 bit exe only works on win10.

Good stuff @ccoupe! I'll test out the beta when I can.