skip main content

Posts Tagged ‘OSX’

My Garmin eTrex Vista HCx and OSX

posted by Duncan at 9:05 pm on June 10th, 2010

A quick post of my learnings when researching the best setup for my Garmin eTrex Vista HCx as most of what I initially found was old, PC only, or just plain wrong.

Garmin eTrex Vista HCx

I chose this GPS device because it was reasonably cheap, expandable, and allowed me to upload maps to the device, and visa-versa. I also wanted to use the power of OpenStreetMap, rather than pay Garmin lots of money, and my research showed me this was possible.

So, rather than talk about all the things that I couldn’t find or do, I’ll just run through the good stuff. Here’s a run down of all the useful software I found.

  • OSM/Computerteddy Garmin IMG tile calculator

    Create a bounding box on a map of the world, and it will return an OSM IMG to use on your device. There’s even a great bookmarklet to use on the OpenStreetMap site. This is an awesome site.

  • geofabrik.de

    A great resource of maps of the world. I don’t speak German, but you can get the idea of what you’re able to download.

  • http://fredericbonifas.free.fr/

    Detailed map of France. I used this on a recent cycle tour, and it was invaluable.

  • TrailRunner

    TrailRunner is a route planning Mac software for all kinds of long distance sports like running, biking, hiking, inline-skating, skiing and more. It’s free, but a donation of 25 Euros will stop prompts. It’s a fantastic bit of software.

  • LoadMyTracks

    This free utility works hand-in-hand with TrailRunner. It will send and receive data to and from the eTrex. It can also be used to translate data between the popular GPX and KML (Google Earth) formats.

Finally there is the OpenStreetMap Garmin page which has the useful information about getting all this data onto the device, and much more.

nextKeyView and moving between NSTextfield and NSButton

posted by Duncan at 3:57 pm on May 26th, 2010

This caught me out today, so I thought I’d share to save someone else scratching their head. The problem I was having was thus. In interface builder I had a window with an NSTextField and an NSButton. I want to be able to tab between them. I did what I thought was correct:

  1. Set the intialFirstResponser for the NSWindow to be my NSTextField
  2. Set the NSTextField nextKeyView to be the NSButton
  3. Set the NSButton nextKeyView to be my NSTextField

But this was not working in the app! It Turns out that in the Apple > System Preferences > Keyboard there is a setting that allows you to press Tab to move keyboard focus between:

  • Text boxes and lists only
  • All controls

I think the top one is set by default. Once changed to All controls everything worked as expected.

Fun with Quartz Composer in Snow Leopard and the BBC Radio Schedule

posted by Duncan at 12:34 pm on October 7th, 2009

I’ve just posted on the BBC Radio Labs blog about some tinkering with Quartz Composer I’ve done. Please read the full article there, but in short, I’ve created a Quartz Composition that you can install as a Screen Saver, that reads in the BBC National Radio Schedule and rolls through each station showing who’s on and displays a pretty picture. Oh, and I think it all looks very pretty.

BBC Radio Screen Saver

Head on over to the Radio Labs site to download and install on your machine. Please note though, it’s for OSX 10.6 Snow Leopard only.

Another iPhone Code Sign Error Fix solution

posted by Duncan at 3:10 pm on May 10th, 2009

Dam, this took far to long to suss out !!! I even left the London Open Hack 2009 early because I was unable to install development apps I was working on onto my iPhone, and it was proving so frustrating I decided to go home to try and fix it there … Dam!!!

So the error I was getting was:

Code Sign error: The identity 'iPhone Developer' doesn't match any valid 
certificate/private key pair in the default keychain

I won’t bore you with all the variations, forums, websites read and ways I tried to solve this, and will leave you with the solution in this case. The problem was that the KeyChain App had changed it’s default keychain over to ‘system‘ and it should have been ‘login‘ as this is where all my keys and certificates are installed. Also, the default keychain is where Xcode looks. The default keyChain in the one in the keychains list that is bold. To make one the default, you right click on it and select the ‘make default’ item from the list.

