Re: class declaration of a signal function in c++
- From: Jeff Franks <adsln7hl tpg com au>
- To: philip dahlquist <dahlquist kreative net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: class declaration of a signal function in c++
- Date: Mon, 05 Jul 2004 13:39:15 +0000
philip dahlquist wrote:
i'm having trouble with the declaration/definition of a gtk signal function inside a c++ class.
CreateTreeItem(...) is the member function that calls the signal function
and below it is the class definition of the signal function, SelectItem(...)
/**********************/
/**********************/
GtkWidget*
Dirpane::CreateTreeItem(char *txt, GtkWidget *tree)
{
GtkWidget *itemnew;
char buffer[256];
strcpy(buffer, txt);
itemnew = gtk_tree_item_new_with_label(txt);
gtk_tree_append(GTK_TREE(tree), itemnew);
gtk_widget_show(itemnew);
gtk_signal_connect(GTK_OBJECT(itemnew), "select",
GTK_SIGNAL_FUNC(SelectItem), g_strdup(buffer));
return(itemnew);
}
/**********************/
/**********************/
void
Dirpane::SelectItem(GtkWidget *wgt, gpointer data)
{
cout << "item selected: " << (char *)data << endl;
}
/**********************/
/**********************/
when i compile the class this is the error message the compiler generates:
------------
dirpane.cpp: In method `GtkWidget *Dirpane::CreateTreeItem (char *,
GtkWidget *)':
dirpane.cpp:157: no matches converting function `SelectItem' to type
`void (*) ()'
dirpane.h:27: candidates are: void Dirpane::SelectItem (GtkWidget *,
void *)
------------
i tried putting the class name and the binary scope resolution op
in there and the compiler liked that a little better, but still no joy
GTK_SIGNAL_FUNC(&Dirpane::SelectItem)
the problem is that what i'm trying to do makes more sense doing it in c++
rather than doing it in c
Phillip, you did declare SelectItem in your class declration as "static"
didn't you?
static void SelectItem(GtkWidget *wgt, gpointer data);
Jeff.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]