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




Tried the cast to (Gtk_ToggleButton *) thingy.. Nope, still doesn't
work... OK So far we have tried:

> > /********What is wrong with this line???***********/
> > connect(radiob->toggled,this, &RadioButtonBox::DoButtonBoxChange,radiob );
> > RadioButtonBox::DoButtonBoxChange(Gtk_ToggleButton *b)
and gotten 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 (*)())'

and

> > connect(radiob->toggled,this, &RadioButtonBox::DoButtonBoxChange );
> > RadioButtonBox::DoButtonBoxChange(Gtk_ToggleButton *b)
and gotten error message:
/usr/local/include/gtk--sig.h: In method `void
Concretegtkslot0cb<void,RadioButtonBox *&,int
(RadioButtonBox::*)(Gtk_ToggleButton *)>::call()':
/usr/local/include/gtk--sig.h:912: `Concretegtkslot0cb<void,RadioButtonBox
*&,int (RadioButtonBox::*)(Gtk_ToggleButton *)>::func' cannot be used as a
function

and (just tried this one right after I sent the message actually) and it
still didn't work

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

and got this 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 (*)())'

Which is the same as the error messagge I got for (1).  So basically
typecasting didn't do a thing.

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

	Maybe there's some sort of weird cast I can make in the connect
call to get it to work?  Or maybe something's missing in the header file. 
I tried to look at it and was utterly baffled as I'm only an about average
programmer...

I've attached the source files as mime attachements so you can fool around
with the connect signal a bit.  I've tried a zillion little variations on
this connect call.  Maybe, if you could fool around with it for a while
until it compiles or you find the bug that needs to be fixed in gtk--,  
we could get this resolved a little more efficiently.  Thanks for your
help!  I want to get the C++ crowd interested in gnome/gtk development by
writing a decent little application in it! I could kludge it and use gtk
signals but I'd rather not... 


-----------------------------------------------------------------------
 Justin Sher         |  "No appeal to any historical or empirical    
 Programmer/Analyst  |   consideration can discover any fault in the
 NDST Communications |   proposition that men aim purposefully at  
 justin@ndst.com     |	 certain chosen ends." -L. Von Mises		   


PREFIX=/usr
LIBS=  -lgtkmm -lgtk -lgdk -lglib -L/usr/X11R6/lib -lXext -lX11 -lm  -lnsl
hello : hello.cc Makefile radiobuttonbox.o
	g++ -g -I$(PREFIX)/include -L$(PREFIX)/lib -o hello hello.cc $(LIBS) -I. radiobuttonbox.o

radiobuttonbox.o : RadioButtonBox.h RadioButtonBox.cc
	g++ -g -I$(PREFIX)/include -L$(PREFIX)/lib -o radiobuttonbox.o RadioButtonBox.cc $(LIBS) -I.
#include <RadioButtonBox.h>
#include <iostream.h>

RadioButtonBox::RadioButtonBox(char * eNameOfBox, ButtonBoxSpec * eButtonBoxSpec, int eElements) : 
 Gtk_Table ( OPTIMALBBOXSIZE(eElements), OPTIMALBBOXSIZE(eElements)+1,false)
{
  //Add Title
  Gtk_RadioButton * radiob;
  int i;
  buttonSpec=eButtonBoxSpec;
  xsize=OPTIMALBBOXSIZE(eElements);
  ysize=OPTIMALBBOXSIZE(eElements)+1;

  tableHeader=new Gtk_Label(eNameOfBox);
  attach_defaults(tableHeader,0,xsize,0,1);

  for (i=0; i < eElements ; ++i)
    {
	  if (!i) 
	    {	  
	      radiob = new Gtk_RadioButton( NULL, eButtonBoxSpec[i].string );	  
	      buttonList = radiob->group();
	    }
	  else {radiob = new Gtk_RadioButton(buttonList, eButtonBoxSpec[i].string );}
	  radiob->show();

	  /********What is wrong with this line???*************/
	  connect(radiob->toggled,this, &RadioButtonBox::DoButtonBoxChange );



	  attach_defaults(radiob,i/xsize,i/xsize+1 , i%xsize+1,i%xsize+2);	 
	  cout << "left " << (i/xsize) << " right " << (i/xsize+1) <<  " top " << i%xsize+1 << " bottom " 
	       << (i%xsize+2) << "\n";

    }
  show();
}

RadioButtonBox::DoButtonBoxChange(Gtk_ToggleButton *b)
{
  if (1)
    {
      sigBoxChanged( buttonSpec[1].val);
    }
}



#include <gtk--.h>

typedef long RadioVal;

typedef struct ButtonBoxSpec
{
  RadioVal val;
  char *string;
}ButtonBoxSpec;

#define OPTIMALBBOXSIZE(x) ((int)(sqrt(x)+.05))

class RadioButtonBox: public Gtk_Table
{
  GSList *  buttonList;
  ButtonBoxSpec * buttonSpec;
 public:
  int xsize,ysize;
  Gtk_Label * tableHeader;
  RadioButtonBox (char * eNameOfBox, ButtonBoxSpec *eButtonBoxSpec,int eElements);
  DoButtonBoxChange(Gtk_ToggleButton *b );
  Signal1<long> sigBoxChanged;
};




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