[Geany-Devel] Python question
Matthew Brush
mbrush at xxxxx
Fri Apr 25 06:35:56 UTC 2014
On 14-04-24 09:44 PM, Pavel Roschin wrote:
> I'm played with GeanyPy plugin and faced with a problem.
>
> Here is the source code I created to get current document from sidebar:
>
> def press(self, widget, event, data=None):
> if event.button != 2:
> return
> mod, it = widget.get_selection().get_selected()
> doc = mod.get(it, 2)[0]
>
> According to sidebar.c, mod.get(it, 2) should return pointer to Document.
>
This isn't supported/recommended to do in either Geany plugin API or
GeanyPy, but see below.
> But Python doesn't know that this is document and doc variable in this
> example has type GPointer. How can I access to this document from python plugin?
>
> P.S. I tried to use ctypes.cast, no success. Currently I'm addressing document
> with a file path but it is a hack and isn't working for symlinks.
>
If you really want to, maybe try to call the C function
`Document_create_new_from_geany_document()` (in
src/geanypy-document.[ch]) which is used by GeanyPy internally, but
should be callable somehow from Python.
Cheers,
Matthew Brush
More information about the Devel
mailing list