[PATCH] Allow clicking on environment and addon text to toggle them (#928010).

Chris Lumens clumens at redhat.com
Wed Apr 17 15:15:57 UTC 2013


---
 pyanaconda/ui/gui/spokes/software.glade |  9 ++++++---
 pyanaconda/ui/gui/spokes/software.py    | 34 +++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/software.glade b/pyanaconda/ui/gui/spokes/software.glade
index 0dbee9d..0b4ca77 100644
--- a/pyanaconda/ui/gui/spokes/software.glade
+++ b/pyanaconda/ui/gui/spokes/software.glade
@@ -136,12 +136,13 @@
                             <property name="headers_visible">False</property>
                             <property name="headers_clickable">False</property>
                             <property name="search_column">0</property>
+                            <signal name="button-release-event" handler="on_addon_view_clicked" swapped="no"/>
                             <child internal-child="selection">
-                              <object class="GtkTreeSelection" id="treeview-selection2"/>
+                              <object class="GtkTreeSelection" id="addonSelector"/>
                             </child>
                             <child>
                               <object class="GtkTreeViewColumn" id="addonSelectedCol">
-                                <property name="title" translatable="yes">column</property>
+                                <property name="title" translatable="no">Selected</property>
                                 <signal name="clicked" handler="on_addon_toggled" swapped="no"/>
                                 <child>
                                   <object class="GtkCellRendererToggle" id="addonSelectedRenderer">
@@ -201,7 +202,9 @@
                             <property name="headers_clickable">False</property>
                             <property name="search_column">0</property>
                             <child internal-child="selection">
-                              <object class="GtkTreeSelection" id="environmentSelector"/>
+                              <object class="GtkTreeSelection" id="environmentSelector">
+                                <signal name="changed" handler="on_environment_selection_changed" swapped="no"/>
+                              </object>
                             </child>
                             <child>
                               <object class="GtkTreeViewColumn" id="environmentSelectedCol">
diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py
index 55af428..0f81fe8 100644
--- a/pyanaconda/ui/gui/spokes/software.py
+++ b/pyanaconda/ui/gui/spokes/software.py
@@ -316,6 +316,15 @@ class SoftwareSelectionSpoke(NormalSpoke):
         self.environment = self._environmentStore[path][2]
         self.refreshAddons()
 
+    def on_environment_selection_changed(self, selection):
+        (model, itr) = selection.get_selected()
+        if not itr:
+            return
+
+        # Only do something if the row's not previously been selected.
+        if not model[itr][0]:
+            self.on_environment_toggled(None, model.get_path(itr))
+
     def on_addon_toggled(self, renderer, path):
         selected = not self._addonStore[path][0]
         group = self._addonStore[path][2]
@@ -330,6 +339,31 @@ class SoftwareSelectionSpoke(NormalSpoke):
         elif not selected and group in self.selectedGroups:
             self.selectedGroups.remove(group)
 
+    def on_addon_view_clicked(self, view, event, *args):
+        from gi.repository import Gdk
+
+        if event and not event.type in [Gdk.EventType.BUTTON_RELEASE, Gdk.EventType.KEY_RELEASE]:
+            return
+
+        if event and event.type == Gdk.EventType.KEY_RELEASE and \
+           event.keyval not in [Gdk.KEY_Return, Gdk.KEY_ISO_Enter, Gdk.KEY_KP_Enter]:
+              return
+
+        selection = view.get_selection()
+        (model, itr) = selection.get_selected()
+        if not itr:
+            return
+
+        # If the user clicked on the first column, they've clicked on the checkbox which was
+        # handled separately from this signal handler.  Handling it again here will result in
+        # the checkbox being toggled yet again.  So, we need to return in that case.
+        (path, col) = view.get_cursor()
+        if not col or col.get_title() == "Selected":
+            return
+
+        # Always do something here, since addons can be toggled.
+        self.on_addon_toggled(None, model.get_path(itr))
+
     def on_custom_clicked(self, button):
         with enlightbox(self.window, self._addRepoDialog.window):
             response =  self._addRepoDialog.run()
-- 
1.8.1.2



More information about the anaconda-patches mailing list