Set the color and font of a GtkLabel

there is two way to set the color and font of GtkLabel, the first is by function, and the second is by loading resource:
1)  by invoking function In GTK+ 2.0:
  GdkColor color;

gdk_color_parse ("red", &color);

gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &color);

There's at least one other good way to set the color of a widget, which is to use a resource file; read on. If you have problems, look at the FAQs below.
 
2)  by loading resource In Gtk+2.0
The widget name path constructed for a Label consists of the widget names of its object hierarchy as well, e.g.
window (name: humphrey) hbox label (name: mylabel)
The widget path your pattern needs to match would be: humphrey.GtkHBox.mylabel
The resource file may look something like:
style "title"
{
fg[NORMAL] = {1.0, 0.0, 0.0}
font = "-adobe-helvetica-bold-r-normal--*-140-*-*-*-*-*-*"
}
widget "*mylabel" style "title"

In your program, you would also need to give a name to the Label widget, which can be done using:
  label = gtk_label_new("Some Label Text");
gtk_widget_set_name(label, "mylabel");
gtk_widget_show(label);

좋은 웹페이지 즐겨찾기