[gnome-system-monitor] Preserve tree scroll position at top/bottom when new processes are added. https://bugzilla.gnome.org
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Preserve tree scroll position at top/bottom when new processes are added. https://bugzilla.gnome.org
- Date: Sun, 5 May 2013 23:11:10 +0000 (UTC)
commit 561378bd53e02e73f0d43850e47d536dd6699d38
Author: Robert Roth <robert roth off gmail com>
Date: Mon May 6 02:10:11 2013 +0300
Preserve tree scroll position at top/bottom when new processes are added.
https://bugzilla.gnome.org/show_bug.cgi?id=92724
src/procman-app.h | 4 ++++
src/proctable.cpp | 30 +++++++++++++++++++++++++++++-
2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/src/procman-app.h b/src/procman-app.h
index d698649..ad9ecc0 100644
--- a/src/procman-app.h
+++ b/src/procman-app.h
@@ -201,6 +201,10 @@ public:
guint timeout;
guint disk_timeout;
+ GtkTreePath *top_of_tree;
+ gdouble last_vscroll_max;
+ gdouble last_vscroll_value;
+
PrettyTable *pretty_table;
GSettings *settings;
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 975dcc7..e4da3bb 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -973,8 +973,36 @@ proctable_update_list (ProcmanApp *app)
glibtop_get_cpu (&cpu);
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;
+ gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(app->tree), 0,0, ¤t_top, NULL, NULL, NULL);
+ 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)
+ {
+ //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)
+ {
+ // 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)
+ {
+ // 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;
g_free (pid_list);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]