CuteClips3 beta12

March 11th, 2008 by Karsten

Thanks to my trip to last weekend’s CocoaDevHouse in Munich at equinux I had some time in the train to work on CuteClips. Lots of bugs were fixed and new features were added. Thanks to Christian I also added the ability to select clips and paste them in the order they were selected. To select clips use shift-up/down, space or shift-click a clip.

I also noticed that I still used Arial for the numbers, now it’s done with Helvetica 😀

Selections in CuteClips3

Have fun with the new version!

Karsten

Briksoftware’s website redesigned

March 10th, 2008 by Michele

Welcome to the new briksoftware’s website! So, we were quite tired of the old design and decided to completely redesign it.

There are still some things we’d like to adjust but the theme is pretty much done and most importantly, it matches our cool t-shirts and business card!

Ah, it also matches our wallpaper!

CocoaDevHouse

March 8th, 2008 by Karsten

Just some hours ago I got to Munich for tomorrow’s CocoaDevHouse. I guess it will be pretty interesting… there’ll be a talk about core data, maybe I finally understand it 😉

On the way here in the train I had some time to work on CuteClips and fixed some bugs, one of them was a badly drawn bezierpath with rounded corners. It was like the edges were drawn with anti aliasing and the corners with very blurry anti aliasing.

Bad pic

I tried the bezierpath in a different view today and it looked pretty normal, just like one would expect it. Then i noticed that the edge was not directly on a pixel, but rather in between two pixels. The problem I has was simply that the bezierpath was clipped and thus the round corners looked much thicker than the edges. I inset the rect that was used to create the bezierpath and boom, it worked 😉

Good pic

Karsten

Setting up your own server

March 2nd, 2008 by Michele

For those of you who may be in our same situation, switching from a managed shared hosting account to your own unmanaged server or VPS, I wrote a little how-to to help you were your resources are scarce and you just cannot use easy tools like cPanel.

This isn’t really “for dummies”, the tutorial doesn’t follow you step by step, but hey, you can get such a configuration to run even on a system with 128MB of RAM.

You can find the tutorial here.

inspecting the Pasteboard: Drop Inspector

March 2nd, 2008 by Karsten

Today I thought about a nice and easy way to inspect drag and drop objects or any Pasteboard in general. I ended up creating Drop Inspector, a very simple app that shows you the content of the General Pasteboard if you click on the drop area, or the content of the dragging pasteboard if you drag something on the drag area.

One big problem was that Cocoa (or OS X in general) doesn’t allow you to register a view for any draggin types. The app doesn’t even receive the mouse over event if you didn’t register for a certain type. But to solve this i simply added a text-input field where you can enter the identifier of this pasteboard type and click on “add type”.

Drop Inspector is listing all types that are registered in the pasteboard and if you select one it’ll show you the data of these types in a text-editor. That’s not the most useful thing to have, but better than nothing…copy and paste it into the hex-editor of your choice and see what comes out.

A much better way of processing this data is through FScript. So I added a simple FScript editor to the app, enter some code, hit Cmd-I and inspect the result. As most data on the clipboard is string data, the default is:

NSString alloc initWithData:data encoding:NSUTF8StringEncoding.

I guess it should be pretty useful for anyone who wants to add drag and drop support to an application or who wants to extend it and needs to see what kind of data is available.

The app is released under MIT License and includes the source-code. The disc image can be loaded from: DropInspector.dmg

Karsten

PS: oh, and if there’s any icon artist out there with some freetime, willing to create a better icon for DropInspector, please do! 🙂

Moved

February 28th, 2008 by Michele

We just got a new home! Moving away from the (exceptionally great) Shared Hosting at A Small Orange, we are now on a VPS still at A Small Orange.

Transition was pretty smooth after I got everything setup, which wasn’t too pleasing to do with no cPanel and little RAM.On the sad not, I’m thinking about closing down codebeach.org.

It hasn’t seen much traffic lately, and apparently only me and Karsten are contributing.
It was an interesting experiment I guess but is time to end it. If someone wants to stop my hand from the delete button, please do it now or never 😉

[EDIT] Probably codebeach is not going away after all

Thoughts on application deployment

February 22nd, 2008 by Karsten

I remember the early days/years of Mac OS X where Apple supplied the Installer.app and probably every software out there used it to install itself in the system. Then some day i noticed that more and more apps ship as a dmg, which was a big confusing in the beginning. After the years I now arrived to a point where I absolutely dislike installers.

Installers have a big downside: they take too long. Even though they’re really easy to use one has to click several times here and there, agree to agreements and even enter a password in most cases. Having to enter a password is a total no go on my side and i usually end up looking up where the files are copied to.

Disc images on the other hand download, maybe show an agreement, and then mount. The user just has to drag and drop the app to some folder he likes or by default just onto the application folder icon that is usually linked just next to the application icon. The user unmounts the image and is done installing. The disk images also have a very nice background pictures which makes it even more fun to install apps. Using a tool like FileStorm even makes it as easy as it might get to create disc images that look good. (Thanks to this post I just notice that it got updated just some days ago!!)

Some developers also deploy in a zip file, or in any other compressed file. The usage is as easy as with disc images: unpack and copy. But there’s a tiny little detail here that always drives me mad when downloading an app that ships as an archive: I always end up searching for the decompressed file. Thing is my download folder is pretty damn huge as I tend to not clean it up, so with a lot of archives and uncompressed files in that folder it’s pretty hard to guess how the files are called that just unpacked. Disc images open the window with the just mounted image right away and it’s totally easy to find the single one file that needs to be copied.

