Skip to main content

FilePicker

Struct FilePicker 

Source
pub struct FilePicker {
Show 18 fields pub kind: ChooseKind, pub dir: PathBuf, pub filters: Vec<FileFilter>, pub filter_index: usize, pub text: String, pub highlight: usize, pub selected: BTreeSet<PathBuf>, pub show_hidden: bool, pub show_preview: bool, pub pane_width: f32, pub view: PickerView, pub dialog: String, pub thumbnail_size: f32, pub sort: PickerSort, pub folders_first: bool, pub grouped: bool, pub fill: bool, pub error: Option<String>, /* private fields */
}
Expand description

The in-app picker: a folder’s entries, a field that filters them (fuzzy) or takes a typed path (with completion), places, filters. Usable on its own: FilePicker::show in any Ui.

Fields§

§kind: ChooseKind§dir: PathBuf

The folder shown.

§filters: Vec<FileFilter>§filter_index: usize

The filter in use (filters.len(): all files).

§text: String

The field: a filter, or a path when it holds a separator or starts with ~.

§highlight: usize

The entry highlighted among those shown: where the arrows are, what the preview is of, and what Enter acts on. The picker’s browser focus, read after each step; set it and the browser focuses that entry at the next.

§selected: BTreeSet<PathBuf>

What is selected, in the folder shown: files (choosing several), or one folder (choosing a folder, or saving: Enter goes into it). The picker’s browser selection, kept to its SelectionPolicy and read after each step; set it and the browser selects what the policy lets at the next.

§show_hidden: bool§show_preview: bool

The preview pane is shown (with previews, FilePicker::with_previews).

§pane_width: f32

The preview pane’s width, as wanted: the room in the dialog may hold it smaller.

§view: PickerView

How the entries are shown.

§dialog: String

The dialog its view is kept under (dialog_of).

§thumbnail_size: f32

The thumbnails’ side in the grid, in points, as last drawn from the zoom (FilePicker::zoom). Set to another size, it becomes the zoom at the next draw (the count per row it gives there).

§sort: PickerSort

The order of the entries, in the list and in the grid.

§folders_first: bool

Folders come before files in every order.

§grouped: bool

Files that go together are one entry, with groupings declared (FilePicker::with_grouping) and when opening files.

§fill: bool

The list takes the height left in the Ui it is drawn in (a dialog of a given size), rather than LIST_HEIGHT.

§error: Option<String>

Why the last Enter did nothing.

Implementations§

Source§

impl FilePicker

Source

pub fn new(request: &FileRequest) -> Self

A picker for a request, in its folder (else home, else the root), on the system’s file system.

Source

pub fn new_in(request: &FileRequest, fs: SharedFs) -> Self

A picker for a request reading from fs, in the request’s folder (else home, else the root).

Source

pub fn choices(&self) -> &ChoiceValues

The application’s choices (FileRequest::choice) as they stand: each id with its value.

Source

pub fn set_choice(&mut self, id: &str, value: &str) -> Result<(), String>

Sets one of the application’s choices; refused for an id the request does not have or a value it cannot take.

Source

pub fn with_previews(self, previews: Previews) -> Self

Shows the selected entry’s preview in a pane beside the list, from these providers (Alt+P hides it).

Source

pub fn with_resize(self, resize: GridResize) -> Self

What its grid’s zoom means when the grid is resized (browser::GridResize::PerRow by default).

Source

pub fn resize(&self) -> GridResize

What its grid’s zoom means when the grid is resized.

Source

pub fn with_grouping(self, groupings: Groupings) -> Self

Files that go together are one entry, by these groupings (groups). Drawn on its own, the picker answers with the main files: its caller reads the others with group_of.

Source

pub fn group_of(&self, path: &Path) -> Option<&FileGroup>

The group a file heads, in the folder as last listed.

Source

pub fn highlighted(&mut self) -> Option<Entry>

The entry the preview is of: the highlighted one.

Source

pub fn file_system(&self) -> &SharedFs

Where it reads.

Source

pub fn go(&mut self, dir: PathBuf)

Shows another folder; the selection stays behind.

Source

pub fn go_back(&mut self) -> bool

Goes back to the folder shown before; says whether there was one.

Source

pub fn go_forward(&mut self) -> bool

Goes forward to the folder gone back from; says whether there was one.

Source

pub fn reload(&mut self)

Reads the folder again, and the facts of its files.

Source

pub fn up(&mut self)

Shows the parent folder.

Source

pub fn entries(&mut self) -> Vec<Entry>

