Commit 2909dcfb authored by erg@chromium.org's avatar erg@chromium.org

GTK: More changes from raw widget->allocation to using the accessor.

BUG=79722
TEST=none


Review URL: http://codereview.chromium.org/8872004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113532 0039d316-1c4b-4281-b951-d872f2087c98
parent 8581ac38
......@@ -67,7 +67,9 @@ void AvatarMenuButtonGtk::UpdateButtonIcon() {
if (!icon_.get())
return;
old_height_ = widget()->allocation.height;
GtkAllocation allocation;
gtk_widget_get_allocation(widget(), &allocation);
old_height_ = allocation.height;
gfx::Image icon = profiles::GetAvatarIconForTitleBar(*icon_, is_gaia_picture_,
profiles::kAvatarIconWidth, old_height_);
gtk_image_set_from_pixbuf(GTK_IMAGE(image_), icon.ToGdkPixbuf());
......
......@@ -583,7 +583,11 @@ void BrowserActionsToolbarGtk::HidePopup() {
void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) {
desired_width_ = WidthForIconCount(count);
start_width_ = button_hbox_->allocation.width;
GtkAllocation allocation;
gtk_widget_get_allocation(button_hbox_.get(), &allocation);
start_width_ = allocation.width;
resize_animation_.Reset();
resize_animation_.Show();
}
......@@ -762,8 +766,12 @@ gboolean BrowserActionsToolbarGtk::OnDragMotion(GtkWidget* widget,
if (!drag_button_)
return FALSE;
if (base::i18n::IsRTL())
x = widget->allocation.width - x;
if (base::i18n::IsRTL()) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
x = allocation.width - x;
}
drop_index_ = x < kButtonWidth ? 0 : x / (kButtonWidth + kButtonPadding);
// We will go ahead and reorder the child in order to provide visual feedback
......@@ -829,10 +837,18 @@ gboolean BrowserActionsToolbarGtk::OnGripperMotionNotify(
// Calculate how much the user dragged the gripper and subtract that off the
// button container's width.
int distance_dragged = base::i18n::IsRTL() ?
-event->x :
event->x - widget->allocation.width;
gint new_width = button_hbox_->allocation.width - distance_dragged;
int distance_dragged;
if (base::i18n::IsRTL()) {
distance_dragged = -event->x;
} else {
GtkAllocation widget_allocation;
gtk_widget_get_allocation(widget, &widget_allocation);
distance_dragged = event->x - widget_allocation.width;
}
GtkAllocation button_hbox_allocation;
gtk_widget_get_allocation(button_hbox_.get(), &button_hbox_allocation);
gint new_width = button_hbox_allocation.width - distance_dragged;
SetButtonHBoxWidth(new_width);
return FALSE;
......@@ -864,8 +880,10 @@ gboolean BrowserActionsToolbarGtk::OnGripperLeaveNotify(
gboolean BrowserActionsToolbarGtk::OnGripperButtonRelease(
GtkWidget* gripper, GdkEventButton* event) {
gfx::Rect gripper_rect(0, 0,
gripper->allocation.width, gripper->allocation.height);
GtkAllocation allocation;
gtk_widget_get_allocation(gripper, &allocation);
gfx::Rect gripper_rect(0, 0, allocation.width, allocation.height);
gfx::Point release_point(event->x, event->y);
if (!gripper_rect.Contains(release_point))
gdk_window_set_cursor(gtk_widget_get_window(gripper), NULL);
......
......@@ -277,10 +277,12 @@ bool BubbleGtk::UpdateArrowLocation(bool force_move_and_reshape) {
rect_.x(), rect_.y(), &offset_x, &offset_y);
ArrowLocationGtk old_location = current_arrow_location_;
GtkAllocation allocation;
gtk_widget_get_allocation(window_, &allocation);
current_arrow_location_ = GetArrowLocation(
preferred_arrow_location_,
toplevel_x + offset_x + (rect_.width() / 2), // arrow_x
window_->allocation.width);
allocation.width);
if (force_move_and_reshape || current_arrow_location_ != old_location) {
UpdateWindowShape();
......@@ -297,9 +299,10 @@ void BubbleGtk::UpdateWindowShape() {
gdk_region_destroy(mask_region_);
mask_region_ = NULL;
}
GtkAllocation allocation;
gtk_widget_get_allocation(window_, &allocation);
std::vector<GdkPoint> points = MakeFramePolygonPoints(
current_arrow_location_,
window_->allocation.width, window_->allocation.height,
current_arrow_location_, allocation.width, allocation.height,
FRAME_MASK);
mask_region_ = gdk_region_polygon(&points[0],
points.size(),
......@@ -324,8 +327,10 @@ void BubbleGtk::MoveWindow() {
if (current_arrow_location_ == ARROW_LOCATION_TOP_LEFT) {
screen_x = toplevel_x + offset_x + (rect_.width() / 2) - kArrowX;
} else if (current_arrow_location_ == ARROW_LOCATION_TOP_RIGHT) {
GtkAllocation allocation;
gtk_widget_get_allocation(window_, &allocation);
screen_x = toplevel_x + offset_x + (rect_.width() / 2) -
window_->allocation.width + kArrowX;
allocation.width + kArrowX;
} else {
NOTREACHED();
}
......@@ -456,9 +461,10 @@ gboolean BubbleGtk::OnExpose(GtkWidget* widget, GdkEventExpose* expose) {
gdk_gc_set_rgb_fg_color(gc, &kFrameColor);
// Stroke the frame border.
GtkAllocation allocation;
gtk_widget_get_allocation(window_, &allocation);
std::vector<GdkPoint> points = MakeFramePolygonPoints(
current_arrow_location_,
window_->allocation.width, window_->allocation.height,
current_arrow_location_, allocation.width, allocation.height,
FRAME_STROKE);
gdk_draw_polygon(drawable, gc, FALSE, &points[0], points.size());
......
......@@ -422,8 +422,11 @@ gfx::Rect FindBarGtk::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
// The height is not used.
// At very low browser widths we can wind up with a negative |dialog_bounds|
// width, so clamp it to 0.
GtkAllocation parent_allocation;
gtk_widget_get_allocation(gtk_widget_get_parent(widget()),
&parent_allocation);
gfx::Rect dialog_bounds = gfx::Rect(ltr ? 0 : 15, 0,
std::max(0, widget()->parent->allocation.width - (ltr ? 15 : 0)), 0);
std::max(0, parent_allocation.width - (ltr ? 15 : 0)), 0);
GtkRequisition req;
gtk_widget_size_request(container_, &req);
......@@ -575,7 +578,9 @@ string16 FindBarGtk::GetMatchCountText() {
}
int FindBarGtk::GetWidth() {
return container_->allocation.width;
GtkAllocation allocation;
gtk_widget_get_allocation(container_, &allocation);
return allocation.width;
}
void FindBarGtk::FindEntryTextInContents(bool forward_search) {
......
......@@ -121,8 +121,10 @@ void NineBox::RenderToWidget(GtkWidget* dst) const {
}
void NineBox::RenderToWidgetWithOpacity(GtkWidget* dst, double opacity) const {
int dst_width = dst->allocation.width;
int dst_height = dst->allocation.height;
GtkAllocation allocation;
gtk_widget_get_allocation(dst, &allocation);
int dst_width = allocation.width;
int dst_height = allocation.height;
// The upper-left and lower-right corners of the center square in the
// rendering of the ninebox.
......@@ -142,7 +144,7 @@ void NineBox::RenderToWidgetWithOpacity(GtkWidget* dst, double opacity) const {
// to their container.
if (GTK_WIDGET_NO_WINDOW(dst)) {
// Transform our cairo from window to widget coordinates.
cairo_translate(cr, dst->allocation.x, dst->allocation.y);
cairo_translate(cr, allocation.x, allocation.y);
}
if (base::i18n::IsRTL()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment