Cocoa and Tab-Modality

Thursday, December 17, 2009 at 12:00 AM



(Note: as regular readers know, we occasionally publish extra-geeky technical posts here on the Google Mac Blog. If this isn't your thing, don't worry; our usual non-technical stuff will be back soon.)

I'm part of the Chromium team working on Mac issues, and as I wrote on our blog, for Chromium we needed a way to provide modality to individual tabs of our web browser. Specifically, we needed to attach sheets to a Cocoa view rather than to just a Cocoa window. How would we accomplish this?

Like always, it's half following what's possible, and half sudden inspiration. What's possible? Putting a sheet on a window. That's done several ways. For an arbitrary sheet you can use
-[NSApplication beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]. But nearly every class that can put up a sheet has its own -beginSheet: method. NSAlert has
-beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:. IKPictureTaker has
-beginPictureTakerSheetForWindow:withDelegate:didEndSelector:contextInfo:.

So we know that we need to hang our sheet on a window. That's where the inspiration comes in. I was talking with a fellow Mac team member who offhandedly mentioned invisible windows. Of course! If you have an invisible window that has a sheet attached, then for all practical purposes you have an independent sheet. Plus, if you make the invisible window the child window of the window that hosts the view that appears to run the sheet, then you can size the invisible window to cover the view and eat all the clicks, achieving the desired modality as well.

That was the easy part. The first implementation was quick, but quickly uncovered issues.

First, how do you hide the sheet when the view is hidden? At first I tried hiding the invisible window, but when you -orderOut: a window you kill any sheets on it. That wouldn't do. Then I remembered the good old days of the Mac Toolbox (and Cocoa before 10.3 when NSView got -setHidden:), where you'd just move windows or views off to infinity (or (-15000,-15000), whichever was closer). Exposé quickly revealed the folly of that approach. Turning the sheet's opacity to 0% worked under Leopard, but under Snow Leopard the sheet blurring effect stayed present. And if I resized the window to NSZeroSize, resizing it back to the original size wrecked the layout.

Eventually I settled on a combination that worked. First I set autoresizesSubviews of the content view of the sheet to NO, and then I resized the sheet down to nothing. Then I set the opacity to 0%. Once I set the invisible window to stop eating clicks, it all worked.

The second problem was all the different classes that provided methods to show a sheet. Even if you could get the sheet window from them, if you ran it using the NSApplication sheet method, it didn't work. A little (actually a lot) of NSInvocation magic helped smooth that issue over.

That's basically it. The API is really simple and the implementation is, if nothing else, amusing to read.

Should you go ahead and use this in your app? Probably not. This is a very specific tool for solving a very specific modality problem that we had. But if you have a similar modality problem, perhaps this is right for you. Give it a try and let us know what you think.

Google Chrome for Mac goes beta!

Tuesday, December 08, 2009 at 7:19 AM

73,804 lines of Mac-specific code and 29 developer builds later, we're excited to finally release Google Chrome for Mac in beta. We took a hefty dose of goodness from the Windows version to build a fast, polished browser for Mac -- with features such as the Omnibox (where you can both search and type in addresses), themes from artists, and most importantly, speed. Try downloading Google Chrome for Mac and see what you think.

We also took great care to make Google Chrome a native application for Mac. For example, we integrated the Keychain into Google Chrome for Mac, and incorporated Mac-style animations when you open the Bookmarks bar.

For more details on today's beta release of Google Chrome for Mac, check out the video below.



To our early users who tried the weekly developer channel builds and provided excellent feedback, we thank you. In bringing the Mac version of Google Chrome from its developer stages to a beta standard, we returned to the core principles of the Chromium project and focused on delivering rock-solid depth in a few critical areas for the browser, rather than a breadth of features that are rough around the edges. This first beta release for Mac does not yet incorporate extensions, bookmark sync, bookmark manager, and cookie manager. However, we focused on features such as sandboxing our renderer process to help provide a safer web experience for our users. We look forward to future releases of Google Chrome for Mac, which will fill in the gaps and provide a fast, clean browser for your enjoyment on Mac OS X.

Can't wait for more info? Read our frequently-updated detailed status, or keep an eye on some Mac-specific sections of the source code. Don't forget to give Google Chrome for Mac a try, and let us know what you think.

Google Chrome for Mac, on the New Tab page


Google Chrome for Mac, with an artist theme


Google Earth for iPhone version 2.0

Wednesday, November 18, 2009 at 11:12 AM



There's a nice update to Google Earth for iPhone and iPod touch available now. You can read all about it in the Google Mobile Blog and you can grab the update in the App Store.

New auto-expanding compose boxes in Gmail for iPhone

Thursday, October 29, 2009 at 10:47 AM



Gmail for iPhone has a new feature: auto-expanding compose boxes. This means that when you're writing a new message and you reach the bottom of the compose box, the box now gets bigger automatically. And you can now scroll through the whole message just by flicking – no need to use the magnifying glass any more.

For all the details, see this post on the Google Mobile Blog.

New face-tagging, iPhoto compatibility, & more Mac-friendly features in Picasa 3.5

Tuesday, September 22, 2009 at 1:00 PM



Today, I'm happy to announce that we're releasing Picasa 3.5, a new version of our free photo editing software. Since we launched it as a beta Labs product 9 months ago, we've been steadily improving Picasa for Mac. Now that it has almost all the same features as the PC version, we've decided it's time to remove the beta label once and for all.

If you haven't tried Picasa for Mac, the new version gives you the ability to add name tags to your photos so that you organize them by what matters most: people. Picasa groups similar faces and lets you easily add a name tag to dozens of photos at once. After you've tagged some photos with names, you can do creative things with your tagged photos, like quickly finding all the photos with the same two people in them, making a face collage for a friend, or simply uploading and sharing people albums.



