Re: creating a Glib::OptionGroup



Den 2022-01-10 kl. 16:30, skrev phosit--- via gtkmm-list:
What is a god method of creating a OptionGroup?

The best option I see is to asign every member of Glib::OptionEntry and
then add it to the Glib::OptionGroup. Like so:

Glib::OptionGroup mainGroup;

Glib::OptionEntry ent;
ent.set_long_name("verbose");
ent.set_short_name('V');
ent.set_description("Set Verbosity level (0, 1, 2)");
ent.set_arg_description("LEVEL");
mainGroup.add_entry(ent, verbosityLevel);

and this for every entry.

This is to mutch code so i use the c-style. I would like  to use c++
features like std::vector and Glib::ustring instead of NULL terminated
arrays. Is ther a bether way of doing it?

No, there is no better way. There is a bunch of overloaded Gio::Application::add_main_option_entry() methods that take all the necessary parameters for creating a new Glib::OptionEntry. But there are no corresponding Glib::OptionGroup methods, and no Glib::OptionEntry constructor that takes all the necessary parameters (long_name, short_name, etc.).

See e.g. https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/master/examples/book/application/command_line_handling/exampleapplication.cc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]