I'm beginning to learn GTK3 and have hit a roadblock. I declared an array of buttons Gtk::Button buttons[15], and linked them all to the same onClicked() function. Each button contains a unique image. When the user clicks a button, I want to retrieve the file name of the image so I know which button was clicked, the images change periodically, so I haven't given them labels.
// creating the button array
for(int i = 0; i < 15; i++){
Gtk::Image image("nothing.png");
button[i].signal_clicked().connect(sigc::mem_fun(*this,
&Window::doOnButtonClicked));
button[i].set_image(image);
}
//doOnButtonClicked
void Window::doOnButtonClicked(Gtk::Button button){
onClicked(&button);
}
//the onClicked() code
void onClicked(Gtk::Button * button){
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_STRING);
g_object_get_property(G_OBJECT(button->get_image()), "file", &value);
string source = g_value_get_string(&value);
cout<<source;
}
I did try to follow the steps to get the file name of the image as listed here, but I realised that I needed to pass my button to extract the Image object, so, I followed the steps in this to pass in the button object to the function.
But right now I have the following errors :
error: return-statement with a value, in function returning 'void' [-fpermissive] { return functor_(); }
no match for call to ‘(sigc::bound_mem_functor1) ()’ { return functor_(); }
Thanks for all the help in advance