Skip to content

Commit

Permalink
FIxed a bug where the separator was shown even when the author was an…
Browse files Browse the repository at this point in the history
… empty string
  • Loading branch information
zalesyc committed Mar 13, 2024
1 parent 36ff811 commit 988f093
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/SingleAppPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ def set_element_order(self, order: list[str], remove_previous: bool = True) -> N

self.show_all()

def set_separator_text(self, new_text: str) -> None:
self.separator_text = new_text
self.song_separator.set_label(self.separator_text)
def set_separator_text(self, new_text: str, override_set_text: bool = True) -> None:
if override_set_text:
self.separator_text = new_text
self.song_separator.set_label(new_text)

def playing_changed(self, status: GLib.Variant) -> None:
if status.get_string() == "Playing":
Expand Down Expand Up @@ -319,23 +320,33 @@ def _init_button(
def _set_song_label(
self, author: Optional[GLib.Variant], title: Optional[GLib.Variant]
) -> None:
str_author = ""
str_title = ""
if title is None or (not title.get_string()):
str_title = "Unknown"
if author is None or author.get_strv() == [""]:
if (
author is None
or "".join(author.get_strv()).isspace()
or "".join(author.get_strv()) == ""
):
str_author = ""
self.set_separator_text("", override_set_text=False)

else:
str_author = ", ".join(author.get_strv())
self.set_separator_text(self.separator_text)

else:
str_title = title.unpack()
if author is None or (not ", ".join(author.get_strv())):
if (
author is None
or "".join(author.get_strv()).isspace()
or "".join(author.get_strv()) == ""
):
str_author = ""
self.set_separator_text("", override_set_text=False)

else:
str_author = ", ".join(author.get_strv())
self.set_separator_text(self.separator_text)

self.song_author.set_label(
(str_author[: self.author_max_len - 3] + "...")
Expand Down

0 comments on commit 988f093

Please sign in to comment.