Re: passing 3 widgets as parameters to g_signal_connect



Hi,

Thanks Pedro.

I'm having problems with my program. When I pass the structure I have the
following warning


warning: passing arg 1 of `gtk_entry_get_text' from incompatible pointer type

Here is a snippet from my code:


___________________________________________________________________________________

typedef struct
{
  GtkWidget *op1;
  GtkWidget *op2;
  GtkWidget *res;
}CALC;

/* create window is called by main */

GtkWidget* create_window (void)

 CALC *elementos;
 elementos = g_new(CALC,1);
.
.
.
/* creating table and attaching entries and labels */

 elementos->op1 = gtk_entry_new ();
 gtk_widget_show (elementos->op1);

/* conecting - here 'vezes' is a button */

g_signal_connect ((gpointer) vezes, "clicked",
                    G_CALLBACK (on_vezes_clicked),
                     elementos);
.
.
.
}


void
on_vezes_clicked                       (GtkButton       *button,
                                        gpointer         user_data)
{

  CALC *elem;
  gint iope1 , iope2, ires;
  gchar *oper1, *oper2, *result;

  (CALC *) elem = user_data;

  oper1 = gtk_entry_get_text(elem->op1);
  oper2 = gtk_entry_get_text(elem->op2);
  iope1 = atoi (oper1);
  iope2 = atoi (oper2);
  ires = iope1 * iope2;
  sprintf(result,"%4d", ires);
  g_print("  %s ",result);

/*   gtk_entry_set_text(elem->res, result); */

}

_______________________________________________________________________________________

Any Idea?

Thanks in advance

LEslie

Em Mon, Jul 05, 2004 at 09:41:15AM -0400, Pedro Villaviencio escreveu o seguinte:
>) From: Pedro Villaviencio <pvillavicencio linuxcenter cl>
>) To: gtk-list gnome org
>) Date: Mon, 05 Jul 2004 09:41:15 -0400
>) Subject: Re: passing 3 widgets as parameters to g_signal_connect
>) 
>) On Mon, 2004-07-05 at 09:33, Leslie Harlley Watter wrote:
>) > Hi,
>) > 
>) > How can I pass 3 widgets as a parameter to g_signal_connect?
>) > 
>) > Example, If I have a single calculator with
>) > 
>) > GtkWidget *op1; /* First operand */
>) > GtkWidget *op2; /* Secont operand */
>) > GtkWidget *res; /* result */
>) 
>) you can do a structure and pass them to the the callback.
>) > 
>) > all these widgets are gtk_entry's and I want to pass they as a parameter
>) > because I need to manipulate their values inside a callback.
>) > 
>) > Thanks in advance
>) > 
>) > Leslie
>) 
>) _______________________________________________
>) gtk-list mailing list
>) gtk-list gnome org
>) http://mail.gnome.org/mailman/listinfo/gtk-list
>) :-- final da mensagem Re: passing 3 widgets as parameters to g_signal_connect de Pedro Villaviencio <pvillavicencio linuxcenter cl> --:

-- 
Outside of a dog, a book is a man's best friend.
Inside a dog it's too dark to read.
Groucho Marx



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