pub struct SimpleComboBox<E: ToString> {
    pub variants: Vec<E>,
    pub active_index: Option<usize>,
}
Expand description

A simple wrapper around gtk::ComboBox.

This can be used with enums, Strings or any custom type you want. The only requirement is that the inner type implements ToString and Debug.

To get notified when the selection changed, you can use Connector::forward() after launching the component.

Fields§

§variants: Vec<E>

The variants that can be selected.

§active_index: Option<usize>

The index of the active element or None is nothing is selected.

Implementations§

source§

impl<E> SimpleComboBox<E>where E: ToString,

source

pub fn get_active_elem(&self) -> Option<&E>

Return the value of the currently selected element or None if nothing is selected.

Trait Implementations§

source§

impl<E: Clone + ToString> Clone for SimpleComboBox<E>

source§

fn clone(&self) -> SimpleComboBox<E>

Returns a copy 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<E> Component for SimpleComboBox<E>where E: ToString + 'static + Debug,

§

type CommandOutput = ()

Messages which are received from commands executing in the background.
§

type Input = SimpleComboBoxMsg<E>

The message type that the component accepts as inputs.
§

type Output = usize

The message type that the component provides as outputs.
§

type Init = SimpleComboBox<E>

The parameter used to initialize the component.
§

type Root = ComboBoxText

The widget that was constructed by the component.
§

type Widgets = ComboBoxText

The type that’s used for storing widgets created for this component.
source§

fn init_root() -> Self::Root

Initializes the root widget.
source§

fn init( model: Self::Init, root: &Self::Root, sender: ComponentSender<Self> ) -> ComponentParts<Self>

Creates the initial model and view, docking it into the component.
source§

fn update_with_view( &mut self, widgets: &mut Self::Widgets, input: Self::Input, sender: ComponentSender<Self>, _root: &Self::Root )

Updates the model and view when a new input is received. Read more
source§

fn builder() -> ComponentBuilder<Self>

Create a builder for this component.
source§

fn update( &mut self, message: Self::Input, sender: ComponentSender<Self>, root: &Self::Root )

Processes inputs received by the component.
source§

fn update_cmd( &mut self, message: Self::CommandOutput, sender: ComponentSender<Self>, root: &Self::Root )

Defines how the component should respond to command updates.
source§

fn update_cmd_with_view( &mut self, widgets: &mut Self::Widgets, message: Self::CommandOutput, sender: ComponentSender<Self>, root: &Self::Root )

Updates the model and view upon completion of a command. Read more
source§

fn update_view( &self, widgets: &mut Self::Widgets, sender: ComponentSender<Self> )

Updates the view after the model has been updated.
source§

fn shutdown( &mut self, widgets: &mut Self::Widgets, output: Sender<Self::Output> )

Last method called before a component is shut down. Read more
source§

fn id(&self) -> String

An identifier for the component used for debug logging. Read more
source§

impl<E: Debug + ToString> Debug for SimpleComboBox<E>

source§

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

Formats the value using the given formatter. Read more
source§

impl<E: PartialEq + ToString> PartialEq<SimpleComboBox<E>> for SimpleComboBox<E>

source§

fn eq(&self, other: &SimpleComboBox<E>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<E: Eq + ToString> Eq for SimpleComboBox<E>

source§

impl<E: ToString> StructuralEq for SimpleComboBox<E>

source§

impl<E: ToString> StructuralPartialEq for SimpleComboBox<E>

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for SimpleComboBox<E>where E: RefUnwindSafe,

§

impl<E> Send for SimpleComboBox<E>where E: Send,

§

impl<E> Sync for SimpleComboBox<E>where E: Sync,

§

impl<E> Unpin for SimpleComboBox<E>where E: Unpin,

§

impl<E> UnwindSafe for SimpleComboBox<E>where E: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<C> AsyncPosition<()> for C

source§

fn position(_index: usize)

Returns the position. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

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 Twhere U: From<T>,

const: unstable · 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<C> Position<()> for C

source§

fn position(&self, _index: usize)

Returns the position. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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