Re: A nautilus script to enqueue folders and files to rhythmbox



Wow Adam!! That was superfast! Appreciate your prompt response. So now, I have a question. If this update_info_full() method gets called for each and every file, then would having such a plugin make sense? Every directory load would start 'n' async threads reading its contents recursively, where n is the number of folders contained within that folder.

I have started to have second thoughts over my plugin now :(
Please advise.

regards,
Seemanta

On Sat, May 1, 2010 at 12:09 AM, Adam Plumb <adamplumb gmail com> wrote:
hi Seemanta, sorry for the confusion, I changed the
update_file_info_async method to update_file_info_full yesterday,
after sending that email.

In order to have cached data available to your get_file_items method,
you would probably want to create a dictionary available throughout
your class, something like self.cache that can be accessed from
anywhere.  update_file_info_full() will get called for each file in a
directory, and you can start a thread or process to cache/process the
file data.  Then when someone right-clicks on a file and
get_file_items is called, you already have the data you need cached.

Adam

On Fri, Apr 30, 2010 at 2:35 PM, Seemanta Dutta <seemanta gmail com> wrote:
> Hi Adam et al,
> I installed the latest nautilus-python from git master but I could not find
> any update_file_info_async() method in it. Perhaps you are referring to
> update_file_info_full() ? What does the *full* signify in these calls ?
>
> And one more question I had was, assuming I get my data and cache it using
> the update_file_info_*() method, how do I make it accessible to to
> get_file_items() method when the user actually right-clicks ? This maybe a
> pretty stupid question but please bear with me, nevertheless.
>
> regards,
> Seemanta
>
> On Wed, Apr 28, 2010 at 7:55 PM, Adam Plumb <adamplumb gmail com> wrote:
>>
>> On Wed, Apr 28, 2010 at 10:11 AM, Seemanta Dutta <seemanta gmail com>
>> wrote:
>> > Actually I did not use update_file_info. I used get_file_list() because
>> > I
>> > derived my class from MenuProvider. Isn't the way I am supposed to do
>> > it? Is
>> > there a better way to do what I have done? Can you please take a look at
>> > my
>> > code and let me know if that is the case? My script is hosted at:
>> > http://seemanta.net/code/Nautilus_plugin/add-to-rhythmbox_V02.py
>> >
>> > In any case, I shall get the latest stuff from git and let you know how
>> > it
>> > goes.
>> >
>> > regards,
>> > Seemanta
>>
>> You have done it correctly.  Looking at your code, I don't see much
>> you can do to improvie things with just sub-classing MenuProvider.
>>
>> One thing you can do is subclass nautilus.InfoProvider and use the
>> update_file_info (or in the case of git master,
>> update_file_info_async) to collect file information asynchronously
>> when the directory is loaded, and then when the user right-clicks on
>> the file and get_file_items() is called, the information is already
>> there.  That may add more complexity than you want to deal with though
>> (for maybe not much benefit).
>>
>> Adam
>>
>> >
>> > On Wed, Apr 28, 2010 at 7:31 PM, Adam Plumb <adamplumb gmail com> wrote:
>> >>
>> >> On Wed, Apr 28, 2010 at 9:18 AM, Seemanta Dutta <seemanta gmail com>
>> >> wrote:
>> >> > Hi Nautilus hackers/users,
>> >> >
>> >> > First of all hats off to all Nautilus hackers. This is such a fine
>> >> > piece
>> >> > of
>> >> > software. I have been using Linux for more than 10 years now and more
>> >> > particularly Gnome where I find Nautilus extremely well integrated.
>> >> > You
>> >> > guys
>> >> > have done a damn fine job of creating/maintaining Nautilus !
>> >> >
>> >> > I recently wrote a small python plugin to enqueue files or folders
>> >> > recursively into the rhythmbox play queue. Please find it here:
>> >> > http://seemanta.net/myblog/?p=634. I am not sure if this is the right
>> >> > place
>> >> > to post this. If there is a dedicated mailing list for python
>> >> > extensions
>> >> > for
>> >> > Nautilus, please let me know.
>> >> >
>> >> > I am however, facing one issue in my script and need your inputs
>> >> > regarding
>> >> > it. Whenever a big folder with several levels of sub-folders and
>> >> > files
>> >> > is
>> >> > selected, there is a high latency in Nautilus during which it seems
>> >> > to
>> >> > become unresponsive. This is because my plugin is creating a list of
>> >> > files
>> >> > that need to be enqueued and this is done recursively. Is there a way
>> >> > to
>> >> > overcome this? I agree, that for huge folders, if I right click the
>> >> > delay
>> >> > might be acceptable. But I think if I simply select a folder, the
>> >> > python
>> >> > plugin should not get invoked.
>> >> >
>> >> > Any ideas how to make my script run only in case of a right-click and
>> >> > not on
>> >> > normal left click selects ?
>> >> >
>> >> > regards,
>> >> > Seemanta
>> >> >
>> >> >
>> >>
>> >> I'm the maintainer for the nautilus-python bindings, and I've been
>> >> doing some work recently to allow for asynchronous IO work in the
>> >> update_file_info method, which I assume is what you are using for your
>> >> IO.  It is still somewhat experimental, but I would appreciate it if
>> >> you could clone git master at
>> >> http://git.gnome.org/browse/nautilus-python and test your extension
>> >> using the new code.  If you do that, let me know whether it alleviates
>> >> the problems you're seeing with your extension.  FYI, you should read
>> >> the new documentation in examples/documentation.py to see how to use
>> >> the new features.
>> >>
>> >> Adam
>> >> --
>> >> nautilus-list mailing list
>> >> nautilus-list gnome org
>> >> http://mail.gnome.org/mailman/listinfo/nautilus-list
>> >
>> >
>
>



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