Imported Upstream version 3.3.1
[platform/upstream/pygobject2.git] / gi / overrides / Pango.py
1 # -*- Mode: Python; py-indent-offset: 4 -*-
2 # vim: tabstop=4 shiftwidth=4 expandtab
3 #
4 # Copyright (C) 2010 Paolo Borelli <pborelli@gnome.org>
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
19 # USA
20
21 from ..overrides import override
22 from ..importer import modules
23
24 Pango = modules['Pango']._introspection_module
25
26 __all__ = []
27
28
29 class Context(Pango.Context):
30
31     def get_metrics(self, desc, language=None):
32         return super(Context, self).get_metrics(desc, language)
33
34 Context = override(Context)
35 __all__.append('Context')
36
37
38 class FontDescription(Pango.FontDescription):
39
40     def __new__(cls, string=None):
41         if string is not None:
42             return Pango.font_description_from_string(string)
43         else:
44             return Pango.FontDescription.__new__(cls)
45
46 FontDescription = override(FontDescription)
47 __all__.append('FontDescription')
48
49
50 class Layout(Pango.Layout):
51
52     def __new__(cls, context):
53         return Pango.Layout.new(context)
54
55     def __init__(self, context, **kwds):
56         # simply discard 'context', since it was set by
57         # __new__ and it is not a PangoLayout property
58         super(Layout, self).__init__(**kwds)
59
60     def set_markup(self, text, length=-1):
61         super(Layout, self).set_markup(text, length)
62
63 Layout = override(Layout)
64 __all__.append('Layout')