142 PangoLayout *layout_one, *layout_two;
143 GdkRectangle layout_one_rect, layout_two_rect, layout_union;
145 if (layout_1 == NULL)
151 layout_one = g_object_ref (layout_1);
153 if (layout_2 != NULL)
154 layout_two = g_object_ref (layout_2);
159 gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
160 pango_layout_get_pixel_extents (layout_one, NULL, (PangoRectangle *) &layout_one_rect);
162 if (layout_two != NULL)
164 pango_layout_get_pixel_extents (layout_two, NULL, (PangoRectangle *) &layout_two_rect);
166 layout_union.width = MAX (layout_one_rect.width, layout_two_rect.width);
167 layout_union.height = layout_one_rect.height + layout_two_rect.height;
171 layout_union = layout_one_rect;
176 gfloat xalign, yalign;
178 gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
180 layout_union.width = MIN (layout_union.width, cell_area->width - 2 * xpad);
181 layout_union.height = MIN (layout_union.height, cell_area->height - 2 * ypad);
185 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
186 *x_offset_1 = (1.0 - xalign) * (cell_area->width - (layout_one_rect.width + (2 * xpad)));
188 *x_offset_1 = xalign * (cell_area->width - (layout_one_rect.width + (2 * xpad)));
190 *x_offset_1 = MAX (*x_offset_1, 0);
194 if (layout_two != NULL)
196 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
197 *x_offset_2 = (1.0 - xalign) * (cell_area->width - (layout_two_rect.width + (2 * xpad)));
199 *x_offset_2 = xalign * (cell_area->width - (layout_two_rect.width + (2 * xpad)));
201 *x_offset_2 = MAX (*x_offset_2, 0);
211 *y_offset = yalign * (cell_area->height - (layout_union.height + (2 * ypad)));
212 *y_offset = MAX (*y_offset, 0);
217 if (x_offset_1) *x_offset_1 = 0;
218 if (x_offset_2) *x_offset_2 = 0;
219 if (y_offset) *y_offset = 0;
222 g_clear_object (&layout_one);
223 g_clear_object (&layout_two);
226 *height = ypad * 2 + layout_union.height;
229 *width = xpad * 2 + layout_union.width;