diff options
| author | Marvin W <git@larma.de> | 2025-04-07 15:28:51 +0200 |
|---|---|---|
| committer | Marvin W <git@larma.de> | 2025-04-07 15:28:51 +0200 |
| commit | 5bf4223acabc3889b5371c517b08db78f508e03f (patch) | |
| tree | 6e79c9eef38dc6450d965c0ec55c075473e864ea /main/src/ui/conversation_content_view | |
| parent | 7dc815ac4d196f01ce76fc5e61ef13b02dace15e (diff) | |
Add Cairo fallback for GTK<4.14
Diffstat (limited to 'main/src/ui/conversation_content_view')
| -rw-r--r-- | main/src/ui/conversation_content_view/file_transmission_progress.vala | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/main/src/ui/conversation_content_view/file_transmission_progress.vala b/main/src/ui/conversation_content_view/file_transmission_progress.vala index a69b547f..711e0822 100644 --- a/main/src/ui/conversation_content_view/file_transmission_progress.vala +++ b/main/src/ui/conversation_content_view/file_transmission_progress.vala @@ -76,30 +76,37 @@ namespace Dino.Ui { } } +#if GTK_4_14 private static extern Gsk.Path create_progress_arc(Gsk.Path circle, float percentage); +#endif public override void snapshot(Gtk.Snapshot snapshot) { base.snapshot(snapshot); - if (state == State.DOWNLOADING || state == State.UPLOADING) { + if ((state == State.DOWNLOADING || state == State.UPLOADING) && progress_animation.value > 0.01) { Gdk.RGBA fg_color = get_color(); get_style_context().lookup_color("accent_color", out fg_color); float radius = float.max(int.min(get_width(), get_height()) / 2, 1); float line_width = (float) LINE_WIDTH; - var stroke = new Gsk.Stroke(line_width); - stroke.set_line_cap(Gsk.LineCap.ROUND); - snapshot.translate({get_width() / 2, get_height() / 2}); - +#if GTK_4_14 var builder = new Gsk.PathBuilder(); builder.add_circle({0, 0}, radius - line_width / 2); var circle_path = builder.to_path(); - if (progress_animation.value > 0.01) { - var arc_path = create_progress_arc(circle_path, (float) progress_animation.value); - snapshot.append_stroke(arc_path, stroke, fg_color); - } + var stroke = new Gsk.Stroke(line_width); + stroke.set_line_cap(Gsk.LineCap.ROUND); + var arc_path = create_progress_arc(circle_path, (float) progress_animation.value); + snapshot.append_stroke(arc_path, stroke, fg_color); +#else + var context = snapshot.append_cairo({{-radius, -radius}, {radius*2, radius*2}}); + context.set_line_cap(Cairo.LineCap.ROUND); + context.set_line_width(line_width); + context.set_source_rgba(fg_color.red, fg_color.green, fg_color.blue, fg_color.alpha); + context.arc(0, 0, radius - line_width / 2, -0.5 * Math.PI, (progress_animation.value - 0.25) * 2 * Math.PI); + context.stroke(); +#endif } } |
