[PATCH 1/2] Initialize X layouts ASAP if given in kickstart or on command line

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

 



People expect to have layouts specified in the kickstart or as
command line option set up when UI initializes.
---
 anaconda               |   32 +++++++++++++++++++++++++-------
 pyanaconda/xklavier.py |   25 +++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/anaconda b/anaconda
index 9f7de2e..4d3b9f1 100755
--- a/anaconda
+++ b/anaconda
@@ -103,13 +103,27 @@ def startAuditDaemon():
     os.waitpid(childpid, 0)
 
 # function to handle X startup special issues for anaconda
-def doStartupX11Actions():
+def doStartupX11Actions(anaconda):
     global wm_pid # pid of the anaconda fork where the window manager is running
 
     # now start up the window manager
     wm_pid = startMetacityWM()
     log.info("Starting window manager, pid %s." % (wm_pid,))
 
+    # setup layouts
+    if anaconda.ksdata.keyboard.layouts_list:
+        from pyanaconda.xklavier import XklWrapper, XklWrapperError
+
+        layouts = anaconda.ksdata.keyboard.layouts_list
+        xklwrapper = XklWrapper.get_instance()
+
+        try:
+            xklwrapper.replace_layouts(layouts)
+
+        except XklWrapperError as xklerr:
+            msg = "Failed to activate layouts %s" % ",".join(layouts)
+            log.error(msg)
+
 def set_x_resolution(runres):
     # cant do this if no window manager is running because otherwise when we
     # open and close an X connection in the xutils calls the X server will exit
@@ -516,7 +530,7 @@ def setupDisplay(anaconda, opts):
 
                 signal.pause()
                 os.environ["DISPLAY"] = ":1"
-                doStartupX11Actions()
+                doStartupX11Actions(anaconda)
             except (OSError, RuntimeError):
                 stdoutLog.warning("X startup failed, falling back to text mode")
                 anaconda.displayMode = 't'
@@ -540,7 +554,7 @@ def setupDisplay(anaconda, opts):
         # if they want us to use VNC do that now
         if anaconda.displayMode == 'g' and flags.usevnc:
             runVNC(vncS)
-            doStartupX11Actions()
+            doStartupX11Actions(anaconda)
 
     # with X running we can initialize the UI interface
     anaconda.initInterface()
@@ -752,6 +766,14 @@ if __name__ == "__main__":
             ksdata.method.proxy = anaconda.proxy    # FIXME: username/password
             ksdata.method.url = anaconda.methodstr
 
+    # setup keyboard layout from the command line option and let
+    # it override from kickstart if/when X is initialized
+    if opts.keymap:
+        if not ksdata.keyboard.keyboard:
+            ksdata.keyboard.keyboard = opts.keymap
+        anaconda.keyboard.set(opts.keymap)
+        anaconda.keyboard.activate()
+
     # now start the interface
     setupDisplay(anaconda, opts)
 
@@ -790,10 +812,6 @@ if __name__ == "__main__":
         anaconda.instLanguage.systemLang = opts.lang
         anaconda.timezone.setTimezoneInfo(anaconda.instLanguage.getDefaultTimeZone())
 
-    if opts.keymap:
-        anaconda.keyboard.set(opts.keymap)
-        anaconda.keyboard.activate()
-
     from pyanaconda.storage import storageInitialize
     from pyanaconda.packaging import payloadInitialize
     from pyanaconda.threads import initThreading, threadMgr, AnacondaThread
diff --git a/pyanaconda/xklavier.py b/pyanaconda/xklavier.py
index 3dad44f..3843e6a 100755
--- a/pyanaconda/xklavier.py
+++ b/pyanaconda/xklavier.py
@@ -236,3 +236,28 @@ class XklWrapper(object):
         if not self._rec.activate(self._engine):
             raise XklWrapperError("Failed to remove layout '%s (%s)'" % (layout,
                                                                        variant))
+    def replace_layouts(self, layouts_list):
+        """
+        Method that replaces the defined layouts in the current X configuration
+        with the new ones given.
+
+        @param layouts_list: list of layouts defined as either 'layout' or
+                             'layout (variant)'
+        @raise XklWrapperError: if layouts cannot be replaced with the new ones
+
+        """
+
+        new_layouts = list()
+        new_variants = list()
+
+        for layout_variant in layouts_list:
+            (layout, variant) = self._parse_layout_variant(layout_variant)
+            new_layouts.append(layout)
+            new_layouts.append(variant)
+
+        self._rec.set_layouts(new_layouts)
+        self._rec.set_variants(new_variants)
+
+        if not self._rec.activate(self._engine):
+            msg = "Failed to replace layouts with: %s" % ",".join(layouts_list)
+            raise XklWrapperError(msg)
-- 
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