# Treeview internal widgets question

**URL:** <https://www.ruby-forum.com/t/treeview-internal-widgets-question/154504>\
**Category:** Ruby-Gnome 2\
**Created:** [November 30, 2008, 11:06pm UTC](https://www.ruby-forum.com/t/treeview-internal-widgets-question/154504 "2008-11-30T23:06:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 30, 2008, 11:06pm UTC](https://www.ruby-forum.com/t/treeview-internal-widgets-question/154504/1 "2008-11-30T23:06:06Z")

</div>

Hi,

I’d like to implement a widget of two Fixeds in a Vbox, attached to a  
TreeView in a HBox.  
The top Fixed would be attached to the TreeView’s header, in sense, it’d  
allocate the same vertical space. Would show some cairo drawings.  
The Bottom Fixed would show some cairo drawings. in a ScrolledWindow,  
scrolled by the TreeView’s vertical scroller.

My current problem is: i can’t get the TreeView’s columns’ allocated  
height, so i could fixate the height of the top Fixed.  
Is it possible?  
i tried TreeViewColumn.widget.allocation, but the widget it’s nil, since  
it’s not set by me.  
I’d welcome anything

Thanks  
Balint

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 2, 2008, 2:26am UTC](https://www.ruby-forum.com/t/treeview-internal-widgets-question/154504/2 "2008-12-02T02:26:38Z")

</div>

Dobai-Pataky BÃ¡lint wrote:

> I’d like to implement a widget of two Fixeds in a Vbox, attached to a  
> TreeView in a HBox.  
> The top Fixed would be attached to the TreeView’s header, in sense, it’d  
> allocate the same vertical space. Would show some cairo drawings.  
> The Bottom Fixed would show some cairo drawings. in a ScrolledWindow,  
> scrolled by the TreeView’s vertical scroller.
> 
> My current problem is: i can’t get the TreeView’s columns’ allocated  
> height, so i could fixate the height of the top Fixed.  
> Is it possible?  
> i tried TreeViewColumn.widget.allocation, but the widget it’s nil, since  
> it’s not set by me.  
> I’d welcome anything

While I haven’t tried what you are doing, here’s a suggestion. Don’t  
use Fixeds. Instead create an Image to place in the VBox. I haven’t  
looked at cairo yet, but am assuming you can draw on a Pixbuf which you  
can get from the Image.

HTH,  
Roy

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 2, 2008, 9:52am UTC](https://www.ruby-forum.com/t/treeview-internal-widgets-question/154504/3 "2008-12-02T09:52:23Z")

</div>

resending with lowres image, to avoid the 40Kb limit

Roy W. wrote:

> > height, so i could fixate the height of the top Fixed.  
> > Is it possible?  
> > i tried TreeViewColumn.widget.allocation, but the widget it’s nil, since  
> > it’s not set by me.  
> > I’d welcome anything
> 
> While I haven’t tried what you are doing, here’s a suggestion. Don’t  
> use Fixeds.  
> How would that help me get the TreeView’s header widgets’ height?  
> Instead create an Image to place in the VBox. I haven’t  
> looked at cairo yet, but am assuming you can draw on a Pixbuf which you  
> can get from the Image.

Even on the Image I’d use cairo, i need transparency.

I attached an image, so it’s easier to get want i want to do.  
Now the top Fixed is fixed to a 20px height, but that may change with  
the theme or if the Column header text is wrapped into rows.

Thanks  
Balint

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 2, 2008, 11:57pm UTC](https://www.ruby-forum.com/t/treeview-internal-widgets-question/154504/4 "2008-12-02T23:57:18Z")

</div>

OK, here’s kind of an ugly way that may do what you want.

A TreeView header is actually a Button. Here’s a php-gtk tutorial that  
includes how to get the Button.

> **[410. How to set the background color of the column header of a treeview? |...](https://www.kksou.com/php-gtk2/sample-codes/set-the-background-color-of-the-column-header-of-a-treeview.php)**
>
> The Joy of Sharing and Learning Together

I think you can then get the size from Gtk::Widget#size\_request, but  
haven’t tried it. There is a caveat on size\_request must be associated  
with a screen.

HTH,  
Roy

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 3, 2008, 11:51am UTC](https://www.ruby-forum.com/t/treeview-internal-widgets-question/154504/5 "2008-12-03T11:51:08Z")

</div>

hi Roy,

this php example sets the column widget, and then uses it, in my  
question i noted, that i use the default column widgets, thus  
TreeViewColumn.widget returns nil.  
my original question was if i can query the header height without using  
custom column widgets, but seems this is the only way. i might give that  
a try.

thanks for your support  
balint
