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 Nov 24, 2014 4:23 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: GTK themes and button background
PostPosted: Wed Jun 18, 2008 1:07 pm 
Offline
GTK+ Geek

Joined: Wed May 21, 2008 2:20 pm
Posts: 76
I would like to place a custom image to the background of all my buttons.

However, even such code placed in my resource file

style "buttons" {
GtkButton::inner-border = { 10, 10, 10, 10 }
bg[NORMAL] = "#666666"
}

doesn't work. I.e., the inner borders change as specified, but the background remains the same. I'm using GTK on Windows. I load resource file with

gtk_rc_parse("myresource.res");

Maybe I'm forgetting something?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 6:29 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
I'm assuming you've read the Gtk+ 2.0 tutorial's RC file section?
if not, these should help:
http://library.gnome.org/devel/gtk-tuto ... c2118.html
http://library.gnome.org/devel/gtk-tuto ... x2138.html
http://library.gnome.org/devel/gtk-tuto ... x2179.html
even if you have read it before, it can help, especially the 2nd and 3rd links.
also, if you want to set a background image, you'll need to use
bg_pixmap[NORMAL]
instead of
bg[NORMAL]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 12:29 pm 
Offline
GTK+ Geek

Joined: Wed May 21, 2008 2:20 pm
Posts: 76
dreblen wrote:
I'm assuming you've read the Gtk+ 2.0 tutorial's RC file section?
if not, these should help:
http://library.gnome.org/devel/gtk-tuto ... c2118.html
http://library.gnome.org/devel/gtk-tuto ... x2138.html
http://library.gnome.org/devel/gtk-tuto ... x2179.html
even if you have read it before, it can help, especially the 2nd and 3rd links.
also, if you want to set a background image, you'll need to use
bg_pixmap[NORMAL]
instead of
bg[NORMAL]


Thanks for the answer, I've read the tutorial, however my problem appeared to be in a slightly different GTK package copy present in the path. My program seemed to import some styles from there which overrode my custom styles.

Also I had another question. I tried to modify widget's style through program source code like

Code:
  GdkColor clr;
  clr.red = 0xaa;
  clr.green = 0xaa;
  clr.blue = 0xaa;
 
  label->style->fg[0] = clr;
  label->style->fg[1] = clr;
  label->style->fg[2] = clr;
  label->style->fg[3] = clr;
  label->style->fg[4] = clr;


But it yilded no results. Is this supposed to wirk at all? Maybe I should put it to some specific place in my code?[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 6:14 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
you might be able to override the default .gtkrc-2.0 file with this:
http://library.gnome.org/devel/gtk/stab ... ault-files

as for doing it manually, try using gtk_widget_modify_fg/bg:
http://library.gnome.org/devel/gtk/stab ... -modify-fg
http://library.gnome.org/devel/gtk/stab ... -modify-bg
to access state types, you use these in the calls to modify_fg/bg:
http://library.gnome.org/devel/gtk/stab ... kStateType
also, accessing members directly (e.g. label->style) is discouraged, and will not be allowed come Gtk+ 3.x


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 9:21 am 
Offline
Familiar Face

Joined: Sat Feb 09, 2008 1:54 pm
Posts: 6
Well, if you want to change the color of a label, the easiest way to do it is to put label into GtkEventBox, and than change its color via gtk_widget_modify_bg/gtk_widget_modify_fg.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 2:36 pm 
Offline
GTK+ Geek

Joined: Wed May 21, 2008 2:20 pm
Posts: 76
Thanks, but I am looking for understanding of architecture. As I see it - direct access to GtkWidget's Style property should do the thing - enable me to change all widget's styles. If it shouldn't then why?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 3:17 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
if you want to modify the style directly, try using these:
http://library.gnome.org/devel/gtk/stab ... yle-struct
http://library.gnome.org/devel/gtk/stab ... -style-new
http://library.gnome.org/devel/gtk/stab ... dify-style
if you directly change the style (e.g. widget->style), it won't do anything to update the style, you'll just be changing values.


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

All times are UTC


Who is online

Users browsing this forum: No registered users 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