Re: GtkClist GtkScrolledWindow and initial position



Take a look at gtk_clist_moveto().

-Josh

Jason Majors wrote:

I have a GtkCList that is inside of a
GtkScrolledWindow (via gtk_container_add) that I would
like to have scroll down some (if needed) to display a
default selection.
Here's the code I have (the Clist has already been
populated and thawed):

  /* Create the scroll bar window. */
  scrollWindow = gtk_scrolled_window_new(NULL, NULL);

gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollWindow),
                                 GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
  gtk_widget_set_usize(scrollWindow, 350, 3
00);

  /* Add the list box to the scroll window. */
  gtk_clist_select_row(GTK_CLIST(listBox), index, 0);
  gtk_container_add(GTK_CONTAINER(scrollWindow),
                                        listBox);

  /* Move the scroll window to show the default
selection. */
  vAdj =
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrollWindow));

  newValue = (vAdj->upper + vAdj->lower) / 2.0f;
  gtk_adjustment_set_value(vAdj, newValue);
  gtk_adjustment_value_changed(vAdj);

Then there's some signal connection and both objects
are shown.

Can anyone tell me what I'm doing wrong here? Or
better yet, the right way to do it?

Thanks,
Jason




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