After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 646798 - Add a tip about "cloning contexts"
Add a tip about "cloning contexts"
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
3.0.x
Other other
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-04-05 11:26 UTC by Andrés G. Aragoneses (IRC: knocte)
Modified: 2012-05-26 17:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andrés G. Aragoneses (IRC: knocte) 2011-04-05 11:26:14 UTC
In http://library.gnome.org/devel/gtk/2.99/ch25s02.html#id1630676 , when it is recommended to use  the gtk_cairo_transform_to_window(), it should also be adviced to use cairo_save() before using it, and cairo_restore() after using the transformed context, in case you want to keep propagating the signal to your base classes without modifying the context.

This idea to improve the GTK2-to-GTK3 docs came up from this full discussion in IRC, for the record:

(12:02:29) knocte: how can I clone a cairo context?
(12:04:51) Company: knocte: you can't
(12:05:02) Company: knocte: you can only save/restore
(12:05:22) Company: knocte: why would you want to clone it?
(12:09:11) knocte: Company: in here ( http://library.gnome.org/devel/gtk/2.99/ch25s02.html#id1630676 which comes from here http://library.gnome.org/devel/gtk/2.99/gtk-migrating-2-to-3.html ) it is suggested that I use the gtk_cairo_transform_to_window() function, but that function doesn't generate a new context, so I guess it modifies the context that I pass as a parameter, therefore I need to keep the previous context I had before modifying it; does that make sense?
(12:11:07) Company: knocte: you are free to modify the context
(12:11:16) Company: knocte: in the draw function
(12:11:58) knocte: Company: but if I want to use the transform function to have windows coordinates, do some stuff with it, and then pass the original context with widget coordinates to my base class?
(12:12:29) Company: knocte: then you'd use cairo_save(); /* do your stuff */ cairo_restore();
(12:12:30) knocte: (to keep the signal propagating)
(12:12:51) knocte: ok, I'll check that out, thanks
(12:15:33) knocte: Company: btw, in the gtk2 code the context was disposed by the receiver of the signal (I guess because it was created from the eventexpose event), I guess now that as the context comes with the Drawn signal, it's responsability of the signal firer to dispose it, right?
(12:15:55) Company: yes
(12:16:02) knocte: ok thanks
(12:16:07) Company: you don't create it anymore, so you don't dispose it
(12:16:15) ***knocte nods
Comment 1 Frederic Peters 2011-04-05 13:04:56 UTC
This documentation is part of gtk+, library.gnome.org is just exposing it.