Re: popt

On Thu, Sep 21, 2000 at 09:17:59AM +0200, Stéphane Genaud wrote:
> for the small app i am doing i'd like to implement a "--noapplet"
> command
> line option : "my_app" would run a gnome application with an applet in
> the panel
> allowing to control the main window, 
> whereas "my_app --noapplet" would run the application without applet.
> I am using popt to parse the arguments and a gboolean "noapplet" is set 
> by gnome_init_with_popt_table. My code goes :
>    gnome_init_with_popt_table(PACKAGE,VERSION,argc,argv,options,0,NULL);
>    if (noapplet) {
>         gtk_main();
>    }
>    else {
>       applet_widget_init(PACKAGE,VERSION,argc,argv,NULL,0,NULL);
>       applet_widget_gtk_main();
>    }

Well, this is a severe limitation on the applet-widget part.  Here's how to
"fake it"

What happens is that, applet_widget_init just initializes gnome with corba
and disables the session managment (because for applets that's taken care of
by the panel).  There's one last tidbit it does, which is to set an internal
flag to call gtk_main_quit when the last applet dies.  SO, to fake it,
just do gnome_CORBA_init_with_popt_table, then in case we're an applet,
gnome_client_disable_master_connection, and then bind to the destroy signal
on the applet widget and call gtk_main_quit.

Hmm... seems hacky?  It is.  All this will be improved in gnome 2.0.

Another option.  Build another binary.  One binary will do an applet,
one binary will do a normal app.  Most of the code can be shared.


George <jirka 5z com>
   As long as people will accept crap, 
   it will be financially profitable to dispense it.
                       -- Dick Cavett, in "Playboy", 1971

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