#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>


int main( int   argc, char *argv[] )
{

        GtkWidget *window;
        GtkWidget *vbox;
        GtkWidget *text_view;

        gtk_init (&argc, &argv);

        /* create a new window */
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_widget_set_size_request (GTK_WIDGET (window), 400, 300);
        g_signal_connect (G_OBJECT (window), "destroy",
                        G_CALLBACK (gtk_main_quit), NULL);

        vbox = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (window), vbox);
        gtk_widget_show (vbox);


        /* create a text entry */
        text_view = gtk_text_view_new();
        gtk_box_pack_start (GTK_BOX (vbox), text_view, TRUE, TRUE, 0);
        GtkTextBuffer *tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));

	char *str = "بهداد";
        GtkTextIter textIter;
	GtkTextTag *tag;
	gtk_text_buffer_get_start_iter(tb, &textIter);
	tag = gtk_text_buffer_create_tag(tb, "blue_settings", NULL);
	gtk_text_buffer_insert(tb, &textIter, str, -1);
	GtkTextIter startIter, endIter;
	gtk_text_buffer_get_iter_at_offset(tb, &startIter, 1);
	gtk_text_buffer_get_iter_at_offset(tb, &endIter, -1);
	gtk_text_buffer_apply_tag(tb, tag, &startIter, &endIter);

	gtk_text_buffer_insert(tb, &textIter, "\n\n\n", -1);

	gtk_text_buffer_insert(tb, &textIter, str, 2);
	gtk_text_buffer_insert_with_tags(tb, &textIter, str+2, -1, tag, NULL);

	char *markup = "<span size=\"x-large\" foreground=\"red\">ب</span><span size=\"x-large\" foreground=\"blue\">هداد</span>";

	PangoAttrList *attrList;
	pango_parse_markup(markup, -1, 0, &attrList, NULL, NULL, NULL);
	GtkLabel *label1 = gtk_label_new (str);
	gtk_label_set_attributes(GTK_LABEL(label1), attrList);
        gtk_box_pack_start (GTK_BOX (vbox), label1, FALSE, FALSE, 0);

        gtk_widget_show_all (window);

        gtk_main();

        return 0;
}
