diff --git a/ChangeLog b/ChangeLog index bc659c2ec5..41fb04a425 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-09-24 Christian Dywan + + 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 Bug 541391 – Unfocussable Treeview swallows focus diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index c3013e9fd1..594f5d53fe 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -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 diff --git a/gtk/gtkbox.h b/gtk/gtkbox.h index 9ab9df2eb6..71b51e6194 100644 --- a/gtk/gtkbox.h +++ b/gtk/gtkbox.h @@ -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 diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index 2f94f840a0..ab7cd625d0 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -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),