Re: How to put send an option to GUI app in a console wothout DISPLAY

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

 



> Hi
>
> I have a GUI program and one of the thing is that I want my user to be
> able to parse options to the program (e.g. adding new record) from the
> command line without DISPLAY variable defined
>
> basically I want the program when it start to check if the user parse
> the option "--add <name>"  then just add the name to the db and exist
> (The user in this case will run the program in a console and there is
> no DISPLAY defined), and if the user didn't parse any option then run
> the program GUI in the defined DISPLAY
>
> I tried gtk_init_with_args but this will not work if the DISPLAY is
> undefined
>
>
> any help ?
>
> Here is my code
>

Don't init gtk unless you are going to use it.

int
main (int argc, char *argv[])
{
 		static gchar *node = NULL;
         GOptionEntry options[] = {
                 { "new-node", 'n', 0, G_OPTION_ARG_STRING, &node,
 _("Add new node"), _("hostname") },
                 		{ NULL, '\0', 0, 0, NULL, NULL, NULL }
         };

 	if(node) {
 	         g_print("NEW NODE\n");
 	         g_print("node=%s)\n",node);
 		 return 0;  // now exit because the user don't want the program, he
 just want to add something
         }

  gtk_init_with_args (&argc, &argv,NULL,options,NULL,NULL);

   gtk_main ();
   return 0;

}
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux