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 Jul 28, 2014 4:12 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: GtKButton text label color.
PostPosted: Wed Jan 23, 2008 11:10 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
Hi! I'm trying to change the foreground color of a GtkButton using themes, but label's color don't change...
My theme is like this one:

style "btnlbl" {

fg[NORMAL] = "#FFFFFF"
fg[PRELIGHT] = "#FFFFFF"
fg[ACTIVE] = "#FFFFFF"
fg[SELECTED] = "#FFFFFF"
fg[INSENSITIVE] = "#FFFFFF"
text[NORMAL] = "#FFFFFF"
text[PRELIGHT] = "#FFFFFF"
text[ACTIVE] = "#FFFFFF"
text[SELECTED] = "#FFFFFF"
text[INSENSITIVE] = "#FFFFFF"
}

widget_class "*.GtkButton.GtkLabel" style "btnlbl"

i already try other things like *GtkButton.*, GtkButton*, and fg, bg, text... parameters; and all the others combinations i can figure out. In the code i just call gtk_rc_parse() before create any widget... A weird thing is that: when i load a theme that use images (pixmap engine) button's label color turns to white! however there's any error in my "solution" hehehe.

i'm using gtk+-2.12.2.

Thanks for all!!!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 24, 2008 3:20 pm 
Offline
Familiar Face

Joined: Thu Jan 10, 2008 8:54 pm
Posts: 7
Maybe like this:

widget_class "*.<GtkButton>.<GtkLabel>" style "btnlbl"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 24, 2008 8:01 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
you could do it without an rc file with gtk_widget_modify_fg()
http://library.gnome.org/devel/gtk/unst ... -modify-fg
just make a GdkColor (not a pointer) and set it's attributes between 0 and (I believe) 65535 by doing a 'color.red = n' etc. (multiply your color value that you want by 255 or 256 to get something in this range)
then set the GtkStateType to whatever you want,
http://library.gnome.org/devel/gtk/unst ... kStateType
hope this helps...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 24, 2008 10:15 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
it does not work for me :( i hav to use a theme, i'm doing this in my job :P anyway... i think that there is a bug in gtk parser when trying to match widget classes... since i don't hav time to look at this right now. i imagine other way to solve this:

1- encapsulate the button
2- put a label inside the button (as a container)
3- set a default name to these labels
4- in rc file i set this *name* to a specific theme.

what u think? i hope it works :D tomorrow i test it. anyway thanks for u both help _o/ it's strange to see that gtk has this bug or documentation is incomplete or i'm doing everything wrong :P

if anyone know how to use it by theme directly, please let me know :)

Thanks!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 3:23 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
I imagine that you know about this, but in case you don't, this might help with the rc files...
http://www.gtk.org/tutorial/c2118.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 9:19 pm 
Offline
Familiar Face

Joined: Wed Jan 23, 2008 11:08 pm
Posts: 38
Location: Brasil
hauwhuawhwa i don't believe :P KDE change some fonts and colors of gtk applications, that's my problem :D not the code :P damm KDE :D thanks folks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [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