Пример #1
0
    def _addLayout(self, store, name):
        # first try to add the layout
        if keyboard.can_configure_keyboard():
            self._xkl_wrapper.add_layout(name)

        # valid layout, append it to the store
        store.append([name])
Пример #2
0
    def _removeLayout(self, store, itr):
        """
        Remove the layout specified by store iterator from the store and
        X runtime configuration.

        """

        if keyboard.can_configure_keyboard():
            self._xkl_wrapper.remove_layout(store[itr][0])
        store.remove(itr)
Пример #3
0
    def __init__(self, data):
        """Create a new UIObject instance, including loading its uiFile and
           all UI-related objects.

           Instance attributes:

           data     -- An instance of a pykickstart Handler object.  The Hub
                       never directly uses this instance.  Instead, it passes
                       it down into Spokes when they are created and applied.
                       The Hub simply stores this instance so it doesn't need
                       to be passed by the user.
           skipTo   -- If this attribute is set to something other than None,
                       it must be the name of a class (as a string).  Then,
                       the interface will skip to the first instance of that
                       class in the action list instead of going on to
                       whatever the next action is normally.

                       Note that actions may only skip ahead, never backwards.
                       Also, standalone spokes may not skip to an individual
                       spoke off a hub.  They can only skip to the hub
                       itself.
        """
        super().__init__(data)

        if self.__class__ is GUIObject:
            raise TypeError("GUIObject is an abstract class")

        self.skipTo = None
        self.applyOnSkip = False

        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(self.translationDomain)
        self._window = None

        if self.builderObjects:
            self.builder.add_objects_from_file(self._findUIFile(),
                                               self.builderObjects)
        else:
            self.builder.add_from_file(self._findUIFile())

        self.builder.connect_signals(self)

        # Hide keyboard indicator if we can't configure the keyboard
        # It doesn't really give you any benefit of seeing something which could
        # give you wrong values.
        # This has to be applied to every spoke and hub - we have to ignore dialog and other
        # non full screen parts.
        if not can_configure_keyboard() and isinstance(
                self.window, AnacondaWidgets.BaseWindow):
            layout_indicator = self.window.get_layout_indicator_box()
            really_hide(layout_indicator)
            layout_indicator.set_sensitive(False)
Пример #4
0
    def on_up_clicked(self, button):
        if not self._selection.count_selected_rows():
            return

        (store, cur) = self._selection.get_selected()
        prev = store.iter_previous(cur)
        if not prev:
            return

        store.swap(cur, prev)
        if keyboard.can_configure_keyboard():
            self._flush_layouts_to_X()

        if not store.iter_previous(cur):
            #layout is first in the list (set as default), activate it
            self._xkl_wrapper.activate_default_layout()

        self._selection.emit("changed")
Пример #5
0
    def on_down_clicked(self, button):
        if not self._selection.count_selected_rows():
            return

        (store, cur) = self._selection.get_selected()

        #if default layout (first in the list) changes we need to activate it
        activate_default = not store.iter_previous(cur)

        nxt = store.iter_next(cur)
        if not nxt:
            return

        store.swap(cur, nxt)
        if keyboard.can_configure_keyboard():
            self._flush_layouts_to_X()

        if activate_default:
            self._xkl_wrapper.activate_default_layout()

        self._selection.emit("changed")
