Re: [Glib::OptionGroup] How to add_entry() for custom data



Perhaps the glibmm example program at https://git.gnome.org/browse/glibmm/tree/examples/options/main.cc can help you.

MyOptionGroup::add_entry() is unnecessary. You can call Glib::OptionGroup::add_entry() directly. Or, if you prefer to keep MyOptionGroup::add_entry(), the argument Gdk::Rectangle& arg is unnecessary. You don't use it, anyway.

I don't see any problem in MyOptionGroup::on_option_arg_rectangle(). I suppose MyOptionGroup::m_arg_box is a Gdk::Rectangle. If rect is a local Gdk::Rectangle in MyOptionGroup::on_option_arg_rectangle(), you can just assign "m_arg_box = rect;" once you have decoded the string 'value' and stored the result in 'rect'.

Have I misunderstood you? Probably, because I don't see what's the problem.

Kjell

2013-06-10 14:57, Maggio Mago skrev:
Hello all,

I have a command line with an option "box" than is a Rectangle:
I would like to do :
$] prog --box="0 0 600 400"
Instead of :
$] prog --box-x="0"  --box-y="0" --box-width="600" --box-height="400"


I wrote my programme in Gtkmm, so I have subclassed Glib::OptionGroup and add this function :

void MyOptionGroup::add_entry(const Glib::OptionEntry& entry, Gdk::Rectangle& arg) {
    Glib::OptionGroup::add_entry(entry, sigc::mem_fun(*this, &OptionGroup::on_option_arg_rectangle));

}
bool MyOptionGroup::on_option_arg_rectangle(const Glib::ustring& option_name, const Glib::ustring& value, bool has_value)
{
    bool succes = true;
    // parse value to Gdk::Rectangle(0, 0, 600, 400);
    // How I can set MyOptionGroup->m_arg_box ?
    return succes;
}

How to store the parsed value in the function on_option_rectangle()


PS : I tried to show you the code that I did but maybe I have it all wrong






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