GNOME Bugzilla – Bug 142849
Replace AlignmentEnum by float constants
Last modified: 2014-06-02 14:43:49 UTC
Currently, every single method or constructor which takes an alignment argument has to be overloaded in order to support the symbolic constants defined by Gtk::AlignmentEnum. Just one example: void Gtk::Entry::set_alignment(float xalign); void Gtk::Entry::set_alignment(AlignmentEnum xalign); This approach introduces a couple of problems: a) overloading introduces ambiguities (this particularly problematic with constructors) b) overloads make function pointers hard to use c) there's the risk of forgetting to add an overload d) methods that take n float arguments would need 2^n overloads in order to support all possible variants e) unnecessary bloat (consider link time, symbol resolving on startup, etc.) I propose to get rid of all these overloads at the next API/ABI break, and to replace Gtk::AlignmentEnum by float constants: namespace Gtk { const float ALIGN_LEFT = 0.0; const float ALIGN_CENTER = 0.5; const float ALIGN_RIGHT = 1.0; const float ALIGN_TOP = 0.0; const float ALIGN_BOTTOM = 1.0; } The only disadvantage would be that the existence of these constants is not obvious from the method's prototype. I think this could be solved by adding some magic to gmmproc to generate appropriate hints in the documentation.
For the documentation, we could just use a typedef instead of a float, and document that typedef.
Sounds good.
There is no Gtk::AlignmentEnum in gtkmm 3. There is the Gtk::Align enum, wrapping GtkAlign. GTK+ has deprecated many functions that take float alignments, e.g. gtk_misc_set_alignment(), gtk_alignment_set() and gtk_button_set_alignment(). Nowadays there are only a few examples of overloaded alignment methods, one taking Align arguments, the other taking float arguments, and none of them deprecated. There are such pairs of methods only in the AspectFrame, Entry, Frame and TreeViewColumn classes. I close this bug as Obsolete. Feel free to reopen it, if you disagree.