mirror of
https://github.com/veeso/termscp.git
synced 2026-09-27 22:41:19 -07:00
fix: replace assert! calls in UI activities with graceful error handling
This commit is contained in:
+119
-125
@@ -40,16 +40,16 @@ impl SetupActivity {
|
||||
|
||||
/// Mount error box
|
||||
pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) {
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Common(IdCommon::ErrorPopup),
|
||||
Box::new(components::ErrorPopup::new(text)),
|
||||
vec![],
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(self.app.active(&Id::Common(IdCommon::ErrorPopup)).is_ok());
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Common(IdCommon::ErrorPopup),
|
||||
Box::new(components::ErrorPopup::new(text)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.active(&Id::Common(IdCommon::ErrorPopup)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Umount error message
|
||||
@@ -59,16 +59,16 @@ impl SetupActivity {
|
||||
|
||||
/// Mount quit popup
|
||||
pub(super) fn mount_quit(&mut self) {
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Common(IdCommon::QuitPopup),
|
||||
Box::<components::QuitPopup>::default(),
|
||||
vec![],
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(self.app.active(&Id::Common(IdCommon::QuitPopup)).is_ok());
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Common(IdCommon::QuitPopup),
|
||||
Box::<components::QuitPopup>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.active(&Id::Common(IdCommon::QuitPopup)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Umount quit
|
||||
@@ -78,16 +78,16 @@ impl SetupActivity {
|
||||
|
||||
/// Mount save popup
|
||||
pub(super) fn mount_save_popup(&mut self) {
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Common(IdCommon::SavePopup),
|
||||
Box::<components::SavePopup>::default(),
|
||||
vec![],
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(self.app.active(&Id::Common(IdCommon::SavePopup)).is_ok());
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Common(IdCommon::SavePopup),
|
||||
Box::<components::SavePopup>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.active(&Id::Common(IdCommon::SavePopup)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Umount quit
|
||||
@@ -97,16 +97,16 @@ impl SetupActivity {
|
||||
|
||||
/// Mount help
|
||||
pub(super) fn mount_help(&mut self) {
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Common(IdCommon::Keybindings),
|
||||
Box::<components::Keybindings>::default(),
|
||||
vec![],
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(self.app.active(&Id::Common(IdCommon::Keybindings)).is_ok());
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Common(IdCommon::Keybindings),
|
||||
Box::<components::Keybindings>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.active(&Id::Common(IdCommon::Keybindings)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Umount help
|
||||
@@ -148,96 +148,90 @@ impl SetupActivity {
|
||||
/// Mount common components
|
||||
fn mount_commons(&mut self, layout: ViewLayout) {
|
||||
// Radio tab
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Common(IdCommon::Header),
|
||||
Box::new(components::Header::new(layout)),
|
||||
vec![],
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Common(IdCommon::Header),
|
||||
Box::new(components::Header::new(layout)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Footer
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Common(IdCommon::Footer),
|
||||
Box::<components::Footer>::default(),
|
||||
vec![],
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Common(IdCommon::Footer),
|
||||
Box::<components::Footer>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Mount global listener
|
||||
fn mount_global_listener(&mut self) {
|
||||
assert!(
|
||||
self.app
|
||||
.mount(
|
||||
Id::Common(IdCommon::GlobalListener),
|
||||
Box::<components::GlobalListener>::default(),
|
||||
vec![
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Esc,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Function(10),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Tab,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Char('h'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Function(1),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Char('r'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Char('s'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Function(4),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(SubEventClause::WindowResize, SubClause::Always)
|
||||
]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.mount(
|
||||
Id::Common(IdCommon::GlobalListener),
|
||||
Box::<components::GlobalListener>::default(),
|
||||
vec![
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Esc,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Function(10),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Tab,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Char('h'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Function(1),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Char('r'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Char('s'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(
|
||||
SubEventClause::Keyboard(KeyEvent {
|
||||
code: Key::Function(4),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
}),
|
||||
Self::no_popup_mounted_clause(),
|
||||
),
|
||||
Sub::new(SubEventClause::WindowResize, SubClause::Always),
|
||||
],
|
||||
) {
|
||||
error!("Failed to mount component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a sub clause which requires that no popup is mounted in order to be satisfied
|
||||
|
||||
@@ -32,7 +32,9 @@ impl SetupActivity {
|
||||
// Load values
|
||||
self.load_input_values();
|
||||
// Active text editor
|
||||
assert!(self.app.active(&Id::Config(IdConfig::TextEditor)).is_ok());
|
||||
if let Err(err) = self.app.active(&Id::Config(IdConfig::TextEditor)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn view_setup(&mut self) {
|
||||
@@ -145,133 +147,111 @@ impl SetupActivity {
|
||||
// Text editor
|
||||
let text_editor: String =
|
||||
String::from(self.config().get_text_editor().as_path().to_string_lossy());
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::TextEditor),
|
||||
Box::new(components::TextEditor::new(text_editor.as_str())),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::TextEditor),
|
||||
Box::new(components::TextEditor::new(text_editor.as_str())),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Protocol
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::DefaultProtocol),
|
||||
Box::new(components::DefaultProtocol::new(
|
||||
self.config().get_default_protocol()
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::DefaultProtocol),
|
||||
Box::new(components::DefaultProtocol::new(
|
||||
self.config().get_default_protocol(),
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Hidden files
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::HiddenFiles),
|
||||
Box::new(components::HiddenFiles::new(
|
||||
self.config().get_show_hidden_files()
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::HiddenFiles),
|
||||
Box::new(components::HiddenFiles::new(
|
||||
self.config().get_show_hidden_files(),
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Updates
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::CheckUpdates),
|
||||
Box::new(components::CheckUpdates::new(
|
||||
self.config().get_check_for_updates()
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::CheckUpdates),
|
||||
Box::new(components::CheckUpdates::new(
|
||||
self.config().get_check_for_updates(),
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// File replace
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::PromptOnFileReplace),
|
||||
Box::new(components::PromptOnFileReplace::new(
|
||||
self.config().get_prompt_on_file_replace()
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::PromptOnFileReplace),
|
||||
Box::new(components::PromptOnFileReplace::new(
|
||||
self.config().get_prompt_on_file_replace(),
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Group dirs
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::GroupDirs),
|
||||
Box::new(components::GroupDirs::new(self.config().get_group_dirs())),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::GroupDirs),
|
||||
Box::new(components::GroupDirs::new(self.config().get_group_dirs())),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Local File Fmt
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::LocalFileFmt),
|
||||
Box::new(components::LocalFileFmt::new(
|
||||
&self.config().get_local_file_fmt().unwrap_or_default()
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::LocalFileFmt),
|
||||
Box::new(components::LocalFileFmt::new(
|
||||
&self.config().get_local_file_fmt().unwrap_or_default(),
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Remote File Fmt
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::RemoteFileFmt),
|
||||
Box::new(components::RemoteFileFmt::new(
|
||||
&self.config().get_remote_file_fmt().unwrap_or_default()
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::RemoteFileFmt),
|
||||
Box::new(components::RemoteFileFmt::new(
|
||||
&self.config().get_remote_file_fmt().unwrap_or_default(),
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Notifications enabled
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::NotificationsEnabled),
|
||||
Box::new(components::NotificationsEnabled::new(
|
||||
self.config().get_notifications()
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::NotificationsEnabled),
|
||||
Box::new(components::NotificationsEnabled::new(
|
||||
self.config().get_notifications(),
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Notifications threshold
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::NotificationsThreshold),
|
||||
Box::new(components::NotificationsThreshold::new(&fmt_bytes(
|
||||
self.config().get_notification_threshold()
|
||||
))),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::NotificationsThreshold),
|
||||
Box::new(components::NotificationsThreshold::new(&fmt_bytes(
|
||||
self.config().get_notification_threshold(),
|
||||
))),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
// Ssh config
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Config(IdConfig::SshConfig),
|
||||
Box::new(components::SshConfig::new(
|
||||
self.config().get_ssh_config().unwrap_or("")
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Config(IdConfig::SshConfig),
|
||||
Box::new(components::SshConfig::new(
|
||||
self.config().get_ssh_config().unwrap_or(""),
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Collect values from input and put them into the configuration
|
||||
|
||||
@@ -74,16 +74,16 @@ impl SetupActivity {
|
||||
|
||||
/// Mount delete ssh key component
|
||||
pub(crate) fn mount_del_ssh_key(&mut self) {
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Ssh(IdSsh::DelSshKeyPopup),
|
||||
Box::<components::DelSshKeyPopup>::default(),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(self.app.active(&Id::Ssh(IdSsh::DelSshKeyPopup)).is_ok());
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Ssh(IdSsh::DelSshKeyPopup),
|
||||
Box::<components::DelSshKeyPopup>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.active(&Id::Ssh(IdSsh::DelSshKeyPopup)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Umount delete ssh key
|
||||
@@ -93,25 +93,23 @@ impl SetupActivity {
|
||||
|
||||
/// Mount new ssh key prompt
|
||||
pub(crate) fn mount_new_ssh_key(&mut self) {
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Ssh(IdSsh::SshHost),
|
||||
Box::<components::SshHost>::default(),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Ssh(IdSsh::SshUsername),
|
||||
Box::<components::SshUsername>::default(),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(self.app.active(&Id::Ssh(IdSsh::SshHost)).is_ok());
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Ssh(IdSsh::SshHost),
|
||||
Box::<components::SshHost>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Ssh(IdSsh::SshUsername),
|
||||
Box::<components::SshUsername>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.active(&Id::Ssh(IdSsh::SshHost)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Umount new ssh key prompt
|
||||
@@ -130,15 +128,15 @@ impl SetupActivity {
|
||||
format!("{username} at {addr}")
|
||||
})
|
||||
.collect();
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Ssh(IdSsh::SshKeys),
|
||||
Box::new(components::SshKeys::new(&keys)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(self.app.active(&Id::Ssh(IdSsh::SshKeys)).is_ok());
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Ssh(IdSsh::SshKeys),
|
||||
Box::new(components::SshKeys::new(&keys)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.active(&Id::Ssh(IdSsh::SshKeys)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ impl SetupActivity {
|
||||
// Load styles
|
||||
self.load_styles();
|
||||
// Active first field
|
||||
assert!(self.app.active(&Id::Theme(IdTheme::AuthProtocol)).is_ok());
|
||||
if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthProtocol)) {
|
||||
error!("Failed to activate component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn view_theme(&mut self) {
|
||||
@@ -242,309 +244,247 @@ impl SetupActivity {
|
||||
}
|
||||
|
||||
fn load_titles(&mut self) {
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::AuthTitle),
|
||||
Box::<components::AuthTitle>::default(),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::MiscTitle),
|
||||
Box::<components::MiscTitle>::default(),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::TransferTitle),
|
||||
Box::<components::TransferTitle>::default(),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::TransferTitle2),
|
||||
Box::<components::TransferTitle2>::default(),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::AuthTitle),
|
||||
Box::<components::AuthTitle>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::MiscTitle),
|
||||
Box::<components::MiscTitle>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::TransferTitle),
|
||||
Box::<components::TransferTitle>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::TransferTitle2),
|
||||
Box::<components::TransferTitle2>::default(),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Load values from theme into input fields
|
||||
pub(crate) fn load_styles(&mut self) {
|
||||
let theme: Theme = self.theme().clone();
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::AuthAddress),
|
||||
Box::new(components::AuthAddress::new(theme.auth_address)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::AuthBookmarks),
|
||||
Box::new(components::AuthBookmarks::new(theme.auth_bookmarks)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::AuthPassword),
|
||||
Box::new(components::AuthPassword::new(theme.auth_password)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::AuthPort),
|
||||
Box::new(components::AuthPort::new(theme.auth_port)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::AuthProtocol),
|
||||
Box::new(components::AuthProtocol::new(theme.auth_protocol)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::AuthRecentHosts),
|
||||
Box::new(components::AuthRecentHosts::new(theme.auth_recents)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::AuthUsername),
|
||||
Box::new(components::AuthUsername::new(theme.auth_username)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::MiscError),
|
||||
Box::new(components::MiscError::new(theme.misc_error_dialog)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::MiscInfo),
|
||||
Box::new(components::MiscInfo::new(theme.misc_info_dialog)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::MiscInput),
|
||||
Box::new(components::MiscInput::new(theme.misc_input_dialog)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::MiscKeys),
|
||||
Box::new(components::MiscKeys::new(theme.misc_keys)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::MiscQuit),
|
||||
Box::new(components::MiscQuit::new(theme.misc_quit_dialog)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::MiscSave),
|
||||
Box::new(components::MiscSave::new(theme.misc_save_dialog)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::MiscWarn),
|
||||
Box::new(components::MiscWarn::new(theme.misc_warn_dialog)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::ExplorerLocalBg),
|
||||
Box::new(components::ExplorerLocalBg::new(
|
||||
theme.transfer_local_explorer_background
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::ExplorerLocalFg),
|
||||
Box::new(components::ExplorerLocalFg::new(
|
||||
theme.transfer_local_explorer_foreground
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::ExplorerLocalHg),
|
||||
Box::new(components::ExplorerLocalHg::new(
|
||||
theme.transfer_local_explorer_highlighted
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::ExplorerRemoteBg),
|
||||
Box::new(components::ExplorerRemoteBg::new(
|
||||
theme.transfer_remote_explorer_background
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::ExplorerRemoteFg),
|
||||
Box::new(components::ExplorerRemoteFg::new(
|
||||
theme.transfer_remote_explorer_foreground
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::ExplorerRemoteHg),
|
||||
Box::new(components::ExplorerRemoteHg::new(
|
||||
theme.transfer_remote_explorer_highlighted
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::ProgBarFull),
|
||||
Box::new(components::ProgBarFull::new(
|
||||
theme.transfer_progress_bar_full
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::ProgBarPartial),
|
||||
Box::new(components::ProgBarPartial::new(
|
||||
theme.transfer_progress_bar_partial
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::LogBg),
|
||||
Box::new(components::LogBg::new(theme.transfer_log_background)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::LogWindow),
|
||||
Box::new(components::LogWindow::new(theme.transfer_log_window)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::StatusSorting),
|
||||
Box::new(components::StatusSorting::new(
|
||||
theme.transfer_status_sorting
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::StatusHidden),
|
||||
Box::new(components::StatusHidden::new(theme.transfer_status_hidden)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
self.app
|
||||
.remount(
|
||||
Id::Theme(IdTheme::StatusSync),
|
||||
Box::new(components::StatusSync::new(
|
||||
theme.transfer_status_sync_browsing
|
||||
)),
|
||||
vec![]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::AuthAddress),
|
||||
Box::new(components::AuthAddress::new(theme.auth_address)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::AuthBookmarks),
|
||||
Box::new(components::AuthBookmarks::new(theme.auth_bookmarks)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::AuthPassword),
|
||||
Box::new(components::AuthPassword::new(theme.auth_password)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::AuthPort),
|
||||
Box::new(components::AuthPort::new(theme.auth_port)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::AuthProtocol),
|
||||
Box::new(components::AuthProtocol::new(theme.auth_protocol)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::AuthRecentHosts),
|
||||
Box::new(components::AuthRecentHosts::new(theme.auth_recents)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::AuthUsername),
|
||||
Box::new(components::AuthUsername::new(theme.auth_username)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::MiscError),
|
||||
Box::new(components::MiscError::new(theme.misc_error_dialog)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::MiscInfo),
|
||||
Box::new(components::MiscInfo::new(theme.misc_info_dialog)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::MiscInput),
|
||||
Box::new(components::MiscInput::new(theme.misc_input_dialog)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::MiscKeys),
|
||||
Box::new(components::MiscKeys::new(theme.misc_keys)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::MiscQuit),
|
||||
Box::new(components::MiscQuit::new(theme.misc_quit_dialog)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::MiscSave),
|
||||
Box::new(components::MiscSave::new(theme.misc_save_dialog)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::MiscWarn),
|
||||
Box::new(components::MiscWarn::new(theme.misc_warn_dialog)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::ExplorerLocalBg),
|
||||
Box::new(components::ExplorerLocalBg::new(
|
||||
theme.transfer_local_explorer_background,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::ExplorerLocalFg),
|
||||
Box::new(components::ExplorerLocalFg::new(
|
||||
theme.transfer_local_explorer_foreground,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::ExplorerLocalHg),
|
||||
Box::new(components::ExplorerLocalHg::new(
|
||||
theme.transfer_local_explorer_highlighted,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::ExplorerRemoteBg),
|
||||
Box::new(components::ExplorerRemoteBg::new(
|
||||
theme.transfer_remote_explorer_background,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::ExplorerRemoteFg),
|
||||
Box::new(components::ExplorerRemoteFg::new(
|
||||
theme.transfer_remote_explorer_foreground,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::ExplorerRemoteHg),
|
||||
Box::new(components::ExplorerRemoteHg::new(
|
||||
theme.transfer_remote_explorer_highlighted,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::ProgBarFull),
|
||||
Box::new(components::ProgBarFull::new(
|
||||
theme.transfer_progress_bar_full,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::ProgBarPartial),
|
||||
Box::new(components::ProgBarPartial::new(
|
||||
theme.transfer_progress_bar_partial,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::LogBg),
|
||||
Box::new(components::LogBg::new(theme.transfer_log_background)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::LogWindow),
|
||||
Box::new(components::LogWindow::new(theme.transfer_log_window)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::StatusSorting),
|
||||
Box::new(components::StatusSorting::new(
|
||||
theme.transfer_status_sorting,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::StatusHidden),
|
||||
Box::new(components::StatusHidden::new(theme.transfer_status_hidden)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
if let Err(err) = self.app.remount(
|
||||
Id::Theme(IdTheme::StatusSync),
|
||||
Box::new(components::StatusSync::new(
|
||||
theme.transfer_status_sync_browsing,
|
||||
)),
|
||||
vec![],
|
||||
) {
|
||||
error!("Failed to remount component: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user