Re: How to modify a button's fg color?



On Sun, Jun 18, 2006 at 11:52:24AM +0800, Bing Lin wrote:
I set some values of GtkRcStyle, but the color still not changed, how can I
do?
The code is like this:

#include <gtk/gtk.h>
int main( int argc, char *argv[] )
{
GtkWidget *window;
GtkWidget *button;
GdkColor color;
GtkRcStyle *rc_style;

gtk_init (&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "test");
gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
button = gtk_button_new_with_label("    ");
gtk_container_add(GTK_CONTAINER(window), button);
gdk_color_parse("red", &color);
rc_style = gtk_rc_style_new();
rc_style->fg[GTK_STATE_NORMAL] = color;
rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;
gtk_widget_modify_style(GTK_WIDGET(button), rc_style);
gtk_rc_style_unref(rc_style);
gtk_widget_show(button);
gtk_widget_show(window);

gtk_main ();
return 0;
}

The only thing drawn with fg color on a button is the focus
frame -- if it has focus.  But it should be visible, the
problem is that this, like the previous method and

    gtk_rc_parse_string("style \"fg-red\" {\n"
                        "  fg[NORMAL] = \"red\"\n"
                        "}\n"
                        "widget \"*.fg-red-button\" style \"fg-red\"\n");
    gtk_widget_set_name(button, "fg-red-button")

is defenceless against theme engines.  For example with
RedHat's bluecurve theme engine, it seems impossible to
change the color of the focus frame.  Without any theme
engine all methods work.

Yeti


--
Anonyms eat their boogers.



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