[PATCH 2/2] Don't let user hit Add button if no new layouts are selected
Vratislav Podzimek
vpodzime at redhat.com
Tue Sep 11 13:28:54 UTC 2012
It doesn't make sense and can cause traceback when replacing the last
layout in the list of added layouts.
Resolves: rhbz#854643
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/ui/gui/spokes/keyboard.glade | 1 +
pyanaconda/ui/gui/spokes/keyboard.py | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/pyanaconda/ui/gui/spokes/keyboard.glade b/pyanaconda/ui/gui/spokes/keyboard.glade
index e0c0888..b46c0ab 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.glade
+++ b/pyanaconda/ui/gui/spokes/keyboard.glade
@@ -115,6 +115,7 @@
<child internal-child="selection">
<object class="GtkTreeSelection" id="newLayoutSelection">
<property name="mode">multiple</property>
+ <signal name="changed" handler="on_add_layout_selection_changed" swapped="no"/>
</object>
</child>
<child>
diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index d350967..4fc07cb 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -106,6 +106,16 @@ class AddLayoutDialog(GUIObject):
for layout in self._xkl_wrapper.get_available_layouts():
self._addLayout(self._store, layout)
+ self._confirmAddButton = self.builder.get_object("confirmAddButton")
+
+ self._newLayoutSelection = self.builder.get_object("newLayoutSelection")
+ selected = self._newLayoutSelection.count_selected_rows()
+ if selected:
+ self._confirmAddButton.set_sensitive(True)
+ else:
+ self._confirmAddButton.set_sensitive(False)
+
+
def run(self):
rc = self.window.run()
self.window.destroy()
@@ -124,6 +134,13 @@ class AddLayoutDialog(GUIObject):
itr = store.get_iter(path)
self._chosen_layouts.append(store[itr][0])
+ def on_add_layout_selection_changed(self, selection):
+ selected = selection.count_selected_rows()
+ if not selected:
+ self._confirmAddButton.set_sensitive(False)
+ else:
+ self._confirmAddButton.set_sensitive(True)
+
def on_cancel_clicked(self, *args):
print "CANCELING"
--
1.7.11.4
More information about the anaconda-patches
mailing list