Beispiel #1
0
/**
\brief
    Function associated with the widget.
*/
int gnoclEntryCmd (
	ClientData data,
	Tcl_Interp *interp,
	int objc,
	Tcl_Obj * const objv[] )
{
#ifdef DEBUG_ENTRY
	printf ( "entry/staticFuncs/gnoclEntryCmd\n" );
#endif

	EntryParams *para;
	int ret;

	if ( gnoclParseOptions ( interp, objc, objv, entryOptions ) != TCL_OK )
	{
		gnoclClearOptions ( entryOptions );
		return TCL_ERROR;
	}

	para = g_new ( EntryParams, 1 );

	para->entry = GTK_ENTRY ( gtk_entry_new( ) );
	para->interp = interp;
	para->variable = NULL;
	para->onChanged = NULL;
	para->inSetVar = 0;

	gtk_entry_set_activates_default ( para->entry, TRUE );


	gtk_widget_show ( GTK_WIDGET ( para->entry ) );

	ret = gnoclSetOptions ( interp, entryOptions, G_OBJECT ( para->entry ), -1 );

	if ( ret == TCL_OK )
	{
		ret = configure ( interp, para, entryOptions );
	}

	gnoclClearOptions ( entryOptions );

	if ( ret != TCL_OK )
	{
		gtk_widget_destroy ( GTK_WIDGET ( para->entry ) );
		g_free ( para );
		return TCL_ERROR;
	}

	para->name = gnoclGetAutoWidgetId();

	g_signal_connect ( G_OBJECT ( para->entry ), "destroy", G_CALLBACK ( destroyFunc ), para );

	gnoclMemNameAndWidget ( para->name, GTK_WIDGET ( para->entry ) );

	Tcl_CreateObjCommand ( interp, para->name, entryFunc, para, NULL );

	Tcl_SetObjResult ( interp, Tcl_NewStringObj ( para->name, -1 ) );

	return TCL_OK;
}
Beispiel #2
0
static int makeComboBox( Tcl_Interp *interp, int objc, 
      Tcl_Obj * const objv[], int isEntry )
{
   ComboParams     *para;
   GtkTreeModel    *model;
   int             ret;
   
   if( gnoclParseOptions( interp, objc, objv, boxOptions ) != TCL_OK )
   {
      gnoclClearOptions( boxOptions );
      return TCL_ERROR;
   }

   model = GTK_TREE_MODEL( gtk_list_store_new( 3, G_TYPE_STRING, 
         G_TYPE_STRING, GDK_TYPE_PIXBUF ) );

   para = g_new( ComboParams, 1 );
   para->interp = interp;
   para->onChanged = NULL;
   para->variable = NULL;
   para->name = gnoclGetAutoWidgetId();
   para->comboBox = GTK_COMBO_BOX( 
         isEntry ? gtk_combo_box_entry_new_with_model( model, VALUE_COLUMN ) 
                 : gtk_combo_box_new_with_model( model ) ); 
   para->inSetVar = 0;

   if( isEntry == 0 )
   {
      GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
      gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( para->comboBox ), 
            renderer, TEXT_COLUMN );
      gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( para->comboBox ), 
            renderer, "text", TEXT_COLUMN, NULL );
   }

   gtk_widget_show( GTK_WIDGET( para->comboBox ) ); 

   ret = gnoclSetOptions( interp, boxOptions, G_OBJECT( para->comboBox ), -1 );
   if( ret == TCL_OK )
      ret = configure( interp, para, boxOptions );
   gnoclClearOptions( boxOptions );

   if( ret != TCL_OK )
   {
      gtk_widget_destroy( GTK_WIDGET( para->comboBox ) );
      g_free( para );
      return TCL_ERROR;
   }
   g_signal_connect( GTK_OBJECT( para->comboBox ), "destroy", 
         G_CALLBACK( destroyFunc ), para );

   gnoclMemNameAndWidget( para->name, GTK_WIDGET( para->comboBox ) );

   Tcl_CreateObjCommand( interp, para->name, comboBoxFunc, para, NULL );
   Tcl_SetObjResult( interp, Tcl_NewStringObj( para->name, -1 ) );

   return TCL_OK;
}
Beispiel #3
0
int gnoclComboCmd ( ClientData data, Tcl_Interp *interp,
					int objc, Tcl_Obj * const objv[] )
{
	ComboParams *para;
	int ret;

	if ( gnoclParseOptions ( interp, objc, objv, comboOptions )
			!= TCL_OK )
	{
		gnoclClearOptions ( comboOptions );
		return TCL_ERROR;
	}

	para = g_new ( ComboParams, 1 );

	para->interp = interp;
	para->combo = GTK_COMBO ( gtk_combo_new( ) );
	para->variable = NULL;
	para->onChanged = NULL;
	para->inSetVar = 0;

	ret = gnoclSetOptions ( interp, comboOptions,
							G_OBJECT ( para->combo ), -1 );

	if ( ret == TCL_OK )
		ret = configure ( interp, para, comboOptions );

	gnoclClearOptions ( comboOptions );

	if ( ret != TCL_OK )
	{
		g_free ( para );
		gtk_widget_destroy ( GTK_WIDGET ( para->combo ) );
		return TCL_ERROR;
	}

	para->name = gnoclGetAutoWidgetId();

	g_signal_connect ( G_OBJECT ( para->combo ), "destroy",
					   G_CALLBACK ( destroyFunc ), para );

	gnoclMemNameAndWidget ( para->name, GTK_WIDGET ( para->combo ) );
	gtk_widget_show ( GTK_WIDGET ( para->combo ) );

	Tcl_CreateObjCommand ( interp, para->name, comboFunc, para, NULL );

	Tcl_SetObjResult ( interp, Tcl_NewStringObj ( para->name, -1 ) );

	return TCL_OK;
}
Beispiel #4
0
int gnoclSpinButtonCmd( ClientData data, Tcl_Interp *interp,
      int objc, Tcl_Obj * const objv[] )
{
   SpinButtonParams *para;

   if( gnoclParseOptions( interp, objc, objv, spinButtonOptions ) != TCL_OK )
   {
      gnoclClearOptions( spinButtonOptions );
      return TCL_ERROR;
   }

   para = g_new( SpinButtonParams, 1 );
   para->spinButton = GTK_SPIN_BUTTON( gtk_spin_button_new( 
            GTK_ADJUSTMENT( gtk_adjustment_new( 0, 0, 100, 
            1, 10, 20 ) ), 1.0, 1 ) );
   para->interp = interp;
   para->variable = NULL;
   para->onValueChanged = NULL;
   para->inSetVar = 0;

   gtk_spin_button_set_numeric( para->spinButton, 1 );

   gtk_widget_show( GTK_WIDGET( para->spinButton ) );

   if( configure( interp, para, spinButtonOptions ) != TCL_OK )
   {
      g_free( para );
      gtk_widget_destroy( GTK_WIDGET( para->spinButton ) );
      gnoclClearOptions( spinButtonOptions );
      return TCL_ERROR;
   }
   gnoclClearOptions( spinButtonOptions );

   para->name = gnoclGetAutoWidgetId();

   g_signal_connect( G_OBJECT( para->spinButton ), "destroy", 
         G_CALLBACK( spinButtonDestroyFunc ), para );

   gnoclMemNameAndWidget( para->name, GTK_WIDGET( para->spinButton ) );

   Tcl_CreateObjCommand( interp, para->name, spinButtonFunc, para, NULL );

   Tcl_SetObjResult( interp, Tcl_NewStringObj( para->name, -1 ) );

   return TCL_OK;
}
Beispiel #5
0
/**
\brief
\author     Peter G Baum, William J Giddings
\date
**/
int gnoclLabelCmd (
	ClientData data,
	Tcl_Interp *interp,
	int objc,
	Tcl_Obj * const objv[] )
{
#ifdef DEBUG_LABEL
	printf ( "label/staticFuncs/gnoclLabelCmd\n" );
#endif

	LabelParams *para;
	int ret;

	if ( gnoclParseOptions ( interp, objc, objv, labelOptions ) != TCL_OK )
	{
		gnoclClearOptions ( labelOptions );
		return TCL_ERROR;
	}

	para = g_new ( LabelParams, 1 );

	para->label = GTK_LABEL ( gtk_label_new ( NULL ) );
	para->interp = interp;
	para->textVariable = NULL;
	para->onChanged = NULL;
	para->inSetVar = 0;

	gtk_widget_show ( GTK_WIDGET ( para->label ) );

	/* added 14/Jan/2010 */
	gtk_label_set_use_markup ( para->label, TRUE );


	ret = gnoclSetOptions ( interp, labelOptions, G_OBJECT ( para->label ), -1 );

	if ( ret == TCL_OK )
	{
		ret = configure ( interp, para, labelOptions );
	}

	gnoclClearOptions ( labelOptions );

	if ( ret != TCL_OK )
	{
		gtk_widget_destroy ( GTK_WIDGET ( para->label ) );
		g_free ( para );
		return TCL_ERROR;
	}

	para->name = gnoclGetAutoWidgetId();

	g_signal_connect ( G_OBJECT ( para->label ), "destroy", G_CALLBACK ( destroyFunc ), para );

	gnoclMemNameAndWidget ( para->name, GTK_WIDGET ( para->label ) );

	Tcl_CreateObjCommand ( interp, para->name, labelFunc, para, NULL );

	Tcl_SetObjResult ( interp, Tcl_NewStringObj ( para->name, -1 ) );

	return TCL_OK;
}
Beispiel #6
0
int gnoclCanvasCmd( ClientData data, Tcl_Interp *interp,
      int objc, Tcl_Obj * const objv[] )
{
   CanvasParams *para;
   int          ret;

   if( gnoclParseOptions( interp, objc, objv, canvasOptions ) != TCL_OK )
   {
      gnoclClearOptions( canvasOptions );
      return TCL_ERROR;
   }

   para = g_new( CanvasParams, 1 );

   /* what is that for? Found in canvas demos. */
   gtk_widget_push_colormap( gdk_rgb_get_cmap() );

   /* antialiased is default */
   if( canvasOptions[antialiasedIdx].status == GNOCL_STATUS_CHANGED &&
         canvasOptions[antialiasedIdx].val.b == 0 )
   {
      para->canvas = GNOME_CANVAS( gnome_canvas_new( ) );
   }
   else
      para->canvas = GNOME_CANVAS( gnome_canvas_new_aa( ) );

   gtk_widget_show( GTK_WIDGET( para->canvas ) );

   /*
   TODO: what is that for? Found in canvas demos. 
   gtk_widget_pop_colormap(); 
   */

   gnome_canvas_set_center_scroll_region( para->canvas, 0 );
   ret = gnoclSetOptions( interp, canvasOptions, 
         G_OBJECT( para->canvas ), -1 );
   if( ret == TCL_OK )
      ret = configure( interp, para, canvasOptions );
   gnoclClearOptions( canvasOptions );

   if( ret != TCL_OK )
   {
      gtk_widget_destroy( GTK_WIDGET( para->canvas ) );
      g_free( para );
      return TCL_ERROR;
   }

   para->name = gnoclGetAutoWidgetId();
   gnoclMemNameAndWidget( para->name, GTK_WIDGET( para->canvas ) );

   /* TODO: g_hash_table_new_full */
   para->tagToItems = g_hash_table_new_full( g_str_hash, g_str_equal,
         g_free, ptrArrayFree );
   para->interp = interp;
   g_signal_connect_after( G_OBJECT( para->canvas ), "destroy", 
         G_CALLBACK( destroyFunc ), para );

   Tcl_CreateObjCommand( interp, para->name, canvasFunc, para, NULL );

   Tcl_SetObjResult( interp, Tcl_NewStringObj( para->name, -1 ) );

   return TCL_OK;
}