Skip to content

Commit

Permalink
Home button in title bar
Browse files Browse the repository at this point in the history
Refs: #169
  • Loading branch information
orontee committed May 25, 2024
1 parent 1df0f78 commit 5e0c5af
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 69 deletions.
3 changes: 3 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ The format is based on `Keep a Changelog
Added
-----

- Home button in title bar to go back to library's default directory
`#169 <https://github.com/orontee/argos/issues/169>`_

Changed
-------

Expand Down
21 changes: 19 additions & 2 deletions argos/ui/title_bar.ui
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkImage" id="back_image">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">go-previous-symbolic</property>
</object>
<object class="GtkImage" id="home_image">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">go-home-symbolic</property>
</object>
<object class="GtkImage" id="search_image">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -53,7 +58,7 @@
<property name="name">back-button</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Go up</property>
<property name="tooltip-text" translatable="yes">Go back</property>
<property name="image">back_image</property>
</object>
</child>
Expand Down Expand Up @@ -98,6 +103,18 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="home_button">
<property name="name">home-button</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Go to home</property>
<property name="image">home_image</property>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="search_button">
<property name="name">search-button</property>
Expand Down
10 changes: 10 additions & 0 deletions argos/widgets/librarywindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@ def goto_parent_state(self) -> None:
else:
self.select_directory_page()

def goto_home_directory(self) -> None:
if not self.is_directory_page_visible():
self.select_directory_page()

home_directory_uri = self._model.library.default_uri
if self.props.directory_uri == home_directory_uri:
return

self.show_directory(home_directory_uri, history=True)

