Beispiel #1
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 );
}
Beispiel #2
0
/***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 );
}
Beispiel #3
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 );
}
Beispiel #4
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 );

}
Beispiel #5
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 );
}
Beispiel #6
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 #7
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 );
}
Beispiel #8
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 #9
0
/**
/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 );
}
Beispiel #10
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 #11
0
static int addItemTcl( ComboParams *para, Tcl_Interp *interp, 
      int objc, Tcl_Obj * const objv[] )
{
   GnoclOption addOption[] = 
   {
      { "-value", GNOCL_OBJ, NULL },    /* 0 */
      /* { "-icon", GNOCL_OBJ, NULL },     1 */
      { NULL }
   };
   /* static const int addValueIdx = 0; */ 

   int ret;

   /* id add text ? opt ...? */
   if( objc < 3 )
   {
      Tcl_WrongNumArgs( interp, 2, objv, "text ?option val ...?" );
      return TCL_ERROR;
   }

   if( gnoclParseOptions( interp, objc - 2, objv + 2, addOption ) != TCL_OK )
   {
      gnoclClearOptions( addOption );
      return TCL_ERROR;
   }

#if 0
   ret = addItem( para, objv[2], 
         addOption[addValueIdx].status == GNOCL_STATUS_CHANGED ?
               addOption[addValueIdx].val.obj : NULL );
#endif

   return ret;
}
Beispiel #12
0
static int itemConfigure( Tcl_Interp *interp, int objc, 
      Tcl_Obj * const objv[], CanvasParams *param, GPtrArray *items )
{
   /* canvas itemConfigure tag-or-id ?option val ...? */
   guint k;
   int   ret = TCL_ERROR;

   if( items == NULL )
      return TCL_OK;

   for( k = 0; k < items->len; ++k )
   {
      Gnocl_CanvasItemInfo *info = GET_INFO( items, k );
      if( gnoclParseOptions( interp, objc - 2, objv + 2, info->options ) 
            != TCL_OK )
         goto cleanExit;
   }
   for( k = 0; k < items->len; ++k )
   {
      Gnocl_CanvasItemInfo *info = GET_INFO( items, k );
      if( (*info->setOptions)( interp, info ) != TCL_OK )
         goto cleanExit;
   }

   ret = TCL_OK;

cleanExit:
   for( k = 0; k < items->len; ++k )
   {
      Gnocl_CanvasItemInfo *info = GET_INFO( items, k );
      gnoclClearOptions( info->options );
   }

   return ret;
}
Beispiel #13
0
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;
}
Beispiel #14
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;
}
Beispiel #15
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 #16
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 );
}
Beispiel #17
0
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;
}
Beispiel #18
0
/**
\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 );
}
Beispiel #19
0
int gnoclSessionCmd( ClientData data, Tcl_Interp *interp,
      int objc, Tcl_Obj * const objv[] )
{
   static const char *cmd[] = { "configure", NULL };
   enum optIdx { ConfigureIdx };
   int idx;

   static GnomeClient *client = NULL;
   if( client == NULL )
      client = gnome_master_client();

   if( client == NULL )
   {
      Tcl_SetResult( interp, "Unable to initialize session.", TCL_STATIC );
      return TCL_ERROR;
   }

   if( objc < 2 )
   {
      Tcl_WrongNumArgs( interp, 1, objv, "command" );
      return TCL_ERROR;
   }
   if( Tcl_GetIndexFromObj( interp, objv[1], cmd, "command", TCL_EXACT,
         &idx ) != TCL_OK )
      return TCL_ERROR;
   switch( idx )
   {
      case ConfigureIdx:
            {
               int ret = TCL_ERROR;
               if( gnoclParseAndSetOptions( interp, objc - 1, objv + 1, 
                     sessionOptions, G_OBJECT( client ) ) == TCL_OK )
               {
                  ret = configure( interp, client, sessionOptions );
               }
               gnoclClearOptions( sessionOptions );
               return ret;
            }
            break;
   }
   return TCL_OK;
}
Beispiel #20
0
/****f* callback/create
 * AUTHOR
 *	PGB
 * SOURCE
 */
static int create ( Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] )
{
	GnoclOption options[] =
	{
		{ "-interval", GNOCL_OBJ, NULL },    /* 0 */
		{ "-priority", GNOCL_INT, NULL },    /* 1 */
		{ NULL }
	};
	const int intervalIdx = 0;
	const int priorityIdx = 1;

	int interval = -1;
	int priority = 0;
	int id;
	GnoclCommandData *cs;

	if ( objc < 3 )
	{
		Tcl_WrongNumArgs ( interp, 2, objv, "script" );
		return TCL_ERROR;
	}

	if ( gnoclParseOptions ( interp, objc - 2, objv + 2, options ) != TCL_OK )
		goto errorExit;

	if ( options[priorityIdx].status == GNOCL_STATUS_CHANGED )
		priority = options[priorityIdx].val.i;

	/* TODO? test priority range? */

	if ( options[intervalIdx].status == GNOCL_STATUS_CHANGED )
	{
		Tcl_Obj * const obj = options[intervalIdx].val.obj;

		if ( Tcl_GetIntFromObj ( NULL, obj, &interval ) != TCL_OK )
		{
			if ( strcmp ( Tcl_GetString ( obj ), "idle" ) != 0 )
			{
				Tcl_AppendResult ( interp,
								   "Expected integer or \"idle\", but got \"",
								   Tcl_GetString ( obj ), "\"", NULL );
				goto errorExit;
			}
		}

		else if ( interval <= 0 )
		{
			Tcl_SetResult ( interp, "interval must be greater zero.",
							TCL_STATIC );
			goto errorExit;
		}

	}

	gnoclClearOptions ( options );

	cs = g_new ( GnoclCommandData, 1 );
	cs->command = g_strdup ( Tcl_GetString ( objv[2] ) );
	cs->interp = interp;


	if ( interval <= 0 ) /* idle */
	{
		id = g_idle_add_full ( G_PRIORITY_DEFAULT_IDLE - priority,
							   doCommand, cs, destroyCmd );
	}

	else
	{
		id = g_timeout_add_full ( G_PRIORITY_DEFAULT_IDLE - priority, interval,
								  doCommand, cs, destroyCmd );
	}

	Tcl_SetObjResult ( interp, Tcl_NewIntObj ( id ) );

	return TCL_OK;


errorExit:
	gnoclClearOptions ( options );

	return TCL_ERROR;
}
Beispiel #21
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 #22
0
/**
/brief
/author William J Giddings
/date   2008-08
**/
int drawingAreaFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] )
{
#ifdef DEBUG_DRAWING_AREA
	g_printf ( "drawingAreaFunc\n" );
	gint _i;

	for ( _i = 0; _i < objc; _i++ )
	{
		g_printf ( "\targ %d = %s\n", _i,  Tcl_GetString ( objv[_i] ) );
	}

#endif

	static const char *cmds[] =
	{
		"draw", "cget", "configure", "delete", "class", "erase", "option", NULL
	};
	enum cmdIdx
	{
		DrawIdx, CgetIdx, ConfigureIdx, DeleteIdx, ClassIdx, EraseIdx, OptionIdx
	};


	/* relocate these to relevant parts of the souce file */
	static const char *drawOpts[] =
	{
		"point", "points", "line", "lines", "pixbuf", "segments",
		"rectangle", "arc", "polygon", "trapezoids", "glyph",
		"glyphTransformed", "layoutLine", "layoutWithColors",
		"string", "text", "image",
		NULL
	};

	enum drawOptsIdx
	{
		PointIdx, PointsIdx, LineIdx, LinesIdx, PixbufIdx, SegmentsIdx,
		RectangleIdx, ArcIdx, PolygonIdx, TrapezoidsIdx, GlypIdx,
		GlyphTransformedIdx, LayoutLineIdx, LayoutWithColorsIdx,
		StringIdx, TextIdx, ImageIdx
	};



	/*
	static const char *events[] =
	{
	    "expose",           "motion",           "motionHint",
	    "buttonMotion",     "button1Motion",    "button2Motion",
	    "button3Motion",    "buttonPress",      "buttonRelease",
	    "keyPress",         "keyRelease",       "enter",
	    "leave",            "focus",            "structure",
	    "propertyChange",   "visibility",       "proximityIn",
	    "proximityOut",     "substructure",     "scroll",
	    "all", NULL
	};
	*/

	GtkWidget *area = GTK_WIDGET ( data );

	int idx;
	int idx2;

	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 OptionIdx:
			{
#ifdef DEBUG_DRAWING_AREA
				g_print ( "drawingArea OptionIdx\n" );
#endif

				/*
				other options here could include:
				    remove      -remove the option from the options array (incl. script)
				    available   -return a list of currently configured options
				    suspend     -remove option from the event mask only
				    resume      -add the option to the event mask
				*/

				if ( !strcmp ( Tcl_GetString ( objv[2] ), "add" )  )
				{
					g_printf ( " add\n" );
				}

				else
				{
					return TCL_ERROR;
				}

				/* create a hash table for events and handlers */

				int OptIdx;

				if ( Tcl_GetIndexFromObj ( interp, objv[3], options, "option", TCL_EXACT, &OptIdx ) != TCL_OK )
				{
					return TCL_ERROR;
				}

				_n = doOptionAdd ( interp, area, OptIdx );

				break;
			case ConfigureIdx:
				{
#ifdef DEBUG_DRAWING_AREA
					g_print ( "drawingArea ConfigureIdx\n" );
#endif
					int ret = TCL_ERROR;

					if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1,
												   drawingAreaOptions, area ) == TCL_OK )
					{
						ret = configure ( interp, area, drawingAreaOptions );
					}

					gnoclClearOptions ( drawingAreaOptions );

					return ret;
				}

				break;
			case DeleteIdx:
				{
					g_print ( "delete\n" );
				}

				break;
			case ClassIdx:
				{
					g_print ( "Class = drawingArea\n" );
					Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "drawingArea", -1 ) );
				}

				break;
				/*
				case PointIdx
				case PointsIdx
				case LineIdx
				case LinesIdx
				case PixbufIdx
				case SegmentsIdx
				case RectangleIdx
				case ArcIdx
				case PolygonIdx
				case TrapezoidsIdx
				case GlypIdx
				case GlyphTransformedIdx
				case LayoutLineIdx
				case LayoutWithColorsIdx,
				case StringIdx
				case TextIdx
				case ImageIdx
				*/
			}
	}

	return TCL_OK;
}
Beispiel #23
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 );
}
Beispiel #24
0
/****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;
}
Beispiel #25
0
/**
\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;
}
Beispiel #26
0
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;
}
Beispiel #27
0
/**
\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;
}
Beispiel #28
0
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;
}
Beispiel #29
0
/**
\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;
}
Beispiel #30
0
/**
\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;
}