00001
00009 #include "gnoclSpellCheck.h"
00010
00015 int Gnoclspellcheck_Init ( Tcl_Interp *interp )
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
00030 Tcl_CreateObjCommand ( interp, "gnocl::spellcheck", gnoclSpellCheckCmd, NULL, NULL );
00031
00032 return TCL_OK;
00033 }
00034
00035
00036
00044 int gnoclSpellCheckCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] )
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
00076
00077 GtkTextView *text;
00078
00079 switch ( idx )
00080 {
00081 case OnIdx:
00082 printf ( "gnocl::spellcheck on \n" );
00083
00084
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 }