Changing a gtkmm label through a signal possible?

M

Markus Pitha

Hello,

I have a window containing a table with some (dynamically created)
buttons. I want to change the buttons, when they are clicked, but with
dynamically created buttons, this issue seems to be not that easy.
Look at this methods:


void GUIAdjazenzmatrix::createTable() {

for(int i = 0; i < knotenAnzahl; i++) {
for(int j = 0; j < knotenAnzahl; j++) {
Gtk::Button* pButton = Gtk::manage(new Gtk::Button(" 0 "));
table.attach(*pButton, j, j+1, i, i+1);

pButton->signal_clicked().connect(sigc::bind<int, int>
(sigc::mem_fun(*this,
&GUIAdjazenzmatrix::eek:nButtonClick), j, i));
}
}
}

void GUIAdjazenzmatrix::eek:nButtonClick(int j, int i) {

//some code

}

I tried to force a Gtk::Button pointer through this signal, but I
couldn't manage it.
When I try something like this:

void GUIAdjazenzmatrix::createTable() {

for(int i = 0; i < knotenAnzahl; i++) {
for(int j = 0; j < knotenAnzahl; j++) {
Gtk::Button* pButton = Gtk::manage(new Gtk::Button(" 0 "));
table.attach(*pButton, j, j+1, i, i+1);

pButton->signal_clicked().connect(sigc::bind<int, int,
Gtk::Button*>
(sigc::mem_fun(*this,
&GUIAdjazenzmatrix::eek:nButtonClick), j, i, pButton));
}
}
}

...I get these errors:


$ g++ GUI*.cpp Main.cpp -o Main `pkg-config gtkmm-2.4 --libs --cflags`


/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h: In member
function »typename
sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1, T_arg2,
T_arg3, void, void, void, void>::type
sigc::adaptor_functor<T_functor>::eek:perator()(T_arg1, T_arg2, T_arg3)
const [with T_arg1 = int&, T_arg2 = int&, T_arg3 = Gtk::Button*&,
T_functor = sigc::bound_mem_functor2<void, GUIAdjazenzmatrix, int, int>]«:
/usr/include/sigc++-2.0/sigc++/adaptors/bind.h:1511: instantiated from
»typename sigc::adapts<T_functor>::adaptor_type::result_type
sigc::bind_functor<-0x000000001, T_functor, T_type1, T_type2, T_type3,
sigc::nil, sigc::nil, sigc::nil, sigc::nil>::eek:perator()() [with
T_functor = sigc::bound_mem_functor2<void, GUIAdjazenzmatrix, int, int>,
T_type1 = int, T_type2 = int, T_type3 = Gtk::Button*]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:103: instantiated from
»static T_return sigc::internal::slot_call0<T_functor,
T_return>::call_it(sigc::internal::slot_rep*) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:110: instantiated from
»static void* (* sigc::internal::slot_call0<T_functor,
T_return>::address())(void*) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:454: instantiated from
»sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1130: instantiated from
»sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor
= sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
GUIAdjazenzmatrix.cpp:27: instantiated from here
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:123: Fehler:

....and so on..

What can i do?


Markus
 
T

Thomas J. Gritzan

Markus said:
I have a window containing a table with some (dynamically created)
buttons. I want to change the buttons, when they are clicked, but with
dynamically created buttons, this issue seems to be not that easy.
Look at this methods:


void GUIAdjazenzmatrix::createTable() {

for(int i = 0; i < knotenAnzahl; i++) {
for(int j = 0; j < knotenAnzahl; j++) {
Gtk::Button* pButton = Gtk::manage(new Gtk::Button(" 0 "));
table.attach(*pButton, j, j+1, i, i+1);

pButton->signal_clicked().connect(sigc::bind<int, int>
(sigc::mem_fun(*this,
&GUIAdjazenzmatrix::eek:nButtonClick), j, i));
}
}
}

void GUIAdjazenzmatrix::eek:nButtonClick(int j, int i) { [...]
I tried to force a Gtk::Button pointer through this signal, but I
couldn't manage it.
When I try something like this:

void GUIAdjazenzmatrix::createTable() { [...]
pButton->signal_clicked().connect(sigc::bind<int, int,
Gtk::Button*>
(sigc::mem_fun(*this,
&GUIAdjazenzmatrix::eek:nButtonClick), j, i, pButton));
}
}
}

..I get these errors:
[...]

Sorry, not enough information.
I think you snipped just before the important part of the error message.

Some questions:
1) Did you read the error messages?
2) Did you change GUIAdjazenzmatrix::eek:nButtonClick also?
3) Did you change the signature of onButtonClick in the class declaration?
4) Did you ask in a place where the GTK library is on-topic?

Read here:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9
 
M

Markus Pitha

Thomas said:
Sorry, not enough information.
I think you snipped just before the important part of the error message.

I didn't post it because I just wanted to demonstrate which errors
appear. Sometime I also get a "Fehler: Syntaxfehler in
Templateargumentliste", depending on my tries.
When I check out
http://libsigc.sourceforge.net/libsigc2/docs/reference/html/group__bind.html
there are a lot of adaptors with different amounts of undefined types,
so how does it come that my 3-argument-expression does not fit.
Some questions:
1) Did you read the error messages?

Yes, and with this link above I tried to find a solution. Unfortunately,
I don't know what these "nil"s in the parameter list are.

2) Did you change GUIAdjazenzmatrix::eek:nButtonClick also?

Sure, but then I only changed just the first method over and over again.
If there are no errors anymore I concentrate on the second method.
3) Did you change the signature of onButtonClick in the class declaration?

I don't exactly know what you mean now?
4) Did you ask in a place where the GTK library is on-topic?

I think my question is probably more a c++ problem than a gtk problem.
Moreover there are no gtk groups. There is indeed
comp.os.linux.development.apps but this group gets only few hits a day
apart from the fact that it's no gtk group either.
But if you recommend one to my I would be glad.

Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top