[gnome-music/wip/mschraal/gtk4-v2: 35/69] Adapt PlayerToolbar to GTK4 changes
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gtk4-v2: 35/69] Adapt PlayerToolbar to GTK4 changes
- Date: Sat, 22 May 2021 20:45:34 +0000 (UTC)
commit 76789b599521304cd24918b77015002ab10f366c
Author: Marinus Schraal <mschraal gnome org>
Date: Sun Apr 11 21:10:39 2021 +0200
Adapt PlayerToolbar to GTK4 changes
data/org.gnome.Music.css | 2 --
data/ui/PlayerToolbar.ui | 49 +++++++++----------------------------
gnomemusic/widgets/playertoolbar.py | 26 +++++++-------------
gnomemusic/window.py | 4 +--
4 files changed, 22 insertions(+), 59 deletions(-)
---
diff --git a/data/org.gnome.Music.css b/data/org.gnome.Music.css
index 4659aec06..4f0136076 100644
--- a/data/org.gnome.Music.css
+++ b/data/org.gnome.Music.css
@@ -55,7 +55,6 @@ box#ArtistAlbumsWidget .artist-label {
.semi-circular {
border-radius: 20px;
- -gtk-outline-radius: 20px;
}
.semi-circular:hover {
@@ -67,7 +66,6 @@ box#ArtistAlbumsWidget .artist-label {
.pill {
border-radius: 9999px;
- -gtk-outline-radius: 9999px;
}
.smooth-scale {
diff --git a/data/ui/PlayerToolbar.ui b/data/ui/PlayerToolbar.ui
index 23493a2b5..4c23ed24a 100644
--- a/data/ui/PlayerToolbar.ui
+++ b/data/ui/PlayerToolbar.ui
@@ -23,36 +23,9 @@
<attribute name="target">none</attribute>
</item>
</menu>
- <object class="GtkImage" id="next_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin-top">1</property>
- <property name="icon_name">media-skip-forward-symbolic</property>
- <property name="icon_size">1</property>
- </object>
- <object class="GtkImage" id="_pause_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin-top">1</property>
- <property name="icon_name">media-playback-pause-symbolic</property>
- <property name="icon_size">5</property>
- </object>
- <object class="GtkImage" id="_play_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin-top">1</property>
- <property name="icon_name">media-playback-start-symbolic</property>
- <property name="icon_size">5</property>
- </object>
- <object class="GtkImage" id="previous_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin-top">1</property>
- <property name="icon_name">media-skip-backward-symbolic</property>
- <property name="icon_size">1</property>
- </object>
<template class="PlayerToolbar" parent="GtkActionBar">
<property name="can_focus">False</property>
+ <property name="revealed">False</property>
<child>
<object class="GtkBox" id="_song_info_box">
<property name="visible">True</property>
@@ -112,6 +85,7 @@
</child>
<child type="center">
<object class="GtkBox" id="_buttons_and_scale">
+ <property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -128,8 +102,7 @@
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="image">previous_image</property>
- <property name="always_show_image">True</property>
+ <property name="icon_name">media-skip-backward-symbolic</property>
<property name="tooltip_text" translatable="yes">Previous</property>
<signal name="clicked" handler="_on_prev_button_clicked" swapped="no"/>
<style>
@@ -145,14 +118,18 @@
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="image">_play_image</property>
- <property name="always_show_image">True</property>
<property name="tooltip_text" translatable="yes">Play</property>
<signal name="clicked" handler="_on_play_button_clicked" swapped="no"/>
<style>
<class name="border-solid"/>
<class name="pill"/>
</style>
+ <child>
+ <object class="GtkImage" id="_play_pause_image">
+ <property name="icon_name">media-playback-start-symbolic</property>
+ <property name="icon_size">2</property>
+ </object>
+ </child>
</object>
</child>
<child>
@@ -162,8 +139,7 @@
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="image">next_image</property>
- <property name="always_show_image">True</property>
+ <property name="icon_name">media-skip-forward-symbolic</property>
<property name="tooltip_text" translatable="yes">Next</property>
<signal name="clicked" handler="_on_next_button_clicked" swapped="no"/>
<style>
@@ -224,7 +200,7 @@
</child>
</object>
</child>
- <child>
+ <child type="end">
<object class="GtkBox" id="menuBox">
<property name="height_request">34</property>
<property name="visible">True</property>
@@ -264,9 +240,6 @@
</object>
</child>
</object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
</child>
</template>
</interface>
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index de2d945f1..ae60ee43c 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -28,6 +28,7 @@ from gi.repository import GObject, Gtk
from gnomemusic.gstplayer import Playback
from gnomemusic.utils import ArtSize
from gnomemusic.player import Player, RepeatMode
+from gnomemusic.widgets.artstack import ArtStack # noqa: F401
from gnomemusic.widgets.smoothscale import SmoothScale # noqa: F401
from gnomemusic.widgets.twolinetip import TwoLineTip
import gnomemusic.utils as utils
@@ -44,12 +45,10 @@ class PlayerToolbar(Gtk.ActionBar):
_artist_label = Gtk.Template.Child()
_art_stack = Gtk.Template.Child()
- _buttons_and_scale = Gtk.Template.Child()
_duration_label = Gtk.Template.Child()
_next_button = Gtk.Template.Child()
- _pause_image = Gtk.Template.Child()
_play_button = Gtk.Template.Child()
- _play_image = Gtk.Template.Child()
+ _play_pause_image = Gtk.Template.Child()
_prev_button = Gtk.Template.Child()
_progress_scale = Gtk.Template.Child()
_progress_time_label = Gtk.Template.Child()
@@ -73,13 +72,6 @@ class PlayerToolbar(Gtk.ActionBar):
self._tooltip = TwoLineTip()
- # A centered widget has an expand child property set to False
- # by default. It needs to be True to have a progress scale
- # at the correct size.
- main_container = self._buttons_and_scale.get_parent()
- main_container.child_set_property(
- self._buttons_and_scale, "expand", True)
-
# FIXME: This is a workaround for not being able to pass the player
# object via init when using Gtk.Builder.
@GObject.Property(type=Player, default=None)
@@ -135,26 +127,26 @@ class PlayerToolbar(Gtk.ActionBar):
def _sync_repeat_image(self):
icon = self._repeat_dict[self._player.props.repeat_mode]
- self._repeat_image.set_from_icon_name(icon, Gtk.IconSize.MENU)
+ self._repeat_image.set_from_icon_name(icon)
def _sync_playing(self, player, state):
if (self._player.props.state == Playback.STOPPED
and not self._player.props.has_next
and not self._player.props.has_previous):
- self.hide()
+ self.props.revealed = False
return
- self.show()
+ self.props.revealed = True
if self._player.props.state == Playback.PLAYING:
- image = self._pause_image
+ icon_name = "media-playback-pause-symbolic"
tooltip = _("Pause")
else:
- image = self._play_image
+ icon_name = "media-playback-start-symbolic"
tooltip = _("Play")
- if self._play_button.get_image() != image:
- self._play_button.set_image(image)
+ if self._play_pause_image.props.icon_name != icon_name:
+ self._play_pause_image.props.icon_name = icon_name
self._play_button.set_tooltip_text(tooltip)
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 994dfc29f..471c11d27 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -458,7 +458,7 @@ class Window(Adw.ApplicationWindow):
def _on_selection_mode_changed(self, widget, data=None):
if (not self.props.selection_mode
and self._player.state == Playback.STOPPED):
- self._player_toolbar.hide()
+ self._player_toolbar.props.revealed = False
def _on_add_to_playlist(self, widget):
if self.props.active_view == self.views[View.PLAYLIST]:
@@ -483,4 +483,4 @@ class Window(Adw.ApplicationWindow):
:param bool visible: actionbar visibility
"""
- self._player_toolbar.set_visible(visible)
+ self._player_toolbar.props.revealed = visible
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]