<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Actions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Gaby's documentation" HREF="index.html"><LINK REL="UP" TITLE="Gaby Developers' Guide" HREF="p489.html"><LINK REL="PREVIOUS" TITLE="Views" HREF="c679.html"><LINK REL="NEXT" TITLE="An action" HREF="x822.html"></HEAD ><BODY CLASS="CHAPTER" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Gaby's documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="c679.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="x822.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="CHAPTER" ><H1 ><A NAME="PLUGIN-ACTION" ></A >Chapter 10. Actions</H1 ><P >An important issue is that those are action<SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >s</I ></SPAN > plugins, not action plugins. This means that one plugin may (and usually do) contain more than one action. For consistency they should be grouped by purpose (this may have exceptions : if plugins are really specific to an app, they could belong to a special plugin for this app).</P ><DIV CLASS="IMPORTANT" ><P ></P ><TABLE CLASS="IMPORTANT" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/important.gif" HSPACE="5" ALT="Important"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P >There are <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >no</I ></SPAN > ways for the user or the writer of a <TT CLASS="FILENAME" >desc.</TT > file to know which functions are in your plug-ins so <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >you must document your plug-in</I ></SPAN >. This could be done in DocBook format so I can easily put it in this documentation.</P ></TD ></TR ></TABLE ></DIV ><P >Gaby needs to know what it should perform when an user choose "Mail to this guy" in the "Actions" menu. On the other side I already said that Gaby has no way to know the list of functions you export. So, how does it work ? <P ></P ><OL TYPE="1" ><LI ><P >The user choose "Mail to";</P ></LI ><LI ><P >Gaby <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >know</I ></SPAN > that this command is "mail" in a plug-in called "net" thanks to the desc file;</P ></LI ><LI ><P >With this information, Gaby can load your plug-in but it doesn't know (yet) where to find "mail";</P ></LI ><LI ><P >Gaby calls a function <CODE CLASS="FUNCTION" >get_function_by_name</CODE > which you have defined in your plug-in;</P ></LI ><LI ><P >Now that Gaby has all the informations, it can call the right function and the user is happy ...</P ></LI ></OL > </P ><P >In the next sections, I'll write (a little) about <CODE CLASS="FUNCTION" >get_function_by_name</CODE > and (a lot) about the other functions.</P ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="AEN807" >10.1. get_function_by_name</A ></H1 ><DIV CLASS="FUNCSYNOPSIS" ><P ></P ><A NAME="AEN809" ></A ><CODE CLASS="FUNCDEF" >void get_function_by_name</CODE >(gchar* name, action* a);<P ></P ></DIV ><P >This is a simple question whose job is to map functions names to functions. Ususally it will be something like : <DIV CLASS="EXAMPLE" ><A NAME="AEN817" ></A ><P ><B >Example 10-1. <CODE CLASS="FUNCTION" >get_function_by_name</CODE ></B ></P ><PRE CLASS="PROGRAMLISTING" >void get_function_by_name (gchar *name, action *a) { a->function = NULL; if ( strcmp(name, "mail") == 0 ) a->function = mail; if ( strcmp(name, "phone") == 0 ) a->function = phone; }</PRE ></DIV > </P ><P >Simple enough to skip comments ...</P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="c679.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="x822.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Views</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="p489.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >An action</TD ></TR ></TABLE ></DIV ></BODY ></HTML >