Question about gtk-- signals..
- From: jfp squinky org
- Subject: Question about gtk-- signals..
- Date: Sat, 18 Apr 1998 21:19:35 -0700
I've been working on my first big gtk-- program. Looks like a great
toolkit! I'm trying to create a nice little widget to manage groups of
radio buttons. When I try to connect the button's toggle signal to
anything I get some very nasty errors. I'm using gtk--0.8.0 and gtk-1.0.0
and gcc version 2.8.0. If someone could help me figure how to create a
member function that can be connected to the toggle signal or send me some
source code showing how they were able to connect radio buttons to
things in g++ that would be great! thanks in advance.
Here are the errors I get:
g++ -g -I/usr/include -L/usr/lib -o radiobuttonbox.o RadioButtonBox.cc
-lgtkmm -lgtk -lgdk -lglib -L/usr/X11R6/lib -lXext -lX11 -lm -lnsl -I.
RadioButtonBox.cc: In method `RadioButtonBox::RadioButtonBox(char *,
struct ButtonBoxSpec *, int)':
RadioButtonBox.cc:28: warning: initialization of non-const reference
`class RadioButtonBox *&' from rvalue `RadioButtonBox *'
/usr/local/include/gtk--sig.h:1256: warning: in passing argument 2 of
`connect<void, Gtk_ToggleButton, RadioButtonBox *, int
(RadioButtonBox::*)(Gtk_ToggleButton
*)>(Signal_proxy0<void,Gtk_ToggleButton> &, RadioButtonBox *&, int
(RadioButtonBox::*)(Gtk_ToggleButton *))'
/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
make: *** [radiobuttonbox.o] Error 1
Here's the header file and source file... The Line in question has big
"What is wrong with this line" comments around it..
#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* toggle );
Signal1<long> sigBoxChanged;
};
#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* toggle )
{
if (toggle->get_state())
{
sigBoxChanged( buttonSpec[1].val);
}
}
-----------------------------------------------------------------------
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]