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 594231 - Glade thinks all GtkVBox elements are horizontal
Glade thinks all GtkVBox elements are horizontal
Status: RESOLVED FIXED
Product: glade
Classification: Applications
Component: general
3.6.x
Other Linux
: Normal normal
: ---
Assigned To: Glade 3 Maintainers
Glade 3 Maintainers
: 599874 (view as bug list)
Depends on: 587256
Blocks:
 
 
Reported: 2009-09-05 13:58 UTC by Alexander Shaduri
Modified: 2010-03-25 20:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Glade file which causes the error (4.54 KB, application/octet-stream)
2009-09-05 13:58 UTC, Alexander Shaduri
  Details
glade 3.6.7 screenshot (buggy) (24.30 KB, image/png)
2009-09-05 13:58 UTC, Alexander Shaduri
  Details
glade 3.5.2 screenshot (good) (17.99 KB, image/png)
2009-09-05 14:00 UTC, Alexander Shaduri
  Details
glade3-bgo594231-fix-vorientation.diff (4.70 KB, patch)
2010-03-25 19:12 UTC, Federico Mena Quintero
needs-work Details | Review
glade3-bgo594231-fix-vorientation.diff (6.62 KB, patch)
2010-03-25 19:58 UTC, Federico Mena Quintero
accepted-commit_now Details | Review

Description Alexander Shaduri 2009-09-05 13:58:18 UTC
Created attachment 142536 [details]
Glade file which causes the error

I have .glade files for my program, generated using glade 3.4.5. They load ok
with 3.5.2, but show up as a total mess with 3.6.7 (all of them). It seems like
every VBox is suddenly a HBox or something.

I'm attaching the .glade file and the screenshots.
Comment 1 Alexander Shaduri 2009-09-05 13:58:57 UTC
Created attachment 142537 [details]
glade 3.6.7 screenshot (buggy)
Comment 2 Alexander Shaduri 2009-09-05 14:00:11 UTC
Created attachment 142538 [details]
glade 3.5.2 screenshot (good)
Comment 3 Tristan Van Berkom 2009-09-05 17:56:43 UTC
Theres not really a fix for this to be done in Glade,
but I'll mark this one depending on the GTK+ bug just
so that we have a flag bug open in the glade3 list.
Comment 4 Alexander Shaduri 2009-09-05 18:16:38 UTC
Thanks,
Is there at least a workaround so I can edit the files in 3.6.7? Why does it happen, anyway?
Comment 5 Tristan Van Berkom 2009-09-05 18:36:04 UTC
For now if you want to see it vertical in Glade you have to
set the property to vertical explicitly, this will leave
an explicit property setting to vertical (which is something
you wont want if you are shipping to a GTK+ that doesnt
know about that property yet).

The reason why, is because the glade/gtkbuilder file format
definition is that default properties are omitted in the
xml, Glade introspects the reported property defaults
by GParamSpec to determine the default.

So now we have pre-orientable boxes with unset orientation,
which is correct, but this means horizontal, because what
the GParamSpec reports is inaccurate.
Comment 6 Tristan Van Berkom 2009-10-28 03:57:01 UTC
*** Bug 599874 has been marked as a duplicate of this bug. ***
Comment 7 Federico Mena Quintero 2010-03-24 22:12:06 UTC
So I have this horrible hack:

+static void
+fix_vertical_orientation (GObject *object)
+{
+	/* See bgo#594231 - GTK+ doesn't return the correct property defaults for
+	 * orientable widgets which are vertical, so we have to fix them up.
+	 */
+	if (GTK_IS_VBOX (object)
+	    || GTK_IS_VBUTTON_BOX (object)
+	    || GTK_IS_VPANED (object)
+	    || GTK_IS_VRULER (object)
+	    || GTK_IS_VSCALE (object)
+	    || GTK_IS_VSCROLLBAR (object)
+	    || GTK_IS_VSEPARATOR (object))
+		gtk_orientable_set_orientation (GTK_ORIENTABLE (object), GTK_ORIENTATION_VERTICAL);
+}
+

... but I haven't found the right place to call that function in the glade-3 sources.  I tried glade_widget_constructor(), glade_widget_build_object(), and somewhere in glade-gtk.c.

