static void
set_option_group (CutModuleFactory *factory, GOptionContext *context)
{
    CutConsoleUIFactory *console = CUT_CONSOLE_UI_FACTORY(factory);
    GOptionGroup *group;
    GOptionEntry entries[] = {
        {"verbose", 'v', 0, G_OPTION_ARG_CALLBACK, parse_verbose_level_arg,
         N_("Set verbose level"), "[s|silent|n|normal|v|verbose]"},
        {"color", 'c', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
         parse_color_arg, N_("Output log with colors"),
         "[yes|true|no|false|auto]"},
        {"notify", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
         parse_notify_arg, N_("Notify test result"), "[yes|true|no|false|auto]"},
        {"show-detail-immediately", 0, G_OPTION_FLAG_OPTIONAL_ARG,
         G_OPTION_ARG_CALLBACK, parse_show_detail_immediately,
         N_("Show test detail immediately"), "[yes|true|no|false]"},
        {NULL}
    };

    if (CUT_MODULE_FACTORY_CLASS(parent_class)->set_option_group)
        CUT_MODULE_FACTORY_CLASS(parent_class)->set_option_group(factory, context);

    group = g_option_group_new(("console-ui"),
                               _("Console UI Options"),
                               _("Show console UI options"),
                               console, NULL);
    g_option_group_add_entries(group, entries);
    g_option_group_set_parse_hooks(group, pre_parse, NULL);
    g_option_group_set_translation_domain(group, GETTEXT_PACKAGE);
    g_option_context_add_group(context, group);
}
Example #2
0
/**
 * pk_debug_get_option_group: (skip)
 *
 * Returns a #GOptionGroup for the commandline arguments recognized
 * by debugging. You should add this group to your #GOptionContext
 * with g_option_context_add_group(), if you are using
 * g_option_context_parse() to parse your commandline arguments.
 *
 * Returns: a #GOptionGroup for the commandline arguments
 */
GOptionGroup *
pk_debug_get_option_group (void)
{
	GOptionGroup *group;
	group = g_option_group_new ("debug", _("Debugging Options"), _("Show debugging options"), NULL, NULL);
	g_option_group_set_parse_hooks (group, pk_debug_pre_parse_hook, pk_debug_post_parse_hook);
	return group;
}
Example #3
0
/**
 * gnm_get_option_group: (skip)
 *
 * Returns a #GOptionGroup for the commandline arguments recognized
 * by libspreadsheet. You should add this group to your #GOptionContext with
 * g_option_context_add_group(), if you are using g_option_context_parse() to
 * parse your commandline arguments.
 *
 * Returns a #GOptionGroup for the commandline arguments recognized
 *   by libspreadsheet
 *
 * Since: 1.8
 **/
GOptionGroup *
gnm_get_option_group (void)
{
	GOptionGroup *group = g_option_group_new ("libspreadsheet",
		_("Gnumeric Options"), _("Show Gnumeric Options"), NULL, NULL);
	g_option_group_add_entries (group, libspreadsheet_options);
	g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
	g_option_group_set_parse_hooks (group, NULL,
		&cb_gnm_option_group_post_parse);
	return group;
}
Example #4
0
void
error_test1 (void)
{
  GOptionContext *context;
  gboolean retval;
  GError *error = NULL;
  gchar **argv;
  int argc;
  GOptionGroup *main_group;
#ifndef SYMBIAN
  GOptionEntry entries [] =
    { { "test", 0, 0, G_OPTION_ARG_INT, &error_test1_int, NULL, NULL },
      { NULL } };
#else    

  GOptionEntry entries [2];
 
  entries[0].long_name = "test";
  entries[0].short_name = 0;
  entries[0].flags = 0;
  entries[0].arg = G_OPTION_ARG_INT;
  entries[0].arg_data = (gpointer)&error_test1_int;
  entries[0].description =  NULL;
  entries[0].arg_description = NULL;
      
  entries[1].long_name = NULL;
  entries[1].short_name = 0;
  entries[1].arg_data = NULL;
  entries[1].description =  NULL;
  entries[1].arg_description = NULL;
#endif
  
  context = g_option_context_new (NULL);
  g_option_context_add_main_entries (context, entries, NULL);

  /* Set pre and post parse hooks */
  main_group = g_option_context_get_main_group (context);
  g_option_group_set_parse_hooks (main_group,
				  error_test1_pre_parse, error_test1_post_parse);
  
  /* Now try parsing */
  argv = split_string ("program --test 20", &argc);

  retval = g_option_context_parse (context, &argc, &argv, &error);
  g_assert (retval == FALSE);

  /* On failure, values should be reset */
  g_assert (error_test1_int == 0x12345678);
  
  g_strfreev (argv);
  g_option_context_free (context);
  
}
Example #5
0
/**
 * gegl_get_option_group:
 *
 * Returns a #GOptionGroup for the commandline arguments recognized
 * by GEGL. You should add this group to your #GOptionContext
 * with g_option_context_add_group(), if you are using
 * g_option_context_parse() to parse your commandline arguments.
 *
 * Returns a #GOptionGroup for the commandline arguments recognized by GEGL.
 */
