[PATCH 3/3] Add layout preview functionality to the KeyboardSpoke

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 pyanaconda/ui/gui/spokes/keyboard.py |   23 +++++++++++++++++------
 pyanaconda/ui/gui/spokes/keyboard.ui |    8 ++++----
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index 100aedb..c0a3e51 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -24,7 +24,7 @@ import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
 N_ = lambda x: x
 
-from gi.repository import GLib, AnacondaWidgets
+from gi.repository import GLib, AnacondaWidgets, Gkbd
 
 from pyanaconda.ui.gui import UIObject
 from pyanaconda.ui.gui.spokes import NormalSpoke
@@ -39,9 +39,9 @@ class AddLayoutDialog(UIObject):
     mainWidgetName = "addLayoutDialog"
     uiFile = "spokes/keyboard.ui"
 
-    def __init__(self, *args):
+    def __init__(self, xkl_wrapper, *args):
+        self._xkl_wrapper = xkl_wrapper
         UIObject.__init__(self, *args)
-        self._xkl_wrapper = xklavier.XklWrapper()
 
     def matches_entry(self, model, itr, user_data=None):
         value = model.get_value(itr, 0)
@@ -116,6 +116,7 @@ class KeyboardSpoke(NormalSpoke):
     def __init__(self, *args):
         NormalSpoke.__init__(self, *args)
         self._remove_last_attempt = False
+        self._xkl_wrapper = xklavier.XklWrapper()
 
     def apply(self):
         pass
@@ -157,7 +158,7 @@ class KeyboardSpoke(NormalSpoke):
 
     # Signal handlers.
     def on_add_clicked(self, button):
-        dialog = AddLayoutDialog(self.data)
+        dialog = AddLayoutDialog(self._xkl_wrapper, self.data)
         dialog.refresh()
         dialog.initialize()
 
@@ -239,8 +240,18 @@ class KeyboardSpoke(NormalSpoke):
         store.swap(cur, nxt)
         selection.emit("changed")
 
-    def on_settings_clicked(self, button):
-        pass
+    def on_preview_clicked(self, button):
+        selection = self.builder.get_object("layoutSelection")
+        (store, cur) = selection.get_selected()
+        layout_description = store[cur]
+        layout_name = self._xkl_wrapper.description_to_name.get(layout_description, None)
+        if not layout_name:
+            return
+
+        dialog = Gkbd.KeyboardDrawing.dialog_new()
+        Gkbd.KeyboardDrawing.dialog_set_layout(dialog, self._xkl_wrapper.configreg,
+                                               layout_name)
+        dialog.show_all()
 
     def on_selection_changed(self, *args):
         self.layout_selection_changed(self.builder.get_object("layoutSelection"))
diff --git a/pyanaconda/ui/gui/spokes/keyboard.ui b/pyanaconda/ui/gui/spokes/keyboard.ui
index 4375cfc..7b8382b 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.ui
+++ b/pyanaconda/ui/gui/spokes/keyboard.ui
@@ -351,8 +351,8 @@ any layout to the top of the list to select it as the default.</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
                                 <property name="use_action_appearance">False</property>
-                                <property name="image">settingsImage</property>
-                                <signal name="clicked" handler="on_settings_clicked" swapped="no"/>
+                                <property name="image">previewImage</property>
+                                <signal name="clicked" handler="on_preview_clicked" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -479,10 +479,10 @@ any layout to the top of the list to select it as the default.</property>
     <property name="can_focus">False</property>
     <property name="icon_name">list-remove-symbolic</property>
   </object>
-  <object class="GtkImage" id="settingsImage">
+  <object class="GtkImage" id="previewImage">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="icon_name">system-run-symbolic</property>
+    <property name="icon_name">input-keyboard-symbolic</property>
   </object>
   <object class="GtkImage" id="upImage">
     <property name="visible">True</property>
-- 
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux