deprecated gtk_cairo_create



Hi, everyone
I'm struggling with migration from gtk2. Well gtk_cairo_create is deprecated in gtk3. And it looks  the changes are very serious (or I'm sach silly that even do not understand what should I do instead of it ). Is there anybody who use Drawing Area in GTK3 and can explain the right way of its cairo context creation and drawing on it to me. It would be so appreciated.

Documentation says the following:
***gtk_cairo_create
gdk_cairo_create
has been deprecated since version 3.22 and should not be used in newly-written code. Use gdk_window_begin_draw_frame() and gdk_drawing_context_get_cairo_context() instead.

***gdk_window_begin_draw_frame
[bla-bla-bla...] When using GTK+, the widget system automatically places calls to gdk_window_begin_draw_frame() and gdk_window_end_draw_frame() around emissions of the GtkWidget::draw signal. That is, if you’re drawing the contents of the widget yourself, you can assume that the widget has a cleared background, is already set as the clip region, and already has a backing store. Therefore in most cases, application code in GTK does not need to call gdk_window_begin_draw_frame() explicitly.

I use GTK+, so I can forget about gdk_window_begin_draw_frame for some time. Right?
And there is only gdk_drawing_context_get_cairo_context in the rest of options. So I write the following:

{main}
...
/*Drawing area and text_entry at the bottom of it */
area = gtk_drawing_area_new();
text_entry = gtk_entry_new();
vbox = gtk_vbox_new (FALSE, 0); 

gtk_box_pack_start(vbox, area, TRUE, TRUE, 0);
gtk_box_pack_start(vbox, text_entry,  FALSE, FALSE, 0);

gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show_all(window);
gtk_main();  
...

{draw_callback}

gboolean draw_callback(GtkWidget *area, GdkEventExpose *event, GArray *ptLinePoints) {
...
cairo_t *cr = gdk_drawing_context_get_cairo_context (area);
...
}

But linker (gcc package) writes  "undefined reference to `gdk_drawing_context_get_cairo_context"... :-(
Everything indicated that I missed several lines of code before gdk_drawing_context_get_cairo_context. But what lines exactly? Googling gives nothing...

Is there anybody who use Drawing Area in GTK3 and can explain the right way of its cairo context creation and drawing on it to me. It would be so appreciated.

Thanks in advance!

Best Regards, (and Happy New Year for everyone here!!!)
Sergey.





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