popt



Hi,

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();
   }

With the applet version, applet_widget_init() complains since it seems
i can't call gnome_init() before, and triggers the assertion :

GnomeUI-CRITICAL **: file gnome-init.c: line 434
(gnome_init_with_popt_table): assertion `gnome_initialized == FALSE'
failed.

I have looked at the gnomeicu sources (it has the same option) and
i'm not convinced by the solution. Gnome-icu just loops over the
arguments to find a "--noapplet" string (thus doing popt job) and
then call gnome_init_with_popt_table(). Popt seems quite useless in
this particular case.

My question is : have someone a cleaner way to address this problem,
calling popt parsing of args before calling gnome_init() ?

Thanks.

/********************************************************/
/* Stéphane Genaud                                      */
/* ICPS, Université Louis Pasteur                       */
/* Pôle API, Bd. S. Brant, F-67400 Illkirch             */
/* tel : (33)(0)388655047, 0619058113 (SFR)             */
/********************************************************/




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