Philipp Hörist pushed to branch master at gajim / gajim


Commits:
535b8bb2 by mesonium at 2023-04-04T21:04:57+02:00
fix: Audio Preview: Set correct pos when clicking into visualizer

- - - - -


2 changed files:

- gajim/data/gui/preview_audio.ui
- gajim/gtk/preview_audio.py


Changes:

=====================================
gajim/data/gui/preview_audio.ui
=====================================
@@ -33,6 +33,7 @@
             <property name="can-focus">False</property>
             <property name="valign">center</property>
             <property name="orientation">vertical</property>
+            <signal name="button-press-event" 
handler="_on_visualizer_button_press_event" swapped="no"/>
             <child>
               <placeholder/>
             </child>


=====================================
gajim/gtk/preview_audio.py
=====================================
@@ -270,19 +270,21 @@ 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,
+    def _on_visualizer_button_press_event(self,
                                     drawing_area: Gtk.DrawingArea,
                                     event: Gdk.EventButton
-                                    ) -> bool:
+                                    ) -> None:
+        width = drawing_area.get_allocation().width - 2 * SEEK_BAR_PADDING
 
-        relative_pos = event.x / drawing_area.get_allocation().width
-        self._seek_unconditionally(self._state.duration * relative_pos)
-        return False
+        if self._is_LTR:
+            x = event.x - SEEK_BAR_PADDING
+        else:
+            x = width - (event.x - SEEK_BAR_PADDING)
+
+        new_pos = self._state.duration * x / width
+        self._seek_unconditionally(new_pos)
 
     def _update_timestamp_label(self) -> None:
         cur = self._state.position
@@ -303,10 +305,6 @@ def _update_seek_bar_and_visualisation(self) -> bool:
         if self._playbin.query(self._query):
             _fmt, position = self._query.parse_position()
 
-            if position is None:
-                self._timeout_id = -1
-                return False
-
             if not self._pause_seek:
                 self._state.position = position
                 self._ui.seek_bar.set_value(self._state.position)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/535b8bb2b324948c49f308deb8f5a0b83909394e

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/535b8bb2b324948c49f308deb8f5a0b83909394e
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

Reply via email to