Yep, That’s It!! and to be honest the error message make a little more sense now I’ve fixed it … Dam!

Using Cocoa to keep an app window always on top

posted by Duncan at 4:39 pm on April 11th, 2009

Sometimes you want your application to keep one of it’s windows always-on-top. A chat application like Adium for example, allows you to keep your conversation window always-on-top so you can follow the conversation whilst still using other applications. In the TellyBox application I wrote, this functionality is also very useful, as you can watch tv whilst still working in other applications.

So the basic implementation was fairly simple. You just use the windowDidResignMain notification, and then re-set the window level a more fitting one. Below I have also wrapped around a preference setting:

- (void)windowDidResignMain:(NSNotification *)notification
{
  // It's always nicer if the user has a choice
  if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAlwaysOnTop"] == YES) {
    [[self window] setLevel:NSFloatingWindowLevel];
  } else {
    [[self window] setLevel:NSNormalWindowLevel];
  }
}

My TellyBox application allows you to go fullscreen via the existing Flash application embedded in a webkit view. Using just the basic implementation meant that when going into fullscreen mode the frame of the original window remained in view. To fix this I added this extra bit of code, which gets used via the firing of another useful notification windowDidBecomeMain :

- (void)windowDidBecomeMain:(NSNotification *)notification
{
  [[self window] setLevel:NSNormalWindowLevel];
}

which sets the window level back to it’s default value of 0 when it becomes the main window i.e when you select it.

I hope this little snippet helps people trying to achieve the same effect in their apps.

Lookup – A simple Mac utility that wraps ldapsearch

posted by Duncan at 11:53 am on April 7th, 2009

I work on a Mac at work, and it has always been a bit slow searching for other staff members in our global address book. Like other big organisations we have some directory services which we can use LDAP to interrogate. The seemingly standard way for apps to poll these services is asynchronously every second or so, so that you’re getting results back quickly in the background. In reality this can be clunky if your network is slow, or the directory is very big.

I wanted something simpler, and a gui that gave me was suited to my work requirements. Lookup displays glance-able contact details straight away, letting you copy, paste and drag this data around. It also has simple shortcuts like double clicking the contact to start a new email to that person.

Lookup does not poll asynchronously, it does one request per search and just looks through some key attributes. It seems to work very well, and has been customised for my workplace, but is generic enough for someone to tweak it to suit their companies needs.

Lookup

It wraps ldapsearch, which is a command line app that comes free on your mac. When I say wraps, it’s not a complete wrapper, but wraps enough to create an app of this kind. Ldapsearch app did everything I wanted in search terms, and gave me a chance to use NSTask and NSPipe which I know will be useful in the future.

You can get the source over at Github. Why not try and tweak it to work for your company. You never know, just compiling it and updating the settings in the preferences menu may be enough.

Just to be clear, this app does NOT give you access to the BBC address book, just incase you thought I’d gone mad.

TellyBox 1.4, Twitter, Scheduling .. plus the coolest icon

posted by Duncan at 3:35 pm on March 22nd, 2009

[note] if you are updating and have the current app in your dock, you may need to remove it, and then re-add it again to get the new icon to appear straight away

I’ve just released a new version of TellyBox, version 1.4. This version pulls in all the new features from sister app RadioAunty, plus a few news ones specific to TellyBox.

If you didn’t know, TellyBox is a Mac app that allows you to watch live and catchup BBC Television (Uk users only I’m afraid). It uses the BBC iPlayer to actually display the telly, but wraps it all up into a native Mac application.

TellyApp screenshot

Like I mentioned above, new features include Twitter support and scheduling as per RadioAunty. I recommend reading this post to get more information on these. As well as them, the new features specific to TellyBox are:

  1. I have removed the default channel entry from the preferences. The app now just remembers what channel you last watched.
  2. The close button, and zoom buttons (red and green) now work.
  3. A brand new app icon (designed by David Wilson)

