예제 #1
0
    def _load_layout(self, layout_filename, color_scheme_filename):
        self.layout_dir = os.path.dirname(layout_filename)
        self.svg_cache = {}
        layout = None

        if color_scheme_filename:
            self.color_scheme = ColorScheme.load(color_scheme_filename)

        f = open(layout_filename)
        try:
            dom = minidom.parse(f).documentElement

            # check layout format
            format = self.LAYOUT_FORMAT_LEGACY
            if dom.hasAttribute("format"):
               format = Version.from_string(dom.attributes["format"].value)

            if format >= self.LAYOUT_FORMAT_LAYOUT_TREE:
                items = self._parse_dom_node(dom)
            else:
                _logger.warning(_("Loading legacy layout format '{}'. "
                            "Please consider upgrading to current format '{}'"
                            ).format(format, self.LAYOUT_FORMAT))
                items = self._parse_legacy_layout(dom)

            if items:
                layout = items[0]
        finally:
            f.close()

        self.svg_cache = {} # Free the memory
        return layout
예제 #2
0
    def load_layout(self, layout_filename, color_scheme_filename):
        _logger.info("Loading keyboard layout " + layout_filename)
        if (color_scheme_filename):
            _logger.info("Loading color scheme " + color_scheme_filename)

        vk = self.get_vk()

        color_scheme = ColorScheme.load(color_scheme_filename) \
                       if color_scheme_filename else None
        layout = LayoutLoaderSVG().load(vk, layout_filename, color_scheme)

        self.keyboard.set_layout(layout, color_scheme, vk)

        if self._window and self._window.icp:
            self._window.icp.queue_draw()
예제 #3
0
    def load_layout(self, layout_filename, color_scheme_filename):
        _logger.info("Loading keyboard layout " + layout_filename)
        if (color_scheme_filename):
            _logger.info("Loading color scheme " + color_scheme_filename)

        vk = self.get_vk()

        color_scheme = ColorScheme.load(color_scheme_filename) \
                       if color_scheme_filename else None
        layout = LayoutLoaderSVG().load(vk, layout_filename, color_scheme)

        self.keyboard.set_layout(layout, color_scheme, vk)

        if self._window and self._window.icp:
            self._window.icp.queue_draw()
예제 #4
0
    def update_color_schemeList(self):
        self.color_schemeList = gtk.ListStore(str,str)
        self.color_scheme_combobox.set_model(self.color_schemeList)
        cell = gtk.CellRendererText()
        self.color_scheme_combobox.clear()
        self.color_scheme_combobox.pack_start(cell, True)
        self.color_scheme_combobox.add_attribute(cell, 'markup', 0)

        self.color_schemes = ColorScheme.get_merged_color_schemes()
        color_scheme_filename = self.theme.get_color_scheme_filename()
        for color_scheme in sorted(self.color_schemes.values(),
                                   key=lambda x: x.name):
            it = self.color_schemeList.append((
                      format_list_item(color_scheme.name, color_scheme.system),
                      color_scheme.filename))
            if color_scheme.filename == color_scheme_filename:
                self.color_scheme_combobox.set_active_iter(it)
예제 #5
0
    def load_layout(self, layout_filename, color_scheme_filename):
        _logger.info("Loading keyboard layout from " + layout_filename)
        if (color_scheme_filename):
            _logger.info("Loading color scheme from " + color_scheme_filename)

        vk = self.get_vk()

        color_scheme = ColorScheme.load(color_scheme_filename) \
                       if color_scheme_filename else None
        layout = LayoutLoaderSVG().load(vk, layout_filename, color_scheme)

        self.keyboard.cleanup()
        self.keyboard.set_virtkey(vk)
        self.keyboard.layout = layout
        self.keyboard.color_scheme = color_scheme
        self.keyboard.on_layout_loaded()
        self.keyboard_widget.on_layout_loaded()

        if self._window and self._window.icp:
            self._window.icp.queue_draw()
예제 #6
0
    def load_layout(self, layout_filename, color_scheme_filename):
        _logger.info("Loading keyboard layout from " + layout_filename)
        if (color_scheme_filename):
            _logger.info("Loading color scheme from " + color_scheme_filename)

        vk = self.get_vk()

        color_scheme = ColorScheme.load(color_scheme_filename) \
                       if color_scheme_filename else None
        layout = LayoutLoaderSVG().load(vk, layout_filename, color_scheme)

        self.keyboard.cleanup()
        self.keyboard.init_key_synth(vk)
        self.keyboard.layout = layout
        self.keyboard.color_scheme = color_scheme
        self.keyboard.on_layout_loaded()
        self.keyboard_widget.on_layout_loaded()

        if self._window and self._window.icp:
            self._window.icp.queue_draw()
예제 #7
0
    def load_layout(self, layout_filename, color_scheme_filename):
        kbfolder = os.path.dirname(layout_filename)
        panes = []

        color_scheme = None
        if color_scheme_filename:
            color_scheme = ColorScheme.load(color_scheme_filename)

        f = open(layout_filename)
        try:
            langdoc = minidom.parse(f).documentElement
            try:
                for i, pane_config in enumerate(langdoc.getElementsByTagName("pane")):
                    pane_svg_filename = os.path.join(kbfolder, pane_config.attributes["filename"].value)
                    try:
                        with open(pane_svg_filename) as svg_file:
                            pane_svg = minidom.parse(svg_file).documentElement
                        try:
                            panes.append(self.load_pane_svg(i, pane_config, pane_svg, color_scheme))
                        finally:
                            pane_svg.unlink()

                    except Exception, (exception):
                        raise Exceptions.LayoutFileError(
                            _("Error loading ") + pane_svg_filename, chained_exception=exception
                        )
            finally:
                langdoc.unlink()
        finally:
            f.close()

        basePane = panes[0]
        otherPanes = panes[1:]

        self.set_basePane(basePane)

        for pane in otherPanes:
            self.add_pane(pane)