# Transparent window (alpha support)

**URL:** <https://www.ruby-forum.com/t/transparent-window-alpha-support/137892>\
**Category:** Ruby-Gnome 2\
**Created:** [May 17, 2008, 8:05pm UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892 "2008-05-17T20:05:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgoetzin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/edb3f5/32.png) [@pgoetzin](https://www.ruby-forum.com/u/pgoetzin)\
**Post date:** [May 17, 2008, 8:05pm UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892/1 "2008-05-17T20:05:47Z")

</div>

Hello everyone,  
i use gtk::windows with various content(child) widgets like

#gstreamer widget  
class SimpleVideoWidget \< Gtk::DrawingArea  
…  
end

#image widget  
class SimpleImageWidget \< Gtk::Image  
…  
end

#html widget  
class WebkitWidget \< Gtk::WebKit::WebView  
…  
end

now i want to set them transparent.

i found some cairo samples but im not sure if the are right for me  
[http://www.pri.univie.ac.at/~mangler/alphademo/alphademo.rb](http://www.pri.univie.ac.at/~mangler/alphademo/alphademo.rb)

my composite manager is enabled  
Gdk::Screen.default.composited? is true  
and here i get the rgba colormap  
Gdk::Screen.default.rgba\_colormap

do i have to use gtk:window#.input\_shape\_combine\_mask(,0,0)?

does anyone have any hints ?

thanks ahead

Philipp

---

<div class="post-metadata">

**Author:** ![pgoetzin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/edb3f5/32.png) [@pgoetzin](https://www.ruby-forum.com/u/pgoetzin)\
**Post date:** [May 17, 2008, 10:40pm UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892/2 "2008-05-17T22:40:23Z")

</div>

> does anyone have any hints ?

ruby-gnome2/trunk/gtk/sample/misc/composited-windows.rb might be a  
good startting point.

–  
Guillaume C. - [NVC Communication Obstacles Game](http://zarb.org/~gc/)

---

<div class="post-metadata">

**Author:** ![pgoetzin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/edb3f5/32.png) [@pgoetzin](https://www.ruby-forum.com/u/pgoetzin)\
**Post date:** [May 19, 2008, 1:06am UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892/3 "2008-05-19T01:06:12Z")

</div>

Hello Guillaume,

thanks for the information …

got it to work. if composite is enabled u can use  
gtk::window#set\_opacity()

alpha must be between 0 an 1

e.g  
@fraticles["#{fraticle[‘id’]}"].signal\_connect\_after(‘map-event’) do  
|widget, event|  
widget.window.set\_opacity(0.8)

end

i think its also important where u call the functions because sometimes  
alpha was set for a window but it was not transparent … got best  
results with the map-event

regards  
Philipp

---

<div class="post-metadata">

**Author:** ![pgoetzin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/edb3f5/32.png) [@pgoetzin](https://www.ruby-forum.com/u/pgoetzin)\
**Post date:** [May 19, 2008, 9:47am UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892/4 "2008-05-19T09:47:41Z")

</div>

On Mon, May 19, 2008 at 1:06 AM, Philipp G.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> e.g  
> @fraticles[“#{fraticle[‘id’]}”].signal\_connect\_after(‘map-event’) do  
> |widget, event|  
> widget.window.set\_opacity(0.8)
> 
> end
> 
> i think its also important where u call the functions because sometimes  
> alpha was set for a window but it was not transparent … got best  
> results with the map-event

I don’t understand fully what you’re saying: do you imply that the  
mentioned example should be fixed? Can you provide a patch if that’s  
the case? Or do you mean there is another way to do the same thing?  
Can you program a short demo program if that’s the case?

–  
Guillaume C. - [NVC Communication Obstacles Game](http://zarb.org/~gc/)

---

<div class="post-metadata">

**Author:** ![pgoetzin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/edb3f5/32.png) [@pgoetzin](https://www.ruby-forum.com/u/pgoetzin)\
**Post date:** [May 19, 2008, 12:23pm UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892/5 "2008-05-19T12:23:43Z")

</div>

Hello Guillaume,  
im not sure if this is a bug, or my fault

i loop through a xml and create 1-5 windows … after 10-20 secs the  
windows will be destroyed and i create new windows …

here my code to create the window

xml\_fraticles.find(‘fraticle’).each{|fraticle|  
@fraticles["#{fraticle[‘id’]}"] = Gtk::Window.new  
@fraticles["#{fraticle[‘id’]}"].screen =  
Gdk::DisplayManager.get.default\_display.get\_screen  
fraticle[‘x11screen’].to\_i  
@fraticles["#{fraticle[‘id’]}"].move(fraticle[‘left’].to\_i,fraticle[‘top’].to\_i)  
@fraticles["#{fraticle[‘id’]}"].resize(fraticle[‘width’].to\_i,fraticle[‘height’].to\_i)  
@fraticles["#{fraticle[‘id’]}"].decorated = false  
fraticles["#{fraticle[‘id’]}"].add  
eval(fraticle[‘playermodule’]).new(self, fraticle)  
@fraticles["#{fraticle[‘id’]}"].set\_opacity(0.8)  
\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\< if i call it here only a few windows are  
transparent  
@fraticles["#{fraticle[‘id’]}"].signal\_connect\_after(‘map-event’) do  
|widget, event|  
widget.window.set\_opacity(0.8)\<\<\<\<\<\<\<\<\<\< if i call i here  
its working for all windows  
end  
}

---

<div class="post-metadata">

**Author:** ![pgoetzin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/edb3f5/32.png) [@pgoetzin](https://www.ruby-forum.com/u/pgoetzin)\
**Post date:** [May 22, 2008, 2:17pm UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892/6 "2008-05-22T14:17:33Z")

</div>

hi:

I am trying use the set\_sort\_func from the sortable interface for  
liststore or for a column in a treeview.

By now i can order columns like this:  
column.set\_sort\_column\_id(3)

This works but i can not have my own set\_sort\_func

or,

@list\_store\_productos.set\_sort\_column\_id(3)  
@list\_store\_productos.set\_sort\_func(3){|iter1,iter2|

}

But this fail to me.

Any ideas?

---

<div class="post-metadata">

**Author:** ![pgoetzin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/edb3f5/32.png) [@pgoetzin](https://www.ruby-forum.com/u/pgoetzin)\
**Post date:** [August 2, 2008, 9:01am UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892/7 "2008-08-02T09:01:56Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] set\_sort\_func” on Thu, 22 May 2008 14:21:12  
+0200,  
“Martin (OpenGeoMap)” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> @list\_store\_productos.set\_sort\_column\_id(3)  
> @list\_store\_productos.set\_sort\_func(3){|iter1,iter2|
> 
> }
> 
> But this fail to me.

Could you show us your example script that is executable?

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![pgoetzin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/edb3f5/32.png) [@pgoetzin](https://www.ruby-forum.com/u/pgoetzin)\
**Post date:** [May 19, 2008, 12:28pm UTC](https://www.ruby-forum.com/t/transparent-window-alpha-support/137892/8 "2008-05-19T12:28:44Z")

</div>

ok code is ugly, one more try

[http://pastie.caboo.se/199410](http://pastie.caboo.se/199410)
