mate-desktop / python-caja Goto Github PK
View Code? Open in Web Editor NEWlibcaja-extension python bindings
Home Page: http://www.mate-desktop.org
License: GNU General Public License v2.0
libcaja-extension python bindings
Home Page: http://www.mate-desktop.org
License: GNU General Public License v2.0
mate-desktop ============= mate-desktop contains the libmate-desktop library, the mate-about program as well as some desktop-wide documents. The libmate-desktop library provides API shared by several applications on the desktop, but that cannot live in the platform for various reasons. There is no API or ABI guarantee, although we are doing our best to provide stability. Documentation for the API is available with gtk-doc. The mate-about program helps find which version of MATE is installed. You may download updates to the package from: http://pub.mate-desktop.org/releases/ Installation ============ If you are not using a released version of mate-desktop (for example, if you checked out the code from git), you first need to run './autogen.sh'. How to report bugs ================== Bugs should be reported to the MATE bug tracking system: https://github.com/mate-desktop/mate-desktop/issues
This is a request for comments. There are several discrepancies in the current master: I would like to fix them but there are more than one way of doing it, all having their drawbacks. I would like to get your opinion on these. Forgive me: I know this text is a bit long.
Caja.OperationResult.IN_PROGRESS
Here is a list of related problems:
While a file information info request is in progress, Caja is responsive to navigation, but does not schedule another file information request until the current one is complete or cancelled: this tends to slow down the displayed items info availability even if the extension is able to process several info update requests in parallel. This is not a python-caja problem and is completely under the responsibility of Caja itself (even the C extensions are affected).
Caja.OperationHandle
is not alterableWhen Caja.update_file_info_full()
returns Caja.OperationResult.IN_PROGRESS, the Caja C API expects the handle parameter to have been set by the extension to a non-NULL gpointer
value. Python-caja does not set this value and uses an undefined value (often NULL) to build the handle object passed to the Python method: this is a python-caja bug. Please note that leaving the handle to a NULL value may fool Caja into "thinking" nothing is in progress at some levels.
There are 2 solutions to this problem:
a) Generate a dummy gpointer
from a counter, store it in the C API's handle and pass it to Caja.update_file_info_full()
. This has the advantage of not fooling Caja and retaining the Python method signature, but does not give handle control to the Python extension. This is the minimum fix needed in python-caja.
b) Do as a) for a default handle value and provide an API that can change a Caja.OperationHandle
value, give this value to the C API upon return. This allows controlling the handle by the Python extension, but will probably require support from Caja itself.
Caja.OperationHandle
is not serializableThe handle is supposed to identify some data associated with the request, but cannot be used as a dictionary key in Python without an awful hack on its string representation. It thus cannot be used by a Python extension for its original purpose of locating extension data. Unfortunately, there is no solution that can be implemented in python-caja: Caja itself ought to provide a serialization API for an OperationHandle
.
cancel_update()
implementation is currently mandatoryIf Caja navigation changes displayed directory while a file info update is in progress, Caja calls method cancel_update()
. A base class method is provided as Caja.InfoProvider.cancel_update(self, handle)
, while python-caja calls it as Caja.InfoProvider.cancel_update(self, provider, handle)
. This is
a python-caja bug (bad implementation) that can hardly be fixed without altering the requested method signature. An immediate solution is to always implement cancel_update()
if there are risks of this situation in a Python extension: this does not break existing extensions but introduces a stupid constraint.
Most of these problems probably existed before the python-caja fork, and still exist in the original project.
By googling around, I have not found a single open-source real Caja Python extension that uses Caja.OperationResult.IN_PROGRESS
: this comforts me into thinking it is hardly usable and we may alter the methods signature with a very little impact, if some.
RabbitVCS uses its own implementation for handling asynchronous updates, mainly because of problem 1), thus avoiding all the other problems: see http://wiki.rabbitvcs.org/wiki/development/nautilus-probs). With regards to all above, I would advice to do so.
As we are supposed to properly support our features, the above points should find a real solution in one way or another:
As a base of investigations for this document, I have spent a lot of time in examining definitions in the generated file /usr/share/gir-1.0/Caja-2.0.gir
, mainly about which and how definitions are enforced: I noted the following discrepancies: they are not all related to Caja.OperationResult.IN_PROGRESS
but may also involve methods signature changes:
Caja.InfoProvider.update_file_info_full()
: python-caja calls it as instance method Caja.InfoProvider.update_file_info_full(provider, handle, closure, file)
while provider is already available as the instance itself. Although not causing any problem, the signature should be simplified into Caja.InfoProvider.update_file_info_full(handle, closure, file)
Caja.InfoProvider.cancel_update
(): likewise. See problem 4).Caja.info_provider_update_complete_invoke
(): the documentation is wrong: should read Caja.info_provider_update_complete_invoke(closure, provider, handle, result)
, with no default value for the result
parameter. Has now even be cloned as @staticmethod Caja.InfoProvider.update_complete_invoke(closure, provider, handle, result)
.Caja.MenuProvider.get_file_items_full
() and Caja.MenuProvider.get_background_items_full
(): no problem here, but methods are useless: provider is already given as the instance itself.Caja.menu_provider_emit_items_updated_signal
(): documentation wrong: renamed Caja.MenuProvider.emit_items_updated_signal
() with the provider taken from the instance.Caja.PropertyPageProvider.get_pages()
: documentation or implementation wrong: although named as such in the C API and gir definitions, Python Caja extensions have to name this method get_property_pages()
or else it won't be called.Thanks for reading and commenting
ERROR:root:Could not find any typelib for Caja
ImportError: No module named Caja
(caja:6515): Caja-Python-WARNING **: caja_python_init_python failed
Version is 1.8.0-0+wheezy
sudo apt-get install gir1.2-caja
is NOT the solution.
Is this software compatible with Python 3? The README file says that Python 2.7 is required, but it isn't clear if that's a minimum requirement or if Python 2.7.x is needed.
If the software is compatible with Python 3, is it possible to install two versions at the same time, one linked against Python 2 and the other against Python 3? Perhaps by switching from:
to:
I have a working extension (caja-thg.py) in ~/.local/share/caja-python/extensions and if I copy the example submenu.py and restart caja, TortoiseHg disappear from menu and I'm only seeing the Foo->Bar example. Same behaviour if I try with other extensions like open-terminal.py and submenu.py: only one extension work at time.
I'm on Linux Mint 17.2 with Caja 1.10.3-1 and python-caja 1.8.1-2
i.e. no version, no copyright, no author...
ImportError: could not import gobject (error was: '/usr/lib/libpyglib-2.0-python2.7.so.0: undefined symbol: _Py_ZeroStruct')
(caja:15523): Caja-Python-WARNING **: pygobject initialization failed
(caja:15523): Caja-Python-WARNING **: caja_python_init_python failed
Seems to be the same as Issue #5 , however it is still unfixed.
I just installed a fresh debian wheezy.
Where can I find the documentation of the python API?
I want to make an extension in python to:
When:
Ctrl
and Shift
are currently pressedgksudo -u root
+ {start command}caja already has a right click command to "start as administrator" (root) but I'd like a step further and have a keyboard shortcut.
I'm developing a Pyhon-Caja script which requires a simple integer setting for the extension. Where can I find an example which uses Caja | Edit | Preferences | File Management Preferences | Extensions | Configure Extension
dialog to configure Python-Caja specific settings?
No documentation / no example?
Currently, the number of shred iterations (int) is now hard-coded in #72.
22.10
Caja 1.26.1
MATE 22.10
N.A.
Relevant config.log:
configure:10987: checking for PYTHON
configure:10994: $PKG_CONFIG --exists --print-errors "${PYTHON_PKG}"
Package python-2.7-embed was not found in the pkg-config search path.
Perhaps you should add the directory containing `python-2.7-embed.pc'
to the PKG_CONFIG_PATH environment variable
Package 'python-2.7-embed', required by 'virtual:world', not found
configure:10997: $? = 1
configure:11011: $PKG_CONFIG --exists --print-errors "${PYTHON_PKG}"
Package python-2.7-embed was not found in the pkg-config search path.
Perhaps you should add the directory containing `python-2.7-embed.pc'
to the PKG_CONFIG_PATH environment variable
Package 'python-2.7-embed', required by 'virtual:world', not found
configure:11014: $? = 1
configure:11028: result: no
Package 'python-2.7-embed', required by 'virtual:world', not found
configure:11048: checking for PYTHON
configure:11055: $PKG_CONFIG --exists --print-errors "${PYTHON_PKG}"
Package python-2.7 was not found in the pkg-config search path.
Perhaps you should add the directory containing `python-2.7.pc'
to the PKG_CONFIG_PATH environment variable
Package 'python-2.7', required by 'virtual:world', not found
configure:11058: $? = 1
configure:11072: $PKG_CONFIG --exists --print-errors "${PYTHON_PKG}"
Package python-2.7 was not found in the pkg-config search path.
Perhaps you should add the directory containing `python-2.7.pc'
to the PKG_CONFIG_PATH environment variable
Package 'python-2.7', required by 'virtual:world', not found
configure:11075: $? = 1
configure:11089: result: no
Package 'python-2.7', required by 'virtual:world', not found
configure:11105: error: Package requirements (python-2.7) were not met:
Package 'python-2.7', required by 'virtual:world', not found
Python 2.7 is already installed:
$ python2.7 --version
Python 2.7.16
When python extensions call gettext.textdomain() to display localized menu items & co., only one extension can do that properly. The other receive wrong domain, and English messages as result.
In the README it is described how plugins are loaded from $XDG_DATA_DIR. This variable is not defined on my computer, and isn't apparently described at freedesktop.org
Maybe it was meant the variable $XDG_DATA_DIRS (final S!)
Hi.
This won't be very precise as my knowlegde of automake tools quite limited, but I found a little bug. It's for the current version. The python.m4 macro has some code that evaluates the libdirsuffix variable, later used in the PYTHON_LIB_LOC variable and so on. The libdrisuffix is hardcoded with the "/i386-linux-gnu/".
Here's the problem: the evaluation of the libdirsuffix variable passes without making changes to the initial value. This results in a "/i386-linux-gnu/" suffix... on a 64-bit environment... where the directory doesn't exist. ;)
This results in an error when trying to load a Python extension (RabbitVCS Caja extension in my case):
(caja:1258): Caja-Python-WARNING **: g_module_open libpython failed: /usr/lib/i386-linux-gnu//libpython2.7.so.1.0: (translated from polish) cannot open shared object file: No such file or directory
ImportError: could not import gobject (error was: '/usr/lib/python2.7/site-packages/gi/_gi.so: undefined symbol: _Py_ZeroStruct')
The workaround for me was to change the hardcoded "/i386-linux-gnu/" to just "/", but it seems that the path evalution code didn't do anything on my environment. I'm using ArchLinux 64-bit. The basic directory structure for the lib directories is:
I didn't have too much time to dig into the evaluation code (at work right now and really needed that SVN integration), but if I find anything else, I'll post it here. If there's anything else you would need to know, I'll be happy to add it.
The patch linked below fixes debbug#770927.
Please consider applying it upstream.
Thanks,
Mike
Caja opens without warnings of python errors, and extensions like Caja Admin extension work
If Debian's packaged python-caja (python-caja_1.20.0-1_amd64.deb and python-caja-common_1.20.0-1_all.deb) are used this package works as expected.
On the other hand, a local build against Debian Unstable as of 4-22-208 it does not work, even with the same configuration options, and even if a python-caja tarball from Debian's repo is used rather than downloaded tarball from git
When caja opens I get the errors below from python-caja and python extensions cannot be loaded.
libpython2.7.so.1.0 is present on the system, so it looks like the undefined symbol: _Py_ZeroStruct is the culprit here:
(caja:21735): Caja-Python-WARNING **: 01:23:22.701: g_module_open libpython failed: /libpython2.7.so.1.0: cannot open shared object file: No such file or directory
ImportError: could not import gobject (error was: '/usr/lib/python2.7/dist-packages/gi/_gi.x86_64-linux-gnu.so: undefined symbol: _Py_ZeroStruct')
(caja:21735): Caja-Python-WARNING **: 01:23:22.710: pygobject initialization failed
(caja:21735): Caja-Python-WARNING **: 01:23:22.710: caja_python_init_python failed
1: Install MATE including caja 1.21 from git master and caja-extensions git master by local builds with config options
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --sysconfdir=/etc --enable-shared=yes --disable-maintainer-mode --disable-schemas-compile
into Debian Unstable
2: Build python-caja with these build options or the ones used by Debian, it makes no difference.
3: install Caja Admin and restart caja (my tests were running from terminal)
$: up come the warnings, python extensions are not loaded
1.20/1.21 mix from git master, generally up to date
1.20.0 as release or 1.20.0+git master 2018-04-23 locally built, both behave the same way as expected.
Debian Unstable updated as of 4-22-2018
None, the packages distributed by Debian work (perhaps linked against older python 2.7 version?), something changed since they were built.
Hi. I downloaded the Mint 15 RC from http://torrents.linuxmint.com/torrents/linuxmint-15-mate-dvd-64bit-rc.iso.torrent then tried it out on a VM. On startup I installed python-caja from the repo and added an extension to /usr/share/caja-python/extensions. Restarting caja through "caja -q" then running it didn't enable the extension.
The code for the extension is here: http://pastebin.com/5tWdxggf
Getting the debug log for caja by sending the USR1 signal to it, the following entries are in the created caja-debug-log.txt:
pygobject initialization failed
caja_python_init_python failed
Versions:
caja - 1.6.1-2+raring
gir1.2-glib-2.0 - 1.36.0-1
python - 2.7.4-0ubuntu1
python-caja - 1.6.0-1+raring
python-gobject - 3.8.0-2
Now extensions can live in /usr/share/nautilus-python/extensions:
// Look in the new global path, $DATADIR/nautilus-python/extensions
nautilus_python_load_dir(module, DATADIR
"/nautilus-python/extensions");
So it'd be a good idea to create this directory on make install :-)
With the most recent commit to fix python-caja for Linux Mint 15 and above, extensions stored at /usr/share/caja-python/extensions don't seem to be recognized by python-caja. Tested in Linux Mint 15.
Steps to reproduce.
When the extension is stored in ~/.local/share/caja-python/extensions then it is recognized.
Versions of installed packages:
mint@mint ~/python-caja $ dpkg -l | egrep "(python-gobject-dev|python-gobject-2-dev|python-dev|gir1.2-caja|libcaja-extension-dev)"
ii gir1.2-caja 1.6.1-2+raring amd64 GObject introspection data for the caja library
ii libcaja-extension-dev 1.6.1-2+raring amd64 libraries for caja components (development files)
ii libpython-dev:amd64 2.7.4-0ubuntu1 amd64 header files and a static library for Python (default)
ii python-dev 2.7.4-0ubuntu1 amd64 header files and a static library for Python (default)
ii python-gobject-2-dev 2.28.6-11 all development headers for the static GObject Python bindings
ii python-gobject-dev 3.8.0-2 all Python 2.x development headers for GObject - transitional package
Asked on irc but no one seems to even be willing to even answer me so I'll report it here. I am seeing the below when running autoreconf.
configure.in:30: error: possibly undefined macro: AC_MSG_ERROR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.in:38: error: possibly undefined macro: AM_CHECK_PYTHON_HEADERS
configure.in:39: error: possibly undefined macro: AM_CHECK_PYTHON_LIBS
W: python-caja-dbg: spelling-error-in-description allows to allows one to
N:
N: Lintian found a spelling error in the package description. Lintian has a
N: list of common misspellings that it looks for. It does not have a
N: dictionary like a spelling checker does. It is particularly picky about
N: spelling and capitalization in package descriptions since they're very
N: visible to end users.
N:
N: Severity: minor, Certainty: certain
N:
N: Check: description, Type: binary, udeb
Hi,
The examples are not working since it is impossible to import Caja from gi.repository
In [1]: from gi.repository import Caja, GObject, Gio
ERROR:root:Could not find any typelib for Caja
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-afab7d503acd> in <module>()
----> 1 from gi.repository import Caja, GObject, Gio
ImportError: cannot import name Caja
This is despite having the latest python-caja package installed on my OS (Debian).
Please add instructions how to enable Caja python bindings.
I am running a Debian sid with mate installed ("deb http://repo.mate-desktop.org/debian wheezy main"). On startup I get the error:
ImportError: could not import gobject (error was: '/usr/lib/libpyglib-2.0-python2.7.so.0: undefined symbol: _Py_ZeroStruct')
(caja:18800): Caja-Python-WARNING **: pygobject initialization failed
(caja:18800): Caja-Python-WARNING **: caja_python_init_python failed
currently the only python-extension is open-terminal.py located in "~/.local./share/caja-python/extensions/". The open-terminal extensions was taken from the examples included in the debian python-caja package.
# This example is contributed by Martin Enlund
import os
import urllib
from gi.repository import Caja, GObject, Gio
TERMINAL_SCHEMA = 'org.mate.applications-terminal'
TERMINAL_KEY = 'exec'
class OpenTerminalExtension(Caja.MenuProvider, GObject.GObject):
def __init__(self):
self.gsettings = Gio.Settings.new(TERMINAL_SCHEMA)
def _open_terminal(self, file):
filename = urllib.unquote(file.get_uri()[7:])
terminal = self.gsettings[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(name='CajaPython::openterminal_file_item',
label='Open Terminal' ,
tip='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(name='CajaPython::openterminal_item',
label='Open Terminal Here',
tip='Open Terminal In This Directory')
item.connect('activate', self.menu_background_activate_cb, file)
return item,
caja 1.6.1-1
python-caja 1.6.0-1
gir1.2-glib-2.0 1.32-1-1
python-gobject-2 2.28.6-11
Running caja-file-management-properties
from terminal should show only three lines
Initializing caja-wallpaper extension
Initializing caja-sendto extension
Initializing caja-open-terminal extension
Running caja-file-management-properties
from terminal shows many Gtk-Warnings like shown below:
(caja-file-management-properties:9334): Gtk-WARNING **: 13:45:25.520: Failed to set text from markup due to error parsing markup: Error on line 1 char 31: Invalid UTF-8 encoded text in name — not valid “Python: \xb0\xd5\xe7\xd3h\u007f”
(caja-file-management-properties:9334): Gtk-WARNING **: 13:45:25.520: Failed to set text from markup due to error parsing markup: Error on line 1 char 26: Invalid UTF-8 encoded text in name — not valid “Python: \xf0B7\xc0\xcaU”
(caja-file-management-properties:9334): Gtk-WARNING **: 13:45:25.520: Failed to set text from markup due to error parsing markup: Error on line 1 char 26: Invalid UTF-8 encoded text in name — not valid “Python: 9\xb5\x87\x9c\xcfU”
(caja-file-management-properties:9334): Gtk-WARNING **: 13:45:25.520: Failed to set text from markup due to error parsing markup: Error on line 1 char 26: Invalid UTF-8 encoded text in name — not valid “Python: \xe0\xd1%\xc0\xcaU”
caja-admin causes the following line to appear:
(caja-file-management-properties:6800): Gtk-WARNING **: 21:09:10.379: Failed to set text from markup due to error parsing markup: Error on line 1 char 26: Invalid UTF-8 encoded text in name — not valid “Python: \xcb\xe7%C\xb3U”
It is reported as infirit/caja-admin#15 .
Caja-rename causes the following line to appear:
(caja-file-management-properties:7372): Gtk-WARNING **: 21:22:42.535: Failed to set text from markup due to error parsing markup: Error on line 1 char 29: Invalid UTF-8 encoded text in name — not valid “Python: H3\x89c\u0005”
Issue is at tari01/caja-rename#6
deja-dup caja causes the following line to appear:
(caja-file-management-properties:7722): Gtk-WARNING **: 21:28:04.420: Failed to set text from markup due to error parsing markup: Error on line 1 char 33: Invalid UTF-8 encoded text in name — not valid “Python: g\xe3\u0002a\u0005”
tortoisehg-caja causes the following line to appear:
(caja-file-management-properties:13746): Gtk-WARNING **: 21:42:46.214: Failed to set text from markup due to error parsing markup: Error on line 1 char 31: Invalid UTF-8 encoded text in name — not valid “Python: ;\xee\xda\u0019\xa3U”
caja-file-management-properties
from terminal1.26.0
1.26.0-0ubuntu1
Ubuntu MATE 21.10 beta
plus some autoconf hygiene (AS_IF clauses):
https://anonscm.debian.org/cgit/pkg-mate/python-caja.git/tree/debian/patches/1001_pkg-config-macro-not-cross-compilation-safe.patch?id=7b54969a354e92d94052acb80a08dce586d42aca
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.