fixup! Port UI to GTK 4

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

View file

@ -59,19 +59,8 @@
</object> </object>
</child> </child>
</object> </object>
<!--
<packing>
<property name="name">cover-scroll</property>
<property name="position">1</property>
</packing>
-->
</child> </child>
</object> </object>
<!--
<packing>
<property name="index">-1</property>
</packing>
-->
</child> </child>
<child type="overlay"> <child type="overlay">
<object class="GtkRevealer" id="info_revealer"> <object class="GtkRevealer" id="info_revealer">
@ -90,9 +79,6 @@
<property name="name">cover_info_scroll</property> <property name="name">cover_info_scroll</property>
<child> <child>
<object class="GtkViewport"> <object class="GtkViewport">
<!--
<property name="shadow-type">none</property>
-->
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
@ -149,14 +135,6 @@
</object> </object>
</child> </child>
</object> </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>
<child> <child>
<object class="GtkScale" id="songs_scale"> <object class="GtkScale" id="songs_scale">
@ -166,19 +144,7 @@
<property name="restrict-to-fill-level">False</property> <property name="restrict-to-fill-level">False</property>
<property name="digits">0</property> <property name="digits">0</property>
<property name="draw-value">False</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> </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> </child>
</object> </object>
</child> </child>

View file

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