I notice that Geany doesn't handle unknown command line options the way most other programs do:
% nedit --no-such-option NEdit: Unrecognized option --no-such-option
% nano --no-such-option nano: unrecognized option `--no-such-option'
% geany --no-such-option Will create a new document named "--no-such-option"
Even more strange, with an already running instance of Geany:
% geany -i --no-such-option Gives me two new documents, one named "--no-such-option" and one named "-i" ?!?!
I think this patch should solve the problem...
- Jeff
On Tue, 18 Dec 2007 15:15:24 -0600, "Jeff Pohlmeyer" yetanothergeek@gmail.com wrote:
I notice that Geany doesn't handle unknown command line options the way most other programs do:
% nedit --no-such-option NEdit: Unrecognized option --no-such-option
% nano --no-such-option nano: unrecognized option `--no-such-option'
% geany --no-such-option Will create a new document named "--no-such-option"
Even more strange, with an already running instance of Geany:
% geany -i --no-such-option Gives me two new documents, one named "--no-such-option" and one named "-i" ?!?!
I think this patch should solve the problem...
Thank you very much. I moved the gtk_init() call into parse_command_line_options() and used gtk_init_with_args(). This doesn't change much but so we get the "cannot open display" warning using the g_printerr call and we can save all the code to create an own g_option_context.
Unfortunately, when using GLib's command line parsing API there seems to be no way to get it working without a valid display(means graphic user interface, running XServer). I didn't find a way to get geany --version running on a text console. I guess to be able to get it working we need to use getopt or parse the command line options completely by hand. But since Geany is a GUI-only application it isn't probably that important.
Regards, Enrico
On Dec 19, 2007 7:55 AM, Enrico Tröger enrico.troeger@uvena.de wrote:
I didn't find a way to get geany --version running on a text console.
Ooops, I had not thought of that one...
What if you first do a simple loop through the command line options, and if you find one of these:
--ft-names --print-prefix -v --version
Just print the requested information and exit, so glib/gtk will never "see" the option.
- Jeff
On Wed, 19 Dec 2007 15:59:12 -0600 "Jeff Pohlmeyer" yetanothergeek@gmail.com wrote:
On Dec 19, 2007 7:55 AM, Enrico Tröger enrico.troeger@uvena.de wrote:
I didn't find a way to get geany --version running on a text console.
Ooops, I had not thought of that one...
What if you first do a simple loop through the command line options, and if you find one of these:
--ft-names --print-prefix -v --version
Just print the requested information and exit, so glib/gtk will never "see" the option.
- Jeff
Better use "gtk_init_check" to not force termination or "gtk_get_option_group" to get gtk specific command line options for use with "g_option_context_parse".
On Wed, 19 Dec 2007 16:22:49 -0700, Michal Kurgan michal.kurgan@moloh.net wrote:
On Wed, 19 Dec 2007 15:59:12 -0600 "Jeff Pohlmeyer" yetanothergeek@gmail.com wrote:
On Dec 19, 2007 7:55 AM, Enrico Tröger enrico.troeger@uvena.de wrote:
I didn't find a way to get geany --version running on a text console.
Ooops, I had not thought of that one...
What if you first do a simple loop through the command line options, and if you find one of these:
--ft-names --print-prefix -v --version
Just print the requested information and exit, so glib/gtk will never "see" the option.
Yes, I also thought about this but then we have to add code to manually parse these command line options. I'd like to keep the GLib command line parsing API but it seems it doesn't work without a display.
Better use "gtk_init_check" to not force termination or
I did some testing with all these functions. gtk_init_check and gtk_init_with_args return FALSE if there is no display present. If they would parse the given command line options it would be ideally. Then we know there is no display and though we know which command line options were given. Unfortunately, all these functions doesn't parse the command line options in case there is no display found. The docs doesn't mention this clearly, IMO. So the only possibility we have (AFAIK) is to manually parse the commandline options(maybe with popt) but I don't want to add this. It is a just another bunch of code for very low use, probably. Especially because the code actually exists already in GLib.
Maybe I'm missing something.
Regards, Enrico
On Dec 21, 2007 4:30 AM, Enrico Tröger enrico.troeger@uvena.de wrote:
Yes, I also thought about this but then we have to add code to manually parse these command line options.
I am just thinking to leave everything as-is, but just do something simple like this, before any of the glib/gtk stuff:
for (i=1; i<argc; i++){ if (g_str_equal(argv[i],"--ft-names")) { print_ft_names(); exit(0); } else { if (g_str_equal(argv[i],"--print-prefix")) { print_prefix(); exit(0); } else { if (g_str_equal(argv[i],"--version") || g_str_equal(argv[i],"-v")) { print_version(); exit(0); } }
It is a just another bunch of code for very low use, probably.
I agree, there's really no reason why anybody would need this.
For what it's worth, I tested some other GTK apps from console:
gimp --version # works wireshark --version # works sylpheed --version # works gftp-gtk # works
bluefish -v # can't open display!
( But I didn't check to see how they do it. )
Maybe I'm missing something.
Or maybe I'm missing something. :-)
- Jeff
On Fri, 21 Dec 2007 11:30:45 +0100 Enrico Tröger enrico.troeger@uvena.de wrote:
Better use "gtk_init_check" to not force termination or
[ ... ] So the only possibility we have (AFAIK) is to manually parse the commandline options(maybe with popt) but I don't want to add this.
Then use "gtk_get_option_group" and "g_option_context_parse". It is used in other gtk and gnome application to connect application specific and standard gtk options. Look at the sources for examples (ie. evince[1] ).
Regards, Enrico
[1] Look for main function only and non-gnome parts http://svn.gnome.org/viewvc/evince/trunk/shell/main.c?revision=2746&view...
On Fri, 21 Dec 2007 09:20:02 -0700, Michal Kurgan michal.kurgan@moloh.net wrote:
On Fri, 21 Dec 2007 11:30:45 +0100 Enrico Tröger enrico.troeger@uvena.de wrote:
Better use "gtk_init_check" to not force termination or
[ ... ] So the only possibility we have (AFAIK) is to manually parse the commandline options(maybe with popt) but I don't want to add this.
Then use "gtk_get_option_group" and "g_option_context_parse". It is used in other gtk and gnome application to connect application specific and standard gtk options. Look at the sources for examples (ie. evince[1] ).
Thanks for the hint, it's working now. The trick is to pass FALSE to gtk_get_option_group(). After doing this, all command line options also work on a plain text console without a valid X display. This may cause other problems but I don't care. When an user is using a GUI app on a plain text console, he should expect problems.
Regards, Enrico