Re: How do I expose a specific widget and all it parents?



Egon Andersen, Talura wrote:
>>  > I have a notebook with several pages and I want to be able to from the
>>  > application to show/expose any specific page I want.
>>
>> I think you need gtk_notebook_set_page()
> 
> I thought of this function, but then I need to make it top-down. I can 
> in no way just say that I want to see the page (and its parents) 
> containing a specific widget?

Hiya,

Sure, just it depends on what info you're tracking. For example, if you 
know the widget that each notebook page is showing, you can do

	gint page = gtk_notebook_page_num( nb, my_page_widget );

	gtk_notebook_set_page( nb, page );

(or have I misunderstood?)

> BTW When I used gtk_widget_get_ancestor(notebook1, GTK_TYPE_NOTEBOOK), I 
> got the pointer equal to 'notebook1', not the parent notebook as I had 
> expected. Is this the intended behaviour of gtk_widget_get_ancestor() or 
> is it a simple bug?

No, that's the way it's supposed to work. Take a look at gtkwidget.c ... 
_get_ancestor() finds the nearest enclosing widget of that type 
(including itself). To get one out, do

	gtk_widget_get_ancestor( widget->parent, GTK_TYPE_WHATEVER )

>>  > I also have scrollable windows and want a specific entry to be 
>> visible -
>>  > just another complication I imagine.
>>
>> It depends on what sort of thing you're displaying. Widgets like 
>> clist, for example, have methods which will scroll to make a specific 
>> row visible.
>>
>> If it's not a clever widget, then you just set the adjustment on the 
>> scrolled window to the position of the child.
> 
> It is 'any widget', so it can not be expected to be a clever widget :-)
> But how do I get the position of the widget, so that I can set the 
> adjustment?

What are you using inside the scrolled window to layout your widgets? 
You might be able to just read child->allocation.x/y, or you might need 
to poke about inside the layout widget.

John



========================================================== 
Coming Soon: 

Madame de Pompadour 
Images of a Mistress 

16 October 2002 - 12 January 2003 

For information and tickets: 
http://www.nationalgallery.org.uk/exhibitions/



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