I was unable to reproduce your error on my system. May be you have something missing from your install which is not monitoring the changes in the file system.
Note in your original code you have done some possible errors. First you should return 0 from main unless you really want to indicate to the operating system that the application had an error. Try to avoid the use of "using namespace", this is considered bad practice and defeats the point of name spaces.
I have also re-written your code to use gtkmm, which is the C++ binding for GTK since you are using C++. This is just an example and does not have full error checking.
Use this to compile (I am using gtkmm 3, this should also work with gtkmm 2 if you substitute gtkmm-2.4 instead of gtkmm-3.0)
Code:
gcc chisr.cc `pkg-config --libs --cflags gtkmm-3.0` -o chisr
Code:
#include<iostream>
#include<gtkmm.h>
Gtk::Window *window;
void insertFromListCb()
{
Gtk::FileChooserDialog dialog(*window, "Open File");
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
if (dialog.run() == Gtk::RESPONSE_ACCEPT) {
std::cout << "filename = " << dialog.get_filename() << std::endl;
}
}
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
Gtk::Button *insert;
Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file("temp.xml");
builder->get_widget("window", window);
builder->get_widget("insert", insert);
insert->signal_clicked().connect(sigc::ptr_fun(&insertFromListCb));
window->show_all();
kit.run(*window);
return 0;
}