GOptionGroup *
gegl_get_option_group (void)
{
  GOptionGroup *group;

  group = g_option_group_new ("gegl", "GEGL Options", "Show GEGL Options",
                              NULL, NULL);
  g_option_group_add_entries (group, cmd_entries);

  g_option_group_set_parse_hooks (group, NULL, gegl_post_parse_hook);

  return group;
}
Example #6
0
/* XXX: GOption based library initialization is not reliable because the
 * GOption API has no way to represent dependencies between libraries.
 */
GOptionGroup *
cogl_get_option_group (void)
{
    GOptionGroup *group;

    group = g_option_group_new ("cogl",
                                _("Cogl Options"),
                                _("Show Cogl options"),
                                NULL, NULL);

    g_option_group_set_parse_hooks (group, pre_parse_hook, NULL);
    g_option_group_add_entries (group, cogl_args);
    g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);

    return group;
}
Example #7
0
/**
 * gdict_get_option_group:
 *
 * FIXME
 *
 * Return value: FIXME
 *
 * Since: 0.12
 */
GOptionGroup *
gdict_get_option_group (void)
{
  GOptionGroup *group;

  group = g_option_group_new ("gdict",
                              _("GDict Options"),
                              _("Show GDict Options"),
                              NULL,
                              NULL);
  
  g_option_group_set_parse_hooks (group, pre_parse_hook, post_parse_hook);
  g_option_group_add_entries (group, gdict_args);
  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);

  return group;
}
Example #8
0
File: uprof.c Project: ebassi/UProf
GOptionGroup *
uprof_get_option_group (void)
{
  GOptionGroup *group;

  group = g_option_group_new ("uprof",
                              "UProf Options",
                              "Show UProf Options",
                              NULL,
                              NULL);

  g_option_group_set_parse_hooks (group, pre_parse_hook, post_parse_hook);
  g_option_group_add_entries (group, uprof_args);
#if 0
  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
#endif

  return group;
}
Example #9
0
static GOptionContext *commandline_parse(int *argc, char ***argv) {
	GOptionContext *context = NULL;
	GError *error = NULL;
	gchar *string;

	string = g_strdup_printf(_("- controls extended capabilities of Roccat %s mice"), KONEXTD_DEVICE_NAME);
	context = g_option_context_new(string);
	g_free(string);

	g_option_context_add_main_entries(context, entries, NULL);
	g_option_context_set_translation_domain(context, PROJECT_NAME);

	g_option_group_set_parse_hooks(g_option_context_get_main_group(context), NULL, post_parse_func);

	if (!g_option_context_parse(context, argc, argv, &error)) {
		g_critical(_("Could not parse options: %s"), error->message);
		exit(EXIT_FAILURE);
	}
	return context;
}
/**
 * egg_sm_client_get_option_group:
 *
 * Creates a %GOptionGroup containing the session-management-related
 * options. You should add this group to the application's
 * %GOptionContext if you want to use #EggSMClient.
 *
 * Return value: the %GOptionGroup
 **/
