Commit a7bb7fe2 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte
Browse files

Removed bindings framework since now all binding work will be done

in the branch until we have a proper framework and a full implementation (python)

svn path=/trunk/; revision=1447
parent d1301931
2007-07-10 Juan Pablo Ugarte <juanpablougarte@gmail.com>
Removed bindings framework since now all binding work will be done
in the branch until we have a proper framework and a full implementation (python)
2007-07-10 Vincent Geddes <vgeddes@gnome.org>
* gladeui/glade-project: fix bug with regards to setting the
......
SUBDIRS = po data gladeui src plugins bindings doc
SUBDIRS = po data gladeui src plugins doc
if HAVE_GNOME_DOC_UTILS
SUBDIRS += help
......
## Process this file with automake to produce Makefile.in
SUBDIRS =
if ENABLE_PYTHON
SUBDIRS += python
endif
## Process this file with automake to produce Makefile.in
libgladeui = $(top_builddir)/gladeui/libgladeui-1.la
# libgladepython
gladepython_LTLIBRARIES = libgladepython.la
gladepythondir = $(pkglibdir)/bindings
libgladepython_la_SOURCES = glade-python.c glade-python-gwa.c
libgladepython_la_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
$(AM_CPPFLAGS)
libgladepython_la_CFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
$(PYTHON_CFLAGS) \
$(NO_STRICT_ALIASING_CFLAGS) \
$(PYGTK_CFLAGS) \
$(GTK_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS)
libgladepython_la_LDFLAGS = -module -avoid-version
libgladepython_la_LIBADD = \
$(libgladeui) \
$(PYTHON_LIB_LOC) \
$(PYTHON_LIBS) \
$(PYTHON_EXTRA_LIBS) \
$(PYGTK_LIBS)
if PLATFORM_WIN32
libgladepython_la_LDFLAGS += -no-undefined
endif
This diff is collapsed.
; Copyright (C) 2006 Juan Pablo Ugarte.
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the
; License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;
; Authors:
; Juan Pablo Ugarte <juanpablougarte@gmail.com>
(define-object GladeWidgetAdaptor
(parent "GObject")
(c-name "GladeWidgetAdaptor")
(gtype-id "GLADE_TYPE_WIDGET_ADAPTOR")
)
(define-enum GladeCreateReason
(in-module "Glade")
(c-name "GladeCreateReason")
(gtype-id "GLADE_CREATE_REASON")
(values
'("create-user" "GLADE_CREATE_USER")
'("create-copy" "GLADE_CREATE_COPY")
'("create-load" "GLADE_CREATE_LOAD")
'("create-rebuild" "GLADE_CREATE_REBUILD")
)
)
(define-virtual verify_property
(of-object "GladeWidgetAdaptor")
(return-type "gboolean")
(parameters
'("GObject*" "object")
'("const-gchar*" "property_name")
'("const-GValue*" "value")
)
)
(define-virtual set_property
(of-object "GladeWidgetAdaptor")
(return-type "none")
(parameters
'("GObject*" "object")
'("const-gchar*" "property_name")
'("const-GValue*" "value")
)
)
(define-virtual get_property
(of-object "GladeWidgetAdaptor")
(return-type "none")
(parameters
'("GObject*" "object")
'("const-gchar*" "property_name")
'("GValue*" "value")
)
)
(define-virtual child_verify_property
(of-object "GladeWidgetAdaptor")
(return-type "gboolean")
(parameters
'("GObject*" "container")
'("GObject*" "child")
'("const-gchar*" "property_name")
'("const-GValue*" "value")
)
)
(define-virtual child_set_property
(of-object "GladeWidgetAdaptor")
(return-type "none")
(parameters
'("GObject*" "container")
'("GObject*" "child")
'("const-gchar*" "property_name")
'("const-GValue*" "value")
)
)
(define-virtual child_get_property
(of-object "GladeWidgetAdaptor")
(return-type "none")
(parameters
'("GObject*" "container")
'("GObject*" "child")
'("const-gchar*" "property_name")
'("GValue*" "value")
)
)
(define-virtual get_children
(of-object "GladeWidgetAdaptor")
(return-type "GList*")
(parameters
'("GObject*" "container")
)
)
(define-virtual add
(of-object "GladeWidgetAdaptor")
(return-type "none")
(parameters
'("GObject*" "parent")
'("GObject*" "child")
)
)
(define-virtual remove
(of-object "GladeWidgetAdaptor")
(return-type "none")
(parameters
'("GObject*" "parent")
'("GObject*" "child")
)
)
(define-virtual replace_child
(of-object "GladeWidgetAdaptor")
(return-type "none")
(parameters
'("GObject*" "container")
'("GObject*" "old")
'("GObject*" "new")
)
)
(define-virtual post_create
(of-object "GladeWidgetAdaptor")
(return-type "none")
(parameters
'("GObject*" "object")
'("GladeCreateReason" "reason")
)
)
(define-virtual get_internal_child
(of-object "GladeWidgetAdaptor")
(return-type "GObject*")
(parameters
'("GObject*" "parent")
'("const-gchar*" "name")
)
)
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2006 Juan Pablo Ugarte.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Authors:
* Juan Pablo Ugarte <juanpablougarte@gmail.com>
*/
#include <config.h>
#include <gladeui/glade.h>
#include <gladeui/glade-binding.h>
#include <Python.h>
#include <pygobject.h>
static PyObject *gladeui, *gladeui_dict, *GladeuiError;
extern PyTypeObject PyGladeWidgetAdaptor_Type;
static GHashTable *registered_classes = NULL;
static PyTypeObject *
glade_python_register_class (GType type)
{
GType parent = g_type_parent (type);
PyTypeObject *klass, *parent_class;
if (parent == 0 || type == GLADE_TYPE_WIDGET_ADAPTOR)
return &PyGladeWidgetAdaptor_Type;
if (g_hash_table_lookup (registered_classes, GUINT_TO_POINTER (parent)) == NULL)
parent_class = glade_python_register_class (parent);
else
parent_class = pygobject_lookup_class (parent);
klass = pygobject_lookup_class (type);
pygobject_register_class (gladeui_dict, g_type_name (type), type, klass,
Py_BuildValue("(O)", parent_class));
pyg_set_object_has_new_constructor (type);
g_hash_table_insert (registered_classes, GUINT_TO_POINTER (type), klass);
return klass;
}
static PyObject *
glade_python_get_adaptor_for_type (PyObject *self, PyObject *args)
{
GladeWidgetAdaptor *adaptor;
PyObject *klass;
gchar *name;
if (PyArg_ParseTuple(args, "s", &name) &&
(adaptor = glade_widget_adaptor_get_by_name (name)))
{
GType type = G_TYPE_FROM_INSTANCE (adaptor);
if ((klass = g_hash_table_lookup (registered_classes, GUINT_TO_POINTER (type))))
return (PyObject *) klass;
else
return (PyObject *) glade_python_register_class (type);
}
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef GladeuiMethods[] = {
{"get_adaptor_for_type", glade_python_get_adaptor_for_type, METH_VARARGS, "Get the corresponding GladeWidgetAdaptor. Use this function to create your own derived Adaptor."},
{NULL, NULL, 0, NULL}
};
/* Bindings */
void
glade_python_binding_finalize (GladeBindingCtrl *ctrl)
{
if (Py_IsInitialized ())
{
while (PyGC_Collect ())
;
Py_Finalize ();
}
}
void
glade_python_binding_library_load (const gchar *library)
{
gchar *str = g_strdup_printf ("import %s;", library);
PyRun_SimpleString (str);
g_free (str);
}
/*
Generated by pygtk-codegen-2.0
pygtk-codegen-2.0 -p glade_python_gwa -o glade-python-gwa.override glade-python-gwa.defs > glade-python-gwa.c
*/
void glade_python_gwa_register_classes (PyObject *d);
static void
glade_python_init (void)
{
char *argv[2] = {"", NULL};
Py_InitializeEx (0);
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)
{
gchar *command;
Py_SetProgramName (PACKAGE_NAME);
/* Initialize the Python interpreter */
glade_python_init ();
/* Check and init pygobject >= 2.12.0 */
PyErr_Clear ();
glade_python_init_pygtk_check (PYGTK_REQUIRED_MAJOR, PYGTK_REQUIRED_MINOR, PYGTK_REQUIRED_MICRO);
if (PyErr_Occurred ())
{
PyObject *ptype, *pvalue, *ptraceback;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
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)\n%s",
PYGTK_REQUIRED_MAJOR, PYGTK_REQUIRED_MINOR, PYGTK_REQUIRED_MICRO,
PyString_AsString (pvalue));
PyErr_Clear ();
Py_Finalize ();
return FALSE;
}
pyg_disable_warning_redirections ();
/* Create glade object */
gladeui = Py_InitModule ("glade", GladeuiMethods);
GladeuiError = PyErr_NewException ("glade.error", NULL, NULL);
Py_INCREF (GladeuiError);
PyModule_AddObject (gladeui, "error", GladeuiError);
/* Register GladeUI classes (GladeWidgetAdaptor) */
gladeui_dict = PyModule_GetDict (gladeui);
glade_python_gwa_register_classes (gladeui_dict);
/* Create registered_classes hash table */
registered_classes = g_hash_table_new (g_direct_hash, g_direct_equal);
/* Insert GladeWidgetAdaptor class in the hash table */
g_hash_table_insert (registered_classes,
GUINT_TO_POINTER (GLADE_TYPE_WIDGET_ADAPTOR),
&PyGladeWidgetAdaptor_Type);
/* Import glade module and set path */
command = g_strdup_printf ("import sys; import glade; sys.path+=['.', '%s'];\n",
glade_app_get_modules_dir ());
PyRun_SimpleString (command);
g_free (command);
/* Setup ctrl members */
ctrl->name = "python";
ctrl->finalize = glade_python_binding_finalize;
ctrl->library_load = glade_python_binding_library_load;
return TRUE;
}
......@@ -151,116 +151,6 @@ AM_CONDITIONAL(BUILD_GNOME, test x"$have_gnome" = "xyes")
GNOME_DOC_INIT([0.9.0],[],[:])
dnl ================================================================
dnl Python
dnl ================================================================
AC_MSG_CHECKING([whether Python support is requested])
AC_ARG_ENABLE([python],
AS_HELP_STRING([--enable-python],[Enable python support]),
[enable_python=$enableval have_python=$enableval],
[enable_python=autodetect have_python=no])
AC_MSG_RESULT([$enable_python])
if test "x$have_python" != "xno"; then
AM_PATH_PYTHON([2.3],[],[no])
if test "x$PYTHON" = "x:"; then
have_python=no
fi
fi
if test "x$have_python" != "xno"; then
AM_CHECK_PYTHON_HEADERS([],[have_python=no])
fi
if test "x$have_python" != "xno"; then
PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'`
PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'`
PYTHON_LIBS="-lpython$PYTHON_VERSION"
PYTHON_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config"
PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION"
PYTHON_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config/Makefile"
PYTHON_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
PYTHON_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
PYTHON_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
PYTHON_EXTRA_LIBS="$PYTHON_LOCALMODLIBS $PYTHON_BASEMODLIBS $PYTHON_OTHER_LIBS"
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_LIB_LOC])
AC_SUBST([PYTHON_CFLAGS])
AC_SUBST([PYTHON_EXTRA_LIBS])
fi
if test "x$have_python" != "xno"; then
PYGTK_REQUIRED_MAJOR=2
PYGTK_REQUIRED_MINOR=10
PYGTK_REQUIRED_MICRO=0
PYGOBJECT_REQUIRED_MAJOR=2
PYGOBJECT_REQUIRED_MINOR=12
PYGOBJECT_REQUIRED_MICRO=0
PYGOBJECT_REQUIRED=$PYGOBJECT_REQUIRED_MAJOR.$PYGOBJECT_REQUIRED_MINOR.$PYGOBJECT_REQUIRED_MICRO
PYGTK_REQUIRED=$PYGTK_REQUIRED_MAJOR.$PYGTK_REQUIRED_MINOR.$PYGTK_REQUIRED_MICRO
PKG_CHECK_MODULES([PYGTK], [
pygobject-2.0 >= $PYGOBJECT_REQUIRED
pygtk-2.0 >= $PYGTK_REQUIRED],
[],[have_python=no])
AC_SUBST([PYGTK_CFLAGS])
AC_SUBST([PYGTK_LIBS])
AC_DEFINE_UNQUOTED(PYGTK_REQUIRED_MAJOR, $PYGTK_REQUIRED_MAJOR, Pygtk mayor version required)
AC_DEFINE_UNQUOTED(PYGTK_REQUIRED_MINOR, $PYGTK_REQUIRED_MINOR, Pygtk minor version required)
AC_DEFINE_UNQUOTED(PYGTK_REQUIRED_MICRO, $PYGTK_REQUIRED_MICRO, Pygtk micro version required)
fi
if test "x$have_python" != "xno"; then
AC_MSG_CHECKING([for pygtk defs])
PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
AC_MSG_RESULT([$PYGTK_DEFSDIR])
AC_MSG_CHECKING([for pygtk codegen])
PYGTK_CODEGEN="$PYTHON `$PKG_CONFIG --variable=codegendir pygtk-2.0`/codegen.py"
AC_MSG_RESULT([$PYGTK_CODEGEN])
AC_MSG_CHECKING([for pygtk h2def])
PYGTK_H2DEF="$PYTHON `$PKG_CONFIG --variable=codegendir pygtk-2.0`/h2def.py"
AC_MSG_RESULT([$PYGTK_H2DEF])
AC_SUBST([PYGTK_DEFSDIR])
AC_SUBST([PYGTK_CODEGEN])
AC_SUBST([PYGTK_H2DEF])
dnl Check for -fno-strict-aliasing
FLAGS="-fno-strict-aliasing"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $FLAGS"
AC_MSG_CHECKING([whether [$]CC understands $FLAGS])
AC_TRY_COMPILE([], [], [compiler_has_option=yes], [compiler_has_option=no])
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($compiler_has_option)
if test $compiler_has_option = yes; then
NO_STRICT_ALIASING_CFLAGS="$FLAGS"
fi
AC_SUBST([NO_STRICT_ALIASING_CFLAGS])
fi
if test "x$have_python" != "xyes"; then
if test "x$enable_python" = "xyes"; then
AC_MSG_ERROR([Python not found])
elif test "x$enable_python" = "xautodetect"; then
enable_python=no
AC_MSG_WARN([Python not found, disabling python support])
fi
elif test "x$enable_python" != "xno"; then
enable_python=yes
AC_DEFINE([ENABLE_PYTHON],[1],[Define to compile with python support])
fi
AM_CONDITIONAL([ENABLE_PYTHON],[test "x$enable_python" = "xyes"])
dnl ================================================================
dnl Check for windows
dnl ================================================================
......@@ -328,8 +218,6 @@ plugins/gnome/Makefile
plugins/gnome/icons/Makefile
plugins/gnome/icons/16x16/Makefile
plugins/gnome/icons/22x22/Makefile
bindings/Makefile
bindings/python/Makefile
po/Makefile.in
doc/Makefile
doc/version.xml
......
......@@ -6,7 +6,6 @@ common_defines = \
-DGLADE_CATALOGSDIR="\"$(pkgdatadir)/catalogs\""\
-DGLADE_MODULESDIR="\"$(pkglibdir)/modules\"" \
-DGLADE_PLUGINSDIR="\"$(pkglibdir)/plugins\"" \
-DGLADE_BINDINGSDIR="\"$(pkglibdir)/bindings\"" \
-DGLADE_PIXMAPSDIR="\"$(pkgdatadir)/pixmaps\"" \
-DGLADE_LOCALEDIR="\"$(datadir)/locale\""
......@@ -55,7 +54,6 @@ libgladeui_1_la_SOURCES = \
glade-app.c \
glade-keysyms.c \
glade-fixed.c \
glade-binding.c \
glade-base-editor.c \
glade-palette-item.h \
glade-palette-box.h \
......@@ -108,7 +106,6 @@ libgladeuiinclude_HEADERS = \
glade-app.h \
glade-builtins.h \
glade-fixed.h \
glade-binding.h \
glade-base-editor.h \
glade-xml-utils.h \
glade-parser.h \
......
......@@ -28,7 +28,6 @@
#include "glade-cursor.h"
#include "glade-catalog.h"
#include "glade-fixed.h"
#include "glade-binding.h"
#include "glade-marshallers.h"
#include "glade-accumulators.h"
......@@ -87,7 +86,6 @@ static guint glade_app_signals[LAST_SIGNAL] = { 0 };
/* installation paths */
static gchar *catalogs_dir = NULL;
static gchar *modules_dir = NULL;
static gchar *bindings_dir = NULL;
static gchar *plugins_dir = NULL;
static gchar *pixmaps_dir = NULL;
static gchar *locale_dir = NULL;
......@@ -184,11 +182,9 @@ glade_app_finalize (GObject *app)
{
g_free (catalogs_dir);
g_free (modules_dir);
g_free (bindings_dir);
g_free (pixmaps_dir);
g_free (locale_dir);
glade_binding_unload_all ();
glade_catalog_destroy_all ();
G_OBJECT_CLASS (glade_app_parent_class)->finalize (app);
......@@ -374,14 +370,6 @@ glade_app_get_locale_dir (void)
return locale_dir;
}
const gchar *
glade_app_get_bindings_dir (void)
{
glade_init_check ();
return bindings_dir;
}
/* build package paths at runtime */
static void
build_package_paths (void)
......@@ -393,13 +381,11 @@ build_package_paths (void)
pixmaps_dir = g_build_filename (prefix, "share", PACKAGE, "pixmaps", NULL);
catalogs_dir = g_build_filename (prefix, "share", PACKAGE, "catalogs", NULL);
modules_dir = g_build_filename (prefix, "lib", PACKAGE, "modules", NULL);
bindings_dir = g_build_filename (prefix, "lib", PACKAGE, "bindings", NULL);
locale_dir = g_build_filename (prefix, "share", "locale", NULL);