Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with NavCreateGetFileDialog() and file types




On Mar 13, 2007, at 10:51 PM, Ed Martin wrote:

Hi,
This is my first time using any Apple specific APIs and i'm somewhat new to C too so if any of my questions seem kinda stupid keep that in mind :)


I am trying to add an Carbon interface to a small existing program and I'm having trouble getting the browse for file thing to work. I have done some searching and found that NavCreateGetFileDialog() or NavCreateChooseFileDialog() should be used, and i have gotten it to the point that i can open the application with the main window, click browser, open the browse dialog

That's usually called an open file dialog on the Mac.

, and then thats where i have a problem, my application needs ASCII input files (they just consist of spaces, tabs and numbers) and the files have no extension, i would preferably like to be able to show only ASCII text files,

I'm not aware of any way to do that short of opening them and reading them. What is the source of these files? Why don't they have extensions?


but i would settle for anything that lets me select a file at this point as right now every file type i put in seem to have no affect at all. Every file shows up all grayed out and i cannot select any file.

Also can anyone point me something that talk about the basics for coding on a Mac/Carbon, i spent far too much time trying to figure out what a NavListTypeHandle was, same goes with learning about CFSTR() and OSType, is there any documentation that gives an overview of these core functions and types that everything needs for even the simple tasks?

I'm not aware of one.

	Thanks in advanced


here is my relevant code:

....a few static variables
//our open file dialogs
static NavDialogRef OpenFileRef;

//hold the file types that may be opened and related info
static NavTypeListHandle hTypeList;
static NavReplyRecord replyNav;
int main(blah){
...some code to initialize some thing...
//for the file open dialog, we need these
fileOpenStatus = NavGetDefaultDialogCreationOptions (&fileOpenOptions);
fileOpenOptions.clientName = CFSTR("Supply & Demand");


//we can pick any file type
hTypeList = (NavTypeListHandle)NewHandleClear(sizeof (NavTypeList) + sizeof(OSType));


HLock ((Handle) hTypeList);

Handles don't move in Mac OS X, so there's no need to look them. Even when they did move the operations you're about to do wouldn't cause one to move, so locking was never needed for this.


That said, the problem is that filtering by file type is not very reliable now that so many applications don't assign file types to files. If you're going to use types for this, I'd use 'TEXT' and 0 (no file type assigned). The modern way is to use UTIs. Look for NavDialogSetFilterTypeIdentifiers() in Navigation.h. But it's only available in 10.4 and later and UTIs are based on extensions and file types. If you need to support 10.3 you'll need to use a filter function and filter files manually. All that said, if the files don't have a type or an extension, how do you propose to identify them?

Larry

    (**hTypeList).componentSignature = kNavGenericSignature;
    (**hTypeList).osTypeCount = 2;
    (**hTypeList).osType[0] = 'TEXT';
    //UTGetOSTypeFromString(CFSTR("TEXT"));
    (**hTypeList).osType[1] = '????';
    HUnlock((Handle) hTypeList);//let it more a bit

    ....code to start/run the interface...
}

static OSStatus AppEventHandler(blah){
..inside switch() for the "Browse" button
NavCreateGetFileDialog(&fileOpenOptions, hTypeList, NULL, NULL,
NULL, NULL, &OpenFileRef);
NavDialogRun (OpenFileRef);
..cleanup code is not in yet, i'll add it when i can select files


}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >help with NavCreateGetFileDialog() and file types (From: Ed Martin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.