[gnome-system-monitor] Scroll process table to the selected row.



commit d85a4450aec3ed1833702cd3e8ea1665dbb540c1
Author: Aldo Nogueira <aldo nogueira gmail com>
Date:   Sat Jan 13 10:45:05 2018 -0200

    Scroll process table to the selected row.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792574

 src/interface.cpp |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/interface.cpp b/src/interface.cpp
index 6534ef5..414d9c5 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -755,6 +755,21 @@ create_main_window (GsmApplication *app)
     g_object_unref (G_OBJECT (builder));
 }
 
+gboolean
+scroll_to_selection (gpointer data)
+{
+    GsmApplication *app = (GsmApplication *) data;
+    GList* paths = gtk_tree_selection_get_selected_rows (app->selection, NULL);
+    guint length = g_list_length(paths);
+    if (length > 0) {
+        GtkTreePath* last_path = (GtkTreePath*) g_list_nth_data(paths, length - 1);
+        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (app->tree), last_path, NULL, FALSE, 0.0, 0.0);
+    }
+
+    g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
+    return FALSE;
+}
+
 void
 update_sensitivity(GsmApplication *app)
 {
@@ -795,4 +810,9 @@ update_sensitivity(GsmApplication *app)
 
     gtk_revealer_set_reveal_child (GTK_REVEALER (app->proc_actionbar_revealer),
                                    selected_sensitivity);
+
+    // Scrolls the table to selected row. Useful when the last row is obstructed by the revealer
+    guint duration_ms = gtk_revealer_get_transition_duration (GTK_REVEALER (app->proc_actionbar_revealer));
+    g_timeout_add (duration_ms, scroll_to_selection, app);
 }
+


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