Notebook and Scrolled windows: bug?



If I run this program, I can only scroll on the first page of the notebook. In this example I used textviews, but the same problem occurs with treeviews. I've only been working with gtk (pygtk) for a few months, so I may be missing something, but this seems pretty straightforward. Version of gtk is gtk+-2.4.0 on Solaris 8. Compiled with: gcc notebook.c -o notebook `pkg-config --cflags --libs gtk+-2.0`

#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;
}







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