ladybird/Userland/Libraries/LibGUI/FilePickerDialog.gml
Marcus Nilsson be464c357a LibGUI: Add allowed file types to FilePicker
This patch adds a ComboBox to `FilePicker` where the user can select
which file types to show, all files that doesn't have an
extension that's in the selected file type will be hidden.

When creating a FilePicker with `FilePicker::construct` or
`FilePicker::get_open_filepath`, allowed file types can be
specified as the last argument.

If no file types are provided then there will be no visual change in the
GUI.

'All Files' and 'Image Files' have shorthands with
`GUI::FileTypeFilter::all_files()` and
`GUI::FileTypeFilter::image_files()`, respectively.
2023-02-02 04:05:42 -07:00

97 lines
2.2 KiB
Plaintext

@GUI::Widget {
fill_with_background_color: true
layout: @GUI::HorizontalBoxLayout {
margins: [4]
spacing: 3
}
@GUI::Widget {
preferred_width: 103
layout: @GUI::VerticalBoxLayout {
margins: [0, 4]
}
@GUI::Label {
text: "Look in:"
text_alignment: "CenterRight"
fixed_height: 24
}
@GUI::Tray {
name: "common_locations_tray"
min_width: 60
}
@GUI::Label {
text: "Filename:"
text_alignment: "CenterRight"
fixed_height: 22
}
@GUI::Label {
name: "allowed_file_types_label"
text: "Files of Type:"
text_alignment: "CenterRight"
fixed_height: 22
}
}
@GUI::Widget {
layout: @GUI::VerticalBoxLayout {}
@GUI::Widget {
preferred_height: "fit"
layout: @GUI::HorizontalBoxLayout {}
@GUI::TextBox {
name: "location_textbox"
preferred_width: "opportunistic_grow"
min_width: 80
}
@GUI::Toolbar {
name: "toolbar"
preferred_width: "shrink"
}
}
@GUI::MultiView {
name: "view"
}
@GUI::Widget {
preferred_height: "fit"
layout: @GUI::VerticalBoxLayout {}
@GUI::Widget {
fixed_height: 22
layout: @GUI::HorizontalBoxLayout {}
@GUI::TextBox {
name: "filename_textbox"
}
@GUI::DialogButton {
name: "ok_button"
text: "OK"
}
}
@GUI::Widget {
fixed_height: 22
layout: @GUI::HorizontalBoxLayout {}
@GUI::ComboBox {
name: "allowed_file_type_filters_combo"
model_only: true
}
@GUI::DialogButton {
name: "cancel_button"
text: "Cancel"
}
}
}
}
}