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


Commits:
225c839a by mesonium at 2024-10-31T19:55:53+01:00
refactor: Hardcode colors and render on eos

- Hardcode colors and avoid state flag change hack to prevent segfaults.
- Render the graph on EOS again, otherwise the wrong seeking color may be shown.

- - - - -


3 changed files:

- gajim/data/style/gajim.css
- gajim/gtk/preview_audio.py
- gajim/gtk/preview_audio_visualizer.py


Changes:

=====================================
gajim/data/style/gajim.css
=====================================
@@ -820,17 +820,6 @@ .preview-image-button:hover {
     box-shadow: none;
 }
 
-/* Audiovisualizer */
-.audiovisualizer {
-    color: @insensitive_fg_color;
-}
-.audiovisualizer:checked {
-    color: @theme_selected_bg_color;
-}
-.audiovisualizer:selected {
-    color: lighter(@theme_selected_bg_color);
-}
-
 /* Conversation meta elements */
 .conversation-meta {
     opacity: 0.6;


=====================================
gajim/gtk/preview_audio.py
=====================================
@@ -388,6 +388,8 @@ def _update_seek_bar_and_visualisation(self) -> bool:
                 self._seek_pos / self._state.duration)
 
             if self._state.is_eos:
+                self._audio_visualizer.render_static_graph(
+                    self._state.position / self._state.duration)
                 self._remove_seek_bar_update_idle()
 
         return True
@@ -626,7 +628,6 @@ def _on_visualizer_button_pressed(
         _y: float,
     ) -> int:
         assert self._cursor_pos is not None
-        self._pause_seek = True
         width = self._audio_visualizer.get_width() - SEEK_BAR_PADDING
         new_pos = self._state.duration * x / width
         self._seek_unconditionally(new_pos)


=====================================
gajim/gtk/preview_audio_visualizer.py
=====================================
@@ -14,6 +14,7 @@
 
 from gajim.common import app
 from gajim.common.preview import AudioSampleT
+from gajim.gtk.util import make_rgba
 
 log = logging.getLogger('gajim.gtk.preview_audio_visualizer')
 
@@ -44,6 +45,11 @@ def __init__(
 
         self._waveform_path = None
 
+        # TODO: Hard code colors for now to workaround segfault
+        self._color_default = make_rgba('rgb(170,180,200)')
+        self._color_progress = make_rgba('rgb(30,144,255)')
+        self._color_seek = make_rgba('rgb(77,166,255)')
+
     def do_unroot(self) -> None:
         Gtk.Widget.do_unroot(self)
         app.check_finalize(self)
@@ -104,9 +110,8 @@ def do_snapshot(self, snapshot: Gtk.Snapshot) -> None:
         snapshot.push_clip(
             Graphene.Rect().init(0, 0, self._width, self._height)
         )
-        self.set_state_flags(Gtk.StateFlags.NORMAL, True)
         snapshot.append_fill(
-            self._waveform_path, Gsk.FillRule.WINDING, self.get_color()
+            self._waveform_path, Gsk.FillRule.WINDING, self._color_default
         )
         snapshot.pop()
 
@@ -114,9 +119,8 @@ def do_snapshot(self, snapshot: Gtk.Snapshot) -> None:
         snapshot.push_clip(
             Graphene.Rect().init(0, 0, play_pos, self._height)
         )
-        self.set_state_flags(Gtk.StateFlags.CHECKED, True)
         snapshot.append_fill(
-            self._waveform_path, Gsk.FillRule.WINDING, self.get_color()
+            self._waveform_path, Gsk.FillRule.WINDING, self._color_progress
         )
         snapshot.pop()
 
@@ -130,9 +134,8 @@ def do_snapshot(self, snapshot: Gtk.Snapshot) -> None:
             snapshot.push_clip(
                 Graphene.Rect().init(start_seek, 0, width_seek, self._height)
             )
-            self.set_state_flags(Gtk.StateFlags.SELECTED,  True)
             snapshot.append_fill(
-                self._waveform_path, Gsk.FillRule.WINDING, self.get_color()
+                self._waveform_path, Gsk.FillRule.WINDING, self._color_seek
             )
             snapshot.pop()
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/225c839a6abfc6e99234c11924efd91ce957e0c4

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/225c839a6abfc6e99234c11924efd91ce957e0c4
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to