mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
keep original header to have re-send ability
This commit is contained in:
parent
c90ec34ccc
commit
faac9c60fe
3 changed files with 9 additions and 9 deletions
|
|
@ -18,10 +18,10 @@ pub trait Titan {
|
||||||
impl Titan for gtk::Box {
|
impl Titan for gtk::Box {
|
||||||
fn titan(callback: impl Fn(Header, Bytes, Box<dyn Fn()>) + 'static) -> Self {
|
fn titan(callback: impl Fn(Header, Bytes, Box<dyn Fn()>) + 'static) -> Self {
|
||||||
use gtk::{glib::uuid_string_random, prelude::ButtonExt, Label, TextView};
|
use gtk::{glib::uuid_string_random, prelude::ButtonExt, Label, TextView};
|
||||||
use std::{cell::Cell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let header = Rc::new(Cell::new(Header {
|
let header = Rc::new(RefCell::new(Header {
|
||||||
mime: None,
|
mime: None,
|
||||||
token: None,
|
token: None,
|
||||||
}));
|
}));
|
||||||
|
|
@ -79,7 +79,7 @@ impl Titan for gtk::Box {
|
||||||
use control::Upload;
|
use control::Upload;
|
||||||
this.set_uploading();
|
this.set_uploading();
|
||||||
callback(
|
callback(
|
||||||
header.take(), // @TODO copy?
|
header.borrow().clone(), // keep original header to have re-send ability
|
||||||
match notebook.current_page().unwrap() {
|
match notebook.current_page().unwrap() {
|
||||||
0 => text.to_bytes(),
|
0 => text.to_bytes(),
|
||||||
1 => file.to_bytes().unwrap(),
|
1 => file.to_bytes().unwrap(),
|
||||||
|
|
@ -87,7 +87,7 @@ impl Titan for gtk::Box {
|
||||||
},
|
},
|
||||||
Box::new({
|
Box::new({
|
||||||
let this = this.clone();
|
let this = this.clone();
|
||||||
move || this.set_resend() // on failure
|
move || this.set_resend() // re-activate button on failure
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use gtk::{
|
||||||
Align, Box, Button, Label, Orientation,
|
Align, Box, Button, Label, Orientation,
|
||||||
};
|
};
|
||||||
use options::Options;
|
use options::Options;
|
||||||
use std::{cell::Cell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
pub use upload::Upload;
|
pub use upload::Upload;
|
||||||
|
|
||||||
pub struct Control {
|
pub struct Control {
|
||||||
|
|
@ -22,7 +22,7 @@ impl Control {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
/// Build new `Self`
|
/// Build new `Self`
|
||||||
pub fn build(header: &Rc<Cell<Header>>) -> Self {
|
pub fn build(header: &Rc<RefCell<Header>>) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let counter = Label::counter();
|
let counter = Label::counter();
|
||||||
let options = Button::options(header);
|
let options = Button::options(header);
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@ use gtk::{
|
||||||
prelude::{ButtonExt, WidgetExt},
|
prelude::{ButtonExt, WidgetExt},
|
||||||
Button,
|
Button,
|
||||||
};
|
};
|
||||||
use std::{cell::Cell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
pub trait Options {
|
pub trait Options {
|
||||||
fn options(header: &Rc<Cell<Header>>) -> Self;
|
fn options(header: &Rc<RefCell<Header>>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options for Button {
|
impl Options for Button {
|
||||||
fn options(header: &Rc<Cell<Header>>) -> Self {
|
fn options(header: &Rc<RefCell<Header>>) -> Self {
|
||||||
let button = Button::builder()
|
let button = Button::builder()
|
||||||
.icon_name("emblem-system-symbolic")
|
.icon_name("emblem-system-symbolic")
|
||||||
.tooltip_text("Options")
|
.tooltip_text("Options")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue