problems with window size



Hi,

I have what is I'm sure is a fairly simple question.

I have a dialog box created with

window = gtk_dialog_new();

Then I create a table containing a bunch of label widgets and stick it in the window with

  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox),
                      table, TRUE, TRUE, 0);

The problem I have is I have is that on some of these dialogs, the table is quite long and you end up with a window that is taller than the screen. The dialogs with smaller tables look great though.

So, I changed the code a bit and added scrollbars. So now I do something like:

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
          GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  table = gtk_table_new(0,0,FALSE);

  /* create and add a bunch of label widgets to the table */
  [snip]

  /* create and add gridlines */
  item=gtk_hseparator_new();
  gtk_table_attach(GTK_TABLE(table),item,0,7,0,1,
  GTK_FILL, GTK_FILL,1,1);
  [snip - lots more h and v separators added]


   /* put the table in the scrolled window */
    gtk_scrolled_window_add_with_viewport(
          GTK_SCROLLED_WINDOW (scrolled_window), table);
    gtk_widget_show_all(scrolled_window);


And finally I stick this scrolled_window into my dialog box in the same way that I used to put the table in.

The problem I have now is the dialog boxes always come up very small, a tiny fraction of my screen size, and I always have to manually enlarge them before they are remotely useful. The scroll bars a a big help on the table which had lots of rows.

So my question is how to tell this dialog box, 'make your self big enough to avoid scroll bars unless you would be larger than [display size, some fixed size, something...] in which case just use the max allowed size'.

I played around with gtk_widget_set_usize, but it makes the smaller tables ugly.

Suggestions?

Thanks!

-Dan





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