[Glade-users] Help passing more than one variable as argument to a function

Giovanni Corriga valkadesh@libero.it
Thu, 14 Dec 2000 08:49:23 +0100


I haven't tried it, but I think you should use
gtk_signal_connect_object():

gtk_signal_connect_object(GTK_OBJECT(clean), "clicked", clear_entry,
GTK_OBJECT(entry1));
gtk_signal_connect_object(GTK_OBJECT(clean), "clicked", clear_entry,
GTK_OBJECT(entry2));
...

where clear_entry() is a function like

void clear_entry (GtkObject object)
{
  gtk_entry_set_text(GTK_ENTRY(entry), "");
}

In this way, you don't have to mess up interface.c.

		Giovanni

Daniel Macedo wrote:
> 
> I am having problems passing more than oe argument through gpointer,
> using glade. I have a dialog box, with 5 entry texts, and i want to
> clear all of them. I am trying to use an array of widgets, but it doesn
> seem to work. how can i pass more than one variable, and connect this
> signal?
> 
> that's how my code looks like:
> 
> code on interface.c:
> 
> GtkWidget *entry1;
>   GtkWidget *entry2;
>   GtkWidget *entry3;
>   GtkWidget *entry4;
>   GtkWidget *entry5;
>    GtkWidget *campos[5];
>  campos[0]=entry1;
>   campos[1]=entry2;
>   campos[2]=entry3;
>   campos[3]=entry4;
>   campos[4]=entry5;
>  gtk_signal_connect(GTK_OBJECT(clean),"clicked",GTK_SIGNAL_FUNC(on_limpar_activate),campos);
> 
> callback function on callbacks.c:
> 
> void
> on_limpar_activate                       (GtkMenuItem     *menuitem,
>                                           gpointer   user_data)
> {
> int i;
> for(i=0;i<5;i++) gtk_entry_set_text(user_data+i,"");
> }
> 
> Daniel Macedo
> damacedo@task.com.br
> 
> _______________________________________________
> Glade-users maillist  -  Glade-users@helixcode.com
> http://lists.helixcode.com/mailman/listinfo/glade-users