drawing to textview's gdk_window



Hello. I'm trying to draw a rectangle of a textview's background
GdkWindow. First I get the gdk_window of the textview and and then try
ot draw on it. But it doesn't work. Why?

-----------------
#include <gtk/gtk.h>

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

        GtkWidget *window;
        GtkWidget *text;
        GdkGC *gc;
        GdkColor color1, color2;
        GdkWindow *win;
        gtk_init(&argc, &argv);

        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        text = gtk_text_view_new();
        gtk_widget_show(text);
        gtk_container_add(window, text);
        gtk_widget_show_all(window);
        gtk_widget_realize(text);

        win = gtk_text_view_get_window(text, GTK_TEXT_WINDOW_WIDGET);
        gc = gdk_gc_new(win);
        gdk_color_parse("red", &color1);
        gdk_gc_set_foreground(gc, &color1);
        gdk_color_parse("black", &color2);
        gdk_gc_set_background(gc, &color2);
        gdk_gc_set_fill(gc, GDK_SOLID);

        gdk_draw_rectangle(win, gc, TRUE, 1, 1, 20, 20);

        gtk_widget_set_size_request(window, 500, 400);
        gtk_main();
        return 0;
}
-------------------


Greets,
Luka


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