Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gtkmm.h>
- #include <iostream>
- class MyWindow : public Gtk::Window {
- public:
- MyWindow();
- protected:
- void on_button_browse_clicked();
- void on_folder_dialog_response(int response_id, Gtk::FileChooserNative* dialog);
- Gtk::Button m_button_browse;};
- void MyWindow::on_button_browse_clicked(){
- auto dialog = Gtk::FileChooserNative::create("Please choose a folder", *this, Gtk::FileChooser::Action::SELECT_FOLDER, "Choose", "Cancel");
- dialog->set_transient_for(*this);
- dialog->set_modal(true);
- dialog->signal_response().connect(sigc::bind(sigc::mem_fun(*this, &MyWindow::on_folder_dialog_response), dialog)); // <- error
- dialog->show();}
- void MyWindow::on_folder_dialog_response(int response_id, Gtk::FileChooserNative* dialog){
- switch (response_id) {
- case Gtk::ResponseType::OK: {std::cout << dialog->get_file()->get_path() << std::endl; break;}
- case Gtk::ResponseType::CANCEL: {std::cout << "Cancel clicked." << response_id << std::endl; break;}
- default: {std::cout << "Unexpected button clicked: " << response_id << std::endl; break;}}}
- MyWindow::MyWindow() : m_button_browse("Browse") {
- set_title("File Order Randomizer");
- m_button_browse.set_margin(10);
- m_button_browse.signal_clicked().connect(sigc::mem_fun(*this,
- &MyWindow::on_button_browse_clicked));
- set_child(m_button_browse);}
- int main(int argc, char* argv[]){
- auto app = Gtk::Application::create("org.gtkmm.examples.base");
- return app->make_window_and_run<MyWindow>(argc, argv);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement