Esempio n. 1
0
File: table.c Progetto: zdia/gnocl
/**
/brief
/author     Peter G Baum, William J Giddings
**/
static int configure ( Tcl_Interp *interp, GtkFrame *frame, GtkTable *table,
					   GnoclOption options[] )
{
	GtkWidget *widget = frame ? GTK_WIDGET ( frame ) : GTK_WIDGET ( table );

	if ( frame == NULL && needFrame ( options ) )
	{
		Tcl_SetResult ( interp, "Frame options can only be set if a "
						"frame option is given on creation (for example -shadow none).",
						TCL_STATIC );
		return TCL_ERROR;
	}

	if ( frame != NULL )
	{
		if ( gnoclSetOptions ( interp, options + startFrameOpts,
							   G_OBJECT ( frame ), startCommonOpts - startFrameOpts ) != TCL_OK )
			return TCL_ERROR;
	}

	if ( gnoclSetOptions ( interp, tableOptions, G_OBJECT ( table ),
						   startFrameOpts ) != TCL_OK )
		return TCL_ERROR;

	if ( gnoclSetOptions ( interp, tableOptions + startCommonOpts,
						   G_OBJECT ( widget ), -1 ) != TCL_OK )
		return TCL_ERROR;

	return TCL_OK;
}
Esempio n. 2
0
/**
/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 );
}
Esempio n. 3
0
/**
\brief
\author     William J Giddings
\date       18/Feb/2010
\since      0.9.94
**/
static int configure ( Tcl_Interp *interp, GtkDrawingArea *area, GnoclOption options[] )
{

	gint ret = gnoclSetOptions ( interp, options, area, -1 );

	return TCL_OK;
}
Esempio n. 4
0
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 );
}
Esempio n. 5
0
/**
/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 );

}
Esempio n. 6
0
/**
\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 );
}
Esempio n. 7
0
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 );
}
Esempio n. 8
0
File: socket.c Progetto: zdia/gnocl
/***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 );
}
Esempio n. 9
0
File: entry.c Progetto: zdia/gnocl
/**
\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;
}
Esempio n. 10
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;
}
Esempio n. 11
0
static int setOptions( Tcl_Interp *interp, Gnocl_CanvasItemInfo *info )
{
   gnoclResetSetOptions( bPathOptions );

   if( gnoclSetOptions( interp, bPathOptions, G_OBJECT( info->item ), -1 ) 
         != TCL_OK )
      return TCL_ERROR;

   return TCL_OK;
}
Esempio n. 12
0
File: combo.c Progetto: zdia/gnocl
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;
}
Esempio n. 13
0
/**
\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;
}
Esempio n. 14
0
/**
\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 );
}
Esempio n. 15
0
File: button.c Progetto: zdia/gnocl
/**
\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 );
}
Esempio n. 16
0
int doOptionAdd ( Tcl_Interp *interp, GtkWidget *area, gint OptIdx )
{
#ifdef DEBUG_DRAWING_AREA
	g_print ( "drawingArea OptionIdx\n" );
#endif

	/* return error the maximum number of options has been reached */
	gint j = sizeof ( drawingAreaOptions ) / sizeof ( GnoclOption );

	if ( j == _n )
	{
		return TCL_ERROR;
	}

	/* set the option name directly from list of possible options */
	drawingAreaOptions[_n].optName =  options[OptIdx];

	/* set the remaining values, assign callback function */
	switch ( OptIdx )
	{

		case OnButtonMotionIdx:
			{
				gtk_widget_add_events ( area, GDK_BUTTON_MOTION_MASK );
				drawingAreaOptions[_n].func = gnoclOptOnButtonMotion;
			}
			break;

		case OnMotionIdx:
			{
				gtk_widget_add_events ( area, GDK_BUTTON_MOTION_MASK );
				drawingAreaOptions[_n].func = gnoclOptOnMotion;
			}
			break;

		case OnEnterIdx:
			{
				gtk_widget_add_events ( area, GDK_ENTER_NOTIFY_MASK );
				drawingAreaOptions[_n].propName = "E";
				drawingAreaOptions[_n].func = gnoclOptOnEnterLeave;
			}
		case OnLeaveIdx:
			{
				gtk_widget_add_events ( area, GDK_LEAVE_NOTIFY_MASK );
				drawingAreaOptions[_n].propName = "L";
				drawingAreaOptions[_n].func = gnoclOptOnEnterLeave;
			}
			break;
		case OnButtonPressIdx:
			{
				gtk_widget_add_events ( area, GDK_BUTTON_PRESS_MASK ) ;
				drawingAreaOptions[_n].propName = "P";
				drawingAreaOptions[_n].func = gnoclOptOnButton;
			}
			break;
		case OnButtonReleaseIdx:
			{
				gtk_widget_add_events ( area, GDK_BUTTON_RELEASE_MASK ) ;
				drawingAreaOptions[_n].propName = "R";
				drawingAreaOptions[_n].func = gnoclOptOnButton;
			}
			break;
	}

	/* implement changes */
	gnoclSetOptions ( interp, drawingAreaOptions, area, -1 );

	return _n + 1;
}
Esempio n. 17
0
/****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 );
}
Esempio n. 18
0
static int configure( Tcl_Interp *interp, SpinButtonParams *para,
      GnoclOption options[] )
{
   int ret = TCL_ERROR;
   int   blocked = 0;

   int setAdjust = 0;
   GtkAdjustment *oldAdjust = gtk_spin_button_get_adjustment( 
         para->spinButton );
   gfloat lower = oldAdjust->lower;
   gfloat upper = oldAdjust->upper;
   gfloat stepInc = oldAdjust->step_increment;
   gfloat pageInc = oldAdjust->page_increment;


   if( gnoclSetOptions( interp, options, G_OBJECT( para->spinButton ), -1 ) 
         != TCL_OK )
      goto cleanExit;

   gnoclAttacheOptCmdAndVar( options + onValueChangedIdx, &para->onValueChanged,
         options + variableIdx, &para->variable,
         "value-changed", G_OBJECT( para->spinButton ), 
         G_CALLBACK( changedFunc ), interp, traceFunc, para );

   if( para->onValueChanged != NULL )
   {
      blocked = g_signal_handlers_block_matched( 
            G_OBJECT( para->spinButton ), G_SIGNAL_MATCH_FUNC,
            0, 0, NULL, (gpointer *)changedFunc, NULL );
   }

   if( options[valueIdx].status == GNOCL_STATUS_CHANGED )
   {
      assert( strcmp( options[valueIdx].optName, "-value" ) == 0 );
      gtk_spin_button_set_value( para->spinButton, options[valueIdx].val.d );
      if( para->variable )
      {
         Tcl_Obj *obj = getObjValue( para->spinButton );
         para->inSetVar++;
         obj = Tcl_SetVar2Ex( para->interp, para->variable, NULL, obj, 
               TCL_GLOBAL_ONLY );
         para->inSetVar--;
         if( obj == NULL )
            goto cleanExit;
      }
   }

   /* if variable is set, synchronize variable and widget */
   if( options[variableIdx].status == GNOCL_STATUS_CHANGED 
         && para->variable != NULL
         && options[valueIdx].status != GNOCL_STATUS_CHANGED )
   {
      Tcl_Obj *var = Tcl_GetVar2Ex( interp, para->variable, NULL, 
            TCL_GLOBAL_ONLY );

      assert( strcmp( options[variableIdx].optName, "-variable" ) == 0 );
      if( var == NULL ) /* variable does not yet exist */
      {
         Tcl_Obj *obj = getObjValue( para->spinButton );

         para->inSetVar++;
         obj = Tcl_SetVar2Ex( para->interp, para->variable, NULL, obj, 
               TCL_GLOBAL_ONLY );
         para->inSetVar--;
         if( obj == NULL )
            goto cleanExit;
      }
      else
      {
         double d;
         if( Tcl_GetDoubleFromObj( interp, var, &d ) != TCL_OK )
            goto cleanExit;
         gtk_spin_button_set_value( para->spinButton, d );
      }
 
   }

   if( options[lowerIdx].status == GNOCL_STATUS_CHANGED )
   {
      assert( strcmp( options[lowerIdx].optName, "-lower" ) == 0 );
      lower = options[lowerIdx].val.d;
      setAdjust = 1;
   }
   if( options[upperIdx].status == GNOCL_STATUS_CHANGED )
   {
      assert( strcmp( options[upperIdx].optName, "-upper" ) == 0 );
      upper = options[upperIdx].val.d;
      setAdjust = 1;
   }
   if( options[stepIncIdx].status == GNOCL_STATUS_CHANGED )
   {
      assert( strcmp( options[stepIncIdx].optName, "-stepInc" ) == 0 );
      stepInc = options[stepIncIdx].val.d;
      setAdjust = 1;
   }
   if( options[pageIncIdx].status == GNOCL_STATUS_CHANGED )
   {
      assert( strcmp( options[pageIncIdx].optName, "-pageInc" ) == 0 );
      pageInc = options[pageIncIdx].val.d;
      setAdjust = 1;
   }


   if( setAdjust )
   {
      /* see also scale.c */
      /* last parameter is pageSize, where it is used? */
      gtk_spin_button_set_adjustment( para->spinButton, 
            GTK_ADJUSTMENT( gtk_adjustment_new( oldAdjust->value, lower, upper, 
            stepInc, pageInc, 0 ) ) ); 
      /* gtk_spin_button_update( para->spinButton ); */
   }

   /*
   spinButtonTraceFunc( para, interp, para->variable, NULL, 0 );
   */
   
   ret = TCL_OK;

cleanExit:
   if( blocked )
   {
      g_signal_handlers_unblock_matched( 
            G_OBJECT( para->spinButton ), G_SIGNAL_MATCH_FUNC, 0,
            0, NULL, (gpointer *)changedFunc, NULL );
   }

   return ret;
}
Esempio n. 19
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;
}
Esempio n. 20
0
File: label.c Progetto: zdia/gnocl
/**
\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;
}