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 669342 - overlay: add left/right/top/bottom style classes to overlay children
overlay: add left/right/top/bottom style classes to overlay children
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-02-03 20:35 UTC by Cosimo Cecchi
Modified: 2012-02-29 17:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
overlay: add left/right/top/bottom style classes to overlay children (4.92 KB, patch)
2012-02-03 20:35 UTC, Cosimo Cecchi
none Details | Review
overlay: add left/right/top/bottom style classes to overlay children (4.98 KB, patch)
2012-02-06 16:30 UTC, Cosimo Cecchi
reviewed Details | Review
tests: add a test for GtkOverlay position style classes (5.86 KB, patch)
2012-02-06 16:30 UTC, Cosimo Cecchi
none Details | Review

Description Cosimo Cecchi 2012-02-03 20:35:37 UTC
See attached patch. This is very useful e.g. to round corners and tweak borders for the floating bars in Nautilus and Epiphany.
Comment 1 Cosimo Cecchi 2012-02-03 20:35:39 UTC
Created attachment 206724 [details] [review]
overlay: add left/right/top/bottom style classes to overlay children

If the children has no programmatic margin set, follow its vertical and
horizontal alignment changes and set left/right/top/bottom style classes
accordingly.
Comment 2 Matthias Clasen 2012-02-06 00:18:56 UTC
Hmm, I don't think this is going to work with the overlays in my new color-chooser, which use ::get-child-position
Comment 3 Cosimo Cecchi 2012-02-06 16:30:26 UTC
Created attachment 206913 [details] [review]
overlay: add left/right/top/bottom style classes to overlay children

A different approach, which also works when a custom get-child-position function is used. Now we just compare the allocations of the child widget and the overlay.
Comment 4 Cosimo Cecchi 2012-02-06 16:30:58 UTC
Created attachment 206914 [details] [review]
tests: add a test for GtkOverlay position style classes

Tests style classes are correctly set for various overlay use scenarios.
Comment 5 Matthias Clasen 2012-02-10 01:29:40 UTC
Review of attachment 206913 [details] [review]:

::: gtk/gtkoverlay.c
@@ +196,3 @@
+    gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+  else
+    changed = FALSE;

This doesn't look right to me... changed should only be FALSE if _all_ the classes are unchanged, no ?
Comment 6 Cosimo Cecchi 2012-02-29 17:37:45 UTC
(In reply to comment #5)

> This doesn't look right to me... changed should only be FALSE if _all_ the
> classes are unchanged, no ?

Yeah, that code was wrong. There was also another issue where the style classes were not correctly compensating for the presence of a scrolled window.
Fixing that also uncovered another bug that was already present in GtkOverlay, namely we weren't checking the return value of gtk_widget_translate_coordinates(), which could lead to using uninitialized values as allocation coordinates.

I now pushed a fixed version of this patchset to git master, including an updated test that covers the GtkScrolledWindow case too.