Re: Only one instance of a capplet should be allowed



On Tue, 2006-02-21 at 19:50 -0500, Havoc Pennington wrote:
> On Tue, 2006-02-21 at 21:44 +0100, Jaap A. Haitsma wrote:
<snip>
> Since arg parsing/handling is different for single-instance apps
> (certain kinds of arg don't make sense for instances after the first,
> such as --display) gtk could offer a gtk_init() alternative perhaps. The
> API would let an app register a "new instance" callback essentially,
> which would be called when the app is first launched, and also if it's
> launched again and forwarded to an existing instance.
> 
> Something like:
> 
> int
> new_launch_callback(int argc, char **argv)
> {
> 
> }
> 
> int main(int argc, char **argv)
> {
>   gtk_set_instance_handler(new_launch_callback);
> 
>   return gtk_invoke_instance(&argc, &argv);
> }
> 
> If the app is already running, then the callback is not invoked in this
> process but instead invoked again in the existing process. If the app is
> not already running, callback is invoked in the current process.

Yes, this is a very good idea, and allows the window to be focused or
refreshed, or whatever.

> There are a variety of complexities, but this is a pretty longstanding
> thing nobody has ever fixed... every app is hand-rolling some wacky
> solution.

A generic solution would be the best way. I really don't want to invent
the wheel for such simple functionality.

Thanks,

Richard.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]