0

When I try to show a file chooser dialog, it is missing the action buttons:

let dialog = FileChooserDialog::new(Some("Open File"), Some(&window), FileChooserAction::Open);
dialog.run();

missing action buttons

I found another way from another project:

let dialog = FileChooserDialog::new_with_buttons::<ApplicationWindow>(
    Some("Open File"),
    Some(&window),
    FileChooserAction::Open,
    &[
        ("_Cancel", ResponseType::Cancel),
        ("_Open", ResponseType::Accept),
    ],
);

The error message is:

no function or associated item named `new_with_buttons` found for type `gtk::FileChooserDialog` in the current scope
Zoe
  • 27,060
  • 21
  • 118
  • 148
鸿则_
  • 314
  • 1
  • 14

1 Answers1

0

I guess you need to use add_button to add the buttons after creating the dialog and before showing it:

let dialog = FileChooserDialog::new(Some("Open File"), Some(&window), FileChooserAction::Open);
dialog.add_button("_Cancel", ResponseType::Cancel);
dialog.add_button("_Open", ResponseType::Accept);
dialog.run();
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Jmb
  • 18,893
  • 2
  • 28
  • 55