GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Aug 29, 2016 7:07 am

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Transparent GtkTextview with gtkrc
PostPosted: Mon Nov 28, 2011 9:35 am 

Joined: Mon Nov 28, 2011 9:17 am
Posts: 2

I have created a window with a background image. On top of this window I put GtkTextview, but I cannot figure out how to make the background of GtkTextview transparent. (Note: I know in general it is not good to have transparent textview because its hard to read characters. But in this project it would look very nice with the background image I have on window widget).

I would like to know if this is possible to achieve with settings styles in gtkrc ? I have investigated this, and it seems that normal gtkrc "engine" cannot do this. It doesn't support RGBA colors, only RGB. I have tried using bg_pixmap with transparent image, but it didn't work. I have read that for example "murrine" engine should support transparency in gtkrc, but I cannot find any examples how it should be used.

If it is not possible with gtkrc, I am interested to hear how I could code my own custom GtkTextview widget, which would render with transparent background. I have seen some examples where people overwrite expose_event to do their own drawing. It seems quite challenging because I am not yet very familiar with cairo.

Here is the gtkrc..
style "window"
  bg_pixmap[NORMAL] = "window_bg.png" 

style "text-view-style"
    #GtkTextView::honors-transparent-bg-hint = 1
    #engine "murrine"
    #    what to put here?

    bg_pixmap[NORMAL] = "textview_transparent_bg.png" 

widget "*window-widget" style "window"
widget "*text-view-field" style "text-view-style"

And here is the pygtk code which creates a window and textview...
import gtk
import os

    Testing how make textview transparent with gtkrc.

def cb_destroy_window(widget, data=None):
    print "cb_destroy_window()"
def main():
    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    window.connect("destroy", cb_destroy_window)
    window.set_title("Transparent textview with gtkrc")

    vbox = gtk.VBox(False, 5)
    text_view = gtk.TextView()
    vbox.pack_start(text_view, False, False, 10)
if __name__ == "__main__":

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group