GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Dec 21, 2014 1:09 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 
Offline

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

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..
Code:
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...
Code:
import gtk
import os

"""
    Testing how make textview transparent with gtkrc.
"""

       
def cb_destroy_window(widget, data=None):
    print "cb_destroy_window()"
    gtk.main_quit()
   
       
def main():
   
    gtk.rc_add_default_file("gtkrc")
    gtk.rc_parse("gtkrc")
   
    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    window.set_name("window-widget")
    window.set_position(gtk.WIN_POS_CENTER)
    window.connect("destroy", cb_destroy_window)
    window.set_title("Transparent textview with gtkrc")
    window.set_size_request(400,400)
    window.set_border_width(30)

    vbox = gtk.VBox(False, 5)
    window.add(vbox)
   
    text_view = gtk.TextView()
    text_view.set_name("text-view-field")
    text_view.set_wrap_mode(gtk.WRAP_CHAR)
    text_view.set_size_request(300,200)
    vbox.pack_start(text_view, False, False, 10)
 
    window.show_all()
    gtk.main()
   
if __name__ == "__main__":
    main()


Top
 Profile  
 
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: No registered users and 1 guest


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