Re: Regarding Nautilus scripts



Am Mon, 2003-06-09 um 20.38 schrieb Andrew Sobala:
> FWIW, it is a simple API. Even I understand it. It doesn't involve
> nautilus internals.

<aol>It's a simple API and I understand it</aol>. I tried in python and
the result is attached. Of course, I'm not a Nautilus coder like Dave
Camp so I needed 25 lines of python and 26 lines of .server stuff and
not 10+20. And it would have helped if I had written pygtk in the past,
but hey, it Works For Me (TM)

You have to adapt the path in the server file and save it in a directory
where bonobo-activation can find it. Then right-click on a text/plain
file.

> Sending stuff back to nautilus isn't implemented in it yet, though.

But that would be nice.

	Martin
#! /usr/bin/env python

import pygtk
pygtk.require("2.0")
import CORBA
import bonobo
import gtk
import gnome

def listener_cb (listener, event_name, args, ev):
        if (event_name == "DoSomething"):
                uris = args.value ()
                dlg = gtk.MessageDialog (message_format = " ".join (uris))
                dlg.show ()

def action_factory (factory, iid):
        if (iid != 'OAFIID:GNOME_Sample_MimeAction_Actions'):
                print "Don't know how to make a " + `iid`
                return None

        return bonobo.Listener (listener_cb)

gnome.init('python-mime-action', '1.0')
bonobo.GenericFactory('OAFIID:GNOME_Sample_MimeAction_Factory', action_factory)
bonobo.main()
<oaf_info>  
  <oaf_server iid="OAFIID:GNOME_Sample_MimeAction_Factory"
    	      type="exe" location="/home/martin/tmp/test-mime-action.py">
    <oaf_attribute name="repo_ids" type="stringv">
      <item value="IDL:Bonobo/GenericFactory:1.0"/>
    </oaf_attribute>
  </oaf_server>  
  <oaf_server iid="OAFIID:GNOME_Sample_MimeAction_Actions" 
    type="factory" location="OAFIID:GNOME_Sample_MimeAction_Factory">
    <oaf_attribute name="repo_ids" type="stringv">
      <item value="IDL:Bonobo/Unknown:1.0"/>
      <item value="IDL:Bonobo/Listener:1.0"/>
    </oaf_attribute>
    <oaf_attribute name="name" type="string" value="Mime Actions"/>
    <oaf_attribute name="description" type="string" value="Mime Actions"/>
    <oaf_attribute name="bonobo:supported_mime_types" type="stringv">
      <item value="text/plain"/>
    </oaf_attribute>
    <oaf_attribute name="nautilus:context_menu_handler"
    		   type="boolean" value="true"/>	
    <oaf_attribute name="nautilus:can_handle_multiple_files"
    		   type="boolean" value="true" />
    <oaf_attribute name="nautilusverb:DoSomething" type="string"
    		   value="Do Something" />
  </oaf_server>  
</oaf_info>


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