What would be the right place to do this?  I know this is not the 100% correct fix (that would be in GTK+), but glade is unusable in its current state :(
Comment 8 Tristan Van Berkom 2010-03-24 22:28:06 UTC
Well, files created (or "fixed") using a GTK+ after the strangely introduced 
property in GTK+ are not affected.

Glade can provide a way to "fix" a broken glade file explicitly,
the code would look something like:
  - Add --fix-orientation option to src/main.c
    o Simple implementation: Add "fix-orientation" attribute to GladeApp
    o Cute implementation: Don't show the main window or run the main loop,
      just ouput the loaded Glade file to stdio
  - in plugins/gtk+/glade-gtk.c:
    o Consult read_widget() functions for correct classes
    o If needed, declare a read_widget() function in gtk+.xml.in for the class
    o In a function like glade_gtk_box_read_widget() you add:
      if (glade_app_fix_orientation())
         force_subclass_contextual_orientation ();
Comment 9 Tristan Van Berkom 2010-03-25 01:08:31 UTC
Well.

We can trash the property entirely with zero effort and just not support 
it in Glade (actually Im not sure why I wasted my brain cells trying 
in the first place).

it will break any existing glade files which rely on manually setting orientation
by completely excluding those properties from Glade output.

I'm pretty convinced that I dont mind that breakage, usually what we
do for false default values is always save them; our policy for completely
broken cases like "orientation" can be to just not allow its configuration
in Glade until the day the toolkit false default is fixed; then we can expose
it for projects targeting GTK+ versions >= false default bug fix.

Objections ?
Comment 10 Alexander Shaduri 2010-03-25 08:55:37 UTC
Just to be sure (as I don't quite understand the internals of what's happening here):

Will this make the old files (made with 3.4.5) loadable again?
Will this affect loading of these files in gtk 2.8 or later through libglade (because I need to support that), or by converting them with gtk-builder-convert for gtk >= 2.12 and loading the converted files through GtkBuilder?

Thanks
Comment 11 Tristan Van Berkom 2010-03-25 16:04:08 UTC
No this will not create any bugs along those lines, "disabling" the 
orientations will just make Glade forget about orientation all together.

If files specify an orientation, it will be forgotten at load time
and omitted at save time.

BTW: saving as libglade format and calling gtk-builder-convert script
happens to work (its a migration path for GTK+ made when Glade did not
support GtkBuilder) - Glade does not explicitly support this conversion,
please convert with Glade instead (if you want Glade to read the files after
it makes sense to convert them with Glade).
Comment 12 Alexander Shaduri 2010-03-25 16:20:22 UTC
Thanks. I guess I'll be able to finally upgrade my Glade installation then.

A bit off topic: I use Glade to generate .glade files, and my configure system generates GtkBuilder files using gtk-builder-convert if gtk >= 2.12 is found (thus avoiding libglade dependency when possible). (Actually, it pre-generates them and includes them in tarball when running "make dist"). I don't need to load the generated files in Glade. So far, this setup works well across many different OS and GTK versions.
If I ever drop the gtk < 2.12 support, I'll be sure to convert them using Glade. I can't find any automated way for that though...
Comment 13 Tristan Van Berkom 2010-03-25 17:01:30 UTC
The main problem I see can happen at transition time is gtk-builder-convert
might make your application addicted to UIManagers.

If its a possibility that people need that parallel dual format support, 
ideally we should just include an option to run the conversion with Glade:

%.ui:%.glade
        glade-3 --target-format=GtkBuilder $< > $@

%.glade:%.ui
        glade-3 --target-format=libglade $< > $@

I could be pretty easy to implement by not doing gtk_main()
and not showing the application, but it will require X to
run (GTK+ has to be initialized because at this point GtkWidgets
need to be created, that could be avoided for a dry run but it would 
be quite a bit more work).

You could then have the option to do the conversion backwards and
optionally use some more advanced GtkBuilder features in >= 2.12.
Comment 14 Alexander Shaduri 2010-03-25 17:27:55 UTC
To avoid making any further off-topic comments here I filed a feature enhancement request at:
https://bugzilla.gnome.org/show_bug.cgi?id=613931
Comment 15 Federico Mena Quintero 2010-03-25 19:12:26 UTC
Created attachment 157095 [details] [review]
glade3-bgo594231-fix-vorientation.diff

This disables the "orientation" property for GtkVBox and other vertical widgets.  It seems to work correctly for me; old .ui files loaded show up correctly, and the re-saved versions don't have an "orientation" property defined either.
Comment 16 Tristan Van Berkom 2010-03-25 19:44:23 UTC
Review of attachment 157095 [details] [review]:

Ok great so: its not going to make sense to expose the property for GtkHVariants but not GtkVVariants so
we should also disable it for anything horizontal as well - I like that its disabled at the subclass level
and not at GtkBox level, as I expect in the future they will be instantiatable and we'll expose them enabled
at that point.

also, we maintain a ChangeLog in Glade; I dont need to see it in the patch but since many projects
nowadays dont maintain one - just a reminder ;-)
Comment 17 Federico Mena Quintero 2010-03-25 19:58:14 UTC
Created attachment 157099 [details] [review]
glade3-bgo594231-fix-vorientation.diff

Oops, you are right; I missed the horizontal widgets.  This fixes it.
Comment 18 Tristan Van Berkom 2010-03-25 20:12:43 UTC
Review of attachment 157099 [details] [review]:

Thanks, it will be great to forget about this for a while.
Comment 19 Federico Mena Quintero 2010-03-25 20:30:19 UTC
No problem.  Pushed to master as ecac9ea.