adcodingmaster -8 Light Poster

i m working on gtk but haviing a problem. i want to make a function which inputs a string and display it on a widget window and then if i call that function again by passing another string then that string should be shown forward to the previous string on the same widget window.
my current code is this. but it just print that text and gt stuck in gtk_main();
compile it as gcc -Wall -g window.c -o window `gtk-config --cflags` `gtk-config --libs`
plz solve this problem if any one can

must b very thankful.

thnx in advance.

#include <gtk/gtk.h>
#include <glib.h>
# include <stdlib.h>
gint destroyapp (GtkWidget *widget, gpointer gdata)
{
	g_print ("Quitting...\n");
	gtk_main_quit();
	return (FALSE);
}


int main (int argc, char *argv[])
{
	
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *text;

	gchar *buffer = "this is my text";

	/*--  Initialize GTK --*/
	gtk_init (&argc, &argv);
	/*-- Create the new window --*/
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	/*-- Create the vbox --*/
	vbox = gtk_vbox_new(FALSE, 0);
	/*-- Create a text area --*/
	text = gtk_text_new(NULL, NULL);
	/*-- Connect the window to the destroyapp function  --*/
	gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroyapp), NULL);
	/*-- Add the text area to the window --*/
	gtk_container_add(GTK_CONTAINER(vbox), text);  
	/*-- Add the vbox to the main window --*/
	gtk_container_add(GTK_CONTAINER(window), vbox);
	/*-- Add some text to the window --*/
	gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, strlen(buffer));
	gtk_widget_show(vbox);
	gtk_widget_show(text);
	gtk_widget_show(window);
	gtk_text_thaw(text);
	gtk_main();
return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.