Re: [gtk-list] Re: Question about gtk-- signals..



Justin Sher <justin@ndst.com> writes:
> I tried this already actually..Here's the exact syntax I used:
> 
> /********What is wrong with this line???***********/
> connect(radiob->toggled,this, &RadioButtonBox::DoButtonBoxChange,radiob );
> 
> And here's the method that receives the signal (basically unchanged)...
> 
> RadioButtonBox::DoButtonBoxChange(Gtk_ToggleButton *b)
> {}

Okay, lets try to parse this completely -- the following reads in gtk--
source:

template<class rettype,class widgettype, class T, class E>
Connection
connect(Signal_proxy0<rettype,widgettype> &p, T *receiver, rettype (T::*method)(E), E arg );

This is the implementation your connect() call should match...
E=Gtk_ToggleButton*
T=RadioButtonBox
rettype=void
widgettype=Gtk_ToggleButton
 
Thus the type of matched connect() call must be exactly:
Connection connect(Signal_proxy0<void,Gtk_ToggleButton> &p, 
		   RadioButtonBox *receiver,
		   void (RadioButtonBox::*method)(Gtk_ToggleButton*),
		   Gtk_ToggleButton *arg);
Now you have radiob to arg which takes Gtk_ToggleButton*... I think thats the
problem - as template args must match exactly - no implicit conversion allowed
for it. Try make the conversion from Derived class to base class explicit:

connect(radiob->toggled,this, &RadioButtonBox::DoButtonBoxChange,(Gtk_ToggleButton*)radiob );

> And the compiler spits out this lovely error message:
> 
> RadioButtonBox.cc: In method `RadioButtonBox::RadioButtonBox(char *,
> struct ButtonBoxSpec *, int)':
> RadioButtonBox.cc:28: conversion from
> `Signal_proxy0<void,Gtk_ToggleButton>' to non-scalar type `Signal0'
> requested
> /usr/local/include/gtk--sig.h:886: in passing argument 1 of
> `connect(Signal0 &, void (*)())'

This error message is just one version it tried to match to => and it
guessed quite wrong -- there isnt even same number of arguments in the
signature..:)

=> C++'s template matching rules are sometimes kinda odd. (I think
they have been relaxed alittle, but compilers dont yet support that)

(I hope that thingy helps... I'm not sure about it :( )

-- 
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]