Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 12d3c8e

Browse filesBrowse files
authored
Merge pull request #23537 from anntzer/no_cairo_to_context
Move the deprecated RendererGTK{3,4}Cairo to a single place.
2 parents d61ebe9 + 3d5ff6f commit 12d3c8e
Copy full SHA for 12d3c8e

File tree

Expand file treeCollapse file tree

3 files changed

+21
-39
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+21
-39
lines changed

‎lib/matplotlib/backends/backend_cairo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_cairo.py
+13-16Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,6 @@
3838
backend_version = cairo.version
3939

4040

41-
if cairo.__name__ == "cairocffi":
42-
# Convert a pycairo context to a cairocffi one.
43-
def _to_context(ctx):
44-
if not isinstance(ctx, cairo.Context):
45-
ctx = cairo.Context._from_pointer(
46-
cairo.ffi.cast(
47-
'cairo_t **',
48-
id(ctx) + object.__basicsize__)[0],
49-
incref=True)
50-
return ctx
51-
else:
52-
# Pass-through a pycairo context.
53-
def _to_context(ctx):
54-
return ctx
55-
56-
5741
def _append_path(ctx, path, transform, clip=None):
5842
for points, code in path.iter_segments(
5943
transform, remove_nans=True, clip=clip):
@@ -547,6 +531,19 @@ def _save(self, fmt, fobj, *, orientation='portrait'):
547531
print_svgz = functools.partialmethod(_save, "svgz")
548532

549533

534+
@_api.deprecated("3.6")
535+
class _RendererGTKCairo(RendererCairo):
536+
def set_context(self, ctx):
537+
if (cairo.__name__ == "cairocffi"
538+
and not isinstance(ctx, cairo.Context)):
539+
ctx = cairo.Context._from_pointer(
540+
cairo.ffi.cast(
541+
'cairo_t **',
542+
id(ctx) + object.__basicsize__)[0],
543+
incref=True)
544+
self.gc.ctx = ctx
545+
546+
550547
@_Backend.export
551548
class _BackendCairo(_Backend):
552549
FigureCanvas = FigureCanvasCairo

‎lib/matplotlib/backends/backend_gtk3cairo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_gtk3cairo.py
+4-12Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
from contextlib import nullcontext
22

3-
from .. import _api
4-
from . import backend_cairo, backend_gtk3
5-
from .backend_gtk3 import Gtk, _BackendGTK3
3+
from .backend_cairo import (
4+
FigureCanvasCairo, _RendererGTKCairo as RendererGTK3Cairo)
5+
from .backend_gtk3 import Gtk, FigureCanvasGTK3, _BackendGTK3
66

77

8-
@_api.deprecated("3.6")
9-
class RendererGTK3Cairo(backend_cairo.RendererCairo):
10-
def set_context(self, ctx):
11-
self.gc.ctx = backend_cairo._to_context(ctx)
12-
13-
14-
class FigureCanvasGTK3Cairo(backend_cairo.FigureCanvasCairo,
15-
backend_gtk3.FigureCanvasGTK3):
16-
8+
class FigureCanvasGTK3Cairo(FigureCanvasCairo, FigureCanvasGTK3):
179
def on_draw_event(self, widget, ctx):
1810
with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
1911
else nullcontext()):

‎lib/matplotlib/backends/backend_gtk4cairo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_gtk4cairo.py
+4-11Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
from contextlib import nullcontext
22

3-
from .. import _api
4-
from . import backend_cairo, backend_gtk4
5-
from .backend_gtk4 import Gtk, _BackendGTK4
3+
from .backend_cairo import (
4+
FigureCanvasCairo, _RendererGTKCairo as RendererGTK4Cairo)
5+
from .backend_gtk4 import Gtk, FigureCanvasGTK4, _BackendGTK4
66

77

8-
@_api.deprecated("3.6")
9-
class RendererGTK4Cairo(backend_cairo.RendererCairo):
10-
def set_context(self, ctx):
11-
self.gc.ctx = backend_cairo._to_context(ctx)
12-
13-
14-
class FigureCanvasGTK4Cairo(backend_cairo.FigureCanvasCairo,
15-
backend_gtk4.FigureCanvasGTK4):
8+
class FigureCanvasGTK4Cairo(FigureCanvasCairo, FigureCanvasGTK4):
169
_context_is_scaled = True
1710

1811
def on_draw_event(self, widget, ctx):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.