fixup! Port UI to GTK 4

This commit is contained in:
coderkun 2023-11-26 15:52:45 +01:00
parent 9f76163043
commit 754556bb92
2 changed files with 12 additions and 46 deletions

View file

@ -59,19 +59,8 @@
</object>
</child>
</object>
<!--
<packing>
<property name="name">cover-scroll</property>
<property name="position">1</property>
</packing>
-->
</child>
</object>
<!--
<packing>
<property name="index">-1</property>
</packing>
-->
</child>
<child type="overlay">
<object class="GtkRevealer" id="info_revealer">
@ -90,9 +79,6 @@
<property name="name">cover_info_scroll</property>
<child>
<object class="GtkViewport">
<!--
<property name="shadow-type">none</property>
-->
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
@ -149,14 +135,6 @@
</object>
</child>
</object>
<!--
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="position">0</property>
</packing>
-->
</child>
<child>
<object class="GtkScale" id="songs_scale">
@ -166,19 +144,7 @@
<property name="restrict-to-fill-level">False</property>
<property name="digits">0</property>
<property name="draw-value">False</property>
<!--
<signal name="button-press-event" handler="on_songs_start_change" swapped="no"/>
<signal name="button-release-event" handler="on_songs_change" swapped="no"/>
-->
</object>
<!--
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
-->
</child>
</object>
</child>

View file

@ -68,6 +68,12 @@ class CoverPanel(Gtk.Overlay):
clickController.connect('pressed', self.on_cover_box_pressed)
self.cover_box.add_controller(clickController)
# Button controller for songs scale
buttonController = Gtk.GestureClick()
buttonController.connect('pressed', self.on_songs_scale_pressed)
buttonController.connect('unpaired-release', self.on_songs_scale_released)
self.songs_scale.add_controller(buttonController)
def get_toolbar(self):
return self.toolbar
@ -87,16 +93,12 @@ class CoverPanel(Gtk.Overlay):
self.cover_info_scroll.set_max_content_width(width // 2)
# FIXME on_songs_start_change()
#@Gtk.Template.Callback()
#def on_songs_start_change(self, widget, event):
# if self._timer:
# GObject.source_remove(self._timer)
# self._timer = None
def on_songs_scale_pressed(self, widget, npress, x, y):
if self._timer:
GObject.source_remove(self._timer)
self._timer = None
#@Gtk.Template.Callback()
def on_songs_change(self, widget, event):
def on_songs_scale_released(self, widget, x, y, npress, sequence):
value = int(self.songs_scale.get_value())
time = self._current_album.get_length()
tracks = self._current_album.get_tracks()
@ -233,7 +235,7 @@ class CoverPanel(Gtk.Overlay):
"""Diese Methode skaliert das geladene Bild aus dem Pixelpuffer
auf die Größe des Fensters unter Beibehalt der Seitenverhältnisse
"""
# FIXME Get size
# Get size
size_width = self.cover_stack.get_size(Gtk.Orientation.HORIZONTAL)
size_height = self.cover_stack.get_size(Gtk.Orientation.HORIZONTAL)
# Abort if size is the same
@ -260,7 +262,5 @@ class CoverPanel(Gtk.Overlay):
height = int(math.floor(pixbuf.get_height()*ratio))
if width <= 0 or height <= 0:
return
# FIXME Pixelpuffer auf Oberfläche zeichnen
#self.cover_image.set_allocation(self.cover_scroll.get_allocation())
self.cover_image.set_from_pixbuf(pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.HYPER))
self.cover_image.show()