ui: open MessageRfc822 attachments in new tab
parent
f72fb069fa
commit
a866e060a1
|
@ -93,7 +93,7 @@ pub trait Component: Display + Debug + Send {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
fn set_dirty(&mut self);
|
fn set_dirty(&mut self);
|
||||||
fn kill(&mut self, _id: ComponentId) {}
|
fn kill(&mut self, _id: ComponentId, _context: &mut Context) {}
|
||||||
fn set_id(&mut self, _id: ComponentId) {}
|
fn set_id(&mut self, _id: ComponentId) {}
|
||||||
fn id(&self) -> ComponentId;
|
fn id(&self) -> ComponentId;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ const MAX_COLS: usize = 500;
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
List,
|
List,
|
||||||
View(CardId),
|
View(CardId),
|
||||||
Close(Uuid),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -158,11 +157,6 @@ impl ContactList {
|
||||||
|
|
||||||
impl Component for ContactList {
|
impl Component for ContactList {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
if let ViewMode::Close(u) = self.mode {
|
|
||||||
context.replies.push_back(UIEvent::Action(Tab(Kill(u))));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(mgr) = self.view.as_mut() {
|
if let Some(mgr) = self.view.as_mut() {
|
||||||
mgr.draw(grid, area, context);
|
mgr.draw(grid, area, context);
|
||||||
return;
|
return;
|
||||||
|
@ -289,8 +283,9 @@ impl Component for ContactList {
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kill(&mut self, uuid: Uuid) {
|
fn kill(&mut self, uuid: Uuid, context: &mut Context) {
|
||||||
self.mode = ViewMode::Close(uuid);
|
debug_assert!(uuid == self.id);
|
||||||
|
context.replies.push_back(UIEvent::Action(Tab(Kill(uuid))));
|
||||||
}
|
}
|
||||||
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
|
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
|
||||||
let mut map = self
|
let mut map = self
|
||||||
|
|
|
@ -65,7 +65,7 @@ impl Component for AccountsPanel {
|
||||||
UIEvent::Input(Key::Char('\n')) => {
|
UIEvent::Input(Key::Char('\n')) => {
|
||||||
context
|
context
|
||||||
.replies
|
.replies
|
||||||
.push_back(UIEvent::Action(Tab(TabOpen(Some(Box::new(
|
.push_back(UIEvent::Action(Tab(New(Some(Box::new(
|
||||||
ContactList::for_account(self.cursor),
|
ContactList::for_account(self.cursor),
|
||||||
))))));
|
))))));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -713,7 +713,7 @@ impl Component for Composer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kill(&mut self, uuid: Uuid) {
|
fn kill(&mut self, uuid: Uuid, _context: &mut Context) {
|
||||||
self.mode = ViewMode::Discard(uuid);
|
self.mode = ViewMode::Discard(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -731,15 +731,16 @@ impl Component for MailView {
|
||||||
if let Some(u) = envelope.body(op).attachments().get(lidx) {
|
if let Some(u) = envelope.body(op).attachments().get(lidx) {
|
||||||
match u.content_type() {
|
match u.content_type() {
|
||||||
ContentType::MessageRfc822 => {
|
ContentType::MessageRfc822 => {
|
||||||
self.mode = ViewMode::Subview;
|
|
||||||
match EnvelopeWrapper::new(u.raw().to_vec()) {
|
match EnvelopeWrapper::new(u.raw().to_vec()) {
|
||||||
Ok(wrapper) => {
|
Ok(wrapper) => {
|
||||||
self.subview = Some(Box::new(EnvelopeView::new(
|
context.replies.push_back(UIEvent::Action(Tab(New(Some(
|
||||||
wrapper,
|
Box::new(EnvelopeView::new(
|
||||||
None,
|
wrapper,
|
||||||
None,
|
None,
|
||||||
self.coordinates.0,
|
None,
|
||||||
)));
|
self.coordinates.0,
|
||||||
|
)),
|
||||||
|
)))));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
context.replies.push_back(UIEvent::StatusEvent(
|
context.replies.push_back(UIEvent::StatusEvent(
|
||||||
|
|
|
@ -555,6 +555,14 @@ impl Component for EnvelopeView {
|
||||||
fn id(&self) -> ComponentId {
|
fn id(&self) -> ComponentId {
|
||||||
self.id
|
self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn kill(&mut self, id: ComponentId, context: &mut Context) {
|
||||||
|
debug_assert!(self.id == id);
|
||||||
|
context
|
||||||
|
.replies
|
||||||
|
.push_back(UIEvent::Action(Tab(Kill(self.id))));
|
||||||
|
}
|
||||||
|
|
||||||
fn set_id(&mut self, id: ComponentId) {
|
fn set_id(&mut self, id: ComponentId) {
|
||||||
self.id = id;
|
self.id = id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1345,7 +1345,7 @@ impl Component for Tabbed {
|
||||||
self.children[self.cursor_pos].set_dirty();
|
self.children[self.cursor_pos].set_dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Action(Tab(TabOpen(ref mut e))) if e.is_some() => {
|
UIEvent::Action(Tab(New(ref mut e))) if e.is_some() => {
|
||||||
self.add_component(e.take().unwrap());
|
self.add_component(e.take().unwrap());
|
||||||
self.cursor_pos = self.children.len() - 1;
|
self.cursor_pos = self.children.len() - 1;
|
||||||
self.children[self.cursor_pos].set_dirty();
|
self.children[self.cursor_pos].set_dirty();
|
||||||
|
@ -1356,7 +1356,7 @@ impl Component for Tabbed {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let id = self.children[self.cursor_pos].id();
|
let id = self.children[self.cursor_pos].id();
|
||||||
self.children[self.cursor_pos].kill(id);
|
self.children[self.cursor_pos].kill(id, context);
|
||||||
self.set_dirty();
|
self.set_dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub enum ListingAction {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum TabAction {
|
pub enum TabAction {
|
||||||
TabOpen(Option<Box<Component>>),
|
New(Option<Box<Component>>),
|
||||||
NewDraft(usize, Option<Draft>),
|
NewDraft(usize, Option<Draft>),
|
||||||
Reply((usize, usize, usize), ThreadHash), // thread coordinates (account, mailbox, root_set idx) and thread hash
|
Reply((usize, usize, usize), ThreadHash), // thread coordinates (account, mailbox, root_set idx) and thread hash
|
||||||
Close,
|
Close,
|
||||||
|
|
Loading…
Reference in New Issue