Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
f5635b84 by wurstsalat at 2023-02-10T21:53:50+01:00
imprv: Audio preview: Allow skipping by clicking the visualization
Closes #11392
- - - - -
2 changed files:
- gajim/gtk/preview_audio.py
- gajim/gtk/preview_audio_visualizer.py
Changes:
=====================================
gajim/gtk/preview_audio.py
=====================================
@@ -268,9 +268,20 @@ def _setup_audio_visualizer(self) -> None:
height,
SEEK_BAR_PADDING,
)
+ self._audio_visualizer.connect(
+ 'button-press-event', self._on_visualizer_button_press)
self._ui.drawing_box.add(self._audio_visualizer)
+ def _on_visualizer_button_press(self,
+ drawing_area: Gtk.DrawingArea,
+ event: Gdk.EventButton
+ ) -> bool:
+
+ relative_pos = event.x / drawing_area.get_allocation().width
+ self._seek_unconditionally(self._state.duration * relative_pos)
+ return False
+
def _update_timestamp_label(self) -> None:
cur = self._state.position
dur = self._state.duration
=====================================
gajim/gtk/preview_audio_visualizer.py
=====================================
@@ -47,6 +47,9 @@ def __init__(self,
self._seek_position = -1.0
self._position = 0.0
+ # Add EventMask to receive button press events (for skipping)
+ self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
+
self.connect('draw', self._on_drawingarea_draw)
self.connect('configure-event', self._on_drawingarea_changed)
self.connect('style-updated', self._on_style_updated)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/f5635b840dd875ec89411f2084937908bd77df68
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/f5635b840dd875ec89411f2084937908bd77df68
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits