Desktop/Gnocl Release/gnocl-0.9.94/src/newGnoclPackage/src/gnoclSpellCheck.c File Reference

#include "gnoclSpellCheck.h"

Include dependency graph for gnoclSpellCheck.c:

Go to the source code of this file.

Functions

int Gnoclspellcheck_Init (Tcl_Interp *interp)
 Implement gnocl::vt.
int gnoclSpellCheckCmd (ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Toggles on/off the autospell check feature.


Function Documentation

int Gnoclspellcheck_Init ( Tcl_Interp *  interp  ) 

Implement gnocl::vt.

Parameters:
Tcl_Interp *interp Pointer to client visible fields of interpreter structure.

Definition at line 15 of file gnoclSpellCheck.c.

References gnoclSpellCheckCmd.

00016 {
00017 
00018     printf ( "Initializing gnocl bindings to GtkSpell libraries, version %s\n", VERSION );
00019 
00020     if ( Tcl_InitStubs ( interp, "8.3", 0 ) == NULL )
00021         return TCL_ERROR;
00022 
00023     if ( Tcl_PkgRequire ( interp, "Gnocl", VERSION, 0 ) == NULL )
00024         return TCL_ERROR;
00025 
00026     if ( Tcl_PkgProvide ( interp, "GnoclSpellCheck", VERSION ) != TCL_OK )
00027         return TCL_ERROR;
00028 
00029     /* gnoclSpellCheckCmd is located in spellcheck.c */
00030     Tcl_CreateObjCommand ( interp, "gnocl::spellcheck", gnoclSpellCheckCmd, NULL, NULL );
00031 
00032     return TCL_OK;
00033 }

int gnoclSpellCheckCmd ( ClientData  data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[] 
)

Toggles on/off the autospell check feature.

Author:
William J Giddings
Date:
30-Oct-2010
Note:

Definition at line 44 of file gnoclSpellCheck.c.

00045 {
00046 
00047     printf ( "gnocl::spellcheck  0 = %s 1 = %s 2 = %s \n",
00048              Tcl_GetString ( objv[0] ) ,
00049              Tcl_GetString ( objv[1] ) ,
00050              Tcl_GetString ( objv[2] ) );
00051 
00052 
00053 
00054     static const char *cmd[] = { "on", "off",
00055                                  NULL
00056                                };
00057     enum cmdIdx { OnIdx, OffIdx
00058                 };
00059 
00060     int  idx;
00061 
00062     char        *key = NULL;
00063     int         ret = TCL_ERROR;
00064 
00065     if ( objc < 2 )
00066     {
00067         Tcl_WrongNumArgs ( interp, 1, objv, "subCommand" );
00068         return TCL_ERROR;
00069     }
00070 
00071     if ( Tcl_GetIndexFromObj ( interp, objv[1], cmd, "subCommand", TCL_EXACT,
00072                                &idx ) != TCL_OK )
00073         return TCL_ERROR;
00074 
00075 // GtkWidget *gnoclGetWidgetFromName ( Tcl_GetString ( objv[2] ) , interp );
00076 
00077     GtkTextView     *text;
00078 
00079     switch ( idx )
00080     {
00081         case OnIdx:
00082             printf ( "gnocl::spellcheck on \n" );
00083 
00084             /* the name of a gnocl::text relates to the container, a scrolled window, the GtkTextView is its child */
00085             text = GTK_TEXT_VIEW ( gtk_bin_get_child ( gnoclGetWidgetFromName ( Tcl_GetString ( objv[2] ) , interp ) ) );
00086 
00087 
00088             gtkspell_new_attach ( text , NULL, NULL );
00089             break;
00090         case OffIdx:
00091             printf ( "gnocl::spellcheck off \n" );
00092             text = GTK_TEXT_VIEW ( gtk_bin_get_child ( gnoclGetWidgetFromName ( Tcl_GetString ( objv[2] ) , interp ) ) );
00093             gtkspell_detach ( gtkspell_get_from_text_view ( text ) );
00094             break;
00095     }
00096 
00097     return TCL_OK;
00098 }


doxygen