[gnome-calculator] Fixed scroll to bottom on history entry insert



commit 64f6c94b07ad56539665547a59916916fd917b45
Author: Robert Roth <robert roth off gmail com>
Date:   Thu Oct 20 10:27:38 2016 +0300

    Fixed scroll to bottom on history entry insert

 data/history-view.ui  |    1 -
 src/math-history.vala |    6 ++++--
 2 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/data/history-view.ui b/data/history-view.ui
index 6e993e6..0568f9f 100644
--- a/data/history-view.ui
+++ b/data/history-view.ui
@@ -3,7 +3,6 @@
 <interface>
   <requires lib="gtk+" version="3.16"/>
   <template class="HistoryView" parent="GtkScrolledWindow">
-    <property name="width_request">100</property>
     <property name="height_request">114</property>
     <property name="visible">True</property>
     <property name="can_focus">True</property>
diff --git a/src/math-history.vala b/src/math-history.vala
index d767f91..ed91b2f 100644
--- a/src/math-history.vala
+++ b/src/math-history.vala
@@ -30,7 +30,9 @@ public class HistoryView : Gtk.ScrolledWindow
     [GtkCallback]
     public void scroll_bottom ()
     {
-        var adjustment = get_vadjustment ();
+        var adjustment = listbox.get_adjustment ();
+        // TODO make this dynamic, do not hardcode listbox_height_request/number_of_rows
+        adjustment.page_size = 114 / 3;
         adjustment.set_value (adjustment.get_upper () - adjustment.get_page_size ());
     }
 
@@ -51,7 +53,7 @@ public class HistoryView : Gtk.ScrolledWindow
 
         var entry = new HistoryEntry (equation, answer_four_digits, answer_nine_digits);
 
-        listbox.add (entry);
+        listbox.insert (entry, -1);
         entry.show ();
         no_ofitems++;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]