Resolves #16: added tooltips to all of the buttons

This commit is contained in:
Sumner Evans
2020-03-18 22:59:19 -06:00
parent 008821d988
commit fa58933f19
8 changed files with 69 additions and 26 deletions

View File

@@ -85,7 +85,7 @@ class AlbumsPanel(Gtk.Box):
self.to_year_spin_button.connect('value-changed', self.on_year_changed)
actionbar.pack_start(self.to_year_spin_button)
refresh = IconButton('view-refresh-symbolic')
refresh = IconButton('view-refresh-symbolic', 'Refresh list of albums')
refresh.connect('clicked', self.on_refresh_clicked)
actionbar.pack_end(refresh)

View File

@@ -70,7 +70,8 @@ class ArtistList(Gtk.Box):
list_actions = Gtk.ActionBar()
refresh = IconButton('view-refresh-symbolic')
refresh = IconButton(
'view-refresh-symbolic', 'Refresh list of artists')
refresh.connect('clicked', lambda *a: self.update(force=True))
list_actions.pack_end(refresh)
@@ -195,12 +196,14 @@ class ArtistDetailPanel(Gtk.Box):
self.artist_action_buttons = Gtk.Box(
orientation=Gtk.Orientation.HORIZONTAL)
view_refresh_button = IconButton('view-refresh-symbolic')
view_refresh_button = IconButton(
'view-refresh-symbolic', 'Refresh artist info')
view_refresh_button.connect('clicked', self.on_view_refresh_click)
self.artist_action_buttons.pack_end(
view_refresh_button, False, False, 5)
download_all_btn = IconButton('folder-download-symbolic')
download_all_btn = IconButton(
'folder-download-symbolic', 'Download all songs by this artist')
download_all_btn.connect('clicked', self.on_download_all_click)
self.artist_action_buttons.pack_end(download_all_btn, False, False, 5)

View File

@@ -209,7 +209,7 @@ class DrilldownList(Gtk.Box):
list_actions = Gtk.ActionBar()
refresh = IconButton('view-refresh-symbolic')
refresh = IconButton('view-refresh-symbolic', 'Refresh folder')
refresh.connect('clicked', self.on_refresh_clicked)
list_actions.pack_end(refresh)

View File

@@ -76,26 +76,41 @@ class AlbumWithSongs(Gtk.Box):
))
self.play_btn = IconButton(
'media-playback-start-symbolic', sensitive=False)
'media-playback-start-symbolic',
'Play all songs in this album',
sensitive=False,
)
self.play_btn.connect('clicked', self.play_btn_clicked)
album_title_and_buttons.pack_start(self.play_btn, False, False, 5)
self.shuffle_btn = IconButton(
'media-playlist-shuffle-symbolic', sensitive=False)
'media-playlist-shuffle-symbolic',
'Shuffle all songs in this album',
sensitive=False,
)
self.shuffle_btn.connect('clicked', self.shuffle_btn_clicked)
album_title_and_buttons.pack_start(self.shuffle_btn, False, False, 5)
self.play_next_btn = IconButton(
'go-top-symbolic', action_name='app.play-next')
'go-top-symbolic',
'Play all of the songs in this album next',
action_name='app.play-next',
)
album_title_and_buttons.pack_start(self.play_next_btn, False, False, 5)
self.add_to_queue_btn = IconButton(
'go-jump-symbolic', action_name='app.add-to-queue')
'go-jump-symbolic',
'Add all the songs in this album to the end of the play queue',
action_name='app.add-to-queue',
)
album_title_and_buttons.pack_start(
self.add_to_queue_btn, False, False, 5)
self.download_all_btn = IconButton(
'folder-download-symbolic', sensitive=False)
'folder-download-symbolic',
'Download all songs in this album',
sensitive=False,
)
self.download_all_btn.connect('clicked', self.on_download_all_click)
album_title_and_buttons.pack_end(
self.download_all_btn, False, False, 5)

View File

@@ -9,6 +9,7 @@ class IconButton(Gtk.Button):
def __init__(
self,
icon_name: Optional[str],
tooltip_text: str = '',
relief: bool = False,
icon_size: Gtk.IconSize = Gtk.IconSize.BUTTON,
label: str = None,
@@ -31,6 +32,7 @@ class IconButton(Gtk.Button):
self.props.relief = Gtk.ReliefStyle.NONE
self.add(box)
self.set_tooltip_text(tooltip_text)
def set_icon(self, icon_name: Optional[str]):
self.image.set_from_icon_name(icon_name, self.icon_size)
@@ -40,6 +42,7 @@ class IconToggleButton(Gtk.ToggleButton):
def __init__(
self,
icon_name: Optional[str],
tooltip_text: str = '',
relief: bool = False,
icon_size: Gtk.IconSize = Gtk.IconSize.BUTTON,
label: str = None,
@@ -61,6 +64,7 @@ class IconToggleButton(Gtk.ToggleButton):
self.props.relief = Gtk.ReliefStyle.NONE
self.add(box)
self.set_tooltip_text(tooltip_text)
def set_icon(self, icon_name: Optional[str]):
self.image.set_from_icon_name(icon_name, self.icon_size)

View File

@@ -135,6 +135,7 @@ class MainWindow(Gtk.ApplicationWindow):
# Menu button
menu_button = Gtk.MenuButton()
menu_button.set_tooltip_text('Open application menu')
menu_button.set_use_popover(True)
menu_button.set_popover(self._create_menu())
menu_button.connect('clicked', self._on_menu_clicked)

View File

@@ -87,6 +87,7 @@ class PlayerControls(Gtk.ActionBar):
icon = 'pause' if state.playing else 'start'
self.play_button.set_icon(f"media-playback-{icon}-symbolic")
self.play_button.set_tooltip_text('Pause' if state.playing else 'Play')
has_current_song = state.current_song is not None
has_next_song = False
@@ -510,7 +511,8 @@ class PlayerControls(Gtk.ActionBar):
# Repeat button
repeat_button_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.repeat_button = IconToggleButton('media-playlist-repeat')
self.repeat_button = IconToggleButton(
'media-playlist-repeat', 'Switch between repeat modes')
self.repeat_button.set_action_name('app.repeat-press')
repeat_button_box.pack_start(Gtk.Box(), True, True, 0)
repeat_button_box.pack_start(self.repeat_button, False, False, 0)
@@ -520,6 +522,7 @@ class PlayerControls(Gtk.ActionBar):
# Previous button
self.prev_button = IconButton(
'media-skip-backward-symbolic',
'Go to previous song',
icon_size=Gtk.IconSize.LARGE_TOOLBAR)
self.prev_button.set_action_name('app.prev-track')
buttons.pack_start(self.prev_button, False, False, 5)
@@ -527,6 +530,7 @@ class PlayerControls(Gtk.ActionBar):
# Play button
self.play_button = IconButton(
'media-playback-start-symbolic',
'Play',
relief=True,
icon_size=Gtk.IconSize.LARGE_TOOLBAR)
self.play_button.set_name('play-button')
@@ -536,6 +540,7 @@ class PlayerControls(Gtk.ActionBar):
# Next button
self.next_button = IconButton(
'media-skip-forward-symbolic',
'Go to next song',
icon_size=Gtk.IconSize.LARGE_TOOLBAR)
self.next_button.set_action_name('app.next-track')
buttons.pack_start(self.next_button, False, False, 5)
@@ -543,7 +548,7 @@ class PlayerControls(Gtk.ActionBar):
# Shuffle button
shuffle_button_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.shuffle_button = IconToggleButton(
'media-playlist-shuffle-symbolic')
'media-playlist-shuffle-symbolic', 'Toggle playlist shuffling')
self.shuffle_button.set_action_name('app.shuffle-press')
shuffle_button_box.pack_start(Gtk.Box(), True, True, 0)
shuffle_button_box.pack_start(self.shuffle_button, False, False, 0)
@@ -562,7 +567,10 @@ class PlayerControls(Gtk.ActionBar):
# Device button (for chromecast)
self.device_button = IconButton(
'video-display-symbolic', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
'video-display-symbolic',
'Show available audio output devices',
icon_size=Gtk.IconSize.LARGE_TOOLBAR,
)
self.device_button.connect('clicked', self.on_device_click)
box.pack_start(self.device_button, False, True, 5)
@@ -586,7 +594,8 @@ class PlayerControls(Gtk.ActionBar):
)
device_popover_header.add(self.popover_label)
refresh_devices = IconButton('view-refresh-symbolic')
refresh_devices = IconButton(
'view-refresh-symbolic', 'Refresh device list')
refresh_devices.connect('clicked', self.on_device_refresh_click)
device_popover_header.pack_end(refresh_devices, False, False, 0)
@@ -619,7 +628,10 @@ class PlayerControls(Gtk.ActionBar):
# Play Queue button
self.play_queue_button = IconButton(
'view-list-symbolic', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
'view-list-symbolic',
'Open play queue',
icon_size=Gtk.IconSize.LARGE_TOOLBAR,
)
self.play_queue_button.connect('clicked', self.on_play_queue_click)
box.pack_start(self.play_queue_button, False, True, 5)
@@ -641,7 +653,8 @@ class PlayerControls(Gtk.ActionBar):
)
play_queue_popover_header.add(self.popover_label)
load_play_queue = Gtk.Button(label='Load Queue from Server', margin=5)
load_play_queue = IconButton(
'folder-download-symbolic', 'Load Queue from Server', margin=5)
load_play_queue.set_action_name('app.update-play-queue-from-server')
play_queue_popover_header.pack_end(load_play_queue, False, False, 0)
@@ -725,7 +738,8 @@ class PlayerControls(Gtk.ActionBar):
self.play_queue_popover.add(play_queue_popover_box)
# Volume mute toggle
self.volume_mute_toggle = IconButton('audio-volume-high-symbolic')
self.volume_mute_toggle = IconButton(
'audio-volume-high-symbolic', 'Toggle mute')
self.volume_mute_toggle.set_action_name('app.mute-toggle')
box.pack_start(self.volume_mute_toggle, False, True, 0)

