Re: Struct Problem



Pablo Fischer wrote:

Hi all;

Now Im here.. with a struct problem heh. This is just an example: When I
click the button, it will call a function (validar) that will get the
text and put it into a gchar, I dont know why I cant compile this:

#include <gtk/gtk.h>

typedef struct _Objetos {
 GtkWidget *nombre;
 GtkWidget *apellido;
} Objetos;

void verificar(GtkWidget *objeto, Objetos *data) {

 gchar *text;
 text = gtk_entry_get_text(data.nombre);
}
int main(int argc, char *argv[]) { gtk_init(&argc, &argv);
 static Objetos agenda;

 GtkWidget *ventana;
 GtkWidget *caja_h, *caja_v;
 GtkWidget *etiqueta;
 GtkWidget *boton;
 ventana = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(ventana), "Estructuras");

 caja_v = gtk_vbox_new(FALSE, 2);
 gtk_container_add(GTK_CONTAINER(ventana), caja_v);


 //Nombre:
 caja_h = gtk_hbox_new(FALSE, 2);
 gtk_box_pack_start(GTK_BOX(caja_v), caja_h, FALSE, TRUE, 2);

 etiqueta = gtk_label_new("Nombre: ");
 gtk_box_pack_start(GTK_BOX(caja_h), etiqueta, FALSE, TRUE, 2);

 agenda.nombre = gtk_entry_new();
 gtk_box_pack_start(GTK_BOX(caja_h), agenda.nombre, FALSE, TRUE, 2);
boton = gtk_button_new_with_label("Sirve?"); g_signal_connect(G_OBJECT(boton), "clicked", G_CALLBACK(verificar), (gpointer) &agenda);
 gtk_box_pack_start(GTK_BOX(caja_v), boton, FALSE, TRUE, 2);

 gtk_widget_show_all(caja_h);
 gtk_widget_show_all(ventana);


 gtk_main();

 return 0;
}
Paul Fischer

what error do you get?






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