Skip to content

Modernize examples#35

Merged
vkareh merged 1 commit into
mate-desktop:masterfrom
monnerat:examples
Jan 30, 2019
Merged

Modernize examples#35
vkareh merged 1 commit into
mate-desktop:masterfrom
monnerat:examples

Conversation

@monnerat

@monnerat monnerat commented Jan 26, 2019

Copy link
Copy Markdown
Contributor

The example extension scripts need to be in sync with new versions of
referenced foreign packages.
This commit also makes them compatible with Python version 3 (retaining
Python 2 compatibility).
An additional example extension "mixed" is added: it implements all caja
extension features and can also be used as a new extension pattern. See
source header comment for a description.

Ref: #34 (comment)

Tested successfully with Fedora 27 x86_64 and Fedora 29 x86_64 with update from PR #34

The example extension scripts need to be in sync with new versions of
referenced foreign packages.
This commit also makes them compatible with Python version 3 (retaining
Python 2 compatibility).
An additional example extension "mixed" is added: it implements all caja
extension features and can also be used as a new extension pattern. See
source header comment for a description.

Ref: #34 (comment)
@monnerat monnerat mentioned this pull request Jan 26, 2019
@raveit65 raveit65 requested review from a team January 26, 2019 18:22
@raveit65

Copy link
Copy Markdown
Member

How do you use the examples?
...i never did that in all that years :)

@raveit65

Copy link
Copy Markdown
Member

Got it, the examples needs to be copied to /usr/share/caja-python/extensions/
....i never saw location-widget on the desktop :)
bildschirmfoto zu 2019-01-26 19-56-37

@monnerat

Copy link
Copy Markdown
Contributor Author

How do you use the examples?

See https://github.com/mate-desktop/python-caja/blob/master/examples/README

Personally, in terminal 1:

su
cp extension-file.py /usr/share/caja-python/extensions/

In terminal 2 (as normal user):
killall caja; caja &

Don't forget to remove the extension and restart caja as above after finishing working with it !

@raveit65 raveit65 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,
tested with python-caja build against python2 an python3.
I used #34 for testing examples with python3.
Looks ready to go.

@raveit65 raveit65 requested a review from a team January 26, 2019 19:45

@vkareh vkareh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me, I have way to many plugins running on caja now :D (I'll remove them)

@vkareh vkareh merged commit 6447d7c into mate-desktop:master Jan 30, 2019
@monnerat

Copy link
Copy Markdown
Contributor Author

Thanks for merge!

return

self.bgsettings[BACKGROUND_KEY] = file.get_uri()
self.bgsettings[BACKGROUND_KEY] = self._filepath(file)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... can we just use some other method from GFile to get the filename? It would keep the code simple as before.

@monnerat

monnerat commented Feb 5, 2019

Copy link
Copy Markdown
Contributor Author

can we just use some other method from GFile to get the filename?

Yes we can, although I'm not convinced this is simpler (I've searched several minutes to find this unobvious solution):

if file.get_uri_scheme() == 'file':
    self.bgsettings[BACKGROUND_KEY] = file.get_location().get_path()

It also has the advantage of not using urllib.

Approved? If yes, I'll submit a PR.

@monnerat monnerat deleted the examples branch February 5, 2019 14:41
@monsta monsta mentioned this pull request Feb 6, 2019
@monsta

monsta commented Feb 7, 2019

Copy link
Copy Markdown
Contributor

I didn't know it would be more complex in Python. I looked at C API docs, there's g_file_get_path available. No "get_location" function is mentioned.

@monnerat

monnerat commented Feb 7, 2019

Copy link
Copy Markdown
Contributor Author

I didn't know it would be more complex in Python. I looked at C API docs, there's g_file_get_path available. No "get_location" function is mentioned.

In fact, the value is a CajaFileInfo that does not expose a get_path method. By playing a bit with it, I found get_location that returns a GLocalFile, subclass of Gfile. CajaFileInfo.get_name() returns the unquoted basename only.
I've locally converted the examples to only use CajaFileInfo.get_name() and CajaFileInfo.get_location()get_path() and get rid of the (python 2/3 incompatible) urllib stuff. Would you have a PR for it ?

@monsta

monsta commented Feb 9, 2019

Copy link
Copy Markdown
Contributor

Ok, I didn't know it was CajaFileInfo... If .get_location().get_path() would do it, I'm fine with using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants