tools: call g_set_prgname() before doing the option parsing

g_setprgname is implicitly called by g_option_context_new() with a check
to see if it's been set already, so set it before g_option_context_new()

Move version printing back until after the options have been parsed,
otherwise it won't work, since it evaluates a flag set by the
option parser.
This commit is contained in:
Tim-Philipp Müller 2010-02-16 11:30:35 +00:00
parent 47601cb911
commit ca320242f3
5 changed files with 20 additions and 8 deletions

View file

@ -1491,6 +1491,8 @@ main (int argc, char *argv[])
g_thread_init (NULL);
gst_tools_set_prgname ("gst-inspect");
#ifndef GST_DISABLE_OPTION_PARSING
ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]");
g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);

View file

@ -715,6 +715,8 @@ main (int argc, char *argv[])
g_thread_init (NULL);
gst_tools_set_prgname ("gst-launch");
#ifndef GST_DISABLE_OPTION_PARSING
ctx = g_option_context_new ("PIPELINE-DESCRIPTION");
g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);

View file

@ -155,7 +155,7 @@ main (int argc, char *argv[])
g_thread_init (NULL);
gst_tools_print_version ("gst-typefind");
gst_tools_set_prgname ("gst-typefind");
ctx = g_option_context_new ("FILES");
g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
@ -166,6 +166,8 @@ main (int argc, char *argv[])
}
g_option_context_free (ctx);
gst_tools_print_version ("gst-typefind");
if (filenames == NULL || *filenames == NULL) {
g_print ("Please give a filename to typefind\n\n");
return 1;

View file

@ -639,7 +639,7 @@ main (int argc, char *argv[])
g_thread_init (NULL);
gst_tools_print_version ("gst-xmlinspect");
gst_tools_set_prgname ("gst-xmlinspect");
ctx = g_option_context_new ("[ELEMENT-NAME]");
g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
@ -650,6 +650,8 @@ main (int argc, char *argv[])
}
g_option_context_free (ctx);
gst_tools_print_version ("gst-xmlinspect");
/* if no arguments, print out all elements */
if (argc == 1) {
GList *features, *f;

View file

@ -44,12 +44,6 @@ static gboolean __gst_tools_version = FALSE;
static void
gst_tools_print_version (const gchar * tool)
{
gchar *s;
s = g_strdup_printf ("%s-%u.%u", tool, GST_VERSION_MAJOR, GST_VERSION_MINOR);
g_set_prgname (s);
g_free (s);
if (__gst_tools_version) {
gchar *version_str;
@ -63,4 +57,14 @@ gst_tools_print_version (const gchar * tool)
}
}
static void
gst_tools_set_prgname (const gchar * tool)
{
gchar *s;
s = g_strdup_printf ("%s-%u.%u", tool, GST_VERSION_MAJOR, GST_VERSION_MINOR);
g_set_prgname (s);
g_free (s);
}
#endif /* __GST_TOOLS_H__ */