From a93fa34513d649e2eb2fe8b29aaef14645157c7f Mon Sep 17 00:00:00 2001 From: David Shea Date: Thu, 5 Mar 2015 15:33:18 -0500 Subject: [PATCH] Connect viewport adjustments to child focus adjustments (#1192155) When we use GtkScrolledWindow with non-natively scrollable widgets, the scroll adjustments on the intermediate viewport need to be connected to the focus adjustments on non-scrollable container in order for the viewport to automatically scroll on keyboard navigation events. Normally this is done automatically by gtk, but adding silent surprises in the middle of the widget hierarchy breaks glade so glade requires the viewport be explicit, and glade does not allow one to change any of the adjustment settings we need to get to. See https://bugzilla.gnome.org/show_bug.cgi?id=744721 I am not optimistic about glade changing things quickly or ever so let's just work around it and have things work a little nicer. --- pyanaconda/ui/gui/spokes/custom.py | 8 ++++++++ pyanaconda/ui/gui/spokes/filter.glade | 16 ++++++++-------- pyanaconda/ui/gui/spokes/filter.py | 21 +++++++++++++++++++++ pyanaconda/ui/gui/spokes/software.py | 6 ++++++ pyanaconda/ui/gui/spokes/source.glade | 6 +++--- pyanaconda/ui/gui/spokes/source.py | 5 +++++ pyanaconda/ui/gui/spokes/storage.glade | 6 +++--- pyanaconda/ui/gui/spokes/storage.py | 11 +++++++++++ 8 files changed, 65 insertions(+), 14 deletions(-) diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py index a36312da7f8..a278842482b 100644 --- a/pyanaconda/ui/gui/spokes/custom.py +++ b/pyanaconda/ui/gui/spokes/custom.py @@ -213,6 +213,10 @@ def _grabObjects(self): self._partitionsViewport = self.builder.get_object("partitionsViewport") self._partitionsNotebook = self.builder.get_object("partitionsNotebook") + # Connect partitionsNotebook focus events to scrolling in the parent viewport + partitionsNotebookViewport = self.builder.get_object("partitionsNotebookViewport") + self._partitionsNotebook.set_focus_vadjustment(partitionsNotebookViewport.get_vadjustment()) + self._whenCreateLabel = self.builder.get_object("whenCreateLabel") self._availableSpaceLabel = self.builder.get_object("availableSpaceLabel") @@ -281,6 +285,10 @@ def initialize(self): self._accordion = Accordion() self._partitionsViewport.add(self._accordion) + # Connect viewport scrolling with accordion focus events + self._accordion.set_focus_hadjustment(self._partitionsViewport.get_hadjustment()) + self._accordion.set_focus_vadjustment(self._partitionsViewport.get_vadjustment()) + threadMgr.add(AnacondaThread(name=THREAD_CUSTOM_STORAGE_INIT, target=self._initialize)) def _initialize(self): diff --git a/pyanaconda/ui/gui/spokes/filter.glade b/pyanaconda/ui/gui/spokes/filter.glade index bad9beb8049..c25aeefe693 100644 --- a/pyanaconda/ui/gui/spokes/filter.glade +++ b/pyanaconda/ui/gui/spokes/filter.glade @@ -1,5 +1,5 @@ - + @@ -112,7 +112,7 @@ True in - + True False none @@ -534,7 +534,7 @@ True in - + True False none @@ -866,7 +866,7 @@ True in - + True False none @@ -1189,7 +1189,7 @@ True in - + True False none @@ -1533,9 +1533,9 @@ 1 0 1 - 1 - - + 1 + + diff --git a/pyanaconda/ui/gui/spokes/filter.py b/pyanaconda/ui/gui/spokes/filter.py index 807130ca639..da1c9719b53 100644 --- a/pyanaconda/ui/gui/spokes/filter.py +++ b/pyanaconda/ui/gui/spokes/filter.py @@ -497,6 +497,27 @@ def initialize(self): self._store = self.builder.get_object("diskStore") self._addDisksButton = self.builder.get_object("addDisksButton") + # Connect focus events in scrolled viewport children to scrolling on the viewport + searchScrolledViewport = self.builder.get_object("searchScrolledViewport") + searchGrid = self.builder.get_object("searchGrid") + searchGrid.set_focus_hadjustment(searchScrolledViewport.get_hadjustment()) + searchGrid.set_focus_vadjustment(searchScrolledViewport.get_vadjustment()) + + multipathViewport = self.builder.get_object("multipathViewport") + multipathGrid = self.builder.get_object("multipathGrid") + multipathGrid.set_focus_hadjustment(multipathViewport.get_hadjustment()) + multipathGrid.set_focus_vadjustment(multipathViewport.get_vadjustment()) + + otherViewport = self.builder.get_object("otherViewport") + otherGrid = self.builder.get_object("otherGrid") + otherGrid.set_focus_hadjustment(otherViewport.get_hadjustment()) + otherGrid.set_focus_vadjustment(otherViewport.get_vadjustment()) + + zViewport = self.builder.get_object("zViewport") + zGrid = self.builder.get_object("zGrid") + zGrid.set_focus_hadjustment(zViewport.get_hadjustment()) + zGrid.set_focus_vadjustment(zViewport.get_vadjustment()) + def _real_ancestors(self, disk): # Return a list of all the ancestors of a disk, but remove the disk # itself from this list. diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py index 5006e4c6244..12e060860eb 100644 --- a/pyanaconda/ui/gui/spokes/software.py +++ b/pyanaconda/ui/gui/spokes/software.py @@ -72,6 +72,12 @@ def __init__(self, *args, **kwargs): self._environmentListBox = self.builder.get_object("environmentListBox") self._addonListBox = self.builder.get_object("addonListBox") + # Connect viewport scrolling with listbox focus events + environmentViewport = self.builder.get_object("environmentViewport") + addonViewport = self.builder.get_object("addonViewport") + self._environmentListBox.set_focus_vadjustment(environmentViewport.get_vadjustment()) + self._addonListBox.set_focus_vadjustment(addonViewport.get_vadjustment()) + # Used to store how the user has interacted with add-ons for the default add-on # selection logic. The dictionary keys are group IDs, and the values are selection # state constants. See refreshAddons for how the values are used. diff --git a/pyanaconda/ui/gui/spokes/source.glade b/pyanaconda/ui/gui/spokes/source.glade index 3703f40bb7b..abb2841a0e4 100644 --- a/pyanaconda/ui/gui/spokes/source.glade +++ b/pyanaconda/ui/gui/spokes/source.glade @@ -508,18 +508,18 @@ True vertical - + True True never - + True False 24 none - + True False vertical diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py index 1b35ca9ec30..7b690850600 100644 --- a/pyanaconda/ui/gui/spokes/source.py +++ b/pyanaconda/ui/gui/spokes/source.py @@ -122,6 +122,11 @@ def __init__(self, data, proxy_url): self._proxyValidate = self.add_check(self._proxyURLEntry, self._checkProxyURL) self._proxyValidate.update_check_status() + # Connect scroll events on the viewport with focus events on the box + mainViewport = self.builder.get_object("mainViewport") + mainBox = self.builder.get_object("mainBox") + mainBox.set_focus_vadjustment(mainViewport.get_vadjustment()) + def _checkProxyURL(self, inputcheck): proxy_string = self.get_input(inputcheck.input_obj) diff --git a/pyanaconda/ui/gui/spokes/storage.glade b/pyanaconda/ui/gui/spokes/storage.glade index b1fa02cd3aa..0acdd3a1bf1 100644 --- a/pyanaconda/ui/gui/spokes/storage.glade +++ b/pyanaconda/ui/gui/spokes/storage.glade @@ -482,18 +482,18 @@ vertical 6 - + True True True never - + True False none - + True False vertical diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py index 8273dcbae76..f4378cb09b1 100644 --- a/pyanaconda/ui/gui/spokes/storage.py +++ b/pyanaconda/ui/gui/spokes/storage.py @@ -525,6 +525,17 @@ def initialize(self): self.local_disks_box = self.builder.get_object("local_disks_box") self.specialized_disks_box = self.builder.get_object("specialized_disks_box") + # Connect the viewport adjustments to the child widgets + # See also https://bugzilla.gnome.org/show_bug.cgi?id=744721 + localViewport = self.builder.get_object("localViewport") + specializedViewport = self.builder.get_object("specializedViewport") + self.local_disks_box.set_focus_hadjustment(localViewport.get_hadjustment()) + self.specialized_disks_box.set_focus_hadjustment(specializedViewport.get_hadjustment()) + + mainViewport = self.builder.get_object("storageViewport") + mainBox = self.builder.get_object("storageMainBox") + mainBox.set_focus_vadjustment(mainViewport.get_vadjustment()) + threadMgr.add(AnacondaThread(name=constants.THREAD_STORAGE_WATCHER, target=self._initialize))