Quicksilver Plugin Tutorial – Basic Tutorial (Draft)

This page is an archived version of http://quicksilver.infogami.com/ObjectiveCPlugInsBasicTutorial

Quicksilver

Basic Tutorial (Draft)

 

Introduction

A brief tutorial showing the creation, installation, and running of a Quicksilver plug-in (Objective-C) implementing a simple action.

Set-up

Ensure a development version of Quicksilver is installed (I put mine under ~/Applications/).

Ensure Developer Tools is installed (I’ve got whichever one gives me Xcode 2.4).

Follow the plug-in template installation instructions (Note that there is an important step involving telling Xcode where certain Quicksilver frameworks live – hint: they live inside the development version of Quicksilver which should now be installed.).

Implementation

Launch Xcode if it’s not already launched.

From the Assistant (or File -> New Project), choose to create a ‘Quicksilver Plug-in’ (You’ll likely choose a location for your project and a name — I’m going to use ‘MyPlugIn’ as a name for this tutorial).

Edit Info.plist to make the content as follows (A plug-in’s Info.plist allows a plug-in to communicate details about itself to Quicksilver (e.g. whether the plug-in provides an action)):

< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>MyPlugIn</string>
    <key>CFBundleIdentifier</key>
    <string>com.blacktree.Quicksilver.MyPlugIn</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>MyPlugIn</string>
    <key>CFBundlePackageType</key>
    <string>BNDL</string>
    <key>CFBundleVersion</key>
    <string>1A</string>
    <key>QSActions</key>
    </dict><dict>
        <key>MyPlugInAction</key>
        </dict><dict>
            <key>actionClass</key>
            <string>MyPlugInActionProvider</string>
            <key>actionSelector</key>
            <string>performMyAction:</string>
            <key>directTypes</key>
            <array>
                <string>NSStringPboardType</string>
            </array>
            <key>name</key>
            <string>My Action</string>
        </dict>

    <key>QSPlugIn</key>
    <dict>
        <key>author</key>
        <string>An Author</string>
    </dict>
    <key>QSRegistration</key>
    <dict>
        <key>QSActionProviders</key>
        </dict><dict>
            <key>MyPlugInActionProvider</key>
            <string>MyPlugInActionProvider</string>
        </dict>


</plist>

Edit MyPlugIn.h to make the content:

//
//  MyPlugIn.h
//  MyPlugIn
//

#import <qscore /QSObject.h>

@interface MyPlugInActionProvider : NSObject
{
}
@end

Edit MyPlugIn.m to make the content:

//
//  MyPlugIn.m
//  MyPlugIn
//

#import "MyPlugIn.h"

#import </qscore><qscore /QSNotifyMediator.h>
#import </qscore><qscore /QSTypes.h>
#import <corefoundation /CoreFoundation.h>

@implementation MyPlugInActionProvider

- (QSObject *) performMyAction:(QSObject *)dObject
{
    NSString *text = [dObject objectForType:QSTextType];
    NSAssert1(text, @"Error: failed to obtain string from: %@", dObject);
    NSDictionary *attributes = \
        [NSDictionary dictionaryWithObjectsAndKeys:@"My Action", QSNotifierTitle, 
                                                   text, QSNotifierText, nil];
    NSAssert(attributes, @"Error: failed to create dictionary for notification");
    QSShowNotifierWithAttributes(attributes);

    return nil;
}

@end

Save your changes.

Build (this should result in the creation of ‘MyPlugIn.qsplugin’).

Installation

Double-click MyPlugIn.qsplugin to initiate plug-in installation.

Answer appropriately when asked by Quicksilver about installing (Plug-ins are installed under ~/Library/Application Support/Quicksilver/).

Testing/Running

Ensure Quicksilver is running.

Activate Quicksilver.

Enter text entry mode (hint: use the period key).

Type some text (how about ‘Would you like to play a green vegetable?’ ?)

Choose ‘My Action’ as the action.

Press the return key.

If all went well, you should be notified by Quicksilver of the text you entered via text entry mode (If not, time to check out Console.app).

References

Related Posts:

  • No Related Posts
This entry was posted in Software and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *