People expect to have layouts specified in the kickstart or as command line option set up when UI initializes. --- anaconda | 40 +++++++++++++++++++++++++++++++++------- pyanaconda/xklavier.py | 25 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/anaconda b/anaconda index 9f7de2e..33782ed 100755 --- a/anaconda +++ b/anaconda @@ -103,13 +103,35 @@ def startAuditDaemon(): os.waitpid(childpid, 0) # function to handle X startup special issues for anaconda -def doStartupX11Actions(): +def doStartupX11Actions(keyboard): + """ + Start window manager and set up keyboard layouts if requested in kickstart + or on command line. + + @param keyboard: ksdata.keyboard object + + """ + 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 keyboard.layouts_list: + from pyanaconda.xklavier import XklWrapper, XklWrapperError + + layouts = 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 +538,7 @@ def setupDisplay(anaconda, opts): signal.pause() os.environ["DISPLAY"] = ":1" - doStartupX11Actions() + doStartupX11Actions(anaconda.ksdata.keyboard) except (OSError, RuntimeError): stdoutLog.warning("X startup failed, falling back to text mode") anaconda.displayMode = 't' @@ -540,7 +562,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.ksdata.keyboard) # with X running we can initialize the UI interface anaconda.initInterface() @@ -752,6 +774,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 +820,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..de6a678 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 layouts defined 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