GtkButtonBox: remove spacing when buttons are linked
authorLars Uebernickel <lars.uebernickel@canonical.com>
Wed, 8 Jul 2015 14:36:07 +0000 (16:36 +0200)
committerLars Uebernickel <lars.uebernickel@canonical.com>
Tue, 14 Jul 2015 13:12:56 +0000 (15:12 +0200)
GtkButtonBox adds the "linked" class to its style context when its
layout is set to GTK_BUTTONBOX_EXPAND. It shouldn't ever make sense to
have spacing between buttons in that case, as themes generally draw
linked elements with a continuous border.

Thus, always set spacing to 0 and ignore GtkDialog's button-spacing
style property when the layout is set to EXPAND.

Also remove the now-redundant css rules which set button-spacing to 0
for message dialogs.

https://bugzilla.gnome.org/show_bug.cgi?id=752131

gtk/gtkbbox.c
gtk/gtkbbox.h
gtk/gtkdialog.c
gtk/theme/Adwaita/_common.scss
gtk/theme/HighContrast/_common.scss

index 260e1c74e5b8086b57e04283d2d3836a65a1d087..68ec4845c812e22f8b70ab64dbfa8d37f6cdcdf8 100644 (file)
@@ -359,6 +359,7 @@ gtk_button_box_set_layout (GtkButtonBox      *widget,
       if (priv->layout_style == GTK_BUTTONBOX_EXPAND)
         {
           gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (widget)), "linked");
+          gtk_box_set_spacing (GTK_BOX (widget), 0);
           gtk_box_set_homogeneous (GTK_BOX (widget), TRUE);
         }
       else
index 46f1e59de083a9bdbe70e9aad6a4054353491784..a191feb3ca516169f8df454839f29c6edc5ddab2 100644 (file)
@@ -81,7 +81,10 @@ struct _GtkButtonBoxClass
  * @GTK_BUTTONBOX_END: Buttons are grouped towards the end of the box,
  *   (on the right for a HBox, or the bottom for a VBox).
  * @GTK_BUTTONBOX_CENTER: Buttons are centered in the box. Since 2.12.
- * @GTK_BUTTONBOX_EXPAND: Buttons expand to fill the box. Since 3.12.
+ * @GTK_BUTTONBOX_EXPAND: Buttons expand to fill the box. This entails giving
+ *   buttons a "linked" appearance, making button sizes homogeneous, and
+ *   setting spacing to 0 (same as calling gtk_box_set_homogeneous() and
+ *   gtk_box_set_spacing() manually). Since 3.12.
  *
  * Used to dictate the style that a #GtkButtonBox uses to layout the buttons it
  * contains.
index 78ee0125aacfc67b90d0aef32083f0f6ad08afa2..21cc18bd749e755fd422070b49e2fda69555e6a1 100644 (file)
@@ -696,8 +696,9 @@ update_spacings (GtkDialog *dialog)
       _gtk_box_set_spacing_set (GTK_BOX (priv->vbox), FALSE);
     }
 
-  gtk_box_set_spacing (GTK_BOX (priv->action_area),
-                       button_spacing);
+  /* don't set spacing when buttons are linked */
+  if (gtk_button_box_get_layout (GTK_BUTTON_BOX (priv->action_area)) != GTK_BUTTONBOX_EXPAND)
+    gtk_box_set_spacing (GTK_BOX (priv->action_area), button_spacing);
 
   if (!_gtk_container_get_border_width_set (GTK_CONTAINER (priv->action_area)))
     {
index fe888c7131f2d9c8632784acdef1cc3e44eeb526..58ebbf42bb3d43e914c2d828e4a6df734eac9daa 100644 (file)
@@ -2761,8 +2761,6 @@ GtkCalendar {
 }
 
 .message-dialog { // Message Dialog styling
-  -GtkDialog-button-spacing: 0;
-
   @if $variant==light {
     // the bright variant as a slightly darker bg which in this case clashes with the window decoration, overriding
     &.background { background-color: $bg_color; }
index c7eef9d6be6cdbaf5ecb7ccd23220432b15de670..50dcdf77897aff16ca1c6454dd4b631c89fb3ce0 100644 (file)
@@ -1998,7 +1998,6 @@ GtkCalendar {
 }
 
 .message-dialog { // Message Dialog styling
-  -GtkDialog-button-spacing: 0;
   .titlebar {
     border-style: none;
     box-shadow: inset 0 1px $borders_edge;