Re: color of gtk widget

On Fri, 2007-03-08 at 16:17 +0100, jcupitt gmail com wrote:
> On 8/3/07, Prasanna Kumar K <prasanna tataelxsi co in> wrote:
> >  I have a GtkWidget "Button. I want the color of the button should be complete red.
> You can do it with a gtkrc. For example, set this resource file:
> widget "*red_widget" style "red_style"

If you already use a style, you can also use

widget "*red_widget* style "red_style"

instead. And then you just need to set the name on the button and none
of its children. As the label will also be affected with the above line
(because of the trailing *).

> Now in your code do:
> void
> set_name( GtkWidget *widget, const char *name )
> {
>         gtk_widget_set_name( widget, name );
>         if( GTK_IS_CONTAINER( widget ) )
>                 gtk_container_foreach( GTK_CONTAINER( widget ),
>                            (GtkCallback) set_name, (char *) name );
> }
> set_name( button, "red_widget" );

Then a simple gtk_widget_set_name is enough.

The only other choice is to call gtk_widget_modify_fg recursively on all
the widgets.


Attachment: signature.asc
Description: This is a digitally signed message part

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