Gtk::FileChooserButton *chooserButton = nullptr; std::string idChooserButton = commonArray[b]["id"]; builder->get_widget(idChooserButton, chooserButton); Php::call("var_dump",chooserButton); if (strcmp(commonArray[b]["action"], "click") == 0) { Php::Value callback = commonArray[b]["callback"]; chooserButton->signal_selection_changed().connect( sigc::bind<Php::Value,Php::Value>( sigc::mem_fun(*this, &ParserGtk::callbacks), callback, chooserButton->get_filename() ) ); } 

This is my code, when I select a file, a callback fires, but the get_filename function returns an empty string ""

  • Something I do not see where chooserButton takes some non-zero value. - 伪位蔚蠂慰位蠀蟿
  • @alexolut in the sense? - Naumov
  • What is a chooserButton during a call? - 伪位蔚蠂慰位蠀蟿
  • @alexolut 0x555555ea4eb0 like this, if you have done it correctly - Naumov
  • And where is it installed? in get_widget something on the link? - 伪位蔚蠂慰位蠀蟿

1 answer 1

In general, in my case I tried to call get_filename during the execution of the signal. You just have to call get_filename in the callback function. In general, the code acquired the following form:

  chooserButton->signal_file_set().connect( sigc::bind<Php::Value,Gtk::FileChooserButton*>( sigc::mem_fun(*this, &ParserGtk::chooserButtonCallback), callbackChooser, chooserButton ) ); 

and callback function

 /** * choooser button special callback * @param callback php callback function * @param chooserButton gtk filechooserbutton object */ void ParserGtk::chooserButtonCallback(Php::Value callback, Gtk::FileChooserButton *chooserButton) { Php::call("var_dump",chooserButton->get_filename()); callback(chooserButton->get_filename()); }