I’m really pleased with the icon. I know David spent a lot of time designing it, and for a first application icon, I think it’s awesome. I also knew the effect I wanted. I really liked the idea of the icon being a mini telly showing you exactly what you are watching in the main screen. It seems Mac icons can make or break an app, so I’m hoping this one can only help.

It’s actually quite a simple effect to achieve. It’s just about building layers. I use CGWindowListCreateImage to take a screen grab of what’s playing over time. When I have a new grab, I then construct the dock icon, using the grab at the bottom, then a version of the app icon with a transparent screen to give the glass effect, and finally the channel logo. If you minimize the app, or change windows using spaces, then the icon will change to the BBC test card.

Download TellyBox from the project page on Github, or if you already have the app installed, then you should get a request to update automagically.

RadioAunty feature update – twitter, scheduling and much more

posted by Duncan at 7:50 pm on March 14th, 2009

In my on going Cocoa learning I have been working hard on updates for RadioAunty. ( If you didn’t know, RadioAunty is Mac app that allows you to listen to live and catchup BBC Radio ). This means the feature list is now quite compelling, so I decided to give and overview of the features to date.

1. Select your Favourite Station – Choose from all the BBC National radio stations. You can listen to them in Normal RealPlayer or the much higher quality ACC streams. Make your decision via the preferences screen.

RadioAunty select a Station

2. Minimise the radio – I didn’t think people generally stare at the player whilst they are listening, so you can now minimise it like you can with iTunes, using ^ cmd Z or the window menu. You can also tweak the width whilst minimised. You will also see that the window title shows the current show playing. This updates along with the schedule as time goes on. More on this next.

RadioAunty minimized

3. View the schedule – In the Schedule menu, you will see the day schedule for the station you are listening to (using data from BBC programmes). You will see a tick next to the show you are currently listening. You will also see that some shows are clickable. This is stuff you can listen to, that is available to catchup in iPlayer, it also displays how long left that show is available in iPlayer for. This schedule updates as you listen throughout the day.

RadioAunty schedule menu

