RE: Getting started with WebKit plugins
RE: Getting started with WebKit plugins
- Subject: RE: Getting started with WebKit plugins
- From: "Rudi Sherry" <email@hidden>
- Date: Tue, 10 Jan 2006 08:29:07 -0800
- Thread-topic: Getting started with WebKit plugins
Hi Chris,
WebKit Plugins are not Cocoa Applications -- they are plugins. Having
an extension as "plugin", and residing in one of the several "Internet
Plug-ins" directory, is sufficient for Safari knowing that it is a
plug-in.
I've developed quite a few plug-ins using the PluginMovieView as a
"starter kit". The things you want to change include:
* the extensions and mime types in the info.plist file. These
extensions and mime types identify the content, sent from the server,
that your plug-in will handle. Safari will instantiate your plug-in and
call the methods (documented in the WebKit documentation) when it gets
content of that type.
* the NSPrincipalClass value in info.plist. This should match the
objective-C className of the WebPlugIn subclass; currently it's
PlugInMovieView in the sample. Once Safari loads your plug-in (because
it matched incoming mime type to your info.plist setting), it
instantiates an object of this type and starts calling the methods as
described in the documentation.
Hope this helps,
Rudi
-----Original Message-----
From: cocoa-dev-bounces+rsherry=email@hidden
[mailto:cocoa-dev-
Date: Mon, 9 Jan 2006 20:03:32 -0800
From: Christopher Drum <email@hidden>
Subject: Getting started with WebKit plugins
To: email@hidden
So I'm going through the Apple docs about making WebKit plugins, and
I'm lost. The documentation in "Web Kit Plug-In Programming Topics"
feels anemic, with many glaring omissions. For example, in going
through the "PlugInMovieView" example project file, it seems to have
not started it's life as a Cocoa Application. It contains no .nib
file and no main.m (as I would expect, I think...). The documentation
gives no indication on how to start a WebKit plugin project, nor is
there an Xcode template to begin one (a major glaring omission,
methinks).
Additional, using the inspector on the target for the example project
shows settings that would not be immediately obvious to a newbie
plugin developer, yet the documentation makes no mention of having
changed some of these things. Nor does the example project explain
the alternations made to the Info.plist file for registering MIME types.
Anyway, all of this leads to the basic question of: How does one
start and end a plugin project? Once started, I get the gist of the
matter, and I've successfully gotten Javascript to talk to Objective-
C and back again through an embedded WebView in a sample Cocoa app.
So, that part of the coding I get (for now). After the coding is
done, what steps need to be taken to ensure the project builds out
properly into the correct filetype. Is a plugin simply a Cocoa
application that ends in ".plugin", or is it something more than that?
When Safari browses a website that needs access to my new plugin,
does the HTML for the webpage have to ask for something specific of
the webpage, or can (for example) the Javascript in the webpage
simply assume access to the plugin's methods are already available?
In my test app, I simply dragged a WebView into my .nib file, had it
load a sample .html file off my desktop and it immediately started
using my Cocoa methods through Javascript. Will .html files in
Safari, using my custom plugin, function likewise or does I need to
modify the .html file in some way to let it know about the plugin's
existence?
Thanks in advance for any help anyone can offer on this matter.
Christopher Drum
http://homepage.mac.com/christopherdrum
------------------------------
Message: 9
Date: Mon, 09 Jan 2006 20:11:22 -0800
From: "Martin" <email@hidden>
Subject: Re: Crash in _blinkCaretTimerAction (NSTextView)
To: "Douglas Davidson" <email@hidden>
Cc: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset="UTF-8"
Douglas,
>> Is there anything more specific I might need to know? For instance,
which
>> text view is responsible for the invalidation?
>
> Actually, to be more specific, the timer is invalidated when the
> NSTextViewSharedData is deallocated, which happens when all of the
text
> views for a given layout manager have been deallocated.
I've continued debugging with this new information, but I still don't
see what could be going wrong. I've posedAs NSTextViewSharedData and
overridden _fixSharedData to view the sequence of events. Here is what I
see:
I. The NSLayoutManager deallocates and releases all of its
NSTextContainers.
A. Each NSTextContainer deallocates.
1. The container nils the container on its NSTextView.
a. The NSTextView autoreleases its original
shared data (call it "A").
b. A new shared data instance (call it "B") is
assigned to the NSTextView.
2. The container releases its NSTextView causing it to
deallocate.
a. The new shared data "B" is released and
deallocates.
II. An autorelease pool is popped and the original shared data "A" is
deallocated.
III. Timer fires.
B. _blinkCaretTimerAction tries to access an NSTextView
deallocated in step 2 above.
If I understand this interaction correctly, the timers should all be
invalid. The original shared data for the NSLayoutManager is deallocated
in step II, while each temporary shared data is deallocated ASAP in step
2.a.
Is there any other line of investigation that you think I should follow?
Thanks again,
~Martin
------------------------------
Message: 10
Date: Mon, 09 Jan 2006 22:56:03 -0800
From: Greg Herlihy <email@hidden>
Subject: Re: Checkbox, Dictionary, Bindings
To: Chris Outwin <email@hidden>, <email@hidden>
Message-ID: <BFE89A83.5A52%email@hidden>
Content-Type: text/plain; charset="US-ASCII"
NSNumbers may be immutable, but they are not irreplaceable.
To check or uncheck the checkbox simply replace the NSNumber currently
representing its checked state with a different NSNumber whose value
represents the checkbox's updated state.
Greg
On 1/9/06 3:18 PM, "Chris Outwin" <email@hidden> wrote:
> I would like to manage a checkbox via a dictionary and bindings. The
> problem is NSNumber and NSValue are immutable, and I can't find
> another class to represent the changing on/off state of the
> checkbox. What class can I use?
>
> NSDictionary* _properties;
>
> NSArray* values = [NSArray arrayWithObjects:[What Class?], //
> scalesImage
> nil];
>
> NSArray* keys = [NSArray arrayWithObjects:@"scalesImage"
>
> _properties = [[NSDictionary alloc] initWithObjects:values
> forKeys:keys];
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
------------------------------
Message: 11
Date: Mon, 9 Jan 2006 23:24:09 -0800 (PST)
From: Jordan Evans <email@hidden>
Subject: Re: Radix Class
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=iso-8859-1
--- Alberto Ricart <email@hidden> wrote:
> 1) It is very weird to see struct's used in OO.
> You should create another object to represent your
> RadixSet. If you
> make the instance variables public, then from within
> your code you
> can do foo->something to access them. True OO would
> not do this (as
> you are breaking encapsulation), and would instead
> call accessor
> methods. Unless you are writing high-performance
> code that requires
> the optimization.
I made the struct so the class was more stand alone.
One benefit is the loss of overhead through messaging.
But I"m not sure if this is really happened. I
haven'd done a performance test. I'll definitely set
one of up in the near future.
> 2) It seems that you are caching values like the
> count (numOfSets)
> that are managed (or should be managed in a
> collection, so you don't
> keep track of that kind of stuff, as the collection
> would do it for
> you). I would rewrite to use the collections more
> fully.
I wrote it that way at first, but I found using a
value returned from a message as a condition in a loop
created unneccessary message overhead. Each time the
loop increments the message is called just to get a
value that could be cached.
> 3) #2 is even stronger when you realize that you are
> given an array
> (so you use a collection to pass them around, but
> then revert to
> unroll it into your own data structure. Why?
I'm not sure I see unrolling of data, except in the
case of the struct being assinged values that are
queried form NSArrays. Again, those values I think
are better cached rather than messaged each time. The
element is my struct is just a highlighted object in
an NSArray, but NSArray has no function to mark a
given object, so element provides a service in the
struct, NSArray can't provide. I'd like to think of
these structs used as a data extension of NSArray,
although some data is mere cached copies.
> 4) You would probably never reInitWithXXX, instead
> you simply alloc
> and init a new Radix. If you are doing object
> pooling, then the
> correct thing to do is to have a setter method like
> setArrayOfSets:
> (NSArray*) to assign a new collection to your
> object.
I thought about this. I was thinking in terms of
immutabiity and mutability and couldn't classify Radix
that way. I sure wish something would break through
that would make me see it. I put in -reInitWith: in
the case when the old source initialized in Radix was
no longer neccessary, but a new source needed Radix's
special abilities.
The old source isn't owned by Radix, rather it has an
aquaintance with no memory ties (just data
connections). If the aquaintance is neccessary, and a
new source comes on to the scene, it's more than an
aquaitance and it's aquaintance should not be ended
with reInitWith. In the case of a strong aquaintance,
a new Radix should then be created.
I'm not sure what pooling means in the context you
used it, so I can't comment.
> 5) zeroElements would be clear or something like
> this. If you
> delegate the set management to an NSArray, you
> simply remove all
> objects and be done, this would also remove many of
> the malloc/frees
I'm not so sure this would be optimal for this class
that may need to perform very quickly as sensitive
times, but I may have misinterpreted what you have
meant.
I'm new to this, so please point out where I may have
gone wrong.
Thanks for your input Alberto.
__________________________________________
Yahoo! DSL - Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
------------------------------
Message: 12
Date: Tue, 10 Jan 2006 20:31:30 +1300
From: David Wilson <email@hidden>
Subject: Re: Screen saver with a configure sheet?
To: patrick <email@hidden>
Cc: cocoadev <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes;
format=flowed
Hi Patrick...
My Screen Saver (see http://www.versiontracker.com/dyn/moreinfo/
macosx/26020 ) has the code implemented as below.
It's a big configure sheet for a screen saver...
Hope this helps. Feel free to contact me and I'll try to be of more
assistance.
- David
- (BOOL)hasConfigureSheet
{
return YES;
}
- (NSWindow*)configureSheet
{
if (configureSheet == nil)
[NSBundle loadNibNamed:@"ConfigureSheet.nib" owner:self];
configW = configureSheet;
return configW;
}
- (IBAction)closeSheetOK:(id)sender
{
//text deleted. Add code here if you need special handling after
the
sheet closes
// close sheet
[NSApp endSheet:configureSheet];
return;
}
On 10/01/2006, at 11:44 AM, patrick wrote:
> I'm making a screen saver with a configure sheet, and I'm having
> trouble understanding how I can create a connection between the sheet
> and my screen saver class.
>
> In my screen saver's header file, I have:
>
> IBOutlet id *configureSheet;
>
> I've created a NIB with the panel, but since the ScreenSaverEngine
> creates the instance of my screen saver view, it doesn't seem like I
> would create an instance of the screen saver view in my NIB.
>
> The only tutorial I could find about making a screen saver with a
> configure sheet didn't explain this part, and just provided a NIB that
> somehow already has the connection in it.
>
> Any pointers would be greatly appreciated.
>
> Thanks,
>
> Patrick
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40paradise.net.nz
>
> This email sent to email@hidden
>
------------------------------
Message: 13
Date: Tue, 10 Jan 2006 02:02:24 -0600
From: Daniel Griffin <email@hidden>
Subject: creating custom widgets(?)
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
Hi all,
First time poster, short time reader. To start with I am not
sure if
I am using the right terminology. I am attempting to create a button
that contains 2 images and some text for a simple instant messenger.
I am not sure how I should go about this. I am new to cocoa and new
to gui's overall. Do i subclass NSView? subclass something else? Is
there a way to add what I want to NSButton? I have looked but I dont
know if I am looking in the right place.
Thank you in advance
Daniel Griffin
------------------------------
Message: 14
Date: Tue, 10 Jan 2006 00:02:23 -0800
From: "Frederick C. Lee" <email@hidden>
Subject: Unable to Load Window NIB
To: Cocoa Developers <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes;
format=flowed
Does anyone know why I can't load a NIB file?
The MainMenu.nib loads without hassle.
I've been loading NSWindowControllers in other projects but this one
escapes me.
Ric.
Running XCode 2.2
IB for OS X 10.2+
Runtime Error:
2006-01-09 23:44:12.229 Global Village[883] -[GVWindowController
loadWindow]: failed to load window nib file 'GVWindowController'.
Inside AppDelegate:
...
- (IBAction)loadGVWindowController:(id)sender {
NSLog(@"{loadGVWindowController}");
if (!gvWindowController) {
[self setGVWindowController:[[GVWindowController alloc] init]];
[[self gvWindowController] showWindow:self];
}
}
...
-------------------------------------------------------------
@interface GVWindowController : NSWindowController {
...
}
...
@implementation GVWindowController
#pragma mark Initialization
- (id)init {
return [super initWithWindowNibName:@"GVWindowController"];
}
//
------------------------------------------------------------------------
---------------------------------
- (void)awakeFromNib {
[[self window] center];
[[self window] makeKeyWindow];
}
...
------------------------------
Message: 15
Date: Tue, 10 Jan 2006 03:33:47 -0500
From: Cameron Hayne <email@hidden>
Subject: Re: Crash in _blinkCaretTimerAction (NSTextView)
To: Martin <email@hidden>
Cc: CocoaDev list <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
On 9-Jan-06, at 11:11 PM, Martin wrote:
> If I understand this interaction correctly, the timers should all
> be invalid
You could perhaps check in the debugger if the timers are in fact
invalid (via the 'isValid' method)
--
Cameron Hayne
email@hidden
------------------------------
Message: 16
Date: Tue, 10 Jan 2006 09:55:55 +0100
From: Damien Bobillot <email@hidden>
Subject: Re: Guarding against missing ObjC implementation
To: Daniel Jalkut <email@hidden>
Cc: Cocoa-Dev List <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
Daniel Jalkut wrote :
> One of the nicest features and worst pitfalls of Objective-C
> programming is the dynamic messaging nature of the language.
>
> In the "pitfall" category is a problem I run into from time to time
> where a project possesses the required header file for a particular
> category, but somehow the source file corresponding to that header
> has been omitted from the project.
>
> When this happens, the compile triggers no warning: you don't get
> "incomplete class" warnings when a category's methods are not
> fulfilled at compile/link time.
>
> I'd like to guard against this problem biting me in the future, and
> I'd like your feedback. What is the best approach?
The approach I personally use is to create a protocol describing what
methods must be implemented for a given functionality :
@protocol MyProto
- (void) revealInFinder;
- (void) openFileInFinder;
@end
Then, you may check if an object implementes all methods of this
protocol :
id object;
if([object conformsToProtocol:@protocol(MyProto)]) {
...
--
Damien Bobillot
> One approach would be to add unit tests for every category. I put
> something like this in one of my test suites as a practical
> experiment:
>
> ------------------------
> #define RequireClassMethod(myClass, mySel) \
> do { \
> NSString* description = [NSString
stringWithFormat:@"Check for %@
> in %@", NSStringFromSelector(mySel), NSStringFromClass([myClass
> class])]; \
> STAssertTrue([myClass instancesRespondToSelector:mySel],
> description); \
> } while (0)
>
> - (void) testRequiredMethodsPresence
> {
> // NSString+FileUtils
> RequireClassMethod(NSString, @selector(revealInFinder));
> RequireClassMethod(NSString, @selector(openFileInFinder));
> }
> ------------------------
>
> This does the trick, but adding explicit tests for every method
> implemented by a category seems overly laborious.
------------------------------
Message: 17
Date: Tue, 10 Jan 2006 09:59:47 +0100
From: j o a r <email@hidden>
Subject: Re: Unable to Load Window NIB
To: "Frederick C. Lee" <email@hidden>
Cc: Cocoa Developers <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset="us-ascii"
On 10 jan 2006, at 09.02, Frederick C. Lee wrote:
> Does anyone know why I can't load a NIB file?
> The MainMenu.nib loads without hassle.
> I've been loading NSWindowControllers in other projects but this
> one escapes me.
Have you verified that the nib file is being copied over to the built
application?
> if (!gvWindowController) {
> [self setGVWindowController:[[GVWindowController alloc]
> init]];
This seems like a potential memory leak. It is the responsibility of
the setter method to retain it's argument, and you should therefore
pass the object autoreleased.
j o a r
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2380 bytes
Desc: not available
Url :
http://lists.apple.com/pipermail/cocoa-dev/attachments/20060110/fa7f0faf
/smime.bin
------------------------------
_______________________________________________
Cocoa-dev mailing list
email@hidden
http://lists.apple.com/mailman/listinfo/cocoa-dev
End of Cocoa-dev Digest, Vol 3, Issue 41
****************************************
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden