Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltips to playback controls #352

Merged
merged 2 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/app/components/playback/playback_controls.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use gettextrs::gettext;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{glib, CompositeTemplate};
Expand Down Expand Up @@ -59,9 +60,17 @@ impl PlaybackControlsWidget {
"media-playback-start-symbolic"
};

imp::PlaybackControlsWidget::from_instance(self)
.play_pause
.set_icon_name(playback_icon);
let translated_tooltip = if is_playing {
gettext("Pause")
} else {
gettext("Play")
};
let tooltip_text = Some(translated_tooltip.as_str());

let playback_control = imp::PlaybackControlsWidget::from_instance(self);

playback_control.play_pause.set_icon_name(playback_icon);
playback_control.play_pause.set_tooltip_text(tooltip_text);
}

pub fn set_shuffled(&self, shuffled: bool) {
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/playback/playback_controls.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<property name="valign">center</property>
<property name="has-frame">0</property>
<property name="icon-name">media-playlist-shuffle-symbolic</property>
<property name="tooltip-text" translatable="yes">Shuffle</property>
</object>
</child>
<child>
Expand All @@ -23,6 +24,7 @@
<property name="valign">center</property>
<property name="has-frame">0</property>
<property name="icon-name">media-skip-backward-symbolic</property>
<property name="tooltip-text" translatable="yes">Previous</property>
</object>
</child>
<child>
Expand All @@ -31,6 +33,7 @@
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">media-playback-start-symbolic</property>
<property name="tooltip-text" translatable="yes">Play/Pause</property>
<style>
<class name="circular"/>
<class name="playback-button"/>
Expand All @@ -44,6 +47,7 @@
<property name="valign">center</property>
<property name="has-frame">0</property>
<property name="icon-name">media-skip-forward-symbolic</property>
<property name="tooltip-text" translatable="yes">Next</property>
</object>
</child>
<child>
Expand All @@ -53,6 +57,7 @@
<property name="valign">center</property>
<property name="has-frame">0</property>
<property name="icon-name">media-playlist-consecutive-symbolic</property>
<property name="tooltip-text" translatable="yes">Repeat</property>
</object>
</child>
</template>
Expand Down