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

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

 



---
 anaconda.spec.in                     |    2 ++
 pyanaconda/ui/gui/spokes/keyboard.py |   25 +++++++++++++++++++------
 pyanaconda/ui/gui/spokes/keyboard.ui |    8 ++++----
 3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/anaconda.spec.in b/anaconda.spec.in
index 1c2e1d5..e889ccd 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -63,6 +63,7 @@ BuildRequires: libXt-devel
 BuildRequires: libXxf86misc-devel
 BuildRequires: libblkid-devel >= %{libblkidver}
 BuildRequires: libcurl-devel
+BuildRequires: libgnomekbd-devel
 BuildRequires: libnl-devel >= %{libnlver}
 BuildRequires: libselinux-devel >= %{libselinuxver}
 BuildRequires: libsepol-devel
@@ -137,6 +138,7 @@ Requires: pytz
 Requires: libxklavier
 #libxklavier requires iso-codes, but does not have it as Requires: (see #813833)
 Requires: iso-codes
+Requires: libgnomekbd
 %ifarch %livearches
 Requires: usermode
 Requires: zenity
diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index 7269dda..c6a8361 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):
         self.data.keyboard.keyboard = None
@@ -159,7 +160,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()
 
@@ -241,8 +242,20 @@ 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)
+        with enlightbox(self.window, dialog):
+            dialog.show_all()
+            dialog.run()
 
     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