Hi,

i have recently run into a layout problem i am unable to solve. I have a dialog 
with a notebook and one of the notebooks
tabs is filled with the widget returned by the funktion below.  This function 
creates a scrolled window, puts a vbox inside and then add several textviews 
and some hboxes with additional info inside. The idea is to have one long 
scrolling window with a bunch of texts seperated by those hboxes (it's a 
geocaching application and this is a list of log entries wach with some info 
header).

The problem is that the textviews don't get scaled correctly. They don't 
display their full text but instead are truncated after one or two lines. I can 
even scroll this truncated stuff. This only happens until i click into on of 
the textviews. And although they aren't editable, they immediately scale to 
their correct size. I can force the same thing to happen with the (now 
commented) gtk_widget_show_all in the function below. But this causes a visible 
reconstruction of the scrolled_window and you actually see the wrong layout for 
a fraction of a second. But more important it makes that tab the default open 
one which isn't what i want. This tab should only become active once the user 
selects it.

I have the impression that there's something with the fact that the textviews 
don't know their size at the time they are put into the vbox. The actual size 
gets known once the entire notebook is being put into the dialog. But at that 
time the construction of the textviews/vboxes/scrolled_window is already done.

Asking the scrolled window to recalc its childrens sizes instead of calling 
gtk_widget_show_all doesn't seem to have any effect.

Any help is really appreciated ...

Regards,
  Till

static GtkWidget *cache_logs(log_t *log) {
  if(!log) 
    return gtk_label_new("No logs\n");

  /* put this inside a scrolled view */
  GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), 
                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);

  GtkWidget *vbox = gtk_vbox_new(FALSE, 0);

  /* add all logs to the vbox */
  while(log) {
    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);

    /* build header */
    gtk_box_pack_start(GTK_BOX(hbox), 
              gtk_image_new_from_pixbuf(icons.log[log->type]), 1, 1, 0);
    char date_str[32];
    sprintf(date_str, sizeof(date_str), "%d/%d/%d", 
            log->year, log->month, log->day);
    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(date_str), 1, 1, 0);  
    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(log->finder), 1, 1, 0);  

    gtk_box_pack_start(GTK_BOX(vbox), hbox, 1, 1, 0);  

    GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);
    gtk_text_buffer_set_text(buffer, log->text, strlen(log->text));
    GtkWidget *textview = gtk_text_view_new_with_buffer(buffer);
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD);
    gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textview), FALSE);

    gtk_box_pack_start(GTK_BOX(vbox), textview, 1, 1, 0);  

    log = log->next;
  }
  
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), 
                                        vbox);

  //  gtk_widget_show_all(scrolled_window);

  return scrolled_window;
}

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to