GOptionGroup *
egg_sm_client_get_option_group (void)
{
  const GOptionEntry entries[] = {
    { "sm-client-disable", 0, 0,
      G_OPTION_ARG_NONE, &sm_client_disable,
      N_("Disable connection to session manager"), NULL },
    { "sm-client-state-file", 0, 0,
      G_OPTION_ARG_FILENAME, &sm_client_state_file,
      N_("Specify file containing saved configuration"), N_("FILE") },
    { "sm-client-id", 0, 0,
      G_OPTION_ARG_STRING, &sm_client_id,
      N_("Specify session management ID"), N_("ID") },
    /* MateClient compatibility option */
    { "sm-disable", 0, G_OPTION_FLAG_HIDDEN,
      G_OPTION_ARG_NONE, &sm_client_disable,
      NULL, NULL },
    /* MateClient compatibility option. This is a dummy option that only
     * exists so that sessions saved by apps with MateClient can be restored
     * later when they've switched to EggSMClient. See bug #575308.
     */
    { "sm-config-prefix", 0, G_OPTION_FLAG_HIDDEN,
      G_OPTION_ARG_STRING, &sm_config_prefix,
      NULL, NULL },
    { NULL }
  };
  GOptionGroup *group;

  /* Use our own debug handler for the "EggSMClient" domain. */
  g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
                     egg_sm_client_debug_handler, NULL);

  group = g_option_group_new ("sm-client",
                              _("Session management options:"),
                              _("Show session management options"),
                              NULL, NULL);
  g_option_group_add_entries (group, entries);
  g_option_group_set_parse_hooks (group, NULL, sm_client_post_parse_func);

  return group;
}
Example #11
0
GOptionGroup*
mux_message_part_get_option_group (MuxMessagePartOptions *opts)
{
	GOptionGroup *og;
	GOptionEntry entries[]= {
		{"extract", 0, 0, G_OPTION_ARG_STRING, &opts->extract,
                 "Message part to extract", "<mime-path>"},
		{"stdout", 0, 0, G_OPTION_ARG_NONE, &opts->stdout,
                 "Write to stdout rather than to a file"},
                {NULL}
	};

	g_return_val_if_fail (opts, NULL);

	og = g_option_group_new ("parts", "Parts options", "", opts, NULL);

	g_option_group_add_entries (og, entries);
        g_option_group_set_parse_hooks (og, NULL,
                                        (GOptionParseFunc)on_parse_options);

	return og;
}
Example #12
0
/**
 * egg_debug_get_option_group:
 *
 * Returns a #GOptionGroup for the commandline arguments recognized
 * by debugging. You should add this group to your #GOptionContext
 * with g_option_context_add_group(), if you are using
 * g_option_context_parse() to parse your commandline arguments.
 *
 * Returns: a #GOptionGroup for the commandline arguments
 */
