From 497957265feeb16fa9c93718d9eb21a2c1f80df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 28 May 2024 16:37:41 -0700 Subject: [PATCH 1/2] Terminal: gtk4prep --- src/Views/ProgressView.vala | 2 ++ src/Widgets/Terminal.vala | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Views/ProgressView.vala b/src/Views/ProgressView.vala index 313f07909..3b52e5efb 100644 --- a/src/Views/ProgressView.vala +++ b/src/Views/ProgressView.vala @@ -203,7 +203,9 @@ public class ProgressView : AbstractInstallerView { } private void fake_status (Distinst.Step step) { + unowned var log_helper = LogHelper.get_default (); for (var percent = 0; percent <= 100; percent++) { + log_helper.log_func (INFO, "I'm faking it!"); Distinst.Status status = Distinst.Status () { step = step, percent = percent diff --git a/src/Widgets/Terminal.vala b/src/Widgets/Terminal.vala index d27e5fd7e..aa210277a 100644 --- a/src/Widgets/Terminal.vala +++ b/src/Widgets/Terminal.vala @@ -17,12 +17,13 @@ * Authored by: Michael Aaron Murphy */ -public class Installer.Terminal : Gtk.ScrolledWindow { +public class Installer.Terminal : Gtk.Box { public signal void toggled (bool active); public Gtk.TextBuffer buffer { get; construct; } private Gtk.TextView view; private double prev_upper_adj = 0; + private Gtk.ScrolledWindow scrolled_window; public string log { owned get { @@ -46,18 +47,25 @@ public class Installer.Terminal : Gtk.ScrolledWindow { }; view.get_style_context ().remove_class (Gtk.STYLE_CLASS_VIEW); - hscrollbar_policy = Gtk.PolicyType.NEVER; - hexpand = true; - vexpand = true; - min_content_height = 120; - add (view); - get_style_context ().add_class (Granite.STYLE_CLASS_TERMINAL); + scrolled_window = new Gtk.ScrolledWindow (null, null) { + child = view, + hexpand = true, + vexpand = true, + hscrollbar_policy = NEVER, + min_content_height = 120 + }; + scrolled_window.get_style_context ().add_class (Granite.STYLE_CLASS_TERMINAL); + + add (scrolled_window); - view.size_allocate.connect (() => attempt_scroll ()); + Idle.add (() => { + attempt_scroll (); + return GLib.Source.CONTINUE; + }); } public void attempt_scroll () { - var adj = vadjustment; + var adj = scrolled_window.vadjustment; var units_from_end = prev_upper_adj - adj.page_size - adj.value; var view_size_difference = adj.upper - prev_upper_adj; From c7b64a803b1caea2950b6f8d15fb276fc7487cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 19 Jun 2024 09:12:46 -0700 Subject: [PATCH 2/2] Return if no view size difference --- src/Widgets/Terminal.vala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Widgets/Terminal.vala b/src/Widgets/Terminal.vala index aa210277a..344e2ed25 100644 --- a/src/Widgets/Terminal.vala +++ b/src/Widgets/Terminal.vala @@ -66,11 +66,10 @@ public class Installer.Terminal : Gtk.Box { public void attempt_scroll () { var adj = scrolled_window.vadjustment; - var units_from_end = prev_upper_adj - adj.page_size - adj.value; - var view_size_difference = adj.upper - prev_upper_adj; - if (view_size_difference < 0) { - view_size_difference = 0; + + if (adj.upper - prev_upper_adj <= 0) { + return; } if (prev_upper_adj <= adj.page_size || units_from_end <= 50) {