gnome-do plugin [part 1]: create an action

I started trying out gnome-do when I read an article about the upcoming ontology based tools (gnome-do and ubiquity) in Linux for you. There are many plug-ins available for gnome-do (official and community). I am using Debian(lenny) and had a hard time in setting it up. Setting up do from source was easy, but setting up the plug-ins from source was hard. Do plug-ins (0.8.3) depends on banshee (>=1.4.3), but debian lenny had a lesser version. Then I tried to set up banshee from source which again asked for gstreamer-* > 0.10.3 which was not available in Lenny. Moreover the first step for building banshee in Lenny has failed (apt-get build-dep banshee). Finally, I migrated to debian testing and got gnome-do and its plug-ins from debian repository without any problem. Its time to start our own plug-in, before proceeding to this step, I tried to build a plug-in( EOG-Slideshow ) that is available already in launchpad. All you have to do is,

1. run gnome-do from terminal

2. open the project file in monodevelop

3. build it from Monodevelop.

4. Now, open the plug-ins list by clicking on do in system tray and selecting the preferences. The list of plug-ins available are listed here.

5. We have to drag the dll (which we had compiled just now) and drop it in.

6. Terminal should show the status that the plug-in is getting installed. once it is installed then we shall enable it and start using.

Now, lets start writing the plug-in, the simplest plug-in that I found on net is Google-Search. There are few changes required (we need to include .addin.xml for the plug-in and we should inherit Act etc..).

HelloWorld.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using Do.Universe;
namespace HelloWorld
{
class HelloWorldAction : Act
{
public override string Name {
get { return "HelloWorld"; }
}
public override string Description {
get { return "Say Hello World."; }
}
public override string Icon {
get { return "search"; }
}
public override IEnumerable SupportedItemTypes {
get { return new Type[] { typeof (ITextItem) }; }
}
public override IEnumerable Perform (IEnumerable items, IEnumerable modItems) {
string query = (items.First() as ITextItem).Text;
System.Diagnostics.Process.Start("/usr/bin/xmessage", " -center -default okay hello, " + query);
return null;
}
}
}

HelloWorld.addin.xml:

<Addin
id="HelloWorld"
namespace= "Do"
version="0.1"
name="HelloWorld"
description="Say Hello World."
author="SatheeshKumar Mohan"
category="Community"
>

how to compile it?

$ gmcs -target:library -r:/usr/lib/gnome-do/Do.Universe.dll HelloWorld.cs "/res:HelloWorld.addin.xml"
That’s it, add the plugin to gnome-do as we did earlier and enable it. Just launch do, type anything say, sathyz and select the action “hello world”, it will display an xmessage saying “Hello, sathyz”.

The principle is this action is supported for any text item, (so the source here is text) and action to perform is show a dialog saying hello, # that text#. In the next part l am trying to get data from a specific source, say the data for Rhythmbox comes from rhythmbox.db,for ssh connect it is ~/.ssh/config.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s