[9298] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: gpointer and callbacks

daemon@ATHENA.MIT.EDU (Nwanua Elumeze)
Wed Oct 14 16:29:26 1998

Date: Wed, 14 Oct 1998 14:28:56 -0600 (MDT)
From: Nwanua Elumeze <nwanua@makaha.colorado.edu>
To: gtk-list@redhat.com
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com

>> examples I found only strings where used. Can you pass any type using
>> gpointer?

Yes.

here's a little coding example to show how:


I have two buttons, the clicking of one would disable itself and enable 
the other:

......

button1  = gtk_button_new_with_label("Enable 2");

button2  = gtk_button_new_with_label("Enable 1");

gtk_signal_connect (GTK_OBJECT (button1), "clicked",
    GTK_SIGNAL_FUNC (enable_disable), (GtkWidget *)button2);
    
gtk_signal_connect (GTK_OBJECT (button1), "clicked", 
   GTK_SIGNAL_FUNC (enable_disable), (GtkWidget *)button1);

/* instead of (GtkWidget *)button1, you could also use the
the type-casting macros like:  GTK_WIDGET(button1) */

.......


and the enable_disable function is defined as such:


gint enable_disable(GtkWidget *disable_this, GtkEvent *event, 
     GtkWidget *enable_this)
{
	/* the GtkEvent event can be used to determine, left clicks,
	  right clicks, double or triple clicks, etc... */
	  
	........
	  
	/* any hoo... */
	gtk_widget_set_sensitive(disable_this, FALSE);
	gtk_widget_set_sensitive(enable_this, TRUE);
	
	........
}


hope that helped.

Nwanua.


-- 
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post