Vvidget Code > Programming > Plug-in > Tutorial
This tutorial shows how to use Vvidget Code without the appearance of a user interface. The particular usage is a QuickLook Plug-in, however the same methodology applies to any other similar need.
The basic steps for such a situation, which are elaborated on in later sections, are as follows:
Step | Description |
Prerequisites | You will have to install the Apple Xcode developer tools and the appropriate Vvidget packages. Both can be downloaded online if you do not already have them. |
New Project | Launch Xcode, located on your computer at /Developer/Applications/Xcode, and make a new Plug-in project. |
Vvidget Capability | Xcode does not come with Vvidget capability so you will have to explicitly add it to your application. Adding the capability is a matter of properly referencing the Vvidget Frameworks (libraries). |
Source Code | Add the source code as described below. The source code includes Vvidget API references, so you need to add the Vvidget capability first as was done in the previous step. |
Build And Install | Installing is simply a matter of dragging the build result to a particular destination. |
Refining | Your plug-in is simply a handful of code. The code you write results in the functionality you desire. |
The following describes the steps above in greater detail.
Prerequisites
Download and install Xcode. If you have not done this before then click: http://developer.apple.com/devcenter/mac to get started or insert the Mac OS X install disk into your computer, locate the Xcode package and install. If you are updating Xcode then I suggest that you uninstall it first (see its notes), reboot, install the new version and then reboot.
If you have not already done so, go to http://www.vvidget.org/download and download and install the Vvidget Code package. For completeness sake, you should logout and then login to your home account. That is because there are some Vvidget components used in development that are based on services, whereas an end user application such as Vvidget Builder or an application you write does not have that issue. In any event a logout and in or a reboot is a nicety of the development environment and may not be needed.
Make A New Project
Launch Xcode, located on your computer at /Developer/Applications/Xcode, and in its main menu click File > New Project .... and then from the New Project panel select the System Plug-in > Quick Look Plug-In template.
Add Vvidget Capability
Xcode does not come with Vvidget capability so you will have to explicitly add it to your application. Adding the capability is a matter of properly referencing the Vvidget Frameworks (libraries). In your project, click the "External Frameworks and Libraries" Group and then click the menu item Project > Add to Project ... From there, navigate to the /Library/Frameworks directory click on the VvidgetCode.framework and then click the Add button. In the resulting panel note that the target for your project is checked and then click the Add button. Your project now has Vvidget Capability. This step contrasts sharply with that in the Cocoa Programming Tutorial where the Vvidget Embedded Frameworks are used. Because the non-embedded framework form is being used in this tutorial, you need to make sure that Vvidget User is installed on your computer as well as other computers that you intend to run your plug-in on. Note that you can also write a Cocoa Application with the non-embedded frameworks as well and that is certainly a legitimate use.
Source Code
In this step you will add Vvidget processing. Click on the GeneratePreviewForURL.m file and add the following to include Vvidget Code definitions:
#include <VvidgetCode/VvidgetCode.h>
|
then paste the following code into its GeneratePreviewForURL() function.
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
|
Do a similar thing to add other needed functionality, for example to add Thumbnail processing.
There are a few interesting things to note in the code:
Build And Install
Next click the Build button and then drag the resulting plug-in to the /Library/QuickLook directory. There is a slight problem with Xcode version 3.2.1 (the one used for this tutorial): The "Build and Run" button is disabled so it appears that you can not build the plug-in. To remedy this, click the menu item Build > Build, or enter the Build icon into the toolbar of Xcode and click that. Xcode is smart enough to know it can not run the plug-in, but not so smart that it changes the "Build and Run" button to a simple "Build" button; a minor detail.
Refining
The plug-in is straight forward and there is not much refining to do but perhaps these are some suggestions:
• | Unlike the Cocoa Programming Tutorial, this tutorial uses the Vvidget Server, a separate process, to handle the graphics processing. This allows for some nice features: The plug-in is small, it does not require graphics processing and it minimizes the amount of symbols imported into the process the plug-in is loaded into. This is not a requirement however and the plug-in can be made to process within its own process space by following the Add Vvidget Capability section in the Cocoa Programming Tutorial. Conversely, a Cocoa application can be made to operate like the plug-in of this tutorial by following the Add Vvidget Capability of this tutorial instead of what is presented in the Cocoa Tutorial. |
• | You can add a lot more functionality to the plug-in but that is beyond the scope of this tutorial. You can also add this same exact code to a simple unix command line tool to implement Vvidget processing without the embellishments of a user interface. |
• | You can download and read about the plug-in project described in this tutorial at the Line Graph QuickLook section. |
Conclusion
By following the few steps above you can create a plug-in or any other program that retrieves a Vvidget Code result. Once you have the result, in the form of an image or other export type, then you can insert that into other processes or systems that take that type of result as input. The QuickLook plug-in is a natural for this type of use, however there are many other situations that are equally if not more applicable.
Please help improve this documentation. If a section is hard to understand, there is a typo, you would like a new section added, or you detect any other improvement that can be made then please email support@vvi.com with your information. |