<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Feature requests versus the &#8220;right way&#8221; to do it</title>
	<atom:link href="http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/feed/" rel="self" type="application/rss+xml" />
	<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/</link>
	<description>Crafty gnomes building toys for you</description>
	<pubDate>Fri, 16 May 2008 02:34:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Justin</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8738</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Mon, 12 May 2008 09:46:18 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8738</guid>
		<description>@Dan -- this is an interesting approach; I'll have a look at it! But I suspect it might be too much for me, as I really want Pukka to launch quickly. I'll have to see what the speed of it is like.</description>
		<content:encoded><![CDATA[<p>@Dan &#8212; this is an interesting approach; I&#8217;ll have a look at it! But I suspect it might be too much for me, as I really want Pukka to launch quickly. I&#8217;ll have to see what the speed of it is like.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8730</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Sat, 10 May 2008 19:00:31 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8730</guid>
		<description>Very interesting article! I believe I have succeeded in overcoming all the difficulties that you describe (and created a new one, but it seems to be a very minor one, see below). The trick is to set LSUIElement=1 in the Info.plist, then if on initialization the app wants to become an ordinary foreground application, use TransformProcessType(), which causes the dock icon to display, followed by a call to SetSystemUIMode(kUIModeNormal, 0), which re-enables the menu bar. This almost solves the problem completely. The only remaining difficulty is that the menu bar is still not visible until you switch to a different app and then switch back. In the code I wrote I overcame this by switching to the dock and back, resulting in the following somewhat ugly hack:

#import 

// this should be called from the application delegate's applicationDidFinishLaunching
// method or from some controller object's awakeFromNib method
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"LaunchAsAgentApp"]) {
        ProcessSerialNumber psn = { 0, kCurrentProcess };
        // display dock icon
        TransformProcessType(&#38;psn, kProcessTransformToForegroundApplication);
        // enable menu bar
        SetSystemUIMode(kUIModeNormal, 0);
        // switch to Dock.app
        [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:@"com.apple.dock" options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil launchIdentifier:nil];
        // switch back
        [[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
}

As far as I can tell, beyond the code's ugliness its only shortcoming is that it might produce a strange result for users who have disabled the Dock application and use other window management programs like Desktop Manager. Sounds like a small price to pay, though, considering the problems with the other approaches you describe in the article.</description>
		<content:encoded><![CDATA[<p>Very interesting article! I believe I have succeeded in overcoming all the difficulties that you describe (and created a new one, but it seems to be a very minor one, see below). The trick is to set LSUIElement=1 in the Info.plist, then if on initialization the app wants to become an ordinary foreground application, use TransformProcessType(), which causes the dock icon to display, followed by a call to SetSystemUIMode(kUIModeNormal, 0), which re-enables the menu bar. This almost solves the problem completely. The only remaining difficulty is that the menu bar is still not visible until you switch to a different app and then switch back. In the code I wrote I overcame this by switching to the dock and back, resulting in the following somewhat ugly hack:</p>
<p>#import </p>
<p>// this should be called from the application delegate&#8217;s applicationDidFinishLaunching<br />
// method or from some controller object&#8217;s awakeFromNib method<br />
if (![[NSUserDefaults standardUserDefaults] boolForKey:@&#8221;LaunchAsAgentApp&#8221;]) {<br />
        ProcessSerialNumber psn = { 0, kCurrentProcess };<br />
        // display dock icon<br />
        TransformProcessType(&amp;psn, kProcessTransformToForegroundApplication);<br />
        // enable menu bar<br />
        SetSystemUIMode(kUIModeNormal, 0);<br />
        // switch to Dock.app<br />
        [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:@&#8221;com.apple.dock&#8221; options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil launchIdentifier:nil];<br />
        // switch back<br />
        [[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];<br />
}</p>
<p>As far as I can tell, beyond the code&#8217;s ugliness its only shortcoming is that it might produce a strange result for users who have disabled the Dock application and use other window management programs like Desktop Manager. Sounds like a small price to pay, though, considering the problems with the other approaches you describe in the article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8357</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Sun, 02 Mar 2008 17:17:11 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8357</guid>
		<description>Thanks Justin!  I'm buying the app right now...</description>
		<content:encoded><![CDATA[<p>Thanks Justin!  I&#8217;m buying the app right now&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8356</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Sun, 02 Mar 2008 16:14:44 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8356</guid>
		<description>@Jon: Thanks for your feedback. One thing that you can do right now to run Pukka dockless is to quit the app, copy and paste the following into a Terminal window, hit Return, then relaunch Pukka: 

&lt;code&gt;defaults write /Applications/Pukka.app/Contents/Info LSUIElement 1&lt;/code&gt;

If you were to then want to go back to dock mode, you'd use this: 

&lt;code&gt;defaults write /Applications/Pukka.app/Contents/Info LSUIElement 0&lt;/code&gt;

i.e., the same thing but with a zero instead of a one. 

This is the method mentioned above of altering the app bundle itself, which is the method that some apps use to go dockless, but the one that will eventually mess with code signing.</description>
		<content:encoded><![CDATA[<p>@Jon: Thanks for your feedback. One thing that you can do right now to run Pukka dockless is to quit the app, copy and paste the following into a Terminal window, hit Return, then relaunch Pukka: </p>
<p><code>defaults write /Applications/Pukka.app/Contents/Info LSUIElement 1</code></p>
<p>If you were to then want to go back to dock mode, you&#8217;d use this: </p>
<p><code>defaults write /Applications/Pukka.app/Contents/Info LSUIElement 0</code></p>
<p>i.e., the same thing but with a zero instead of a one. </p>
<p>This is the method mentioned above of altering the app bundle itself, which is the method that some apps use to go dockless, but the one that will eventually mess with code signing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8355</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Sun, 02 Mar 2008 15:27:09 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8355</guid>
		<description>To tell you the truth, I have avoided buying Pukka because it does not run dockless.  I try a new version out every few months in the hope that it's added, but to me having a docked Pukka is a plague.  I have absolutely no interest in it wasting space on my dock. I absolutely hate seeing it there. I never swap to it anyway - it's default window is just a blank entry screen - who would want to swap to that....

So once you figure out how to go dockless, I'll buy the app!  There are so many dockless apps out there.  I understand from your post that the issue isn't as straightforward as you would wish, but don't stop me from going dockless now because in the future Apple might change something... Or because of Applescript.  I'd like to use Pukka in two ways: a) from netnewswire, b) as a bookmarklet. I'm sure 95% of your users do the same.  Save us all from tearing our hair out :-)  Please!</description>
		<content:encoded><![CDATA[<p>To tell you the truth, I have avoided buying Pukka because it does not run dockless.  I try a new version out every few months in the hope that it&#8217;s added, but to me having a docked Pukka is a plague.  I have absolutely no interest in it wasting space on my dock. I absolutely hate seeing it there. I never swap to it anyway - it&#8217;s default window is just a blank entry screen - who would want to swap to that&#8230;.</p>
<p>So once you figure out how to go dockless, I&#8217;ll buy the app!  There are so many dockless apps out there.  I understand from your post that the issue isn&#8217;t as straightforward as you would wish, but don&#8217;t stop me from going dockless now because in the future Apple might change something&#8230; Or because of Applescript.  I&#8217;d like to use Pukka in two ways: a) from netnewswire, b) as a bookmarklet. I&#8217;m sure 95% of your users do the same.  Save us all from tearing our hair out <img src='http://codesorcery.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Please!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8294</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Thu, 07 Feb 2008 02:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8294</guid>
		<description>@Tom: You can use &lt;code&gt;defaults&lt;/code&gt; to write to the app bundle (as I do in the Xcode build script) but not to the user defaults. Or, rather, it doesn't have any effect. I wish it could go into the defaults :-/

I'm pretty open in how I target the binary. I should mention that it's kind of unpredictable as to which version gets opened, though -- it's not always the outer one. It's kind of up to the whim of Launch Services. Regardless, though, the launched version can figure out which one it is and launch the other. I'm currently using NSTask to launch the binary directly, but I could use NSWorkspace, &lt;code&gt;/usr/bin/open&lt;/code&gt;, &lt;code&gt;execve()&lt;/code&gt;, etc. Regardless, I'm still not seeing how to get the context of the current Apple Event to pass it along. For file opening and the NNW posting protocol, I have methods that are called, so that's been easy, but for AppleScript, either my NSScriptHandler subclass's &lt;code&gt;performDefaultImplementation&lt;/code&gt; is called (for commands) or my app delegate's &lt;code&gt;application:delegateHandlesKey:&lt;/code&gt; is consulted (for getters/setters) but I'm not able to grasp the event to pass it along. Even if I could, I've tried passing dummy events and the Script Editor running the script seems to get confused and loses the connection with the app when the other version is launched.</description>
		<content:encoded><![CDATA[<p>@Tom: You can use <code>defaults</code> to write to the app bundle (as I do in the Xcode build script) but not to the user defaults. Or, rather, it doesn&#8217;t have any effect. I wish it could go into the defaults :-/</p>
<p>I&#8217;m pretty open in how I target the binary. I should mention that it&#8217;s kind of unpredictable as to which version gets opened, though &#8212; it&#8217;s not always the outer one. It&#8217;s kind of up to the whim of Launch Services. Regardless, though, the launched version can figure out which one it is and launch the other. I&#8217;m currently using NSTask to launch the binary directly, but I could use NSWorkspace, <code>/usr/bin/open</code>, <code>execve()</code>, etc. Regardless, I&#8217;m still not seeing how to get the context of the current Apple Event to pass it along. For file opening and the NNW posting protocol, I have methods that are called, so that&#8217;s been easy, but for AppleScript, either my NSScriptHandler subclass&#8217;s <code>performDefaultImplementation</code> is called (for commands) or my app delegate&#8217;s <code>application:delegateHandlesKey:</code> is consulted (for getters/setters) but I&#8217;m not able to grasp the event to pass it along. Even if I could, I&#8217;ve tried passing dummy events and the Script Editor running the script seems to get confused and loses the connection with the app when the other version is launched.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Harrington</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8292</link>
		<dc:creator>Tom Harrington</dc:creator>
		<pubDate>Thu, 07 Feb 2008 02:17:53 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8292</guid>
		<description>I had thought you could set LSUIElement using "defaults write..." but it seems I was mistaken.

The question of Apple Events, etc, probably depends on how you launch the hidden pseudo-app bundle.  Higher-level approaches like telling NSWorkspace to open it probably mean you need to pass everything on yourself.  A lower-level approach like execve(), targeting the binary directly, might mean you could just wait until after execve() to read all that information, and it'd all just arrive.  This is an untested idea, though.</description>
		<content:encoded><![CDATA[<p>I had thought you could set LSUIElement using &#8220;defaults write&#8230;&#8221; but it seems I was mistaken.</p>
<p>The question of Apple Events, etc, probably depends on how you launch the hidden pseudo-app bundle.  Higher-level approaches like telling NSWorkspace to open it probably mean you need to pass everything on yourself.  A lower-level approach like execve(), targeting the binary directly, might mean you could just wait until after execve() to read all that information, and it&#8217;d all just arrive.  This is an untested idea, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8287</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Wed, 06 Feb 2008 23:31:31 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8287</guid>
		<description>@Lee: Thanks for the post. I've considered this too, but it opens up the possibility of differences creeping up between the versions that could complicate the support of Pukka more than the feature is worth (either intended because certain things wouldn't be possible on both versions, or unintended because of bugs). Also, it would mean that I have to package separate versions for Sparkle to use as well and keep that distinction between the two versions. Lastly, people would read about the feature on the site but perhaps wouldn't download the right version and that would also complicate things. It's not out of the question, but it seems to me a non-ideal solution as well.</description>
		<content:encoded><![CDATA[<p>@Lee: Thanks for the post. I&#8217;ve considered this too, but it opens up the possibility of differences creeping up between the versions that could complicate the support of Pukka more than the feature is worth (either intended because certain things wouldn&#8217;t be possible on both versions, or unintended because of bugs). Also, it would mean that I have to package separate versions for Sparkle to use as well and keep that distinction between the two versions. Lastly, people would read about the feature on the site but perhaps wouldn&#8217;t download the right version and that would also complicate things. It&#8217;s not out of the question, but it seems to me a non-ideal solution as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lee</title>
		<link>http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8284</link>
		<dc:creator>lee</dc:creator>
		<pubDate>Wed, 06 Feb 2008 20:05:43 +0000</pubDate>
		<guid isPermaLink="false">http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it/#comment-8284</guid>
		<description>offer two downloads for your app. one that is displayed in the dock, the other that does not.</description>
		<content:encoded><![CDATA[<p>offer two downloads for your app. one that is displayed in the dock, the other that does not.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
