[PATCH 2/2] Close AddLayout dialog on double-click

Vratislav Podzimek vpodzime at redhat.com
Tue Sep 25 09:54:54 UTC 2012


Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/ui/gui/spokes/keyboard.glade |  2 ++
 pyanaconda/ui/gui/spokes/keyboard.py    | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/ui/gui/spokes/keyboard.glade b/pyanaconda/ui/gui/spokes/keyboard.glade
index b0408e7..1919a14 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.glade
+++ b/pyanaconda/ui/gui/spokes/keyboard.glade
@@ -108,9 +108,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>
+                    <signal name="button-press-event" handler="on_layout_view_button_press" 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 9e25040..dc1271f 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -24,7 +24,8 @@ import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
 N_ = lambda x: x
 
-from gi.repository import GLib, Gkbd, Gtk
+# pylint: disable-msg=E0611
+from gi.repository import GLib, Gkbd, Gtk, Gdk
 
 from pyanaconda.ui.gui import GUIObject
 from pyanaconda.ui.gui.spokes import NormalSpoke
@@ -140,6 +141,16 @@ class AddLayoutDialog(GUIObject):
     def on_entry_icon_clicked(self, *args):
         self._entry.set_text("")
 
+    def on_layout_view_button_press(self, widget, event, *args):
+        # BUG: Gdk.EventType.2BUTTON_PRESS results in syntax error
+        if event.type == getattr(Gdk.EventType, "2BUTTON_PRESS"):
+            # double-click should close the dialog
+            button = self.builder.get_object("confirmAddButton")
+            button.emit("clicked")
+
+        # let the other actions happen as well
+        return False
+
     def _addLayout(self, store, name):
         store.append([name])
 
-- 
1.7.11.4



More information about the anaconda-patches mailing list