The folder’s entries in the picker’s order, those the filter accepts (folders whatever the filter; none but folders when choosing a folder), hidden ones only when asked, those the field’s text matches best first. The folder is listed through a browser::FileBrowser, off the interface thread on the system’s file system: its entries come in over the next frames.

Source

pub fn loading(&self) -> bool

Whether the folder’s listing, or its groups, are still under way.

Source

pub fn set_grouped(&mut self, on: bool)

Groups files or leaves each its own entry: the highlight stays on its entry, or goes to the group that takes it in, and a member selected leaves the selection for what its group’s entry stands for.

Source

pub fn set_sort(&mut self, sort: PickerSort)

Takes another order; the highlighted entry stays highlighted, wherever it lands, and comes into view.

Source

pub fn set_folders_first(&mut self, on: bool)

Keeps folders first, or sorts them among the files; the highlighted entry stays highlighted, wherever it lands, and comes into view.

Source

pub fn edit_path(&mut self)

Ctrl+L: the folder goes into the field, as a path to edit, and the field takes the focus; a path already typed stays. Saving, the name stays at the path’s end with its stem selected, and comes back if the path leads to another folder instead.

Source

pub fn is_path(&self) -> bool

Whether the field holds a path rather than a filter.

Source

pub fn typed_path(&self) -> PathBuf

The field as a path: ~ is home, a relative path is in the folder.

Source

pub fn visible(&mut self) -> Vec<Entry>

The entries shown: entries, the field’s text ranking them.

Source

pub fn completions(&self) -> Vec<String>

What a typed path may complete to: the names in its folder its last part starts (folders end with a separator).

Source

pub fn complete(&mut self) -> bool

Completes the typed path (Tab): to the only completion, else to what every completion shares. Says whether the text changed.

Source

pub fn activate(&mut self) -> Option<PickerAnswer>

Enter: into a folder, or the choice. Saving, the folder selected goes first: otherwise the field’s name is what Enter takes.

Source

pub fn set_filter(&mut self, index: usize)

Takes another filter (filters.len(): all files). Saving, a name whose extension one of the request’s filters names takes the new filter’s first, unless the new filter accepts it too; an extension no filter names is the person’s and stays, and so does the name under a filter without extensions.

Source

pub fn begin_new_folder(&mut self) -> Result<(), String>

Asks the new folder’s name, in a row under the folder: Enter makes it, Escape closes the row. Without a file system that can make one, the reason is the picker’s error, and the result.

Source

pub fn create_folder(&mut self, name: &str) -> Result<PathBuf, String>

Makes a folder in the one shown, and goes into it. A refusal is the picker’s error, and the result.

Source

pub fn accept(&mut self) -> Option<PickerAnswer>

Ctrl+Enter, and the primary button: the folder (choosing a folder), the selection, the field’s name (saving: a folder selected does not turn Save into Open), or what Enter would choose.

Source

pub fn toggle(&mut self)

Selects or unselects the highlighted entry: a file choosing several (a folder is refused, the reason in error), a folder choosing one. Does nothing in the other kinds, which have no key for it.

Source

pub fn select_all(&mut self) -> Result<(), String>

Selects every file shown (choosing several). None to select is a refusal: the reason is the picker’s error, and the result.

Source

pub fn primary(&mut self) -> Primary

What the primary button does now: its label, the readout of what it takes (announced when it changes), and why it is off, when it is.

Source

pub fn empty_state(&self) -> EmptyState

What the list says when it shows nothing, and the way out it offers.

Source

pub fn describe(&mut self) -> Json

The picker as the bridge shows it.

Source

pub fn show(&mut self, ui: &mut Ui, places: &Places) -> Option<PickerAnswer>

Draws the picker; its answer when given. Drawn to fill its room (fill, a dialog), its footer keeps its whole height at the bottom and what is above it scrolls when the room runs short (overlay::DialogLayout).

Source§

impl FilePicker

Source

pub fn zoom(&self) -> ThumbZoom

How many thumbnails fill a row of the grid.

Source

pub fn set_zoom(&mut self, zoom: ThumbZoom)

A new zoom for the grid; the highlighted cell stays in view.

Source

pub fn views(&self) -> Vec<PickerView>

The views it offers, in the switcher’s order: details; thumbnails with previews; columns when choosing a folder.

Source

pub fn set_mode_index(&mut self, n: usize) -> bool

Shows the n-th mode (from 1, among Self::views), as Ctrl+n does; false without such a mode, or with one view alone.

Trait Implementations§

Source§

impl Clone for FilePicker

Source§

fn clone(&self) -> FilePicker

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FilePicker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,