diff options
author | Stefano Karapetsas <[email protected]> | 2012-01-13 23:18:04 +0100 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-01-13 23:18:04 +0100 |
commit | ca0a8f4d6cc24707bc07c3013bff321e2f0c24fd (patch) | |
tree | 4c4d47f249603be3cb816b1456a9dc71c0b48999 /examples | |
download | python-caja-ca0a8f4d6cc24707bc07c3013bff321e2f0c24fd.tar.bz2 python-caja-ca0a8f4d6cc24707bc07c3013bff321e2f0c24fd.tar.xz |
initial import from Mate-Extra repo
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 14 | ||||
-rw-r--r-- | examples/Makefile.in | 465 | ||||
-rw-r--r-- | examples/README | 15 | ||||
-rw-r--r-- | examples/background-image.py | 40 | ||||
-rw-r--r-- | examples/block-size-column.py | 22 | ||||
-rw-r--r-- | examples/location-widget-provider.py | 12 | ||||
-rw-r--r-- | examples/md5sum-property-page.py | 42 | ||||
-rw-r--r-- | examples/open-terminal.py | 47 | ||||
-rw-r--r-- | examples/submenu.py | 29 | ||||
-rw-r--r-- | examples/update-file-info-async.py | 15 |
10 files changed, 701 insertions, 0 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 0000000..45e8909 --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,14 @@ +docsdir = $(datadir)/doc/$(PACKAGE) +docs_DATA = README + +examplesdir = $(datadir)/doc/$(PACKAGE)/examples +examples_DATA = \ + background-image.py \ + block-size-column.py \ + location-widget-provider.py \ + open-terminal.py \ + md5sum-property-page.py \ + submenu.py \ + update-file-info-async.py + +EXTRA_DIST = README $(examples_DATA) diff --git a/examples/Makefile.in b/examples/Makefile.in new file mode 100644 index 0000000..a5e3822 --- /dev/null +++ b/examples/Makefile.in @@ -0,0 +1,465 @@ +# 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 = examples +DIST_COMMON = README $(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 = +SOURCES = +DIST_SOURCES = +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)$(docsdir)" "$(DESTDIR)$(examplesdir)" +DATA = $(docs_DATA) $(examples_DATA) +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 = @pyexecdir@ +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@ +docsdir = $(datadir)/doc/$(PACKAGE) +docs_DATA = README +examplesdir = $(datadir)/doc/$(PACKAGE)/examples +examples_DATA = \ + background-image.py \ + block-size-column.py \ + location-widget-provider.py \ + open-terminal.py \ + md5sum-property-page.py \ + submenu.py \ + update-file-info-async.py + +EXTRA_DIST = README $(examples_DATA) +all: all-am + +.SUFFIXES: +$(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 examples/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/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): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-docsDATA: $(docs_DATA) + @$(NORMAL_INSTALL) + test -z "$(docsdir)" || $(MKDIR_P) "$(DESTDIR)$(docsdir)" + @list='$(docs_DATA)'; test -n "$(docsdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docsdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(docsdir)" || exit $$?; \ + done + +uninstall-docsDATA: + @$(NORMAL_UNINSTALL) + @list='$(docs_DATA)'; test -n "$(docsdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(docsdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(docsdir)" && rm -f $$files +install-examplesDATA: $(examples_DATA) + @$(NORMAL_INSTALL) + test -z "$(examplesdir)" || $(MKDIR_P) "$(DESTDIR)$(examplesdir)" + @list='$(examples_DATA)'; test -n "$(examplesdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(examplesdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(examplesdir)" || exit $$?; \ + done + +uninstall-examplesDATA: + @$(NORMAL_UNINSTALL) + @list='$(examples_DATA)'; test -n "$(examplesdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(examplesdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(examplesdir)" && rm -f $$files +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +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 $(DATA) +installdirs: + for dir in "$(DESTDIR)$(docsdir)" "$(DESTDIR)$(examplesdir)"; 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: + +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-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-docsDATA install-examplesDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +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 -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-docsDATA uninstall-examplesDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-docsDATA install-dvi \ + install-dvi-am install-examplesDATA 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-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-docsDATA uninstall-examplesDATA + + +# 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/examples/README b/examples/README new file mode 100644 index 0000000..7526a37 --- /dev/null +++ b/examples/README @@ -0,0 +1,15 @@ +To try any of the examples, copy them over to: + + $XDG_DATA_DIR/share/caja-python/extensions/ +or: + ~/.local/share/caja-python/extensions/ + +FYI, it is still possible to load plugins from the old locations. + +Then restart caja. + +Hint: if you're testing an extension that you're developing, it may +be useful to start a 'private' instance of caja, like this: + $ mkdir /tmp/testing + $ export TMPDIR=/tmp/testing + $ caja --no-desktop diff --git a/examples/background-image.py b/examples/background-image.py new file mode 100644 index 0000000..0f5bea6 --- /dev/null +++ b/examples/background-image.py @@ -0,0 +1,40 @@ +import urllib + +import mateconf +import caja + +SUPPORTED_FORMATS = 'image/jpeg', 'image/png' +BACKGROUND_KEY = '/desktop/mate/background/picture_filename' + +class BackgroundImageExtension(caja.MenuProvider): + def __init__(self): + self.mateconf = mateconf.client_get_default() + + def menu_activate_cb(self, menu, file): + if file.is_gone(): + return + + # Strip leading file:// + filename = urllib.unquote(file.get_uri()[7:]) + self.mateconf.set_string(BACKGROUND_KEY, filename) + + def get_file_items(self, window, files): + if len(files) != 1: + return + + file = files[0] + + # We're only going to put ourselves on images context menus + if not file.get_mime_type() in SUPPORTED_FORMATS: + return + + # Mate can only handle file: + # In the future we might want to copy the file locally + if file.get_uri_scheme() != 'file': + return + + item = caja.MenuItem('Caja::set_background_image', + 'Use as background image', + 'Set the current image as a background image') + item.connect('activate', self.menu_activate_cb, file) + return item, diff --git a/examples/block-size-column.py b/examples/block-size-column.py new file mode 100644 index 0000000..6f94158 --- /dev/null +++ b/examples/block-size-column.py @@ -0,0 +1,22 @@ +import os +import urllib + +import caja + +class ColumnExtension(caja.ColumnProvider, caja.InfoProvider): + def __init__(self): + pass + + def get_columns(self): + return caja.Column("CajaPython::block_size_column", + "block_size", + "Block size", + "Get the block size"), + + def update_file_info(self, file): + if file.get_uri_scheme() != 'file': + return + + filename = urllib.unquote(file.get_uri()[7:]) + + file.add_string_attribute('block_size', str(os.stat(filename).st_blksize)) diff --git a/examples/location-widget-provider.py b/examples/location-widget-provider.py new file mode 100644 index 0000000..0e7504c --- /dev/null +++ b/examples/location-widget-provider.py @@ -0,0 +1,12 @@ +import caja +import gtk + +class LocationProviderExample(caja.LocationWidgetProvider): + def __init__(self): + pass + + def get_widget(self, uri, window): + entry = gtk.Entry() + entry.set_text(uri) + entry.show() + return entry diff --git a/examples/md5sum-property-page.py b/examples/md5sum-property-page.py new file mode 100644 index 0000000..13c59e7 --- /dev/null +++ b/examples/md5sum-property-page.py @@ -0,0 +1,42 @@ +import hashlib +import urllib + +import gtk +import caja + +class MD5SumPropertyPage(caja.PropertyPageProvider): + def __init__(self): + pass + + def get_property_pages(self, files): + if len(files) != 1: + return + + file = files[0] + if file.get_uri_scheme() != 'file': + return + + if file.is_directory(): + return + + filename = urllib.unquote(file.get_uri()[7:]) + + self.property_label = gtk.Label('MD5Sum') + self.property_label.show() + + self.hbox = gtk.HBox(0, False) + self.hbox.show() + + label = gtk.Label('MD5Sum:') + label.show() + self.hbox.pack_start(label) + + self.value_label = gtk.Label() + self.hbox.pack_start(self.value_label) + + md5sum = hashlib.md5(filename).hexdigest() + self.value_label.set_text(md5sum) + self.value_label.show() + + return caja.PropertyPage("CajaPython::md5_sum", + self.property_label, self.hbox), diff --git a/examples/open-terminal.py b/examples/open-terminal.py new file mode 100644 index 0000000..8e22ccf --- /dev/null +++ b/examples/open-terminal.py @@ -0,0 +1,47 @@ +# This example is contributed by Martin Enlund +import os +import urllib + +import gtk +import caja +import mateconf + +TERMINAL_KEY = '/desktop/mate/applications/terminal/exec' + +class OpenTerminalExtension(caja.MenuProvider): + def __init__(self): + self.client = mateconf.client_get_default() + + def _open_terminal(self, file): + filename = urllib.unquote(file.get_uri()[7:]) + terminal = self.client.get_string(TERMINAL_KEY) + + os.chdir(filename) + os.system('%s &' % terminal) + + def menu_activate_cb(self, menu, file): + self._open_terminal(file) + + def menu_background_activate_cb(self, menu, file): + self._open_terminal(file) + + def get_file_items(self, window, files): + if len(files) != 1: + return + + file = files[0] + if not file.is_directory() or file.get_uri_scheme() != 'file': + return + + item = caja.MenuItem('CajaPython::openterminal_file_item', + 'Open Terminal' , + 'Open Terminal In %s' % file.get_name()) + item.connect('activate', self.menu_activate_cb, file) + return item, + + def get_background_items(self, window, file): + item = caja.MenuItem('CajaPython::openterminal_item', + 'Open Terminal Here', + 'Open Terminal In This Directory') + item.connect('activate', self.menu_background_activate_cb, file) + return item, diff --git a/examples/submenu.py b/examples/submenu.py new file mode 100644 index 0000000..7b91459 --- /dev/null +++ b/examples/submenu.py @@ -0,0 +1,29 @@ +import caja + +class ExampleMenuProvider(caja.MenuProvider): + + # Caja crashes if a plugin doesn't implement the __init__ method. + # See Bug #374958 + def __init__(self): + pass + + def get_file_items(self, window, files): + top_menuitem = caja.MenuItem('ExampleMenuProvider::Foo', 'Foo', '') + + submenu = caja.Menu() + top_menuitem.set_submenu(submenu) + + sub_menuitem = caja.MenuItem('ExampleMenuProvider::Bar', 'Bar', '') + submenu.append_item(sub_menuitem) + + return top_menuitem, + + def get_background_items(self, window, file): + submenu = caja.Menu() + submenu.append_item(caja.MenuItem('ExampleMenuProvider::Bar', 'Bar', '')) + + menuitem = caja.MenuItem('ExampleMenuProvider::Foo', 'Foo', '') + menuitem.set_submenu(submenu) + + return menuitem, + diff --git a/examples/update-file-info-async.py b/examples/update-file-info-async.py new file mode 100644 index 0000000..349b169 --- /dev/null +++ b/examples/update-file-info-async.py @@ -0,0 +1,15 @@ +import caja +import gobject + +class UpdateFileInfoAsync(caja.InfoProvider): + def __init__(self): + pass + + def update_file_info_full(self, provider, handle, closure, file): + print "update_file_info_full" + gobject.timeout_add_seconds(3, self.update_cb, provider, handle, closure) + return caja.OPERATION_IN_PROGRESS + + def update_cb(self, provider, handle, closure): + print "update_cb" + self.update_complete_invoke(provider, handle, closure, result=caja.OPERATION_FAILED) |