static int separatorFunc( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx }; GtkSeparatorMenuItem *separator = GTK_SEPARATOR_MENU_ITEM( data ); int idx; if( objc < 2 ) { Tcl_WrongNumArgs( interp, 1, objv, "command" ); return TCL_ERROR; } if( Tcl_GetIndexFromObj( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch( idx ) { case DeleteIdx: return gnoclDelete( interp, GTK_WIDGET( separator ), objc, objv ); case ConfigureIdx: { int ret = gnoclParseAndSetOptions( interp, objc - 1, objv + 1, separatorOptions, G_OBJECT( separator ) ); gnoclClearOptions( separatorOptions ); return ret; } break; } return TCL_OK; }
static int menuBarFunc( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "add", "addBegin", "addEnd", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, AddIdx, BeginIdx, EndIdx }; GtkMenuBar *menuBar = GTK_MENU_BAR( data ); int idx; if( objc < 2 ) { Tcl_WrongNumArgs( interp, 1, objv, "command" ); return TCL_ERROR; } if( Tcl_GetIndexFromObj( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch( idx ) { case DeleteIdx: return gnoclDelete( interp, GTK_WIDGET( menuBar ), objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if( gnoclParseAndSetOptions( interp, objc - 1, objv + 1, menuBarOptions, G_OBJECT( menuBar ) ) == TCL_OK ) { ret = configure( interp, menuBar, menuBarOptions ); } gnoclClearOptions( menuBarOptions ); return ret; } break; case AddIdx: case BeginIdx: case EndIdx: { if( objc != 3 ) { Tcl_WrongNumArgs( interp, 2, objv, "widget-list" ); return TCL_ERROR; } return gnoclMenuShellAddChildren( interp, GTK_MENU_SHELL( menuBar ), objv[2], idx != EndIdx ); } } return TCL_OK; }
/****f* widget/linkButtonFunc * AUTHOR * PGB * SOURCE */ int linkButtonFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "cget", "onClicked", "class", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnClickedIdx, ClassIdx }; #ifdef DEBUG printf ( "linkButtonFunc 1\n" ); #endif GtkWidget *button = GTK_LINK_BUTTON ( data ); #ifdef DEBUG printf ( "linkButtonFunc 2\n" ); #endif int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case ClassIdx: Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "linkButton", -1 ) ); break; case DeleteIdx: { return gnoclDelete ( interp, GTK_WIDGET ( button ), objc, objv ); } case ConfigureIdx: { #ifdef DEBUG printf ( "linkButtonFunc ConfigureIdx\n" ); #endif int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, linkButtonOptions, button ) == TCL_OK ) { ret = configure ( interp, button, linkButtonOptions ); } gnoclClearOptions ( linkButtonOptions ); return ret; } break; case OnClickedIdx: if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } if ( GTK_WIDGET_IS_SENSITIVE ( GTK_WIDGET ( button ) ) ) { gtk_button_clicked ( button ); } break; case CgetIdx: { int idx; switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( button ), linkButtonOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget ( interp, button, linkButtonOptions, idx ); } } } return TCL_OK; }
static int comboBoxFunc( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "cget", "add", "onChanged", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, AddIdx, DoOnChangedIdx }; ComboParams *para = (ComboParams *)data; GtkWidget *widget = GTK_WIDGET( para->comboBox ); int idx; if( objc < 2 ) { Tcl_WrongNumArgs( interp, 1, objv, "command" ); return TCL_ERROR; } if( Tcl_GetIndexFromObj( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch( idx ) { case DeleteIdx: return gnoclDelete( interp, widget, objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if( gnoclParseAndSetOptions( interp, objc - 1, objv + 1, boxOptions, G_OBJECT( widget ) ) == TCL_OK ) { ret = configure( interp, para, boxOptions ); } gnoclClearOptions( boxOptions ); return ret; } break; case CgetIdx: { int idx; switch( gnoclCget( interp, objc, objv, G_OBJECT( para->comboBox ), boxOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget( interp, para, boxOptions, idx ); } } case AddIdx: return addItemTcl( para, interp, objc, objv ); case DoOnChangedIdx: { const char *val; if( objc != 2 ) { Tcl_WrongNumArgs( interp, 2, objv, NULL ); return TCL_ERROR; } val = getActiveValue( para->comboBox ); if( val ) return doCommand( para, val, 0 ); return TCL_OK; } break; } return TCL_OK; }
/** \brief Function associated with the widget. **/ int buttonFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "cget", "onClicked", "class", "parent", "geometry", "toplevel", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnClickedIdx, ClassIdx, ParentIdx, GeometryIdx, ToplevelIdx }; GtkButton *button = GTK_BUTTON ( data ); int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) { return TCL_ERROR; } switch ( idx ) { case ToplevelIdx: { g_print ( "button ToplevelIdx\n" ); GtkWidget *toplevel; Tcl_Obj *obj = NULL; toplevel = gtk_widget_get_toplevel ( button ) ; obj = Tcl_NewStringObj ( gnoclGetNameFromWidget ( toplevel ), -1 ); Tcl_SetObjResult ( interp, obj ); return TCL_OK; } break; case GeometryIdx: { g_print ( "button GeometryIdx\n" ); char *txt = gnoclGetWidgetGeometry ( button ) ; Tcl_SetObjResult ( interp, Tcl_NewStringObj ( txt , -1 ) ); return TCL_OK; } break; case ParentIdx: { GtkWidget * parent; Tcl_Obj *obj = NULL; parent = gtk_widget_get_parent ( GTK_WIDGET ( button ) ); obj = Tcl_NewStringObj ( gnoclGetNameFromWidget ( parent ), -1 ); Tcl_SetObjResult ( interp, obj ); /* this function not working too well! */ /* return gnoclGetParent ( interp, data ); */ return TCL_OK; } break; case ClassIdx: { Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "button", -1 ) ); break; } case DeleteIdx: { return gnoclDelete ( interp, GTK_WIDGET ( button ), objc, objv ); } case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, buttonOptions, G_OBJECT ( button ) ) == TCL_OK ) { ret = configure ( interp, button, buttonOptions ); } gnoclClearOptions ( buttonOptions ); return ret; } break; case OnClickedIdx: if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } if ( GTK_WIDGET_IS_SENSITIVE ( GTK_WIDGET ( button ) ) ) { gtk_button_clicked ( button ); } break; case CgetIdx: { int idx; switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( button ), buttonOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget ( interp, button, buttonOptions, idx ); } } } return TCL_OK; }
/** \brief \author William J Giddings **/ int recentChooserFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { printf ( "widgetFunc\n" ); static const char *cmds[] = { "delete", "configure", "cget", "onClicked", "class", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnClickedIdx, ClassIdx }; GtkWidget *widget = GTK_WIDGET ( data ); int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) { return TCL_ERROR; } switch ( idx ) { case ClassIdx: Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "recentChooser", -1 ) ); break; case DeleteIdx: return gnoclDelete ( interp, GTK_WIDGET ( widget ), objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; ret = configure ( interp, widget, recentChooserOptions ); if ( 1 ) { if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, recentChooserOptions, G_OBJECT ( widget ) ) == TCL_OK ) { ret = configure ( interp, widget, recentChooserOptions ); } } gnoclClearOptions ( recentChooserOptions ); return ret; } break; case OnClickedIdx: if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } if ( GTK_WIDGET_IS_SENSITIVE ( GTK_WIDGET ( widget ) ) ) { gtk_button_clicked ( widget ); } break; case CgetIdx: { int idx; switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( widget ), recentChooserOptions, &idx ) ) { case GNOCL_CGET_ERROR: { return TCL_ERROR; } case GNOCL_CGET_HANDLED: { return TCL_OK; } case GNOCL_CGET_NOTHANDLED: { return cget ( interp, widget, recentChooserOptions, idx ); } } } } return TCL_OK; }
static int spinButtonFunc( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "cget", "onValueChanged", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnValueChangedIdx }; SpinButtonParams *para = (SpinButtonParams *)data; GtkWidget *widget = GTK_WIDGET( para->spinButton ); int idx; if( objc < 2 ) { Tcl_WrongNumArgs( interp, 1, objv, "command" ); return TCL_ERROR; } if( Tcl_GetIndexFromObj( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch( idx ) { case DeleteIdx: return gnoclDelete( interp, widget, objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if( gnoclParseOptions( interp, objc - 1, objv + 1, spinButtonOptions ) == TCL_OK ) { ret = configure( interp, para, spinButtonOptions ); } gnoclClearOptions( spinButtonOptions ); return ret; } break; case CgetIdx: { int idx; switch( gnoclCget( interp, objc, objv, G_OBJECT( para->spinButton ), spinButtonOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget( interp, para, spinButtonOptions, idx ); } } case OnValueChangedIdx: { if( objc != 2 ) { Tcl_WrongNumArgs( interp, 2, objv, NULL ); return TCL_ERROR; } return doCommand( para, getObjValue( para->spinButton ), 0 ); } } return TCL_OK; }
/** \brief \author \date **/ static int fontSelFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "class", "cget", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, ClassIdx, CgetIdx }; GtkWidget *widget = GTK_WIDGET ( data ); int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case ClassIdx: { Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "fontSelection", -1 ) ); } break; case DeleteIdx: { return gnoclDelete ( interp, widget, objc, objv ); } case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, fontSelectOptions, G_OBJECT ( widget ) ) == TCL_OK ) { ret = configure ( interp, widget, fontSelectOptions ); } gnoclClearOptions ( fontSelectOptions ); return ret; } case CgetIdx: { int idx; switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( widget ), fontSelectOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget ( interp, widget, fontSelectOptions, idx ); } } } return TCL_OK; }
/** \brief Description yet to be added. **/ int notebookFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { /* TODO?: notebook insert pos child label ?menu? */ static const char *cmds[] = { "delete", "configure", "addPage", "currentPage", "nextPage", "removePage", "class", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, AddPageIdx, CurrentIdx, NextPageIdx, RemovePageIdx, ClassIdx }; GtkNotebook *notebook = GTK_NOTEBOOK ( data ); int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) { return TCL_ERROR; } switch ( idx ) { case ClassIdx: Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "notebook", -1 ) ); break; case DeleteIdx: return gnoclDelete ( interp, GTK_WIDGET ( notebook ), objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, notebookOptions, G_OBJECT ( notebook ) ) == TCL_OK ) { ret = configure ( interp, notebook, notebookOptions ); } gnoclClearOptions ( notebookOptions ); return ret; } break; case AddPageIdx: { int ret; /* ID addPage child tab ?label? */ if ( objc < 4 || objc > 5 ) { Tcl_WrongNumArgs ( interp, 2, objv, "child label ?menu?" ); return TCL_ERROR; } ret = addPage ( notebook, interp, objv[2], objv[3], objc < 5 ? NULL : objv[4], 1 ); if ( ret < 0 ) { return TCL_ERROR; } /* TODO? associate an ID to every page? */ Tcl_SetObjResult ( interp, Tcl_NewIntObj ( ret ) ); return TCL_OK; } case CurrentIdx: case NextPageIdx: return notebookNext ( notebook, interp, objc, objv, idx == NextPageIdx ); case RemovePageIdx: { int k; if ( objc != 3 ) { Tcl_WrongNumArgs ( interp, 2, objv, "pageNumber" ); return TCL_ERROR; } if ( Tcl_GetIntFromObj ( interp, objv[2], &k ) != TCL_OK ) return TCL_ERROR; gtk_notebook_remove_page ( notebook, k ); return TCL_OK; } } return TCL_OK; }
/** \brief \author Peter G Baum, William J Giddings \date **/ int labelFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "cget", "onChanged", "class", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnChangedIdx, ClassIdx}; LabelParams *para = ( LabelParams * ) data; GtkWidget *widget = GTK_WIDGET ( para->label ); int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case ClassIdx: Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "label", -1 ) ); break; case DeleteIdx: return gnoclDelete ( interp, widget, objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, labelOptions, G_OBJECT ( widget ) ) == TCL_OK ) { ret = configure ( interp, para, labelOptions ); } gnoclClearOptions ( labelOptions ); return ret; } break; case CgetIdx: { int idx; switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( para->label ), labelOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget ( interp, para, labelOptions, idx ); } } case OnChangedIdx: { const char *txt = gtk_label_get_text ( para->label ); if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } return doCommand ( para, txt, 0 ); } } return TCL_OK; }
/***f* socket/staticFuncs/socketFunc * AUTHOR * PGB * SOURCE */ static int socketFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { const char *cmds[] = { "delete", "configure", "getID", "getPlugID", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, GetIDIdx, GetPlugIDIdx }; int idx; GtkSocket *socket = GTK_SOCKET ( data ); if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case DeleteIdx: return gnoclDelete ( interp, GTK_WIDGET ( socket ), objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, socketOptions, G_OBJECT ( socket ) ) == TCL_OK ) { ret = configure ( interp, socket, socketOptions ); } gnoclClearOptions ( socketOptions ); return ret; } break; case GetIDIdx: { long xid; Tcl_Obj *val; if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } #ifdef WIN32 xid = gtk_socket_get_id(socket); #else xid = GDK_WINDOW_XWINDOW ( GTK_WIDGET ( socket )->window ); #endif val = Tcl_NewLongObj ( xid ); Tcl_SetObjResult ( interp, val ); } break; case GetPlugIDIdx: { long xid = 0; Tcl_Obj *val; if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } if ( socket->plug_window ) #ifdef WIN32 xid = gdk_win32_drawable_get_handle( socket->plug_window ); #else xid = GDK_WINDOW_XWINDOW ( socket->plug_window ); #endif val = Tcl_NewLongObj ( xid ); Tcl_SetObjResult ( interp, val ); } break; } return TCL_OK; }
/** \brief Function associated with the widget. */ int entryFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { #ifdef DEBUG_ENTRY g_print ( "entryFunc\n" ); #endif static const char *cmds[] = { "delete", "configure", "cget", "onChanged", "class", "get", "clear", "set", "setPosition", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnChangedIdx, ClassIdx, GetIdx, ClearIdx, SetIdx, SetPositionIdx }; EntryParams *para = ( EntryParams * ) data; //GtkWidget *widget = GTK_WIDGET ( para->entry ); int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case SetPositionIdx: { if ( 1 ) { gtk_entry_set_position ( GTK_WIDGET ( para->entry ) , Tcl_GetString ( objv[2] ) ); } else { gtk_editable_set_position ( GTK_EDITABLE ( GTK_WIDGET ( para->entry ) ) , Tcl_GetString ( objv[2] ) ); } } break; case SetIdx: { /* simply set the text to nothing */ gtk_entry_set_text ( para->entry, Tcl_GetString ( objv[2] ) ); } break; case GetIdx: { /* equivalent to widget cget -value */ Tcl_Obj *obj = NULL; obj = Tcl_NewStringObj ( gtk_entry_get_text ( para->entry ), -1 ); if ( obj != NULL ) { Tcl_SetObjResult ( interp, obj ); return TCL_OK; } } break; case ClearIdx: { /* simply set the text to nothing */ gtk_entry_set_text ( para->entry, "" ); } break; case ClassIdx: { Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "entry", -1 ) ); } break; case DeleteIdx: { return gnoclDelete ( interp, GTK_WIDGET ( para->entry ), objc, objv ); } case ConfigureIdx: { #ifdef DEBUG_ENTRY g_print ( "entryFunc ConfigureIdx\n" ); #endif int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, entryOptions, G_OBJECT ( para->entry ) ) == TCL_OK ) { ret = configure ( interp, para, entryOptions ); } gnoclClearOptions ( entryOptions ); return ret; } break; case CgetIdx: { int idx; switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( para->entry ), entryOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget ( interp, para, entryOptions, idx ); } } case OnChangedIdx: { const char *txt = gtk_entry_get_text ( para->entry ); if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } return doCommand ( para, txt, 0 ); } } return TCL_OK; }
static int comboFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { static const char *cmds[] = { "delete", "configure", "cget", "onChanged", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, OnChangedIdx }; ComboParams *para = ( ComboParams * ) data; GtkWidget *widget = GTK_WIDGET ( para->combo ); int idx; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case DeleteIdx: return gnoclDelete ( interp, widget, objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, comboOptions, G_OBJECT ( widget ) ) == TCL_OK ) { ret = configure ( interp, para, comboOptions ); } gnoclClearOptions ( comboOptions ); return ret; } break; case CgetIdx: { int idx; switch ( gnoclCget ( interp, objc, objv, G_OBJECT ( para->combo ), comboOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget ( interp, para, comboOptions, idx ); } } case OnChangedIdx: { GtkEntry *entry = GTK_ENTRY ( para->combo->entry ); const char *txt = gtk_entry_get_text ( entry ); if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } return doCommand ( para, txt, 0 ); } } return TCL_OK; }
/** /brief /author Peter G Baum, William J Giddings **/ static int tableFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { const char *cmds[] = { "delete", "configure", "add", "addRow", "addColumn", "class", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, AddIdx, AddRowIdx, AddColumnIdx, ClassIdx }; int idx; GtkWidget *widget = GTK_WIDGET ( data ); GtkFrame *frame; GtkTable *table; if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( GTK_IS_FRAME ( widget ) ) { frame = GTK_FRAME ( widget ); table = GTK_TABLE ( gtk_bin_get_child ( GTK_BIN ( frame ) ) ); } else { frame = NULL; table = GTK_TABLE ( widget ); } /* For debugging purposes { guint rows, columns; g_object_get( G_OBJECT( table ), "n_rows", &rows, NULL ); g_object_get( G_OBJECT( table ), "n_columns", &columns, NULL ); printf( "rows: %d cols: %d\n", (int)rows, (int)columns ); } */ if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case ClassIdx: Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "table", -1 ) ); break; case DeleteIdx: return gnoclDelete ( interp, widget, objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseOptions ( interp, objc - 1, objv + 1, tableOptions ) == TCL_OK ) { ret = configure ( interp, frame, table, tableOptions ); } gnoclClearOptions ( tableOptions ); return ret; } break; case AddIdx: return tableFuncAdd ( table, interp, objc, objv ); case AddColumnIdx: case AddRowIdx: return addRowCol ( table, interp, objc, objv, idx == AddRowIdx ); } return TCL_OK; }
static int canvasFunc( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { const char *cmds[] = { "delete", "configure", "cget", "isMapped", "getCurrentSize", "update", "raise", "lower", "create", "itemDelete", "itemShow", "itemConfigure", "itemCget", "itemCommand", "affine", "scale", "move", "rotate", "windowToCanvas", "canvasToWindow", "findItemAt", "getBounds", "findWithTag", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, CgetIdx, IsMappedIdx, GetCurSizeIdx, UpdateIdx, RaiseIdx, LowerIdx, CreateIdx, ItemDeleteIdx, ItemShowIdx, ItemConfigureIdx, ItemCgetIdx, ItemCommandIdx, AffineIdx, ScaleIdx, MoveIdx, RotateIdx, WindowToCanvasIdx, CanvasToWindowIdx, FindItemAtIdx, GetBoundsIdx, GetIDsFromTagIdx }; CanvasParams *para = (CanvasParams *)data; GtkWidget *widget = GTK_WIDGET( para->canvas ); int idx; if( objc < 2 ) { Tcl_WrongNumArgs( interp, 1, objv, "command" ); return TCL_ERROR; } if( Tcl_GetIndexFromObj( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch( idx ) { case DeleteIdx: return gnoclDelete( interp, widget, objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if( gnoclParseAndSetOptions( interp, objc - 1, objv + 1, canvasOptions, G_OBJECT( widget ) ) == TCL_OK ) { if( canvasOptions[antialiasedIdx].status == GNOCL_STATUS_CHANGED ) { Tcl_SetResult( interp, "antialiasing cannot be changed " "after creation", TCL_STATIC ); } else ret = configure( interp, para, canvasOptions ); } gnoclClearOptions( canvasOptions ); return ret; } break; case CgetIdx: { int idx; switch( gnoclCget( interp, objc, objv, G_OBJECT( widget ), canvasOptions, &idx ) ) { case GNOCL_CGET_ERROR: return TCL_ERROR; case GNOCL_CGET_HANDLED: return TCL_OK; case GNOCL_CGET_NOTHANDLED: return cget( interp, para->canvas, canvasOptions, idx ); } break; } case IsMappedIdx: return isMapped( interp, widget, objc, objv ); case GetCurSizeIdx: return getCurSize( interp, widget, objc, objv ); case UpdateIdx: if( objc != 2 ) { Tcl_WrongNumArgs( interp, 2, objv, NULL ); return TCL_ERROR; } gnome_canvas_update_now( para->canvas ); break; case CreateIdx: return canvasCreateItem( interp, objc, objv, para ); case RaiseIdx: case LowerIdx: case ItemDeleteIdx: case ItemShowIdx: case ItemConfigureIdx: case ItemCgetIdx: case ItemCommandIdx: case AffineIdx: case ScaleIdx: case MoveIdx: case RotateIdx: case GetBoundsIdx: case GetIDsFromTagIdx: { GPtrArray *items; int ret; if( objc < 3 ) { Tcl_WrongNumArgs( interp, 2, objv, "tag-or-id ?option val ...?" ); return TCL_ERROR; } if( gnoclCanvasItemsFromTagOrId( interp, para, Tcl_GetString( objv[2] ), &items ) != TCL_OK ) return TCL_ERROR; switch( idx ) { case RaiseIdx: case LowerIdx: ret = itemRaise( interp, objc, objv, para, items, idx == RaiseIdx ); break; case ItemDeleteIdx: ret = itemDelete( interp, objc, objv, para, items ); break; case ItemShowIdx: ret = itemShow( interp, objc, objv, para, items ); break; case ItemConfigureIdx: ret = itemConfigure( interp, objc, objv, para, items ); break; case ItemCgetIdx: ret = itemCget( interp, objc, objv, para, items ); break; case ItemCommandIdx: ret = itemCommand( interp, objc, objv, para, items ); break; case AffineIdx: ret = affine( interp, objc, objv, para, items, Affine ); break; case ScaleIdx: ret = affine( interp, objc, objv, para, items, Scale ); break; case MoveIdx: ret = affine( interp, objc, objv, para, items, Move ); break; case RotateIdx: ret = affine( interp, objc, objv, para, items, Rotate ); break; case GetBoundsIdx: ret = itemBounds( interp, objc, objv, para, items ); break; case GetIDsFromTagIdx: ret = getIDs( interp, objc, objv, para, items ); break; default: assert( 0 ); } if( items ) g_ptr_array_free( items, 0 ); return ret; } break; case WindowToCanvasIdx: return windowToCanvas( interp, objc, objv, para, 0 ); case CanvasToWindowIdx: return windowToCanvas( interp, objc, objv, para, 1 ); case FindItemAtIdx: return findItemAt( interp, objc, objv, para ); } return TCL_OK; }