RE: GtkEntry color Background



hi pernas:
maybe you could use gtk_widget_set_style();
you could do following:
void
on_button1_clicked    (GtkButton   *button,  gpointer   user_data)
{
  GtkStyle *style;
  GtkStyle *oldstyle;
  GdkColor color;
  GdkColor color2;

  color.red=65535;
  color.blue=0;
  color.green=0;
  color.red=0;
  color.blue=65535;
  color.green=0;

  oldstyle = gtk_widget_get_default_style();
  style = gtk_style_copy(oldstyle);
  style->bg[GTK_STATE_NORMAL] =color;
  style->bg[GTK_STATE_ACTIVE] =color2;	
  gtk_widget_set_style(button,style);
}

i do that to set a button's background color in a my own button class .
try to do that.
Good a day.
kason

-----Original Message-----
From: Isaac Pernas [mailto:isaacpernas telefonica net]
Sent: Tuesday, January 29, 2002 8:57 PM
To: gtk-list gtk org
Subject: GtkEntry color Background



Hola.
Estoy intentando cambiar el fondo d un GtkEntry pero por más que lo
intento no me deja. Nosé que estoy haciendo mal. La versión de mis
librerías Gtk es la 1.2.
I'm trying to change de background color for my GtkEntry but i can´t.
I don't know what i'm doing wrong. I have de Gtk+ 1.2 version.
This funcxtion changes the color of the background when youn click the
button.

void
on_button1_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
{
  GtkRcStyle *rc_style;
  GdkColor color;
  GdkColor color2;

  color.red=65535;
  color.blue=0;
  color.green=0;
  gdk_color_parse("#FFFFCC",&color2);
  rc_style=gtk_rc_style_new();
  rc_style->fg[GTK_STATE_NORMAL]=color;
  rc_style->bg[GTK_STATE_NORMAL]=color2;
  rc_style->base[GTK_STATE_NORMAL]=color2;
  rc_style->text[GTK_STATE_SELECTED]=color;
  rc_style->color_flags[GTK_STATE_NORMAL]|=GTK_RC_FG;
  rc_style->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BG;
  rc_style->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BASE;
  rc_style->color_flags[GTK_STATE_SELECTED]|=GTK_RC_TEXT;
 //gtk_widget_modify_style(GTK_WIDGET(GTK_BIN(button)->child),rc_style);
  gtk_widget_modify_style(GTK_WIDGET(user_data),rc_style);
  gtk_rc_style_unref(rc_style);
  g_print("cambiado el estado\n");
}

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list



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