[master 1/1] Connect viewport adjustments to child focus adjustments (#1192155)

dashea installerbot-noreply at redhat.com
Thu Mar 5 20:55:05 UTC 2015


From: David Shea <dshea at redhat.com>

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 a36312d..a278842 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 bad9beb..c25aeef 100644
--- a/pyanaconda/ui/gui/spokes/filter.glade
+++ b/pyanaconda/ui/gui/spokes/filter.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.1 -->
+<!-- Generated with glade 3.18.3 -->
 <interface>
   <requires lib="gtk+" version="3.0"/>
   <requires lib="AnacondaWidgets" version="1.0"/>
@@ -112,7 +112,7 @@
                         <property name="can_focus">True</property>
                         <property name="shadow_type">in</property>
                         <child>
-                          <object class="GtkViewport" id="viewport1">
+                          <object class="GtkViewport" id="searchScrolledViewport">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="shadow_type">none</property>
@@ -534,7 +534,7 @@
                         <property name="can_focus">True</property>
                         <property name="shadow_type">in</property>
                         <child>
-                          <object class="GtkViewport" id="viewport2">
+                          <object class="GtkViewport" id="multipathViewport">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="shadow_type">none</property>
@@ -866,7 +866,7 @@
                         <property name="can_focus">True</property>
                         <property name="shadow_type">in</property>
                         <child>
-                          <object class="GtkViewport" id="viewport4">
+                          <object class="GtkViewport" id="otherViewport">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="shadow_type">none</property>
@@ -1189,7 +1189,7 @@
                         <property name="can_focus">True</property>
                         <property name="shadow_type">in</property>
                         <child>
-                          <object class="GtkViewport" id="viewport3">
+                          <object class="GtkViewport" id="zViewport">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="shadow_type">none</property>
@@ -1533,9 +1533,9 @@
                                     <property name="left_attach">1</property>
                                     <property name="top_attach">0</property>
                                     <property name="width">1</property>
-                                     <property name="height">1</property>
-                                   </packing>
-                                 </child>
+                                    <property name="height">1</property>
+                                  </packing>
+                                </child>
                               </object>
                             </child>
                           </object>
diff --git a/pyanaconda/ui/gui/spokes/filter.py b/pyanaconda/ui/gui/spokes/filter.py
index 807130c..da1c971 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 5006e4c..12e0608 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 3703f40..abb2841 100644
--- a/pyanaconda/ui/gui/spokes/source.glade
+++ b/pyanaconda/ui/gui/spokes/source.glade
@@ -508,18 +508,18 @@
                 <property name="vexpand">True</property>
                 <property name="orientation">vertical</property>
                 <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow1">
+                  <object class="GtkScrolledWindow" id="mainScrolledWindow">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="hscrollbar_policy">never</property>
                     <child>
-                      <object class="GtkViewport" id="viewport1">
+                      <object class="GtkViewport" id="mainViewport">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="margin_right">24</property>
                         <property name="shadow_type">none</property>
                         <child>
-                          <object class="GtkBox" id="box4">
+                          <object class="GtkBox" id="mainBox">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="orientation">vertical</property>
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index 1b35ca9..7b69085 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 b1fa02c..0acdd3a 100644
--- a/pyanaconda/ui/gui/spokes/storage.glade
+++ b/pyanaconda/ui/gui/spokes/storage.glade
@@ -482,18 +482,18 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow1">
+                  <object class="GtkScrolledWindow" id="storageScrolledWindow">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="vexpand">True</property>
                     <property name="hscrollbar_policy">never</property>
                     <child>
-                      <object class="GtkViewport" id="viewport1">
+                      <object class="GtkViewport" id="storageViewport">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="shadow_type">none</property>
                         <child>
-                          <object class="GtkBox" id="box3">
+                          <object class="GtkBox" id="storageMainBox">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="orientation">vertical</property>
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 8273dcb..f4378cb 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))
 


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/a93fa34513d649e2eb2fe8b29aaef14645157c7f


More information about the anaconda-patches mailing list