Re: Help with .server file



On Mon, Jan 26, 2004 at 01:59:54PM -0200, Adriano Del Vigna de Almeida wrote:

I'm copying this to the nautilus list in case it might help others. Also I
have been informed that mechanism to create a context menu entry will change
in nautilus 2.5, making all this obsolete. Kind of frustrating after all the
time spent figuring out how to do it.


> But I am having some difficulties, most notabily with Bonobo binding to
> Python.

I did too. It's completely undocumented. The functions don't even have doc
strings. I mostly figured it out by guessing, so I wish the author would
document this stuff.


> In your method 'listener_callback(listener, event_name, args, ev)', what
> are the types of the arguments (listener, event_name, args, ev)? Do you
> know some way to discover this? Since with 'help(bonobo.Listener)', for
> example, I don't have the necessary information of the arguments of the
> __init(...)__ method, do you see the period? :)

You can put print(type(args)) and stuff like that in the listener callback
to print that.


> Also, I tryied to just print the selected files, using your approach of
> the loop:
> 
> for file in args.value():
>     print file
> 
> But I got no prints! 

I am not in a place where I can verify that now. But I am pretty sure I got
the file names printed when I did that.

Run your context menu python script from a shell manually before doing it,
rather than letting nautilus create the server instance through a factory.
It will wait in a loop for events (selecting your menu item).

Also check that old servers are not still running, with something like
killall -9 python. That was a big gotcha I ran into while debugging.


> Using other form of output, the 'zenity' program to
> create a GNOME dialog, again, I got no output, neither a window dialog.
> In fact, I think that this loop doesn't work. And without knowing what
> are the argument types passed to 'listener_callback(...)' I can't find
> any workaround... Plus, where goes the 'print's of Python? I opened a
> terminal and started a Nautilus session and don't see any 'print'
> output... Knowing where are this outputs I could just do a 'print args'
> and check its type...

You must run your equivalent of privateryan-nautilus-context-menu from the
shell. It's a server. The prints will show up in that terminal that you run
the server from.


> More, I don't know if this happens to you, and this is why I think that
> the file loop is wrong, when a server application executes something
> wrong, in the case the suspect query at the 'args' argument, the server
> (context menu entry) is no more executed. I believe that this is a
> bonobo protection, since I have to reboot my machine, or restart
> manually the bonobo server to the context menu entry work again... This
> happens to you?

I don't know. I'll have to check sometime when I am at home.


-- 
Ryan Boder
http://www.bitwiser.org/icanoop



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]