In addition to name tags, Picasa 3.5 has integrated Google Maps so you can more easily geotag your photos. And using our redesigned import process, you can now import photos from your camera and upload selected photos to Picasa Web Albums in one easy step.

Of course, Picasa for Mac is also designed to "play nice" with iPhoto, taking a special read-only approach to editing photos stored in the iPhoto library. It duplicates instead of changing files as needed, so your iPhoto library isn't ever affected when you use Picasa.

Picasa 3.5 is available in English (for now; more languages to come). You can download and try it today at picasa.google.com.

Improved Contact Sync in Snow Leopard

Tuesday, September 01, 2009 at 2:56 PM



In May 2008, we told you how iPhone and iPod touch users could sync their Gmail contacts with Address Book in Mac OS X 10.5. Now with Mac OS X 10.6, syncing Gmail contacts is also available to users who do not have an iPhone or iPod touch. If your Mac is running Snow Leopard, you can turn on contact sync in the Address Book preferences.

The syncing is better, too: in Mac OS X 10.6, only contacts in Gmail's "My Contacts" group are synced, rather than all of Gmail's contact suggestions. And photos are now transferred as well, since sometimes you just need to put a face to a name.

Before turning on contact sync, it's a good idea to back up your Gmail and Address Book contacts. Our help page explains how to do that, and covers a bit more on how contact sync works.

WWDC 2009 journal (part 2)

Monday, August 24, 2009 at 11:05 AM

by Mike Morton, Google Mac Team

Every year, Google engineer Mike Morton becomes intrepid reporter Mike Morton as he ventures to Apple's Worldwide Developer Conference. Apple doesn't allow attendees to disclose the technical bits of the conference, so Mike writes about other important observations and details: general survival tips for the week, how to figure out in advance when the conference will be held, and insight into how WWDC is like the Soviet Union. Once you've read part 1 of Mike's annual report, you can continue to the thrilling conclusion here in part 2.

Between the lines

Wednesday morning, I discovered the gym in the corporate apartments, and found that 20 minutes on the elliptical goes a lot faster when there’s no TV intruding.

Eating the minimalist breakfast provided at Moscone, I looked over a web page of WWDC-related parties. I think I’m probably too old to go to a club called “Harlot”. In fact, I’m even too old for the music they play before sessions; there's nothing that was written before the turn of the millennium. Several other folks commented that they didn’t think much of the music either. I told them about my neighbor’s bumper sticker: “It’s Not That I’m Old. Your Music Really Does Suck.”

Two guys at the breakfast table seemed to be forming a business on the spot. They weren’t too far along, though: one said to the other, “Let me give you my card”, ripped a page from a notebook, and wrote his contact info on it.

The session rooms were the same size as last year, but with more people trying to crowd in. The poor Apple engineers, who don’t get to go in until all the paying customers have, must have been even more frustrated this year. I wonder how Apple will handle the growth next year. Some rumors claimed that this is the last year at Moscone, that Apple has met some contractual obligation.

Despite the larger crowds, there seemed to be more power outlets in the sessions. You can often spot clusters of them from a distance — those seats are more densely filled. I went the whole week without having to pull the spare battery from my pack, a first.


Nerdvana!

For me this year, the most interesting part of the week was in the labs, not the sessions. Apple said that they brought in over 1,000 of their engineers, and I can believe it. Lots of attendees (n00bies and not) queue up for help from an Apple expert in the area they need help with. At one point, an iPhone performance engineer was helping one person, with four others (including me) in line with questions.

Attendees lined up for other things, too: to get good seats for sessions, for snack tables set up between sessions, for the fridges with Odwalla juice. It felt a little like the old Soviet economy: you see a line and you figure it must be worth waiting in. Of course, the Soviet strategy has its downside: you might find that the line turns out to be a bunch of Apple engineers waiting to see if a session has seats.

iPhones everywhere

Walking to Moscone, I noticed just how many iPhones there are in the city, and not just near the conference. Maybe this platform really is as big a deal as Apple keeps telling us. I think I saw more iPhones than Zipcars, which are also plentiful.

Earlier, I mentioned the importance of the labs for one-on-one access to helpful Apple engineers, but I should say that most sessions were good, too. Sitting for that many hours was tiring – when will they introduce premium seating? I’d pay more for Herman Miller – but mostly worth it. The only time it’s not worth it is when the talk is too elementary or too advanced. Alas, that does happen. Apple has a difficult challenge because attendees have experience ranging from near-zero up to decades of Cocoa development. It’s a balancing act, and Apple did it fairly well. At least as an old-timer I thought they did. I wonder what newcomers think. All those folks focusing on their laptops in sessions: are they tuned out, or just trying the examples from the session?

Even though some sessions miss the mark, the week as a whole is useful. I think the importance of this conference is demonstrated by a Googler I know who doesn’t work with Apple products enough to justify Google sending him, so he took a week of vacation and paid his own conference fee and travel expenses just to go.

Show’s Over

I confess I blew off the last day of the conference to go to my godson’s college graduation. In the BART station, waiting for a train to the airport, I chatted with someone who was also skipping the last day of his conference, some non-Apple thing. We agreed that the last day is usually the most boring, and that we felt sorry for anyone who has to speak on the last day.

Sitting on the flight home, I had to focus on work because, again, I had no window. I tried to go through all my notes. It was a frantic week, and I had notes in my laptop, in my iPhone, in emails to my team, on scraps of paper big and small, and it was good that I made those notes, because the conference feeds me so much information, I for one have to write it down or lose it. Now it was time to look at all the cool new things in the OS and the hardware and figure out how and when we can take advantage of them!