RE: color of gtk widget



Title: Re: color of gtk widget
will this change the text color of gtkbutton
 
  style = gtk_widget_get_style (button);
  style->text[0]="red color"; // is there any API to do this.
  gtk_widget_set_style(button, style);
 
Regards,
Prasanna.


From: Benjamin Berg [mailto:benjamin sipsolutions net]
Sent: Sat 8/4/2007 6:07 AM
To: jcupitt gmail com
Cc: Prasanna Kumar K; gtk-devel-list gnome org
Subject: 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.

Benjamin

This message (including any attachment) is confidential and may be legally privileged. Access to this message by anyone other than the intended recipient(s) listed above is unauthorized. If you are not the intended recipient you are hereby notified that any disclosure, copying, or distribution of the message, or any action taken or omission of action by you in reliance upon it, is prohibited and may be unlawful. Please immediately notify the sender by reply e-mail and permanently delete all copies of the message if you have received this message in error.



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