Re: GtkOrientable and GtkBox
From: "Davyd Madeley", Date: 04/06/2009 10:59, Wrote: >> I haven't tried this, but unless I am mistaken this should reverse the >> order of children in a box. Seems easy enough to do and avoids the need >> to introduce yet another special case in the GtkBox code. Perhaps if >> this solution is not obvious enough, this should be turned into a >> utility function gtk_box_reverse_children_order() ? > For the GtkBox case, this assumes that you're not going to be making any > calls to pack_start() or pack_end() in the future. Otherwise you end up > with the button ordering that is not independent of your orientation. I think gtk_box_reverse_children_order() might be a good helper to have, I've personally thus far been moderately afraid to delve into the inner structure like that. Though I think now after seeing that snippet, it does look pretty straight forward. Still, I would count it as non-obvious, though, on the grounds that if there is the question of people not understanding pack_start() and pack_end() properly, then there's definitely people who don't understand how these packing methods interact with the list of widgets in the box. But I think GTK+ needs more model-view separation, not less. If an application puts stuff into a box, it's kinda handy if it comes back out in a predictable fashion. Having to remember and compensate for the Especially if it wants to rearrange the boxes contents, without having to iterate through the box looking for the item it wants to move. (Imagine, for example, if it were possible that a style change could cause the boxes contents to be reversed part way through that gtk_box_reverse_children_order() call... I'm pretty certain that can't happen, but I think it's an apt analogy.) Fredderic Hit it out of the park with a new bat. Click now! Bats http://tagline.excite.com/fc/FgElN1g3ri4MRUqgf2duKtUVR9QTdqC4pfLYZBg1ef9D4fkNnmOSwvhbH36/___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
On Wed, 2009-06-03 at 19:56 +0200, Sven Neumann wrote: > what's so painful about: > > GList *list = gtk_container_get_children (GTK_CONTAINER (box)); > gint pos = g_list_length (list) - 1; > > for (; list; list = list->next, pos--) > gtk_box_reorder_child (GTK_BOX (box), list->data, pos); > > I haven't tried this, but unless I am mistaken this should reverse the > order of children in a box. Seems easy enough to do and avoids the need > to introduce yet another special case in the GtkBox code. Perhaps if > this solution is not obvious enough, this should be turned into a > utility function gtk_box_reverse_children_order() ? For the GtkBox case, this assumes that you're not going to be making any calls to pack_start() or pack_end() in the future. Otherwise you end up with the button ordering that is not independent of your orientation. -- Davyd Madeley http://www.davyd.id.au/ 08B0 341A 0B9B 08BB 2118 C060 2EDD BB4F 5191 6CDA ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
On Wed, Jun 3, 2009 at 1:56 PM, Sven Neumann wrote: [...] > > I haven't tried this, but unless I am mistaken this should reverse the > order of children in a box. Seems easy enough to do and avoids the need > to introduce yet another special case in the GtkBox code. Perhaps if > this solution is not obvious enough, this should be turned into a > utility function gtk_box_reverse_children_order() ? Good point I over looked this api no need to ref, unparent, repack children, unref. Cheers, -Tristan ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
Hi, On Wed, 2009-06-03 at 13:32 -0400, Freddie Unpenstein wrote: > From: "Tristan Van Berkom", Date: 04/06/2009 00:13, Wrote: > > >> In general though, GtkOrientable already exists. People are bound > to > >> use it. > > An example use case of this would be a custom toolbar that could be > > placed optionally on top or on the side of the workspace where the > tool > > ordering is relevant, but thats not really the point right, aren't > we more after > > making sure the use cases we haven't thought of yet are still > valid ? ;-) > > I have had a use case... Wasn't critical, just a two-pane window, and > wanted to allow the two halves to be swapped. Since the thing was > loaded from a glade file, it was a pain to do it manually, and I ended > up just ditching the idea in favour or more useful functionality. what's so painful about: GList *list = gtk_container_get_children (GTK_CONTAINER (box)); gint pos = g_list_length (list) - 1; for (; list; list = list->next, pos--) gtk_box_reorder_child (GTK_BOX (box), list->data, pos); I haven't tried this, but unless I am mistaken this should reverse the order of children in a box. Seems easy enough to do and avoids the need to introduce yet another special case in the GtkBox code. Perhaps if this solution is not obvious enough, this should be turned into a utility function gtk_box_reverse_children_order() ? Sven ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
From: "Tristan Van Berkom", Date: 04/06/2009 00:13, Wrote: >> In general though, GtkOrientable already exists. People are bound to >> use it. > An example use case of this would be a custom toolbar that could be > placed optionally on top or on the side of the workspace where the tool > ordering is relevant, but thats not really the point right, aren't we more > after > making sure the use cases we haven't thought of yet are still valid ? ;-) I have had a use case... Wasn't critical, just a two-pane window, and wanted to allow the two halves to be swapped. Since the thing was loaded from a glade file, it was a pain to do it manually, and I ended up just ditching the idea in favour or more useful functionality. A more significant case, is where I wanted to be able to "rotate" three widgets relative to each other though 90 degree increments. The end two were toolbar's, the middle one was the main set of controls, with separators between them all. Again, though it would have been handy thing to be able to do, it really wasn't worth the effort of implementing it. Another spot where it could be useful, is in toolbars. I could imagine grabbing the handle of a floating toolbar, dragging it to the other end, and having all the buttons reverse their order. Might be appreciated by right-to-left reading users... (By the way, is floating toolbars and menus actually useful yet...? There really needs to be a handle box which allows multiple toobars/menus to be attached to all four sides of a central widget...) > I think a more interesting question is, what are we going to do with > GtkVBox and GtkHBox, just keep them around for api stability ? > Have them subclass GtkBox and override the "orientation" property > to mark it as G_PARAM_READABLE only ? Is that really neccessary...? They could simply be used to specify the "default" orientation... With it having to be specified explicitly in the base Box class, perhaps? Old apps that don't know about the re-orientation, shouldn't be using it. But some of them may still make sense even if they don't know about it, if it can be asserted through styles, for example. > Another worry is that pack start/pack end properties can already > be confusing, will adding a reverse-order property make things more > or less confusing to the user ? It's just defining an end and a direction... "start" and "end" still fit. Just need to describe them a little better, perhaps... This facility would allow allow for 90 degree "rotation" helper functions that do a orient-and-reverse combo. Fredderic LSAT Learn more about study prep, LSAT info and tips. Free info! http://tagline.excite.com/fc/FgElN1g1t3cOLKPdbTCLUznx4AU4tBJPehIUAIZh3oDIjuu6pEAa3vWGZKg/___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
On Wed, Jun 3, 2009 at 7:18 AM, Davyd Madeley wrote: [...] > > In general though, GtkOrientable already exists. People are bound to use > it. > An example use case of this would be a custom toolbar that could be placed optionally on top or on the side of the workspace where the tool ordering is relevant, but thats not really the point right, aren't we more after making sure the use cases we haven't thought of yet are still valid ? ;-) I think a more interesting question is, what are we going to do with GtkVBox and GtkHBox, just keep them around for api stability ? Have them subclass GtkBox and override the "orientation" property to mark it as G_PARAM_READABLE only ? If we were to add a GtkBox:reverse-order property, would it still play fair in GtkBox subclasses ? hmmm I think so. Another worry is that pack start/pack end properties can already be confusing, will adding a reverse-order property make things more or less confusing to the user ? Just some thoughts, personally I think if start/end pack properties dont cut it then its probably worth just a little switch in GtkBox (sounds like more fun than manually repopulating boxes at runtime). Cheers, -Tristan ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
On Wed, 2009-06-03 at 13:09 +0200, Sven Neumann wrote: > On Wed, 2009-06-03 at 19:03 +0800, Davyd Madeley wrote: > > > It's not really related to GtkOrientable per se, but it's specifically > > that when you change the runtime orientation you might also wish to > > reverse the packing order (I guess think about wishing to do a -90 > > degree rotation rather than a +90 degree rotation). > > > > Previously because you couldn't change the orientation, this was never > > something that came up. > > > > Does this clear up what I mean? > > Sure. But it would probably help to come up with a use case for this. I > can not think of any good use case for changing the box orientation at > run-time. And without such a use case, it becomes even harder to imagine > that one would also want to reverse the packing order. I don't actually want to change it at run time per-se (it's not going to be a preference in a UI), but I do want to be able to change the orientation based upon a style-property from the theme. Specifically this work relates to being able to offer style-properties to rearrange some GTK+ widgets (e.g. GtkDialog) for handheld-tablet environments using the GTK theme. In general though, GtkOrientable already exists. People are bound to use it. --d -- Davyd Madeley http://www.davyd.id.au/ 08B0 341A 0B9B 08BB 2118 C060 2EDD BB4F 5191 6CDA ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
Hi, On Wed, 2009-06-03 at 19:03 +0800, Davyd Madeley wrote: > It's not really related to GtkOrientable per se, but it's specifically > that when you change the runtime orientation you might also wish to > reverse the packing order (I guess think about wishing to do a -90 > degree rotation rather than a +90 degree rotation). > > Previously because you couldn't change the orientation, this was never > something that came up. > > Does this clear up what I mean? Sure. But it would probably help to come up with a use case for this. I can not think of any good use case for changing the box orientation at run-time. And without such a use case, it becomes even harder to imagine that one would also want to reverse the packing order. Sven ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
On Wed, 2009-06-03 at 11:55 +0200, Christian Dywan wrote: > how is this related to GtkOrientable at all? This was always > how a vertical box worked, ever since GtkVBox was there. There is > nothing new with it. > > I'm afraid I don't see how Gtk could help you out, if what you > need really is a specific packing. Anything but the current way is > pretty much random and up to the application. It's not really related to GtkOrientable per se, but it's specifically that when you change the runtime orientation you might also wish to reverse the packing order (I guess think about wishing to do a -90 degree rotation rather than a +90 degree rotation). Previously because you couldn't change the orientation, this was never something that came up. Does this clear up what I mean? --d -- Davyd Madeley http://www.davyd.id.au/ 08B0 341A 0B9B 08BB 2118 C060 2EDD BB4F 5191 6CDA ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
Am Wed, 03 Jun 2009 16:18:17 +0800 schrieb Davyd Madeley : > On Wed, 2009-06-03 at 10:08 +0200, Sven Neumann wrote: > > Hi, > > > > On Wed, 2009-06-03 at 14:25 +0800, Davyd Madeley wrote: > > > I was experimenting with using GtkOrientable today and came > > > across what might be an oversight when using it with GtkBox'like > > > objects. > > > > > > I wanted to turn a hbox into a vbox, which is fine. However the > > > buttons in the box are then clearly in the reverse order to the > > > one that makes sense. > > > > What order are they? What order would you suggest makes more sense? > > This would be a usage-specific thing. > > They're in the order they were packed. When you swap the orientation > of the vbox, they're still in the order they were packed, but that > order might be backwards from the order you desire (i.e. if you were > going to build the vbox from scratch). > > E.g., you might have: > > [1] [2] [3] > > Which orients to become > > [1] > [2] > [3] > > But for whatever reason, what you desired was: > > [3] > [2] > [1] > Hey David, how is this related to GtkOrientable at all? This was always how a vertical box worked, ever since GtkVBox was there. There is nothing new with it. I'm afraid I don't see how Gtk could help you out, if what you need really is a specific packing. Anything but the current way is pretty much random and up to the application. Yours, Christian ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
On Wed, 2009-06-03 at 10:08 +0200, Sven Neumann wrote: > Hi, > > On Wed, 2009-06-03 at 14:25 +0800, Davyd Madeley wrote: > > I was experimenting with using GtkOrientable today and came across what > > might be an oversight when using it with GtkBox'like objects. > > > > I wanted to turn a hbox into a vbox, which is fine. However the buttons > > in the box are then clearly in the reverse order to the one that makes > > sense. > > What order are they? What order would you suggest makes more sense? This would be a usage-specific thing. They're in the order they were packed. When you swap the orientation of the vbox, they're still in the order they were packed, but that order might be backwards from the order you desire (i.e. if you were going to build the vbox from scratch). E.g., you might have: [1] [2] [3] Which orients to become [1] [2] [3] But for whatever reason, what you desired was: [3] [2] [1] -- Davyd Madeley http://www.davyd.id.au/ 08B0 341A 0B9B 08BB 2118 C060 2EDD BB4F 5191 6CDA ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: GtkOrientable and GtkBox
Hi, On Wed, 2009-06-03 at 14:25 +0800, Davyd Madeley wrote: > I was experimenting with using GtkOrientable today and came across what > might be an oversight when using it with GtkBox'like objects. > > I wanted to turn a hbox into a vbox, which is fine. However the buttons > in the box are then clearly in the reverse order to the one that makes > sense. What order are they? What order would you suggest makes more sense? Sven ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
GtkOrientable and GtkBox
I was experimenting with using GtkOrientable today and came across what might be an oversight when using it with GtkBox'like objects. I wanted to turn a hbox into a vbox, which is fine. However the buttons in the box are then clearly in the reverse order to the one that makes sense. This can be hacked around by swapping PACK_START and PACK_END in the child properties, but it doesn't work if another item is then added to the box. I was considering the usefulness of a gtk_box_set_reverse_order() that reverses the meaning of PACK_START and PACK_END. There are kludge ways of implementing this, but it seems like it would be the most useful built into GtkBox. Thoughts? --davyd -- Davyd Madeley http://www.davyd.id.au/ 08B0 341A 0B9B 08BB 2118 C060 2EDD BB4F 5191 6CDA ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list