summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am48
-rw-r--r--src/Makefile.in643
-rw-r--r--src/caja-python-object.c615
-rw-r--r--src/caja-python-object.h50
-rw-r--r--src/caja-python.c403
-rw-r--r--src/caja-python.h79
-rw-r--r--src/caja.defs332
-rw-r--r--src/caja.override139
-rw-r--r--src/cajamodule.c55
9 files changed, 2364 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..998069f
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,48 @@
+INCLUDES = \
+ -DG_LOG_DOMAIN=\"Caja-Python\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBDIR=\"$(libdir)\" \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ $(CAJA_PYTHON_CFLAGS) \
+ -DPYTHON_VERSION=\"$(PYTHON_VERSION)\" \
+ -DPY_LIB_LOC="\"$(PYTHON_LIB_LOC)\"" \
+ $(PYTHON_INCLUDES)
+
+caja_extensiondir=$(CAJA_EXTENSION_DIR)
+
+caja_extension_LTLIBRARIES = libcaja-python.la
+
+libcaja_python_la_SOURCES = \
+ caja-python.c \
+ caja-python.h \
+ caja-python-object.c \
+ caja-python-object.h
+
+libcaja_python_la_LDFLAGS = -module -avoid-version
+libcaja_python_la_LIBADD = $(CAJA_PYTHON_LIBS) $(PYTHON_LIBS)
+
+pyexec_LTLIBRARIES = caja.la
+pyexecdir = $(CAJA_LIBDIR)/caja-python
+
+caja_la_LDFLAGS = -module -avoid-version -export-symbols-regex initcaja
+caja_la_LIBADD = $(CAJA_PYTHON_LIBS)
+caja_la_SOURCES = cajamodule.c
+nodist_caja_la_SOURCES = caja.c
+caja.c: caja.defs caja.override
+CLEANFILES = caja.c
+EXTRA_DIST = caja.override caja.defs
+
+.defs.c:
+ (cd $(srcdir)\
+ && $(PYGTK_CODEGEN) \
+ --register $(PYGTK_DEFSDIR)/pango-types.defs \
+ --register $(PYGTK_DEFSDIR)/gdk-types.defs \
+ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
+ --register $(PYGOBJECT_DEFSDIR)/gio-types.defs \
+ --register $(PYGOBJECT_DEFSDIR)/unix-types.defs \
+ --override $*.override \
+ --prefix py$* $*.defs) > gen-$*.c \
+ && cp gen-$*.c $*.c \
+ && rm -f gen-$*.c
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..09b964c
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,643 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/gtk-doc.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/python.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(caja_extensiondir)" \
+ "$(DESTDIR)$(pyexecdir)"
+LTLIBRARIES = $(caja_extension_LTLIBRARIES) $(pyexec_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+caja_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_caja_la_OBJECTS = cajamodule.lo
+nodist_caja_la_OBJECTS = caja.lo
+caja_la_OBJECTS = $(am_caja_la_OBJECTS) $(nodist_caja_la_OBJECTS)
+caja_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(caja_la_LDFLAGS) \
+ $(LDFLAGS) -o $@
+libcaja_python_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_libcaja_python_la_OBJECTS = caja-python.lo caja-python-object.lo
+libcaja_python_la_OBJECTS = $(am_libcaja_python_la_OBJECTS)
+libcaja_python_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libcaja_python_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(caja_la_SOURCES) $(nodist_caja_la_SOURCES) \
+ $(libcaja_python_la_SOURCES)
+DIST_SOURCES = $(caja_la_SOURCES) $(libcaja_python_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CAJA_EXTENSION_DIR = @CAJA_EXTENSION_DIR@
+CAJA_LIBDIR = @CAJA_LIBDIR@
+CAJA_PYTHON_CFLAGS = @CAJA_PYTHON_CFLAGS@
+CAJA_PYTHON_LIBS = @CAJA_PYTHON_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+HAVE_PKGCONFIG = @HAVE_PKGCONFIG@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PYGOBJECT_DATADIR = @PYGOBJECT_DATADIR@
+PYGOBJECT_DEFSDIR = @PYGOBJECT_DEFSDIR@
+PYGOBJECT_FIXXREF = @PYGOBJECT_FIXXREF@
+PYGOBJECT_PYGDOCS = @PYGOBJECT_PYGDOCS@
+PYGTK_CODEGEN = @PYGTK_CODEGEN@
+PYGTK_DEFSDIR = @PYGTK_DEFSDIR@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_LIB_LOC = @PYTHON_LIB_LOC@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XSLTPROC = @XSLTPROC@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libdirsuffix = @libdirsuffix@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = $(CAJA_LIBDIR)/caja-python
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = \
+ -DG_LOG_DOMAIN=\"Caja-Python\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBDIR=\"$(libdir)\" \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ $(CAJA_PYTHON_CFLAGS) \
+ -DPYTHON_VERSION=\"$(PYTHON_VERSION)\" \
+ -DPY_LIB_LOC="\"$(PYTHON_LIB_LOC)\"" \
+ $(PYTHON_INCLUDES)
+
+caja_extensiondir = $(CAJA_EXTENSION_DIR)
+caja_extension_LTLIBRARIES = libcaja-python.la
+libcaja_python_la_SOURCES = \
+ caja-python.c \
+ caja-python.h \
+ caja-python-object.c \
+ caja-python-object.h
+
+libcaja_python_la_LDFLAGS = -module -avoid-version
+libcaja_python_la_LIBADD = $(CAJA_PYTHON_LIBS) $(PYTHON_LIBS)
+pyexec_LTLIBRARIES = caja.la
+caja_la_LDFLAGS = -module -avoid-version -export-symbols-regex initcaja
+caja_la_LIBADD = $(CAJA_PYTHON_LIBS)
+caja_la_SOURCES = cajamodule.c
+nodist_caja_la_SOURCES = caja.c
+CLEANFILES = caja.c
+EXTRA_DIST = caja.override caja.defs
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .defs .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-caja_extensionLTLIBRARIES: $(caja_extension_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(caja_extensiondir)" || $(MKDIR_P) "$(DESTDIR)$(caja_extensiondir)"
+ @list='$(caja_extension_LTLIBRARIES)'; test -n "$(caja_extensiondir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(caja_extensiondir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(caja_extensiondir)"; \
+ }
+
+uninstall-caja_extensionLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(caja_extension_LTLIBRARIES)'; test -n "$(caja_extensiondir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(caja_extensiondir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(caja_extensiondir)/$$f"; \
+ done
+
+clean-caja_extensionLTLIBRARIES:
+ -test -z "$(caja_extension_LTLIBRARIES)" || rm -f $(caja_extension_LTLIBRARIES)
+ @list='$(caja_extension_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+install-pyexecLTLIBRARIES: $(pyexec_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pyexecdir)" || $(MKDIR_P) "$(DESTDIR)$(pyexecdir)"
+ @list='$(pyexec_LTLIBRARIES)'; test -n "$(pyexecdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pyexecdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pyexecdir)"; \
+ }
+
+uninstall-pyexecLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pyexec_LTLIBRARIES)'; test -n "$(pyexecdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pyexecdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pyexecdir)/$$f"; \
+ done
+
+clean-pyexecLTLIBRARIES:
+ -test -z "$(pyexec_LTLIBRARIES)" || rm -f $(pyexec_LTLIBRARIES)
+ @list='$(pyexec_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+caja.la: $(caja_la_OBJECTS) $(caja_la_DEPENDENCIES)
+ $(caja_la_LINK) -rpath $(pyexecdir) $(caja_la_OBJECTS) $(caja_la_LIBADD) $(LIBS)
+libcaja-python.la: $(libcaja_python_la_OBJECTS) $(libcaja_python_la_DEPENDENCIES)
+ $(libcaja_python_la_LINK) -rpath $(caja_extensiondir) $(libcaja_python_la_OBJECTS) $(libcaja_python_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caja-python-object.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caja-python.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/caja.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cajamodule.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(caja_extensiondir)" "$(DESTDIR)$(pyexecdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-caja_extensionLTLIBRARIES clean-generic clean-libtool \
+ clean-pyexecLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-caja_extensionLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pyexecLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-caja_extensionLTLIBRARIES \
+ uninstall-pyexecLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean \
+ clean-caja_extensionLTLIBRARIES clean-generic clean-libtool \
+ clean-pyexecLTLIBRARIES ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-caja_extensionLTLIBRARIES install-data install-data-am \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-pdf install-pdf-am install-ps \
+ install-ps-am install-pyexecLTLIBRARIES install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am \
+ uninstall-caja_extensionLTLIBRARIES \
+ uninstall-pyexecLTLIBRARIES
+
+caja.c: caja.defs caja.override
+
+.defs.c:
+ (cd $(srcdir)\
+ && $(PYGTK_CODEGEN) \
+ --register $(PYGTK_DEFSDIR)/pango-types.defs \
+ --register $(PYGTK_DEFSDIR)/gdk-types.defs \
+ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
+ --register $(PYGOBJECT_DEFSDIR)/gio-types.defs \
+ --register $(PYGOBJECT_DEFSDIR)/unix-types.defs \
+ --override $*.override \
+ --prefix py$* $*.defs) > gen-$*.c \
+ && cp gen-$*.c $*.c \
+ && rm -f gen-$*.c
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/caja-python-object.c b/src/caja-python-object.c
new file mode 100644
index 0000000..14667bb
--- /dev/null
+++ b/src/caja-python-object.c
@@ -0,0 +1,615 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) 2004 Novell, Inc.
+ *
+ * This library 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 library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Dave Camp <[email protected]>
+ *
+ */
+
+#include <config.h>
+
+#include "caja-python-object.h"
+#include "caja-python.h"
+
+#include <libcaja-extension/caja-extension-types.h>
+
+#include <pygobject.h>
+
+/* Caja extension headers */
+#include <libcaja-extension/caja-file-info.h>
+#include <libcaja-extension/caja-info-provider.h>
+#include <libcaja-extension/caja-column-provider.h>
+#include <libcaja-extension/caja-location-widget-provider.h>
+#include <libcaja-extension/caja-menu-item.h>
+#include <libcaja-extension/caja-menu-provider.h>
+#include <libcaja-extension/caja-property-page-provider.h>
+
+#include <string.h>
+
+#define METHOD_PREFIX ""
+
+static GObjectClass *parent_class;
+
+/* These macros assumes the following things:
+ * a METHOD_NAME is defined with is a string
+ * a goto label called beach
+ * the return value is called ret
+ */
+
+#define CHECK_METHOD_NAME(self) \
+ if (!PyObject_HasAttrString(self, METHOD_NAME)) \
+ goto beach;
+
+#define CHECK_OBJECT(object) \
+ if (object->instance == NULL) \
+ { \
+ g_object_unref (object); \
+ goto beach; \
+ } \
+
+#define CONVERT_LIST(py_files, files) \
+ { \
+ GList *l; \
+ py_files = PyList_New(0); \
+ for (l = files; l; l = l->next) \
+ { \
+ PyList_Append(py_files, pygobject_new((GObject*)l->data)); \
+ } \
+ }
+
+#define HANDLE_RETVAL(py_ret) \
+ if (!py_ret) \
+ { \
+ PyErr_Print(); \
+ goto beach; \
+ } \
+ else if (py_ret == Py_None) \
+ { \
+ goto beach; \
+ }
+
+#define HANDLE_LIST(py_ret, type, type_name) \
+ { \
+ Py_ssize_t i = 0; \
+ if (!PySequence_Check(py_ret) || PyString_Check(py_ret)) \
+ { \
+ PyErr_SetString(PyExc_TypeError, \
+ METHOD_NAME " must return a sequence"); \
+ goto beach; \
+ } \
+ for (i = 0; i < PySequence_Size (py_ret); i++) \
+ { \
+ PyGObject *py_item; \
+ py_item = (PyGObject*)PySequence_GetItem (py_ret, i); \
+ if (!pygobject_check(py_item, &Py##type##_Type)) \
+ { \
+ PyErr_SetString(PyExc_TypeError, \
+ METHOD_NAME \
+ " must return a sequence of " \
+ type_name); \
+ goto beach; \
+ } \
+ ret = g_list_append (ret, (type*) g_object_ref(py_item->obj)); \
+ Py_DECREF(py_item); \
+ } \
+ }
+
+
+static void
+free_pygobject_data(gpointer data, gpointer user_data)
+{
+ /* Some CajaFile objects are cached and not freed until caja
+ itself is closed. Since PyGObject stores data that must be freed by
+ the Python interpreter, we must always free it before the interpreter
+ is finalized. */
+ g_object_set_data((GObject *)data, "PyGObject::instance-data", NULL);
+}
+
+static void
+free_pygobject_data_list(GList *list)
+{
+ if (list == NULL)
+ return;
+
+ g_list_foreach(list, (GFunc)free_pygobject_data, NULL);
+}
+
+#define METHOD_NAME "get_property_pages"
+static GList *
+caja_python_object_get_property_pages (CajaPropertyPageProvider *provider,
+ GList *files)
+{
+ CajaPythonObject *object = (CajaPythonObject*)provider;
+ PyObject *py_files, *py_ret = NULL;
+ GList *ret = NULL;
+ PyGILState_STATE state = pyg_gil_state_ensure();
+
+ debug_enter();
+
+ CHECK_OBJECT(object);
+ CHECK_METHOD_NAME(object->instance);
+
+ CONVERT_LIST(py_files, files);
+
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
+ "(N)", py_files);
+ HANDLE_RETVAL(py_ret);
+
+ HANDLE_LIST(py_ret, CajaPropertyPage, "caja.PropertyPage");
+
+ beach:
+ Py_XDECREF(py_ret);
+ pyg_gil_state_release(state);
+ return ret;
+}
+#undef METHOD_NAME
+
+
+static void
+caja_python_object_property_page_provider_iface_init (CajaPropertyPageProviderIface *iface)
+{
+ iface->get_pages = caja_python_object_get_property_pages;
+}
+
+#define METHOD_NAME "get_widget"
+static GtkWidget *
+caja_python_object_get_widget (CajaLocationWidgetProvider *provider,
+ const char *uri,
+ GtkWidget *window)
+{
+ CajaPythonObject *object = (CajaPythonObject*)provider;
+ GtkWidget *ret = NULL;
+ PyObject *py_ret = NULL;
+ PyGObject *py_ret_gobj;
+ PyObject *py_uri = NULL;
+ PyGILState_STATE state = pyg_gil_state_ensure();
+
+ debug_enter();
+
+ CHECK_OBJECT(object);
+ CHECK_METHOD_NAME(object->instance);
+
+ py_uri = PyString_FromString(uri);
+
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
+ "(NN)", py_uri,
+ pygobject_new((GObject *)window));
+ HANDLE_RETVAL(py_ret);
+
+ py_ret_gobj = (PyGObject *)py_ret;
+ if (!pygobject_check(py_ret_gobj, &PyGtkWidget_Type))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ METHOD_NAME "should return a gtk.Widget");
+ goto beach;
+ }
+ ret = (GtkWidget *)g_object_ref(py_ret_gobj->obj);
+
+ beach:
+ Py_XDECREF(py_ret);
+ pyg_gil_state_release(state);
+ return ret;
+}
+#undef METHOD_NAME
+
+static void
+caja_python_object_location_widget_provider_iface_init (CajaLocationWidgetProviderIface *iface)
+{
+ iface->get_widget = caja_python_object_get_widget;
+}
+
+#define METHOD_NAME "get_file_items"
+static GList *
+caja_python_object_get_file_items (CajaMenuProvider *provider,
+ GtkWidget *window,
+ GList *files)
+{
+ CajaPythonObject *object = (CajaPythonObject*)provider;
+ GList *ret = NULL;
+ PyObject *py_ret = NULL, *py_files;
+ PyGILState_STATE state = pyg_gil_state_ensure();
+ PyObject *provider_version = NULL;
+
+ debug_enter();
+
+ CHECK_OBJECT(object);
+
+ if (PyObject_HasAttrString(object->instance, "get_file_items_full"))
+ {
+ CONVERT_LIST(py_files, files);
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX "get_file_items_full",
+ "(NNN)",
+ pygobject_new((GObject *)provider),
+ pygobject_new((GObject *)window),
+ py_files);
+ }
+ else if (PyObject_HasAttrString(object->instance, "get_file_items"))
+ {
+ CONVERT_LIST(py_files, files);
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
+ "(NN)",
+ pygobject_new((GObject *)window),
+ py_files);
+ }
+ else
+ {
+ goto beach;
+ }
+
+ HANDLE_RETVAL(py_ret);
+
+ HANDLE_LIST(py_ret, CajaMenuItem, "caja.MenuItem");
+
+ beach:
+ free_pygobject_data_list(files);
+ Py_XDECREF(py_ret);
+ pyg_gil_state_release(state);
+ return ret;
+}
+#undef METHOD_NAME
+
+#define METHOD_NAME "get_background_items"
+static GList *
+caja_python_object_get_background_items (CajaMenuProvider *provider,
+ GtkWidget *window,
+ CajaFileInfo *file)
+{
+ CajaPythonObject *object = (CajaPythonObject*)provider;
+ GList *ret = NULL;
+ PyObject *py_ret = NULL;
+ PyGILState_STATE state = pyg_gil_state_ensure();
+
+ debug_enter();
+
+ CHECK_OBJECT(object);
+
+ if (PyObject_HasAttrString(object->instance, "get_background_items_full"))
+ {
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX "get_background_items_full",
+ "(NNN)",
+ pygobject_new((GObject *)provider),
+ pygobject_new((GObject *)window),
+ pygobject_new((GObject *)file));
+ }
+ else if (PyObject_HasAttrString(object->instance, "get_background_items"))
+ {
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
+ "(NN)",
+ pygobject_new((GObject *)window),
+ pygobject_new((GObject *)file));
+ }
+ else
+ {
+ goto beach;
+ }
+
+ HANDLE_RETVAL(py_ret);
+
+ HANDLE_LIST(py_ret, CajaMenuItem, "caja.MenuItem");
+
+ beach:
+ free_pygobject_data(file, NULL);
+ Py_XDECREF(py_ret);
+ pyg_gil_state_release(state);
+ return ret;
+}
+#undef METHOD_NAME
+
+#define METHOD_NAME "get_toolbar_items"
+static GList *
+caja_python_object_get_toolbar_items (CajaMenuProvider *provider,
+ GtkWidget *window,
+ CajaFileInfo *file)
+{
+ CajaPythonObject *object = (CajaPythonObject*)provider;
+ GList *ret = NULL;
+ PyObject *py_ret = NULL;
+ PyGILState_STATE state = pyg_gil_state_ensure();
+
+ debug_enter();
+
+ CHECK_OBJECT(object);
+
+ if (PyObject_HasAttrString(object->instance, "get_toolbar_items_full"))
+ {
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX "get_toolbar_items_full",
+ "(NNN)",
+ pygobject_new((GObject *)provider),
+ pygobject_new((GObject *)window),
+ pygobject_new((GObject *)file));
+ }
+ else if (PyObject_HasAttrString(object->instance, "get_toolbar_items"))
+ {
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
+ "(NN)",
+ pygobject_new((GObject *)window),
+ pygobject_new((GObject *)file));
+ }
+ else
+ {
+ goto beach;
+ }
+
+ HANDLE_RETVAL(py_ret);
+
+ HANDLE_LIST(py_ret, CajaMenuItem, "caja.MenuItem");
+
+ beach:
+ free_pygobject_data(file, NULL);
+ Py_XDECREF(py_ret);
+ pyg_gil_state_release(state);
+ return ret;
+}
+#undef METHOD_NAME
+
+static void
+caja_python_object_menu_provider_iface_init (CajaMenuProviderIface *iface)
+{
+ iface->get_background_items = caja_python_object_get_background_items;
+ iface->get_toolbar_items = caja_python_object_get_toolbar_items;
+ iface->get_file_items = caja_python_object_get_file_items;
+}
+
+#define METHOD_NAME "get_columns"
+static GList *
+caja_python_object_get_columns (CajaColumnProvider *provider)
+{
+ CajaPythonObject *object = (CajaPythonObject*)provider;
+ GList *ret = NULL;
+ PyObject *py_ret;
+ PyGILState_STATE state = pyg_gil_state_ensure(); \
+
+ debug_enter();
+
+ CHECK_OBJECT(object);
+ CHECK_METHOD_NAME(object->instance);
+
+ py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
+ NULL);
+
+ HANDLE_RETVAL(py_ret);
+
+ HANDLE_LIST(py_ret, CajaColumn, "caja.Column");
+
+ beach:
+ Py_XDECREF(py_ret);
+ pyg_gil_state_release(state);
+ return ret;
+}
+#undef METHOD_NAME
+
+static void
+caja_python_object_column_provider_iface_init (CajaColumnProviderIface *iface)
+{
+ iface->get_columns = caja_python_object_get_columns;
+}
+
+
+#define METHOD_NAME "cancel_update"
+static void
+caja_python_object_cancel_update (CajaInfoProvider *provider,
+ CajaOperationHandle *handle)
+{
+ CajaPythonObject *object = (CajaPythonObject*)provider;
+ PyGILState_STATE state = pyg_gil_state_ensure();
+
+ debug_enter();
+
+ CHECK_OBJECT(object);
+ CHECK_METHOD_NAME(object->instance);
+
+ PyObject_CallMethod(object->instance,
+ METHOD_PREFIX METHOD_NAME, "(NN)",
+ pygobject_new((GObject*)provider),
+ pyg_pointer_new(G_TYPE_POINTER, handle));
+
+ beach:
+ pyg_gil_state_release(state);
+}
+#undef METHOD_NAME
+
+#define METHOD_NAME "update_file_info"
+static CajaOperationResult
+caja_python_object_update_file_info (CajaInfoProvider *provider,
+ CajaFile *file,
+ GClosure *update_complete,
+ CajaOperationHandle **handle)
+{
+ CajaPythonObject *object = (CajaPythonObject*)provider;
+ CajaOperationResult ret = CAJA_OPERATION_COMPLETE;
+ PyObject *py_ret = NULL;
+ PyGILState_STATE state = pyg_gil_state_ensure(); \
+
+ debug_enter();
+
+ CHECK_OBJECT(object);
+
+ if (PyObject_HasAttrString(object->instance, "update_file_info_full"))
+ {
+ py_ret = PyObject_CallMethod(object->instance,
+ METHOD_PREFIX "update_file_info_full", "(NNNN)",
+ pygobject_new((GObject*)provider),
+ pyg_pointer_new(G_TYPE_POINTER, *handle),
+ pyg_boxed_new(G_TYPE_CLOSURE, update_complete, TRUE, TRUE),
+ pygobject_new((GObject*)file));
+ }
+ else if (PyObject_HasAttrString(object->instance, "update_file_info"))
+ {
+ py_ret = PyObject_CallMethod(object->instance,
+ METHOD_PREFIX METHOD_NAME, "(N)",
+ pygobject_new((GObject*)file));
+ }
+ else
+ {
+ goto beach;
+ }
+
+ HANDLE_RETVAL(py_ret);
+
+ if (!PyInt_Check(py_ret))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ METHOD_NAME " must return None or a int");
+ goto beach;
+ }
+
+ ret = PyInt_AsLong(py_ret);
+
+ beach:
+ free_pygobject_data(file, NULL);
+ Py_XDECREF(py_ret);
+ pyg_gil_state_release(state);
+ return ret;
+}
+#undef METHOD_NAME
+
+static void
+caja_python_object_info_provider_iface_init (CajaInfoProviderIface *iface)
+{
+ iface->cancel_update = caja_python_object_cancel_update;
+ iface->update_file_info = caja_python_object_update_file_info;
+}
+
+static void
+caja_python_object_instance_init (CajaPythonObject *object)
+{
+ CajaPythonObjectClass *class;
+ debug_enter();
+
+ class = (CajaPythonObjectClass*)(((GTypeInstance*)object)->g_class);
+
+ object->instance = PyObject_CallObject(class->type, NULL);
+ if (object->instance == NULL)
+ PyErr_Print();
+}
+
+static void
+caja_python_object_finalize (GObject *object)
+{
+ debug_enter();
+
+ if (((CajaPythonObject *)object)->instance != NULL)
+ Py_DECREF(((CajaPythonObject *)object)->instance);
+}
+
+static void
+caja_python_object_class_init (CajaPythonObjectClass *class,
+ gpointer class_data)
+{
+ debug_enter();
+
+ parent_class = g_type_class_peek_parent (class);
+
+ class->type = (PyObject*)class_data;
+
+ G_OBJECT_CLASS (class)->finalize = caja_python_object_finalize;
+}
+
+GType
+caja_python_object_get_type (GTypeModule *module,
+ PyObject *type)
+{
+ GTypeInfo *info;
+ const char *type_name;
+ GType gtype;
+
+ static const GInterfaceInfo property_page_provider_iface_info = {
+ (GInterfaceInitFunc) caja_python_object_property_page_provider_iface_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo location_widget_provider_iface_info = {
+ (GInterfaceInitFunc) caja_python_object_location_widget_provider_iface_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo menu_provider_iface_info = {
+ (GInterfaceInitFunc) caja_python_object_menu_provider_iface_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo column_provider_iface_info = {
+ (GInterfaceInitFunc) caja_python_object_column_provider_iface_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo info_provider_iface_info = {
+ (GInterfaceInitFunc) caja_python_object_info_provider_iface_init,
+ NULL,
+ NULL
+ };
+
+ debug_enter_args("type=%s", PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+ info = g_new0 (GTypeInfo, 1);
+
+ info->class_size = sizeof (CajaPythonObjectClass);
+ info->class_init = (GClassInitFunc)caja_python_object_class_init;
+ info->instance_size = sizeof (CajaPythonObject);
+ info->instance_init = (GInstanceInitFunc)caja_python_object_instance_init;
+
+ info->class_data = type;
+ Py_INCREF(type);
+
+ type_name = g_strdup_printf("%s+CajaPython",
+ PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+
+ gtype = g_type_module_register_type (module,
+ G_TYPE_OBJECT,
+ type_name,
+ info, 0);
+
+ if (PyObject_IsSubclass(type, (PyObject*)&PyCajaPropertyPageProvider_Type))
+ {
+ g_type_module_add_interface (module, gtype,
+ CAJA_TYPE_PROPERTY_PAGE_PROVIDER,
+ &property_page_provider_iface_info);
+ }
+
+ if (PyObject_IsSubclass(type, (PyObject*)&PyCajaLocationWidgetProvider_Type))
+ {
+ g_type_module_add_interface (module, gtype,
+ CAJA_TYPE_LOCATION_WIDGET_PROVIDER,
+ &location_widget_provider_iface_info);
+ }
+
+ if (PyObject_IsSubclass(type, (PyObject*)&PyCajaMenuProvider_Type))
+ {
+ g_type_module_add_interface (module, gtype,
+ CAJA_TYPE_MENU_PROVIDER,
+ &menu_provider_iface_info);
+ }
+
+ if (PyObject_IsSubclass(type, (PyObject*)&PyCajaColumnProvider_Type))
+ {
+ g_type_module_add_interface (module, gtype,
+ CAJA_TYPE_COLUMN_PROVIDER,
+ &column_provider_iface_info);
+ }
+
+ if (PyObject_IsSubclass(type, (PyObject*)&PyCajaInfoProvider_Type))
+ {
+ g_type_module_add_interface (module, gtype,
+ CAJA_TYPE_INFO_PROVIDER,
+ &info_provider_iface_info);
+ }
+
+ return gtype;
+}
diff --git a/src/caja-python-object.h b/src/caja-python-object.h
new file mode 100644
index 0000000..e1d7e74
--- /dev/null
+++ b/src/caja-python-object.h
@@ -0,0 +1,50 @@
+/*
+ * caja-python-object.h - Generation of wrapper objects for caja
+ * extension objects in python.
+ *
+ * Copyright (C) 2003 Novell, Inc.
+ *
+ * This library 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 library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Dave Camp <[email protected]>
+ *
+ */
+
+#ifndef CAJA_PYTHON_OBJECT_H
+#define CAJA_PYTHON_OBJECT_H
+
+#include <Python.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _CajaPythonObject CajaPythonObject;
+typedef struct _CajaPythonObjectClass CajaPythonObjectClass;
+
+struct _CajaPythonObject {
+ GObject parent_slot;
+ PyObject *instance;
+};
+
+struct _CajaPythonObjectClass {
+ GObjectClass parent_slot;
+ PyObject *type;
+};
+
+GType caja_python_object_get_type (GTypeModule *module, PyObject *type);
+
+G_END_DECLS
+
+#endif
diff --git a/src/caja-python.c b/src/caja-python.c
new file mode 100644
index 0000000..ac6d18b
--- /dev/null
+++ b/src/caja-python.c
@@ -0,0 +1,403 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * Copyright (C) 2004,2005 Johan Dahlin
+ *
+ * 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Python.h>
+#include <pygobject.h>
+#include <pygtk/pygtk.h>
+
+#include "caja-python.h"
+#include "caja-python-object.h"
+
+#include <libcaja-extension/caja-extension-types.h>
+
+static const GDebugKey caja_python_debug_keys[] = {
+ {"misc", CAJA_PYTHON_DEBUG_MISC},
+};
+static const guint caja_python_ndebug_keys = sizeof (caja_python_debug_keys) / sizeof (GDebugKey);
+CajaPythonDebug caja_python_debug;
+
+static gboolean caja_python_init_python(void);
+
+static GArray *all_types = NULL;
+
+
+static inline gboolean
+np_init_pygobject(void)
+{
+ PyObject *gobject = PyImport_ImportModule("gobject");
+ if (gobject != NULL)
+ {
+ PyObject *mdict = PyModule_GetDict(gobject);
+ PyObject *cobject = PyDict_GetItemString(mdict, "_PyGObject_API");
+ if (PyCObject_Check(cobject))
+ {
+ _PyGObject_API = (struct _PyGObject_Functions *)PyCObject_AsVoidPtr(cobject);
+ }
+ else
+ {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not find _PyGObject_API object");
+ PyErr_Print();
+ return FALSE;
+ }
+ }
+ else
+ {
+ PyErr_Print();
+ g_warning("could not import gobject");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static inline gboolean
+np_init_pygtk(void)
+{
+ PyObject *pygtk = PyImport_ImportModule("gtk._gtk");
+ if (pygtk != NULL)
+ {
+#ifdef Py_CAPSULE_H
+ void *capsule = PyCapsule_Import("gtk._gtk._PyGtk_API", 0);
+ if (capsule)
+ {
+ _PyGtk_API = (struct _PyGtk_FunctionStruct*)capsule;
+ }
+#endif
+ if (!_PyGtk_API)
+ {
+ PyObject *module_dict = PyModule_GetDict(pygtk);
+ PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
+ if (PyCObject_Check(cobject))
+ {
+ _PyGtk_API = (struct _PyGtk_FunctionStruct*)
+ PyCObject_AsVoidPtr(cobject);
+ }
+ else
+ {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not find _PyGtk_API object");
+ PyErr_Print();
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ PyErr_Print();
+ g_warning("could not import gtk._gtk");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+static void
+caja_python_load_file(GTypeModule *type_module,
+ const gchar *filename)
+{
+ PyObject *main_module, *main_locals, *locals, *key, *value;
+ PyObject *module;
+ GType gtype;
+ Py_ssize_t pos = 0;
+
+ debug_enter_args("filename=%s", filename);
+
+ main_module = PyImport_AddModule("__main__");
+ if (main_module == NULL)
+ {
+ g_warning("Could not get __main__.");
+ return;
+ }
+
+ main_locals = PyModule_GetDict(main_module);
+ module = PyImport_ImportModuleEx((char *) filename, main_locals, main_locals, NULL);
+ if (!module)
+ {
+ PyErr_Print();
+ return;
+ }
+
+ locals = PyModule_GetDict(module);
+
+ while (PyDict_Next(locals, &pos, &key, &value))
+ {
+ if (!PyType_Check(value))
+ continue;
+
+ if (PyObject_IsSubclass(value, (PyObject*)&PyCajaColumnProvider_Type) ||
+ PyObject_IsSubclass(value, (PyObject*)&PyCajaInfoProvider_Type) ||
+ PyObject_IsSubclass(value, (PyObject*)&PyCajaLocationWidgetProvider_Type) ||
+ PyObject_IsSubclass(value, (PyObject*)&PyCajaMenuProvider_Type) ||
+ PyObject_IsSubclass(value, (PyObject*)&PyCajaPropertyPageProvider_Type))
+ {
+ gtype = caja_python_object_get_type(type_module, value);
+ g_array_append_val(all_types, gtype);
+ }
+ }
+
+ debug("Loaded python modules");
+}
+
+static void
+caja_python_load_dir (GTypeModule *module,
+ const char *dirname)
+{
+ GDir *dir;
+ const char *name;
+ gboolean initialized = FALSE;
+
+ debug_enter_args("dirname=%s", dirname);
+
+ dir = g_dir_open(dirname, 0, NULL);
+ if (!dir)
+ return;
+
+ while ((name = g_dir_read_name(dir)))
+ {
+ if (g_str_has_suffix(name, ".py"))
+ {
+ char *modulename;
+ int len;
+
+ len = strlen(name) - 3;
+ modulename = g_new0(char, len + 1 );
+ strncpy(modulename, name, len);
+
+ if (!initialized)
+ {
+ PyObject *sys_path, *py_path;
+
+ /* n-p python part is initialized on demand (or not
+ * at all if no extensions are found) */
+ if (!caja_python_init_python())
+ {
+ g_warning("caja_python_init_python failed");
+ g_dir_close(dir);
+ }
+
+ /* sys.path.insert(0, dirname) */
+ sys_path = PySys_GetObject("path");
+ py_path = PyString_FromString(dirname);
+ PyList_Insert(sys_path, 0, py_path);
+ Py_DECREF(py_path);
+ }
+ caja_python_load_file(module, modulename);
+ }
+ }
+}
+
+static gboolean
+caja_python_init_python (void)
+{
+ PyObject *pygtk, *mdict, *require;
+ PyObject *sys_path, *tmp, *caja, *gtk, *pygtk_version, *pygtk_required_version;
+ GModule *libpython;
+ char *argv[] = { "caja", NULL };
+
+ if (Py_IsInitialized())
+ return TRUE;
+
+ debug("g_module_open " PY_LIB_LOC "/libpython" PYTHON_VERSION "." G_MODULE_SUFFIX ".1.0");
+ libpython = g_module_open(PY_LIB_LOC "/libpython" PYTHON_VERSION "." G_MODULE_SUFFIX ".1.0", 0);
+ if (!libpython)
+ g_warning("g_module_open libpython failed: %s", g_module_error());
+
+ debug("Py_Initialize");
+ Py_Initialize();
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ debug("PySys_SetArgv");
+ PySys_SetArgv(1, argv);
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ debug("Sanitize the python search path");
+ PyRun_SimpleString("import sys; sys.path = filter(None, sys.path)");
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ /* pygtk.require("2.0") */
+ debug("pygtk.require(\"2.0\")");
+ pygtk = PyImport_ImportModule("pygtk");
+ if (!pygtk)
+ {
+ PyErr_Print();
+ return FALSE;
+ }
+ mdict = PyModule_GetDict(pygtk);
+ require = PyDict_GetItemString(mdict, "require");
+ PyObject_CallObject(require, Py_BuildValue("(S)", PyString_FromString("2.0")));
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ /* import gobject */
+ debug("init_pygobject");
+ if (!np_init_pygobject())
+ {
+ g_warning("pygobject initialization failed");
+ return FALSE;
+ }
+
+ /* import gtk */
+ debug("init_pygtk");
+ if (!np_init_pygtk())
+ {
+ g_warning("pygtk initialization failed");
+ return FALSE;
+ }
+
+ /* gobject.threads_init() */
+ debug("pyg_enable_threads");
+ setenv("PYGTK_USE_GIL_STATE_API", "", 0);
+ pyg_enable_threads();
+
+ /* gtk.pygtk_version < (2, 4, 0) */
+ gtk = PyImport_ImportModule("gtk");
+ mdict = PyModule_GetDict(gtk);
+ pygtk_version = PyDict_GetItemString(mdict, "pygtk_version");
+ pygtk_required_version = Py_BuildValue("(iii)", 2, 4, 0);
+ if (PyObject_Compare(pygtk_version, pygtk_required_version) == -1)
+ {
+ g_warning("PyGTK %s required, but %s found.",
+ PyString_AsString(PyObject_Repr(pygtk_required_version)),
+ PyString_AsString(PyObject_Repr(pygtk_version)));
+ Py_DECREF(pygtk_required_version);
+ return FALSE;
+ }
+ Py_DECREF(pygtk_required_version);
+
+ /* sys.path.insert(., ...) */
+ debug("sys.path.insert(0, ...)");
+ sys_path = PySys_GetObject("path");
+ PyList_Insert(sys_path, 0,
+ (tmp = PyString_FromString(CAJA_LIBDIR "/caja-python")));
+ Py_DECREF(tmp);
+
+ /* import caja */
+ g_setenv("INSIDE_CAJA_PYTHON", "", FALSE);
+ debug("import caja");
+ caja = PyImport_ImportModule("caja");
+ if (!caja)
+ {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ /* Extract types and interfaces from caja */
+ mdict = PyModule_GetDict(caja);
+
+ _PyGtkWidget_Type = pygobject_lookup_class(GTK_TYPE_WIDGET);
+ g_assert(_PyGtkWidget_Type != NULL);
+
+#define IMPORT(x, y) \
+ _PyCaja##x##_Type = (PyTypeObject *)PyDict_GetItemString(mdict, y); \
+ if (_PyCaja##x##_Type == NULL) { \
+ PyErr_Print(); \
+ return FALSE; \
+ }
+
+ IMPORT(Column, "Column");
+ IMPORT(ColumnProvider, "ColumnProvider");
+ IMPORT(InfoProvider, "InfoProvider");
+ IMPORT(LocationWidgetProvider, "LocationWidgetProvider");
+ IMPORT(Menu, "Menu");
+ IMPORT(MenuItem, "MenuItem");
+ IMPORT(MenuProvider, "MenuProvider");
+ IMPORT(PropertyPage, "PropertyPage");
+ IMPORT(PropertyPageProvider, "PropertyPageProvider");
+
+#undef IMPORT
+
+ return TRUE;
+}
+
+void
+caja_module_initialize(GTypeModule *module)
+{
+ gchar *user_extensions_dir;
+ const gchar *env_string;
+
+ env_string = g_getenv("CAJA_PYTHON_DEBUG");
+ if (env_string != NULL)
+ {
+ caja_python_debug = g_parse_debug_string(env_string,
+ caja_python_debug_keys,
+ caja_python_ndebug_keys);
+ env_string = NULL;
+ }
+
+ debug_enter();
+
+ all_types = g_array_new(FALSE, FALSE, sizeof(GType));
+
+ // Look in the new global path, $DATADIR/caja-python/extensions
+ caja_python_load_dir(module, DATADIR "/caja-python/extensions");
+
+ // Look in XDG_DATA_DIR, ~/.local/share/caja-python/extensions
+ user_extensions_dir = g_build_filename(g_get_user_data_dir(),
+ "caja-python", "extensions", NULL);
+ caja_python_load_dir(module, user_extensions_dir);
+
+ // Look in the old local path, ~/.caja/python-extensions
+ user_extensions_dir = g_build_filename(g_get_home_dir(),
+ ".caja", "python-extensions", NULL);
+ caja_python_load_dir(module, user_extensions_dir);
+ g_free(user_extensions_dir);
+
+ // Look in the old global path, /usr/lib(64)/caja/extensions-2.0/python
+ caja_python_load_dir(module, CAJA_EXTENSION_DIR "/python");
+}
+
+void
+caja_module_shutdown(void)
+{
+ debug_enter();
+
+ if (Py_IsInitialized())
+ Py_Finalize();
+
+ g_array_free(all_types, TRUE);
+}
+
+void
+caja_module_list_types(const GType **types,
+ int *num_types)
+{
+ debug_enter();
+
+ *types = (GType*)all_types->data;
+ *num_types = all_types->len;
+}
diff --git a/src/caja-python.h b/src/caja-python.h
new file mode 100644
index 0000000..a57f499
--- /dev/null
+++ b/src/caja-python.h
@@ -0,0 +1,79 @@
+/*
+ * caja-python.c - Caja Python extension
+ *
+ * Copyright (C) 2004 Johan Dahlin
+ *
+ * This library 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 library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef CAJA_PYTHON_H
+#define CAJA_PYTHON_H
+
+#include <glib-object.h>
+#include <glib/gprintf.h>
+#include <Python.h>
+
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
+
+typedef enum {
+ CAJA_PYTHON_DEBUG_MISC = 1 << 0,
+} CajaPythonDebug;
+
+extern CajaPythonDebug caja_python_debug;
+
+#define debug(x) { if (caja_python_debug & CAJA_PYTHON_DEBUG_MISC) \
+ g_printf( "caja-python:" x "\n"); }
+#define debug_enter() { if (caja_python_debug & CAJA_PYTHON_DEBUG_MISC) \
+ g_printf("%s: entered\n", __FUNCTION__); }
+#define debug_enter_args(x, y) { if (caja_python_debug & CAJA_PYTHON_DEBUG_MISC) \
+ g_printf("%s: entered " x "\n", __FUNCTION__, y); }
+
+
+PyTypeObject *_PyGtkWidget_Type;
+#define PyGtkWidget_Type (*_PyGtkWidget_Type)
+
+PyTypeObject *_PyCajaColumn_Type;
+#define PyCajaColumn_Type (*_PyCajaColumn_Type)
+
+PyTypeObject *_PyCajaColumnProvider_Type;
+#define PyCajaColumnProvider_Type (*_PyCajaColumnProvider_Type)
+
+PyTypeObject *_PyCajaInfoProvider_Type;
+#define PyCajaInfoProvider_Type (*_PyCajaInfoProvider_Type)
+
+PyTypeObject *_PyCajaLocationWidgetProvider_Type;
+#define PyCajaLocationWidgetProvider_Type (*_PyCajaLocationWidgetProvider_Type)
+
+PyTypeObject *_PyCajaMenu_Type;
+#define PyCajaMenu_Type (*_PyCajaMenu_Type)
+
+PyTypeObject *_PyCajaMenuItem_Type;
+#define PyCajaMenuItem_Type (*_PyCajaMenuItem_Type)
+
+PyTypeObject *_PyCajaMenuProvider_Type;
+#define PyCajaMenuProvider_Type (*_PyCajaMenuProvider_Type)
+
+PyTypeObject *_PyCajaPropertyPage_Type;
+#define PyCajaPropertyPage_Type (*_PyCajaPropertyPage_Type)
+
+PyTypeObject *_PyCajaPropertyPageProvider_Type;
+#define PyCajaPropertyPageProvider_Type (*_PyCajaPropertyPageProvider_Type)
+
+#endif /* CAJA_PYTHON_H */
diff --git a/src/caja.defs b/src/caja.defs
new file mode 100644
index 0000000..7031a3f
--- /dev/null
+++ b/src/caja.defs
@@ -0,0 +1,332 @@
+;; -*- scheme -*-
+; object definitions ...
+(define-object Column
+ (in-module "Caja")
+ (parent "GObject")
+ (c-name "CajaColumn")
+ (gtype-id "CAJA_TYPE_COLUMN")
+)
+
+(define-interface ColumnProvider
+ (in-module "Caja")
+ (c-name "CajaColumnProvider")
+ (gtype-id "CAJA_TYPE_COLUMN_PROVIDER")
+)
+
+(define-interface FileInfo
+ (in-module "Caja")
+ (c-name "CajaFileInfo")
+ (gtype-id "CAJA_TYPE_FILE_INFO")
+)
+
+(define-interface InfoProvider
+ (in-module "Caja")
+ (c-name "CajaInfoProvider")
+ (gtype-id "CAJA_TYPE_INFO_PROVIDER")
+)
+
+(define-interface LocationWidgetProvider
+ (in-module "Caja")
+ (c-name "CajaLocationWidgetProvider")
+ (gtype-id "CAJA_TYPE_LOCATION_WIDGET_PROVIDER")
+)
+
+(define-object Menu
+ (in-module "Caja")
+ (parent "GObject")
+ (c-name "CajaMenu")
+ (gtype-id "CAJA_TYPE_MENU")
+)
+
+(define-object MenuItem
+ (in-module "Caja")
+ (parent "GObject")
+ (c-name "CajaMenuItem")
+ (gtype-id "CAJA_TYPE_MENU_ITEM")
+)
+
+(define-interface MenuProvider
+ (in-module "Caja")
+ (c-name "CajaMenuProvider")
+ (gtype-id "CAJA_TYPE_MENU_PROVIDER")
+)
+
+(define-object PropertyPage
+ (in-module "Caja")
+ (parent "GObject")
+ (c-name "CajaPropertyPage")
+ (gtype-id "CAJA_TYPE_PROPERTY_PAGE")
+)
+
+(define-interface PropertyPageProvider
+ (in-module "Caja")
+ (c-name "CajaPropertyPageProvider")
+ (gtype-id "CAJA_TYPE_PROPERTY_PAGE_PROVIDER")
+)
+
+;; Enumerations and flags ...
+
+(define-enum OperationResult
+ (in-module "Caja")
+ (c-name "CajaOperationResult")
+ (gtype-id "CAJA_TYPE_OPERATION_RESULT")
+ (values
+ '("complete" "CAJA_OPERATION_COMPLETE")
+ '("failed" "CAJA_OPERATION_FAILED")
+ '("in-progress" "CAJA_OPERATION_IN_PROGRESS")
+ )
+)
+
+
+;; From /usr/include/caja/libcaja-extension/caja-column.h
+
+(define-function caja_column_get_type
+ (c-name "caja_column_get_type")
+ (return-type "GType")
+)
+
+(define-function caja_column_new
+ (c-name "caja_column_new")
+ (is-constructor-of "CajaColumn")
+ (return-type "CajaColumn*")
+ (parameters
+ '("const-char*" "name")
+ '("const-char*" "attribute")
+ '("const-char*" "label")
+ '("const-char*" "description")
+ )
+)
+
+
+
+;; From /usr/include/caja/libcaja-extension/caja-extension-types.h
+
+(define-function caja_operation_result_get_type
+ (c-name "caja_operation_result_get_type")
+ (return-type "GType")
+)
+
+;; From /usr/include/caja/libcaja-extension/caja-file-info.h
+
+(define-function caja_file_info_list_copy
+ (c-name "caja_file_info_list_copy")
+ (return-type "GList*")
+ (parameters
+ '("GList*" "files")
+ )
+)
+
+(define-function caja_file_info_list_free
+ (c-name "caja_file_info_list_free")
+ (return-type "none")
+ (parameters
+ '("GList*" "files")
+ )
+)
+
+(define-function caja_file_info_get_type
+ (c-name "caja_file_info_get_type")
+ (return-type "GType")
+)
+
+(define-method is_gone
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_is_gone")
+ (return-type "gboolean")
+)
+
+(define-method get_file_type
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_file_type")
+ (return-type "GFileType")
+)
+
+(define-method get_location
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_location")
+ (return-type "GFile*")
+)
+
+(define-method get_name
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_name")
+ (return-type "char*")
+)
+
+(define-method get_uri
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_uri")
+ (return-type "char*")
+)
+
+(define-method get_activation_uri
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_activation_uri")
+ (return-type "char*")
+)
+
+(define-method get_parent_location
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_parent_location")
+ (return-type "GFile*")
+)
+
+(define-method get_parent_uri
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_parent_uri")
+ (return-type "char*")
+)
+
+(define-method get_mount
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_mount")
+ (return-type "GMount*")
+)
+
+(define-method get_uri_scheme
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_uri_scheme")
+ (return-type "char*")
+)
+
+(define-method get_mime_type
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_mime_type")
+ (return-type "char*")
+)
+
+(define-method is_mime_type
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_is_mime_type")
+ (return-type "gboolean")
+ (parameters
+ '("const-char*" "mime_type")
+ )
+)
+
+(define-method is_directory
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_is_directory")
+ (return-type "gboolean")
+)
+
+(define-method can_write
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_can_write")
+ (return-type "gboolean")
+)
+
+(define-method add_emblem
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_add_emblem")
+ (return-type "none")
+ (parameters
+ '("const-char*" "emblem_name")
+ )
+)
+
+(define-method get_string_attribute
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_get_string_attribute")
+ (return-type "char*")
+ (parameters
+ '("const-char*" "attribute_name")
+ )
+)
+
+(define-method add_string_attribute
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_add_string_attribute")
+ (return-type "none")
+ (parameters
+ '("const-char*" "attribute_name")
+ '("const-char*" "value")
+ )
+)
+
+(define-method invalidate_extension_info
+ (of-object "CajaFileInfo")
+ (c-name "caja_file_info_invalidate_extension_info")
+ (return-type "none")
+)
+
+;; From /usr/include/caja/libcaja-extension/caja-menu-item.h
+
+(define-function caja_menu_item_get_type
+ (c-name "caja_menu_item_get_type")
+ (return-type "GType")
+)
+
+(define-function caja_menu_new
+ (c-name "caja_menu_new")
+ (is-constructor-of "CajaMenu")
+ (return-type "CajaMenu*")
+)
+
+(define-method append_item
+ (of-object "CajaMenu")
+ (c-name "caja_menu_append_item")
+ (return-type "none")
+ (parameters
+ '("CajaMenuItem*" "item")
+ )
+)
+
+(define-method get_items
+ (of-object "CajaMenu")
+ (c-name "caja_menu_get_items")
+ (return-type "GList*")
+)
+
+(define-function caja_menu_item_list_free
+ (c-name "caja_menu_item_list_free")
+ (return-type "none")
+ (parameters
+ '("GList*", "item_list")
+ )
+)
+
+(define-function caja_menu_item_new
+ (c-name "caja_menu_item_new")
+ (is-constructor-of "CajaMenuItem")
+ (return-type "CajaMenuItem*")
+ (parameters
+ '("const-char*" "name")
+ '("const-char*" "label")
+ '("const-char*" "tip")
+ '("const-char*" "icon" (null-ok) (default "NULL"))
+ )
+)
+
+(define-method set_submenu
+ (of-object "CajaMenuItem")
+ (c-name "caja_menu_item_set_submenu")
+ (return-type "none")
+ (parameters
+ '("CajaMenu*" "menu")
+ )
+)
+
+(define-method activate
+ (of-object "CajaMenuItem")
+ (c-name "caja_menu_item_activate")
+ (return-type "none")
+)
+
+;; From /usr/include/caja/libcaja-extension/caja-property-page.h
+
+(define-function caja_property_page_get_type
+ (c-name "caja_property_page_get_type")
+ (return-type "GType")
+)
+
+(define-function caja_property_page_new
+ (c-name "caja_property_page_new")
+ (is-constructor-of "CajaPropertyPage")
+ (return-type "CajaPropertyPage*")
+ (parameters
+ '("const-char*" "name")
+ '("GtkWidget*" "label")
+ '("GtkWidget*" "page")
+ )
+)
diff --git a/src/caja.override b/src/caja.override
new file mode 100644
index 0000000..b968425
--- /dev/null
+++ b/src/caja.override
@@ -0,0 +1,139 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Copyright (C) 2004 Johan Dahlin
+ *
+ * caja.override: overrides for the caja extension library
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+%%
+headers
+#define NO_IMPORT_PYGOBJECT
+#include "pygobject.h"
+
+#include <libcaja-extension/caja-file-info.h>
+#include <libcaja-extension/caja-info-provider.h>
+#include <libcaja-extension/caja-column-provider.h>
+#include <libcaja-extension/caja-location-widget-provider.h>
+#include <libcaja-extension/caja-menu-provider.h>
+#include <libcaja-extension/caja-property-page-provider.h>
+#include <libcaja-extension/caja-menu.h>
+
+static PyObject *
+_glist_to_pyobject (GList *list)
+{
+ GList *l;
+ PyObject *item, *py_ret;
+
+ py_ret = PyList_New (0);
+
+ for (l = list; l != NULL; l = l->next)
+ {
+ item = pygobject_new ((GObject *)l->data);
+
+ if (item == NULL)
+ {
+ Py_DECREF (py_ret);
+ return NULL;
+ }
+
+ PyList_Append (py_ret, item);
+ Py_DECREF (item);
+ }
+
+ return py_ret;
+}
+
+%%
+modulename caja
+%%
+import gobject.GObject as PyGObject_Type
+import gtk.Widget as PyGtkWidget_Type
+import gtk.Window as PyGtkWindow_Type
+%%
+ignore-glob
+ *_get_type
+%%
+define CajaMenu.get_items
+static PyObject *
+_wrap_caja_menu_get_items(PyGObject *self)
+{
+ GList *ret;
+
+ if(self == NULL)
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ ret = caja_menu_get_items(CAJA_MENU(self->obj));
+ if (ret) {
+ PyObject *py_ret = _glist_to_pyobject(ret);
+ return py_ret;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+define CajaInfoProvider.update_complete_invoke kwargs
+static PyObject *
+_wrap_caja_info_provider_update_complete_invoke(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "provider", "handle", "closure", "result", NULL };
+ PyObject *py_closure, *py_handle, *py_result;
+ PyGObject *py_provider;
+ GClosure *closure;
+ CajaOperationHandle *handle;
+ CajaOperationResult result = CAJA_OPERATION_COMPLETE;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!OO|O:CajaInfoProvider.update_complete_invoke", kwlist,
+ &PyCajaInfoProvider_Type, &py_provider,
+ &py_handle, &py_closure, &py_result))
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ closure = pyg_boxed_get(py_closure, GClosure);
+ handle = pyg_pointer_get(py_handle, CajaOperationHandle);
+ if (py_result != NULL)
+ result = (CajaOperationResult)py_result;
+
+ caja_info_provider_update_complete_invoke(closure,
+ CAJA_INFO_PROVIDER(py_provider->obj), handle, result);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+define CajaMenuProvider.emit_items_updated_signal args
+static PyObject *
+_wrap_caja_menu_provider_emit_items_updated_signal(PyGObject *self, PyObject *args)
+{
+ PyGObject *py_provider;
+
+ if (!PyArg_ParseTuple(args, "O!:CajaMenuProvider.emit_items_updated_signal",
+ &PyCajaMenuProvider_Type, &py_provider))
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ caja_menu_provider_emit_items_updated_signal(CAJA_MENU_PROVIDER(py_provider->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
diff --git a/src/cajamodule.c b/src/cajamodule.c
new file mode 100644
index 0000000..550ff7a
--- /dev/null
+++ b/src/cajamodule.c
@@ -0,0 +1,55 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Copyright (C) 2004 Johan Dahlin
+ *
+ * caja.override: overrides for the caja extension library
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* include this first, before NO_IMPORT_PYGOBJECT is defined */
+#include <pygobject.h>
+#include <pygtk/pygtk.h>
+
+void pycaja_register_classes (PyObject *d);
+void pycaja_add_constants(PyObject *module, const gchar *strip_prefix);
+
+extern PyMethodDef pycaja_functions[];
+
+DL_EXPORT(void)
+initcaja(void)
+{
+ PyObject *m, *d;
+
+ if (!g_getenv("INSIDE_CAJA_PYTHON"))
+ {
+ Py_FatalError("This module can only be used from caja");
+ return;
+ }
+
+ init_pygobject ();
+ init_pygtk ();
+
+ m = Py_InitModule ("caja", pycaja_functions);
+ d = PyModule_GetDict (m);
+
+ pycaja_register_classes (d);
+ pycaja_add_constants(m, "CAJA_");
+}