I need your help on GTK+.
On the same window i have 20 textviews, and i need to handle in only 1 callback the "changed" signal coming from the textbuffers under them.
What is the best way to implement this, i mean how to retrieve the textview widget concerned by the text change ?
On my side i tryied to pass the textview widget object itself, on the connect for the signal "changed" but it is not working.
On my side i also tryied the same kind of implementation for buttons and it works perfectly for signal "clicked", and the button widget object passed is working fine.
Why isn't it working for Textview with underlying textbuffers ?
The code for connect:
g_signal_connect(G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT_VIEW(WidgetSecret))), "changed", G_CALLBACK(on_SecretText_changed), WidgetSecret);
and the callback:
void on_SecretText_changed(GtkWidget *p)
Thanks for your help.
0
votes
1 Answers
0
votes
Hello all,
I found another way to work on it, first is to conform to Gtkmm only, and not to mix up Gtk and Gtkmm.
Gtk::TextView* pSecret[21];
First Retrieve all objects from Glade:
for (int i=1; i<=20; i++) {
sprintf(Bidon, "tvCh%0d", i);
pBuilder->get_widget(Bidon, pSecret[i]);
}
and then use a bind to transmit an integer:
int id = 1; // this is the Id to pass to callback for this TextView
pSecret[id]->get_buffer()->signal_changed().connect(sigc::bind<int>(sigc::ptr_fun(&on_SecretText_changed), id));
according to this kind of callback:
void on_SecretText_changed(int id)
{
// id is retrieved and used here
}
and that works !