diff options
author | Juan Pablo Ugarte <jpu@src.gnome.org> | 2006-11-22 22:26:16 +0000 |
---|---|---|
committer | Juan Pablo Ugarte <jpu@src.gnome.org> | 2006-11-22 22:26:16 +0000 |
commit | fce7b7af47c087ac85569a9955955a6e6612fd7d (patch) | |
tree | bf34690a0b3f698c82509fed79c0258e33fa6613 | |
parent | d2f07880644f428b84732cec4a6c072f0a81ad09 (diff) | |
download | glade-fce7b7af47c087ac85569a9955955a6e6612fd7d.tar.gz |
added PYGTK_REQ_MAYOR, PYGTK_REQ_MINOR and PYGTK_REQ_MICRO to config.h
* configure.in: added PYGTK_REQ_MAYOR, PYGTK_REQ_MINOR and
PYGTK_REQ_MICRO to config.h
* src/glade-python.c: check for pygobject >= 2.12.0
* src/glade-python-gwa.override: fixed packing property bug in
glade_python_support_init_value()
* src/glade-python-gwa.c: updated.
* src/glade-project-window.c: show clipboard.
* src/glade-catalog.c: check catalog's language is valid.
* src/glade-binding.c: added a warning message when we can not load
a module.
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | configure.in | 8 | ||||
-rw-r--r-- | src/glade-binding.c | 3 | ||||
-rw-r--r-- | src/glade-catalog.c | 16 | ||||
-rw-r--r-- | src/glade-project-window.c | 1 | ||||
-rw-r--r-- | src/glade-python-gwa.c | 74 | ||||
-rw-r--r-- | src/glade-python-gwa.override | 12 | ||||
-rw-r--r-- | src/glade-python.c | 70 |
8 files changed, 151 insertions, 60 deletions
@@ -1,4 +1,23 @@ -2006-11-22 Andreas Köhler andi5.py@gmx.net> +2006-11-21 Juan Pablo Ugarte <juanpablougarte@gmail.com> + + * configure.in: added PYGTK_REQ_MAYOR, PYGTK_REQ_MINOR and + PYGTK_REQ_MICRO to config.h + + * src/glade-python.c: check for pygobject >= 2.12.0 + + * src/glade-python-gwa.override: fixed packing property bug in + glade_python_support_init_value() + + * src/glade-python-gwa.c: updated. + + * src/glade-project-window.c: show clipboard. + + * src/glade-catalog.c: check catalog's language is valid. + + * src/glade-binding.c: added a warning message when we can not load + a module. + +2006-11-22 Andreas Köhler <andi5.py@gmx.net> * src/glade-design-view.h: dllexported functions with LIBGLADEUI_API. @@ -36,12 +55,12 @@ * src/glade-project-window.c: added window which a console for each GladeBinding that provide a console. - * glade-python-gwa.c: GladeWidgetAdaptor python wrapper. + * src/glade-python-gwa.c: GladeWidgetAdaptor python wrapper. - * glade-python-gwa.[defs override]: files used by pygtk-codegen-2.0 + * src/glade-python-gwa.[defs override]: files used by pygtk-codegen-2.0 to create glade-python-gwa.c - * glade-python.c: GladeBinding plugin for python language. + * src/glade-python.c: GladeBinding plugin for python language. * src/glade-widget-adaptor.[ch]: o added GWAAction support. diff --git a/configure.in b/configure.in index 2f43535a..55d287df 100644 --- a/configure.in +++ b/configure.in @@ -82,12 +82,18 @@ AC_ARG_ENABLE(python, if test x"$check_python" = x"yes"; then AC_PATH_PROGS([PYTHON], [python]) - PKG_CHECK_MODULES(PYGTK, pygtk-2.0 >= 2.10.0, [have_pygtk=yes], [have_pygtk=no]) + PYGTK_REQ_MAYOR=2 + PYGTK_REQ_MINOR=10 + PYGTK_REQ_MICRO=0 + PKG_CHECK_MODULES(PYGTK, pygtk-2.0 >= $PYGTK_REQ_MAYOR.$PYGTK_REQ_MINOR.$PYGTK_REQ_MICRO, [have_pygtk=yes], [have_pygtk=no]) if test -f $PYTHON -a "$have_pygtk" = "yes"; then PYTHON_CFLAGS="`$PYTHON -c "from distutils import sysconfig; getvar = sysconfig.get_config_var; flags = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True)]; print ' '.join(flags)"` $PYGTK_CFLAGS" PYTHON_LIBS="`$PYTHON -c "from distutils import sysconfig; pyver = sysconfig.get_config_var('VERSION'); getvar = sysconfig.get_config_var; libs = getvar('LIBS').split() + getvar('SYSLIBS').split(); libs.append('-lpython'+pyver); libs.insert(0, '-L' + getvar('LIBPL')); print ' '.join(libs)"` $PYGTK_LIBS" AC_SUBST(PYTHON_CFLAGS) AC_SUBST(PYTHON_LIBS) + AC_DEFINE_UNQUOTED(PYGTK_REQ_MAYOR, $PYGTK_REQ_MAYOR, Pygtk mayor version required) + AC_DEFINE_UNQUOTED(PYGTK_REQ_MINOR, $PYGTK_REQ_MINOR, Pygtk minor version required) + AC_DEFINE_UNQUOTED(PYGTK_REQ_MICRO, $PYGTK_REQ_MICRO, Pygtk micro version required) have_python=yes else have_python=no diff --git a/src/glade-binding.c b/src/glade-binding.c index 48656d1b..849b5417 100644 --- a/src/glade-binding.c +++ b/src/glade-binding.c @@ -182,7 +182,6 @@ glade_binding_load_all (void) path = g_build_filename (glade_bindings_dir, filename, NULL); module = g_module_open (path, G_MODULE_BIND_LAZY); - g_free (path); if (module == NULL) continue; @@ -215,9 +214,11 @@ glade_binding_load_all (void) } else { + g_warning ("Unable to load GladeBinding module '%s'", path); g_module_close (module); g_free (binding); } + g_free (path); } } diff --git a/src/glade-catalog.c b/src/glade-catalog.c index 94ee9e8f..74b495a2 100644 --- a/src/glade-catalog.c +++ b/src/glade-catalog.c @@ -140,7 +140,6 @@ catalog_open (const gchar *filename) catalog = g_new0 (GladeCatalog, 1); catalog->context = context; catalog->name = glade_xml_get_property_string (root, GLADE_TAG_NAME); - loaded_catalogs = g_list_prepend (loaded_catalogs, g_strdup (catalog->name)); if (!catalog->name) { @@ -152,6 +151,21 @@ catalog_open (const gchar *filename) catalog->language = glade_xml_get_property_string (root, GLADE_TAG_LANGUAGE); + + if (catalog->language && (glade_binding_get (catalog->language)) == NULL) + { + g_warning ("%s language is not supported. " + "Make sure the corresponding GladeBinding module is available.", + catalog->language); + g_free (catalog->name); + g_free (catalog->language); + g_free (catalog); + glade_xml_context_free (context); + return NULL; + } + + loaded_catalogs = g_list_prepend (loaded_catalogs, g_strdup (catalog->name)); + catalog->library = glade_xml_get_property_string (root, GLADE_TAG_LIBRARY); catalog->dep_catalog = diff --git a/src/glade-project-window.c b/src/glade-project-window.c index 3f5638fd..0b03af9f 100644 --- a/src/glade-project-window.c +++ b/src/glade-project-window.c @@ -1247,6 +1247,7 @@ gpw_show_clipboard_cb (GtkAction *action, GladeProjectWindow *gpw) g_signal_connect (view, "delete_event", G_CALLBACK (gpw_hide_window_on_delete), gpw->priv->ui); + gtk_widget_show_all (view); } gtk_window_present (GTK_WINDOW (view)); diff --git a/src/glade-python-gwa.c b/src/glade-python-gwa.c index 2bead297..5a4c67fa 100644 --- a/src/glade-python-gwa.c +++ b/src/glade-python-gwa.c @@ -31,8 +31,10 @@ glade_python_support_init_value (GObject *object, if (property == NULL) { - PyErr_Format (PyExc_TypeError, "%s does not support property `%s'", - (is_pack) ? "container ": "object", property_name); + PyErr_Format (PyExc_TypeError, "'%s' does not support %s property `%s'", + glade_widget_get_name (widget), + (is_pack) ? "packing" : "", + property_name); return FALSE; } @@ -74,7 +76,7 @@ glade_python_support_list_from_glist (GList *list) GValue* and GList* types. */ -#line 78 "glade-python-gwa.c" +#line 80 "glade-python-gwa.c" /* ---------- types from other modules ---------- */ @@ -85,13 +87,13 @@ static PyTypeObject *_PyGObject_Type; /* ---------- forward type declarations ---------- */ PyTypeObject PyGladeWidgetAdaptor_Type; -#line 89 "glade-python-gwa.c" +#line 91 "glade-python-gwa.c" /* ----------- GladeWidgetAdaptor ----------- */ -#line 96 "glade-python-gwa.override" +#line 98 "glade-python-gwa.override" static PyObject * _wrap_GladeWidgetAdaptor__do_verify_property(PyObject *cls, PyObject *args, PyObject *kwargs) { @@ -121,10 +123,10 @@ _wrap_GladeWidgetAdaptor__do_verify_property(PyObject *cls, PyObject *args, PyOb return PyBool_FromLong(ret); } -#line 125 "glade-python-gwa.c" +#line 127 "glade-python-gwa.c" -#line 210 "glade-python-gwa.override" +#line 212 "glade-python-gwa.override" static PyObject * _wrap_GladeWidgetAdaptor__do_set_property(PyObject *cls, PyObject *args, PyObject *kwargs) { @@ -153,10 +155,10 @@ _wrap_GladeWidgetAdaptor__do_set_property(PyObject *cls, PyObject *args, PyObjec Py_INCREF(Py_None); return Py_None; } -#line 157 "glade-python-gwa.c" +#line 159 "glade-python-gwa.c" -#line 330 "glade-python-gwa.override" +#line 332 "glade-python-gwa.override" static PyObject * _wrap_GladeWidgetAdaptor__do_get_property(PyObject *cls, PyObject *args, PyObject *kwargs) { @@ -186,10 +188,10 @@ _wrap_GladeWidgetAdaptor__do_get_property(PyObject *cls, PyObject *args, PyObjec g_type_class_unref(klass); return ret; } -#line 190 "glade-python-gwa.c" +#line 192 "glade-python-gwa.c" -#line 430 "glade-python-gwa.override" +#line 432 "glade-python-gwa.override" static PyObject * _wrap_GladeWidgetAdaptor__do_child_verify_property(PyObject *cls, PyObject *args, PyObject *kwargs) { @@ -205,7 +207,7 @@ _wrap_GladeWidgetAdaptor__do_child_verify_property(PyObject *cls, PyObject *args return NULL; klass = g_type_class_ref(pyg_type_from_object(cls)); - glade_python_support_init_value (container->obj, TRUE, property_name, &value); + glade_python_support_init_value (child->obj, TRUE, property_name, &value); pyg_value_from_pyobject (&value, val); if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_verify_property) @@ -219,10 +221,10 @@ _wrap_GladeWidgetAdaptor__do_child_verify_property(PyObject *cls, PyObject *args return PyBool_FromLong(ret); } -#line 223 "glade-python-gwa.c" +#line 225 "glade-python-gwa.c" -#line 554 "glade-python-gwa.override" +#line 556 "glade-python-gwa.override" static PyObject * _wrap_GladeWidgetAdaptor__do_child_set_property(PyObject *cls, PyObject *args, PyObject *kwargs) { @@ -237,7 +239,7 @@ _wrap_GladeWidgetAdaptor__do_child_set_property(PyObject *cls, PyObject *args, P return NULL; klass = g_type_class_ref(pyg_type_from_object(cls)); - glade_python_support_init_value (container->obj, TRUE, property_name, &value); + glade_python_support_init_value (child->obj, TRUE, property_name, &value); pyg_value_from_pyobject (&value, val); if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_set_property) @@ -251,10 +253,10 @@ _wrap_GladeWidgetAdaptor__do_child_set_property(PyObject *cls, PyObject *args, P Py_INCREF(Py_None); return Py_None; } -#line 255 "glade-python-gwa.c" +#line 257 "glade-python-gwa.c" -#line 684 "glade-python-gwa.override" +#line 686 "glade-python-gwa.override" static PyObject * _wrap_GladeWidgetAdaptor__do_child_get_property(PyObject *cls, PyObject *args, PyObject *kwargs) { @@ -270,7 +272,7 @@ _wrap_GladeWidgetAdaptor__do_child_get_property(PyObject *cls, PyObject *args, P klass = g_type_class_ref(pyg_type_from_object(cls)); if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_get_property) { - glade_python_support_init_value (container->obj, TRUE, property_name, &value); + glade_python_support_init_value (child->obj, TRUE, property_name, &value); GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_get_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(child->obj), property_name, &value); ret = pyg_value_as_pyobject (&value, TRUE); g_value_unset (&value); @@ -283,10 +285,10 @@ _wrap_GladeWidgetAdaptor__do_child_get_property(PyObject *cls, PyObject *args, P g_type_class_unref(klass); return ret; } -#line 287 "glade-python-gwa.c" +#line 289 "glade-python-gwa.c" -#line 792 "glade-python-gwa.override" +#line 794 "glade-python-gwa.override" static PyObject * _wrap_GladeWidgetAdaptor__do_get_children(PyObject *cls, PyObject *args, PyObject *kwargs) { @@ -312,7 +314,7 @@ _wrap_GladeWidgetAdaptor__do_get_children(PyObject *cls, PyObject *args, PyObjec g_list_free (ret); return list; } -#line 316 "glade-python-gwa.c" +#line 318 "glade-python-gwa.c" static PyObject * @@ -515,7 +517,7 @@ PyTypeObject PyGladeWidgetAdaptor_Type = { (inquiry)0 /* tp_is_gc */ }; -#line 127 "glade-python-gwa.override" +#line 129 "glade-python-gwa.override" static gboolean _wrap_GladeWidgetAdaptor__proxy_do_verify_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, const GValue*value) { @@ -597,10 +599,10 @@ _wrap_GladeWidgetAdaptor__proxy_do_verify_property(GladeWidgetAdaptor *self, GOb return retval; } -#line 601 "glade-python-gwa.c" +#line 603 "glade-python-gwa.c" -#line 240 "glade-python-gwa.override" +#line 242 "glade-python-gwa.override" static void _wrap_GladeWidgetAdaptor__proxy_do_set_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, const GValue*value) { @@ -689,10 +691,10 @@ _wrap_GladeWidgetAdaptor__proxy_do_set_property(GladeWidgetAdaptor *self, GObjec Py_DECREF(py_self); pyg_gil_state_release(__py_state); } -#line 693 "glade-python-gwa.c" +#line 695 "glade-python-gwa.c" -#line 361 "glade-python-gwa.override" +#line 363 "glade-python-gwa.override" static void _wrap_GladeWidgetAdaptor__proxy_do_get_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, GValue *value) { @@ -760,10 +762,10 @@ _wrap_GladeWidgetAdaptor__proxy_do_get_property(GladeWidgetAdaptor *self, GObjec Py_DECREF(py_self); pyg_gil_state_release(__py_state); } -#line 764 "glade-python-gwa.c" +#line 766 "glade-python-gwa.c" -#line 461 "glade-python-gwa.override" +#line 463 "glade-python-gwa.override" static gboolean _wrap_GladeWidgetAdaptor__proxy_do_child_verify_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, GValue*value) { @@ -855,10 +857,10 @@ _wrap_GladeWidgetAdaptor__proxy_do_child_verify_property(GladeWidgetAdaptor *sel return retval; } -#line 859 "glade-python-gwa.c" +#line 861 "glade-python-gwa.c" -#line 584 "glade-python-gwa.override" +#line 586 "glade-python-gwa.override" static void _wrap_GladeWidgetAdaptor__proxy_do_child_set_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, const GValue *value) { @@ -957,10 +959,10 @@ _wrap_GladeWidgetAdaptor__proxy_do_child_set_property(GladeWidgetAdaptor *self, Py_DECREF(py_self); pyg_gil_state_release(__py_state); } -#line 961 "glade-python-gwa.c" +#line 963 "glade-python-gwa.c" -#line 714 "glade-python-gwa.override" +#line 716 "glade-python-gwa.override" static void _wrap_GladeWidgetAdaptor__proxy_do_child_get_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, GValue *value) { @@ -1037,10 +1039,10 @@ _wrap_GladeWidgetAdaptor__proxy_do_child_get_property(GladeWidgetAdaptor *self, Py_DECREF(py_self); pyg_gil_state_release(__py_state); } -#line 1041 "glade-python-gwa.c" +#line 1043 "glade-python-gwa.c" -#line 819 "glade-python-gwa.override" +#line 821 "glade-python-gwa.override" static GList* _wrap_GladeWidgetAdaptor__proxy_do_get_children(GladeWidgetAdaptor *self, GObject*container) { @@ -1100,7 +1102,7 @@ _wrap_GladeWidgetAdaptor__proxy_do_get_children(GladeWidgetAdaptor *self, GObjec return retval; } -#line 1104 "glade-python-gwa.c" +#line 1106 "glade-python-gwa.c" static void @@ -1667,7 +1669,7 @@ glade_python_gwa_register_classes(PyObject *d) } -#line 1671 "glade-python-gwa.c" +#line 1673 "glade-python-gwa.c" pygobject_register_class(d, "GladeWidgetAdaptor", GLADE_TYPE_WIDGET_ADAPTOR, &PyGladeWidgetAdaptor_Type, Py_BuildValue("(O)", &PyGObject_Type)); pyg_set_object_has_new_constructor(GLADE_TYPE_WIDGET_ADAPTOR); pyg_register_class_init(GLADE_TYPE_WIDGET_ADAPTOR, __GladeWidgetAdaptor_class_init); diff --git a/src/glade-python-gwa.override b/src/glade-python-gwa.override index b6a40207..ac5b2b59 100644 --- a/src/glade-python-gwa.override +++ b/src/glade-python-gwa.override @@ -46,8 +46,10 @@ glade_python_support_init_value (GObject *object, if (property == NULL) { - PyErr_Format (PyExc_TypeError, "%s does not support property `%s'", - (is_pack) ? "container ": "object", property_name); + PyErr_Format (PyExc_TypeError, "'%s' does not support %s property `%s'", + glade_widget_get_name (widget), + (is_pack) ? "packing" : "", + property_name); return FALSE; } @@ -442,7 +444,7 @@ _wrap_GladeWidgetAdaptor__do_child_verify_property(PyObject *cls, PyObject *args return NULL; klass = g_type_class_ref(pyg_type_from_object(cls)); - glade_python_support_init_value (container->obj, TRUE, property_name, &value); + glade_python_support_init_value (child->obj, TRUE, property_name, &value); pyg_value_from_pyobject (&value, val); if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_verify_property) @@ -565,7 +567,7 @@ _wrap_GladeWidgetAdaptor__do_child_set_property(PyObject *cls, PyObject *args, P return NULL; klass = g_type_class_ref(pyg_type_from_object(cls)); - glade_python_support_init_value (container->obj, TRUE, property_name, &value); + glade_python_support_init_value (child->obj, TRUE, property_name, &value); pyg_value_from_pyobject (&value, val); if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_set_property) @@ -696,7 +698,7 @@ _wrap_GladeWidgetAdaptor__do_child_get_property(PyObject *cls, PyObject *args, P klass = g_type_class_ref(pyg_type_from_object(cls)); if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_get_property) { - glade_python_support_init_value (container->obj, TRUE, property_name, &value); + glade_python_support_init_value (child->obj, TRUE, property_name, &value); GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_get_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(child->obj), property_name, &value); ret = pyg_value_as_pyobject (&value, TRUE); g_value_unset (&value); diff --git a/src/glade-python.c b/src/glade-python.c index 2178ed59..49476188 100644 --- a/src/glade-python.c +++ b/src/glade-python.c @@ -365,16 +365,6 @@ static PyMethodDef GladeStderrMethods[] = { {NULL, NULL, 0, NULL} }; -void -glade_python_init () -{ - char *argv[2] = {"", NULL}; - Py_Initialize (); - PySys_SetArgv (1, argv); - init_pygobject (); - pyg_disable_warning_redirections (); -} - /* Bindings */ void glade_python_binding_finalize (GladeBindingCtrl *ctrl) @@ -509,6 +499,45 @@ glade_python_binding_console_new (void) */ void glade_python_gwa_register_classes (PyObject *d); +static void +glade_python_init (void) +{ + char *argv[2] = {"", NULL}; + + /* Init interpreter */ + Py_Initialize (); + PySys_SetArgv (1, argv); +} + +static void +glade_python_init_pygtk_check (gint req_major, gint req_minor, gint req_micro) +{ + PyObject *gobject, *mdict, *version; + int found_major, found_minor, found_micro; + + init_pygobject(); + + gobject = PyImport_ImportModule("gobject"); + mdict = PyModule_GetDict(gobject); + version = PyDict_GetItemString(mdict, "pygtk_version"); + if (!version) + { + PyErr_SetString(PyExc_ImportError, "PyGObject version too old"); + return; + } + if (!PyArg_ParseTuple(version, "iii", &found_major, &found_minor, &found_micro)) + return; + if (req_major != found_major || req_minor > found_minor || + (req_minor == found_minor && req_micro > found_micro)) + { + PyErr_Format(PyExc_ImportError, + "PyGObject version mismatch, %d.%d.%d is required, " + "found %d.%d.%d.", req_major, req_minor, req_micro, + found_major, found_minor, found_micro); + return; + } +} + gboolean glade_binding_init (GladeBindingCtrl *ctrl) { @@ -529,8 +558,25 @@ glade_binding_init (GladeBindingCtrl *ctrl) Py_SetProgramName (PACKAGE_NAME); - /* Initialize the Python interpreter if it is not */ - if (Py_IsInitialized() == FALSE) glade_python_init (); + /* Initialize the Python interpreter */ + glade_python_init (); + + /* Check and init pygobject >= 2.12.0 */ + PyErr_Clear (); + glade_python_init_pygtk_check (PYGTK_REQ_MAYOR, PYGTK_REQ_MINOR, PYGTK_REQ_MICRO); + if (PyErr_Occurred ()) + { + g_warning ("Unable to load pygobject module >= %d.%d.%d, " + "please make sure it is in python's path (sys.path). " + "(use PYTHONPATH env variable to specify non default paths)", + PYGTK_REQ_MAYOR, PYGTK_REQ_MINOR, PYGTK_REQ_MICRO); + PyErr_Clear (); + Py_Finalize (); + g_object_unref (PythonBuffer); + return FALSE; + } + + pyg_disable_warning_redirections (); /* Create glade object */ glade = Py_InitModule ("glade", GladeMethods); |