[gtk+/dialogs: 8/25] message dialog: Allow button box to extend to the edge



commit e8704268f94cda120085d5184938bcde9495ce93
Author: William Jon McCann <william jon mccann gmail com>
Date:   Sat Jan 11 15:31:29 2014 -0500

    message dialog: Allow button box to extend to the edge
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720059

 gtk/gtkbbox.c           |   23 +++++++++++++++++++----
 gtk/gtkdialog.ui        |    9 ++++++++-
 gtk/gtkmessagedialog.c  |    4 ++++
 gtk/gtkmessagedialog.ui |   10 ++++++----
 4 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c
index becdca2..58bed64 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -133,6 +133,13 @@ static void gtk_button_box_get_child_property (GtkContainer      *container,
 G_DEFINE_TYPE_WITH_PRIVATE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX)
 
 static void
+gtk_button_box_add (GtkContainer *container,
+                    GtkWidget    *widget)
+{
+  gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+}
+
+static void
 gtk_button_box_class_init (GtkButtonBoxClass *class)
 {
   GtkWidgetClass *widget_class;
@@ -154,6 +161,7 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
   widget_class->size_allocate = gtk_button_box_size_allocate;
 
   container_class->remove = gtk_button_box_remove;
+  container_class->add = gtk_button_box_add;
   container_class->set_child_property = gtk_button_box_set_child_property;
   container_class->get_child_property = gtk_button_box_get_child_property;
   gtk_container_class_handle_border_width (container_class);
@@ -349,10 +357,18 @@ gtk_button_box_set_layout (GtkButtonBox      *widget,
   if (priv->layout_style != layout_style)
     {
       priv->layout_style = layout_style;
+
       if (priv->layout_style == GTK_BUTTONBOX_EXPAND)
-        gtk_box_set_homogeneous (GTK_BOX (widget), TRUE);
+        {
+          gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (widget)), "linked");
+          gtk_box_set_homogeneous (GTK_BOX (widget), TRUE);
+        }
       else
-        gtk_box_set_homogeneous (GTK_BOX (widget), FALSE);
+        {
+          gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (widget)), "linked");
+          gtk_box_set_homogeneous (GTK_BOX (widget), FALSE);
+        }
+
       g_object_notify (G_OBJECT (widget), "layout-style");
       gtk_widget_queue_resize (GTK_WIDGET (widget));
     }
@@ -435,8 +451,7 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
 
   if (bbox->priv->layout_style == GTK_BUTTONBOX_EXPAND)
     {
-      gtk_box_set_child_packing (GTK_BOX (bbox), child, TRUE, TRUE, 0,
-                                 is_secondary ? GTK_PACK_START : GTK_PACK_END);
+      gtk_box_reorder_child (GTK_BOX (bbox), child, is_secondary ? 0 : -1);
     }
 
   if (gtk_widget_get_visible (GTK_WIDGET (widget)) &&
diff --git a/gtk/gtkdialog.ui b/gtk/gtkdialog.ui
index 2ff09b5..c03b8dd 100644
--- a/gtk/gtkdialog.ui
+++ b/gtk/gtkdialog.ui
@@ -17,13 +17,20 @@
       <object class="GtkBox" id="vbox">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="border_width">0</property>
         <property name="orientation">vertical</property>
+        <style>
+          <class name="dialog-vbox"/>
+        </style>
         <child>
           <object class="GtkButtonBox" id="action_area">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
-          </object>
+            <style>
+              <class name="dialog-action-area"/>
+            </style>
+           </object>
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
index 5eb5b00..7ce8274 100644
--- a/gtk/gtkmessagedialog.c
+++ b/gtk/gtkmessagedialog.c
@@ -32,6 +32,7 @@
 #include "gtkbuildable.h"
 #include "gtklabel.h"
 #include "gtkbox.h"
+#include "gtkbbox.h"
 #include "gtkimage.h"
 #include "gtkintl.h"
 #include "gtkprivate.h"
@@ -305,6 +306,7 @@ static void
 gtk_message_dialog_init (GtkMessageDialog *dialog)
 {
   GtkMessageDialogPrivate *priv;
+  GtkWidget *action_area;
 
   dialog->priv = gtk_message_dialog_get_instance_private (dialog);
   priv = dialog->priv;
@@ -316,6 +318,8 @@ gtk_message_dialog_init (GtkMessageDialog *dialog)
 
   gtk_widget_init_template (GTK_WIDGET (dialog));
   gtk_message_dialog_style_updated (GTK_WIDGET (dialog));
+  action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_EXPAND);
 }
 
 static void
diff --git a/gtk/gtkmessagedialog.ui b/gtk/gtkmessagedialog.ui
index 593debf..e2a1022 100644
--- a/gtk/gtkmessagedialog.ui
+++ b/gtk/gtkmessagedialog.ui
@@ -3,7 +3,7 @@
   <!-- interface-requires gtk+ 3.10 -->
   <template class="GtkMessageDialog" parent="GtkDialog">
     <property name="can_focus">False</property>
-    <property name="border_width">5</property>
+    <property name="border_width">0</property>
     <property name="title"> </property>
     <property name="resizable">False</property>
     <property name="type_hint">dialog</property>
@@ -18,13 +18,14 @@
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
+        <property name="border_width">0</property>
         <property name="orientation">vertical</property>
-        <property name="spacing">14</property>
+        <property name="spacing">20</property>
         <child>
           <object class="GtkBox" id="box">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="border_width">5</property>
+            <property name="border_width">0</property>
             <property name="spacing">12</property>
             <child>
               <object class="GtkImage" id="image">
@@ -35,7 +36,7 @@
                 <property name="stock">gtk-missing-image</property>
                 <property name="use_fallback">True</property>
                 <property name="icon_size">6</property>
-                <property name="xpad">6</property>
+                <property name="xpad">12</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -47,6 +48,7 @@
               <object class="GtkBox" id="message_area">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="margin_end">20</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">12</property>
                 <child>


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