Trees | Indices | Help |
---|
|
1 # -*- Mode: Python; py-indent-offset: 4 -*- 2 # pygobject - Python bindings for the GObject library 3 # Copyright (C) 2006 Johan Dahlin 4 # 5 # gobject/__init__.py: initialisation file for gobject module 6 # 7 # This library is free software; you can redistribute it and/or 8 # modify it under the terms of the GNU Lesser General Public 9 # License as published by the Free Software Foundation; either 10 # version 2.1 of the License, or (at your option) any later version. 11 # 12 # This library is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 # Lesser General Public License for more details. 16 # 17 # You should have received a copy of the GNU Lesser General Public 18 # License along with this library; if not, write to the Free Software 19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 20 # USA 21 22 # this can go when things are a little further along 23 24 import sys 25 26 from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \ 27 io_add_watch, source_remove, child_watch_add, markup_escape_text, \ 28 get_current_time, filename_display_name, filename_display_basename, \ 29 filename_from_utf8, get_application_name, set_application_name, \ 30 get_prgname, set_prgname, main_depth, Pid, GError, glib_version, \ 31 MainLoop, MainContext, main_context_default, IOChannel, Source, Idle, \ 32 Timeout, PollFD, OptionGroup, OptionContext, option, uri_list_extract_uris 33 from glib import SPAWN_LEAVE_DESCRIPTORS_OPEN, SPAWN_DO_NOT_REAP_CHILD, \ 34 SPAWN_SEARCH_PATH, SPAWN_STDOUT_TO_DEV_NULL, SPAWN_STDERR_TO_DEV_NULL, \ 35 SPAWN_CHILD_INHERITS_STDIN, SPAWN_FILE_AND_ARGV_ZERO, PRIORITY_HIGH, \ 36 PRIORITY_DEFAULT, PRIORITY_HIGH_IDLE, PRIORITY_DEFAULT_IDLE, \ 37 PRIORITY_LOW, IO_IN, IO_OUT, IO_PRI, IO_ERR, IO_HUP, IO_NVAL, \ 38 IO_STATUS_ERROR, IO_STATUS_NORMAL, IO_STATUS_EOF, IO_STATUS_AGAIN, \ 39 IO_FLAG_APPEND, IO_FLAG_NONBLOCK, IO_FLAG_IS_READABLE, \ 40 IO_FLAG_IS_WRITEABLE, IO_FLAG_IS_SEEKABLE, IO_FLAG_MASK, \ 41 IO_FLAG_GET_MASK, IO_FLAG_SET_MASK, OPTION_FLAG_HIDDEN, \ 42 OPTION_FLAG_IN_MAIN, OPTION_FLAG_REVERSE, OPTION_FLAG_NO_ARG, \ 43 OPTION_FLAG_FILENAME, OPTION_FLAG_OPTIONAL_ARG, OPTION_FLAG_NOALIAS, \ 44 OPTION_ERROR_UNKNOWN_OPTION, OPTION_ERROR_BAD_VALUE, \ 45 OPTION_ERROR_FAILED, OPTION_REMAINING, OPTION_ERROR 46 47 from gobject.constants import * 48 from gobject._gobject import * 49 _PyGObject_API = _gobject._PyGObject_API 50 51 from gobject.propertyhelper import property 52 53 sys.modules['gobject.option'] = option 5456 "Metaclass for automatically registering GObject classes"102 cls.do_set_property = obj_set_property 103 112 116 117 _gobject._install_metaclass(GObjectMeta) 118 119 del _gobject 12058 type.__init__(cls, name, bases, dict_) 59 cls._install_properties() 60 cls._type_register(cls.__dict__)6163 gproperties = getattr(cls, '__gproperties__', {}) 64 65 props = [] 66 for name, prop in cls.__dict__.items(): 67 if isinstance(prop, property): # not same as the built-in 68 if name in gproperties: 69 raise ValueError 70 prop.name = name 71 gproperties[name] = prop.get_pspec_args() 72 props.append(prop) 73 74 if not props: 75 return 76 77 cls.__gproperties__ = gproperties 78 79 if ('do_get_property' in cls.__dict__ or 80 'do_set_property' in cls.__dict__): 81 for prop in props: 82 if (prop.getter != prop._default_getter or 83 prop.setter != prop._default_setter): 84 raise TypeError( 85 "GObject subclass %r defines do_get/set_property" 86 " and it also uses a property which a custom setter" 87 " or getter. This is not allowed" % ( 88 cls.__name__,)) 89 90 def obj_get_property(self, pspec): 91 name = pspec.name.replace('-', '_') 92 prop = getattr(cls, name, None) 93 if prop: 94 return prop.getter(self)95 cls.do_get_property = obj_get_property 96 97 def obj_set_property(self, pspec, value): 98 name = pspec.name.replace('-', '_') 99 prop = getattr(cls, name, None) 100 if prop: 101 prop.setter(self, value)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sun Sep 16 23:29:31 2012 | http://epydoc.sourceforge.net |