GNOME Bugzilla – Bug 304099
Add an oriented box widget to gtk
Last modified: 2008-10-02 03:09:24 UTC
An oriented box is a box that can change its orientation, from a hbox to a vbox. There is an implementation here: http://cvs.gnome.org/viewcvs/gthumb/src/gtkorientationbox.h?rev=1.1&view=markup http://cvs.gnome.org/viewcvs/gthumb/src/gtkorientationbox.c?rev=1.2&view=markup (This implementation is missing an "orientation-changed" signal however.) This widget is useful for things like panels. I'd rather have it in gtk itself than doing copy-paste because I'm using the OCaml language binding.
Created attachment 46405 [details] C source The C source - the gthumb file above, with a property, a signal, and some name changes for consistency with GtkToolbar.
Created attachment 46406 [details] The header
It may be a good idea to move the code of gtk_{h,v}box_size_allocate into another file, since it is duplicated in gtkorientationbox.c .
If this is a useful addition, the right way to do it is to add gtk_box_set_orientation() Change Box to be non-abstract, and make GtkHBox and GtkVBox just trivial subclasses with different default orientations.
I prefer the first option (but I don't care that much). I think GtkVBox and GtkHBox have a purpose as widgets that keep the same orientation, so it would be better not to break that guarantee. There is no code duplication either way, the subclasses of GtkBox all have a handful of methods. As far as the use cases: for doing some layout like in a dialog box, use a HBox or a VBox. For doing a panel, or a dockable component, use an OrientableBox.
Created attachment 46424 [details] C source
Created attachment 46425 [details] C header I've renamed the class to GtkOrientableBox, and removed the code duplication.
I believe owen is right. If we add something like this, GtkBox should just be made orientable.
*** This bug has been marked as a duplicate of 553573 ***