FileDialog in Mac doesn't automatically add extension

Hello,

I'm a Mac newbie, so maybe I'm not understanding something here.

I press Save in my app, the FileDialog works (finally,) but when I
type a file name and hit save, it doesn't add the extension (`*.gssp`)
to the file. The file gets saved without an extension.

I checked in another Mac app, TextEdit, and when you save there with a
plain name it automatically adds `.rtf` to the file name.

Why isn't my app adding an extension? How can I make it add it?

Thanks,
Ram.

On the Mac you don't need a file extension to tell you what kind of file it is or which application should be used to open it. That information can be stored in the file's resource fork instead. Things seem to be moving more towards the file extension model but the other way of doing it is still possible, and there is a lot of heritage associated with that, so the file dialog doesn't automatically do it. I usually just add the extension myself if it's not already in the string I get back from the dialog. That works on all platforms.

···

On 12/7/10 4:43 PM, cool-RR wrote:

Hello,

I'm a Mac newbie, so maybe I'm not understanding something here.

I press Save in my app, the FileDialog works (finally,) but when I
type a file name and hit save, it doesn't add the extension (`*.gssp`)
to the file. The file gets saved without an extension.

I checked in another Mac app, TextEdit, and when you save there with a
plain name it automatically adds `.rtf` to the file name.

Why isn't my app adding an extension? How can I make it add it?

--
Robin Dunn
Software Craftsman

On the Mac you don't need a file extension to tell you what kind of file
it is or which application should be used to open it. That information
can be stored in the file's resource fork instead.

OS-X is really moving away from resource forks (and technically, while the file type and creator is part of the file meta-data, I don't think it's actually in the resource fork)

In fact, a lot of OS-X file-save dialogs do add an extension for you (and often have a check-box hide the extension in the lower left corner. I suppose it would be good for wx to support this.

I usually just add
the extension myself if it's not already in the string I get back from
the dialog. That works on all platforms.

That's how I handle it, too -- I think it's less annoying that way anyway.

-Chris

···

On 12/7/10 10:14 PM, Robin Dunn wrote:

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

On the Mac you don’t need a file extension to tell you what kind of file

it is or which application should be used to open it. That information

can be stored in the file’s resource fork instead.

OS-X is really moving away from resource forks (and technically, while the file type and creator is part of the file meta-data, I don’t think it’s actually in the resource fork)

In fact, a lot of OS-X file-save dialogs do add an extension for you (and often have a check-box hide the extension in the lower left corner. I suppose it would be good for wx to support this.

I’d also prefer wx to support this. Should I open a ticket?

I usually just add

the extension myself if it’s not already in the string I get back from

the dialog. That works on all platforms.

That’s how I handle it, too – I think it’s less annoying that way anyway.

-Chris

I’d say it might be a bit annoying to a power user who wishes to save a file without an extension. But I guess it’s a rare enough occurrence, so I’ll take this solution for now.

Ram.

···

On Wed, Dec 8, 2010 at 7:13 PM, Christopher Barker Chris.Barker@noaa.gov wrote:

On 12/7/10 10:14 PM, Robin Dunn wrote:

On Linux how to get extension selected by user in dialog?
E.g. exporting image and detecting format from extension.

Niki

···

On 8.12.2010 08:14, Robin Dunn wrote:

On the Mac you don't need a file extension to tell you what kind of file
it is or which application should be used to open it. That information
can be stored in the file's resource fork instead. Things seem to be
moving more towards the file extension model but the other way of doing
it is still possible, and there is a lot of heritage associated with
that, so the file dialog doesn't automatically do it. I usually just add
the extension myself if it's not already in the string I get back from
the dialog. That works on all platforms.

You can call GetFilterIndex after ShowModal has returned. It will tell you the index into the list of wildcards that was selected in the dialog.

···

On 12/9/10 12:24 AM, niki wrote:

On 8.12.2010 08:14, Robin Dunn wrote:

On the Mac you don't need a file extension to tell you what kind of file
it is or which application should be used to open it. That information
can be stored in the file's resource fork instead. Things seem to be
moving more towards the file extension model but the other way of doing
it is still possible, and there is a lot of heritage associated with
that, so the file dialog doesn't automatically do it. I usually just add
the extension myself if it's not already in the string I get back from
the dialog. That works on all platforms.

On Linux how to get extension selected by user in dialog?
E.g. exporting image and detecting format from extension.

--
Robin Dunn
Software Craftsman