libgimp/gimpgradientselectbutton.c libgimp/gimpmenu.c

2008-06-28  Michael Natterer  <mitch@gimp.org>

	* libgimp/gimpgradientselectbutton.c
	* libgimp/gimpmenu.c
	* libgimpwidgets/gimpbrowser.c
	* libgimpwidgets/gimpcellrenderercolor.c
	* libgimpwidgets/gimpcellrenderertoggle.c
	* libgimpwidgets/gimpchainbutton.c
	* libgimpwidgets/gimpcolorarea.c
	* libgimpwidgets/gimpcolorscale.c
	* libgimpwidgets/gimpcolorscales.c
	* libgimpwidgets/gimpcolorselect.c
	* libgimpwidgets/gimpenumwidgets.c
	* libgimpwidgets/gimpframe.c
	* libgimpwidgets/gimphelpui.c
	* libgimpwidgets/gimpoffsetarea.c
	* libgimpwidgets/gimppreviewarea.c
	* libgimpwidgets/gimppropwidgets.c
	* libgimpwidgets/gimpscrolledpreview.c: use accessors instead of
	accessing members of GTK+ widgets directly.


svn path=/trunk/; revision=26005
This commit is contained in:
Michael Natterer 2008-06-28 15:09:46 +00:00 committed by Michael Natterer
parent 29754a4cff
commit 58cfcd4f57
18 changed files with 162 additions and 109 deletions

View file

@ -98,13 +98,15 @@ static void
gimp_frame_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkFrame *frame = GTK_FRAME (widget);
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
GtkFrame *frame = GTK_FRAME (widget);
GtkWidget *label_widget = gtk_frame_get_label_widget (frame);
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
GtkRequisition child_requisition;
gint border_width;
if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
if (label_widget && GTK_WIDGET_VISIBLE (label_widget))
{
gtk_widget_size_request (frame->label_widget, requisition);
gtk_widget_size_request (label_widget, requisition);
}
else
{
@ -125,16 +127,19 @@ gimp_frame_size_request (GtkWidget *widget,
requisition->height += child_requisition.height;
}
requisition->width += 2 * GTK_CONTAINER (widget)->border_width;
requisition->height += 2 * GTK_CONTAINER (widget)->border_width;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
requisition->width += 2 * border_width;
requisition->height += 2 * border_width;
}
static void
gimp_frame_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkFrame *frame = GTK_FRAME (widget);
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
GtkFrame *frame = GTK_FRAME (widget);
GtkWidget *label_widget = gtk_frame_get_label_widget (frame);
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
widget->allocation = *allocation;
@ -143,22 +148,23 @@ gimp_frame_size_allocate (GtkWidget *widget,
if (child && GTK_WIDGET_VISIBLE (child))
gtk_widget_size_allocate (child, &frame->child_allocation);
if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
if (label_widget && GTK_WIDGET_VISIBLE (label_widget))
{
GtkAllocation label_allocation;
GtkRequisition label_requisition;
gint border = GTK_CONTAINER (widget)->border_width;
gint border_width;
gtk_widget_get_child_requisition (frame->label_widget,
&label_requisition);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
label_allocation.x = allocation->x + border;
label_allocation.y = allocation->y + border;
gtk_widget_get_child_requisition (label_widget, &label_requisition);
label_allocation.x = allocation->x + border_width;
label_allocation.y = allocation->y + border_width;
label_allocation.width = MAX (label_requisition.width,
allocation->width - 2 * border);
allocation->width - 2 * border_width);
label_allocation.height = label_requisition.height;
gtk_widget_size_allocate (frame->label_widget, &label_allocation);
gtk_widget_size_allocate (label_widget, &label_allocation);
}
}
@ -166,34 +172,36 @@ static void
gimp_frame_child_allocate (GtkFrame *frame,
GtkAllocation *child_allocation)
{
GtkWidget *widget = GTK_WIDGET (frame);
GtkAllocation *allocation = &widget->allocation;
gint border = GTK_CONTAINER (frame)->border_width;
gint spacing = 0;
gint indent = gimp_frame_get_indent (widget);
GtkWidget *widget = GTK_WIDGET (frame);
GtkWidget *label_widget = gtk_frame_get_label_widget (frame);
GtkAllocation *allocation = &widget->allocation;
gint border_width;
gint spacing = 0;
gint indent = gimp_frame_get_indent (widget);
if (frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget))
border_width = gtk_container_get_border_width (GTK_CONTAINER (frame));
if (label_widget && GTK_WIDGET_VISIBLE (label_widget))
{
GtkRequisition child_requisition;
gtk_widget_get_child_requisition (frame->label_widget,
&child_requisition);
gtk_widget_get_child_requisition (label_widget, &child_requisition);
spacing += child_requisition.height;
}
spacing += gimp_frame_get_label_spacing (frame);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
child_allocation->x = border + indent;
child_allocation->x = border_width + indent;
else
child_allocation->x = border;
child_allocation->x = border_width;
child_allocation->y = border + spacing;
child_allocation->y = border_width + spacing;
child_allocation->width = MAX (1,
allocation->width - 2 * border - indent);
allocation->width - 2 * border_width - indent);
child_allocation->height = MAX (1,
allocation->height -
child_allocation->y - border);
child_allocation->y - border_width);
child_allocation->x += allocation->x;
child_allocation->y += allocation->y;
@ -227,20 +235,24 @@ gimp_frame_expose_event (GtkWidget *widget,
static void
gimp_frame_label_widget_notify (GtkFrame *frame)
{
if (frame->label_widget)
GtkWidget *label_widget = gtk_frame_get_label_widget (frame);
if (label_widget)
{
GtkLabel *label = NULL;
if (GTK_IS_LABEL (frame->label_widget))
if (GTK_IS_LABEL (label_widget))
{
label = GTK_LABEL (frame->label_widget);
gfloat xalign, yalign;
gtk_misc_set_alignment (GTK_MISC (label),
frame->label_xalign, frame->label_yalign);
label = GTK_LABEL (label_widget);
gtk_frame_get_label_align (frame, &xalign, &yalign);
gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign);
}
else if (GTK_IS_BIN (frame->label_widget))
else if (GTK_IS_BIN (label_widget))
{
GtkWidget *child = gtk_bin_get_child (GTK_BIN (frame->label_widget));
GtkWidget *child = gtk_bin_get_child (GTK_BIN (label_widget));
if (GTK_IS_LABEL (child))
label = GTK_LABEL (child);
@ -293,9 +305,10 @@ gimp_frame_get_indent (GtkWidget *widget)
static gint
gimp_frame_get_label_spacing (GtkFrame *frame)
{
gint spacing = 0;
GtkWidget *label_widget = gtk_frame_get_label_widget (frame);
gint spacing = 0;
if ((frame->label_widget && GTK_WIDGET_VISIBLE (frame->label_widget)) ||
if ((label_widget && GTK_WIDGET_VISIBLE (label_widget)) ||
(g_object_get_data (G_OBJECT (frame), GIMP_FRAME_IN_EXPANDER_KEY)))
{
gtk_widget_style_get (GTK_WIDGET (frame),