X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fmain.c;h=ba35a4b205bf74af4f477adacc3c97889b3aebd5;hb=7b28f309d313b9ff2c867d523ab017095ebc274f;hp=ffe94c735481598cc44e477d01a82c685fa3831a;hpb=7ed8e1d6f794a98c3eb6447dd8e205899fcb1435;p=hvgrip.git diff --git a/src/main.c b/src/main.c index ffe94c7..ba35a4b 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,9 @@ */ #include -#include +#include +#include +#include #include #include "grip.h" @@ -40,6 +42,7 @@ static int force_small=FALSE; static int local_mode=FALSE; static int no_redirect=FALSE; static int verbose=FALSE; +static int version=FALSE; struct poptOption options[] = { { @@ -114,6 +117,16 @@ struct poptOption options[] = { N_("Run in verbose (debug) mode"), NULL }, + { + "version", + '\0', + POPT_ARG_NONE, + &version, + 0, + N_("Print version number"), + NULL + }, + POPT_AUTOHELP { NULL, '\0', @@ -145,19 +158,37 @@ void Debug(char *fmt,...) int Cmain(int argc, char* argv[]) { + poptContext context; + int status; + /* Unbuffer stdout */ setvbuf(stdout, 0, _IONBF, 0); /* setup locale, i18n */ gtk_set_locale(); - bindtextdomain(GETTEXT_PACKAGE,GNOMELOCALEDIR); - textdomain(GETTEXT_PACKAGE); + bindtextdomain(PACKAGE_TARNAME, LOCALEDIR); + textdomain(PACKAGE_TARNAME); + + gtk_init(&argc, &argv); + context = poptGetContext(NULL, argc, (const char **) argv, options, 0); + status = poptGetNextOpt(context); + if (status != -1) { + fprintf(stderr, "Error with option [%s]:\n %s\n", + poptBadOption(context, POPT_BADOPTION_NOALIAS), + poptStrerror(status)); + + /* Print a short usage message. */ + poptPrintUsage(context, stderr, 0); - gnome_program_init(PACKAGE,VERSION,LIBGNOMEUI_MODULE,argc,argv, - GNOME_PARAM_POPT_TABLE,options, - GNOME_PROGRAM_STANDARD_PROPERTIES,NULL); + exit(1); + } + + if (version) { + printf("%s\n", PACKAGE_VERSION); + exit(0); + } - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF8"); + bind_textdomain_codeset(PACKAGE_TARNAME, "UTF8"); setenv("CHARSET","UTF-8",1); do_debug=verbose;