ccolorsgtkbackgroundgtktextview

Linux / C / GTK+ Set GtkTextView background to the default window colour


I want to set the GtkTexetView background colour to the window's default colour so that it looks like a GtkLabel. Take a look at these images, but please note that I want it for C and not PHP, and I use GNOME, not MS Windows.


Solution

  • Here is how to do it:

    GdkColor color;
    gtk_widget_realize(window);
    gtk_style_lookup_color(gtk_widget_get_style(window), "bg_color", &color);
    gtk_widget_modify_base(textview, GTK_STATE_NORMAL, &color);
    

    It really doesn't matter whether you use Windows or Gnome, or C or PHP, the GTK toolkit works mostly the same way across platforms, and you should be able to deduce the C code from looking at the PHP code.