Re: question for signal handler



On Tue, 2004-01-06 at 03:11, �îºê�° wrote:
Hi, all:
   If I want to pass two or more widget by a signal handler, what should I do?
For example, there are a button, an text entry and a tree view, if the button
is clicked, the text of the entry and the content of the tree view will be 
refreshed. I have wrote:
   g_signal_connect(button, "clicked", G_CALLBACK(button_clicked), data);
   The problem is: how can I pass the entry and the tree view with 'data', should I create a struct to pass 
in as data? I have tried that way, but result
is unexpected:
   "invalid unclassed pointer in cast to 'GtkWidget'"

   Is there anyone who knows how to do? Thanks

How about something like:

typedef _my_struct my_struct;

struct _my_struct {
        GtkWidget *treeview;
        GtkWidget *entry;
};

void
button_clicked (GtkButton *button, gpointer data)
{
        my_struct *my_widgets_struct;
        GtkWidget *view_widget, *entry_widget;

        my_widgets_struct = (my_struct *) data;

        view_widget = my_widgets_struct->treeview;
        entry_widget = my_widgets_struct->entry;

        /* Do something with the widgets */
}

I haven't tested this, so it might not work :-)

Keith.




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