Difference between revisions of "Development:Third-Party Preference Panes"

From Camino Wiki
Jump to navigation Jump to search
(more revisions per smorgan)
(remove Copy Headers bit, since we don't want to encourage use of anything outside PPB, and that ships in the sample)
Line 49: Line 49:
  
 
If you have multiple copies of Camino, point it to the oldest one you plan to support with your preference pane.
 
If you have multiple copies of Camino, point it to the oldest one you plan to support with your preference pane.
 
You'll also need to copy over any Camino header files for methods you're using in your preference pane. You can add them to the Copy Headers phase of the project, like this:
 
 
[[Image:Adding-files.png]]
 
  
 
That's it! You should be able to build the project and test your preference pane with Camino. Remember to re-launch Camino after placing the preference pane in <code>[~]/Library/Application Suppport/Camino/PreferencePanes/</code>.
 
That's it! You should be able to build the project and test your preference pane with Camino. Remember to re-launch Camino after placing the preference pane in <code>[~]/Library/Application Suppport/Camino/PreferencePanes/</code>.

Revision as of 18:30, 28 January 2008

DRAFT
This page is not complete.

See Bug 384800 for more information on the status of this page. The current how-to should not be attempted by people unfamiliar with Xcode and its related tools or the Camino codebase.

Who should read this document?

Camino, per our mission statement, "is an open source web browser developed with a focus on providing the best possible experience for Mac OS X users." This, along with the limited time available for our all-volunteer programming team to implement features, means that certain choices have to be made about what should and shouldn't be part of the Camino application itself. As with Firefox extensions, there are many opportunities for third-party developers to step in and provide niche features or UI for things that Camino doesn't provide by default. This document is intended to provide a jumping-off point for third-party developers interested in developing additional preference panes for Camino.

Getting started

These instructions assume a basic working knowledge of Apple's Developer Tools, including Xcode and Interface Builder, as well as the Objective-C language itself. If you are unfamiliar with these, Apple Developer Connection is an excellent place to start learning. You'll also want to be familiar with the basics of preference pane development, for which Apple has provided an excellent tutorial as well.

Applicability and support

These instructions can be used by anyone developing preference panes on Mac OS X 10.4 or higher, with Xcode 2.4.x or higher and Interface Builder 2.x or higher, to be deployed on any version of Camino from 1.5 onward. Developers may choose to support only Mac OS X 10.4+ or Camino 2.0pre+, but this is highly discouraged unless certain limitations of the Mac OS or Camino/Gecko code make supporting Mac OS X 10.3.9 or the Camino 1.5 branch impossible.

Disclaimer

These instructions are presented in good faith, but we cannot guarantee preference panes developed using this guide will not set your cat -- or your users' cats, or both -- on fire.

We do make every effort to ensure the compatibility and stability of methods in PreferencePaneBase.

Creating the Xcode project

In Xcode's New Project Assistant (see below), scroll down and expand the "Standard Apple Plug-ins" group and select "PreferencePane", then click Next and continue through the Assistant.

Error creating thumbnail: Unable to save thumbnail to destination

Camino's preference panes are standard Apple PreferencePanes with a small twist: their creator code is MOZC (Camino's creator code) instead of the default ????. Go to Xcode's Project menu and select "Edit Active Target", which will bring up the Target Info window. Click on the Properties tab and you'll be able to change the creator code, as seen in the screenshot below:

Error creating thumbnail: Unable to save thumbnail to destination


We've put together a [CBSamplePane.zip sample Xcode project] (download size) for developers to use when writing preference panes for Camino. Feel free to use this project as a starting point, or make your own.

If you use the provided project, make sure you change your preference pane's bundle identifier from org.mozilla.caminoprefpane, as bundle ID conflicts can prevent your pane from loading. Bundle identifiers generally take the form of tld.developer.productname, so your preference pane might be com.johndoe.awesomeprefs, for example.

You should also ensure that your classes have unique names, as class name conflicts can also be a problem. Continuing with the above example, your preference pane's class would be ComJohndoeAwesomeprefs.

Laying out the UI

In order to keep the UI of your preference panes as consistent as possible with the preference panes shipped with Camino itself, please use our Nib Editing Guide as a reference for laying out the UI when developing preference panes for Camino.

Using Camino methods

If you plan to use any of Camino's methods directly, your preference pane should subclass Camino's PreferencePaneBase class (which is, in turn, a subclass of the standard AppKit NSPreferencePane class). Using Camino methods other than those defined in PreferencePaneBase is explicitly discouraged; other classes can and do change without notice and should not be relied on to be stable across Camino versions.

Logically, it follows that PreferencePaneBase.h is a required header if you decide to use any of its methods. If you plan to deploy your preference pane on Camino 1.5.x, you'll also need to compile PreferencePaneBase.mm (in the Compile Sources phase of the target). This step is unnecessary if you plan to deploy your preference pane only for Camino 1.6 or higher.

You'll also need to tell the linker where it can find a Camino application. Using the Target Info window, point the linker's "Bundle Loader" to a copy of Camino on your hard disk. For example, if Camino is in your Applications folder, it would look like this:

Error creating thumbnail: Unable to save thumbnail to destination

If you have multiple copies of Camino, point it to the oldest one you plan to support with your preference pane.

That's it! You should be able to build the project and test your preference pane with Camino. Remember to re-launch Camino after placing the preference pane in [~]/Library/Application Suppport/Camino/PreferencePanes/.

Using Gecko functions and methods

Calling Gecko functions directly from a third-party preference pane is somewhat more involved. You'll still need to link against the appropriate libraries, but rather than copying the headers, which is likely to be a big headache (there are a great number of interdependencies amongst Gecko's header files, and it's easy to miss one), you'll probably be better off adding appropriate paths to the HEADER_SEARCH_PATHS parameter in Xcode's Target Info window. [An example here would be great. -cl]

If there's something in Gecko you really need to use that simply doesn't have a Cocoa wrapper on it in Camino, please bring it to our attention. We may be willing to add wrapper code for it, since one architectural goal we have for Camino is to hide Gecko from our developers as much as possible.

Other potential gotchas and caveats

  • Anything with C++ code in it built by gcc 4 won't run on Mac OS versions prior to 10.3.9. If you need to deploy on 10.3.8 or lower, you'll need to select an earlier gcc version.