GOptionGroup *
egg_debug_get_option_group (void)
{
	GOptionGroup *group;
	const GOptionEntry debug_entries[] = {
		{ "debug-modules", '\0', 0, G_OPTION_ARG_STRING_ARRAY, &_modules,
		  /* TRANSLATORS: a list of modules to debug */
		  N_("Debug these specific modules"), NULL },
		{ "debug-functions", '\0', 0, G_OPTION_ARG_STRING_ARRAY, &_functions,
		  /* TRANSLATORS: a list of functions to debug */
		  N_("Debug these specific functions"), NULL },
		{ "debug-log-filename", '\0', 0, G_OPTION_ARG_STRING, &_log_filename,
		  /* TRANSLATORS: save to a log */
		  N_("Log debugging data to a file"), NULL },
		{ NULL}
	};

	group = g_option_group_new ("debug", _("Debugging Options"), _("Show debugging options"), NULL, NULL);
	g_option_group_set_parse_hooks (group, egg_debug_pre_parse_hook, egg_debug_post_parse_hook);
	g_option_group_add_entries (group, debug_entries);
	return group;
}
Example #13
0
GOptionGroup*
mux_config_get_option_group (MuxConfigOptions *opts)
{
	GOptionGroup *og;
	GOptionEntry entries[]= {
		{"config", 'c', 0, G_OPTION_ARG_FILENAME, &opts->config,
		 "Path to alternative configuration file", "<path>"},
		{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &opts->maildir,
		 "Maildir path", "<path>"},
		{"store-path", 'm', 0, G_OPTION_ARG_FILENAME,
		 &opts->store_path,
		 "Path to the Xapian data store ", "<path>"},
		{"user-addresses", 'u', 0, G_OPTION_ARG_STRING,
		 &opts->user_addrs,
		 "Comma-separated list of regexps matching user's "
		 "email addresses","<address-rx>" },
		{"quiet", 'q', 0, G_OPTION_ARG_NONE, &opts->quiet,
		 "Enable quiet mode", NULL},
		{"verbose", 'q', 0, G_OPTION_ARG_NONE, &opts->verbose,
		 "Enable verbose mode", NULL},
		{"force", 'f', 0, G_OPTION_ARG_NONE, &opts->force,
		 "Force an operation", NULL},
		{"debug", 'd', G_OPTION_FLAG_HIDDEN,
		 G_OPTION_ARG_NONE, &opts->debug,
		 "Run in debug mode", NULL},
		{NULL, 0, 0, 0, NULL, NULL, NULL},
	};

	g_return_val_if_fail (opts, NULL);

	og = g_option_group_new ("general", "General options", "",
				 opts, NULL);

	g_option_group_add_entries (og, entries);
	g_option_group_set_parse_hooks (og, NULL,
					(GOptionParseFunc)on_parse_config);

	return og;
}
Example #14
0
GOptionGroup *
gst_init_get_option_group (void)
{
#ifndef GST_DISABLE_OPTION_PARSING
  GOptionGroup *group;
  static const GOptionEntry gst_args[] = {
    {"gst-version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
        (gpointer) parse_goption_arg, N_("Print the GStreamer version"), NULL},
    {"gst-fatal-warnings", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
        (gpointer) parse_goption_arg, N_("Make all warnings fatal"), NULL},
#ifndef GST_DISABLE_GST_DEBUG
    {"gst-debug-help", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Print available debug categories and exit"),
        NULL},
    {"gst-debug-level", 0, 0, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Default debug level from 1 (only error) to 9 (anything) or "
              "0 for no output"),
        N_("LEVEL")},
    {"gst-debug", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) parse_goption_arg,
          N_("Comma-separated list of category_name:level pairs to set "
              "specific levels for the individual categories. Example: "
              "GST_AUTOPLUG:5,GST_ELEMENT_*:3"),
        N_("LIST")},
    {"gst-debug-no-color", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg, N_("Disable colored debugging output"),
        NULL},
    {"gst-debug-color-mode", 0, 0, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Changes coloring mode of the debug log. "
              "Possible modes: off, on, disable, auto, unix"),
        NULL},
    {"gst-debug-disable", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
        (gpointer) parse_goption_arg, N_("Disable debugging"), NULL},
#endif
    {"gst-plugin-spew", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Enable verbose plugin loading diagnostics"),
        NULL},
    {"gst-plugin-path", 0, 0, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
        N_("Colon-separated paths containing plugins"), N_("PATHS")},
    {"gst-plugin-load", 0, 0, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Comma-separated list of plugins to preload in addition to the "
              "list stored in environment variable GST_PLUGIN_PATH"),
        N_("PLUGINS")},
    {"gst-disable-segtrap", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Disable trapping of segmentation faults during plugin loading"),
        NULL},
    {"gst-disable-registry-update", 0, G_OPTION_FLAG_NO_ARG,
          G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Disable updating the registry"),
        NULL},
    {"gst-disable-registry-fork", 0, G_OPTION_FLAG_NO_ARG,
          G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Disable spawning a helper process while scanning the registry"),
        NULL},
    {NULL}
  };

  group = g_option_group_new ("gst", _("GStreamer Options"),
      _("Show GStreamer Options"), NULL, NULL);
  g_option_group_set_parse_hooks (group, (GOptionParseFunc) init_pre,
      (GOptionParseFunc) init_post);

  g_option_group_add_entries (group, gst_args);
  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);

  return group;
#else
  return NULL;
