Commit 0beb9ab2 authored by Julian Hofer's avatar Julian Hofer Committed by Daniel Garcia Moreno

Switch order of if blocks to increase readability

Several if statements in the code started with the negation
of the boolean condition to check,
which makes it harder to comprehend the code.
parent d78b52a3
Pipeline #135232 passed with stages
in 34 minutes and 34 seconds
......@@ -99,13 +99,13 @@ pub fn new(
let err_label = upgrade_weak!(err_weak);
server_entry.get_text().map(|txt| {
if !txt.is_empty() {
if txt.is_empty() {
err_label.show();
} else {
err_label.hide();
let state = LoginState::Credentials;
stack.set_visible_child_name(&state.to_string());
back.borrow_mut().push(state);
} else {
err_label.show();
}
});
});
......
......@@ -98,12 +98,12 @@ impl App {
let spinner = avatar_spinner.downgrade();
avatar_btn.connect_property_sensitive_notify(move |w| {
let spinner = upgrade_weak!(spinner);
if !w.get_sensitive() {
spinner.start();
spinner.show();
} else {
if w.get_sensitive() {
spinner.hide();
spinner.stop();
} else {
spinner.start();
spinner.show();
}
});
}
......
......@@ -37,12 +37,12 @@ impl App {
let decor_split: Vec<String> = decor.splitn(2,':').map(|s| s.to_string()).collect();
// Change the headerbar controls depending on position
// of close
if !decor_split[1].contains("close") {
right_header.set_show_close_button(false);
left_header.set_show_close_button(true);
} else {
if decor_split[1].contains("close") {
left_header.set_show_close_button(false);
right_header.set_show_close_button(true);
} else {
right_header.set_show_close_button(false);
left_header.set_show_close_button(true);
}
};
}));
......
......@@ -56,19 +56,7 @@ impl App {
.connect_property_active_notify(move |_| {
op.lock().unwrap().md_enabled = markdown_switch.get_active();
if !markdown_switch.get_active() {
md_img.set_from_icon_name(
Some("format-justify-left-symbolic"),
gtk::IconSize::Menu,
);
txt.get_style_context().add_class("dim-label");
util::set_markdown_schema(false);
let lang: Option<&sourceview4::Language> = None;
buffer.set_highlight_matching_brackets(false);
buffer.set_language(lang);
buffer.set_highlight_syntax(false);
} else {
if markdown_switch.get_active() {
md_img.set_from_icon_name(
Some("format-indent-more-symbolic"),
gtk::IconSize::Menu,
......@@ -81,6 +69,18 @@ impl App {
buffer.set_language(Some(&md_lang));
buffer.set_highlight_syntax(true);
}
} else {
md_img.set_from_icon_name(
Some("format-justify-left-symbolic"),
gtk::IconSize::Menu,
);
txt.get_style_context().add_class("dim-label");
util::set_markdown_schema(false);
let lang: Option<&sourceview4::Language> = None;
buffer.set_highlight_matching_brackets(false);
buffer.set_language(lang);
buffer.set_highlight_syntax(false);
}
});
}
......
......@@ -235,11 +235,11 @@ fn filter_rows(
let mut empty = true;
for (index, member) in members.iter().enumerate() {
let alias_lower = member.get_alias().to_lowercase();
if !alias_lower.contains(search) {
container.get_row_at_index(index as i32)?.hide();
} else {
if alias_lower.contains(search) {
container.get_row_at_index(index as i32)?.show();
empty = false;
} else {
container.get_row_at_index(index as i32)?.hide();
}
}
label.set_visible(empty);
......
......@@ -178,12 +178,12 @@ impl RoomSettings {
let spinner = avatar_spinner.downgrade();
avatar_btn.connect_property_sensitive_notify(move |w| {
let spinner = upgrade_weak!(spinner);
if !w.get_sensitive() {
spinner.start();
spinner.show();
} else {
if w.get_sensitive() {
spinner.hide();
spinner.stop();
} else {
spinner.start();
spinner.show();
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment