question



Thanks for your answer. David Cantin

But the problem is that I am using C.

For example I have the following code: 


//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
gboolean btnAcept_button_press_event (GtkWidget
*widget, GdkEventButton *event, gpointer user_data);

  GtkWidget *gentName;
  GtkWidget *gentAdress;
  GtkWidget *gentTel;
  GtkWidget *gentEmail;
  GtkWidget *gentCol;

GtkWidget *create_wdgForm (void){
  GtkWidget *wdgForm;
  GtkWidget *table2;
  GtkWidget *lblName;
  GtkWidget *lblAdress;
  GtkWidget *lblTel;
  GtkWidget *lblCod;
  GtkWidget *lblEmail;
  GtkWidget *btnAcept;

  wdgForm = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (wdgForm), "Form");
  gtk_window_set_resizable (GTK_WINDOW (wdgForm),
FALSE);

  table2 = gtk_table_new (6, 2, FALSE);
  gtk_widget_show (table2);
  gtk_container_add (GTK_CONTAINER (wdgForm), table2);

  lblName = gtk_label_new ("Name:");
  gtk_widget_show (lblName);
  gtk_table_attach (GTK_TABLE (table2), lblName, 0, 1,
0, 1,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions)
(0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (lblName), 0, 0.5);

  lblAdress = gtk_label_new ("Adress:");
  gtk_widget_show (lblAdress);
  gtk_table_attach (GTK_TABLE (table2), lblAdress, 0,
1, 1, 2,(GtkAttachOptions)
(GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (lblAdress), 0,
0.5);

  lblTel = gtk_label_new ("Tel:");
  gtk_widget_show (lblTel);
  gtk_table_attach (GTK_TABLE (table2), lblTel, 0, 1,
2, 3,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions)
(0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (lblTel), 0, 0.5);

  lblCod = gtk_label_new ("Cod:");
  gtk_widget_show (lblCod);
  gtk_table_attach (GTK_TABLE (table2), lblCod, 0, 1,
3, 4,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions)
(0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (lblCod), 0, 0.5);

  lblEmail = gtk_label_new ("email:");
  gtk_widget_show (lblEmail);
  gtk_table_attach (GTK_TABLE (table2), lblEmail, 0,
1, 4, 5,(GtkAttachOptions)
(GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (lblEmail), 0,
0.5);

  gentName = gtk_entry_new ();
  gtk_widget_show (gentName);
  gtk_table_attach (GTK_TABLE (table2), gentName, 1,
2, 0, 1,(GtkAttachOptions) (GTK_EXPAND |
GTK_FILL),(GtkAttachOptions) (0), 0, 0);

  gentAdress = gtk_entry_new ();
  gtk_widget_show (gentAdress);
  gtk_table_attach (GTK_TABLE (table2), gentAdress, 1,
2, 1, 2,(GtkAttachOptions) (GTK_EXPAND |
GTK_FILL),(GtkAttachOptions) (0), 0, 0);

  gentTel = gtk_entry_new ();
  gtk_widget_show (gentTel);
  gtk_table_attach (GTK_TABLE (table2), gentTel, 1, 2,
2, 3,(GtkAttachOptions) (GTK_EXPAND |
GTK_FILL),(GtkAttachOptions) (0), 0, 0);

  gentEmail = gtk_entry_new ();
  gtk_widget_show (gentEmail);
  gtk_table_attach (GTK_TABLE (table2), gentEmail, 1,
2, 4, 5,(GtkAttachOptions) (GTK_EXPAND |
GTK_FILL),(GtkAttachOptions) (0), 0, 0);

  gentCol = gtk_entry_new ();
  gtk_widget_show (gentCol);
  gtk_table_attach (GTK_TABLE (table2), gentCol, 1, 2,
3, 4,(GtkAttachOptions) (GTK_EXPAND |
GTK_FILL),(GtkAttachOptions) (0), 0, 0);

  btnAcept = gtk_button_new_with_mnemonic ("Acept");
  gtk_widget_show (btnAcept);
  gtk_table_attach (GTK_TABLE (table2), btnAcept, 1,
2, 5, 6,(GtkAttachOptions)
(GTK_FILL),(GtkAttachOptions) (0), 0, 0);

  g_signal_connect ((gpointer) btnAcept,
"button_press_event",G_CALLBACK
(btnAcept_button_press_event),NULL);

  return wdgForm;
}

gboolean btnAcept_button_press_event (GtkWidget
*widget, GdkEventButton *event, gpointer user_data){

	...
		
	saveData(gtk_entry_get_text(GTK_ENTRY(gentName)),
			 gtk_entry_get_text(GTK_ENTRY(gentAdress)), 
			 gtk_entry_get_text(GTK_ENTRY(gentTel)),
			 gtk_entry_get_text(GTK_ENTRY(gentCol)), 
			 gtk_entry_get_text(GTK_ENTRY(gentEmail)));

	...

  return FALSE;
}


////////////////////////////////////////////////////

////////////////////////////////////////////////////


If  I want to get data from the GtkEntry in the
function ?btnAcept_button_press_event?, I need global
variables to get the data of these.

But I have other windows with many GtkEntry,
GtkCheckButton, GtkComboBox, etc., if  I want to get
the data of  these widgets I need many global
variables.

But, as I mentioned before in visual basic can do
this.

Name=Me.txtName.tex()

But the problem is that I am use C.

Then as do I same with gtk and C?

And all example of Gtk use C and global variables.



      ____________________________________________________________________________________
¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:                      
http://correo.yahoo.com.mx/


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