#endif
}
Example #15
0
int
main (int argc, char **argv)
{
  GOptionContext *context;
  GOptionGroup *group;
  GError* err = NULL;
  int i;
  int args_len;
  mode_t dir_permissions;
  char *basename;

  setlocale (LC_ALL, "");

  basename = g_path_get_basename (argv[0]);
  if (g_strcmp0 (basename, "desktop-file-edit") == 0)
    edit_mode = TRUE;
  g_free (basename);

  context = g_option_context_new ("");
  g_option_context_set_summary (context, edit_mode ? _("Edit a desktop file.") : _("Install desktop files."));
  g_option_context_add_main_entries (context, main_options, NULL);

  if (!edit_mode)
    {
      group = g_option_group_new ("install", _("Installation options for desktop file"), _("Show desktop file installation options"), NULL, NULL);
      g_option_group_add_entries (group, install_options);
      g_option_context_add_group (context, group);
    }

  group = g_option_group_new ("edit", _("Edition options for desktop file"), _("Show desktop file edition options"), NULL, NULL);
  g_option_group_add_entries (group, edit_options);
  g_option_group_set_parse_hooks (group, NULL, post_parse_edit_options_callback);
  g_option_context_add_group (context, group);

  err = NULL;
  g_option_context_parse (context, &argc, &argv, &err);

  if (err != NULL) {
    g_printerr ("%s\n", err->message);
    g_printerr (_("Run '%s --help' to see a full list of available command line options.\n"), argv[0]);
    g_error_free (err);
    return 1;
  }

  if (!edit_mode)
    {
      if (vendor_name == NULL && g_getenv ("DESKTOP_FILE_VENDOR"))
        vendor_name = g_strdup (g_getenv ("DESKTOP_FILE_VENDOR"));

      if (target_dir == NULL && g_getenv ("DESKTOP_FILE_INSTALL_DIR"))
        target_dir = g_strdup (g_getenv ("DESKTOP_FILE_INSTALL_DIR"));

      if (target_dir == NULL)
        {
          if (g_getenv ("RPM_BUILD_ROOT"))
            target_dir = g_build_filename (g_getenv ("RPM_BUILD_ROOT"), DATADIR, "applications", NULL);
          else
            target_dir = g_build_filename (DATADIR, "applications", NULL);
        }

      /* Create the target directory */
      dir_permissions = permissions;

      /* Add search bit when the target file is readable */
      if (permissions & 0400)
        dir_permissions |= 0100;
      if (permissions & 0040)
        dir_permissions |= 0010;
      if (permissions & 0004)
        dir_permissions |= 0001;

      g_mkdir_with_parents (target_dir, dir_permissions);
    }

  args_len = 0;
  for (i = 0; args && args[i]; i++)
    args_len++;

  if (edit_mode)
    {
      if (args_len == 0)
        {
          g_printerr (_("Must specify a desktop file to process.\n"));
          return 1;
        }
      if (args_len > 1)
        {
          g_printerr (_("Only one desktop file can be processed at once.\n"));
          return 1;
        }
    }
  else
    {
      if (args_len == 0)
        {
          g_printerr (_("Must specify one or more desktop files to process.\n"));
          return 1;
        }
    }

  for (i = 0; args && args[i]; i++)
    {
      err = NULL;
      process_one_file (args[i], &err);
      if (err != NULL)
        {
          g_printerr (_("Error on file \"%s\": %s\n"),
                      args[i], err->message);
          g_error_free (err);

          return 1;
        }
    }

#if GLIB_CHECK_VERSION(2,28,0)
  g_slist_free_full (edit_actions, (GDestroyNotify) dfu_edit_action_free);
#else
  g_slist_foreach (edit_actions, (GFunc) dfu_edit_action_free, NULL);
  g_slist_free (edit_actions);
#endif

  g_option_context_free (context);

  return 0;
}
Example #16
0
GOptionGroup *
gst_init_get_option_group (void)
{
#ifndef GST_DISABLE_OPTION_PARSING
  GOptionGroup *group;
  static const GOptionEntry gst_args[] = {
    {"gst-version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
        (gpointer) parse_goption_arg, N_("Print the GStreamer version"), NULL},
    {"gst-fatal-warnings", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
        (gpointer) parse_goption_arg, N_("Make all warnings fatal"), NULL},
#ifndef GST_DISABLE_GST_DEBUG
    {"gst-debug-help", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Print available debug categories and exit"),
        NULL},
    {"gst-debug-level", 0, 0, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Default debug level from 1 (only error) to 5 (anything) or "
              "0 for no output"),
        N_("LEVEL")},
    {"gst-debug", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) parse_goption_arg,
          N_("Comma-separated list of category_name:level pairs to set "
              "specific levels for the individual categories. Example: "
              "GST_AUTOPLUG:5,GST_ELEMENT_*:3"),
        N_("LIST")},
    {"gst-debug-no-color", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg, N_("Disable colored debugging output"),
        NULL},
    {"gst-debug-disable", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
        (gpointer) parse_goption_arg, N_("Disable debugging"), NULL},