While disc images seem to be a perfect winner here, there’s a pretty annoying issue with Sparkle and disk images: if the disc image has a disclaimer it wouldn’t work with Sparkle. This little detail is really annoying unless one either changes to a disc image without agreement or to an archive like zip.

Uninstalling an Application is usually also easier if one moved just the application to the applications folder. Uninstalling an application that installed via installer is a bit tricky unless on knows which files were installed to which location.

I for myself usually think twice before installing an app using the installer (except if the app is from Apple 😉 ). If I download an application as archive I’m typically a bit annoyed to search for the decompressed file. Fortunately enough the disc images are used by most apps so it’s typically fun to install most apps!

I think for developers its probably the best to ship a disc image and provide a zip file for sparkle. Only if the application goes a bit deeper into the system and has to install files to somewhere other than the application folder, it should use an installer. What do you think?

Karsten

Activating Applications with shortcuts

February 17th, 2008 by Karsten

I’m using Cmd-Tab to cycle through my apps really often…in fact my left hand always sits on the keyboard and Cmd-Tab and Cmd-< is probably one of the most shortcuts used here to cycle through apps and windows. I don’t know why I just hit the option key while releasing the Cmd-Tab, but the result was pretty cool: It’s just like clicking the application’s icon in the dock!

I always wondered why apps just activate when you Cmd-Tab to them, but activating them in the dock always works a little bit different: in Mail it opens the main window if no window is open; in Safari it opens a new window if none is open. So pressing the option key when you want to release Cmd-Tab also does this.

The only downside is: it’s a bit tricky to do actually, especially as you can’t hold down option to activate the application cycling.

nice hidden modifier 😉

Karsten

NSImage drawing problems with jpgs that have a custom DPI

February 13th, 2008 by Karsten

I ran into this problem twice now but I finally found a way of drawing a JPG which has a different pixel-size than the NSImage that represents it.

So I had an NSImage that printed like this:

NSImage 0x250390 Size={601.5, 451.5} Reps=(
		NSBitmapImageRep 0x250df0 Size={601.5, 451.5} ColorSpace=NSCalibratedRGBColorSpace 
		BPS=8 BPP=24 Pixels=802x602 Alpha=NO Planar=NO Format=0
    )

Please notice the size of {601.5, 451.5}! First I was like WTF‽ Looking for a solution I found out that the bitmap representation responds to pixelsWide and pixelsHigh, so I could use this to calculate the correct size of the image. The next problem I needed to solve was how to tell the image that it should use the correct pixel size for drawing. I tried with drawInRect:fromRect:composite:fraction to no avail.

The solution to all this mess is as simple as it could be: just set the NSImage’s size to the pixel size and you’re done!

    NSImageRep* rep = [image bestRepresentationForDevice:nil];
    NSSize imgSize = NSMakeSize([rep pixelsWide],[rep pixelsHigh]);
    [image setSize:imgSize];

These three simple lines can save a lot of trouble, especially if you don’t know about these resolution information that NSImage seems to take care of.

So thanks to this little snippet Camouflage should render wallpapers pretty much exactly as Apple does in Finder.

Karsten

Installing things to /usr/bin – Trampolines

January 10th, 2008 by Michele

Some Mac OS X applications can install useful tools to use with Terminal. PDFKey Pro is one of those applications. Currently I simply installed a binary called “pdfkeypro” in /usr/bin via a .pkg file. This had the obvious draw back of needing the user upgrade it manually on every release.

Some applications, like the excellent TextMate place a symlink to an executable inside the application bundle, solving said problem. But introducing another one: as soon as the application bundle is moved, the symlink breaks.

As I am about to update the command line tools for PDFKey Pro, I started thinking about a better way to install said binaries. One which would update automatically when the main bundle is updated, but wouldn’t break if said bundle is moved in another location.

Trampolines to the rescue! Instead of installing the real tools I install 2 trampoline applications in /usr/bin called respectively pdflock and pdfunlock. The trampoline then uses NSWorkspace to locate the bundle, and starts the real executable found in the application’s bundle. The code of a trampoline looks like this:

int main(int argc, char *argv[]) 
{
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	NSWorkspace *env = [NSWorkspace sharedWorkspace];
	NSString *app = [env absolutePathForAppBundleWithIdentifier:@"com.pdfkey.pdfkeypro"];
	NSString *targetPath = [[app stringByAppendingPathComponent:@"Contents/Resources/pdflock"] retain];

	const char *CStringPath = [targetPath UTF8String];
	[pool release];

	execv(CStringPath, argv);

	// You reach this code only if execv returns, which means that something wrong happened.
	[targetPath release];
	printf("PDFKey Pro is not installed. Please download it from http://pdfkey.com\n");
	return 0;
}

I can already read the comment that I could use argv[0] instead of hardcoding the application name. That’s true, but this trampoline once written should not be ever modified again and I want it to perform the minimum number of instructions required to work.

You can use this code liberally to make your very own trampoline, consider this to be of public domain. You can also find it at codebeach.

As a side note, I wonder why most application installing things in /usr/bin usually have their very own installer. Why wouldn’t a .pkg do? This is a sincere question, not an attempt to flame. In PDFKey Pro all I do is bundle a .pkg file and provide a menu item which launches it. It couldn’t be easier!