Strange Interface Builder hacks

p

Registered
Hi everyone,
I noticed something strange: when I do a Get Info on an app package, and choose "Show package contents", I'll get access to the nib files. Is it common practice for an OS to let users tinker with the commercial applications' files?

I mean, the nib file does tell the user something about the design of the application, right? Currently, I can play with the GUI of every Cocoa app I've seen (be it from Apple, Stone Design or Omni). Do users with developer tools get such access to source files for apps in other OSes too? Or is this just a beta thing?

Incidentally, I didn't like the new trend of not having borders around document windows, so I decided to resize the text field of Text Edit so it doesn't fill the entire window, leaving some room as a margin or border. I did that in Interface Builder, and was about to launch Text Edit to test the new look, when I realized that I had left Text Edit open with a document, and its document window already sported the new look!!! That was impressive.
 

eucci

Registered

It's unknown if the "Show package contents" will be in the final release. Since a package is just a directory on the file system, any command line tools or third party things that make improper calls (ie, Java apps that implement their own open|save dialogs), all of those files are available to those apps.

The primary reason Mac OS X is implemented this way is that there are (sadly) problems with Forked file systems, such as traditional Mac OS has. Primarily, these problems have to do with intercommunication. When NeXTStep was developed, the file system they chose didn't support forked files. But they still wanted the file system, at least at the primary user experience level, to offer the object oriented benefits of a smarter system. There are a lot of benefits to the way rich objects such as Applications are done in Mac OS X. Look inside the IE5.app package, and you'll find a *lot* of what is normally inside the IE 5 folder on the Mac. Now it's all contained inside its own package, making removal (and moving in general) easy. This is *much* better than the Registry solution implemented by Windows, and also better than the forked system of the Mac OS (you can have a *lot* more resources in an object for one thing).

Remember, with ResEdit, you can just as easily get into and much around with resources in Mac OS "Classic" (our favorite trick waaay back in high school on System 6 macs was to change the Hand icon (used in the "Stop!" style Alerts) to flip the user off).
 

p

Registered
I'm not saying this is bad, I've just asked if this is common practice to have such easy and friendly access to proprietary elements of applications. The program code is pretty hard (if not impossible) to reverse engineer, as I know, but nib files are opened in a dedicated GUI tool, an easy one at that. To me, a nib file is somewhere between program code and source code, or maybe even the latter. Are you saying that user-editable GUI objects like nib files are also present in other OSes?

