[master 4/7] Add keyboard layouts on the row-activated signal.

dashea installerbot-noreply at redhat.com
Tue Jul 7 14:15:56 UTC 2015


From: David Shea <dshea at redhat.com>

Besides removing the need for a pile of Gdk constants and flags to
detect double clicks, row-activated is fired on a wider variety of
events, such as hitting Enter when a row is selected.

Also remove the check for whether the button is sensitive, since the
button will take care of that itself.
---
 pyanaconda/ui/gui/spokes/keyboard.glade |  9 ++++-----
 pyanaconda/ui/gui/spokes/keyboard.py    | 18 +++++++-----------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/keyboard.glade b/pyanaconda/ui/gui/spokes/keyboard.glade
index 4df7951..392afe0 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.glade
+++ b/pyanaconda/ui/gui/spokes/keyboard.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.19.0 -->
 <interface>
   <requires lib="gtk+" version="3.2"/>
   <requires lib="AnacondaWidgets" version="3.0"/>
@@ -53,9 +53,9 @@
                   <object class="GtkLabel" id="pickLayoutLabel">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Which keyboard layouts would you like to use on this system?  You may move any layout to the top of the list to select it as the default.</property>
                     <property name="wrap">True</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="font-desc" value="Cantarell 12"/>
                       <attribute name="weight" value="normal"/>
@@ -480,8 +480,8 @@
               <object class="GtkLabel" id="label3">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes">You may add a keyboard layout by selecting it below:</property>
+                <property name="xalign">0</property>
                 <attributes>
                   <attribute name="font-desc" value="Cantarell 12"/>
                 </attributes>
@@ -503,12 +503,11 @@
                   <object class="GtkTreeView" id="newLayoutView">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="events">GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property>
                     <property name="model">newLayoutStoreSort</property>
                     <property name="headers_visible">False</property>
                     <property name="headers_clickable">False</property>
                     <property name="enable_search">False</property>
-                    <signal name="button-press-event" handler="on_layout_view_button_press" swapped="no"/>
+                    <signal name="row-activated" handler="on_layout_row_activated" swapped="no"/>
                     <child internal-child="selection">
                       <object class="GtkTreeSelection" id="newLayoutSelection">
                         <property name="mode">multiple</property>
diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index 6c024e7..f7f20c8 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -20,7 +20,7 @@
 #                    Vratislav Podzimek <vpodzime at redhat.com>
 #
 
-from gi.repository import Gkbd, Gdk, Gtk
+from gi.repository import Gkbd, Gtk
 
 from pyanaconda.ui.gui import GUIObject
 from pyanaconda.ui.gui.spokes import NormalSpoke
@@ -160,16 +160,12 @@ def on_entry_changed(self, *args):
     def on_entry_icon_clicked(self, *args):
         self._entry.set_text("")
 
-    def on_layout_view_button_press(self, widget, event, *args):
-        if event.type == Gdk.EventType._2BUTTON_PRESS and \
-                self._confirmAddButton.get_sensitive():
-            # double-click should close the dialog if something is selected
-            # (i.e. the Add button is sensitive)
-            # @see on_add_layout_selection_changed
-            self._confirmAddButton.emit("clicked")
-
-        # let the other actions happen as well
-        return False
+    def on_layout_row_activated(self, treeview, path, column, user_data=None):
+        # Activating a row (double-click, Enter, space, shift+space) should
+        # close the dialog if something is selected (i.e. the Add button is
+        # sensitive)
+        # @see on_add_layout_selection_changed
+        self._confirmAddButton.emit("clicked")
 
     def _addLayout(self, name, store):
         store.append([name])


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


More information about the anaconda-patches mailing list