[gtk-list] calling functions with widgets



One idea is to create a structure for the parameters to your
function. Then set the elements of an instantiation of the structure
and pass it's address as the data parameter to the
gtk_signal_connect() call, which by the way only takes _four_
parameters, the last being a data pointer (unless it's been
implemented as a va-list and it's not documented as such).

Brent Briggs writes:
 > I am currently developing a program that controls a robot arm. I am now
 > making this program graphical using GTK+. I am having trouble getting
 > the widgets to call my functions that send commands to the robot. For
 > instance, I have a button that I want to call the issueCommand()
 > function and pass it the arguments (int fd, char command, int init[]). I
 > 
 > am trying to call this function like this.
 > 
 >   /*setup the initialize button */
 >   button = gtk_button_new_with_label ("Re-Initialize");
 >   gtk_container_add (GTK_CONTAINER (control_vbox), button);
 >   gtk_widget_show (button);
 >   gtk_signal_connect (GTK_OBJECT (button), "clicked",
 >         GTK_SIGNAL_FUNC (issueCommand),
 >         fdescripter, 'i', init);
 > 
 > This is not working for me. Could someone tell me how to call my
 > function and pass the arguments to the function? I am stuck here and
 > can't prgress with this program's developement until I figure this out.
 > Any help would be appreciated.
 > 
 > Thanks,
 > Brent Briggs
 > 
 > 
 > 
 > -- 
 > To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null

-- 
Jonathan H. Wheaton
jwheaton@applink.net



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