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