View File

@@ -95,7 +95,8 @@ class PlaylistList(Gtk.Box):
new_playlist_button.connect('clicked', self.on_new_playlist_clicked)
playlist_list_actions.pack_start(new_playlist_button)
list_refresh_button = IconButton('view-refresh-symbolic')
list_refresh_button = IconButton(
'view-refresh-symbolic', 'Refresh list of playlists')
list_refresh_button.connect('clicked', self.on_list_refresh_click)
playlist_list_actions.pack_end(list_refresh_button)
@@ -126,6 +127,7 @@ class PlaylistList(Gtk.Box):
confirm_button = IconButton(
'object-select-symbolic',
'Create playlist',
name='playlist-list-new-playlist-confirm',
relief=True,
)
@@ -134,6 +136,7 @@ class PlaylistList(Gtk.Box):
self.cancel_button = IconButton(
'process-stop-symbolic',
'Cancel create playlist',
name='playlist-list-new-playlist-cancel',
relief=True,
)
@@ -281,18 +284,21 @@ class PlaylistDetailPanel(Gtk.Overlay):
self.playlist_action_buttons = Gtk.Box(
orientation=Gtk.Orientation.HORIZONTAL)
view_refresh_button = IconButton('view-refresh-symbolic')
view_refresh_button = IconButton(
'view-refresh-symbolic', 'Refresh playlist info')
view_refresh_button.connect('clicked', self.on_view_refresh_click)
self.playlist_action_buttons.pack_end(
view_refresh_button, False, False, 5)
playlist_edit_button = IconButton('document-edit-symbolic')
playlist_edit_button = IconButton(
'document-edit-symbolic', 'Edit paylist')
playlist_edit_button.connect(
'clicked', self.on_playlist_edit_button_click)
self.playlist_action_buttons.pack_end(
playlist_edit_button, False, False, 5)
download_all_button = IconButton('folder-download-symbolic')
download_all_button = IconButton(
'folder-download-symbolic', 'Download all songs in the playlist')
download_all_button.connect(
'clicked', self.on_playlist_list_download_all_button_click)
self.playlist_action_buttons.pack_end(
@@ -363,11 +369,11 @@ class PlaylistDetailPanel(Gtk.Overlay):
return max(row_score(key, row) for row in rows)
def playlist_song_list_search_fn(
model: Gtk.ListStore,
col: int,
key: str,
treeiter: Gtk.TreeIter,
data: Any = None,
model: Gtk.ListStore,
col: int,
key: str,
treeiter: Gtk.TreeIter,
data: Any = None,
) -> bool:
# TODO (#28): this is very inefficient, it's slow when the result
# is close to the bottom of the list. Would be good to research