@Gtk.Template.Callback()
def directory_view_item_activated_cb(
self, icon_view: Gtk.IconView, path: Gtk.TreePath
Expand Down
5 changes: 5 additions & 0 deletions argos/widgets/titlebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TitleBar(Gtk.HeaderBar):
__gtype_name__ = "TitleBar"

back_button: Gtk.Button = Gtk.Template.Child()
home_button: Gtk.Button = Gtk.Template.Child()
app_menu_button: Gtk.MenuButton = Gtk.Template.Child()
central_view_switcher: Gtk.StackSwitcher = Gtk.Template.Child()
search_button: Optional[Gtk.ToggleButton] = Gtk.Template.Child()
Expand All @@ -38,6 +39,7 @@ def __init__(self, application: Gtk.Application, *, window: Gtk.ApplicationWindo

if application.props.disable_tooltips:
self.back_button.props.has_tooltip = False
self.home_button.props.has_tooltip = False
self.sort_button.props.has_tooltip = False
if self.search_button is not None:
self.search_button.props.has_tooltip = False
Expand Down Expand Up @@ -141,6 +143,7 @@ def set_state(self, state: TitleBarState, *, force: bool = False) -> None:
TitleBarState.FOR_PLAYLISTS_PAGE,
):
self.back_button.set_visible(False)
self.home_button.set_visible(False)
self.title_stack.set_visible(True)
self.sort_button.set_visible(False)
if self.search_button is not None:
Expand All @@ -154,13 +157,15 @@ def set_state(self, state: TitleBarState, *, force: bool = False) -> None:
self.back_button.set_sensitive(
state == TitleBarState.FOR_LIBRARY_PAGE_ON_DIRECTORY
)
self.home_button.set_visible(True)
self.title_stack.set_visible(True)
self.sort_button.set_visible(True)
if self.search_button is not None:
self.search_button.set_visible(True)
elif state == TitleBarState.FOR_LIBRARY_PAGE_ON_ALBUM:
self.back_button.set_visible(True)
self.back_button.set_sensitive(True)
self.home_button.set_visible(True)
self.title_stack.set_visible(True)
self.sort_button.set_visible(False)
if self.search_button is not None:
Expand Down
4 changes: 4 additions & 0 deletions argos/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def __init__(self, application: Gtk.Application):
def _setup_titlebar(self, titlebar: TitleBar) -> None:
titlebar.central_view_switcher.set_stack(self.central_view)
titlebar.back_button.connect("clicked", self._on_title_back_button_clicked)
titlebar.home_button.connect("clicked", self._on_title_home_button_clicked)
titlebar.search_entry.connect("search-changed", self._on_search_entry_changed)

def is_playing_page_visible(self) -> None:
Expand Down Expand Up @@ -188,6 +189,9 @@ def _update_titlebar_state(self) -> None:
def _on_title_back_button_clicked(self, _1: Gtk.Button) -> None:
self.props.library_window.goto_parent_state()

def _on_title_home_button_clicked(self, _1: Gtk.Button) -> None:
self.props.library_window.goto_home_directory()

def _on_search_entry_changed(self, search_entry: Gtk.SearchEntry) -> None:
filtering_text = search_entry.props.text
self.props.library_window.set_filtering_text(filtering_text)
Expand Down
52 changes: 30 additions & 22 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-19 00:39+0100\n"
"POT-Creation-Date: 2024-05-25 08:49+0200\n"
"PO-Revision-Date: 2022-02-20 13:30+0100\n"
"Last-Translator: André Dokis <[email protected]>\n"
"Language-Team: German <[email protected]>\n"
Expand Down Expand Up @@ -114,7 +114,7 @@ msgstr "Alle"
msgid "Started to play {}"
msgstr "Es läuft {}"

#: argos/controllers/playlists.py:42 argos/controllers/playlists.py:318
#: argos/controllers/playlists.py:42 argos/controllers/playlists.py:322
#: argos/ui/preferences.ui:376
msgid "History"
msgstr "Zuletzt gespielt"
Expand Down Expand Up @@ -433,15 +433,19 @@ msgstr ""
msgid "Play immediately"
msgstr "Direkt starten"

#: argos/ui/title_bar.ui:56
msgid "Go up"
msgstr ""
#: argos/ui/title_bar.ui:61
msgid "Go back"
msgstr "Geh zurück"

#: argos/ui/title_bar.ui:87
#: argos/ui/title_bar.ui:91
msgid "Sort albums"
msgstr "Alben sortieren"

#: argos/ui/title_bar.ui:107
#: argos/ui/title_bar.ui:111
msgid "Go to home"
msgstr "Zur Startseite"

#: argos/ui/title_bar.ui:123
msgid "Search albums"
msgstr "Alben durchsuchen"

Expand Down Expand Up @@ -634,70 +638,74 @@ msgid "Album details view"
msgstr "Ansicht der Albumdetails"

#: data/io.github.orontee.Argos.appdata.xml.in:33
msgid "Maintenance release."
msgid "New year's eve release!"
msgstr ""

#: data/io.github.orontee.Argos.appdata.xml.in:40
msgid "Welcome to Dutch music lovers 🇳🇱"
msgid "Maintenance release."
msgstr ""

#: data/io.github.orontee.Argos.appdata.xml.in:47
msgid "Library browser improvements and bug fixes."
msgid "Welcome to Dutch music lovers 🇳🇱"
msgstr ""

#: data/io.github.orontee.Argos.appdata.xml.in:54
msgid "Library browser improvements and bug fixes."
msgstr ""

#: data/io.github.orontee.Argos.appdata.xml.in:61
msgid "Birthday release: Argos is 1-year old!"
msgstr "Geburtstags: Argos wird 1 Jahr alt!"

#: data/io.github.orontee.Argos.appdata.xml.in:61
#: data/io.github.orontee.Argos.appdata.xml.in:68
msgid "Implement a library browser and improve performance."
msgstr ""

#: data/io.github.orontee.Argos.appdata.xml.in:68
#: data/io.github.orontee.Argos.appdata.xml.in:75
msgid "Open its eyes to the outside world!"
msgstr ""

#: data/io.github.orontee.Argos.appdata.xml.in:75
#: data/io.github.orontee.Argos.appdata.xml.in:82
msgid "Bug fixes and small enhancement."
msgstr "Fehlerbehebungen und kleine Verbesserungen."

#: data/io.github.orontee.Argos.appdata.xml.in:82
#: data/io.github.orontee.Argos.appdata.xml.in:89
msgid "Improving user experience. Once again."
msgstr "Verbesserung der Benutzererfahrung. Noch einmal."

#: data/io.github.orontee.Argos.appdata.xml.in:89
#: data/io.github.orontee.Argos.appdata.xml.in:96
msgid "Improving user experience."
msgstr "Verbesserung der Benutzererfahrung."

#: data/io.github.orontee.Argos.appdata.xml.in:96
#: data/io.github.orontee.Argos.appdata.xml.in:103
msgid "Autumnal delivery."
msgstr "Herbstliche Lieferung"

#: data/io.github.orontee.Argos.appdata.xml.in:103
#: data/io.github.orontee.Argos.appdata.xml.in:110
msgid ""
"Improve performance while browsing albums and add support for Mopidy-"
"Jellyfin."
msgstr ""
"Verbesserung der Leistung beim Durchsuchen von Alben und Unterstützung von "
"Mopidy-Jellyfin."

#: data/io.github.orontee.Argos.appdata.xml.in:110
#: data/io.github.orontee.Argos.appdata.xml.in:117
msgid "Bug fixes release."
msgstr "Fehlerbehebungen"

#: data/io.github.orontee.Argos.appdata.xml.in:117
#: data/io.github.orontee.Argos.appdata.xml.in:124
msgid "Attempt to comply to Flathub expectations."
msgstr "Versuch die Erwartungen von Flathub zu erfüllen."

#: data/io.github.orontee.Argos.appdata.xml.in:124
#: data/io.github.orontee.Argos.appdata.xml.in:131
msgid "Delivered during holidays, use at your own risks!"
msgstr "Auslieferung während der Ferien, Nutzung auf eigene Gefahr!"

#: data/io.github.orontee.Argos.appdata.xml.in:131
#: data/io.github.orontee.Argos.appdata.xml.in:138
msgid "Delivered during a toothache, use at your own risks!"
msgstr "Auslieferung mit Zahnschmerzen, Nutzung auf eigene Gefahr!"

#: data/io.github.orontee.Argos.appdata.xml.in:137
#: data/io.github.orontee.Argos.appdata.xml.in:144
msgid "Matthias Meulien"
msgstr ""

Expand Down
Loading

0 comments on commit 5e0c5af

Please sign in to comment.