Debian Codegraph @

gi/overrides/GdkPixbuf.py

raw
1 # Copyright 2018 Christoph Reiter <[email protected]>
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
16 # USA
17
18 import warnings
19
20 from gi import PyGIDeprecationWarning
21 from gi.repository import GLib
22
23 from ..overrides import override
24 from ..module import get_introspection_module
25
26
27 GdkPixbuf = get_introspection_module("GdkPixbuf")
28 __all__ = []
29
30
31 @override
32 class Pixbuf(GdkPixbuf.Pixbuf):
33 @classmethod
34 def new_from_data(
35 cls,
36 data,
37 colorspace,
38 has_alpha,
39 bits_per_sample,
40 width,
41 height,
42 rowstride,
43 destroy_fn=None,
44 *destroy_fn_data,
45 ):
46 if destroy_fn is not None:
47 w = PyGIDeprecationWarning("destroy_fn argument deprecated")
48 warnings.warn(w, stacklevel=2)
49 if destroy_fn_data:
50 w = PyGIDeprecationWarning("destroy_fn_data argument deprecated")
51 warnings.warn(w, stacklevel=2)
52
53 data = GLib.Bytes.new(data)
54 return cls.new_from_bytes(
55 data, colorspace, has_alpha, bits_per_sample, width, height, rowstride
56 )
57
58
59 __all__.append("Pixbuf")