Skip to main content

Posts

Showing posts from July, 2024

Overhaul of widget cget functionality.

The current basis of the cget function for widgets is based upon code written over 20yrs ago and, whilst it works reasonably well for the simple setting of gtk widget properties, support for more complex custom options is hit and miss.   typedef struct GnoclOption_ {     const char *optName;       enum GnoclOptionType type;     const char *propName;     gnoclOptFunc *func;     const char *args;     const char *description;     const char *values;      enum GnoclOptionStatus status;     union {         gboolean b;         gint     i;         gdouble  d;           gchar    *str;           Tcl_Obj  *obj;           } val; } GnoclOption;   With the recent upda...

Obtaining the index of value from an array of strings or an array of structures.

     static char *options[] = {         "-opt1", "-opt2", "-opt3",NULL     }; static enum  optsIdx {     opt1Idx, opt2Idx, opt3Idx     };  gint idx; /* obtain idx from an array of strings */ Tcl_GetIndexFromObj ( interp, objv[1], options, "option", TCL_EXACT, &idx ); /* obtain idx from array of structures, not an array of strings */ Tcl_GetIndexFromObjStruct ( interp, objv[1], ( char ** ) &commands[0].cmdName, sizeof ( GnoclCommand ), "command", TCL_EXACT, &idx );