Re: CVS: commit dom abiword-plugins/tools/gdict/unix GdictAbiPlugin.cpp

From: Dom Lachowicz <domlachowicz_at_yahoo.com>
Date: Thu Apr 13 2006 - 16:57:45 CEST

Please formward-port. Thanks.

--- cvs@abisource.com wrote:

>
> Update of /cvsroot/abiword-plugins/tools/gdict/unix
> In directory
> abiword.snt.utwente.nl:/tmp/cvs-serv4953/unix
>
> Modified Files:
> Tag: ABI-2-4-0-STABLE
> GdictAbiPlugin.cpp
> Log Message:
> 10184, for real this time
>
> Index: GdictAbiPlugin.cpp
>
===================================================================
> RCS file:
>
/cvsroot/abiword-plugins/tools/gdict/unix/GdictAbiPlugin.cpp,v
> retrieving revision 1.20.2.1
> retrieving revision 1.20.2.2
> diff -u -d -r1.20.2.1 -r1.20.2.2
> --- GdictAbiPlugin.cpp 13 Apr 2006 12:39:39 -0000
> 1.20.2.1
> +++ GdictAbiPlugin.cpp 13 Apr 2006 14:33:33 -0000
> 1.20.2.2
> @@ -39,6 +39,41 @@
> #include "xap_UnixFrameImpl.h"
> #include "xap_UnixDialogHelper.h"
>
> +#ifdef USE_FORK_AND_EXEC_METHOD
> +
> +#include <sys/types.h>
> +#include <sys/wait.h>
> +#include <unistd.h>
> +
> +static void
> +GDict_exec (const char * search)
> +{
> + pid_t pid;
> +
> + if ( (pid = fork ()) == 0 )
> + {
> + // child
> + const char *args[3];
> + args[0] = "--noapplet"; // definitely needed
> for kde users, for example
> + args[1] = search;
> + args[2] = 0;
> +
> + exit ( execvp ( "gnome-dictionary", (char **)
> args ) );
> + // TODO: be smarter with warnings and such
> + }
> + else if ( pid > 0 )
> + {
> + // parent
> + waitpid ( pid, 0, WNOHANG );
> + }
> + else
> + {
> + // couln't spawn
> + }
> +}
> +
> +#else
> +
> #include <gnome.h>
> #include <libgdict/gdict-defbox.h>
>
> @@ -184,6 +219,8 @@
> gdict_defbox_lookup (GDICT_DEFBOX (gdict_defbox),
> (char*)search);
> }
>
> +#endif /* USE_FORK_AND_EXEC_METHOD */
> +
> //
> // GDict_invoke
> // -------------------
> @@ -205,18 +242,14 @@
> pView->moveInsPtTo(FV_DOCPOS_BOW);
> pView->extSelTo(FV_DOCPOS_EOW_SELECT);
>
> - // Now we will figure out what word to look up
> when we open our dialog.
> - if (!pView->isSelectionEmpty())
> - {
> - // We need to get the Ascii version of the
> current word.
> - UT_UCS4Char *ucs4ST = NULL;
> - pView->getSelectionText(*&ucs4ST);
> - if (ucs4ST) {
> - UT_UTF8String search(ucs4ST);
> - GDict_exec (search.utf8_str());
> - FREEP(ucs4ST);
> - }
> - }
> + // We need to get the utf-8 version of the
> current word.
> + UT_UCS4Char *ucs4ST = NULL;
> + pView->getSelectionText(*&ucs4ST);
> + if (ucs4ST) {
> + UT_UTF8String search(ucs4ST);
> + GDict_exec (search.utf8_str());
> + FREEP(ucs4ST);
> + }
>
> return true;
> }
>
> -----------------------------------------------
> To unsubscribe from this list, send a message to
> abisource-cvs-commit-request@abisource.com with the
> word
> unsubscribe in the message body.
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Received on Thu Apr 13 17:01:47 2006

This archive was generated by hypermail 2.1.8 : Thu Apr 13 2006 - 17:01:47 CEST