headerbar: Don't show error when add input is empty

When you add a feed url and clear the input after entering some
characters, then the error label is shown. The empty url check in the
code is broken, because it is performed on a version of the url which
is not the original input and instead a version modified in the code.

I store in a variable whether the original input url is empty.

part of #45
This commit is contained in:
FeuRenard 2019-05-12 17:55:20 +02:00 committed by Jordan Petridis
parent 2631173a0d
commit 86f6a944ff
No known key found for this signature in database
GPG Key ID: E8523968931763BE

View File

@ -96,6 +96,7 @@ impl AddPopover {
.entry
.get_text()
.ok_or_else(|| format_err!("GtkEntry blew up somehow."))?;
let is_input_url_empty = url.is_empty();
debug!("Url: {}", url);
if !(url.starts_with("https://") || url.starts_with("http://")) {
@ -131,7 +132,7 @@ impl AddPopover {
}
Err(err) => {
self.add.set_sensitive(false);
if !url.is_empty() {
if !is_input_url_empty {
self.entry
.get_style_context()
.add_class(&gtk::STYLE_CLASS_ERROR);