Giter Site home page Giter Site logo

python-caja's Introduction

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

python-caja's People

Contributors

alexandervdm avatar clefebvre avatar flexiondotorg avatar infirit avatar leigh123linux avatar mbkma avatar mgersten avatar monnerat avatar monsta avatar raveit65 avatar rbuj avatar sc0w avatar stefano-k avatar sunweaver avatar szesch avatar tamplan avatar yetist avatar yselkowitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-caja's Issues

Problems related to Caja.OperationResult.IN_PROGRESS and some others

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:

1) file info updates are serialized.

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).

2) Caja.OperationHandle is not alterable

When 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.

3) Caja.OperationHandle is not serializable

The 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.

4) cancel_update() implementation is currently mandatory

If 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:

  • Are we allowed to alter prototype signatures?
  • Do we minimally fix existing API and provide an alternate one?
  • Can we consider additional support in Caja itself?

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

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.

Python 3 compatibility

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:

  • /usr/lib64/caja/extensions-2.0/libcaja-python.so

to:

  • /usr/lib64/caja/extensions-2.0/libcaja-python2.so
  • /usr/lib64/caja/extensions-2.0/libcaja-python3.so

Unable to have multiple working extensions

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

pygobject initialization failed

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; documentation for python API

Where can I find the documentation of the python API?

I want to make an extension in python to:
When:

  • Double click used on a file
    Instead of (default):
  • Open the file with default program
    Do:
  • Test if Ctrl and Shift are currently pressed
    -- (if so) Execute gksudo -u root + {start command}
    -- (else) Execute default

caja already has a right click command to "start as administrator" (root) but I'd like a step further and have a keyboard shortcut.

Caja-Python example with configurable settings via Configure Extension

Expected behaviour

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?

Actual behaviour

No documentation / no example?

Steps to reproduce the behaviour

Currently, the number of shred iterations (int) is now hard-coded in #72.

MATE general version

22.10

Package version

Caja 1.26.1

Linux Distribution

MATE 22.10

Link to bugreport of your Distribution (requirement)

N.A.

autogen.sh failed

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

$XDG_DATA_DIR not defined

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!)

Python lib suffix detection flawed (kind of)

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:

  • /usr/lib - 64-bit libraries
  • /usr/lib32 - 32-bit libraries
  • /usr/lib64 - symlink to /usr/lib

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.

undefined symbol: _Py_ZeroStruct when built against current Debian Unstable as of 4-22-2018

Expected behaviour

Caja opens without warnings of python errors, and extensions like Caja Admin extension work

Actual behaviour

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

Steps to reproduce the behaviour

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

MATE general version

1.20/1.21 mix from git master, generally up to date

Package version

1.20.0 as release or 1.20.0+git master 2018-04-23 locally built, both behave the same way as expected.

Linux Distribution

Debian Unstable updated as of 4-22-2018

Link to downstream report of your Distribution

None, the packages distributed by Debian work (perhaps linked against older python 2.7 version?), something changed since they were built.

python-caja not working in Mint 15 64-bit

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

python-caja does not look at /usr/share/caja-python/extensions

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.

  1. Clone the latest repo.
  2. Install dependencies: gir1.2-caja, libcaja-extension-dev, python-dev, python-gobject-2-dev, python-gobject-dev.
  3. Build and install python-caja.
  4. Add an extension to /usr/share/caja-python/extensions.
  5. Restart Caja.

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

autoconf errors

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

lintian reports a grammar error (allows to -> allows one to) in some text output

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

Examples won't work

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.

python-caja on Debian

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

There is something wrong with Python3-Caja in upcoming Ubuntu MATE 21.10

Expected behaviour

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

Actual behaviour

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”
    

Steps to reproduce the behaviour

  1. Install Ubuntu MATE 21.10 beta
  2. Launch caja-file-management-properties from terminal

MATE general version

1.26.0

Package version

1.26.0-0ubuntu1

Linux Distribution

Ubuntu MATE 21.10 beta

Link to bugreport of your Distribution (requirement)

https://pad.lv/1945052

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.