#include <gtk/gtk.h> #include <string.h>
static gboolean delete( GtkWidget *widget, GtkWidget *event, gpointer data ) { gtk_main_quit (); return FALSE; }
int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *tab; GtkWidget *sw1; GtkWidget *sw2; GtkWidget *tv1; GtkWidget *tv2; GtkTextBuffer *tb1; GtkTextBuffer *tb2; int i; char buf[1024]; char line[10];
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete), NULL);
/* create two textview widgets and add text */ tv1 = gtk_text_view_new(); tv2 = gtk_text_view_new(); tb1 = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv1)); tb2 = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv2)); buf[0] = 0; for(i=1;i<=80;i++) { sprintf(line, "Line %d\n", i); strcat(buf, line); } gtk_text_buffer_set_text(GTK_TEXT_BUFFER(tb1), buf, strlen(buf)); gtk_text_buffer_set_text(GTK_TEXT_BUFFER(tb2), buf, strlen(buf)); gtk_widget_show(tv1); gtk_widget_show(tv2);
/* create two scrolled windows and add textview widgets to them */ sw1 = gtk_scrolled_window_new(0,0); sw2 = gtk_scrolled_window_new(0,0); gtk_container_add(GTK_CONTAINER (sw1), tv1); gtk_container_add(GTK_CONTAINER (sw2), tv2); gtk_widget_show(sw1); gtk_widget_show(sw2);
/* create the notebook with two pages */
tab = gtk_notebook_new();
gtk_notebook_append_page(GTK_NOTEBOOK (tab), sw1, gtk_label_new("Page 1"));
gtk_notebook_append_page(GTK_NOTEBOOK (tab), sw2, gtk_label_new("Page 2"));
gtk_container_add(GTK_CONTAINER (window), tab);
gtk_widget_show(tab);
gtk_widget_show(window);
gtk_main ();
return 0; }
_______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list