[gnome-games] ui: Reset scroll position when selecting rows in sidebar



commit be5ff7caf848dc10c12a09cd3323eb1e120af36b
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sat Aug 4 15:23:50 2018 +0500

    ui: Reset scroll position when selecting rows in sidebar

 src/ui/collection-icon-view.vala | 5 +++++
 src/ui/sidebar-view.vala         | 1 +
 2 files changed, 6 insertions(+)
---
diff --git a/src/ui/collection-icon-view.vala b/src/ui/collection-icon-view.vala
index 3fd90bed..0ff2d230 100644
--- a/src/ui/collection-icon-view.vala
+++ b/src/ui/collection-icon-view.vala
@@ -198,6 +198,11 @@ private class Games.CollectionIconView : Gtk.Stack {
                }
        }
 
+       public void reset_scroll_position () {
+               var adjustment = scrolled_window.get_vadjustment ();
+               adjustment.set_value (0);
+       }
+
        private bool apply_cursor_movement () {
                if (flow_box.get_selected_children ().length () == 0) {
                        var first_child = flow_box.get_child_at_index (0);
diff --git a/src/ui/sidebar-view.vala b/src/ui/sidebar-view.vala
index e97afa5b..a7215c47 100644
--- a/src/ui/sidebar-view.vala
+++ b/src/ui/sidebar-view.vala
@@ -41,6 +41,7 @@ private abstract class Games.SidebarView : Gtk.Box {
        private void on_list_box_row_selected (Gtk.ListBoxRow row_item) {
                list_box.select_row (row_item);
                invalidate (row_item);
+               collection_view.reset_scroll_position ();
        }
 
        private void on_model_changed (uint position, uint removed, uint added) {


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