Exemplo n.º 1
0
    def compile_css(self) -> None:
        # workaround for issue with a caret-color
        # GTK+ < 3.20 doesn't support that prop
        css_file_name = self.get_css_file_gtk_3_20() if gtk_version_is_gte(
            3, 20, 0) else self.get_css_file()
        css_file = os.path.join(self.path, css_file_name)

        if not self.get_extend_theme():
            return css_file

        # if theme extends another one, we must import it in css
        # therefore a new css file (generated.css) is created here
        extend_theme_name = self.get_extend_theme()
        try:
            extend_theme = themes[extend_theme_name]
        except KeyError:
            logger.error('Cannot extend theme "%s". It does not exist',
                         extend_theme_name)
            return css_file

        generated_css = self._get_path_for_generated_css()
        with open(generated_css, 'w') as new_css_file:
            new_css_file.write('@import url("%s");\n\n' %
                               extend_theme.compile_css())
            with open(css_file, 'r') as theme_css_file:
                new_css_file.write(theme_css_file.read())

        return generated_css
Exemplo n.º 2
0
 def fix_window_width(self):
     """
     Add 2px to the window width if GTK+ >= 3.20
     Because of the bug in <3.20 that doesn't add css borders to the width
     """
     if gtk_version_is_gte(3, 20, 0):
         width, height = self.get_size_request()
         self.set_size_request(width + 2, height)
Exemplo n.º 3
0
def test_gtk_version_is_gte():
    # test sould pass with GTK 3.22.30
    assert gtk_version_is_gte(1, 99, 100)
    assert not gtk_version_is_gte(100, 1, 1)
    assert gtk_version_is_gte(3, 0, 0)
    assert gtk_version_is_gte(3, 22, 0)