[Glade-users] change the font color and style of label



On Saturday 31 March 2007 23:44, Tristan Van Berkom wrote:
On Sat, 2007-03-31 at 13:12 +0100, amit bag wrote:
Hi All,
        I want to change the font size and the font style of the label
in glade . I also want to change the color of the letters of the
label . Please tell me how to change the font style and the color .

Use pango markup strings, that means set the "use-markup" property to
TRUE and search "pango markup" on google (or go to gtk.org/api and
find the online docs directly).

Basically you just set the text of the label with some xml markup
that lets you do pretty much anything to the label.

Cheers,
                  -Tristan


_______________________________________________
Glade-users maillist  -  Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users

Without XML markups it would be something like

#include <gtk/gtk.h>

int main (int argc, char **argv)
{
  gtk_init (&argc, &argv);

  GtkWidget *fen = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (G_OBJECT (fen), "destroy", G_CALLBACK (gtk_main_quit), 
NULL);

  GtkWidget *label = gtk_label_new ("This is a Multi-line label.\nSecond 
line\nThird line");
  gtk_container_add (GTK_CONTAINER (fen), label);

  PangoFontDescription *font_desc = pango_font_description_from_string ("mono 
8");
  gtk_widget_modify_font (label, font_desc);
  pango_font_description_free (font_desc);

  GdkColor color;
  gdk_color_parse ("#FFBF00", &color);
  gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &color);

  gtk_widget_show_all (fen);
  gtk_main();

  return 0;
}

You may want to take a look at the documentation for further details about 
functions.





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