Ted Leung on the air
Ted Leung on the air: Open Source, Java, Python, and ...
Fri, 06 Feb 2004
Developer response time
One thing that I'm really enjoying about the Macintosh is the abundance of small responsive developers. Take my more recent experience: I've been getting more and more reluctant to disconnect the PowerBook and work outside my office. The reason? I'm using a big 21" (1856x1392) monitor in the office. When I "undock", all of my windows move into semi-reasonable positions (but not sizes) for a 1280x854 display. So there's a bunch of time that I waste to rearrange and resize all the windows. When I "re-dock" I have to the same thing to get back to optimality for the big screen. This is compounded by the fact that I'm using virtual desktops. What I need is something that rearranges and resizes the windows based on the presence or absence of an external display. This being a Macintosh, I figured that this was exactly the kind of job for AppleScript (I suppose you could argue that this is a feature request for CodeTek Virtual Desktop, but I don't believe so). So I started looking for a way for AppleScript to figure out how many displays there were. I wasn't having much luck, and figured that I was going to have to write a scripting extension that could talk to Cocoa/Carbon and get the job done myself. I even went as far as downloading an Apple Code sample.

Tuesday I came across Extra Suites which is a package of scripting extensions that can do all sorts of stuff. One of the extensions lets you get information about the screen - dimensions, etc. Alas, It only worked for a single display. I say worked, because late Tuesday night I sent e-mail off the the Kanzu e-mail address, asking about multiple display support. Wednesday morning when I sat down in front of my machine, there was a prerelease of Extra Suites 1.0.2 that contained a new command to count the number of displays, and the screen info command had been extended to take the display number as a parameter. I'm not sure I've gotten such quick response from an open source project... Needless to say, the $10 for Extra Suites is less than the cost of the relevant Cocoa books and the time and hassle of figuring out how to do this myself.

So the next step is for me to figure out enough AppleScript to write a window layout script that can position the relevant windows (I have a standard setup) according to the display configuration. They'll even (mostly) be on the right virtual desktop, because CodeTek Virtual desktop can switch desktops from AppleScript -- I have a request in to them to move single windows across virtual desktops -- maybe in the next release. Once I get that going, Kanzu is going to get my $10. It's just a small matter of time and programming.

[00:09] | [computers/operating_systems/macosx] | # | TB | F | G | 5 Comments | Other blogs commenting on this post

FYI, you can buy all the Cocoa books you want and they're not going to do you any good in this case.  Scripting Extensions are Carbon beasts, and the APIs to enumerate display hardware live in CoreGraphics.  I'm pretty sure that CoreGraphics is not even covered anywhere other than Apple's electronic documentation, and last I checked most of the relevant Carbon books are really old-world pre-carbon books that are out of print (but were reprinted by fatbrain a few years ago, I don't know if that is still the case).

What I'm trying to say is that OS X is a pretty new platform, and you shouldn't waste your money on books.  There's perhaps two or three worth owning if you need someone to hold your hand while you learn Interface Builder and the Foundation/AppKit frameworks, but that's about as far as they go in my experience.  Also, these frameworks are not really stable.. Every new release of OS X adds a slew of enhancements to these frameworks.  Two particular instances of AppKit enhancements in 10.3 that I have experimented with are the addition of programmable word completion to all text views (used in PyInterpreter, an example now included with PyObjC), and an entirely new paradigm of developing controllers (first called the Controller Layer, but now called Cocoa Bindings), which is used by Bill's latest WebServicesTool example (depends on Twisted, but also comes with PyObjC as an example).  Anyways, I'm pretty sure all the books out there are stale, and if the books covered CoreGraphics, they'd probably be stale too.  I'm relatively sure Apple has done quite a bit of good there considering the performance enhancements.

You might have better luck just writing it in C, AppleScript is pretty annoying ;)  That's something I'm working on, I should have a new release of aeve (my Apple Events <-> Python bridge) at some point in the near future.
Posted by
Bob Ippolito at Fri Feb 6 04:30:17 2004




You can subscribe to an RSS feed of the comments for this blog: RSS Feed for comments

Add a comment here:

You can use some HTML tags in the comment text:
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are: <a href>, <em>, <i>, <b>, <blockquote>, <br/>, <p>, <code>, <pre>, <cite>, <sub> and <sup>.

You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk

Name:


E-mail:


URL:


Comment:


Remember my info?


twl JPG

About

Ted Leung FOAF Explorer

I work at the Open Source Applications Foundation (OSAF).
The opinions expressed here are entirely my own, not those of my employer.

Creative Commons License
This work is licensed under a Creative Commons License.

Now available!
Professional XML Development with Apache Tools : Xerces, Xalan, FOP, Cocoon, Axis, Xindice
Technorati Profile
PGP Key Fingerprint
My del.icio.us Bookmarks
My Flickr Photos


Syndicate
RSS 2.0 xml GIF
Comments (RSS 2.0) xml GIF
Atom 0.3 feed
Feedburner'ed RSS feed

< February 2004 >
SuMoTuWeThFrSa
1 2 3 4 5 6 7
8 91011121314
15161718192021
22232425262728
29      

Archives
2006
2005
2004
2003

Articles
Macintosh Tips and Tricks

Search
Lucene
Blogs nearby
geourl PNG

Categories
/ (1567)
  books/ (33)
  computers/ (62)
    hardware/ (15)
    internet/ (58)
      mail/ (11)
      microcontent/ (58)
      weblogs/ (174)
        pyblosxom/ (36)
      www/ (25)
    open_source/ (145)
      asf/ (53)
      osaf/ (32)
        chandler/ (35)
        cosmo/ (1)
    operating_systems/ (16)
      linux/ (9)
        debian/ (15)
        ubuntu/ (2)
      macosx/ (101)
        tips/ (25)
      windows_xp/ (4)
    programming/ (156)
      clr/ (1)
      dotnet/ (13)
      java/ (71)
        eclipse/ (22)
      lisp/ (34)
      python/ (86)
      smalltalk/ (4)
      xml/ (18)
    research/ (1)
    security/ (4)
    wireless/ (1)
  culture/ (10)
    film/ (8)
    music/ (6)
  education/ (13)
  family/ (17)
  gadgets/ (24)
  misc/ (47)
  people/ (18)
  photography/ (25)
    pictures/ (12)
  places/ (3)
    us/ (0)
      wa/ (2)
        bainbridge_island/ (17)
        seattle/ (13)
  skating/ (6)
  society/ (20)



[Valid RSS]

del.icio.us linkblog

www.flickr.com

Blogroll

java.blogs
Listed on BlogShares

Locations of visitors to this page
Where are visitors to this page?


pyblosxom GIF