From ab3e01359a077805b7f902a1d746ec5fc0ac1705 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sat, 14 Dec 2019 18:50:05 +0200 Subject: [PATCH] ui/Component: change set_dirty() to set_dirty(value) Next commit will need to set a child component as not dirty so we need set_dirty(value) instead of set_dirty() that always sets is to true. --- ui/src/components.rs | 2 +- ui/src/components/contacts.rs | 14 ++-- ui/src/components/contacts/contact_list.rs | 30 +++---- ui/src/components/indexer.rs | 4 +- ui/src/components/indexer/index.rs | 16 ++-- ui/src/components/mail/compose.rs | 20 ++--- ui/src/components/mail/listing.rs | 20 ++--- ui/src/components/mail/listing/compact.rs | 14 ++-- .../components/mail/listing/conversations.rs | 14 ++-- ui/src/components/mail/listing/plain.rs | 14 ++-- ui/src/components/mail/listing/thread.rs | 12 +-- ui/src/components/mail/status.rs | 10 +-- ui/src/components/mail/view.rs | 24 +++--- ui/src/components/mail/view/envelope.rs | 4 +- ui/src/components/mail/view/html.rs | 4 +- ui/src/components/mail/view/thread.rs | 16 ++-- ui/src/components/notifications.rs | 10 +-- ui/src/components/utilities.rs | 81 ++++++++++--------- ui/src/components/utilities/widgets.rs | 28 +++---- 19 files changed, 168 insertions(+), 169 deletions(-) diff --git a/ui/src/components.rs b/ui/src/components.rs index e5018fbd8..efc03da91 100644 --- a/ui/src/components.rs +++ b/ui/src/components.rs @@ -93,7 +93,7 @@ pub trait Component: Display + Debug + Send { fn can_quit_cleanly(&mut self, _context: &Context) -> bool { true } - fn set_dirty(&mut self); + fn set_dirty(&mut self, value: bool); fn kill(&mut self, _id: ComponentId, _context: &mut Context) {} fn set_id(&mut self, _id: ComponentId) {} fn id(&self) -> ComponentId; diff --git a/ui/src/components/contacts.rs b/ui/src/components/contacts.rs index 4eef427c6..91907a58c 100644 --- a/ui/src/components/contacts.rs +++ b/ui/src/components/contacts.rs @@ -194,7 +194,7 @@ impl Component for ContactManager { _ => {} } } - self.set_dirty(); + self.set_dirty(true); return true; } } @@ -240,7 +240,7 @@ impl Component for ContactManager { context.replies.push_back(UIEvent::ComponentKill(self.id)); } } - self.set_dirty(); + self.set_dirty(true); if let UIEvent::InsertInput(_) = event { self.has_changes = true; } @@ -269,11 +269,11 @@ impl Component for ContactManager { } } - fn set_dirty(&mut self) { - self.dirty = true; - self.form.set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.dirty = value; + self.form.set_dirty(value); if let ViewMode::Discard(ref mut selector) = self.mode { - selector.set_dirty(); + selector.set_dirty(value); } } @@ -301,7 +301,7 @@ impl Component for ContactManager { true, context, )); - self.set_dirty(); + self.set_dirty(true); false } } diff --git a/ui/src/components/contacts/contact_list.rs b/ui/src/components/contacts/contact_list.rs index 89d60bab5..a79d4cfd6 100644 --- a/ui/src/components/contacts/contact_list.rs +++ b/ui/src/components/contacts/contact_list.rs @@ -656,7 +656,7 @@ impl Component for ContactList { } if self.account_pos + amount < self.accounts.len() { self.account_pos += amount; - self.set_dirty(); + self.set_dirty(true); self.initialized = false; self.cursor_pos = 0; self.new_cursor_pos = 0; @@ -693,7 +693,7 @@ impl Component for ContactList { } if self.account_pos >= amount { self.account_pos -= amount; - self.set_dirty(); + self.set_dirty(true); self.cursor_pos = 0; self.new_cursor_pos = 0; self.length = 0; @@ -710,7 +710,7 @@ impl Component for ContactList { if shortcut!(k == shortcuts[Self::DESCRIPTION]["toggle_menu_visibility"]) => { self.menu_visibility = !self.menu_visibility; - self.set_dirty(); + self.set_dirty(true); } UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt('')) => { self.cmd_buf.clear(); @@ -747,7 +747,7 @@ impl Component for ContactList { return true; }; self.movement = Some(PageMovement::Up(amount)); - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -769,7 +769,7 @@ impl Component for ContactList { .push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); return true; }; - self.set_dirty(); + self.set_dirty(true); self.movement = Some(PageMovement::Down(amount)); return true; } @@ -789,7 +789,7 @@ impl Component for ContactList { .push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); return true; }; - self.set_dirty(); + self.set_dirty(true); self.movement = Some(PageMovement::PageUp(mult)); return true; } @@ -809,17 +809,17 @@ impl Component for ContactList { .push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); return true; }; - self.set_dirty(); + self.set_dirty(true); self.movement = Some(PageMovement::PageDown(mult)); return true; } UIEvent::Input(ref key) if *key == Key::Home => { - self.set_dirty(); + self.set_dirty(true); self.movement = Some(PageMovement::Home); return true; } UIEvent::Input(ref key) if *key == Key::End => { - self.set_dirty(); + self.set_dirty(true); self.movement = Some(PageMovement::End); return true; } @@ -830,14 +830,14 @@ impl Component for ContactList { UIEvent::ComponentKill(ref kill_id) if self.mode == ViewMode::View(*kill_id) => { self.mode = ViewMode::List; self.view.take(); - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::ChangeMode(UIMode::Normal) => { - self.set_dirty(); + self.set_dirty(true); } UIEvent::Resize => { - self.set_dirty(); + self.set_dirty(true); } _ => {} } @@ -849,11 +849,11 @@ impl Component for ContactList { self.dirty || self.view.as_ref().map(|v| v.is_dirty()).unwrap_or(false) } - fn set_dirty(&mut self) { + fn set_dirty(&mut self, value: bool) { if let Some(p) = self.view.as_mut() { - p.set_dirty(); + p.set_dirty(value); }; - self.dirty = true; + self.dirty = value; } fn kill(&mut self, uuid: Uuid, context: &mut Context) { diff --git a/ui/src/components/indexer.rs b/ui/src/components/indexer.rs index 6a1bdf1fc..150caa85a 100644 --- a/ui/src/components/indexer.rs +++ b/ui/src/components/indexer.rs @@ -124,8 +124,8 @@ impl Component for Indexer { self.dirty } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn id(&self) -> ComponentId { diff --git a/ui/src/components/indexer/index.rs b/ui/src/components/indexer/index.rs index 585b37038..731e5361a 100644 --- a/ui/src/components/indexer/index.rs +++ b/ui/src/components/indexer/index.rs @@ -131,32 +131,32 @@ impl Component for Index { UIEvent::Input(Key::Up) => { if self.cursor_pos > 0 { self.new_cursor_pos = self.new_cursor_pos.saturating_sub(1); - self.set_dirty(); + self.set_dirty(true); } return true; } UIEvent::Input(Key::Down) => { if self.length > 0 && self.new_cursor_pos < self.length - 1 { self.new_cursor_pos += 1; - self.set_dirty(); + self.set_dirty(true); } return true; } UIEvent::Input(Key::Char('\n')) if self.state == IndexState::Listing => { self.state = IndexState::Unfocused; - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(Key::Char('i')) if self.state == IndexState::Unfocused => { self.state = IndexState::Listing; - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::ChangeMode(UIMode::Normal) => { - self.set_dirty(); + self.set_dirty(true); } UIEvent::Resize => { - self.set_dirty(); + self.set_dirty(true); } _ => {} } @@ -166,8 +166,8 @@ impl Component for Index { fn is_dirty(&self) -> bool { self.dirty || self.content.is_dirty() } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn id(&self) -> ComponentId { diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index 124295780..8f2838dea 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -507,7 +507,7 @@ impl Component for Composer { } } else { self.embed_area = (upper_left!(header_area), bottom_right!(body_area)); - self.pager.set_dirty(); + self.pager.set_dirty(true); self.pager.draw(grid, body_area, context); } @@ -642,7 +642,7 @@ impl Component for Composer { } _ => {} } - self.set_dirty(); + self.set_dirty(true); } return true; } @@ -661,7 +661,7 @@ impl Component for Composer { match *event { UIEvent::Resize => { - self.set_dirty(); + self.set_dirty(true); } /* /* Switch e-mail From: field to the `left` configured account. */ @@ -812,7 +812,7 @@ impl Component for Composer { } } } - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -830,7 +830,7 @@ impl Component for Composer { context .replies .push_back(UIEvent::ChangeMode(UIMode::Embed)); - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -997,10 +997,10 @@ impl Component for Composer { } } - fn set_dirty(&mut self) { - self.dirty = true; - self.pager.set_dirty(); - self.form.set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.dirty = value; + self.pager.set_dirty(value); + self.form.set_dirty(value); } fn kill(&mut self, uuid: Uuid, context: &mut Context) { @@ -1063,7 +1063,7 @@ impl Component for Composer { context, ), ); - self.set_dirty(); + self.set_dirty(true); false } } diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index bd705499a..a44c6ac66 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -387,7 +387,7 @@ impl Component for Listing { self.cursor_pos.1 += amount; self.component .set_coordinates((self.cursor_pos.0, self.cursor_pos.1)); - self.set_dirty(); + self.set_dirty(true); } else { return true; } @@ -397,7 +397,7 @@ impl Component for Listing { self.cursor_pos.1 -= amount; self.component .set_coordinates((self.cursor_pos.0, self.cursor_pos.1)); - self.set_dirty(); + self.set_dirty(true); } else { return true; } @@ -451,7 +451,7 @@ impl Component for Listing { if self.cursor_pos.0 + amount < self.accounts.len() { self.cursor_pos = (self.cursor_pos.0 + amount, 0); self.component.set_coordinates((self.cursor_pos.0, 0)); - self.set_dirty(); + self.set_dirty(true); } else { return true; } @@ -460,7 +460,7 @@ impl Component for Listing { if self.cursor_pos.0 >= amount { self.cursor_pos = (self.cursor_pos.0 - amount, 0); self.component.set_coordinates((self.cursor_pos.0, 0)); - self.set_dirty(); + self.set_dirty(true); } else { return true; } @@ -520,7 +520,7 @@ impl Component for Listing { for i in focused { self.component.perform_action(context, i, a); } - self.component.set_dirty(); + self.component.set_dirty(true); return true; } _ => {} @@ -545,7 +545,7 @@ impl Component for Listing { self.dirty = true; } UIEvent::Resize => { - self.set_dirty(); + self.set_dirty(true); } UIEvent::Input(ref key) if shortcut!(key == shortcuts[Listing::DESCRIPTION]["scroll_up"]) => @@ -643,7 +643,7 @@ impl Component for Listing { if shortcut!(k == shortcuts[Listing::DESCRIPTION]["toggle_menu_visibility"]) => { self.menu_visibility = !self.menu_visibility; - self.set_dirty(); + self.set_dirty(true); } UIEvent::Input(ref k) if shortcut!(k == shortcuts[Listing::DESCRIPTION]["new_mail"]) => @@ -711,9 +711,9 @@ impl Component for Listing { fn is_dirty(&self) -> bool { self.dirty || self.component.is_dirty() } - fn set_dirty(&mut self) { - self.dirty = true; - self.component.set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.dirty = value; + self.component.set_dirty(value); } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index 89015609a..e4965fc86 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -499,7 +499,7 @@ impl ListingTrait for CompactListing { fn set_movement(&mut self, mvm: PageMovement) { self.movement = Some(mvm); - self.set_dirty(); + self.set_dirty(true); } } @@ -1335,14 +1335,14 @@ impl Component for CompactListing { ) => { self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); } UIEvent::StartupCheck(ref f) if *f == context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] => { self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); } UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { let account = &context.accounts[self.cursor_pos.0]; @@ -1398,7 +1398,7 @@ impl Component for CompactListing { UIEvent::Input(Key::Esc) if !self.unfocused && !self.filter_term.is_empty() => { self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1)); self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Action(ref action) => match action { @@ -1433,11 +1433,11 @@ impl Component for CompactListing { false } } - fn set_dirty(&mut self) { + fn set_dirty(&mut self, value: bool) { + self.dirty = value; if self.unfocused { - self.view.set_dirty(); + self.view.set_dirty(value); } - self.dirty = true; } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs index 9cfd2543b..92c188481 100644 --- a/ui/src/components/mail/listing/conversations.rs +++ b/ui/src/components/mail/listing/conversations.rs @@ -469,7 +469,7 @@ impl ListingTrait for ConversationsListing { fn set_movement(&mut self, mvm: PageMovement) { self.movement = Some(mvm); - self.set_dirty(); + self.set_dirty(true); } } @@ -1353,14 +1353,14 @@ impl Component for ConversationsListing { ) => { self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); } UIEvent::StartupCheck(ref f) if *f == context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] => { self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); } UIEvent::ChangeMode(UIMode::Normal) => { self.dirty = true; @@ -1395,7 +1395,7 @@ impl Component for ConversationsListing { self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1)); self.refresh_mailbox(context); self.force_draw = false; - self.set_dirty(); + self.set_dirty(true); return true; } _ => {} @@ -1411,11 +1411,11 @@ impl Component for ConversationsListing { false } } - fn set_dirty(&mut self) { + fn set_dirty(&mut self, value: bool) { if self.unfocused { - self.view.set_dirty(); + self.view.set_dirty(value); } - self.dirty = true; + self.dirty = value; } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs index be72d6d8b..e18b85f8c 100644 --- a/ui/src/components/mail/listing/plain.rs +++ b/ui/src/components/mail/listing/plain.rs @@ -451,7 +451,7 @@ impl ListingTrait for PlainListing { fn set_movement(&mut self, mvm: PageMovement) { self.movement = Some(mvm); - self.set_dirty(); + self.set_dirty(true); } } @@ -1112,14 +1112,14 @@ impl Component for PlainListing { ) => { self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); } UIEvent::StartupCheck(ref f) if *f == context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] => { self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); } UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { let account = &context.accounts[self.cursor_pos.0]; @@ -1156,7 +1156,7 @@ impl Component for PlainListing { } UIEvent::Input(Key::Esc) if !self.unfocused && !self.filter_term.is_empty() => { self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1)); - self.set_dirty(); + self.set_dirty(true); self.refresh_mailbox(context); return true; } @@ -1192,11 +1192,11 @@ impl Component for PlainListing { false } } - fn set_dirty(&mut self) { + fn set_dirty(&mut self, value: bool) { + self.dirty = value; if self.unfocused { - self.view.set_dirty(); + self.view.set_dirty(value); } - self.dirty = true; } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs index 5312c93eb..3754dd232 100644 --- a/ui/src/components/mail/listing/thread.rs +++ b/ui/src/components/mail/listing/thread.rs @@ -216,7 +216,7 @@ impl ListingTrait for ThreadListing { fn set_movement(&mut self, mvm: PageMovement) { self.movement = Some(mvm); - self.set_dirty(); + self.set_dirty(true); } } @@ -628,7 +628,7 @@ impl Component for ThreadListing { ) => { self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); } UIEvent::StartupCheck(ref f) if *f @@ -636,7 +636,7 @@ impl Component for ThreadListing { [self.new_cursor_pos.1] => { self.refresh_mailbox(context); - self.set_dirty(); + self.set_dirty(true); } UIEvent::ChangeMode(UIMode::Normal) => { self.dirty = true; @@ -674,11 +674,11 @@ impl Component for ThreadListing { fn is_dirty(&self) -> bool { self.dirty || self.view.as_ref().map(|p| p.is_dirty()).unwrap_or(false) } - fn set_dirty(&mut self) { + fn set_dirty(&mut self, value: bool) { if let Some(p) = self.view.as_mut() { - p.set_dirty(); + p.set_dirty(value); }; - self.dirty = true; + self.dirty = value; } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { self.view diff --git a/ui/src/components/mail/status.rs b/ui/src/components/mail/status.rs index e803462ce..653e58985 100644 --- a/ui/src/components/mail/status.rs +++ b/ui/src/components/mail/status.rs @@ -208,10 +208,10 @@ impl Component for StatusPanel { fn is_dirty(&self) -> bool { self.dirty || self.status.as_ref().map(|s| s.is_dirty()).unwrap_or(false) } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; if let Some(ref mut status) = self.status { - status.set_dirty(); + status.set_dirty(value); } } @@ -575,8 +575,8 @@ impl Component for AccountStatus { fn is_dirty(&self) -> bool { self.dirty } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn id(&self) -> ComponentId { diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index fe5369ba1..f8d119987 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -269,7 +269,7 @@ impl MailView { pub fn update(&mut self, new_coordinates: (usize, usize, EnvelopeHash)) { self.coordinates = new_coordinates; self.mode = ViewMode::Normal; - self.set_dirty(); + self.set_dirty(true); } } @@ -615,7 +615,7 @@ impl Component for MailView { } } } - self.set_dirty(); + self.set_dirty(true); } return true; } @@ -637,7 +637,7 @@ impl Component for MailView { return true; } } - self.pager.set_dirty(); + self.pager.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -647,7 +647,7 @@ impl Component for MailView { { self.force_draw_headers = true; self.headers_cursor += 1; - self.pager.set_dirty(); + self.pager.set_dirty(true); return true; } _ => { @@ -718,7 +718,7 @@ impl Component for MailView { if self.mode.is_contact_selector() => { self.mode = ViewMode::Normal; - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt('')) => { @@ -742,7 +742,7 @@ impl Component for MailView { && shortcut!(key == shortcuts[MailView::DESCRIPTION]["view_raw_source"]) => { self.mode = ViewMode::Raw; - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -755,7 +755,7 @@ impl Component for MailView { ) => { self.mode = ViewMode::Normal; - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -797,7 +797,7 @@ impl Component for MailView { drop(account); if let Some(u) = attachments.get(lidx) { if let Ok(()) = crate::mailcap::MailcapEntry::execute(u, context) { - self.set_dirty(); + self.set_dirty(true); } else { context.replies.push_back(UIEvent::StatusEvent( StatusEvent::DisplayMessage(format!( @@ -1270,15 +1270,15 @@ impl Component for MailView { false } } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; match self.mode { ViewMode::Normal => { - self.pager.set_dirty(); + self.pager.set_dirty(value); } ViewMode::Subview => { if let Some(s) = self.subview.as_mut() { - s.set_dirty(); + s.set_dirty(value); } } _ => {} diff --git a/ui/src/components/mail/view/envelope.rs b/ui/src/components/mail/view/envelope.rs index 5a43370bb..57bfc0d09 100644 --- a/ui/src/components/mail/view/envelope.rs +++ b/ui/src/components/mail/view/envelope.rs @@ -541,8 +541,8 @@ impl Component for EnvelopeView { || self.pager.as_ref().map(|p| p.is_dirty()).unwrap_or(false) || self.subview.as_ref().map(|p| p.is_dirty()).unwrap_or(false) } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn id(&self) -> ComponentId { diff --git a/ui/src/components/mail/view/html.rs b/ui/src/components/mail/view/html.rs index 1df18c97f..9fc5231bc 100644 --- a/ui/src/components/mail/view/html.rs +++ b/ui/src/components/mail/view/html.rs @@ -160,8 +160,8 @@ impl Component for HtmlView { fn is_dirty(&self) -> bool { self.pager.is_dirty() } - fn set_dirty(&mut self) { - self.pager.set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.pager.set_dirty(value); } fn id(&self) -> ComponentId { diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index 626e18995..dc4f341a4 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -155,7 +155,7 @@ impl ThreadView { self.expanded_pos = new_entry_idx; } } - self.set_dirty(); + self.set_dirty(true); } fn initiate(&mut self, expanded_hash: Option, context: &Context) { /* stack to push thread messages in order in order to pop and print them later */ @@ -1014,7 +1014,7 @@ impl Component for ThreadView { self.new_expanded_pos = self.current_pos(); self.show_mailview = true; //self.initiated = false; - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -1022,7 +1022,7 @@ impl Component for ThreadView { { self.show_mailview = !self.show_mailview; self.initiated = false; - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -1030,7 +1030,7 @@ impl Component for ThreadView { { self.show_thread = !self.show_thread; self.initiated = false; - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(ref key) @@ -1076,7 +1076,7 @@ impl Component for ThreadView { return true; } UIEvent::Resize => { - self.set_dirty(); + self.set_dirty(true); } UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { let account = &context.accounts[self.coordinates.0]; @@ -1104,9 +1104,9 @@ impl Component for ThreadView { fn is_dirty(&self) -> bool { self.dirty || (self.show_mailview && self.mailview.is_dirty()) } - fn set_dirty(&mut self) { - self.dirty = true; - self.mailview.set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.dirty = value; + self.mailview.set_dirty(value); } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { let mut map = self.mailview.get_shortcuts(context); diff --git a/ui/src/components/notifications.rs b/ui/src/components/notifications.rs index 8e6036620..ec4c0ae41 100644 --- a/ui/src/components/notifications.rs +++ b/ui/src/components/notifications.rs @@ -72,7 +72,8 @@ impl Component for XDGNotifications { } false } - fn set_dirty(&mut self) {} + fn set_dirty(&mut self, _value: bool) {} + fn is_dirty(&self) -> bool { false } @@ -153,10 +154,7 @@ impl Component for NotificationFilter { .spawn() { log( - format!( - "Could not run notification script: {}.", - err.to_string() - ), + format!("Could not run notification script: {}.", err.to_string()), ERROR, ); debug!("{:?}", err); @@ -187,6 +185,6 @@ impl Component for NotificationFilter { fn is_dirty(&self) -> bool { false } - fn set_dirty(&mut self) {} + fn set_dirty(&mut self, _value: bool) {} fn set_id(&mut self, _id: ComponentId) {} } diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index e82fcb76c..09bf30cef 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -105,9 +105,9 @@ impl Component for HSplit { self.top.is_dirty() || self.bottom.is_dirty() } - fn set_dirty(&mut self) { - self.top.set_dirty(); - self.bottom.set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.top.set_dirty(value); + self.bottom.set_dirty(value); } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { @@ -171,7 +171,7 @@ impl Component for VSplit { let total_cols = get_x(bottom_right) - get_x(upper_left); let visibility = (self.left.is_visible(), self.right.is_visible()); if visibility != self.prev_visibility { - self.set_dirty(); + self.set_dirty(true); self.prev_visibility = visibility; } let right_component_width = match visibility { @@ -245,9 +245,9 @@ impl Component for VSplit { self.left.is_dirty() || self.right.is_dirty() } - fn set_dirty(&mut self) { - self.left.set_dirty(); - self.right.set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.left.set_dirty(value); + self.right.set_dirty(value); } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { @@ -676,8 +676,8 @@ impl Component for Pager { fn is_dirty(&self) -> bool { self.dirty } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { let config_map: FnvHashMap<&'static str, Key> = @@ -901,19 +901,19 @@ impl Component for StatusBar { self.auto_complete.set_suggestions(suggestions); /* redraw self.container because we have got ridden of an autocomplete * box, and it must be drawn over */ - self.container.set_dirty(); + self.container.set_dirty(true); return; } /* redraw self.container because we have less suggestions than before */ if suggestions.len() < self.auto_complete.suggestions().len() { - self.container.set_dirty(); + self.container.set_dirty(true); } if self.auto_complete.set_suggestions(suggestions) { let len = self.auto_complete.suggestions().len() - 1; self.auto_complete.set_cursor(len); - self.container.set_dirty(); + self.container.set_dirty(true); } let hist_height = std::cmp::min(15, self.auto_complete.suggestions().len()); let hist_area = if height < self.auto_complete.suggestions().len() { @@ -1064,8 +1064,8 @@ impl Component for StatusBar { UIEvent::ChangeMode(m) => { let offset = self.status.find('|').unwrap_or_else(|| self.status.len()); self.status.replace_range(..offset, &format!("{} ", m)); - self.set_dirty(); - self.container.set_dirty(); + self.set_dirty(true); + self.container.set_dirty(true); self.mode = *m; match m { UIMode::Normal => { @@ -1098,8 +1098,8 @@ impl Component for StatusBar { let mut utext = UText::new(suggestion); let len = utext.as_str().len(); utext.set_cursor(len); - self.container.set_dirty(); - self.set_dirty(); + self.container.set_dirty(true); + self.set_dirty(true); self.ex_buffer = Field::Text(utext, None); } } @@ -1145,8 +1145,8 @@ impl Component for StatusBar { ); let len = utext.as_str().len(); utext.set_cursor(len); - self.container.set_dirty(); - self.set_dirty(); + self.container.set_dirty(true); + self.set_dirty(true); self.ex_buffer = Field::Text(utext, None); self.ex_buffer_cmd_history_pos = pos; self.dirty = true; @@ -1167,8 +1167,8 @@ impl Component for StatusBar { ); let len = utext.as_str().len(); utext.set_cursor(len); - self.container.set_dirty(); - self.set_dirty(); + self.container.set_dirty(true); + self.set_dirty(true); self.ex_buffer = Field::Text(utext, None); self.ex_buffer_cmd_history_pos = pos; self.dirty = true; @@ -1202,8 +1202,8 @@ impl Component for StatusBar { fn is_dirty(&self) -> bool { self.dirty || self.container.is_dirty() } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { @@ -1274,7 +1274,8 @@ impl Component for Progress { fn process_event(&mut self, _event: &mut UIEvent, _context: &mut Context) -> bool { false } - fn set_dirty(&mut self) {} + fn set_dirty(&mut self, _value: bool) {} + fn is_dirty(&self) -> bool { false } @@ -1585,7 +1586,7 @@ impl Component for Tabbed { .get_status(context) .unwrap_or_default(), ))); - self.set_dirty(); + self.set_dirty(true); } return true; } @@ -1598,13 +1599,13 @@ impl Component for Tabbed { .get_status(context) .unwrap_or_default(), ))); - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Input(Key::Char('?')) => { if self.show_shortcuts { /* children below the shortcut overlay must be redrawn */ - self.set_dirty(); + self.set_dirty(true); } self.show_shortcuts = !self.show_shortcuts; self.dirty = true; @@ -1617,13 +1618,13 @@ impl Component for Tabbed { } self.add_component(Box::new(composer)); self.cursor_pos = self.children.len() - 1; - self.children[self.cursor_pos].set_dirty(); + self.children[self.cursor_pos].set_dirty(true); return true; } UIEvent::Action(Tab(Reply(coordinates, msg))) => { self.add_component(Box::new(Composer::with_context(coordinates, msg, context))); self.cursor_pos = self.children.len() - 1; - self.children[self.cursor_pos].set_dirty(); + self.children[self.cursor_pos].set_dirty(true); return true; } UIEvent::Action(Tab(Edit(account_pos, msg))) => { @@ -1651,13 +1652,13 @@ impl Component for Tabbed { }; self.add_component(Box::new(composer)); self.cursor_pos = self.children.len() - 1; - self.children[self.cursor_pos].set_dirty(); + self.children[self.cursor_pos].set_dirty(true); return true; } UIEvent::Action(Tab(New(ref mut e))) if e.is_some() => { self.add_component(e.take().unwrap()); self.cursor_pos = self.children.len() - 1; - self.children[self.cursor_pos].set_dirty(); + self.children[self.cursor_pos].set_dirty(true); return true; } UIEvent::Action(Tab(Close)) => { @@ -1666,7 +1667,7 @@ impl Component for Tabbed { } let id = self.children[self.cursor_pos].id(); self.children[self.cursor_pos].kill(id, context); - self.set_dirty(); + self.set_dirty(true); return true; } UIEvent::Action(Tab(Kill(id))) => { @@ -1676,7 +1677,7 @@ impl Component for Tabbed { if let Some(c_idx) = self.children.iter().position(|x| x.id() == id) { self.children.remove(c_idx); self.cursor_pos = 0; - self.set_dirty(); + self.set_dirty(true); return true; } else { debug!( @@ -1717,9 +1718,9 @@ impl Component for Tabbed { fn is_dirty(&self) -> bool { self.dirty || self.children[self.cursor_pos].is_dirty() } - fn set_dirty(&mut self) { - self.dirty = true; - self.children[self.cursor_pos].set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.dirty = value; + self.children[self.cursor_pos].set_dirty(value); } fn id(&self) -> ComponentId { @@ -1739,7 +1740,7 @@ impl Component for Tabbed { for (i, c) in self.children.iter_mut().enumerate() { if !c.can_quit_cleanly(context) { self.cursor_pos = i; - self.set_dirty(); + self.set_dirty(true); return false; } } @@ -2038,8 +2039,8 @@ impl Component for Selector { fn is_dirty(&self) -> bool { self.dirty } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn id(&self) -> ComponentId { @@ -2318,8 +2319,8 @@ impl Component for RawBuffer { self.dirty } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn id(&self) -> ComponentId { diff --git a/ui/src/components/utilities/widgets.rs b/ui/src/components/utilities/widgets.rs index 48a6883db..13c2a3d0f 100644 --- a/ui/src/components/utilities/widgets.rs +++ b/ui/src/components/utilities/widgets.rs @@ -246,13 +246,13 @@ impl Component for Field { return false; } } - self.set_dirty(); + self.set_dirty(true); true } fn is_dirty(&self) -> bool { false } - fn set_dirty(&mut self) {} + fn set_dirty(&mut self, _value: bool) {} fn id(&self) -> ComponentId { ComponentId::nil() @@ -490,7 +490,7 @@ impl Component for FormWidget { self.focus = FormFocus::Buttons; self.buttons.set_focus(true); if self.hide_buttons { - self.set_dirty(); + self.set_dirty(true); return false; } } @@ -532,15 +532,15 @@ impl Component for FormWidget { return false; } } - self.set_dirty(); + self.set_dirty(true); true } fn is_dirty(&self) -> bool { self.dirty || self.buttons.is_dirty() } - fn set_dirty(&mut self) { - self.dirty = true; - self.buttons.set_dirty(); + fn set_dirty(&mut self, value: bool) { + self.dirty = value; + self.buttons.set_dirty(value); } fn id(&self) -> ComponentId { @@ -658,14 +658,14 @@ where return false; } } - self.set_dirty(); + self.set_dirty(true); true } fn is_dirty(&self) -> bool { self.dirty } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn id(&self) -> ComponentId { @@ -766,8 +766,8 @@ impl Component for AutoComplete { fn is_dirty(&self) -> bool { self.dirty } - fn set_dirty(&mut self) { - self.dirty = true; + fn set_dirty(&mut self, value: bool) { + self.dirty = value; } fn id(&self) -> ComponentId { @@ -845,12 +845,12 @@ impl AutoComplete { pub fn inc_cursor(&mut self) { if self.cursor < self.entries.len().saturating_sub(1) { self.cursor += 1; - self.set_dirty(); + self.set_dirty(true); } } pub fn dec_cursor(&mut self) { self.cursor = self.cursor.saturating_sub(1); - self.set_dirty(); + self.set_dirty(true); } pub fn cursor(&self) -> usize {