Re: [gtk-list] Re: change box orientation in runtime?



Chris Phelps wrote:

> Read inside:
>
> > This is just a proposal.
> >
> > Shouldn't the gtk_boxes have the capacity to change orientation between
> > horizontal and vertical in runtime?
> > I mean, it would be nice to have all logic of hboxes and vboxes inside
> > just the box widgets.
> > Just insert a:
> > gboolean orientation,
> > in the properties of boxes, and add the logic of hboxes and vboxes
> > inside it.
>
> >
> > For example, if I want to change a hbox into a vertical fashion, I must
> > destroy the hbox, and then rebuild all the destroys widgets inside a new
> > vbox where the last hbox resided. (This is no good, indeed).
> >
>
> One thing that you can do is build a Glist of all the items in the box,
> gtk_widget_ref() each one, make the new box, add all the widgets to it, and
> then gtk_widget_unref()... That could be done in about 10 lines of code I
> think...
>

Not sure that would be useful, because when I add the widgets (already
referenced with gtk_widget_ref) to the newly created box, GTK complains with
something like:

Gtk-CRITICAL **: file gtkcontainer.c: line 715 (gtk_container_add): assertion
`widget->parent == NULL' failed.

It means that the widgets can't be added to the new box, because the are already
children of the first box.
So I think this can't be done. (GTK doesn't support the concept of the same
widget as child of multiple parents, which is a pity too).

The only solution I see is:

1) Destroying the first box (and therefore all of its children), and then
creating a new one, creating all the widgets again and then packing them inside
the newly created box. (This a crappy solution in memory and processor usage).

2) Creating two boxes, one horizontal and the other vertical. Create all the
widgets and their duplicates (double memory usage), and pack ones inside the
horizontal box, and the duplicates in the vertical box. Then for switching
between the horizontal or vertical box, you just hide one and show the other.
(Crappy solution again, double memory usage).

3) Changing the box widget as I have said (I almost have already done it,
although I'm having a few small problems, because this could be my first patch
to GTK), and issue:
gtk_box_set_orientation(GTK_BOX(box),GTK_ORIENTATION_HORIZONTAL or
GTK_ORIENTATION_VERTICAL); (That's easy).

Problem with 3):

The hboxes and vboxes doesn't have any sense now. Two possibilities:

a) Maintain backwards compatibility, making hboxes and vboxes really stupid
classes for not breaking code or the dependency tree.

b) Remove hboxes and vboxes classes, and try to insert some defines inside
gtkcompat.h to maintain compatibility. (I don't know if this is even easy or at
least doable).
(Owen, any orientation on what would be good here?)


>
> > Another bad solution, is to create a hbox and a vbox, and fill both of
> > them with the same widgets (a duplicate of every widget for each box),
> > and them show the hbox and hide the vbox. To change orientation you just
> > hide the hbox and show the vbox or viceversa. (Bad solution).
> >
>
> I second this motion. It would be very useful for several of my projects, and
> might make some of the various gnome stuff a bit easier as well.
>
> >
> > The good solution:
> > Add the logic of hboxes and vboxes inside the boxes simply adding an
> > orientation property, and functions to change the property. E.g.:
> > gtk_box_set_orientation(GTK_BOX(box),GTK_HORIZONTAL)...
> >
> > For not killing backwards compatibility, hboxes and vboxes should be
> > only subclasses of the general box, with orientation set to
> > GTK_HORIZONTAL or GTK_VERTICAL (respectively) by default.
> >
> > How all this sound? Anybody interested in doing this?
> > I'm not very well qualified to change the code, but anyway I'll try it.
> > By the way, if one call gtk_box_set_orientation, what widget function
> > should I call to produce a change in the
> > orientation? gtk_widget_queque_resize or something?
> >
> > --
> > To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null




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