[−][src]Struct woab::Factory
Holds instructions for generating GTK widgets and connecing them to Actix actors.
- The first generic parameter,
A
, is the actor type. - The second generic parameter,
W
, is the widgets type. Typically created with#[derive(woab::WidgetsFromBuilder)]
on a struct that specifies the widgets of the Glade XML file that the code needs to access. - The third generic parameter,
S
, is the signal type. Typically created with#[derive(woab::BuilderSignal)]
on an enum that lists the signals from the Glade XML file that the code wants to handle.
A
can be ()
if the widgets are to be handled by an existing actor - usually the one that
handles their parent widget. S
can also be ()
if it is desired to just generate widgets
without connecting a signal.
Refer to #[derive(woab::Factories)]
for how to create instances of
this struct.
#[derive(woab::Factories)] struct Factories { window: woab::Factory<WindowActor, WindowWidgets, WindowSignal>, row: woab::Factory<(), RowWidgets, RowSignal>, } struct WindowActor { widgets: WindowWidgets, } impl actix::StreamHandler<WindowSignal> for WindowActor { fn handle(&mut self, signal: WindowSignal, _ctx: &mut <Self as actix::Actor>::Context) { match signal { // Handle the signals of the main window } } } #[derive(woab::WidgetsFromBuilder)] struct WindowWidgets { window: gtk::ApplicationWindow, list_box: gtk::ListBox, } #[derive(woab::WidgetsFromBuilder)] struct RowWidgets { row: gtk::ListBoxRow, label: gtk::Label, } impl actix::StreamHandler<(usize, RowSignal)> for WindowActor { fn handle(&mut self, (row_number, signal): (usize, RowSignal), _ctx: &mut <Self as actix::Actor>::Context) { match signal { // Handle the signals of row #row_number } } // ****************************************************** // * VERY IMPORTANT! Otherwise once one row is deleted, * // * its signal stream will be closed and the default * // * implementation will close the WindowActor. * // ****************************************************** fn finished(&mut self, _ctx: &mut Self::Context) {} } fn create_window_with_rows(factory: &Factories) { factory.window.build().actor(|ctx, widgets| { for row_number in 0..10 { let row_widgets = factory.row.build() .connect_tagged_builder_signals(ctx, row_number) .widgets().unwrap(); row_widgets.label.set_text(&format!("Roe number {}", row_number)); widgets.list_box.add(&row_widgets.row); } WindowActor { widgets } }).unwrap(); }
Implementations
impl<A, W, S> Factory<A, W, S>
[src]
pub fn build(&self) -> BuilderUtilizer<A, W, S>
[src]
Create the gtk::Builder
(inside a woab::BuilderUtilizer
)
Note that this causes the GTK widgets to be created (but not to be shown or be connected to anything)
Trait Implementations
Auto Trait Implementations
impl<A, W, S> RefUnwindSafe for Factory<A, W, S> where
A: RefUnwindSafe,
S: RefUnwindSafe,
W: RefUnwindSafe,
A: RefUnwindSafe,
S: RefUnwindSafe,
W: RefUnwindSafe,
impl<A, W, S> Send for Factory<A, W, S> where
A: Send,
S: Send,
W: Send,
A: Send,
S: Send,
W: Send,
impl<A, W, S> Sync for Factory<A, W, S> where
A: Sync,
S: Sync,
W: Sync,
A: Sync,
S: Sync,
W: Sync,
impl<A, W, S> Unpin for Factory<A, W, S> where
A: Unpin,
S: Unpin,
W: Unpin,
A: Unpin,
S: Unpin,
W: Unpin,
impl<A, W, S> UnwindSafe for Factory<A, W, S> where
A: UnwindSafe,
S: UnwindSafe,
W: UnwindSafe,
A: UnwindSafe,
S: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,