]> Pileus Git - ~andy/gtk/commitdiff
Bug 408244 – add GtkDialog::content-area-spacing
authorChristian Dywan <cdywan@src.gnome.org>
Wed, 24 Sep 2008 08:41:46 +0000 (08:41 +0000)
committerChristian Dywan <cdywan@src.gnome.org>
Wed, 24 Sep 2008 08:41:46 +0000 (08:41 +0000)
* gtk/gtkbox.c (gtk_box_init), (gtk_box_set_spacing),
(_gtk_box_set_spacing_set), (_gtk_box_get_spacing_set):
* gtk/gtkbox.h:
* gtk/gtkdialog.c (gtk_dialog_class_init), (update_spacings):
Implement "content-area-spacing" style property in GtkDialog
and internal helper _gtk_box_get_spacing_set in GtkBox.
Patch by Tim Janik, Sven Herzberg and myself.

svn path=/trunk/; revision=21508

ChangeLog
gtk/gtkbox.c
gtk/gtkbox.h
gtk/gtkdialog.c

index bc659c2ec5b2961c7b214f83de9cb256bbdf1f65..41fb04a4256d453177162daf4c7311589e01aa62 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-09-24  Christian Dywan  <christian@imendio.com>
+
+       Bug 408244 – add GtkDialog::content-area-spacing
+
+       * gtk/gtkbox.c (gtk_box_init), (gtk_box_set_spacing),
+       (_gtk_box_set_spacing_set), (_gtk_box_get_spacing_set):
+       * gtk/gtkbox.h:
+       * gtk/gtkdialog.c (gtk_dialog_class_init), (update_spacings):
+        Implement "content-area-spacing" style property in GtkDialog
+        and internal helper _gtk_box_get_spacing_set in GtkBox.
+        Patch by Tim Janik, Sven Herzberg and myself.
+
 2008-09-24  Christian Dywan  <christian@imendio.com>
 
        Bug 541391 – Unfocussable Treeview swallows focus
index c3013e9fd18bd46226b606ad43546b7be29ca1f1..594f5d53fedd9696e8aa7efd7c7dc4177c5e889e 100644 (file)
@@ -101,7 +101,7 @@ gtk_box_class_init (GtkBoxClass *class)
                                                      G_MAXINT,
                                                      0,
                                                      GTK_PARAM_READWRITE));
-  
+
   g_object_class_install_property (gobject_class,
                                    PROP_HOMOGENEOUS,
                                    g_param_spec_boolean ("homogeneous",
@@ -155,6 +155,7 @@ gtk_box_init (GtkBox *box)
   
   box->children = NULL;
   box->spacing = 0;
+  box->spacing_set = FALSE;
   box->homogeneous = FALSE;
 }
 
@@ -531,7 +532,10 @@ gtk_box_set_spacing (GtkBox *box,
   if (spacing != box->spacing)
     {
       box->spacing = spacing;
+      box->spacing_set = TRUE;
+
       g_object_notify (G_OBJECT (box), "spacing");
+
       gtk_widget_queue_resize (GTK_WIDGET (box));
     }
 }
@@ -552,6 +556,23 @@ gtk_box_get_spacing (GtkBox *box)
   return box->spacing;
 }
 
+void
+_gtk_box_set_spacing_set (GtkBox  *box,
+                          gboolean spacing_set)
+{
+  g_return_if_fail (GTK_IS_BOX (box));
+
+  box->spacing_set = spacing_set;
+}
+
+gboolean
+_gtk_box_get_spacing_set (GtkBox *box)
+{
+  g_return_val_if_fail (GTK_IS_BOX (box), FALSE);
+
+  return box->spacing_set;
+}
+
 /**
  * gtk_box_reorder_child:
  * @box: a #GtkBox
index 9ab9df2eb6976f90158e284b4f6948b21e77e0fa..71b51e6194d26629e5cae71454311fc28fbd9769 100644 (file)
@@ -59,6 +59,7 @@ struct _GtkBox
   GList *GSEAL (children);
   gint16 GSEAL (spacing);
   guint GSEAL (homogeneous) : 1;
+  guint GSEAL (spacing_set) : 1;
 };
 
 struct _GtkBoxClass
@@ -115,6 +116,9 @@ void           gtk_box_set_child_packing   (GtkBox       *box,
                                        gboolean      fill,
                                        guint         padding,
                                        GtkPackType   pack_type);
+gboolean   _gtk_box_get_spacing_set    (GtkBox*              box);
+void      _gtk_box_set_spacing_set    (GtkBox       *box,
+                                        gboolean      spacing_set);
 
 
 G_END_DECLS
index 2f94f840a071fe17febac6bea7f131e9964c292b..ab7cd625d0b887b68857459ebd03d5c22e45b590 100644 (file)
@@ -194,6 +194,24 @@ gtk_dialog_class_init (GtkDialogClass *class)
                                                              G_MAXINT,
                                                              2,
                                                              GTK_PARAM_READABLE));
+  /**
+   * GtkDialog:content-area-spacing:
+   *
+   * The default spacing used between elements of the
+   * content area of the dialog, as returned by
+   * gtk_dialog_get_content_area(), unless gtk_box_set_spacing()
+   * was called on that widget directly.
+   *
+   * Since: 2.16
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_int ("content-area-spacing",
+                                                             P_("Content area spacing"),
+                                                             P_("Spacing between elements of the main dialog area"),
+                                                             0,
+                                                             G_MAXINT,
+                                                             0,
+                                                             GTK_PARAM_READABLE));
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_int ("button-spacing",
                                                              P_("Button spacing"),
@@ -220,21 +238,25 @@ gtk_dialog_class_init (GtkDialogClass *class)
 static void
 update_spacings (GtkDialog *dialog)
 {
-  GtkWidget *widget;
   gint content_area_border;
+  gint content_area_spacing;
   gint button_spacing;
   gint action_area_border;
-  
-  widget = GTK_WIDGET (dialog);
 
-  gtk_widget_style_get (widget,
+  gtk_widget_style_get (GTK_WIDGET (dialog),
                         "content-area-border", &content_area_border,
+                        "content-area-spacing", &content_area_spacing,
                         "button-spacing", &button_spacing,
                         "action-area-border", &action_area_border,
                         NULL);
 
   gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox),
                                   content_area_border);
+  if (!_gtk_box_get_spacing_set (GTK_BOX (dialog->vbox)))
+    {
+      gtk_box_set_spacing (GTK_BOX (dialog->vbox), content_area_spacing);
+      _gtk_box_set_spacing_set (GTK_BOX (dialog->vbox), FALSE);
+    }
   gtk_box_set_spacing (GTK_BOX (dialog->action_area),
                        button_spacing);
   gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area),