#endif
    {"gst-plugin-spew", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Enable verbose plugin loading diagnostics"),
        NULL},
    {"gst-plugin-path", 0, 0, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
        N_("Colon-separated paths containing plugins"), N_("PATHS")},
    {"gst-plugin-load", 0, 0, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Comma-separated list of plugins to preload in addition to the "
              "list stored in environment variable GST_PLUGIN_PATH"),
        N_("PLUGINS")},
    {"gst-disable-segtrap", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Disable trapping of segmentation faults during plugin loading"),
        NULL},
    {"gst-disable-registry-update", 0, G_OPTION_FLAG_NO_ARG,
          G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Disable updating the registry"),
        NULL},
    {"gst-disable-registry-fork", 0, G_OPTION_FLAG_NO_ARG,
          G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Disable spawning a helper process while scanning the registry"),
        NULL},
    {NULL}
  };

  /* Since GLib 2.23.2 calling g_thread_init() 'late' is allowed and is
   * automatically done as part of g_type_init() */
  if (glib_check_version (2, 23, 3)) {
    /* The GLib threading system must be initialised before calling any other
     * GLib function according to the documentation; if the application hasn't
     * called gst_init() yet or initialised the threading system otherwise, we
     * better issue a warning here (since chances are high that the application
     * has already called other GLib functions such as g_option_context_new() */
    if (!g_thread_get_initialized ()) {
      g_warning ("The GStreamer function gst_init_get_option_group() was\n"
          "\tcalled, but the GLib threading system has not been initialised\n"
          "\tyet, something that must happen before any other GLib function\n"
          "\tis called. The application needs to be fixed so that it calls\n"
          "\t   if (!g_thread_get_initialized ()) g_thread_init(NULL);\n"
          "\tas very first thing in its main() function. Please file a bug\n"
          "\tagainst this application.");
      g_thread_init (NULL);
    }
  } else {
    /* GLib >= 2.23.2 */
  }

  group = g_option_group_new ("gst", _("GStreamer Options"),
      _("Show GStreamer Options"), NULL, NULL);
  g_option_group_set_parse_hooks (group, (GOptionParseFunc) init_pre,
      (GOptionParseFunc) init_post);

  g_option_group_add_entries (group, gst_args);
  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);

  return group;
#else
  return NULL;
#endif
}
Example #17
0
File: bosh-main.c Project: rib/Bosh
static GSwatSession *
parse_args (int *argc, char ***argv)
{
  GOptionContext *option_context;
  GOptionGroup *group;
  GError *error = NULL;
  GSwatSession *session = NULL;

  option_context = g_option_context_new ("[executable-file "
                                         "[core-file or process-id]]");
  //g_option_context_set_ignore_unknown_options (option_context, TRUE);
  //g_option_context_set_help_enabled (option_context, TRUE);

  group = g_option_group_new ("bosh",
                              _("Bosh Options"),
                              _("Show Bosh options"),
                              NULL, NULL);

  g_option_group_set_parse_hooks (group, pre_parse_hook, NULL);
  g_option_group_add_entries (group, bosh_args);
  //g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);

  g_option_context_set_main_group (option_context, group);

  if (!g_option_context_parse (option_context, argc, argv, &error))
    {
      if (error)
        {
          g_warning ("%s", error->message);
          g_error_free (error);
        }
    }

  /* First we see if the user has described a new session on the command line
   */
  if (pid != -1)
    {
      gchar *target;
      if (!remaining_args)
        {
          g_message ("%s",
                     g_option_context_get_help (option_context, TRUE, NULL));
          exit (1);
        }
      session = gswat_session_new ();
      gswat_session_set_target_type (session, "PID Local");
      target = g_strdup_printf ("pid=%d file=%s", pid, remaining_args[0]);
      gswat_session_set_target (session, target);
      g_free (target);
    }
  else if (remaining_args != NULL)
    {
      int i;
      GString *target;
      session = gswat_session_new ();
      gswat_session_set_target_type (session, "Run Local");
      target = g_string_new (remaining_args[0]);
      for (i=1; remaining_args[i] != NULL; i++)
        {
          g_string_append_printf (target, " %s",
                                 g_shell_quote (remaining_args[i]));
        }
      gswat_session_set_target (session, target->str);
      g_string_free (target, TRUE);
    }

  g_option_context_free (option_context);

  return session;
}