/** \brief Description yet to be added. **/ int gnoclNotebookCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkWidget *widget; if ( gnoclParseOptions ( interp, objc, objv, notebookOptions ) != TCL_OK ) { gnoclClearOptions ( notebookOptions ); return TCL_ERROR; } widget = gtk_notebook_new(); ret = gnoclSetOptions ( interp, notebookOptions, G_OBJECT ( widget ), -1 ); if ( ret == TCL_OK ) ret = configure ( interp, GTK_NOTEBOOK ( widget ), notebookOptions ); gnoclClearOptions ( notebookOptions ); if ( ret != TCL_OK ) { gtk_widget_destroy ( widget ); return TCL_ERROR; } gtk_widget_show ( widget ); return gnoclRegisterWidget ( interp, widget, notebookFunc ); }
/** /brief /author William J Giddings /date 2008-08 **/ int gnoclDrawingAreaCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkWidget *widget; if ( gnoclParseOptions ( interp, objc, objv, drawingAreaOptions ) != TCL_OK ) { gnoclClearOptions ( drawingAreaOptions ); return TCL_ERROR; } widget = gtk_drawing_area_new (); gtk_widget_show ( GTK_WIDGET ( widget ) ); gnoclSetOptions ( interp, drawingAreaOptions, G_OBJECT ( widget ), -1 ); gnoclClearOptions ( drawingAreaOptions ); /* register the new widget for use with the Tcl interpretor */ return gnoclRegisterWidget ( interp, GTK_WIDGET ( widget ), drawingAreaFunc ); }
int gnoclMenuBarCmd( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkMenuBar *menuBar; if( gnoclParseOptions( interp, objc, objv, menuBarOptions ) != TCL_OK ) { gnoclClearOptions( menuBarOptions ); return TCL_ERROR; } menuBar = GTK_MENU_BAR( gtk_menu_bar_new( ) ); gtk_widget_show( GTK_WIDGET( menuBar ) ); ret = gnoclSetOptions( interp, menuBarOptions, G_OBJECT( menuBar ), -1 ); if( ret == TCL_OK ) ret = configure( interp, menuBar, menuBarOptions ); gnoclClearOptions( menuBarOptions ); if( ret != TCL_OK ) { gtk_widget_destroy( GTK_WIDGET( menuBar ) ); return TCL_ERROR; } return gnoclRegisterWidget( interp, GTK_WIDGET( menuBar ), menuBarFunc ); }
/***f* socket/gnoclSocketCmd * AUTHOR * PGB * SOURCE */ int gnoclSocketCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkSocket *socket; if ( gnoclParseOptions ( interp, objc, objv, socketOptions ) != TCL_OK ) { gnoclClearOptions ( socketOptions ); return TCL_ERROR; } socket = GTK_SOCKET ( gtk_socket_new() ); gtk_widget_show ( GTK_WIDGET ( socket ) ); ret = gnoclSetOptions ( interp, socketOptions, G_OBJECT ( socket ), -1 ); if ( ret == TCL_OK ) ret = configure ( interp, socket, socketOptions ); gnoclClearOptions ( socketOptions ); if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( socket ) ); return TCL_ERROR; } return gnoclRegisterWidget ( interp, GTK_WIDGET ( socket ), socketFunc ); }
/** /brief /author William J Giddings **/ int gnoclFontButtonCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkFontButton *button; if ( gnoclParseOptions ( interp, objc, objv, fontButtonOptions ) != TCL_OK ) { gnoclClearOptions ( fontButtonOptions ); return TCL_ERROR; } button = GTK_FONT_BUTTON ( gtk_font_button_new( ) ); gtk_widget_show ( GTK_WIDGET ( button ) ); ret = gnoclSetOptions ( interp, fontButtonOptions, G_OBJECT ( button ), -1 ); gnoclClearOptions ( fontButtonOptions ); if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( button ) ); return TCL_ERROR; } return gnoclRegisterWidget ( interp, GTK_WIDGET ( button ), fontButtonFunc ); }
int gnoclMenuSeparatorCmd( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkSeparatorMenuItem *separator; if( gnoclParseOptions( interp, objc - 1, objv + 1, separatorOptions ) != TCL_OK ) { gnoclClearOptions( separatorOptions ); return TCL_ERROR; } separator = GTK_SEPARATOR_MENU_ITEM( gtk_separator_menu_item_new( ) ); gtk_widget_show( GTK_WIDGET( separator ) ); /* gtk_widget_set_sensitive( GTK_WIDGET( para->menuItem ), 0 ); */ ret = gnoclSetOptions( interp, separatorOptions, G_OBJECT( separator ), -1 ); gnoclClearOptions( separatorOptions ); if( ret != TCL_OK ) { gtk_widget_destroy( GTK_WIDGET( separator ) ); return TCL_ERROR; } return gnoclRegisterWidget( interp, GTK_WIDGET( separator ), separatorFunc ); }
/** /brief /author Peter G Baum, William J Giddings **/ int gnoclTableCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret = TCL_OK; GtkTable *table; GtkFrame *frame = NULL; GtkWidget *widget; assert ( strcmp ( tableOptions[startFrameOpts].optName, "-label" ) == 0 ); assert ( strcmp ( tableOptions[startCommonOpts].optName, "-name" ) == 0 ); if ( gnoclParseOptions ( interp, objc, objv, tableOptions ) != TCL_OK ) { gnoclClearOptions ( tableOptions ); return TCL_ERROR; } table = GTK_TABLE ( gtk_table_new ( 1, 1, 0 ) ); if ( needFrame ( tableOptions ) ) { frame = GTK_FRAME ( gtk_frame_new ( NULL ) ); gtk_container_add ( GTK_CONTAINER ( frame ), GTK_WIDGET ( table ) ); widget = GTK_WIDGET ( frame ); } else widget = GTK_WIDGET ( table ); /* set default values */ gtk_table_set_row_spacings ( table, GNOCL_PAD_TINY ); gtk_table_set_col_spacings ( table, GNOCL_PAD ); gtk_container_set_border_width ( GTK_CONTAINER ( table ), GNOCL_PAD_TINY ); ret = configure ( interp, frame, table, tableOptions ); gnoclClearOptions ( tableOptions ); if ( ret != TCL_OK ) { gtk_widget_destroy ( widget ); return TCL_ERROR; } gtk_widget_show_all ( widget ); return gnoclRegisterWidget ( interp, widget, tableFunc ); }
/** \brief \author \date **/ int gnoclFontSelectionCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret = TCL_OK; GtkWidget *widget; if ( gnoclParseOptions ( interp, objc, objv, fontSelectOptions ) != TCL_OK ) { gnoclClearOptions ( fontSelectOptions ); return TCL_ERROR; } widget = gtk_font_selection_new() ; gtk_widget_show ( GTK_WIDGET ( widget ) ); ret = gnoclSetOptions ( interp, fontSelectOptions, G_OBJECT ( widget ), -1 ); if ( ret == TCL_OK ) { ret = configure ( interp, G_OBJECT ( widget ), fontSelectOptions ); } gnoclClearOptions ( fontSelectOptions ); /* STEP 3) -show the widget */ if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( widget ) ); return TCL_ERROR; } /* STEP 4) -everything has worked, register the widget with the Tcl interpretor. */ return gnoclRegisterWidget ( interp, GTK_WIDGET ( widget ), fontSelFunc ); return ret; }
/** \brief \author \date **/ int gnoclCalendarCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret = TCL_OK; GtkWidget *calendar; if ( 0 ) { if ( gnoclParseOptions ( interp, objc, objv, calendarOptions ) != TCL_OK ) { gnoclClearOptions ( calendarOptions ); return TCL_ERROR; } } calendar = gtk_calendar_new() ; gtk_widget_show ( GTK_WIDGET ( calendar ) ); if ( 0 ) { ret = gnoclSetOptions ( interp, calendarOptions, G_OBJECT ( calendar ), -1 ); if ( ret == TCL_OK ) { ret = configure ( interp, G_OBJECT ( calendar ), calendarOptions ); } gnoclClearOptions ( calendarOptions ); /* STEP 3) -show the widget */ if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( calendar ) ); return TCL_ERROR; } } /* STEP 4) -everything has worked, register the widget with the Tcl interpretor. */ return gnoclRegisterWidget ( interp, GTK_WIDGET ( calendar ), calendarFunc ); }
/** \brief Function to create and configure an new instance of the button widget. **/ int gnoclButtonCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkButton *button; /* step 1) check validity of switches */ if ( gnoclParseOptions ( interp, objc, objv, buttonOptions ) != TCL_OK ) { gnoclClearOptions ( buttonOptions ); return TCL_ERROR; } /* step 2) create an instance of the widget and 'show' it*/ button = GTK_BUTTON ( gtk_button_new( ) ); gtk_widget_show ( GTK_WIDGET ( button ) ); /* step 3) check the options passed for the creation of the widget */ ret = gnoclSetOptions ( interp, buttonOptions, G_OBJECT ( button ), -1 ); /* step 4) if this is ok, then configure the new widget */ if ( ret == TCL_OK ) { ret = configure ( interp, button, buttonOptions ); } /* step 5) clear the memory set assigned to the options */ gnoclClearOptions ( buttonOptions ); /* step 6) if the options passed were incorrect, then delete the widget */ if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( button ) ); return TCL_ERROR; } /* step 7) the process has been successful, so 'register' the widget with the interpreter */ return gnoclRegisterWidget ( interp, GTK_WIDGET ( button ), buttonFunc ); }
/****f* widget/gnoclLinkButtonCmd * AUTHOR * PGB * SOURCE */ int gnoclLinkButtonCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkWidget *widget; int k, a, b; GnoclOption *pop; char *str_label, *str_uri ; /* determine which type of linkButton to create... */ /* * Do some pre-checking on the options set. * The gtk library has two forms of linkbutton, on with a label or one that simply shows the uri * these values are set at initialisation and so the argument line needs to be parsed so * that a decision can be made as to which type of widget to create. * */ /* * Parse all Options * Picking out individual options from the active script command line. */ for ( k = 1; k < objc; k += 2 ) { int idx; if ( gnoclGetIndexFromObjStruct ( interp, objv[k], ( char ** ) &linkButtonOptions[0].optName, sizeof ( GnoclOption ), "option", TCL_EXACT, &idx ) != TCL_OK ) { return -1; } /* originally, commented out */ /* printf( "parsing %s -> %s\n", Tcl_GetString( objv[k] ), linkButtonOptions[idx].optName); */ if ( strcmp ( Tcl_GetString ( objv[k] ), "-text" ) == 0 ) { str_label = Tcl_GetString ( objv[k+1] ); a = 1; } if ( strcmp ( Tcl_GetString ( objv[k] ), "-uri" ) == 0 ) { str_uri = Tcl_GetString ( objv[k+1] ); b = 1; } } /* decide what to do based on above values in step 2*/ /* STEP 1) -check validity of switches */ if ( gnoclParseOptions ( interp, objc, objv, linkButtonOptions ) != TCL_OK ) { gnoclClearOptions ( linkButtonOptions ); return TCL_ERROR; } /* STEP 2) -create widget, configure it, then clear memory */ /* * a== 1 and b == 1, then create a button with a label. * if a!= 1 and b == 1, then create a button with the URI as label * if b != 1, then this is an error. -uri is a mandatory option. */ if ( a == 1 && b == 1 ) { //printf ("label %s and URI %s\n", str_label, str_uri ); widget = GTK_WIDGET ( gtk_link_button_new_with_label ( str_uri, str_label ) ); } else if ( b == 1 ) { //printf ("URI %s\n", str_uri ); widget = gtk_link_button_new ( str_uri ); } else { //printf ("error\n" ); } a = 0; b = 0; gtk_widget_show ( GTK_WIDGET ( widget ) ); ret = gnoclSetOptions ( interp, linkButtonOptions, G_OBJECT ( widget ), -1 ); if ( ret == TCL_OK ) { ret = configure ( interp, G_OBJECT ( widget ), linkButtonOptions ); } gnoclClearOptions ( linkButtonOptions ); /* STEP 3) -show the widget */ if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( widget ) ); return TCL_ERROR; } /* STEP 4) -everything has worked, register the widget with the Tcl interpretor. */ return gnoclRegisterWidget ( interp, GTK_WIDGET ( widget ), linkButtonFunc ); }