4. Twitter support and other preferences – The preferences window gives you the chance to change some of RadioAunty’s settings and turn on others. From the top, we have updates. Turning this on allows you to receive updates to the application when they become available. Next is default station. This allows you to choose a default station to open with (I think this may be removed next release, and the app will just remember what you last listened to. Next is audio quality. It’s best to stick to high quality, but those streams are only available in the UK, so if you are listening abroad you will have to choose normal quality. Finally Twitter support. Opting in means that as you listen, details about what you are listening to will be sent to the @radioandtvbot account on Twitter. If you supply your twitter username, this will be added to the tweet instead of the default, which is your computer login FullName. The screenshot below next shows you what gets sent.

RadioAunty twitter support
radioandtvbot

5. A nice dynamic app icon – The wonderful Tim Broom made the current icon. The icon changes, showing the network you are currently listening to.

Nice Icon

6. Growl support – If you use Growl, then RadioAunty will notify you when a show starts playing. If you choose the twitter support it will also notify you when this information is sent to twitter.

Growl Support

Next then. I’m going to be transferring the twitter and scheduling stuff over to TellyBox (A Mac app that allows you to watch live and catchup BBC Television). So watch out for the updates. Then I think lastfm integration is on the cards. It’s be nice to scrobble what tracks you are listening to.

Replicating Apples embossed text in a Cocoa App

posted by Duncan at 11:22 am on March 11th, 2009

[update] Thanks to the chaps below in the comments, my in-experience with cocoa is shown. This whole post could be replaced with this code:

 [[myTextField cell] setBackgroundStyle:NSBackgroundStyleRaised];

If you look at the text in the task or status bar on of a Mac app, you will see that the text has the appearance of being embossed slightly. It is essentially a textField with some neat attributes associated with it.

Apple embossed text

This effect does not come for free when you want to use your own NSTextField somewhere else in your Apps window (actually, I think it does on the iPhone?). To recreate this effect is quite simple. You just need to create a NSAttibutedString and associate the attributes below to it.

// Create the white shadow that sits behind the text
NSShadow *shadow = [[NSShadow alloc] init];
[shadow setShadowColor:[NSColor colorWithDeviceWhite:1.0 alpha:0.5]];
[shadow setShadowOffset:NSMakeSize(1.0, -1.1)];
// Create the attributes dictionary, you can change the font size
// to whatever is useful to you
NSMutableDictionary *sAttribs = [[[NSMutableDictionary alloc] initWithObjectsAndKeys:
    [NSFont systemFontOfSize:11.0],NSFontAttributeName,
    shadow, NSShadowAttributeName,
    nil] autorelease];
// The shadow object has been assigned to the dictionary, so release
[shadow release];
// Create a new attributed string with your attributes dictionary attached
NSAttributedString *s = [[NSAttributedString alloc] initWithString:@"82 results found"
    attributes:sAttribs];
// Set your text value
[myTextField setAttributedStringValue:s];
// Clean up
[s release];

I’m sure there are many other ways to achieve this effect, and I’d be interested in any easier versions, but this works for me.

Experiments in Cocoa #1 RadioAunty

posted by Duncan at 9:47 pm on December 12th, 2008

[UPDATE] I’ve updated the app to now use the new higher quality live streams. Yay, no more RealPlayer for the majority.

I’ve seem to have spent a lot of time reading about Cocoa without actually building anything of substance. So to put a change to that I have built RadioAunty.

1. RadioAunty – This is a Cocoa Application that lets you listen to the radio, BBC radio, on your desktop. You can view the current schedule and select listen again shows, as well as simply changing the station via the menu bar and via the Dock. You can also set preferences to decide which should be your default Station to start with, and whether you would like to receive updates to the application when they are available (very important). If you have listened to BBC radio via Safari, then RadioAunty should work just fine for you.

Download RadioAunty from it’s project site

RadioAunty

There are now many *.frameworks that come as part of the Apple Developer Tools and I found it pretty daunting to start with. So to make life easier for myself, I decided to start small and build bigger as I go along. This is why I started with the simple idea of RadioAunty. Oh and it’s Leopard only because it seemed silly to have to learn old ways of doing things as well as new.

RadioAunty is at a high level not that complex. It basically embeds an already existing webpage into a desktop app. It seemed like an ideal starting point. Once I had got that working (Thanks Apple, it takes about 3 lines of code!), the next thing was to make use of other classes and functionality to actually learn something. The app as it stands uses only uses these Cocoa classes (I’ve left the boring ones out):

I’ve used @property quite a lot (properties are a bit like Ruby :attr_accessor) to automagically create getter and setters. I have also use key-value bindings, which once I understood them were amazing, and allow you to chop huge chunks of code from your source. I use a stations.plist to store the radio station data, but hope to pull that from the web in the future, meaning that it could play any radio station and not just the BBC’s. I also use delegation a lot whenever I can.

As I only started the app on Tuesday, I’ll continue making it more polished, that and I have a few other ideas, but I wanted to get something out for people to use as quickly as possible, so first main thing to add (apart from the radio) was auto-updating. This is taken care of by Sparkle 1.5b6.

Sparkle was super simple to implement. Their wiki documentation worked great, and I was amazed that something I always think is cool, and take for granted was so smooth to implement in this application. If you’re building OSX applications then this should surely be a must.

I have a few other projects in the pipeline, that incorporate more frameworks for me to learn, so stay posted. I’m progressing well with is an app called LeaveFrom, that does what is says on the tin really. It uses Core-Data which again had a bit of a learning curve, but I’m getting on ok. Can my old brain take all this new fun information.


back to the top