How Documents Know Their Parents

7 207 0
How Documents Know Their Parents

Đang tải... (xem toàn văn)

Thông tin tài liệu

5.6. How Documents Know Their Parents Every operating system needs a mechanism to associate documents with the applications that created them. When you double-click a Microsoft Word document icon, for example, it's clear that you want Microsoft Word to launch and open the document. So how does Mac OS X know how to find a document's mommy? It actually has four different mechanisms. • Your preferences. If you've used the "Always Open with" command to specify a program (Section 5.6.1.1 ), that's the one that opens. • Type/Creator codes. First, it checks to see if the document has an invisible, four- letter Type code and Creator code. It does that because that's how Mac OS 9 used to recognize documents, and Mac OS X wants to ensure compatibility. (Apple used to monitor and track these four-letter codes, in conjunction with the various Mac software companies, so that no two creator codes were alike.) The Creator code is the same for a program and the documents it creates—MSWD for Microsoft Word, FMP7 for FileMaker Pro, and so on. That's the entire point: The creator code tells the Mac which program to open when you double-click a particular document. The Type code, meanwhile, specifies the document's file format: GIF, JPEG, TIFF, and so on. UP TO SPEED Window Layering Mac OS X takes a layered approach to your programs' windows. They're not all in front or all in back; it's entirely possible to wind up with the windows of different programs sandwiched and layered, front to back. Suppose, for example, you have Microsoft Excel in the foreground, but Word in the back-ground. If you click within a visible portion of a background window, you bring only that window of Word to the front. The remedy for this situation, if it bothers you, is the Window Bring All to Front command, which appears in the Finder and many other programs. It brings all of a program's windows to the front. (You can do the same thing by simply clicking the program's Dock icon, or using the -Tab "heads-up" display.) In the Finder, if you prefer, you can also use the Window Arrange in Front command. To reveal it, press Option as you open the Window menu. (What used to say "Bring All to Front" changes to say "Arrange in Front.") Mac OS X responds by cascading all open Finder windows, stacking them diagonally, overlapping them so that only their title bars are visible. Layered windows shine when you're comparing two documents in two different programs, because it frees you of the window clutter of other open documents. But the time will come when you're ready to bring all of a background program's windows to the front. Get into the habit of clicking its Dock icon, or pressing -Tab to select its icon, rather than clicking inside one window. When you do that, all open windows in that application come forward, from wherever they may be. When you double-click a document, Mac OS X checks to see if it has a creator code. If so, it then consults an invisible database of icons and codes, the master index that lists the correspondence between creator codes and the applications that generate them. If the desktop file discovers a match, then the corresponding program opens the document, which now appears on your screen. • Unix database. If the document doesn't have Type or Creator codes (and documents created by Cocoa programs—see Section 5.9 —generally don't), Mac OS X consults a second internal Mac OS X database, one that's inherited from Unix systems. The only real interaction you have with it is when you change a document's parent to a different program, as described on the following pages. (Actually, you can open and examine the database—if you're a programmer/geek.) • Filename extensions. A filename extension is a suffix following a period in the file's name, as in Letter to Mom.doc. (It's usually three letters long, but doesn't have to be.) These, too, play a role in determining which documents open into which programs—as the operating system's last resort. Figure 5-11. Top: In the Info window, open the Name & Extension pane. Now you can see what Mac OS X really thinks your file is called. Turn "Hide extension" on if you'd rather not see the file name suffix in the Finder. Bottom: If you try to add a suffix of your own, Mac OS X objects, in effect saying, "Hey—I've already got a filename extension for this, even if you can't see it. Are you sure you know what you're doing?" (And hallelujah—in Leopard, you can turn off this warning, if you like. Choose Finder Preferences Advanced pane. Turn off "Show warning before changing an extension.") That's how Windows identifies its documents. If you double-click something called memo.doc, it opens in Microsoft Word. If you double-click memo.wri, it opens in Microsoft Write, and so on. Note: Mac OS X comes set to hide most filename extensions, on the premise that they make the operating system look more technical and threatening. If you'd like to see them, however, choose Finder Preferences, click the Advanced button, and then turn on "Show all file extensions." Now examine a few of your documents; you'll see that their names now display the previously hidden suffixes.You can hide or show these suffixes on an icon-at-a-time basis, too (or a clump-at-a-time basis). Just highlight the icon or icons you want to affect, and then choose File Get Info. In the resulting Info window, proceed as shown in Figure 5-11 . It's possible to live a long and happy life without knowing anything about these codes and suffixes. Indeed, the vast majority of Mac fans may never even encounter them. But if you're prepared for a little bit of technical bushwhacking, you may discover that understanding creator/type codes and file name suffixes can be useful in troubleshooting, keeping your files private, and appreciating how Mac OS X works. GEM IN THE ROUGH Using the Dock or Sidebar for Drag-and-Drop The Mac is smart about the relationship between documents and applications. If you double-click a TextEdit document icon, for example, TextEdit opens automatically and shows you the document. But it's occasionally useful to open a document using a program other than the one that created it. Perhaps, as is often the case with downloaded Internet graphics, you don't have the program that created it, or you don't know which one was used. This technique is also useful when opening a Read Me file into your word processor, such as Word, instead of the usual TextEdit program. In such cases, the Dock is handy: Just drag the mystery document onto one of the Dock's tiles, as shown here. Doing so forces the program to open the document—if it can. (Dragging onto a program's icon in the Sidebar or even the Finder toolbar works just as well.) Incidentally, in general, only the Dock icons of programs that can, in fact, open the file you're dragging become highlighted. The others just shrug indifferently or even scoot aside, thinking you're trying to drag the file into the dock. Pressing Option- as you drag forces Dock icons to be more tolerant. Now all of them "light up" as your document touches them, indicating that they'll try to open your file. Even so, a "could not be opened" error message may result. As they say in Cupertino, sometimes what a can really needs is a can opener. 5.6.1. Reassigning Documents to Programs Unfortunately, Type and Creator codes aren't of much use when you encounter a document created by a program that you don't have. If someone emails you a MIDI file (a file-exchange format for music) that she exported from the Finale sheet-music program, you won't be able to open it by double-clicking, unless you, too, have Finale installed. Even if you have a different sheet-music program on your hard drive, just double-clicking the MIDI file won't, by itself, open it. Filename extensions, meanwhile, have problems of their own. Filename extensions are even less likely to pinpoint which parent program should open a particular document. Suppose you've downloaded a graphic called Sunset.jpg. Well, almost any program these days can open a JPEG graphic—Photoshop, Word, Preview, Safari, and so on. How does Mac OS X know which of these programs to open when you double-click the file? Fortunately, you can decide. You can reassign a document (or all documents of its kind) to a specific program. Here's the rundown. 5.6.1.1. Reassigning a certain document—just once Double-clicking a graphics file generally opens it in Preview, the graphics viewer included with Mac OS X (see Section 10.23 ). Most of the time, that's a perfectly good arrangement. But Preview has only limited editing powers. What if you decide to edit a graphics file more substantially? You'd want it to open, just this once, into a different program—Photoshop Elements, for example. To do so, you must access the Open With command. You can find it in two places: • Highlight the icon, and then choose File Open With. • Control-click (or right-click) the file's icon. Or, in a Finder window, highlight the icon and then open the Action menu. In the shortcut menu, choose Open With. Study the submenu for a moment (Figure 5-12 , top). The program whose name says "(default)" indicates which program usually opens this kind of document. From this pop- up menu, choose the name of the program you'd rather open this particular file, right now, just this once. 5.6.1.2. Reassigning a certain document—permanently After opening a TIFF file in, say, Photoshop Elements for editing, you haven't really made any changes in the fabric of your Mac universe. The next time you double-click that file, it opens once again in Preview. If you wish this particular file would always open in Photoshop Elements, the steps are slightly different. In fact, there are three different ways: • In the Choose an Application dialog box, turn on "Always Open With"(shown at bottom in Figure 5-12 ). Start out with one of the previously described techniques (File Open With, or Control-click/right-click the file's icon and choose Open With)—but after you see the menu, press the Option key, too. Before your very eyes, the Open With command changes to say Always Open With. Figure 5-12. Top: The shortcut menu offers a list of programs capable of opening an icon. If you were to press the Option key right now, the words Open With would suddenly change to say Always Open With. Bottom: If you choose Other, you're prompted to choose a different program. Turn on Always Open With if you'll always want this document to open in the new parent program. Otherwise, this is a one-time reassignment. • Highlight the icon, and then choose File Get Info. Open the "Open with" panel. Choose a new "parent" program's name from the pop-up menu. You'll see that the word "(default)" changes position, now tacking itself onto the name of the new program you've chosen. Tip: You can use a similar trick to reassign the parenthood of a whole flock of selected icons at once. Once you've selected them, keep the Option key pressed as you choose File Show Inspector. In the "Open with" section of this specialized GetInfo window, choose an ew program from the pop-up menu. The message at the top of the window— "22 items," for example—reminds you that you're changing the whole batch at once. 5.6.1.3. Reassigning all documents of one type So much for reassigning one document (or group of documents) at a time. What if you're writing, say, a book about Mac OS X, and you've been taking a lot of screenshots? Mac OS X saves each captured screen illustration as a graphics file in something called PNG format. That's all fine, except that every time you double-click one of these, it opens into Preview, where you can't paint out unwanted details. You could reassign all of these files, one at a time, to a different program, but your grandchildren would have grandchildren by the time you finish. In this case, you want to tell Mac OS X, "For heaven's sake, make all PNG files open in Photoshop from now on!" To make it happen, start by highlighting any PNG file. Choose File Get Info. (The shortcut menus won't help you in this case.) Open the "Open with" panel. From its pop-up menu, choose the program you want to open this kind of document from now on. (If the one you prefer isn't listed, use the Other option, which opens the Choose an Application dialog box so that you can navigate to the one you want. Find and double- click the program.) This time, follow up by clicking Change All beneath the pop-up menu. (This button is dimmed until you've actually selected a different program from the pop-up menu.) Mac OS X asks you to confirm by clicking Continue or pressing Enter. From now on, double-clicking any similar kind of document opens it in the newly selected program. . 5.6. How Documents Know Their Parents Every operating system needs a mechanism to associate documents with the applications. that you want Microsoft Word to launch and open the document. So how does Mac OS X know how to find a document's mommy? It actually has four different

Ngày đăng: 24/10/2013, 07:15

Tài liệu cùng người dùng

Tài liệu liên quan