[][src]Macro gtk_fnonce_on_eventloop::with_gtk

macro_rules! with_gtk {
    ( $struct:ident ) => { ... };
}

Creates some static (thread-local) variables and functions to initialize that storage and to execute closures on the event loop with access to that storage.

Example usage

    pub struct Refs {
        button: gtk::Button,
        // This is possible too
        other_non_send_state : Rc<RefCell<Vec<String>>>
    }


    // Better place the macro with_gtk! in a module, it pollutes its souroundings a bit
    mod r {
        use super::Refs;
        use gtk_fnonce_on_eventloop::with_gtk;
        with_gtk!(Refs);
    }

Generated items

   pub fn init_storage(&Refs);
   pub fn do_in_gtk_eventloop( FnOnce(Rc<Refs>) );

   // And some private stuff which you must ignore
   use std::...;
   use gtk_fnonce_on_eventloop::...;
   type BoxedUiAction = ...;
   type FnAndEvent = ...;
   static (threadlocal) DATA = RefCell<Option<Rc<Refs>>>;
   static (threadlocal) RX = RefCell<Option<Receiver<FnAndEvent>>;
   static               TX = RefCell<Option<Sender<FnAndEvent>>;
   fn handle_one_callback_in_gtk_thread();