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

Re: Simple Event Handling



On Thu, 2001-08-30 at 20:19, manchalapraveenk reddy wrote:
> hi all,
> Plz find time to answer this at the earliest.
> i had placed two text entries and a button on a window
> and the first text entry should accept a string and
> after a cllick on the button i should be able to
> display the contents in teh second text entry. plz
> find time to answer this at the earliest possible.
> thank you.

is it something like the attached code you are looking for?

	/mailund

-- 
"No prayer goes unanswered - just, sometimes, you don't like the
answer."
				   -- Professor Colvert

#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

static GtkWidget *entry1, *entry2;

static void
button_clicked (void)
{
  gtk_entry_set_text (GTK_ENTRY (entry2),
		      gtk_entry_get_text (GTK_ENTRY (entry1)));
}


int
main (int argc, char *argv[])
{
  GtkWidget *win;
  GtkWidget *vbox;
  GtkWidget *button;

  gtk_init (&argc, &argv);

  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  vbox = gtk_vbox_new (TRUE, 0);
  gtk_container_add (GTK_CONTAINER (win), vbox);

  entry1 = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry1, FALSE, FALSE, 0);

  button = gtk_button_new_with_label ("Move Text");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

  entry2 = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (vbox), entry2, FALSE, FALSE, 0);

  /* setting up signals */
  gtk_signal_connect (GTK_OBJECT (button), "clicked",
		      GTK_SIGNAL_FUNC (button_clicked),
		      NULL);


  gtk_widget_show_all (win);

  gtk_main ();

  return 0;
}

PGP signature



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