Drawing on gtk textview
- From: "Soren Berg" <berg soren gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Drawing on gtk textview
- Date: Fri, 17 Oct 2008 09:43:24 -0500
I am trying to draw on a gtk textview's gdk window. I have set the textview
as app paintable before initialization and done the drawing in a callback
for the expose event of the textview as suggested
here<http://mail.gnome.org/archives/gtk-app-devel-list/2007-June/msg00060.html>(
http://mail.gnome.org/archives/gtk-app-devel-list/2007-June/msg00060.html)
but have not had any luck. Has this functionality been depreciated? Do I
need to use composited windows somehow? The previously linked discution
suggests that the OP got it working without them but he did not say how.
I would appricate any advice or information you could give me.
Thank you,
-Soren Berg
Here is what I have so far but either it is not drawing or GTK is blindly
painting over my work:
CODE:
__________________________
#include <gtk/gtk.h>
gboolean
text_exposed (GtkWidget *widget, GdkEventExpose *event, GtkTextView *text)
{
GdkColor color1, color2;
GdkWindow *win;
GdkGC *gc;
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, 50, 50);
return FALSE;
}
int main(int argc, char **argv) {
GtkWidget *window;
GtkWidget *text;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
text = gtk_text_view_new();
gtk_widget_set_app_paintable (GTK_WIDGET (text), TRUE);
gtk_widget_set_app_paintable (GTK_WIDGET (window), FALSE);
gtk_container_add(GTK_CONTAINER(window), text);
gtk_widget_show_all(window);
g_signal_connect (G_OBJECT(text), "expose-event",
G_CALLBACK(text_exposed), text);
gtk_widget_set_size_request(window, 500, 400);
gtk_main();
return 0;
}
________________________
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]