After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663589 - Gtk.Overlay Not Transparent
Gtk.Overlay Not Transparent
Status: RESOLVED NOTABUG
Product: pygobject
Classification: Bindings
Component: general
3.0.x
Other Linux
: Normal major
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 663417 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-11-07 23:05 UTC by Jason C. McDonald
Modified: 2011-11-08 20:19 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jason C. McDonald 2011-11-07 23:05:23 UTC
I have been working with the new Gtk.Overlay object, and I was disappointed to discover that it does not work as it should. When any object is added via overlay.add_overlay(object), the background object (added via overlay.add(object) is completely hidden.

My code is below.

--

from gi.repository import Gtk, Gdk, GdkPixbuf, GdkX11

class OverlayTest:
    
    def __init__(self):
        
        win = Gtk.Window()
        win.set_resizable(False)
        win.set_decorated(False)
        win.set_size_request(640, 480)
        win.set_position(Gtk.WindowPosition.CENTER)
        
        overlay = Gtk.Overlay()
        win.add(overlay)
        overlay.show()
        
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("IMG/IMG-AMB-BRDG-L.png", 640, 480)
        img = Gtk.Image()
        img.set_from_pixbuf(pixbuf)
        overlay.add(img)
        img.show()
        
        fixed = Gtk.Fixed()
        overlay.add_overlay(fixed)
        fixed.show()
        
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("IMG/IMG-MPG-LOGO.png", 250, 50)
        imgMPL = Gtk.Image()
        imgMPL.set_from_pixbuf(pixbuf)
        eb_imgMPL = Gtk.EventBox()
        eb_imgMPL.set_visible_window(False)
        eb_imgMPL.add(imgMPL)
        fixed.put(eb_imgMPL, 10, 10)
        imgMPL.show()
        eb_imgMPL.show()
        
        win.show_all()

                
if __name__ == "__main__":
    Gdk.threads_enter()
    OverlayTest()
    Gtk.main()

--

How do I make this object function properly? Its functionality is pivotal to my project...in fact, it is the whole reason why I ported to PyGObject 3 in the first place.
Comment 1 Timo Vanwynsberghe 2011-11-08 15:21:16 UTC
You should simplify your testscript when asking help. There is way too much going on that is totally unnecessary and most of us probably won't have those image files :-).

Anyway, here is a working example:
from gi.repository import Gtk

class OverlayTest:
    def __init__(self):
        win = Gtk.Window()
        win.resize(400, 100)
        win.connect('delete-event', Gtk.main_quit)

        overlay = Gtk.Overlay()

        label = Gtk.Label("See me?")
        overlay.add(label)

        label = Gtk.Label("I am the overlay label")
        label.set_halign(Gtk.Align.END)
        label.set_valign(Gtk.Align.END)
        overlay.add_overlay(label)

        win.add(overlay)
        win.show_all()

if __name__ == "__main__":
    OverlayTest()
    Gtk.main()

Docs are your friend: http://developer.gnome.org/gtk3/stable/GtkOverlay.html
Comment 2 Jason C. McDonald 2011-11-08 16:17:17 UTC
If you look at my code, that is exactly what I have done. The reason I used the images is that the problem occurs with the images.

And I did happen to read the documentation. Several times. That's how I got my above code in the first place. Replace my image file paths with something you have, and you'll see my problem. As far as I know, labels are a very different animal.
Comment 3 Timo Vanwynsberghe 2011-11-08 18:21:52 UTC
It works perfectly with images and your example (which uses a Gtk.Fixed to overlay, not image) as well. I think you missed the important bits in my example/docs:
        label.set_halign(Gtk.Align.END)
        label.set_valign(Gtk.Align.END)
Comment 4 Jason C. McDonald 2011-11-08 18:43:27 UTC
Okay, that (mostly) works now. That wasn't super clear in the documentation, thus why I overlooked it. Docs could use a bit of polishing there...

Last aspect is, the image I've overlayed appears to lose its transparency (it's a .png with an alpha channel). Is there any additional step I need to make to correct this? Transparency here is very important to my project.
Comment 5 johnp 2011-11-08 18:58:25 UTC
Overlays look like a fairly new API which may not support alpha blending.  I think that is what clutter is for.  Not sure though.  You should ask nacho who wrote the patch in #gtk on irc.
Comment 6 johnp 2011-11-08 18:59:10 UTC
Any other bugs should be filed against Gtk
Comment 7 johnp 2011-11-08 20:19:44 UTC
*** Bug 663417 has been marked as a duplicate of this bug. ***