1 # -*- Mode: Python; py-indent-offset: 4 -*-
2 # vim: tabstop=4 shiftwidth=4 expandtab
4 # Copyright (C) 2010 Paolo Borelli <pborelli@gnome.org>
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.
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.
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
21 from ..overrides import override
22 from ..importer import modules
24 Pango = modules['Pango']._introspection_module
29 class Context(Pango.Context):
31 def get_metrics(self, desc, language=None):
32 return super(Context, self).get_metrics(desc, language)
34 Context = override(Context)
35 __all__.append('Context')
38 class FontDescription(Pango.FontDescription):
40 def __new__(cls, string=None):
41 if string is not None:
42 return Pango.font_description_from_string(string)
44 return Pango.FontDescription.__new__(cls)
46 FontDescription = override(FontDescription)
47 __all__.append('FontDescription')
50 class Layout(Pango.Layout):
52 def __new__(cls, context):
53 return Pango.Layout.new(context)
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)
60 def set_markup(self, text, length=-1):
61 super(Layout, self).set_markup(text, length)
63 Layout = override(Layout)
64 __all__.append('Layout')