Пример #6
0
    def test_can_configure_keyboard(self, exec_mock, conf_mock):
        """Check if the keyboard configuration is enabled or disabled."""
        # It's a dir installation.
        conf_mock.system.can_configure_keyboard = False
        conf_mock.system.can_run_on_xwayland = False
        assert keyboard.can_configure_keyboard() is False
        exec_mock.assert_not_called()

        # It's a boot.iso.
        conf_mock.system.can_configure_keyboard = True
        conf_mock.system.can_run_on_xwayland = False
        assert keyboard.can_configure_keyboard() is True
        exec_mock.assert_not_called()

        # It's a Live installation on Wayland.
        conf_mock.system.can_configure_keyboard = True
        conf_mock.system.can_run_on_xwayland = True
        exec_mock.return_value = 0
        assert keyboard.can_configure_keyboard() is False
        exec_mock.assert_called_once_with('xisxwayland', [])
        exec_mock.reset_mock()

        # It's a Live installation and not on Wayland.
        conf_mock.system.can_configure_keyboard = True
        conf_mock.system.can_run_on_xwayland = True
        exec_mock.return_value = 1  # xisxwayland returns 1 if it is not XWayland
        assert keyboard.can_configure_keyboard() is True
        exec_mock.assert_called_once_with('xisxwayland', [])
        exec_mock.reset_mock()

        # It's a Live installation and probably not on Wayland,
        # because the xisxwayland tooling is not present.
        conf_mock.system.can_configure_keyboard = True
        conf_mock.system.can_run_on_xwayland = True
        exec_mock.side_effect = FileNotFoundError()

        with self.assertLogs(level="WARNING") as cm:
            keyboard.can_configure_keyboard()

        msg = "The xisxwayland tool is not available!"
        assert any(map(lambda x: msg in x, cm.output))

        exec_mock.assert_called_once_with('xisxwayland', [])
        exec_mock.reset_mock()
Пример #7
0
    def completed(self):
        if flags.flags.automatedInstall and not self._seen:
            return False

        # Confirmed by a user nothing else is required
        if self._confirmed:
            return True

        # Below are checks if we want users attention when the spoke wasn't confirmed (visited)

        # Not an issue for VNC, since VNC keymaps are weird and more on the client side.
        if flags.flags.usevnc:
            return True

        # Not an issue where system keyboard configuration is not allowed
        # This have to be before the `_xkl_wrapper.get_current_layout()` because on Wayland
        # that call can fail in case when system has multiple layouts set.
        if not keyboard.can_configure_keyboard():
            return True

        # Request user attention if the current activated layout is a different from the
        # selected ones
        return self._xkl_wrapper.get_current_layout(
        ) in self._l12_module.XLayouts
Пример #8
0
    def initialize(self):
        super().initialize()
        self.initialize_start()

        # set X keyboard defaults
        # - this needs to be done early in spoke initialization so that
        #   the spoke status does not show outdated keyboard selection
        keyboard.set_x_keyboard_defaults(self._l12_module, self._xkl_wrapper)

        # make sure the x_layouts list has at least one keyboard layout
        if not self._l12_module.XLayouts:
            self._l12_module.XLayouts = [DEFAULT_KEYBOARD]

        self._add_dialog = AddLayoutDialog(self.data)
        self._add_dialog.initialize()

        if keyboard.can_configure_keyboard():
            self.builder.get_object("warningBox").hide()

        # We want to store layouts' names but show layouts as
        # 'language (description)'.
        layoutColumn = self.builder.get_object("layoutColumn")
        layoutRenderer = self.builder.get_object("layoutRenderer")
        override_cell_property(layoutColumn, layoutRenderer, "text",
                               _show_layout, self._xkl_wrapper)

        self._store = self.builder.get_object("addedLayoutStore")
        self._add_data_layouts()

        self._selection = self.builder.get_object("layoutSelection")

        self._switching_dialog = ConfigureSwitchingDialog(
            self.data, self._l12_module)
        self._switching_dialog.initialize()

        self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel")

        if not keyboard.can_configure_keyboard():
            # Disable area for testing layouts as we cannot make
            # it work without modifying runtime system

            widgets = [
                self.builder.get_object("testingLabel"),
                self.builder.get_object("testingWindow"),
                self.builder.get_object("layoutSwitchLabel")
            ]

            # Use testingLabel's text to explain why this part is not
            # sensitive.
            widgets[0].set_text(
                _("Testing layouts configuration not "
                  "available."))

            for widget in widgets:
                widget.set_sensitive(False)

        hubQ.send_not_ready(self.__class__.__name__)
        hubQ.send_message(self.__class__.__name__,
                          _("Getting list of layouts..."))
        threadMgr.add(
            AnacondaThread(name=THREAD_KEYBOARD_INIT, target=self._wait_ready))