diff options
author | Johan Dahlin <zilch@src.gnome.org> | 2004-04-10 16:39:39 +0000 |
---|---|---|
committer | Johan Dahlin <zilch@src.gnome.org> | 2004-04-10 16:39:39 +0000 |
commit | 287806047cf293b5935f627b2f26ed9a96a7e958 (patch) | |
tree | bb9aa7cf39d3e8e052c9f493261bb76070fe7ca6 /gtk | |
parent | 4d81aa9f5ee5bda405efaa8a7fd1881a4db59bf1 (diff) | |
download | pygtk-287806047cf293b5935f627b2f26ed9a96a7e958.tar.gz |
Move GtkDeprecatedWarning ... Remove global module import and do it in the
* gtk/__init__.py: Move GtkDeprecatedWarning ...
Remove global module import and do it in the class _Deprecated and
delete _Deprecated when done.
(_Deprecated.__repr__): Add.
* gtk/gtkmodule.c: ... here, and rename it to DeprecatedWarning
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/__init__.py | 17 | ||||
-rw-r--r-- | gtk/gtkmodule.c | 9 |
2 files changed, 18 insertions, 8 deletions
diff --git a/gtk/__init__.py b/gtk/__init__.py index 0642eb6d..a504ebcf 100644 --- a/gtk/__init__.py +++ b/gtk/__init__.py @@ -59,12 +59,9 @@ gdk.INPUT_WRITE = _gobject.IO_OUT | _gobject.IO_HUP gdk.INPUT_EXCEPTION = _gobject.IO_PRI # Warnings -from warnings import warn as _warn - -class GtkDeprecationWarning(DeprecationWarning): - pass - class _Deprecated: + from warnings import warn + warn = staticmethod(warn) def __init__(self, func, oldname, module=''): self.func = func self.oldname = oldname @@ -73,12 +70,17 @@ class _Deprecated: self.module = 'gtk.' + module else: self.module = 'gtk' - + + def __repr__(self): + return '<deprecated function %s at 0x%x>' % (self.oldname, id(self)) + def __call__(self, *args, **kwargs): message = 'gtk.%s is deprecated, use %s.%s instead' % (self.oldname, self.module, self.name) - _warn(message, GtkDeprecationWarning) + # DeprecationWarning is imported from _gtk, so it's not the same + # as the one found in exceptions. + self.warn(message, DeprecationWarning) return self.func(*args, **kwargs) # old names compatibility ... @@ -92,3 +94,4 @@ create_pixmap_from_xpm = _Deprecated(gdk.pixmap_create_from_xpm, 'pixmap_create_from_xpm', 'gdk') create_pixmap_from_xpm_d = _Deprecated(gdk.pixmap_create_from_xpm_d, 'pixmap_create_from_xpm_d', 'gdk') +del _Deprecated diff --git a/gtk/gtkmodule.c b/gtk/gtkmodule.c index b7621c07..22ec993f 100644 --- a/gtk/gtkmodule.c +++ b/gtk/gtkmodule.c @@ -40,6 +40,8 @@ void pygdk_add_constants(PyObject *module, const gchar *strip_prefix); extern PyMethodDef pygtk_functions[]; extern PyMethodDef pygdk_functions[]; +PyObject *PyGtkDeprecationWarning; + static struct _PyGtk_FunctionStruct functions = { VERSION, @@ -152,6 +154,10 @@ init_gtk(void) o=PyCObject_FromVoidPtr(&functions, NULL)); Py_DECREF(o); + PyGtkDeprecationWarning = PyErr_NewException("gtk.GtkDeprecationWarning", + PyExc_DeprecationWarning, NULL); + PyDict_SetItemString(d, "DeprecationWarning", PyGtkDeprecationWarning); + stock_ids = gtk_stock_list_ids(); strcpy(buf, "STOCK_"); for (cur = stock_ids; cur; cur = stock_ids) { @@ -184,6 +190,7 @@ init_gtk(void) stock_ids = cur->next; g_slist_free_1(cur); } + /* namespace all the gdk stuff in gtk.gdk ... */ m = Py_InitModule("gtk.gdk", pygdk_functions); d = PyModule_GetDict(m); @@ -210,6 +217,6 @@ init_gtk(void) add_atom(SELECTION_TYPE_WINDOW); add_atom(SELECTION_TYPE_STRING); #undef add_atom - + gtk_timeout_add(100, python_do_pending_calls, NULL); } |