gtk_widget_show() doesn't "show".



 Folks,

   I'm working on a charting application that uses the Gnome Canvas for
drawing purposes.  I have a piece of code which reads in the definition
of a chart window, which contains one or more charts.  The chart window
is created first; it is a top level window with only one object inside:
a GtkNotebook.  Then, for each chart defined in the file, we add a page
to the notebook, and embed in the page a scrolled window with a canvas
inside.

   Seems simple, no?  The problem lies in creating the scaling affines
for the canvas.  I wish to modify the world to canvas affine so that I
can force the canvas to exactly match the height of its scrolled window
and to control what percentage appears from left to right.  I use the
following snippet of code to identify the size of the scrolled window:

   The variable CO is a "Chart Object" structure, and sw is a pointer
to the previously created (and shown!) scrolled window.

adjust = gtk_scrolled_window_get_hadjustment( 
                GTK_SCROLLED_WINDOW(CO->sw) );
view_width = (double)(adjust->page_size);

adjust = gtk_scrolled_window_get_vadjustment(
                GTK_SCROLLED_WINDOW(CO->sw) );
view_height = (double)(adjust->page_size);

   I then use the values of view_width and view_height, along with the
canvas scroll region, to set the canvas-to-window affine.  The problem
is this: view_width and view_height *always* get set to 0.  I even know
*why* this is the case: the scrolled window hasn't been "shown" yet.  I
have explicit calls to gtk_widget_show() for *every* widget in the
heirarchy as I create them, but the window does not appear on screen
until *all* of the notebook pages have been created.  Can anybody tell
me why this is the case?

   After I create the top level window and place the notebook in it, I
call gtk_widget_show_all( window ), after I create the scrolled window
I show it, after I create the canvas I show it, I even deliberately add
extra redundant gtk_widget_show() calls for all of the objects before
I try to get the adjustment values.  I even added in a call to
gtk_main_iteration() before getting the adjustment values.  All to no
avail.  It just will not show the items until the very end, and as a
consequence, I can't get valid values for the width and height of the
viewport.

   Can *anybody* give me any clues as to what's happening, here?

thanks,
Jim Wiggs
wiggs wiggs net





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