[gnome-system-monitor] Fix logic for scrolling treeview to the bottom



commit c46bf03239018fa9b365b63e25b882d81d569fe8
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Mon Jul 29 23:52:21 2013 +0200

    Fix logic for scrolling treeview to the bottom
    
    It should scroll when the treeview was already scrolled to
    the bottom (i.e. last_vscroll_value == last_vscroll_max).
    
    While touching it, fix style and simplify a conditional.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705126

 src/proctable.cpp |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 98da8b5..0f34935 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -1097,32 +1097,31 @@ proctable_update_list (ProcmanApp *app)
     app->cpu_total_time = MAX(cpu.total - app->cpu_total_time_last, 1);
     app->cpu_total_time_last = cpu.total;
     
-    GtkAdjustment* vadjustment = GTK_ADJUSTMENT(gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(app->tree)));
     refresh_list (app, pid_list, proclist.number);
-    
+
     // juggling with tree scroll position to fix https://bugzilla.gnome.org/show_bug.cgi?id=92724
     GtkTreePath* current_top;
     if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(app->tree), 0,0, &current_top, NULL, NULL, NULL)) {
+        GtkAdjustment *vadjustment = GTK_ADJUSTMENT (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE 
(app->tree)));
         gdouble current_max = gtk_adjustment_get_upper(vadjustment);
         gdouble current_value = gtk_adjustment_get_value(vadjustment);
+
         if (app->top_of_tree) {
             // if the visible cell from the top of the tree is still the same, as last time 
-            if (gtk_tree_path_compare(app->top_of_tree, current_top) == 0) 
-            {
+            if (gtk_tree_path_compare (app->top_of_tree, current_top) == 0) {
                 //but something from the scroll parameters has changed compared to the last values
-                if (app->last_vscroll_value==0 && current_value!=app->last_vscroll_value) 
-                {
+                if (app->last_vscroll_value == 0 && current_value != 0) {
                     // the tree was scrolled to top, and something has been added above the current top row
                     gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(app->tree), -1, 0);
-                }
-                else if (current_max > app->last_vscroll_max && current_value == app->last_vscroll_value)
-                {
+                } else if (current_max > app->last_vscroll_max && app->last_vscroll_max == 
app->last_vscroll_value) {
                     // the tree was scrolled to bottom, something has been added below the current bottom row
                     gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(app->tree), -1, current_max);
                 }
             }
+
             gtk_tree_path_free(app->top_of_tree);
         }
+
         app->top_of_tree = current_top;
         app->last_vscroll_value = current_value;
         app->last_vscroll_max = current_max;


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