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 142849 - Replace AlignmentEnum by float constants
Replace AlignmentEnum by float constants
Status: RESOLVED OBSOLETE
Product: gtkmm
Classification: Bindings
Component: general
2.4
Other All
: Normal normal
: 3
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-05-20 16:04 UTC by Daniel Elstner
Modified: 2014-06-02 14:43 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Daniel Elstner 2004-05-20 16:04:38 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.
Comment 1 Murray Cumming 2004-05-21 18:06:51 UTC
For the documentation, we could just use a typedef instead of a float, and
document that typedef.
Comment 2 Daniel Elstner 2004-05-21 18:46:27 UTC
Sounds good.
Comment 3 Kjell Ahlstedt 2014-06-02 14:43:49 UTC
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.