diff --git a/gajim/gajim.py b/gajim/gajim.py index c60c589bb0c8d262742c298bd0dfea332653a586..e2b2915a2b7e2e4cfc8d21cfead4e962cb9092d3 100644 --- a/gajim/gajim.py +++ b/gajim/gajim.py @@ -28,7 +28,7 @@ _MIN_NBXMPP_VER = '0.9.94' _MIN_GTK_VER = '3.22.27' -_MIN_CAIRO_VER = '1.14.0' +_MIN_CAIRO_VER = '1.16.0' _MIN_PYGOBJECT_VER = '3.32.0' diff --git a/gajim/gtk/avatar.py b/gajim/gtk/avatar.py index 4d6a2befc3b6680a4418e4753d42b1607c079c81..8c4faec9f15b5d6b17822b3e69d086c72f192599 100644 --- a/gajim/gtk/avatar.py +++ b/gajim/gtk/avatar.py @@ -52,7 +52,7 @@ def generate_avatar(letters, color, size, scale): font_size = size * 0.5 # Set up surface - surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) + surface = cairo.ImageSurface(cairo.Format.ARGB32, width, height) context = cairo.Context(surface) context.set_source_rgb(color_r, color_g, color_b) @@ -61,26 +61,20 @@ def generate_avatar(letters, color, size, scale): # Draw letters context.select_font_face('sans-serif', - cairo.FONT_SLANT_NORMAL, - cairo.FONT_WEIGHT_NORMAL) + cairo.FontSlant.NORMAL, + cairo.FontWeight.NORMAL) context.set_font_size(font_size) extends = context.text_extents(letters) - if isinstance(extends, tuple): - # For cairo < 1.15 - x_bearing, y_bearing, ex_width, ex_height = extends[0:4] - else: - x_bearing = extends.x_bearing - y_bearing = extends.y_bearing - ex_width = extends.width - ex_height = extends.height + x_bearing = extends.x_bearing + y_bearing = extends.y_bearing + ex_width = extends.width + ex_height = extends.height x_pos = width / 2 - (ex_width / 2 + x_bearing) y_pos = height / 2 - (ex_height / 2 + y_bearing) context.move_to(x_pos, y_pos) context.set_source_rgb(0.95, 0.95, 0.95) - # use cairo.OPERATOR_OVER legacy constant because its - # compatible with cairo < 1.13 - context.set_operator(cairo.OPERATOR_OVER) + context.set_operator(cairo.Operator.OVER) context.show_text(letters) return context.get_target() @@ -90,7 +84,7 @@ def add_status_to_avatar(surface, show): width = surface.get_width() height = surface.get_height() - new_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) + new_surface = cairo.ImageSurface(cairo.Format.ARGB32, width, height) new_surface.set_device_scale(*surface.get_device_scale()) scale = surface.get_device_scale()[0] @@ -128,7 +122,7 @@ def square(surface, size): if width == height: return surface - new_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, size, size) + new_surface = cairo.ImageSurface(cairo.Format.ARGB32, size, size) new_surface.set_device_scale(*surface.get_device_scale()) context = cairo.Context(new_surface) @@ -147,7 +141,7 @@ def square(surface, size): def clip_circle(surface): - new_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, + new_surface = cairo.ImageSurface(cairo.Format.ARGB32, surface.get_width(), surface.get_height()) diff --git a/setup.cfg b/setup.cfg index d1e091d0dbb23929dc608e31e8e8f941e07eedb9..27ab82580dc806264245ca38289eb2ba9833de52 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ install_requires = nbxmpp>=0.9.94 precis-i18n>=1.0.0 pyOpenSSL>=16.2 - pycairo>=1.14.0 + pycairo>=1.16.0 [options.package_data] gajim =