Bounce boot stack dock icon using C ++ (without using ObjectiveC)

Currently, Firefox does not bounce the download window in the dock when the download is complete , such as Safari, Chrome, and Camino.

If Firefox was written in Objective-C, you could easily add one line of Objective-C code to do this. However, it is not. Is there a way to call this Cocoa function from C ++ so that it can be added to Firefox for all Mac users?

+4
source share
2 answers

You can use the Carbon API CFNotificationCenterPostNotification. Carbon - Clean C.

Sample documentation and code here .

+3
source

What would I recommend, and I had to do this for the project I was working on, you can have several obj-C ++ files that provide both C / C ++ api and the obj-c internal code to run the document blinks.

Essentially, you are creating a standard C / C ++ header file. On the code side, you create a .m file or .mm file.

This would allow you to write obj-c a single insert of questions directly into the C / C ++ function, and since the header file is in simple C / C ++, this will not be a compiler error for .mm files. in project.

This, of course, involves compiling with a compiler (like GCC) that speaks both languages.

A simple and (verified) example of such an approach would be:

TriggerBounce.h

void TriggerBounce(char * filepath); 

TriggerBounce.m

 #import <Cocoa/Cocoa.h> void TriggerBounce(char * filepath) { NSString *pathToFile = [NSString stringWithCString:filepath encoding:NSUTF8StringEncoding]; [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.DownloadFileFinished" object:pathToFile]; } 
+4
source

All Articles