Пример #1
0
wxString
wxGUIAppTraits::GetStandardCmdLineOptions(wxArrayString& names,
                                          wxArrayString& desc) const
{
    wxString usage;

#ifdef __WXGTK26__
#ifndef __WXGTK3__
    if (!gtk_check_version(2,6,0))
#endif
    {
        // since GTK>=2.6, we can use the glib_check_version() symbol...

        // check whether GLib version is greater than 2.6 but also lower than 2.33
        // because, as we use the undocumented _GOptionGroup struct, we don't want
        // to run this code with future versions which might change it (2.32 is the
        // latest one at the time of this writing)
        if (glib_check_version(2,6,0) == NULL && glib_check_version(2,33,0))
        {
            usage << _("The following standard GTK+ options are also supported:\n");

            // passing true here means that the function can open the default
            // display while parsing (not really used here anyhow)
            GOptionGroup *gtkOpts = gtk_get_option_group(true);

            // WARNING: here we access the internals of GOptionGroup:
            GOptionEntry *entries = ((_GOptionGroup*)gtkOpts)->entries;
            unsigned int n_entries = ((_GOptionGroup*)gtkOpts)->n_entries;
            wxArrayString namesOptions, descOptions;

            for ( size_t n = 0; n < n_entries; n++ )
            {
                if ( entries[n].flags & G_OPTION_FLAG_HIDDEN )
                    continue;       // skip

                names.push_back(wxGetNameFromGtkOptionEntry(&entries[n]));

                const gchar * const entryDesc = entries[n].description;
                desc.push_back(wxString(entryDesc));
            }

            g_option_group_free (gtkOpts);
        }
    }
#else
    wxUnusedVar(names);
    wxUnusedVar(desc);
#endif // __WXGTK26__

    return usage;
}
Пример #2
0
/**
 * g_option_context_free:
 * @context: a #GOptionContext 
 *
 * Frees context and all the groups which have been 
 * added to it.
 *
 * Since: 2.6
 */
void g_option_context_free (GOptionContext *context) 
{
  g_return_if_fail (context != NULL);

  g_list_foreach (context->groups, (GFunc)g_option_group_free, NULL);
  g_list_free (context->groups);

  if (context->main_group) 
    g_option_group_free (context->main_group);

  free_changes_list (context, FALSE);
  free_pending_nulls (context, FALSE);
  
  g_free (context->parameter_string);
  
  g_free (context);
}
Пример #3
0
int
main (int argc, char *argv[])
{
	GError* error = NULL;
	GOptionContext *context;
	GOptionGroup* groupMain;
	GOptionGroup* groupSearch;
	GOptionGroup* groupPoll;


	g_type_init();

	context = g_option_context_new("\nArchive, Download, Parse, and render NEXRAD data");

	groupMain = g_option_group_new("Main", "", "", NULL, NULL);
	g_option_group_add_entries(groupMain, entriesMain);
	g_option_context_add_group(context, groupMain);
	g_option_context_set_ignore_unknown_options(context, TRUE);

	if (!g_option_context_parse(context, &argc, &argv, &error))
	{
		g_error("Failed to parse cli options (phase 1): %s", error->message);
		return 1;
	}

	if (!chrOp)
	{
		g_error("Operation required");
		return 1;
	}

	g_option_context_set_ignore_unknown_options(context, FALSE);

	groupSearch = g_option_group_new("Search", "Search through archived data", "Search through archived data", NULL, NULL);
	g_option_group_add_entries(groupSearch, entriesSearch);

	groupPoll = g_option_group_new("Poll", "Poll data from darxend", "Continually polls for data, archiving it in the process", NULL, NULL);
	g_option_group_add_entries(groupPoll, entriesPoll);

	if (!strcasecmp(chrOp, "search"))
	{
		g_option_context_add_group(context, groupSearch);
	}
	else if (!strcasecmp(chrOp, "poll"))
	{
		g_option_context_add_group(context, groupPoll);
	}
//	else if (!strcasecmp(chrOp, "render"))
//	{
//
//	}
//	else if (!strcasecmp(chrOp, "disp"))
//	{
//
//	}
	else
	{
		printf("Invalid operation: %s\n", chrOp);
	}

	if (!g_option_context_parse(context, &argc, &argv, &error))
	{
		g_error("Failed to parse cli options(phase 2): %s", error->message);
		return 1;
	}

	int res;

	if (!strcasecmp(chrOp, "search"))
	{
		res = main_search();
	}
	else if (!strcasecmp(chrOp, "poll"))
	{
		res = main_poll();
	}
//	else if (!strcasecmp(chrOp, "render"))
//	{
//
//	}
//	else if (!strcasecmp(chrOp, "disp"))
//	{
//
//	}

	//g_option_context_add_main_entries(context, entries, NULL);
	//g_option_context_set_ignore_unknown_options(context, TRUE);

	g_option_group_free(groupSearch);
	g_option_group_free(groupPoll);
	g_option_context_free(context);

	return res;
}