class declaration of a signal function in c++



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

anyway, thanks
philip










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