I haven't used ResEdit, OS X is the first platform that I'm really interested in as a hacker (I'm basically an absolute beginner, but I have the impression that OS X is gonna be a really friendly platform for aspiring developers).

Btw., I really like the idea of packages. The less litter an app throws all over the HD the better. I heard that plug-ins for apps like Photoshop or browsers will go inside the package too, so the host app will need to provide its own UI for managing them. I like that too, I just hope that I'll be able to remove bad plugins via the Finder if I really need to.

Also, on the phenomenon with TextEdit changing skin immediately: is that also common? Or does it have to do with dynamic linking? I'm in the dark here, this is "Computers for the Not Entirely Idiotic 101" for me now.

 

eucci

Registered

re: nibs and resources -- different OS's do make information like that available in different ways to edit, in varying degrees of course. You can do a lot of interesting tweaks with the Registry Editor on Windows, for example. The version of IE 5 (for windows) I downloaded turned out to be one of the co-branded ones that always says "...provided by ZDNet" in its title bar. Using the registry editor, that can be changed pretty easily (as long as you know where to look).

ResEdit on the classic Mac OS is a fairly common tool (so long as you can find it) that lets you edit the resource fork of any file in the Mac OS. Inside the resource fork tends to be everything from Menu definitions (if you know what you're doing, you can add new keyboard shortcuts to a program) to dialog box and window definitions to icons and many other resources. It's not as nice as Interface Builder, but ResEdit actually used to be one of the main tools for doing visual programming on the Mac - You use it to define and draw dialog boxes, menus, etc, and then refer to those resources in the code. (Microsoft's Visual C++ works similarly for windows). These sort of resource-based programs usually don't hold that much intelligence about the connections between View objects (ie - the resources) and the Controller\Model objects (the code), it's usually up to the programmer to do a lot of that manually. But it still seperates the View from the Code enough that using a tool like ResEdit you can do some sneaky alterations of dialog boxes, add keyboard shortcuts to menus, maybe change the window dressing of something, without requiring a recompile.

Interface Builder and .nibs are really just a much more advanced version of this. One of the things that makes this so is that Cocoa apps work on an Action-Target paradigm, while Carbon apps work on an Event Loop paradigm. What the Action-Target paradigm of Interface Builder means is that the relationships between objects is what's important. In event loop, the question is "What was just clicked and how should I dispatch?" when a button is clicked, while in Action-Target the statement is "I was just clicked, I should tell my target". It's hard to describe without going into too much detail, I recommend reading some of the documentation at Apple's developer site. But it really is a delightfully simple concept. And since .nibs are so central to Cocoa, there are some common API's and messages to refresh|awake a .nib. Your experience with TextEdit saw one of these happen, but I don't know whether TextEdit itself was watching the .nibs and refreshed for its own reasons or if the OS sent the message "hey, your .nib changed, refresh!" automatically.

A good sized PDF from the Rhapsody days (with some cute historical references to the older ideals of Rhapsody before the Mac OS X plan was introduced) that covers interface builder and the old project builder (now ProjectBuilderWO) is at http://developer.apple.com/techpubs/macosx/Legacy/DeveloperTutorial/Rhapsody_DiscOS.pdf

And also http://developer.apple.com/techpubs/macosx/

and http://developer.apple.com/techpubs/macosx/Cocoa/CocoaTopics.html


 

ebalch

Registered
I expect that Apple won't take away the ability to view the contents of packages. Please note that they've already demoted the menu option from the main menu to a context menu. Back in the NeXT days it was called "Open as folder". For myself as a carry-over developer from the NeXT days, I hope apple doesn't take it away. And I suspect even if they did remove it from the Aqua interface there's no reason you couldn't just bring up terminal and "cd" into the "package" and examine all it's bits and pieces. To me this is just another expression of the open attitude that is so common in the unix community.
 

p

Registered
whoa, thanks for the detailed answer.
I tried to replicate the behavior i mentioned (I decided I still like the original look of TextEdit better :) ), but the appearance didn't change immediately this time.
I also had to login as "root" in the first place. As a normal user, I couldn't rewrite the nib file (either because it was open as Text Edit was running), or just because.

I know that being "root" is really dangerous, and that you have the power to screw up anything, so please no letures on that... but it's strange to see that as root, I can even rewrite files belonging to running apps. That's really being "omnipotent".

Btw., does "NS" in the name of frameworks and objectsmean "NextStep"? If so, maybe Apple should change that to "X" or something, it's weird to have that reference.
 

Ghoser777

Registered
Originally posted by p
whoa, thanks for the detailed answer.
I tried to replicate the behavior i mentioned (I decided I still like the original look of TextEdit better :) ), but the appearance didn't change immediately this time.
I also had to login as "root" in the first place. As a normal user, I couldn't rewrite the nib file (either because it was open as Text Edit was running), or just because.

I know that being "root" is really dangerous, and that you have the power to screw up anything, so please no letures on that... but it's strange to see that as root, I can even rewrite files belonging to running apps. That's really being "omnipotent".

Btw., does "NS" in the name of frameworks and objectsmean "NextStep"? If so, maybe Apple should change that to "X" or something, it's weird to have that reference.
Don't be so scared of root. Everyone is just being over cautious - it's the same access privledges as single user on OS9. The only difference, I guess, is that u can type rm *.* a lot easier than u can select a whole bunch of system files and drop them in th trash. It's generally not a good idea to stay in root ALL the time, but whenever u need to tweek something, don't be so hesitant, especially when it's not important system software.

NS I believe does stand for NextStep. But i don't think they'll change that to X any time soon. They'd have to rewrite all their method calls ad compilers and the like, and that'd be a real pain in the butt.
 

Ghoser777

Registered
Originally posted by p
whoa, thanks for the detailed answer.
I tried to replicate the behavior i mentioned (I decided I still like the original look of TextEdit better :) ), but the appearance didn't change immediately this time.
I also had to login as "root" in the first place. As a normal user, I couldn't rewrite the nib file (either because it was open as Text Edit was running), or just because.

I know that being "root" is really dangerous, and that you have the power to screw up anything, so please no letures on that... but it's strange to see that as root, I can even rewrite files belonging to running apps. That's really being "omnipotent".

Btw., does "NS" in the name of frameworks and objectsmean "NextStep"? If so, maybe Apple should change that to "X" or something, it's weird to have that reference.
Don't be so scared of root. Everyone is just being over cautious - it's the same access privledges as single user on OS9. The only difference, I guess, is that u can type rm *.* a lot easier than u can select a whole bunch of system files and drop them in th trash. It's generally not a good idea to stay in root ALL the time, but whenever u need to tweek something, don't be so hesitant, especially when it's not important system software.

NS I believe does stand for NextStep. But i don't think they'll change that to X any time soon. They'd have to rewrite all their method calls ad compilers and the like, and that'd be a real pain in the butt.
 
Top