diff --git a/autogen.sh b/autogen.sh index 6769318..56ea79f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -24,7 +24,6 @@ which yelp-build || { } REQUIRED_AUTOMAKE_VERSION=1.9 -REQUIRED_MACROS=python.m4 GNOME_DATADIR="$gnome_datadir" USE_COMMON_DOC_BUILD=yes diff --git a/configure.ac b/configure.ac index e37126a..3d6e7e2 100644 --- a/configure.ac +++ b/configure.ac @@ -178,123 +178,6 @@ dnl ================================================================ GLIB_GSETTINGS -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=yes]) -AC_MSG_RESULT([$enable_python]) - -if test "x$have_python" != "xno"; then - AM_PATH_PYTHON([2.5],[],[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_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'` - PYTHON_LIBS="-lpython$PYTHON_VERSION" - - PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'` - PYTHON_LIB_LOC="-L$libdir/python$PYTHON_VERSION/config" - PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION" - PYTHON_MAKEFILE="$libdir/python$PYTHON_VERSION/config/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_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" != "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 -fi - -if test "x$have_python" != "xno"; then - PYGOBJECT_REQUIRED=2.15.4 - PYGTK_REQUIRED=2.12.0 - PYGTKSOURCEVIEW_REQUIRED=2.9.2 - - PKG_CHECK_MODULES([PYGTK], [ - pygobject-2.0 >= $PYGOBJECT_REQUIRED - pygtk-2.0 >= $PYGTK_REQUIRED - pygtksourceview-2.0 >= $PYGTKSOURCEVIEW_REQUIRED], - [], - [ - have_python=no - if test "x$enable_python" = "xyes"; then - AC_MSG_ERROR([$PYGTK_PKG_ERRORS]) - elif test "x$enable_python" = "xautodetect"; then - enable_python=no - AC_MSG_WARN([$PYGTK_PKG_ERRORS]) - AC_MSG_WARN([Disabling python support]) - fi - ]) -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 pygobject defs]) - PYGOBJECT_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygobject-2.0` - AC_MSG_RESULT([$PYGOBJECT_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([PYGOBJECT_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_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[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" != "xno" -a "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 This allows the bug-report script to know whether python has been enabled -AC_SUBST(enable_python) - dnl ================================================================ dnl Misc dnl ================================================================ @@ -355,8 +238,6 @@ help/Makefile pixmaps/Makefile plugin-loaders/Makefile plugin-loaders/c/Makefile -plugin-loaders/python/Makefile -plugin-loaders/python/bindings/Makefile plugins/Makefile plugins/changecase/Makefile plugins/docinfo/Makefile @@ -381,9 +262,8 @@ echo " Configuration: Source code location: ${srcdir} - Compiler: ${CC} - Python Plugins Support: $enable_python + Compiler: ${CC} Spell Plugin enabled: $enable_enchant Gvfs metadata enabled: $enable_gvfs_metadata - Tests enabled: $enable_tests + Tests enabled: $enable_tests " diff --git a/data/xed-bugreport.sh.in b/data/xed-bugreport.sh.in index fcaed9f..01ae2cc 100644 --- a/data/xed-bugreport.sh.in +++ b/data/xed-bugreport.sh.in @@ -1,10 +1,7 @@ #!/bin/sh -ENABLE_PYTHON=@enable_python@ - PKG_CONFIG_MODULES="glib-2.0 gtk+-2.0 gtksourceview-2.0 \ - pygobject-2.0 pygtk-2.0 \ - pygtksourceview-2.0 enchant iso-codes" + enchant iso-codes" echo_padded () { @@ -53,21 +50,3 @@ else echo " pkg-config unavailable" fi echo - -echo "Python module versions:" -if test "$ENABLE_PYTHON" = "yes" -then - echo_padded "python" - python -V 2>&1 | cut -c8- - - echo_padded "pygtk" - python -c "import gtk, sys; \ - sys.stdout.write('%d.%d.%d ' % gtk.pygtk_version); \ - sys.stdout.write('(GTK+ %d.%d.%d)' % gtk.gtk_version)" \ - 2>/dev/null - echo -else - echo " Python support was not enabled at compile time." -fi -echo - diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index e153873..a890721 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -20,7 +20,7 @@ DOC_SOURCE_DIR=../../xed SCANGOBJ_OPTIONS= # Extra options to supply to gtkdoc-scan. -# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" +# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" SCAN_OPTIONS= # Extra options to supply to gtkdoc-mkdb. @@ -96,16 +96,6 @@ GTKDOC_LIBS= \ $(top_builddir)/xed/libxed.la \ $(XED_LIBS) -if ENABLE_PYTHON -GTKDOC_CFLAGS += \ - $(NO_STRICT_ALIASING_CFLAGS) \ - $(PYGTK_CFLAGS) \ - $(PYTHON_CFLAGS) \ - $(AM_CFLAGS) -GTKDOC_LIBS += \ - $(top_builddir)/plugin-loaders/python/bindings/xed.la -endif - # This includes the standard gtk-doc make rules, copied by gtkdocize. include $(top_srcdir)/gtk-doc.make diff --git a/m4/python.m4 b/m4/python.m4 deleted file mode 100644 index e1c5266..0000000 --- a/m4/python.m4 +++ /dev/null @@ -1,62 +0,0 @@ -## this one is commonly used with AM_PATH_PYTHONDIR ... -dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) -dnl Check if a module containing a given symbol is visible to python. -AC_DEFUN([AM_CHECK_PYMOD], -[AC_REQUIRE([AM_PATH_PYTHON]) -py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` -AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1) -AC_CACHE_VAL(py_cv_mod_$py_mod_var, [ -ifelse([$2],[], [prog=" -import sys -try: - import $1 -except ImportError: - sys.exit(1) -except: - sys.exit(0) -sys.exit(0)"], [prog=" -import $1 -$1.$2"]) -if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC - then - eval "py_cv_mod_$py_mod_var=yes" - else - eval "py_cv_mod_$py_mod_var=no" - fi -]) -py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"` -if test "x$py_val" != xno; then - AC_MSG_RESULT(yes) - ifelse([$3], [],, [$3 -])dnl -else - AC_MSG_RESULT(no) - ifelse([$4], [],, [$4 -])dnl -fi -]) - -dnl a macro to check for ability to create python extensions -dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) -dnl function also defines PYTHON_INCLUDES -AC_DEFUN([AM_CHECK_PYTHON_HEADERS], -[AC_REQUIRE([AM_PATH_PYTHON]) -AC_MSG_CHECKING(for headers required to compile python extensions) -dnl deduce PYTHON_INCLUDES -py_prefix=`$PYTHON -c "import sys; print sys.prefix"` -py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` -PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" -if test "$py_prefix" != "$py_exec_prefix"; then - PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" -fi -AC_SUBST(PYTHON_INCLUDES) -dnl check if the headers exist: -save_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" -AC_TRY_CPP([#include ],dnl -[AC_MSG_RESULT(found) -$1],dnl -[AC_MSG_RESULT(not found) -$2]) -CPPFLAGS="$save_CPPFLAGS" -]) diff --git a/plugin-loaders/Makefile.am b/plugin-loaders/Makefile.am index bf1e964..2573ec3 100644 --- a/plugin-loaders/Makefile.am +++ b/plugin-loaders/Makefile.am @@ -1,7 +1,3 @@ SUBDIRS = c -if ENABLE_PYTHON -SUBDIRS += python -endif - -include $(top_srcdir)/git.mk diff --git a/plugin-loaders/python/Makefile.am b/plugin-loaders/python/Makefile.am deleted file mode 100644 index ef9acc2..0000000 --- a/plugin-loaders/python/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -# C plugin loader - -SUBDIRS = bindings -loaderdir = $(libdir)/xed/plugin-loaders - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/xed \ - -I$(top_builddir)/xed \ - $(XED_CFLAGS) \ - $(WARN_CFLAGS) \ - $(DISABLE_DEPRECATED_CFLAGS) \ - $(PYGTK_CFLAGS) \ - $(PYTHON_CFLAGS) \ - -DXED_PLUGINS_LIBS_DIR=\"$(XED_PLUGINS_LIBS_DIR)\" \ - -DXED_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" - -loader_LTLIBRARIES = libpythonloader.la - - -NOINST_H_FILES = \ - xed-plugin-loader-python.h \ - xed-plugin-python.h - -libpythonloader_la_SOURCES = \ - xed-plugin-loader-python.c \ - xed-plugin-python.c \ - $(NOINST_H_FILES) - -libpythonloader_la_LDFLAGS = $(LOADER_LIBTOOL_FLAGS) -libpythonloader_la_LIBADD = \ - $(XED_LIBS) \ - bindings/xed.la - --include $(top_srcdir)/git.mk diff --git a/plugin-loaders/python/bindings/Makefile.am b/plugin-loaders/python/bindings/Makefile.am deleted file mode 100644 index efcbf17..0000000 --- a/plugin-loaders/python/bindings/Makefile.am +++ /dev/null @@ -1,115 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_LTLIBRARIES = \ - xed.la - -nodist_xed_la_SOURCES = \ - xed.c \ - xedutils.c \ - xedcommands.c - -xed_la_LDFLAGS = \ - -module -avoid-version - -xed_la_LIBADD = \ - $(PYTHON_LIB_LOC) \ - $(PYTHON_LIBS) \ - $(PYTHON_EXTRA_LIBS) \ - $(PYGTK_LIBS) - -xed_la_CFLAGS = \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/xed \ - -I$(top_builddir)/xed \ - -I$(top_srcdir)/plugin-loaders/python \ - -I$(top_builddir)/plugin-loaders/python \ - $(XED_CFLAGS) \ - $(NO_STRICT_ALIASING_CFLAGS) \ - $(PYGTK_CFLAGS) \ - $(PYTHON_CFLAGS) \ - $(AM_CFLAGS) - -$(top_builddir)/xed/xed-enum-types.h: - cd $(top_builddir)/xed && $(MAKE) xed-enum-types.h - -xed.c: xed.defs xed.override xedplugin.override xedmessage.override $(top_builddir)/xed/xed-enum-types.h - ( cd $(srcdir) && $(PYGTK_CODEGEN) \ - --register $(PYGTK_DEFSDIR)/pango-types.defs \ - --register $(PYGTK_DEFSDIR)/gdk-types.defs \ - --register $(PYGTK_DEFSDIR)/gtk-types.defs \ - --register $(PYGTK_DEFSDIR)/gtksourceview2.defs \ - --register $(PYGOBJECT_DEFSDIR)/gio-types.defs \ - --override $*.override \ - --prefix py$* $( $@ - -xedutils.c: xedutils.defs xedutils.override - ( cd $(srcdir) && $(PYGTK_CODEGEN) \ - --override $*.override \ - --prefix py$* $( $@ - -xedcommands.c: xedcommands.defs xedcommands.override xed.defs - ( cd $(srcdir) && $(PYGTK_CODEGEN) \ - --register xed.defs \ - --register $(PYGTK_DEFSDIR)/gtk-types.defs \ - --override $*.override \ - --prefix py$* $( $@ - -BINDING_XED_HEADERS_SRCDIR_IN = \ - xed/xed-app.h \ - xed/xed-document.h \ - xed/xed-encodings.h \ - xed/xed-plugin.h \ - plugin-loaders/python/xed-plugin-python.h \ - xed/xed-view.h \ - xed/xed-statusbar.h \ - xed/xed-tab.h \ - xed/xed-panel.h \ - xed/xed-window.h \ - xed/xed-help.h \ - xed/xed-debug.h \ - xed/xed-message-type.h \ - xed/xed-message.h \ - xed/xed-message-bus.h \ - xed/xed-language-manager.h - -BINDING_UTILS_HEADERS_SRCDIR_IN = \ - xed/xed-utils.h - -BINDING_COMMANDS_HEADERS_SRCDIR_IN = \ - xed/xed-commands.h - -BINDING_HEADERS_BUILDDIR_IN = - -BINDING_XED_HEADERS_SRCDIR := $(addprefix $(top_srcdir)/,$(BINDING_XED_HEADERS_SRCDIR_IN)) -BINDING_UTILS_HEADERS_SRCDIR := $(addprefix $(top_srcdir)/,$(BINDING_UTILS_HEADERS_SRCDIR_IN)) -BINDING_COMMANDS_HEADERS_SRCDIR := $(addprefix $(top_srcdir)/,$(BINDING_COMMANDS_HEADERS_SRCDIR_IN)) - -BINDING_HEADERS_BUILDDIR := $(addprefix $(top_builddir)/,$(BINDING_HEADERS_BUILDDIR_IN)) - -regenerate-python-binding: - $(PYGTK_H2DEF) $(sort $(BINDING_XED_HEADERS_SRCDIR) $(BINDING_HEADERS_BUILDDIR)) > xed.defs.new - $(PYGTK_H2DEF) $(sort $(BINDING_UTILS_HEADERS_SRCDIR) $(BINDING_HEADERS_BUILDDIR)) > xedutils.defs.new - $(PYGTK_H2DEF) $(sort $(BINDING_COMMANDS_HEADERS_SRCDIR) $(BINDING_HEADERS_BUILDDIR)) > xedcommands.defs.new - -BUILT_SOURCES = \ - xed.c \ - xedutils.c \ - xedcommands.c - -EXTRA_DIST = \ - xed.override \ - xed.defs \ - xedutils.override \ - xedutils.defs \ - xedcommands.override \ - xedcommands.defs \ - xedmessage.override \ - xedplugin.override - -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - --include $(top_srcdir)/git.mk diff --git a/plugin-loaders/python/bindings/xed.defs b/plugin-loaders/python/bindings/xed.defs deleted file mode 100644 index 75af263..0000000 --- a/plugin-loaders/python/bindings/xed.defs +++ /dev/null @@ -1,1442 +0,0 @@ -;; -*- scheme -*- -; object definitions ... -(define-object App - (in-module "Xed") - (parent "GObject") - (c-name "XedApp") - (gtype-id "XED_TYPE_APP") -) - -(define-object Document - (in-module "Xed") - (parent "GtkSourceBuffer") - (c-name "XedDocument") - (gtype-id "XED_TYPE_DOCUMENT") -) - -(define-object Message - (in-module "Xed") - (parent "GObject") - (c-name "XedMessage") - (gtype-id "XED_TYPE_MESSAGE") -) - -(define-object MessageBus - (in-module "Xed") - (parent "GObject") - (c-name "XedMessageBus") - (gtype-id "XED_TYPE_MESSAGE_BUS") -) - -(define-object Panel - (in-module "Xed") - (parent "GtkVBox") - (c-name "XedPanel") - (gtype-id "XED_TYPE_PANEL") -) - -(define-object __Plugin - (in-module "Xed") - (parent "GObject") - (c-name "XedPlugin") - (gtype-id "XED_TYPE_PLUGIN") -) - -(define-object Plugin - (in-module "Xed") - (parent "XedPlugin") - (c-name "XedPluginPython") - (gtype-id "XED_TYPE_PLUGIN_PYTHON") -) - -(define-object Statusbar - (in-module "Xed") - (parent "GtkStatusbar") - (c-name "XedStatusbar") - (gtype-id "XED_TYPE_STATUSBAR") -) - -(define-object Tab - (in-module "Xed") - (parent "GtkVBox") - (c-name "XedTab") - (gtype-id "XED_TYPE_TAB") -) - -(define-object View - (in-module "Xed") - (parent "GtkSourceView") - (c-name "XedView") - (gtype-id "XED_TYPE_VIEW") -) - -(define-object Window - (in-module "Xed") - (parent "GtkWindow") - (c-name "XedWindow") - (gtype-id "XED_TYPE_WINDOW") -) - -;; Enumerations and flags ... - -(define-flags SearchFlags - (in-module "Xed") - (c-name "XedSearchFlags") - (gtype-id "XED_TYPE_SEARCH_FLAGS") - (values - '("dont-set-flags" "XED_SEARCH_DONT_SET_FLAGS") - '("entire-word" "XED_SEARCH_ENTIRE_WORD") - '("case-sensitive" "XED_SEARCH_CASE_SENSITIVE") - ) -) - -(define-flags DocumentSaveFlags - (in-module "Xed") - (c-name "XedDocumentSaveFlags") - (gtype-id "XED_TYPE_DOCUMENT_SAVE_FLAGS") - (values - '("ignore-mtime" "XED_DOCUMENT_SAVE_IGNORE_MTIME") - '("ignore-backup" "XED_DOCUMENT_SAVE_IGNORE_BACKUP") - '("preserve-backup" "XED_DOCUMENT_SAVE_PRESERVE_BACKUP") - ) -) - -(define-enum TabState - (in-module "Xed") - (c-name "XedTabState") - (gtype-id "XED_TYPE_TAB_STATE") - (values - '("normal" "XED_TAB_STATE_NORMAL") - '("loading" "XED_TAB_STATE_LOADING") - '("reverting" "XED_TAB_STATE_REVERTING") - '("saving" "XED_TAB_STATE_SAVING") - '("printing" "XED_TAB_STATE_PRINTING") - '("print-previewing" "XED_TAB_STATE_PRINT_PREVIEWING") - '("showing-print-preview" "XED_TAB_STATE_SHOWING_PRINT_PREVIEW") - '("generic-not-editable" "XED_TAB_STATE_GENERIC_NOT_EDITABLE") - '("loading-error" "XED_TAB_STATE_LOADING_ERROR") - '("reverting-error" "XED_TAB_STATE_REVERTING_ERROR") - '("saving-error" "XED_TAB_STATE_SAVING_ERROR") - '("generic-error" "XED_TAB_STATE_GENERIC_ERROR") - '("closing" "XED_TAB_STATE_CLOSING") - ) -) - -(define-flags WindowState - (in-module "Xed") - (c-name "XedWindowState") - (gtype-id "XED_TYPE_WINDOW_STATE") - (values - '("normal" "XED_WINDOW_STATE_NORMAL") - '("saving" "XED_WINDOW_STATE_SAVING") - '("printing" "XED_WINDOW_STATE_PRINTING") - '("loading" "XED_WINDOW_STATE_LOADING") - '("error" "XED_WINDOW_STATE_ERROR") - '("saving-session" "XED_WINDOW_STATE_SAVING_SESSION") - ) -) - -;; Boxed types -(define-boxed Encoding - (in-module "Xed") - (c-name "XedEncoding") - (gtype-id "XED_TYPE_ENCODING") - (copy-func "xed_encoding_copy") - (release-func "xed_encoding_free") -;; (fields -;; '("gint" "index") -;; '("gchar*" "charset") -;; '("gchar*" "name") -;; ) -) - -(define-boxed MessageType - (in-module "Xed") - (c-name "XedMessageType") - (gtype-id "XED_TYPE_MESSAGE_TYPE") - (copy-func "xed_message_type_ref") - (release-func "xed_message_type_unref") -) - - -;; From ../../xed/xed-app.h - -(define-function xed_app_get_type - (c-name "xed_app_get_type") - (return-type "GType") -) - -(define-function app_get_default - (c-name "xed_app_get_default") - (return-type "XedApp*") -) - -; deprecated version ! -(define-function xed_app_get_default - (c-name "xed_app_get_default_deprecated") - (return-type "XedApp*") -) - -(define-method create_window - (of-object "XedApp") - (c-name "xed_app_create_window") - (return-type "XedWindow*") - (parameters - '("GdkScreen*" "screen") - ) -) - -(define-method get_windows - (of-object "XedApp") - (c-name "xed_app_get_windows") - (return-type "const-GList*") -) - -(define-method get_active_window - (of-object "XedApp") - (c-name "xed_app_get_active_window") - (return-type "XedWindow*") -) - -(define-method get_documents - (of-object "XedApp") - (c-name "xed_app_get_documents") - (return-type "GList*") -) - -(define-method get_views - (of-object "XedApp") - (c-name "xed_app_get_views") - (return-type "GList*") -) - - -;; From ../../xed/xed-document.h - -(define-function document_error_quark - (c-name "xed_document_error_quark") - (return-type "GQuark") -) - -(define-function xed_document_get_type - (c-name "xed_document_get_type") - (return-type "GType") -) - -(define-function xed_document_new - (c-name "xed_document_new") - (is-constructor-of "XedDocument") - (return-type "XedDocument*") -) - -(define-method get_location - (of-object "XedDocument") - (c-name "xed_document_get_location") - (return-type "GFile*") -) - -(define-method get_uri - (of-object "XedDocument") - (c-name "xed_document_get_uri") - (return-type "gchar*") -) - -(define-method set_uri - (of-object "XedDocument") - (c-name "xed_document_set_uri") - (return-type "none") - (parameters - '("const-gchar*" "uri") - ) -) - -(define-method get_uri_for_display - (of-object "XedDocument") - (c-name "xed_document_get_uri_for_display") - (return-type "gchar*") -) - -(define-method get_short_name_for_display - (of-object "XedDocument") - (c-name "xed_document_get_short_name_for_display") - (return-type "gchar*") -) - -(define-method get_content_type - (of-object "XedDocument") - (c-name "xed_document_get_content_type") - (return-type "gchar*") -) - -(define-method get_mime_type - (of-object "XedDocument") - (c-name "xed_document_get_mime_type") - (return-type "gchar*") -) - -(define-method get_readonly - (of-object "XedDocument") - (c-name "xed_document_get_readonly") - (return-type "gboolean") -) - -(define-method load - (of-object "XedDocument") - (c-name "xed_document_load") - (return-type "none") - (parameters - '("const-gchar*" "uri") - '("const-XedEncoding*" "encoding") - '("gint" "line_pos") - '("gboolean" "create") - ) -) - -(define-method insert_file - (of-object "XedDocument") - (c-name "xed_document_insert_file") - (return-type "gboolean") - (parameters - '("GtkTextIter*" "iter") - '("const-gchar*" "uri") - '("const-XedEncoding*" "encoding") - ) -) - -(define-method load_cancel - (of-object "XedDocument") - (c-name "xed_document_load_cancel") - (return-type "gboolean") -) - -(define-method save - (of-object "XedDocument") - (c-name "xed_document_save") - (parameters - '("XedDocumentSaveFlags" "flags") - ) - (return-type "none") -) - -(define-method save_as - (of-object "XedDocument") - (c-name "xed_document_save_as") - (return-type "none") - (parameters - '("const-gchar*" "uri") - '("const-XedEncoding*" "encoding") - '("XedDocumentSaveFlags" "flags") - ) -) - -(define-method is_untouched - (of-object "XedDocument") - (c-name "xed_document_is_untouched") - (return-type "gboolean") -) - -(define-method is_untitled - (of-object "XedDocument") - (c-name "xed_document_is_untitled") - (return-type "gboolean") -) - -(define-method is_local - (of-object "XedDocument") - (c-name "xed_document_is_local") - (return-type "gboolean") -) - -(define-method get_deleted - (of-object "XedDocument") - (c-name "xed_document_get_deleted") - (return-type "gboolean") -) - -(define-method goto_line - (of-object "XedDocument") - (c-name "xed_document_goto_line") - (return-type "gboolean") - (parameters - '("gint" "line") - ) -) - -(define-method set_search_text - (of-object "XedDocument") - (c-name "xed_document_set_search_text") - (return-type "none") - (parameters - '("const-gchar*" "text") - '("guint" "flags") - ) -) - -(define-method get_search_text - (of-object "XedDocument") - (c-name "xed_document_get_search_text") - (return-type "gchar*") - (parameters - '("guint*" "flags") - ) -) - -(define-method get_can_search_again - (of-object "XedDocument") - (c-name "xed_document_get_can_search_again") - (return-type "gboolean") -) - -(define-method search_forward - (of-object "XedDocument") - (c-name "xed_document_search_forward") - (return-type "gboolean") - (parameters - '("const-GtkTextIter*" "start") - '("const-GtkTextIter*" "end") - '("GtkTextIter*" "match_start") - '("GtkTextIter*" "match_end") - ) -) - -(define-method replace_all - (of-object "XedDocument") - (c-name "xed_document_replace_all") - (return-type "gint") - (parameters - '("const-gchar*" "find") - '("const-gchar*" "replace") - '("guint" "flags") - ) -) - -(define-method search_backward - (of-object "XedDocument") - (c-name "xed_document_search_backward") - (return-type "gboolean") - (parameters - '("const-GtkTextIter*" "start") - '("const-GtkTextIter*" "end") - '("GtkTextIter*" "match_start") - '("GtkTextIter*" "match_end") - ) -) - -(define-method set_language - (of-object "XedDocument") - (c-name "xed_document_set_language") - (return-type "none") - (parameters - '("GtkSourceLanguage*" "lang" (null-ok)) - ) -) - -(define-method get_language - (of-object "XedDocument") - (c-name "xed_document_get_language") - (return-type "GtkSourceLanguage*") -) - -(define-method get_encoding - (of-object "XedDocument") - (c-name "xed_document_get_encoding") - (return-type "const-XedEncoding*") -) - -(define-method set_enable_search_highlighting - (of-object "XedDocument") - (c-name "xed_document_set_enable_search_highlighting") - (return-type "none") - (parameters - '("gboolean" "enable") - ) -) - -(define-method get_enable_search_highlighting - (of-object "XedDocument") - (c-name "xed_document_get_enable_search_highlighting") - (return-type "gboolean") -) - -;; From ../../xed/xed-encodings.h - -(define-function xed_encoding_get_type - (c-name "xed_encoding_get_type") - (return-type "GType") -) - -(define-method copy - (of-object "XedEncoding") - (c-name "xed_encoding_copy") - (return-type "XedEncoding*") -) - -(define-method free - (of-object "XedEncoding") - (c-name "xed_encoding_free") - (return-type "none") -) - -(define-function encoding_get_from_charset - (c-name "xed_encoding_get_from_charset") - (return-type "const-XedEncoding*") - (parameters - '("const-gchar*" "charset") - ) -) - -; Deprecated version ! -(define-function xed_encoding_get_from_charset - (c-name "xed_encoding_get_from_charset_deprecated") - (return-type "const-XedEncoding*") - (parameters - '("const-gchar*" "charset") - ) -) - -(define-function encoding_get_from_index - (c-name "xed_encoding_get_from_index") - (return-type "const-XedEncoding*") - (parameters - '("gint" "index") - ) -) - -; Deprecated version ! -(define-function xed_encoding_get_from_index - (c-name "xed_encoding_get_from_index_deprecated") - (return-type "const-XedEncoding*") - (parameters - '("gint" "index") - ) -) - -(define-method to_string - (of-object "XedEncoding") - (c-name "xed_encoding_to_string") - (return-type "gchar*") -) - -(define-method get_name - (of-object "XedEncoding") - (c-name "xed_encoding_get_name") - (return-type "const-gchar*") -) - -(define-method get_charset - (of-object "XedEncoding") - (c-name "xed_encoding_get_charset") - (return-type "const-gchar*") -) - -(define-function encoding_get_utf8 - (c-name "xed_encoding_get_utf8") - (return-type "const-XedEncoding*") -) - -; Deprecated version ! -(define-function xed_encoding_get_utf8 - (c-name "xed_encoding_get_utf8_deprecated") - (return-type "const-XedEncoding*") -) - -(define-function encoding_get_current - (c-name "xed_encoding_get_current") - (return-type "const-XedEncoding*") -) - -; Deprecated version ! -(define-function xed_encoding_get_current - (c-name "xed_encoding_get_current_deprecated") - (return-type "const-XedEncoding*") -) - -;; From ../../xed/xed-help.h - -(define-function help_display - (c-name "xed_help_display") - (return-type "gboolean") - (parameters - '("GtkWindow*" "parent") - '("const-gchar*" "name") - '("const-gchar*" "link_id") - ) -) - - - -;; From ../../xed/xed-panel.h - -(define-function xed_panel_get_type - (c-name "xed_panel_get_type") - (return-type "GType") -) - -(define-function xed_panel_new - (c-name "xed_panel_new") - (is-constructor-of "XedPanel") - (return-type "GtkWidget*") -) - -(define-method add_item - (of-object "XedPanel") - (c-name "xed_panel_add_item") - (return-type "none") - (parameters - '("GtkWidget*" "item") - '("const-gchar*" "name") - '("GtkWidget*" "image") - ) -) - -(define-method add_item_with_stock_icon - (of-object "XedPanel") - (c-name "xed_panel_add_item_with_stock_icon") - (return-type "none") - (parameters - '("GtkWidget*" "item") - '("const-gchar*" "name") - '("const-gchar*" "stock_id") - ) -) - -(define-method remove_item - (of-object "XedPanel") - (c-name "xed_panel_remove_item") - (return-type "gboolean") - (parameters - '("GtkWidget*" "item") - ) -) - -(define-method activate_item - (of-object "XedPanel") - (c-name "xed_panel_activate_item") - (return-type "gboolean") - (parameters - '("GtkWidget*" "item") - ) -) - -(define-method item_is_active - (of-object "XedPanel") - (c-name "xed_panel_item_is_active") - (return-type "gboolean") - (parameters - '("GtkWidget*" "item") - ) -) - -(define-method get_orientation - (of-object "XedPanel") - (c-name "xed_panel_get_orientation") - (return-type "GtkOrientation") -) - -(define-method get_n_items - (of-object "XedPanel") - (c-name "xed_panel_get_n_items") - (return-type "gint") -) - - -;; From ../../xed/xed-plugin.h - -(define-function xed_plugin_get_type - (c-name "xed_plugin_get_type") - (return-type "GType") -) - -(define-method get_install_dir - (of-object "XedPlugin") - (c-name "xed_plugin_get_install_dir") - (return-type "gchar*") -) - -(define-method get_data_dir - (of-object "XedPlugin") - (c-name "xed_plugin_get_data_dir") - (return-type "gchar*") -) - -(define-method activate - (of-object "XedPlugin") - (c-name "xed_plugin_activate") - (return-type "none") - (parameters - '("XedWindow*" "window") - ) -) - -(define-method deactivate - (of-object "XedPlugin") - (c-name "xed_plugin_deactivate") - (return-type "none") - (parameters - '("XedWindow*" "window") - ) -) - -(define-method update_ui - (of-object "XedPlugin") - (c-name "xed_plugin_update_ui") - (return-type "none") - (parameters - '("XedWindow*" "window") - ) -) - -(define-method is_configurable - (of-object "XedPlugin") - (c-name "xed_plugin_is_configurable") - (return-type "gboolean") -) - -(define-method create_configure_dialog - (of-object "XedPlugin") - (c-name "xed_plugin_create_configure_dialog") - (return-type "GtkWidget*") -) - -;; From ../xed/xed-plugin-python.h - -(define-function xed_plugin_python_get_type - (c-name "xed_plugin_python_get_type") - (return-type "GType") -) - -(define-function xed_plugin_python_new - (c-name "xed_plugin_python_new") - (is-constructor-of "XedPluginPython") - (return-type "XedPluginPython*") -) - -;; From ../../xed/xed-status-bar.h - -(define-method flash_message - (of-object "XedStatusbar") - (c-name "xed_statusbar_flash_message") - (return-type "none") - (parameters - '("int" "context_id") - '("const-gchar*" "message") - ) - ) - -;; From ../../xed/xed-tab.h - -(define-function xed_tab_get_type - (c-name "xed_tab_get_type") - (return-type "GType") -) - -(define-method get_view - (of-object "XedTab") - (c-name "xed_tab_get_view") - (return-type "XedView*") -) - -(define-method get_document - (of-object "XedTab") - (c-name "xed_tab_get_document") - (return-type "XedDocument*") -) - -(define-function tab_get_from_document - (c-name "xed_tab_get_from_document") - (return-type "XedTab*") - (parameters - '("XedDocument*" "doc") - ) -) - -; Deprecated version ! -(define-function xed_tab_get_from_document - (c-name "xed_tab_get_from_document_deprecated") - (return-type "XedTab*") - (parameters - '("XedDocument*" "doc") - ) -) - -(define-method get_state - (of-object "XedTab") - (c-name "xed_tab_get_state") - (return-type "XedTabState") -) - -(define-method set_auto_save_enabled - (of-object "XedTab") - (c-name "xed_tab_set_auto_save_enabled") - (return-type "none") - (parameters - '("gboolean" "enable") - ) -) - -(define-method get_auto_save_enabled - (of-object "XedTab") - (c-name "xed_tab_get_auto_save_enabled") - (return-type "gboolean") -) - -(define-method set_auto_save_interval - (of-object "XedTab") - (c-name "xed_tab_set_auto_save_interval") - (return-type "none") - (parameters - '("gint" "interval") - ) -) - -(define-method get_auto_save_interval - (of-object "XedTab") - (c-name "xed_tab_get_auto_save_interval") - (return-type "gint") -) - -;; From ../../xed/xed-view.h - -(define-function xed_view_get_type - (c-name "xed_view_get_type") - (return-type "GtkType") -) - -(define-function xed_view_new - (c-name "xed_view_new") - (is-constructor-of "XedView") - (return-type "GtkWidget*") - (parameters - '("XedDocument*" "doc") - ) -) - -(define-method cut_clipboard - (of-object "XedView") - (c-name "xed_view_cut_clipboard") - (return-type "none") -) - -(define-method copy_clipboard - (of-object "XedView") - (c-name "xed_view_copy_clipboard") - (return-type "none") -) - -(define-method paste_clipboard - (of-object "XedView") - (c-name "xed_view_paste_clipboard") - (return-type "none") -) - -(define-method delete_selection - (of-object "XedView") - (c-name "xed_view_delete_selection") - (return-type "none") -) - -(define-method select_all - (of-object "XedView") - (c-name "xed_view_select_all") - (return-type "none") -) - -(define-method scroll_to_cursor - (of-object "XedView") - (c-name "xed_view_scroll_to_cursor") - (return-type "none") -) - -(define-method set_font - (of-object "XedView") - (c-name "xed_view_set_font") - (return-type "none") - (parameters - '("gboolean" "def") - '("const-gchar*" "font_name") - ) -) - - - -;; From ../../xed/xed-window.h - -(define-function xed_window_get_type - (c-name "xed_window_get_type") - (return-type "GType") -) - -(define-method create_tab - (of-object "XedWindow") - (c-name "xed_window_create_tab") - (return-type "XedTab*") - (parameters - '("gboolean" "jump_to") - ) -) - -(define-method create_tab_from_uri - (of-object "XedWindow") - (c-name "xed_window_create_tab_from_uri") - (return-type "XedTab*") - (parameters - '("const-gchar*" "uri") - '("const-XedEncoding*" "encoding" (null-ok)) - '("gint" "line_pos") - '("gboolean" "create") - '("gboolean" "jump_to") - ) -) - -(define-method close_tab - (of-object "XedWindow") - (c-name "xed_window_close_tab") - (return-type "none") - (parameters - '("XedTab*" "tab") - ) -) - -(define-method close_tabs - (of-object "XedWindow") - (c-name "xed_window_close_tabs") - (return-type "none") - (parameters - '("const-GList*" "tabs") - ) -) - -(define-method close_all_tabs - (of-object "XedWindow") - (c-name "xed_window_close_all_tabs") - (return-type "none") -) - -(define-method get_active_tab - (of-object "XedWindow") - (c-name "xed_window_get_active_tab") - (return-type "XedTab*") -) - -(define-method set_active_tab - (of-object "XedWindow") - (c-name "xed_window_set_active_tab") - (return-type "none") - (parameters - '("XedTab*" "tab") - ) -) - -(define-method get_active_view - (of-object "XedWindow") - (c-name "xed_window_get_active_view") - (return-type "XedView*") -) - -(define-method get_active_document - (of-object "XedWindow") - (c-name "xed_window_get_active_document") - (return-type "XedDocument*") -) - -(define-method get_documents - (of-object "XedWindow") - (c-name "xed_window_get_documents") - (return-type "GList*") -) - -(define-method get_unsaved_documents - (of-object "XedWindow") - (c-name "xed_window_get_unsaved_documents") - (return-type "GList*") -) - -(define-method get_views - (of-object "XedWindow") - (c-name "xed_window_get_views") - (return-type "GList*") -) - -(define-method get_group - (of-object "XedWindow") - (c-name "xed_window_get_group") - (return-type "GtkWindowGroup*") -) - -(define-method get_side_panel - (of-object "XedWindow") - (c-name "xed_window_get_side_panel") - (return-type "XedPanel*") -) - -(define-method get_bottom_panel - (of-object "XedWindow") - (c-name "xed_window_get_bottom_panel") - (return-type "XedPanel*") -) - -(define-method get_statusbar - (of-object "XedWindow") - (c-name "xed_window_get_statusbar") - (return-type "GtkWidget*") -) - -(define-method get_ui_manager - (of-object "XedWindow") - (c-name "xed_window_get_ui_manager") - (return-type "GtkUIManager*") -) - -(define-method get_state - (of-object "XedWindow") - (c-name "xed_window_get_state") - (return-type "XedWindowState") -) - -(define-method get_message_bus - (of-object "XedWindow") - (c-name "xed_window_get_message_bus") - (return-type "XedMessageBus*") -) - -(define-method get_tab_from_uri - (of-object "XedWindow") - (c-name "xed_window_get_tab_from_uri") - (return-type "XedTab*") - (parameters - '("const-gchar*" "uri") - ) -) - -;; From xed-language-manager.h - -(define-function get_language_manager - (c-name "xed_get_language_manager") - (return-type "GtkSourceLanguageManager*") -) - -(define-function language_manager_list_languages_sorted - (c-name "xed_language_manager_list_languages_sorted") - (return-type "GSList*") - (parameters - '("GtkSourceLanguageManager*" "lm") - '("gboolean" "include_hidden") - ) -) - - -;; From xed-message-bus.h - -(define-function xed_message_bus_get_type - (c-name "xed_message_bus_get_type") - (return-type "GType") -) - -(define-function message_bus_get_default - (c-name "xed_message_bus_get_default") - (return-type "XedMessageBus*") -) - -(define-function xed_message_bus_new - (c-name "xed_message_bus_new") - (is-constructor-of "XedMessageBus") - (return-type "XedMessageBus*") -) - -(define-method lookup - (of-object "XedMessageBus") - (c-name "xed_message_bus_lookup") - (return-type "XedMessageType*") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - ) -) - -(define-method register - (of-object "XedMessageBus") - (c-name "xed_message_bus_register") - (return-type "XedMessageType*") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - '("guint" "num_optional") - ) - (varargs #t) -) - -(define-method unregister - (of-object "XedMessageBus") - (c-name "xed_message_bus_unregister") - (return-type "none") - (parameters - '("XedMessageType*" "message_type") - ) -) - -(define-method unregister_all - (of-object "XedMessageBus") - (c-name "xed_message_bus_unregister_all") - (return-type "none") - (parameters - '("const-gchar*" "object_path") - ) -) - -(define-method is_registered - (of-object "XedMessageBus") - (c-name "xed_message_bus_is_registered") - (return-type "gboolean") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - ) -) - -(define-method connect - (of-object "XedMessageBus") - (c-name "xed_message_bus_connect") - (return-type "guint") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - '("XedMessageCallback" "callback") - '("gpointer" "userdata") - '("GDestroyNotify" "destroy_data") - ) -) - -(define-method disconnect - (of-object "XedMessageBus") - (c-name "xed_message_bus_disconnect") - (return-type "none") - (parameters - '("guint" "id") - ) -) - -(define-method disconnect_by_func - (of-object "XedMessageBus") - (c-name "xed_message_bus_disconnect_by_func") - (return-type "none") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - '("XedMessageCallback" "callback") - '("gpointer" "userdata") - ) -) - -(define-method block - (of-object "XedMessageBus") - (c-name "xed_message_bus_block") - (return-type "none") - (parameters - '("guint" "id") - ) -) - -(define-method block_by_func - (of-object "XedMessageBus") - (c-name "xed_message_bus_block_by_func") - (return-type "none") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - '("XedMessageCallback" "callback") - '("gpointer" "userdata") - ) -) - -(define-method unblock - (of-object "XedMessageBus") - (c-name "xed_message_bus_unblock") - (return-type "none") - (parameters - '("guint" "id") - ) -) - -(define-method unblock_by_func - (of-object "XedMessageBus") - (c-name "xed_message_bus_unblock_by_func") - (return-type "none") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - '("XedMessageCallback" "callback") - '("gpointer" "userdata") - ) -) - -(define-method send_message - (of-object "XedMessageBus") - (c-name "xed_message_bus_send_message") - (return-type "none") - (parameters - '("XedMessage*" "message") - ) -) - -(define-method send_message_sync - (of-object "XedMessageBus") - (c-name "xed_message_bus_send_message_sync") - (return-type "none") - (parameters - '("XedMessage*" "message") - ) -) - -(define-method send - (of-object "XedMessageBus") - (c-name "xed_message_bus_send") - (return-type "none") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - ) - (varargs #t) -) - -(define-method send_sync - (of-object "XedMessageBus") - (c-name "xed_message_bus_send_sync") - (return-type "XedMessage*") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - ) - (varargs #t) -) - - -;; From xed-message-type.h - -(define-function xed_message_type_get_type - (c-name "xed_message_type_get_type") - (return-type "GType") -) - -(define-function xed_message_type_is_supported - (c-name "xed_message_type_is_supported") - (return-type "gboolean") - (parameters - '("GType" "type") - ) -) - -(define-function xed_message_type_identifier - (c-name "xed_message_type_identifier") - (return-type "gchar*") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - ) -) - -(define-function xed_message_type_new - (c-name "xed_message_type_new") - (is-constructor-of "XedMessageType") - (return-type "XedMessageType*") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - '("guint" "num_optional") - ) - (varargs #t) -) - -(define-function xed_message_type_new_valist - (c-name "xed_message_type_new_valist") - (return-type "XedMessageType*") - (parameters - '("const-gchar*" "object_path") - '("const-gchar*" "method") - '("guint" "num_optional") - '("va_list" "va_args") - ) -) - -(define-method ref - (of-object "XedMessageType") - (c-name "xed_message_type_ref") - (return-type "XedMessageType*") -) - -(define-method unref - (of-object "XedMessageType") - (c-name "xed_message_type_unref") - (return-type "none") -) - -(define-method instantiate_valist - (of-object "XedMessageType") - (c-name "xed_message_type_instantiate_valist") - (return-type "XedMessage*") - (parameters - '("va_list" "va_args") - ) -) - -(define-method instantiate - (of-object "XedMessageType") - (c-name "xed_message_type_instantiate") - (return-type "XedMessage*") - (parameters - ) - (varargs #t) -) - -(define-method get_object_path - (of-object "XedMessageType") - (c-name "xed_message_type_get_object_path") - (return-type "const-gchar*") -) - -(define-method get_method - (of-object "XedMessageType") - (c-name "xed_message_type_get_method") - (return-type "const-gchar*") -) - -(define-method lookup - (of-object "XedMessageType") - (c-name "xed_message_type_lookup") - (return-type "GType") - (parameters - '("const-gchar*" "key") - ) -) - -(define-method foreach - (of-object "XedMessageType") - (c-name "xed_message_type_foreach") - (return-type "none") - (parameters - '("XedMessageTypeForeach" "func") - '("gpointer" "user_data") - ) -) - - -;; From xed-message.h - -(define-function xed_message_get_type - (c-name "xed_message_get_type") - (return-type "GType") -) - -(define-method get - (of-object "XedMessage") - (c-name "xed_message_get") - (return-type "none") - (parameters - ) - (varargs #t) -) - -(define-method get_valist - (of-object "XedMessage") - (c-name "xed_message_get_valist") - (return-type "none") - (parameters - '("va_list" "var_args") - ) -) - -(define-method get_value - (of-object "XedMessage") - (c-name "xed_message_get_value") - (return-type "none") - (parameters - '("const-gchar*" "key") - '("GValue*" "value") - ) -) - -(define-method set - (of-object "XedMessage") - (c-name "xed_message_set") - (return-type "none") - (parameters - ) - (varargs #t) -) - -(define-method set_valist - (of-object "XedMessage") - (c-name "xed_message_set_valist") - (return-type "none") - (parameters - '("va_list" "var_args") - ) -) - -(define-method set_value - (of-object "XedMessage") - (c-name "xed_message_set_value") - (return-type "none") - (parameters - '("const-gchar*" "key") - '("GValue*" "value") - ) -) - -(define-method set_valuesv - (of-object "XedMessage") - (c-name "xed_message_set_valuesv") - (return-type "none") - (parameters - '("const-gchar**" "keys") - '("GValue*" "values") - '("gint" "n_values") - ) -) - -(define-method get_object_path - (of-object "XedMessage") - (c-name "xed_message_get_object_path") - (return-type "const-gchar*") -) - -(define-method get_method - (of-object "XedMessage") - (c-name "xed_message_get_method") - (return-type "const-gchar*") -) - -(define-method has_key - (of-object "XedMessage") - (c-name "xed_message_has_key") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - ) -) - -(define-method get_key_type - (of-object "XedMessage") - (c-name "xed_message_get_key_type") - (return-type "GType") - (parameters - '("const-gchar*" "key") - ) -) - -(define-method validate - (of-object "XedMessage") - (c-name "xed_message_validate") - (return-type "gboolean") -) - - -;; From ../../xed/xed-debug.h - -(define-function debug - (c-name "xed_debug") - (parameters - '("const-gchar*" "message") - ) - (return-type "none") -) - diff --git a/plugin-loaders/python/bindings/xed.override b/plugin-loaders/python/bindings/xed.override deleted file mode 100644 index 93f37e3..0000000 --- a/plugin-loaders/python/bindings/xed.override +++ /dev/null @@ -1,461 +0,0 @@ -%% -headers -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "xed-plugin-python.h" - -void pyxed_register_classes (PyObject *d); -void pyxed_add_constants (PyObject *module, const gchar *strip_prefix); - -static PyObject * -_helper_wrap_gobject_glist (const GList *list) -{ - PyObject *py_list; - const GList *tmp; - - if ((py_list = PyList_New(0)) == NULL) { - return NULL; - } - for (tmp = list; tmp != NULL; tmp = tmp->next) { - PyObject *py_obj = pygobject_new(G_OBJECT(tmp->data)); - - if (py_obj == NULL) { - Py_DECREF(py_list); - return NULL; - } - PyList_Append(py_list, py_obj); - Py_DECREF(py_obj); - } - return py_list; -} - -static PyObject * -_helper_wrap_gobject_gslist (const GSList *list) -{ - PyObject *py_list; - const GSList *tmp; - - if ((py_list = PyList_New(0)) == NULL) { - return NULL; - } - for (tmp = list; tmp != NULL; tmp = tmp->next) { - PyObject *py_obj = pygobject_new(G_OBJECT(tmp->data)); - - if (py_obj == NULL) { - Py_DECREF(py_list); - return NULL; - } - PyList_Append(py_list, py_obj); - Py_DECREF(py_obj); - } - return py_list; -} -%% -include - xedplugin.override - xedmessage.override -%% -modulename xed -%% -import gtk.Widget as PyGtkWidget_Type -import gobject.GObject as PyGObject_Type -import gtk.gdk.Screen as PyGdkScreen_Type -import gtk.VBox as PyGtkVBox_Type -import gtk.Window as PyGtkWindow_Type -import gtk.Image as PyGtkImage_Type -import gtk.Statusbar as PyGtkStatusbar_Type -import gtksourceview2.Buffer as PyGtkSourceBuffer_Type -import gtksourceview2.View as PyGtkSourceView_Type -import gtksourceview2.Language as PyGtkSourceLanguage_Type -import gtksourceview2.LanguageManager as PyGtkSourceLanguageManager_Type -%% -ignore-glob - *_get_type - xed_document_error_quark - xed_panel_add_item_with_stock_icon -%% -override xed_app_create_window kwargs -static PyObject * -_wrap_xed_app_create_window(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "screen", NULL}; - PyGObject *screen = NULL; - XedWindow *ret; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O!", kwlist, - &PyGdkScreen_Type, &screen)) - return NULL; - - ret = xed_app_create_window(XED_APP(self->obj), - screen ? GDK_SCREEN(screen->obj) : NULL); - - /* pygobject_new handles NULL checking */ - return pygobject_new((GObject *)ret); -} -%% -override xed_app_get_windows -static PyObject * -_wrap_xed_app_get_windows(PyGObject *self) -{ - const GList *list; - PyObject *py_list; - - list = xed_app_get_windows (XED_APP (self->obj)); - - py_list = _helper_wrap_gobject_glist (list); - - return py_list; -} -%% -override xed_app_get_views -static PyObject * -_wrap_xed_app_get_views(PyGObject *self) -{ - GList *list; - PyObject *py_list; - - list = xed_app_get_views (XED_APP (self->obj)); - - py_list = _helper_wrap_gobject_glist (list); - - g_list_free (list); - - return py_list; -} -%% -override xed_app_get_documents -static PyObject * -_wrap_xed_app_get_documents(PyGObject *self) -{ - GList *list; - PyObject *py_list; - - list = xed_app_get_documents (XED_APP (self->obj)); - - py_list = _helper_wrap_gobject_glist (list); - - g_list_free (list); - - return py_list; -} -%% -override xed_window_get_documents -static PyObject * -_wrap_xed_window_get_documents(PyGObject *self) -{ - GList *list; - PyObject *py_list; - - list = xed_window_get_documents (XED_WINDOW (self->obj)); - - py_list = _helper_wrap_gobject_glist (list); - - g_list_free(list); - - return py_list; -} -%% -override xed_window_get_unsaved_documents -static PyObject * -_wrap_xed_window_get_unsaved_documents(PyGObject *self) -{ - GList *list; - PyObject *py_list; - - list = xed_window_get_unsaved_documents (XED_WINDOW (self->obj)); - - py_list = _helper_wrap_gobject_glist (list); - - g_list_free(list); - - return py_list; -} -%% -override xed_window_get_views -static PyObject * -_wrap_xed_window_get_views(PyGObject *self) -{ - GList *list; - PyObject *py_list; - - list = xed_window_get_views (XED_WINDOW (self->obj)); - - py_list = _helper_wrap_gobject_glist (list); - - g_list_free(list); - - return py_list; -} -%% -override xed_window_close_tabs kwargs -static PyObject * -_wrap_xed_window_close_tabs (PyGObject *self, - PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "tabs", NULL }; - PyObject *list, *item; - GList *glist = NULL; - int len, i; - - if (!PyArg_ParseTupleAndKeywords (args, kwargs, - "O:XedWindow.close_tabs", kwlist, - &list)) - return NULL; - - if (!PySequence_Check (list)) - { - PyErr_SetString (PyExc_TypeError, - "first argument must be a sequence"); - return NULL; - } - - len = PySequence_Length (list); - - for (i = 0; i < len; i++) - { - item = PySequence_GetItem (list, i); - Py_DECREF(item); - - if (!pygobject_check (item, &PyXedTab_Type)) - { - PyErr_SetString (PyExc_TypeError, - "sequence item not a Gtkwidget object"); - g_list_free (glist); - return NULL; - } - - glist = g_list_append (glist, pygobject_get (item)); - } - - xed_window_close_tabs (XED_WINDOW (self->obj), glist); - - g_list_free (glist); - Py_INCREF (Py_None); - return Py_None; -} -%% -override xed_document_get_search_text -static PyObject * -_wrap_xed_document_get_search_text(PyGObject *self) -{ - PyObject *tuple, *string; - guint flags; - gchar *ret; - - ret = xed_document_get_search_text (XED_DOCUMENT (self->obj), &flags); - - tuple = PyTuple_New(2); - if (ret) { - string = PyString_FromString(ret); - PyTuple_SetItem(tuple, 0, string); - } else { - Py_INCREF(Py_None); - PyTuple_SetItem(tuple, 0, Py_None); - } - PyTuple_SetItem(tuple, 1, PyInt_FromLong(flags)); - - g_free(ret); - - return tuple; -} -%% -override xed_panel_add_item kwargs -static PyObject * -_wrap_xed_panel_add_item(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist1[] = { "item", "name", "image", NULL }; - static char *kwlist2[] = { "item", "name", "stock_id", NULL }; - PyGObject *item, *image; - char *name = NULL; - char *stock_id = NULL; - - if (PyArg_ParseTupleAndKeywords(args, kwargs, "O!sO!:XedPanel.add_item", kwlist1, &PyGtkWidget_Type, &item, &name, &PyGtkImage_Type, &image)) { - xed_panel_add_item(XED_PANEL(self->obj), GTK_WIDGET(item->obj), name, GTK_WIDGET(image->obj)); - Py_INCREF(Py_None); - return Py_None; - } - - PyErr_Clear(); - - if (PyArg_ParseTupleAndKeywords(args, kwargs, "O!ss:XedPanel.add_item", kwlist2, &PyGtkWidget_Type, &item, &name, &stock_id)) { - xed_panel_add_item_with_stock_icon(XED_PANEL(self->obj), GTK_WIDGET(item->obj), name, stock_id); - Py_INCREF(Py_None); - return Py_None; - } - - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, "the last arg should be either a gtk.Image or a stock_id string"); - return NULL; -} -%% -override xed_app_get_default_deprecated -/* deprecated wrappers */ -static PyObject * -_wrap_xed_app_get_default_deprecated(PyObject *self) -{ - if (PyErr_Warn(PyExc_DeprecationWarning, "use xed.app_get_default instead") < 0) - return NULL; - return _wrap_xed_app_get_default(self); -} -%% -override xed_encoding_get_from_charset_deprecated kwargs -static PyObject * -_wrap_xed_encoding_get_from_charset_deprecated(PyObject *self, PyObject *args, PyObject *kwargs) -{ - if (PyErr_Warn(PyExc_DeprecationWarning, "use xed.encoding_get_from_charset instead") < 0) - return NULL; - return _wrap_xed_encoding_get_from_charset(self, args, kwargs); -} -%% -override xed_encoding_get_from_index_deprecated kwargs -static PyObject * -_wrap_xed_encoding_get_from_index_deprecated(PyObject *self, PyObject *args, PyObject *kwargs) -{ - if (PyErr_Warn(PyExc_DeprecationWarning, "use xed.encoding_get_from_index instead") < 0) - return NULL; - return _wrap_xed_encoding_get_from_index(self, args, kwargs); -} -%% -override xed_encoding_get_utf8_deprecated -static PyObject * -_wrap_xed_encoding_get_utf8_deprecated(PyObject *self) -{ - if (PyErr_Warn(PyExc_DeprecationWarning, "use xed.encoding_get_utf8 instead") < 0) - return NULL; - return _wrap_xed_encoding_get_utf8(self); -} -%% -override xed_encoding_get_current_deprecated -static PyObject * -_wrap_xed_encoding_get_current_deprecated(PyObject *self) -{ - if (PyErr_Warn(PyExc_DeprecationWarning, "use xed.encoding_get_current instead") < 0) - return NULL; - return _wrap_xed_encoding_get_current(self); -} -%% -override xed_tab_get_from_document_deprecated kwargs -static PyObject * -_wrap_xed_tab_get_from_document_deprecated(PyObject *self, PyObject *args, PyObject *kwargs) -{ - if (PyErr_Warn(PyExc_DeprecationWarning, "use xed.tab_get_from_document instead") < 0) - return NULL; - return _wrap_xed_tab_get_from_document(self, args, kwargs); -} -%% -override xed_language_manager_list_languages_sorted kwargs -static PyObject * -_wrap_xed_language_manager_list_languages_sorted(PyObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "lm", "include_hidden", NULL }; - PyGObject *lm; - int include_hidden; - PyObject *py_list; - GSList *list; - - if (!PyArg_ParseTupleAndKeywords (args, kwargs, - "O!i:language_manager_list_languages_sorted", - kwlist, &PyGtkSourceLanguageManager_Type, &lm, - &include_hidden)) - return NULL; - - list = xed_language_manager_list_languages_sorted (GTK_SOURCE_LANGUAGE_MANAGER (lm->obj), - include_hidden); - - py_list = _helper_wrap_gobject_gslist (list); - - g_slist_free (list); - - return py_list; -} -%% -override xed_debug kwargs -static PyObject * -_wrap_xed_debug(PyObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "message", NULL }; - PyObject *traceback_module, *mdict, *func, *traceback, *tuple; - PyObject *filename, *lineno, *funcname; - char *message = NULL; - - if (g_getenv ("XED_DEBUG_PLUGINS") == NULL) - { - Py_INCREF (Py_None); - return Py_None; - } - - if (!PyArg_ParseTupleAndKeywords (args, kwargs, "|s", kwlist, &message)) - return NULL; - - traceback_module = PyImport_ImportModule ("traceback"); - if (traceback_module == NULL) - { - g_warning ("traceback module cannot be imported"); - Py_INCREF (Py_None); - return Py_None; - } - - mdict = PyModule_GetDict (traceback_module); - func = PyDict_GetItemString (mdict, "extract_stack"); - traceback = PyObject_CallFunction (func, "zi", NULL, 1); - tuple = PyList_GetItem (traceback, 0); - - if (tuple == NULL || !PyTuple_Check (tuple)) - { - g_warning ("traceback tuple is null!"); - } - else - { - filename = PyTuple_GetItem (tuple, 0); - lineno = PyTuple_GetItem (tuple, 1); - funcname = PyTuple_GetItem (tuple, 2); - - if (message == NULL) - xed_debug (XED_DEBUG_PLUGINS, - PyString_AsString (filename), - PyInt_AsLong (lineno), - PyString_AsString (funcname)); - else - xed_debug_message (XED_DEBUG_PLUGINS, - PyString_AsString (filename), - PyInt_AsLong (lineno), - PyString_AsString (funcname), - "%s", - message); - } - Py_DECREF (traceback); - Py_DECREF (traceback_module); - - Py_INCREF (Py_None); - return Py_None; -} -%% -override xed_statusbar_flash_message kwargs -static PyObject * -_wrap_xed_statusbar_flash_message(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "context_id", "message", NULL }; - int context_id; - char *message; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs,"is:XedStatusbar.flash_message", kwlist, &context_id, &message)) - return NULL; - - xed_statusbar_flash_message(XED_STATUSBAR(self->obj), context_id, "%s", message); - - Py_INCREF(Py_None); - return Py_None; -} -%% diff --git a/plugin-loaders/python/bindings/xedcommands.defs b/plugin-loaders/python/bindings/xedcommands.defs deleted file mode 100644 index 31aa7e3..0000000 --- a/plugin-loaders/python/bindings/xedcommands.defs +++ /dev/null @@ -1,45 +0,0 @@ -;; -*- scheme -*- -; object definitions ... -;; Enumerations and flags ... - - -;; From ../../xed/xed-commands.h - -(define-function load_uri - (c-name "xed_commands_load_uri") - (return-type "none") - (parameters - '("XedWindow*" "window") - '("const-gchar*" "uri") - '("const-XedEncoding*" "encoding") - '("gint" "line_pos") - ) -) - -(define-function load_uris - (c-name "xed_commands_load_uris") - (return-type "gint") - (parameters - '("XedWindow*" "window") - '("const-GSList*" "uris") - '("const-XedEncoding*" "encoding") - '("gint" "line_pos") - ) -) - -(define-function save_document - (c-name "xed_commands_save_document") - (return-type "none") - (parameters - '("XedWindow*" "window") - '("XedDocument*" "document") - ) -) - -(define-function save_all_documents - (c-name "xed_commands_save_all_documents") - (return-type "none") - (parameters - '("XedWindow*" "window") - ) -) diff --git a/plugin-loaders/python/bindings/xedcommands.override b/plugin-loaders/python/bindings/xedcommands.override deleted file mode 100644 index 603b0c5..0000000 --- a/plugin-loaders/python/bindings/xedcommands.override +++ /dev/null @@ -1,122 +0,0 @@ -%% -headers -#define NO_IMPORT_PYGOBJECT -#define NO_IMPORT_PYGTK -#include -#include - -#include "xed-commands.h" -#include "xed-window.h" - -void pyxedcommands_register_classes (PyObject *d); -void pyxedcommands_add_constants (PyObject *module, const gchar *strip_prefix); - -%% -modulename xed.commands -%% -import xed.Window as PyXedWindow_Type -import xed.Document as PyXedDocument_Type -%% -ignore-glob - _* -%% -override xed_commands_load_uri kwargs -static PyObject * -_wrap_xed_commands_load_uri (PyObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "window", "uri", "encoding", "line_pos", NULL }; - PyGObject *window; - char *uri; - int line_pos = 0; - PyObject *py_encoding = NULL; - XedEncoding *encoding = NULL; - - if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!s|Oi:load_uri", - kwlist, &PyXedWindow_Type, - &window, &uri, &py_encoding, - &line_pos)) - return NULL; - - if (py_encoding != NULL && py_encoding != Py_None) - { - if (pyg_boxed_check (py_encoding, XED_TYPE_ENCODING)) - encoding = pyg_boxed_get (py_encoding, XedEncoding); - else - { - PyErr_SetString (PyExc_TypeError, - "encoding should be a XedEncoding"); - return NULL; - } - } - - xed_commands_load_uri (XED_WINDOW (window->obj), uri, encoding, - line_pos); - Py_INCREF (Py_None); - return Py_None; -} -%% -override xed_commands_load_uris kwargs -static PyObject * -_wrap_xed_commands_load_uris (PyObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "window", "uris", "encoding", "line_pos", NULL }; - PyGObject *window; - GSList *uris = NULL; - int line_pos = 0; - PyObject *py_encoding = NULL; - PyObject *list; - PyObject *item; - XedEncoding *encoding = NULL; - int len; - int i; - - if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!O|Oi:load_uri", - kwlist, &PyXedWindow_Type, - &window, &list, &py_encoding, - &line_pos)) - return NULL; - - if (py_encoding != NULL && py_encoding != Py_None) - { - if (pyg_boxed_check (py_encoding, XED_TYPE_ENCODING)) - encoding = pyg_boxed_get (py_encoding, XedEncoding); - else { - PyErr_SetString (PyExc_TypeError, - "encoding should be a XedEncoding"); - return NULL; - } - } - - if (!PySequence_Check (list)) - { - PyErr_SetString (PyExc_TypeError, - "second argument must be a sequence"); - return NULL; - } - - len = PySequence_Length (list); - - for (i = 0; i < len; i++) - { - item = PySequence_GetItem (list, i); - Py_DECREF (item); - - if (!PyString_Check (item)) - { - PyErr_SetString (PyExc_TypeError, - "sequence item not a string"); - g_slist_free (uris); - return NULL; - } - - uris = g_slist_prepend (uris, PyString_AsString (item)); - } - - uris = g_slist_reverse (uris); - xed_commands_load_uris (XED_WINDOW (window->obj), uris, - encoding, line_pos); - g_slist_free (uris); - - Py_INCREF (Py_None); - return Py_None; -} diff --git a/plugin-loaders/python/bindings/xedmessage.override b/plugin-loaders/python/bindings/xedmessage.override deleted file mode 100644 index c1af552..0000000 --- a/plugin-loaders/python/bindings/xedmessage.override +++ /dev/null @@ -1,556 +0,0 @@ -%% -headers - -#include -#include - -static GType -_helper_wrap_get_gtype_from_pytype (PyObject *pytype) -{ - PyTypeObject *type = (PyTypeObject *)pytype; - - if (type == &PyList_Type || type == &PyTuple_Type) - return G_TYPE_STRV; - - return pyg_type_from_object (pytype); -} - -static gchar * -_helper_wrap_get_string (PyObject *obj) -{ - PyObject *str; - gchar *result; - - str = PyObject_Str (obj); - - if (!str) - return NULL; - - result = g_strdup (PyString_AsString (str)); - Py_DECREF (str); - - return result; -} - -static int -_helper_wrap_list_to_gvalue (GValue *gvalue, PyObject *pyvalue) -{ - int num; - gchar **lst; - gint i; - - num = PySequence_Size (pyvalue); - lst = g_new0 (gchar *, num + 1); - - for (i = 0; i < num; i++) - { - lst[i] = _helper_wrap_get_string (PySequence_GetItem (pyvalue, i)); - - if (lst[i] == NULL) - { - g_strfreev (lst); - return 1; - } - } - - g_value_set_boxed (gvalue, lst); - g_strfreev (lst); - - return 0; -} - -static int -_helper_wrap_get_gvalue_from_pyobject (GValue *gvalue, PyObject *pyvalue) -{ - if (pyvalue->ob_type == &PyList_Type || pyvalue->ob_type == &PyTuple_Type) - return _helper_wrap_list_to_gvalue (gvalue, pyvalue); - - return pyg_value_from_pyobject(gvalue, pyvalue); -} - -static int -_helper_wrap_message_set_value(XedMessage *message, PyObject *pykey, PyObject *pyvalue) -{ - gchar *key; - GType gtype; - GValue value = {0,}; - - key = _helper_wrap_get_string(pykey); - - if (key == NULL) - return 0; - - gtype = xed_message_get_key_type(message, key); - - if (gtype == 0) { - PyErr_SetString(PyExc_TypeError, "invalid key"); - g_free (key); - return 0; - } - - g_value_init(&value, gtype); - - if (_helper_wrap_get_gvalue_from_pyobject (&value, pyvalue)) { - PyErr_SetString(PyExc_TypeError, - "value is of the wrong type for this key"); - g_free (key); - return 0; - } - - xed_message_set_value(message, key, &value); - g_value_unset(&value); - g_free (key); - - return 1; -} - -typedef void (*ParsePairFunc)(PyObject *key, PyObject *value, gpointer user_data); - -static void -_helper_parse_pairs_dict (PyObject *dict, ParsePairFunc func, gpointer user_data) -{ - if (!dict) - return; - - PyObject *key, *value; - Py_ssize_t i = 0; - - while (PyDict_Next(dict, &i, &key, &value)) - { - func(key, value, user_data); - } -} - -static void -_helper_parse_pairs(PyObject *args, PyObject *kwargs, ParsePairFunc func, gpointer user_data) -{ - guint len; - guint i; - - len = PyTuple_Size(args); - - for (i = 0; i < len; ++i) - { - PyObject *d = PyTuple_GetItem(args, i); - - if (PyDict_Check(d)) - _helper_parse_pairs_dict(d, func, user_data); - } - - _helper_parse_pairs_dict(kwargs, func, user_data); -} - -static void -_helper_message_set(PyObject *key, PyObject *value, XedMessage *message) -{ - _helper_wrap_message_set_value(message, key, value); -} - -static void -_helper_message_set_values(XedMessage *message, PyObject *args, PyObject *kwargs) -{ - _helper_parse_pairs(args, kwargs, (ParsePairFunc)_helper_message_set, message); -} - -static XedMessage * -_helper_wrap_create_message(XedMessageBus *bus, PyObject *args, PyObject *kwargs) -{ - PyObject *pypath, *pymethod, *pydict; - - if (!PyArg_ParseTuple(args, "OO|O:XedMessage.create", &pypath, &pymethod, &pydict)) - return NULL; - - gchar *object_path = _helper_wrap_get_string(pypath); - gchar *method = _helper_wrap_get_string(pymethod); - - XedMessageType *message_type = xed_message_bus_lookup (bus, object_path, method); - XedMessage *message; - - if (message_type) - { - message = xed_message_type_instantiate(message_type, NULL); - _helper_message_set_values(message, args, kwargs); - } - else - { - PyErr_SetString(PyExc_StandardError, "Message type does not exist"); - message = NULL; - } - - g_free(object_path); - g_free(method); - - return message; -} - -typedef struct { - PyObject *func; - PyObject *data; -} PyXedCustomNotify; - -static void -pyxed_custom_destroy_notify(gpointer user_data) -{ - PyXedCustomNotify *cunote = user_data; - PyGILState_STATE state; - - g_return_if_fail(user_data); - state = pyg_gil_state_ensure(); - Py_XDECREF(cunote->func); - Py_XDECREF(cunote->data); - pyg_gil_state_release(state); - - g_free(cunote); -} -%% -ignore-glob - *_get_type - xed_message_type_foreach - xed_message_type_instantiate_valist - xed_message_type_new_valist - xed_message_get_valist - xed_message_set_valist - xed_message_set_valuesv - xed_message_bus_disconnect_by_func - xed_message_bus_block_by_func - xed_message_bus_unblock_by_func -%% -override xed_message_type_new kwargs - -typedef struct -{ - XedMessageType *message_type; - PyObject *optional; -} MessageTypeSetInfo; - -static void -_message_type_set(PyObject *key, PyObject *value, MessageTypeSetInfo *info) -{ - GType gtype; - - gchar *k = _helper_wrap_get_string(key); - - if (!k) - return; - - gtype = _helper_wrap_get_gtype_from_pytype(value); - - gboolean optional = info->optional && PySequence_Contains(info->optional, key); - - xed_message_type_set(info->message_type, optional, k, gtype, NULL); - g_free(k); -} - -static int -_wrap_xed_message_type_new(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *pypath, *pymethod, *optional = NULL, *pydict; - - if (!PyArg_ParseTuple(args, "OO|OO:XedMessageType.new", &pypath, &pymethod, &optional, &pydict)) - return -1; - - XedMessageType *message_type = XED_MESSAGE_TYPE(g_object_new(pyg_type_from_object((PyObject *) self), NULL)); - - MessageTypeSetInfo info = {message_type, optional && PySequence_Check(optional) ? optional : NULL}; - _helper_parse_pairs (args, kwargs, (ParsePairFunc)_message_type_set, &info); - - self->obj = (GObject *)message_type; - pygobject_register_wrapper((PyObject *) self); - - return 0; -} -%% -override xed_message_type_instantiate kwargs -static PyObject * -_wrap_xed_message_type_instantiate(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - XedMessageType *message_type = XED_MESSAGE_TYPE (self->obj); - XedMessage *message = xed_message_type_instantiate(message_type, NULL); - - _helper_message_set_values(message, args, kwargs); - - return pygobject_new((GObject *)message); -} -%% -override xed_message_get args -static PyObject * -_wrap_xed_message_get(PyGObject *self, PyObject *args) -{ - guint len, i; - PyObject *ret; - - len = PyTuple_Size(args); - - ret = PyTuple_New(len); - - for (i = 0; i < len; i++) { - GValue value = { 0, }; - PyObject *py_key = PyTuple_GetItem(args, i); - gchar *key = _helper_wrap_get_string(py_key); - - if (!key) { - PyErr_SetString(PyExc_TypeError, "keys must be strings"); - Py_DECREF(ret); - return NULL; - } - - xed_message_get_value (XED_MESSAGE (self->obj), key, &value); - g_free (key); - - PyTuple_SetItem(ret, i, pyg_value_as_pyobject(&value, TRUE)); - g_value_unset(&value); - } - - return ret; -} -%% -override xed_message_get_value kwargs -static PyObject * -_wrap_xed_message_get_value(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "key", NULL }; - const gchar *key; - PyObject *ret; - GValue value = { 0, }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:XedMessage.get_value", kwlist, &key)) - return NULL; - - xed_message_get_value(XED_MESSAGE(self->obj), key, &value); - ret = pyg_value_as_pyobject(&value, TRUE); - g_value_unset(&value); - - return ret; -} -%% -override xed_message_set_value kwargs -static PyObject * -_wrap_xed_message_set_value(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "key", "value", NULL }; - PyObject *pykey, *pyvalue; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:XedMessage.set_value", kwlist, &pykey, &pyvalue)) - return NULL; - - if (!_helper_wrap_message_set_value(XED_MESSAGE(self->obj), pykey, pyvalue)) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} -%% -override xed_message_set kwargs -static PyObject * -_wrap_xed_message_set (PyGObject *self, PyObject *args, PyObject *kwargs) { - _helper_message_set_values(XED_MESSAGE(self->obj), args, kwargs); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override xed_message_bus_new -static int -_wrap_xed_message_bus_new(PyGObject *self) -{ - pygobject_construct (self, NULL); - - if (!self->obj) { - PyErr_SetString (PyExc_RuntimeError, "could not create xed.MessageBus object"); - return -1; - } - - return 0; -} -%% -new-constructor XED_TYPE_MESSAGE_BUS -%% -override xed_message_bus_register kwargs -static PyObject * -_wrap_xed_message_bus_register(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *pypath, *pymethod, *optional = NULL, *pydict; - XedMessageBus *bus = XED_MESSAGE_BUS(self->obj); - - if (!PyArg_ParseTuple(args, "OO|OO:XedMessageBus.register", &pypath, &pymethod, &optional, &pydict)) - return NULL; - - gchar *object_path = _helper_wrap_get_string(pypath); - gchar *method = _helper_wrap_get_string(pymethod); - - XedMessageType *message_type = xed_message_bus_register(bus, object_path, method, 0, NULL); - - g_free(object_path); - g_free(method); - - if (!message_type) - { - PyErr_SetString(PyExc_StandardError, "Message type already exists"); - return NULL; - } - - MessageTypeSetInfo info = {message_type, optional && PySequence_Check(optional) ? optional : NULL}; - _helper_parse_pairs (args, kwargs, (ParsePairFunc)_message_type_set, &info); - - return pyg_boxed_new(XED_TYPE_MESSAGE_TYPE, message_type, TRUE, TRUE); -} -%% -override xed_message_bus_connect kwargs -static void -pyxed_message_bus_connect_cb(XedMessageBus *bus, XedMessage *message, gpointer data) -{ - PyGILState_STATE state; - PyXedCustomNotify *cunote = data; - PyObject *pybus, *pymessage, *retobj; - - g_assert(cunote->func); - - state = pyg_gil_state_ensure(); - - pybus = pygobject_new((GObject *)bus); - pymessage = pygobject_new((GObject *)message); - - if (cunote->data) { - retobj = PyEval_CallFunction(cunote->func, "(NNO)", pybus, pymessage, cunote->data); - } else { - retobj = PyEval_CallFunction(cunote->func, "(NN)", pybus, pymessage); - } - - if (PyErr_Occurred()) { - PyErr_Print(); - } - - Py_XDECREF(retobj); - - pyg_gil_state_release(state); -} - -static PyObject * -_wrap_xed_message_bus_connect(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "domain", "name", "func", "data", NULL }; - PyObject *pyfunc, *pyarg = NULL; - const gchar *domain; - const gchar *name; - PyXedCustomNotify *cunote; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "ssO|O:XedMessageBus.connect", - kwlist, &domain, &name, &pyfunc, &pyarg)) - return NULL; - - if (!PyCallable_Check(pyfunc)) { - PyErr_SetString(PyExc_TypeError, "func must be a callable object"); - return NULL; - } - cunote = g_new(PyXedCustomNotify, 1); - Py_INCREF(pyfunc); - cunote->func = pyfunc; - Py_XINCREF(pyarg); - cunote->data = pyarg; - - guint id = xed_message_bus_connect(XED_MESSAGE_BUS(self->obj), - domain, - name, - pyxed_message_bus_connect_cb, - (gpointer)cunote, - pyxed_custom_destroy_notify); - return PyLong_FromUnsignedLong(id); -} -%% -override xed_message_bus_send kwargs -static PyObject * -_wrap_xed_message_bus_send(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - /* create a new message object */ - XedMessage *message; - XedMessageBus *bus = XED_MESSAGE_BUS(self->obj); - message = _helper_wrap_create_message(bus, args, kwargs); - - if (!message) - return NULL; - - xed_message_bus_send_message(bus, message); - g_object_unref (message); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override xed_message_bus_send_sync kwargs -static PyObject * -_wrap_xed_message_bus_send_sync(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - /* create a new message object */ - XedMessage *message; - XedMessageBus *bus = XED_MESSAGE_BUS(self->obj); - - message = _helper_wrap_create_message(bus, args, kwargs); - - if (!message) - return NULL; - - xed_message_bus_send_message_sync(bus, message); - return pygobject_new((GObject *)message); -} -%% -override-slot XedMessage.tp_getattro -static PyObject * -_wrap_xed_message_tp_getattro(PyObject *self, PyObject *attrname) -{ - XedMessage *message = XED_MESSAGE(((PyGObject *)self)->obj); - XedMessageType *type; - - gchar *name = _helper_wrap_get_string (attrname); - gboolean exists; - gboolean intype; - PyObject *ret; - - if (name == NULL) - { - PyErr_SetString(PyExc_TypeError, "attr name somehow not a string"); - return NULL; - } - - g_object_get (message, "type", &type, NULL); - intype = xed_message_type_lookup (type, name) != G_TYPE_INVALID; - xed_message_type_unref (type); - - exists = xed_message_has_key (message, name); - - if (!intype) - { - ret = PyObject_GenericGetAttr(self, attrname); - } - else if (exists) - { - GValue value = { 0, }; - xed_message_get_value (message, name, &value); - ret = pyg_value_as_pyobject(&value, TRUE); - g_value_unset (&value); - } - else - { - Py_INCREF(Py_None); - ret = Py_None; - } - - g_free (name); - return ret; -} -%% -override-slot XedMessage.tp_setattro -static int -_wrap_xed_message_tp_setattro(PyObject *self, PyObject *attrname, PyObject *value) -{ - XedMessage *message = XED_MESSAGE(((PyGObject *)self)->obj); - - if (!_helper_wrap_message_set_value(message, attrname, value)) - { - return PyObject_GenericSetAttr(self, attrname, value); - } - else - { - return 1; - } -} diff --git a/plugin-loaders/python/bindings/xedplugin.override b/plugin-loaders/python/bindings/xedplugin.override deleted file mode 100644 index 05d549a..0000000 --- a/plugin-loaders/python/bindings/xedplugin.override +++ /dev/null @@ -1,193 +0,0 @@ -%% -headers -#include -#include -%% -override xed_plugin_activate kwargs -static PyObject * -_wrap_xed_plugin_activate(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - gpointer klass, klass2; - static char *kwlist[] = { "window", NULL }; - PyGObject *window; - PyObject *cls = (PyObject *)(((PyObject *)self)->ob_type); - - if (!PyArg_ParseTupleAndKeywords (args, - kwargs, - "O!:XedPlugin.activate", - kwlist, - &PyXedWindow_Type, - &window)) - return NULL; - - klass = g_type_class_ref (pyg_type_from_object (cls)); - - if (XED_IS_PLUGIN_PYTHON_CLASS (klass)) - { - klass2 = g_type_class_peek_parent (klass); - g_type_class_unref (klass); - klass = g_type_class_ref (G_TYPE_FROM_CLASS (klass2)); - } - - if (XED_PLUGIN_CLASS (klass)->activate) - XED_PLUGIN_CLASS (klass)->activate (XED_PLUGIN (self->obj), - XED_WINDOW (window->obj)); - else { - PyErr_SetString (PyExc_NotImplementedError, - "virtual method XedPlugin.activate not implemented"); - g_type_class_unref (klass); - return NULL; - } - - g_type_class_unref (klass); - Py_INCREF(Py_None); - return Py_None; -} - -%% -override xed_plugin_deactivate kwargs -static PyObject * -_wrap_xed_plugin_deactivate(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - gpointer klass, klass2; - static char *kwlist[] = {"window", NULL}; - PyGObject *window; - PyObject *cls = (PyObject *)(((PyObject *)self)->ob_type); - - if (!PyArg_ParseTupleAndKeywords (args, - kwargs, - "O!:XedPlugin.deactivate", - kwlist, - &PyXedWindow_Type, - &window)) - return NULL; - - klass = g_type_class_ref (pyg_type_from_object (cls)); - - if (XED_IS_PLUGIN_PYTHON_CLASS (klass)) - { - klass2 = g_type_class_peek_parent (klass); - g_type_class_unref (klass); - klass = g_type_class_ref (G_TYPE_FROM_CLASS (klass2)); - } - - if (XED_PLUGIN_CLASS (klass)->deactivate) - XED_PLUGIN_CLASS (klass)->deactivate (XED_PLUGIN (self->obj), - XED_WINDOW (window->obj)); - else { - PyErr_SetString (PyExc_NotImplementedError, - "virtual method XedPlugin.deactivate not implemented"); - g_type_class_unref (klass); - return NULL; - } - - g_type_class_unref (klass); - Py_INCREF(Py_None); - return Py_None; -} - -%% -override xed_plugin_update_ui kwargs -static PyObject * -_wrap_xed_plugin_update_ui (PyGObject *self, PyObject *args, PyObject *kwargs) -{ - gpointer klass, klass2; - static char *kwlist[] = {"window", NULL}; - PyGObject *window; - PyObject *cls = (PyObject *)(((PyObject *)self)->ob_type); - - if (!PyArg_ParseTupleAndKeywords (args, - kwargs, - "O!:XedPlugin.update_ui", - kwlist, - &PyXedWindow_Type, - &window)) - return NULL; - - klass = g_type_class_ref (pyg_type_from_object (cls)); - - if (XED_IS_PLUGIN_PYTHON_CLASS (klass)) - { - klass2 = g_type_class_peek_parent (klass); - g_type_class_unref (klass); - klass = g_type_class_ref (G_TYPE_FROM_CLASS (klass2)); - } - - if (XED_PLUGIN_CLASS (klass)->update_ui) - XED_PLUGIN_CLASS (klass)->update_ui (XED_PLUGIN (self->obj), - XED_WINDOW (window->obj)); - else { - PyErr_SetString (PyExc_NotImplementedError, - "virtual method XedPlugin.update_ui not implemented"); - g_type_class_unref (klass); - return NULL; - } - - g_type_class_unref (klass); - Py_INCREF(Py_None); - return Py_None; -} - -%% -override xed_plugin_is_configurable -static PyObject * -_wrap_xed_plugin_is_configurable (PyGObject *self) -{ - int ret; - gpointer klass, klass2; - PyObject *cls = (PyObject *)(((PyObject *)self)->ob_type); - - klass = g_type_class_ref (pyg_type_from_object (cls)); - - if (XED_IS_PLUGIN_PYTHON_CLASS (klass)) - { - klass2 = g_type_class_peek_parent (klass); - g_type_class_unref (klass); - klass = g_type_class_ref (G_TYPE_FROM_CLASS (klass2)); - } - - if (XED_PLUGIN_CLASS (klass)->is_configurable) - ret = XED_PLUGIN_CLASS (klass)->is_configurable (XED_PLUGIN (self->obj)); - else { - PyErr_SetString (PyExc_NotImplementedError, - "virtual method XedPlugin.is_configurable not implemented"); - g_type_class_unref (klass); - return NULL; - } - - g_type_class_unref (klass); - return PyBool_FromLong (ret); -} - -%% -override xed_plugin_configure_dialog -static PyObject * -_wrap_xed_plugin_create_configure_dialog (PyGObject *self) -{ - GtkWidget *ret; - gpointer klass, klass2; - PyObject *cls = (PyObject *)(((PyObject *)self)->ob_type); - - klass = g_type_class_ref(pyg_type_from_object (cls)); - - if (XED_IS_PLUGIN_PYTHON_CLASS (klass)) - { - klass2 = g_type_class_peek_parent (klass); - g_type_class_unref (klass); - klass = g_type_class_ref (G_TYPE_FROM_CLASS (klass2)); - } - - if (XED_PLUGIN_CLASS (klass)->create_configure_dialog) - ret = XED_PLUGIN_CLASS (klass)->create_configure_dialog (XED_PLUGIN (self->obj)); - else { - PyErr_SetString (PyExc_NotImplementedError, - "virtual method XedPlugin.create_configure_dialog not implemented"); - g_type_class_unref (klass); - return NULL; - } - - g_type_class_unref (klass); - - /* pygobject_new handles NULL checking */ - return pygobject_new ((GObject *)ret); -} diff --git a/plugin-loaders/python/bindings/xedutils.defs b/plugin-loaders/python/bindings/xedutils.defs deleted file mode 100644 index ecb38db..0000000 --- a/plugin-loaders/python/bindings/xedutils.defs +++ /dev/null @@ -1,67 +0,0 @@ -;; -*- scheme -*- - -;; From ../../xed/xed-utils.h - -(define-function uri_has_writable_scheme - (c-name "xed_utils_uri_has_writable_scheme") - (return-type "gboolean") - (parameters - '("const-gchar*" "uri") - ) -) - -(define-function uri_has_file_scheme - (c-name "xed_utils_uri_has_file_scheme") - (return-type "gboolean") - (parameters - '("const-gchar*" "uri") - ) -) - -(define-function uri_exists - (c-name "xed_utils_uri_exists") - (return-type "gboolean") - (parameters - '("const-gchar*" "text_uri") - ) -) - -(define-function uri_is_valid - (c-name "xed_utils_is_valid_uri") - (return-type "gboolean") - (parameters - '("const-gchar*" "uri") - ) -) - -(define-function uri_get_dirname - (c-name "xed_utils_uri_get_dirname") - (return-type "gchar*") - (parameters - '("const-char*" "uri") - ) -) - -(define-function menu_position_under_widget - (c-name "xed_utils_menu_position_under_widget") - (return-type "none") - (parameters - '("GtkMenu*" "menu") - '("gint*" "x") - '("gint*" "y") - '("gboolean*" "push_in") - '("gpointer" "user_data") - ) -) - -(define-function menu_position_under_tree_view - (c-name "xed_utils_menu_position_under_tree_view") - (return-type "none") - (parameters - '("GtkMenu*" "menu") - '("gint*" "x") - '("gint*" "y") - '("gboolean*" "push_in") - '("gpointer" "user_data") - ) -) diff --git a/plugin-loaders/python/bindings/xedutils.override b/plugin-loaders/python/bindings/xedutils.override deleted file mode 100644 index f177494..0000000 --- a/plugin-loaders/python/bindings/xedutils.override +++ /dev/null @@ -1,85 +0,0 @@ -%% -headers -#define NO_IMPORT_PYGOBJECT -#define NO_IMPORT_PYGTK -#include -#include - -#include "xed-utils.h" - -void pyxedutils_register_classes (PyObject *d); -void pyxedutils_add_constants (PyObject *module, const gchar *strip_prefix); - -%% -modulename xed.utils -%% -import gtk.Widget as PyGtkWidget_Type -import gtk.TreeView as PyGtkTreeView_Type -import gtk.Menu as PyGtkMenu_Type -%% -ignore-glob - _* -%% -override xed_utils_menu_position_under_widget kwargs -static PyObject * -_wrap_xed_utils_menu_position_under_widget (PyObject *self, - PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "menu", "widget", NULL }; - PyObject *py_menu, *py_widget; - GtkMenu *menu; - GtkWidget *widget; - gint x, y; - gboolean push_in; - PyObject *tuple; - - if (!PyArg_ParseTupleAndKeywords (args, kwargs, - "O!O!", kwlist, - &PyGtkMenu_Type, &py_menu, - &PyGtkWidget_Type, &py_widget)) - return NULL; - - menu = GTK_MENU (pygobject_get (py_menu)); - widget = GTK_WIDGET (pygobject_get (py_widget)); - - xed_utils_menu_position_under_widget (menu, &x, &y, &push_in, widget); - - tuple = PyTuple_New (3); - PyTuple_SetItem (tuple, 0, PyInt_FromLong (x)); - PyTuple_SetItem (tuple, 1, PyInt_FromLong (y)); - PyTuple_SetItem (tuple, 2, PyBool_FromLong (push_in)); - return tuple; -} -%% -override xed_utils_menu_position_under_tree_view kwargs -static PyObject * -_wrap_xed_utils_menu_position_under_tree_view (PyObject *self, - PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "menu", "tree_view", NULL }; - PyObject *py_menu, *py_view; - GtkMenu *menu; - GtkTreeView *view; - gint x, y; - gboolean push_in; - PyObject *tuple; - - if (!PyArg_ParseTupleAndKeywords (args, kwargs, - "O!O!", kwlist, - &PyGtkMenu_Type, &py_menu, - &PyGtkTreeView_Type, &py_view)) - return NULL; - - menu = GTK_MENU (pygobject_get (py_menu)); - view = GTK_TREE_VIEW (pygobject_get (py_view)); - - xed_utils_menu_position_under_widget (menu, &x, &y, &push_in, view); - - tuple = PyTuple_New (3); - PyTuple_SetItem (tuple, 0, PyInt_FromLong (x)); - PyTuple_SetItem (tuple, 1, PyInt_FromLong (y)); - PyTuple_SetItem (tuple, 2, PyBool_FromLong (push_in)); - return tuple; -} diff --git a/plugin-loaders/python/xed-plugin-loader-python.c b/plugin-loaders/python/xed-plugin-loader-python.c deleted file mode 100644 index 3b14715..0000000 --- a/plugin-loaders/python/xed-plugin-loader-python.c +++ /dev/null @@ -1,719 +0,0 @@ -/* - * xed-plugin-loader-python.c - * This file is part of xed - * - * Copyright (C) 2008 - Jesse van den Kieboom - * - * 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 St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "xed-plugin-loader-python.h" -#include "xed-plugin-python.h" -#include - -#define NO_IMPORT_PYGOBJECT -#define NO_IMPORT_PYGTK - -#include -#include -#include -#include -#include "config.h" - -#if PY_VERSION_HEX < 0x02050000 -typedef int Py_ssize_t; -#define PY_SSIZE_T_MAX INT_MAX -#define PY_SSIZE_T_MIN INT_MIN -#endif - -#define XED_PLUGIN_LOADER_PYTHON_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), XED_TYPE_PLUGIN_LOADER_PYTHON, XedPluginLoaderPythonPrivate)) - -struct _XedPluginLoaderPythonPrivate -{ - GHashTable *loaded_plugins; - guint idle_gc; - gboolean init_failed; -}; - -typedef struct -{ - PyObject *type; - PyObject *instance; - gchar *path; -} PythonInfo; - -static void xed_plugin_loader_iface_init (gpointer g_iface, gpointer iface_data); - -/* Exported by pyxed module */ -void pyxed_register_classes (PyObject *d); -void pyxed_add_constants (PyObject *module, const gchar *strip_prefix); -extern PyMethodDef pyxed_functions[]; - -/* Exported by pyxedutils module */ -void pyxedutils_register_classes (PyObject *d); -extern PyMethodDef pyxedutils_functions[]; - -/* Exported by pyxedcommands module */ -void pyxedcommands_register_classes (PyObject *d); -extern PyMethodDef pyxedcommands_functions[]; - -/* We retreive this to check for correct class hierarchy */ -static PyTypeObject *PyXedPlugin_Type; - -XED_PLUGIN_LOADER_REGISTER_TYPE (XedPluginLoaderPython, xed_plugin_loader_python, G_TYPE_OBJECT, xed_plugin_loader_iface_init); - - -static PyObject * -find_python_plugin_type (XedPluginInfo *info, - PyObject *pymodule) -{ - PyObject *locals, *key, *value; - Py_ssize_t pos = 0; - - locals = PyModule_GetDict (pymodule); - - while (PyDict_Next (locals, &pos, &key, &value)) - { - if (!PyType_Check(value)) - continue; - - if (PyObject_IsSubclass (value, (PyObject*) PyXedPlugin_Type)) - return value; - } - - g_warning ("No XedPlugin derivative found in Python plugin '%s'", - xed_plugin_info_get_name (info)); - return NULL; -} - -static XedPlugin * -new_plugin_from_info (XedPluginLoaderPython *loader, - XedPluginInfo *info) -{ - PythonInfo *pyinfo; - PyTypeObject *pytype; - PyObject *pyobject; - PyGObject *pygobject; - XedPlugin *instance; - PyObject *emptyarg; - - pyinfo = (PythonInfo *)g_hash_table_lookup (loader->priv->loaded_plugins, info); - - if (pyinfo == NULL) - return NULL; - - pytype = (PyTypeObject *)pyinfo->type; - - if (pytype->tp_new == NULL) - return NULL; - - emptyarg = PyTuple_New(0); - pyobject = pytype->tp_new (pytype, emptyarg, NULL); - Py_DECREF (emptyarg); - - if (pyobject == NULL) - { - g_error ("Could not create instance for %s.", xed_plugin_info_get_name (info)); - return NULL; - } - - pygobject = (PyGObject *)pyobject; - - if (pygobject->obj != NULL) - { - Py_DECREF (pyobject); - g_error ("Could not create instance for %s (GObject already initialized).", xed_plugin_info_get_name (info)); - return NULL; - } - - pygobject_construct (pygobject, - "install-dir", pyinfo->path, - "data-dir-name", xed_plugin_info_get_module_name (info), - NULL); - - if (pygobject->obj == NULL) - { - g_error ("Could not create instance for %s (GObject not constructed).", xed_plugin_info_get_name (info)); - Py_DECREF (pyobject); - - return NULL; - } - - /* now call tp_init manually */ - if (PyType_IsSubtype (pyobject->ob_type, pytype) && - pyobject->ob_type->tp_init != NULL) - { - emptyarg = PyTuple_New(0); - pyobject->ob_type->tp_init (pyobject, emptyarg, NULL); - Py_DECREF (emptyarg); - } - - instance = XED_PLUGIN (pygobject->obj); - pyinfo->instance = (PyObject *)pygobject; - - /* make sure to register the python instance for the XedPluginPython - object to it can wrap the virtual xed plugin funcs back to python */ - _xed_plugin_python_set_instance (XED_PLUGIN_PYTHON (instance), (PyObject *)pygobject); - - /* we return a reference here because the other is owned by python */ - return XED_PLUGIN (g_object_ref (instance)); -} - -static XedPlugin * -add_python_info (XedPluginLoaderPython *loader, - XedPluginInfo *info, - PyObject *module, - const gchar *path, - PyObject *type) -{ - PythonInfo *pyinfo; - - pyinfo = g_new (PythonInfo, 1); - pyinfo->path = g_strdup (path); - pyinfo->type = type; - - Py_INCREF (pyinfo->type); - - g_hash_table_insert (loader->priv->loaded_plugins, info, pyinfo); - - return new_plugin_from_info (loader, info); -} - -static const gchar * -xed_plugin_loader_iface_get_id (void) -{ - return "Python"; -} - -static XedPlugin * -xed_plugin_loader_iface_load (XedPluginLoader *loader, - XedPluginInfo *info, - const gchar *path) -{ - XedPluginLoaderPython *pyloader = XED_PLUGIN_LOADER_PYTHON (loader); - PyObject *main_module, *main_locals, *pytype; - PyObject *pymodule, *fromlist; - gchar *module_name; - XedPlugin *result; - - if (pyloader->priv->init_failed) - { - g_warning ("Cannot load python plugin Python '%s' since xed was" - "not able to initialize the Python interpreter.", - xed_plugin_info_get_name (info)); - return NULL; - } - - /* see if py definition for the plugin is already loaded */ - result = new_plugin_from_info (pyloader, info); - - if (result != NULL) - return result; - - main_module = PyImport_AddModule ("xed.plugins"); - if (main_module == NULL) - { - g_warning ("Could not get xed.plugins."); - return NULL; - } - - /* If we have a special path, we register it */ - if (path != NULL) - { - PyObject *sys_path = PySys_GetObject ("path"); - PyObject *pypath = PyString_FromString (path); - - if (PySequence_Contains (sys_path, pypath) == 0) - PyList_Insert (sys_path, 0, pypath); - - Py_DECREF (pypath); - } - - main_locals = PyModule_GetDict (main_module); - - /* we need a fromlist to be able to import modules with a '.' in the - name. */ - fromlist = PyTuple_New(0); - module_name = g_strdup (xed_plugin_info_get_module_name (info)); - - pymodule = PyImport_ImportModuleEx (module_name, - main_locals, - main_locals, - fromlist); - - Py_DECREF(fromlist); - - if (!pymodule) - { - g_free (module_name); - PyErr_Print (); - return NULL; - } - - PyDict_SetItemString (main_locals, module_name, pymodule); - g_free (module_name); - - pytype = find_python_plugin_type (info, pymodule); - - if (pytype) - return add_python_info (pyloader, info, pymodule, path, pytype); - - return NULL; -} - -static void -xed_plugin_loader_iface_unload (XedPluginLoader *loader, - XedPluginInfo *info) -{ - XedPluginLoaderPython *pyloader = XED_PLUGIN_LOADER_PYTHON (loader); - PythonInfo *pyinfo; - PyGILState_STATE state; - - pyinfo = (PythonInfo *)g_hash_table_lookup (pyloader->priv->loaded_plugins, info); - - if (!pyinfo) - return; - - state = pyg_gil_state_ensure (); - Py_XDECREF (pyinfo->instance); - pyg_gil_state_release (state); - - pyinfo->instance = NULL; -} - -static gboolean -run_gc (XedPluginLoaderPython *loader) -{ - while (PyGC_Collect ()) - ; - - loader->priv->idle_gc = 0; - return FALSE; -} - -static void -xed_plugin_loader_iface_garbage_collect (XedPluginLoader *loader) -{ - XedPluginLoaderPython *pyloader; - - if (!Py_IsInitialized()) - return; - - pyloader = XED_PLUGIN_LOADER_PYTHON (loader); - - /* - * We both run the GC right now and we schedule - * a further collection in the main loop. - */ - - while (PyGC_Collect ()) - ; - - if (pyloader->priv->idle_gc == 0) - pyloader->priv->idle_gc = g_idle_add ((GSourceFunc)run_gc, pyloader); -} - -static void -xed_plugin_loader_iface_init (gpointer g_iface, - gpointer iface_data) -{ - XedPluginLoaderInterface *iface = (XedPluginLoaderInterface *)g_iface; - - iface->get_id = xed_plugin_loader_iface_get_id; - iface->load = xed_plugin_loader_iface_load; - iface->unload = xed_plugin_loader_iface_unload; - iface->garbage_collect = xed_plugin_loader_iface_garbage_collect; -} - -static void -xed_python_shutdown (XedPluginLoaderPython *loader) -{ - if (!Py_IsInitialized ()) - return; - - if (loader->priv->idle_gc != 0) - { - g_source_remove (loader->priv->idle_gc); - loader->priv->idle_gc = 0; - } - - while (PyGC_Collect ()) - ; - - Py_Finalize (); -} - - -/* C equivalent of - * import pygtk - * pygtk.require ("2.0") - */ -static gboolean -xed_check_pygtk2 (void) -{ - PyObject *pygtk, *mdict, *require; - - /* pygtk.require("2.0") */ - pygtk = PyImport_ImportModule ("pygtk"); - if (pygtk == NULL) - { - g_warning ("Error initializing Python interpreter: could not import pygtk."); - return FALSE; - } - - mdict = PyModule_GetDict (pygtk); - require = PyDict_GetItemString (mdict, "require"); - PyObject_CallObject (require, - Py_BuildValue ("(S)", PyString_FromString ("2.0"))); - if (PyErr_Occurred()) - { - g_warning ("Error initializing Python interpreter: pygtk 2 is required."); - return FALSE; - } - - return TRUE; -} - -/* Note: the following two functions are needed because - * init_pyobject and init_pygtk which are *macros* which in case - * case of error set the PyErr and then make the calling - * function return behind our back. - * It's up to the caller to check the result with PyErr_Occurred() - */ -static void -xed_init_pygobject (void) -{ - init_pygobject_check (2, 11, 5); /* FIXME: get from config */ -} - -static void -xed_init_pygtk (void) -{ - PyObject *gtk, *mdict, *version, *required_version; - - init_pygtk (); - - /* there isn't init_pygtk_check(), do the version - * check ourselves */ - gtk = PyImport_ImportModule("gtk"); - mdict = PyModule_GetDict(gtk); - version = PyDict_GetItemString (mdict, "pygtk_version"); - if (!version) - { - PyErr_SetString (PyExc_ImportError, - "PyGObject version too old"); - return; - } - - required_version = Py_BuildValue ("(iii)", 2, 4, 0); /* FIXME */ - - if (PyObject_Compare (version, required_version) == -1) - { - PyErr_SetString (PyExc_ImportError, - "PyGObject version too old"); - Py_DECREF (required_version); - return; - } - - Py_DECREF (required_version); -} - -static void -old_gtksourceview_init (void) -{ - PyErr_SetString(PyExc_ImportError, - "gtksourceview module not allowed, use gtksourceview2"); -} - -static void -xed_init_pygtksourceview (void) -{ - PyObject *gtksourceview, *mdict, *version, *required_version; - - gtksourceview = PyImport_ImportModule("gtksourceview2"); - if (gtksourceview == NULL) - { - PyErr_SetString (PyExc_ImportError, - "could not import gtksourceview"); - return; - } - - mdict = PyModule_GetDict (gtksourceview); - version = PyDict_GetItemString (mdict, "pygtksourceview2_version"); - if (!version) - { - PyErr_SetString (PyExc_ImportError, - "PyGtkSourceView version too old"); - return; - } - - required_version = Py_BuildValue ("(iii)", 0, 8, 0); /* FIXME */ - - if (PyObject_Compare (version, required_version) == -1) - { - PyErr_SetString (PyExc_ImportError, - "PyGtkSourceView version too old"); - Py_DECREF (required_version); - return; - } - - Py_DECREF (required_version); - - /* Create a dummy 'gtksourceview' module to prevent - * loading of the old 'gtksourceview' modules that - * has conflicting symbols with the gtksourceview2 module. - * Raise an exception when trying to import it. - */ - PyImport_AppendInittab ("gtksourceview", old_gtksourceview_init); -} - -static gboolean -xed_python_init (XedPluginLoaderPython *loader) -{ - PyObject *mdict, *tuple; - PyObject *xed, *xedutils, *xedcommands, *xedplugins; - PyObject *gettext, *install, *gettext_args; - //char *argv[] = { "xed", NULL }; - char *argv[] = { XED_PLUGINS_LIBS_DIR, NULL }; -#ifdef HAVE_SIGACTION - gint res; - struct sigaction old_sigint; -#endif - - if (loader->priv->init_failed) - { - /* We already failed to initialized Python, don't need to - * retry again */ - return FALSE; - } - - if (Py_IsInitialized ()) - { - /* Python has already been successfully initialized */ - return TRUE; - } - - /* We are trying to initialize Python for the first time, - set init_failed to FALSE only if the entire initialization process - ends with success */ - loader->priv->init_failed = TRUE; - - /* Hack to make python not overwrite SIGINT: this is needed to avoid - * the crash reported on bug #326191 */ - - /* CHECK: can't we use Py_InitializeEx instead of Py_Initialize in order - to avoid to manage signal handlers ? - Paolo (Dec. 31, 2006) */ - -#ifdef HAVE_SIGACTION - /* Save old handler */ - res = sigaction (SIGINT, NULL, &old_sigint); - if (res != 0) - { - g_warning ("Error initializing Python interpreter: cannot get " - "handler to SIGINT signal (%s)", - g_strerror (errno)); - - return FALSE; - } -#endif - - /* Python initialization */ - Py_Initialize (); - -#ifdef HAVE_SIGACTION - /* Restore old handler */ - res = sigaction (SIGINT, &old_sigint, NULL); - if (res != 0) - { - g_warning ("Error initializing Python interpreter: cannot restore " - "handler to SIGINT signal (%s).", - g_strerror (errno)); - - goto python_init_error; - } -#endif - - PySys_SetArgv (1, argv); - - if (!xed_check_pygtk2 ()) - { - /* Warning message already printed in check_pygtk2 */ - goto python_init_error; - } - - /* import gobject */ - xed_init_pygobject (); - if (PyErr_Occurred ()) - { - g_warning ("Error initializing Python interpreter: could not import pygobject."); - - goto python_init_error; - } - - /* import gtk */ - xed_init_pygtk (); - if (PyErr_Occurred ()) - { - g_warning ("Error initializing Python interpreter: could not import pygtk."); - - goto python_init_error; - } - - /* import gtksourceview */ - xed_init_pygtksourceview (); - if (PyErr_Occurred ()) - { - PyErr_Print (); - - g_warning ("Error initializing Python interpreter: could not import pygtksourceview."); - - goto python_init_error; - } - - /* import xed */ - xed = Py_InitModule ("xed", pyxed_functions); - mdict = PyModule_GetDict (xed); - - pyxed_register_classes (mdict); - pyxed_add_constants (xed, "XED_"); - - /* xed version */ - tuple = Py_BuildValue("(iii)", - XED_MAJOR_VERSION, - XED_MINOR_VERSION, - XED_MICRO_VERSION); - PyDict_SetItemString(mdict, "version", tuple); - Py_DECREF(tuple); - - /* Retrieve the Python type for xed.Plugin */ - PyXedPlugin_Type = (PyTypeObject *) PyDict_GetItemString (mdict, "Plugin"); - if (PyXedPlugin_Type == NULL) - { - PyErr_Print (); - - goto python_init_error; - } - - /* import xed.utils */ - xedutils = Py_InitModule ("xed.utils", pyxedutils_functions); - PyDict_SetItemString (mdict, "utils", xedutils); - - /* import xed.commands */ - xedcommands = Py_InitModule ("xed.commands", pyxedcommands_functions); - PyDict_SetItemString (mdict, "commands", xedcommands); - - /* initialize empty xed.plugins module */ - xedplugins = Py_InitModule ("xed.plugins", NULL); - PyDict_SetItemString (mdict, "plugins", xedplugins); - - mdict = PyModule_GetDict (xedutils); - pyxedutils_register_classes (mdict); - - mdict = PyModule_GetDict (xedcommands); - pyxedcommands_register_classes (mdict); - - /* i18n support */ - gettext = PyImport_ImportModule ("gettext"); - if (gettext == NULL) - { - g_warning ("Error initializing Python interpreter: could not import gettext."); - - goto python_init_error; - } - - mdict = PyModule_GetDict (gettext); - install = PyDict_GetItemString (mdict, "install"); - gettext_args = Py_BuildValue ("ss", GETTEXT_PACKAGE, XED_LOCALEDIR); - PyObject_CallObject (install, gettext_args); - Py_DECREF (gettext_args); - - /* Python has been successfully initialized */ - loader->priv->init_failed = FALSE; - - return TRUE; - -python_init_error: - - g_warning ("Please check the installation of all the Python related packages required " - "by xed and try again."); - - PyErr_Clear (); - - xed_python_shutdown (loader); - - return FALSE; -} - -static void -xed_plugin_loader_python_finalize (GObject *object) -{ - XedPluginLoaderPython *pyloader = XED_PLUGIN_LOADER_PYTHON (object); - - g_hash_table_destroy (pyloader->priv->loaded_plugins); - xed_python_shutdown (pyloader); - - G_OBJECT_CLASS (xed_plugin_loader_python_parent_class)->finalize (object); -} - -static void -xed_plugin_loader_python_class_init (XedPluginLoaderPythonClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = xed_plugin_loader_python_finalize; - - g_type_class_add_private (object_class, sizeof (XedPluginLoaderPythonPrivate)); -} - -static void -xed_plugin_loader_python_class_finalize (XedPluginLoaderPythonClass *klass) -{ -} - -static void -destroy_python_info (PythonInfo *info) -{ - PyGILState_STATE state = pyg_gil_state_ensure (); - Py_XDECREF (info->type); - pyg_gil_state_release (state); - - g_free (info->path); - g_free (info); -} - -static void -xed_plugin_loader_python_init (XedPluginLoaderPython *self) -{ - self->priv = XED_PLUGIN_LOADER_PYTHON_GET_PRIVATE (self); - - /* initialize python interpreter */ - xed_python_init (self); - - /* loaded_plugins maps XedPluginInfo to a PythonInfo */ - self->priv->loaded_plugins = g_hash_table_new_full (g_direct_hash, - g_direct_equal, - NULL, - (GDestroyNotify)destroy_python_info); -} - -XedPluginLoaderPython * -xed_plugin_loader_python_new () -{ - GObject *loader = g_object_new (XED_TYPE_PLUGIN_LOADER_PYTHON, NULL); - - return XED_PLUGIN_LOADER_PYTHON (loader); -} - diff --git a/plugin-loaders/python/xed-plugin-loader-python.h b/plugin-loaders/python/xed-plugin-loader-python.h deleted file mode 100644 index b6c3afe..0000000 --- a/plugin-loaders/python/xed-plugin-loader-python.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * xed-plugin-loader-python.h - * This file is part of xed - * - * Copyright (C) 2008 - Jesse van den Kieboom - * - * 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 St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __XED_PLUGIN_LOADER_PYTHON_H__ -#define __XED_PLUGIN_LOADER_PYTHON_H__ - -#include - -G_BEGIN_DECLS - -#define XED_TYPE_PLUGIN_LOADER_PYTHON (xed_plugin_loader_python_get_type ()) -#define XED_PLUGIN_LOADER_PYTHON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_PLUGIN_LOADER_PYTHON, XedPluginLoaderPython)) -#define XED_PLUGIN_LOADER_PYTHON_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_PLUGIN_LOADER_PYTHON, XedPluginLoaderPython const)) -#define XED_PLUGIN_LOADER_PYTHON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_PLUGIN_LOADER_PYTHON, XedPluginLoaderPythonClass)) -#define XED_IS_PLUGIN_LOADER_PYTHON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_PLUGIN_LOADER_PYTHON)) -#define XED_IS_PLUGIN_LOADER_PYTHON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_PLUGIN_LOADER_PYTHON)) -#define XED_PLUGIN_LOADER_PYTHON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_PLUGIN_LOADER_PYTHON, XedPluginLoaderPythonClass)) - -typedef struct _XedPluginLoaderPython XedPluginLoaderPython; -typedef struct _XedPluginLoaderPythonClass XedPluginLoaderPythonClass; -typedef struct _XedPluginLoaderPythonPrivate XedPluginLoaderPythonPrivate; - -struct _XedPluginLoaderPython { - GObject parent; - - XedPluginLoaderPythonPrivate *priv; -}; - -struct _XedPluginLoaderPythonClass { - GObjectClass parent_class; -}; - -GType xed_plugin_loader_python_get_type (void) G_GNUC_CONST; -XedPluginLoaderPython *xed_plugin_loader_python_new(void); - -/* All the loaders must implement this function */ -G_MODULE_EXPORT GType register_xed_plugin_loader (GTypeModule * module); - -G_END_DECLS - -#endif /* __XED_PLUGIN_LOADER_PYTHON_H__ */ - diff --git a/plugin-loaders/python/xed-plugin-python.c b/plugin-loaders/python/xed-plugin-python.c deleted file mode 100644 index 2700d83..0000000 --- a/plugin-loaders/python/xed-plugin-python.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * xed-plugin-python.c - * This file is part of xed - * - * Copyright (C) 2005 Raphael Slinckx - * Copyright (C) 2008 Jesse van den Kieboom - * - * 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 St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include - -#include "xed-plugin-python.h" - -#include -#include -#include -#include - -#define XED_PLUGIN_PYTHON_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_PLUGIN_PYTHON, XedPluginPythonPrivate)) - -static GObjectClass *parent_class; - -struct _XedPluginPythonPrivate -{ - PyObject *instance; -}; - -static void xed_plugin_python_class_init (XedPluginPythonClass *klass); -static void xed_plugin_python_init (XedPluginPython *plugin); - -G_DEFINE_TYPE (XedPluginPython, xed_plugin_python, XED_TYPE_PLUGIN) - -static PyObject * -call_python_method (XedPluginPythonPrivate *priv, - XedWindow *window, - gchar *method) -{ - PyObject *py_ret = NULL; - - g_return_val_if_fail (PyObject_HasAttrString (priv->instance, method), NULL); - - if (window == NULL) - { - py_ret = PyObject_CallMethod (priv->instance, - method, - NULL); - } - else - { - py_ret = PyObject_CallMethod (priv->instance, - method, - "(N)", - pygobject_new (G_OBJECT (window))); - } - - if (!py_ret) - PyErr_Print (); - - return py_ret; -} - -static gboolean -check_py_object_is_gtk_widget (PyObject *py_obj) -{ - static PyTypeObject *_PyGtkWidget_Type = NULL; - - if (_PyGtkWidget_Type == NULL) - { - PyObject *module; - - if ((module = PyImport_ImportModule ("gtk"))) - { - PyObject *moddict = PyModule_GetDict (module); - _PyGtkWidget_Type = (PyTypeObject *) PyDict_GetItemString (moddict, "Widget"); - } - - if (_PyGtkWidget_Type == NULL) - { - PyErr_SetString(PyExc_TypeError, "could not find Python gtk widget type"); - PyErr_Print(); - - return FALSE; - } - } - - return PyObject_TypeCheck (py_obj, _PyGtkWidget_Type) ? TRUE : FALSE; -} - -static void -impl_update_ui (XedPlugin *plugin, - XedWindow *window) -{ - PyGILState_STATE state = pyg_gil_state_ensure (); - XedPluginPythonPrivate *priv = XED_PLUGIN_PYTHON(plugin)->priv; - - if (PyObject_HasAttrString (priv->instance, "update_ui")) - { - PyObject *py_ret = call_python_method (priv, window, "update_ui"); - - if (py_ret) - { - Py_XDECREF (py_ret); - } - } - else - XED_PLUGIN_CLASS (parent_class)->update_ui (plugin, window); - - pyg_gil_state_release (state); -} - -static void -impl_deactivate (XedPlugin *plugin, - XedWindow *window) -{ - PyGILState_STATE state = pyg_gil_state_ensure (); - XedPluginPythonPrivate *priv = XED_PLUGIN_PYTHON(plugin)->priv; - - if (PyObject_HasAttrString (priv->instance, "deactivate")) - { - PyObject *py_ret = call_python_method (priv, window, "deactivate"); - - if (py_ret) - { - Py_XDECREF (py_ret); - } - } - else - XED_PLUGIN_CLASS (parent_class)->deactivate (plugin, window); - - pyg_gil_state_release (state); -} - -static void -impl_activate (XedPlugin *plugin, - XedWindow *window) -{ - PyGILState_STATE state = pyg_gil_state_ensure (); - XedPluginPythonPrivate *priv = XED_PLUGIN_PYTHON(plugin)->priv; - - if (PyObject_HasAttrString (priv->instance, "activate")) - { - PyObject *py_ret = call_python_method (priv, window, "activate"); - - if (py_ret) - { - Py_XDECREF (py_ret); - } - } - else - XED_PLUGIN_CLASS (parent_class)->activate (plugin, window); - - pyg_gil_state_release (state); -} - -static GtkWidget * -impl_create_configure_dialog (XedPlugin *plugin) -{ - PyGILState_STATE state = pyg_gil_state_ensure (); - XedPluginPythonPrivate *priv = XED_PLUGIN_PYTHON(plugin)->priv; - GtkWidget *ret = NULL; - - if (PyObject_HasAttrString (priv->instance, "create_configure_dialog")) - { - PyObject *py_ret = call_python_method (priv, NULL, "create_configure_dialog"); - - if (py_ret) - { - if (check_py_object_is_gtk_widget (py_ret)) - { - ret = GTK_WIDGET (pygobject_get (py_ret)); - g_object_ref (ret); - } - else - { - PyErr_SetString(PyExc_TypeError, "return value for create_configure_dialog is not a GtkWidget"); - PyErr_Print(); - } - - Py_DECREF (py_ret); - } - } - else - ret = XED_PLUGIN_CLASS (parent_class)->create_configure_dialog (plugin); - - pyg_gil_state_release (state); - - return ret; -} - -static gboolean -impl_is_configurable (XedPlugin *plugin) -{ - PyGILState_STATE state = pyg_gil_state_ensure (); - XedPluginPythonPrivate *priv = XED_PLUGIN_PYTHON(plugin)->priv; - PyObject *dict = priv->instance->ob_type->tp_dict; - gboolean result; - - if (dict == NULL) - result = FALSE; - else if (!PyDict_Check(dict)) - result = FALSE; - else - result = PyDict_GetItemString(dict, "create_configure_dialog") != NULL; - - pyg_gil_state_release (state); - - return result; -} - -void -_xed_plugin_python_set_instance (XedPluginPython *plugin, - PyObject *instance) -{ - PyGILState_STATE state = pyg_gil_state_ensure (); - - /* we don't increment the instance here because we are the instance, - when it dies, we also die */ - plugin->priv->instance = instance; - pyg_gil_state_release (state); -} - -PyObject * -_xed_plugin_python_get_instance (XedPluginPython *plugin) -{ - return plugin->priv->instance; -} - -static void -xed_plugin_python_init (XedPluginPython *plugin) -{ - plugin->priv = XED_PLUGIN_PYTHON_GET_PRIVATE(plugin); - - xed_debug_message (DEBUG_PLUGINS, "Creating Python plugin instance"); - plugin->priv->instance = 0; -} - -static void -xed_plugin_python_finalize (GObject *object) -{ - PyGILState_STATE state; - - xed_debug_message (DEBUG_PLUGINS, "Finalizing Python plugin instance"); - - state = pyg_gil_state_ensure (); - Py_XDECREF (XED_PLUGIN_PYTHON(object)->priv->instance); - pyg_gil_state_release (state); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -xed_plugin_python_class_init (XedPluginPythonClass *klass) -{ - XedPluginClass *plugin_class = XED_PLUGIN_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - g_type_class_add_private (klass, sizeof (XedPluginPythonPrivate)); - G_OBJECT_CLASS (klass)->finalize = xed_plugin_python_finalize; - - plugin_class->activate = impl_activate; - plugin_class->deactivate = impl_deactivate; - plugin_class->update_ui = impl_update_ui; - plugin_class->create_configure_dialog = impl_create_configure_dialog; - plugin_class->is_configurable = impl_is_configurable; -} - diff --git a/plugin-loaders/python/xed-plugin-python.h b/plugin-loaders/python/xed-plugin-python.h deleted file mode 100644 index 96a9eec..0000000 --- a/plugin-loaders/python/xed-plugin-python.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * xed-plugin-python.h - * This file is part of xed - * - * Copyright (C) 2005 - Raphael Slinckx - * Copyright (C) 2008 - Jesse van den Kieboom - * - * 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 St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __XED_PLUGIN_PYTHON_H__ -#define __XED_PLUGIN_PYTHON_H__ - -#define NO_IMPORT_PYGOBJECT - -#include -#include - -#include - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define XED_TYPE_PLUGIN_PYTHON (xed_plugin_python_get_type()) -#define XED_PLUGIN_PYTHON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_PLUGIN_PYTHON, XedPluginPython)) -#define XED_PLUGIN_PYTHON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_PLUGIN_PYTHON, XedPluginPythonClass)) -#define XED_IS_PLUGIN_PYTHON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_PLUGIN_PYTHON)) -#define XED_IS_PLUGIN_PYTHON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_PLUGIN_PYTHON)) -#define XED_PLUGIN_PYTHON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_PLUGIN_PYTHON, XedPluginPythonClass)) - -/* Private structure type */ -typedef struct _XedPluginPythonPrivate XedPluginPythonPrivate; - -/* - * Main object structure - */ -typedef struct _XedPluginPython XedPluginPython; - -struct _XedPluginPython -{ - XedPlugin parent; - - /*< private > */ - XedPluginPythonPrivate *priv; -}; - -/* - * Class definition - */ -typedef struct _XedPluginPythonClass XedPluginPythonClass; - -struct _XedPluginPythonClass -{ - XedPluginClass parent_class; -}; - -/* - * Public methods - */ -GType xed_plugin_python_get_type (void) G_GNUC_CONST; - - -/* - * Private methods - */ -void _xed_plugin_python_set_instance (XedPluginPython *plugin, - PyObject *instance); -PyObject *_xed_plugin_python_get_instance (XedPluginPython *plugin); - -G_END_DECLS - -#endif /* __XED_PLUGIN_PYTHON_H__ */ - diff --git a/tools/plugin_template/xed-plugin.desktop.in b/tools/plugin_template/xed-plugin.desktop.in index df3a5cd..7b54a27 100644 --- a/tools/plugin_template/xed-plugin.desktop.in +++ b/tools/plugin_template/xed-plugin.desktop.in @@ -1,7 +1,4 @@ [Xed Plugin] -##ifdef WITH_PYTHON -Loader=python -##endif Module=##(PLUGIN_MODULE) IAge=2 _Name=##(PLUGIN_NAME) diff --git a/xed/xed-plugin-info-priv.h b/xed/xed-plugin-info-priv.h index 23f799f..79d8742 100644 --- a/xed/xed-plugin-info-priv.h +++ b/xed/xed-plugin-info-priv.h @@ -2,7 +2,7 @@ * xed-plugin-info-priv.h * This file is part of xed * - * Copyright (C) 2002-2005 - Paolo Maggi + * Copyright (C) 2002-2005 - Paolo Maggi * Copyright (C) 2007 - Paolo Maggi, Steve Frécinaux * * This program is free software; you can redistribute it and/or modify @@ -17,10 +17,10 @@ * * 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 St, Fifth Floor, - * Boston, MA 02110-1301, USA. + * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ - + /* * Modified by the xed Team, 2002-2007. See the AUTHORS file for a * list of people on the xed Team. @@ -55,8 +55,7 @@ struct _XedPluginInfo gchar *version; /* A plugin is unavailable if it is not possible to activate it - due to an error loading the plugin module (e.g. for Python plugins - when the interpreter has not been correctly initializated) */ + due to an error loading the plugin module */ gint available : 1; };