Scraping colors from the current Gnome theme



Sorry if I'm asking in the wrong place, but I asked on the PyGTK list and
didn't get much response.

I am trying to write a little script to scrape the color scheme from Gnome
and apply it to Wine.  I thought this would be trivial; reading from one
config file and translating into another, but it hasn't been so easy of a
beginner task.  I found a partial script and have improved on it, but am
stuck with colors that don't make sense to me.

https://bugs.launchpad.net/ubuntu/+source/wine/+bug/111061
http://ubuntuforums.org/showthread.php?t=55286&page=3#23

gtk.RcStyle Class Reference says (
http://www.pygtk.org/docs/pygtk/class-gtkrcstyle.html):

    PRELIGHT - A color used for widgets in the
    gtk.STATE_PRELIGHT state. This state
    is the used for gtk.Button and gtk.MenuItem
    widgets that have the mouse cursor over
    them, and for their children.

So PRELIGHT should be the text and background color of a menu item when I
hover over it, right?  In the Raleigh theme, I can use
menuitem.style.bg[gtk.STATE_PRELIGHT]
to read the menu hover background color, and it matches what I actually see
(#EAEAEA), so this would seem to be correct.

In the Human theme, though, it's completely different. The menu hover
highlight is yellowish orange, while menuitem.style.bg[gtk.STATE_PRELIGHT]
gives me #F3F0ED, almost white. I don't understand why.

In the Human gtkrc file, there's a bit like this:

  style "ubuntulooks-menu-item" = "ubuntulooks-default"
  {
     xthickness     = 2
     ythickness     = 3
     bg[SELECTED]   = @selected_bg_color
     fg[PRELIGHT]   = @selected_fg_color
     text[PRELIGHT] = @text_color
  }

That "bg[SELECTED]   = @selected_bg_color" is not bg PRELIGHT, but changing
it changes the actual visible hover color, so that must be it, right? "
menuitem.style.bg[gtk.STATE_SELECTED]" returns #FFD799, and this is much
closer to the actual highlight color.  (In the top of the gtkrc file,
there's "selected_bg_color:#FFD799", which is where it comes from, I guess.)

But if I try to use this bg[SELECTED] value to get the color for Raleigh, it
gives me a blue, which is not correct.

How do I get the actual color being used by a widget? Not the GTK color it's
theoretically supposed to us, but the color that GTK actually uses to draw
it.  Is this engine-specific?  Is there some other value I can read to get
the colors I actually want?  It seems to me that if I have a menu item
object, and I access menuitem.style.bg[gtk.STATE_PRELIGHT], it should give
me the actual hover (prelight) color of the menu item background.  Why
doesn't it?

Also, is there such a thing as a multiple-document interface in GTK, and if
so, how do I read its background color?

Sorry for all the questions.  :)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]