OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" | 5 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 257 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
258 close_button_->SetBackground( | 258 close_button_->SetBackground( |
259 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), | 259 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), |
260 rb.GetBitmapNamed(IDR_CLOSE_BAR), | 260 rb.GetBitmapNamed(IDR_CLOSE_BAR), |
261 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); | 261 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 int DownloadShelfGtk::GetHeight() const { | 265 int DownloadShelfGtk::GetHeight() const { |
266 return slide_widget_->widget()->allocation.height; | 266 GtkAllocation allocation; |
| 267 gtk_widget_get_allocation(slide_widget_->widget(), &allocation); |
| 268 return allocation.height; |
267 } | 269 } |
268 | 270 |
269 void DownloadShelfGtk::RemoveDownloadItem(DownloadItemGtk* download_item) { | 271 void DownloadShelfGtk::RemoveDownloadItem(DownloadItemGtk* download_item) { |
270 DCHECK(download_item); | 272 DCHECK(download_item); |
271 std::vector<DownloadItemGtk*>::iterator i = | 273 std::vector<DownloadItemGtk*>::iterator i = |
272 find(download_items_.begin(), download_items_.end(), download_item); | 274 find(download_items_.begin(), download_items_.end(), download_item); |
273 DCHECK(i != download_items_.end()); | 275 DCHECK(i != download_items_.end()); |
274 download_items_.erase(i); | 276 download_items_.erase(i); |
275 delete download_item; | 277 delete download_item; |
276 if (download_items_.empty()) { | 278 if (download_items_.empty()) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 mouse_in_shelf_ = mouse_in_shelf; | 358 mouse_in_shelf_ = mouse_in_shelf; |
357 | 359 |
358 if (mouse_in_shelf) | 360 if (mouse_in_shelf) |
359 MouseEnteredShelf(); | 361 MouseEnteredShelf(); |
360 else | 362 else |
361 MouseLeftShelf(); | 363 MouseLeftShelf(); |
362 } | 364 } |
363 | 365 |
364 bool DownloadShelfGtk::IsCursorInShelfZone( | 366 bool DownloadShelfGtk::IsCursorInShelfZone( |
365 const gfx::Point& cursor_screen_coords) { | 367 const gfx::Point& cursor_screen_coords) { |
| 368 GtkAllocation allocation; |
| 369 gtk_widget_get_allocation(shelf_.get(), &allocation); |
| 370 |
366 gfx::Rect bounds(gtk_util::GetWidgetScreenPosition(shelf_.get()), | 371 gfx::Rect bounds(gtk_util::GetWidgetScreenPosition(shelf_.get()), |
367 gfx::Size(shelf_.get()->allocation.width, | 372 gfx::Size(allocation.width, allocation.height)); |
368 shelf_.get()->allocation.height)); | |
369 | 373 |
370 // Negative insets expand the rectangle. We only expand the top. | 374 // Negative insets expand the rectangle. We only expand the top. |
371 bounds.Inset(gfx::Insets(-kShelfAuraSize, 0, 0, 0)); | 375 bounds.Inset(gfx::Insets(-kShelfAuraSize, 0, 0, 0)); |
372 | 376 |
373 return bounds.Contains(cursor_screen_coords); | 377 return bounds.Contains(cursor_screen_coords); |
374 } | 378 } |
375 | 379 |
376 void DownloadShelfGtk::MouseLeftShelf() { | 380 void DownloadShelfGtk::MouseLeftShelf() { |
377 DCHECK(close_on_mouse_out_); | 381 DCHECK(close_on_mouse_out_); |
378 | 382 |
379 MessageLoop::current()->PostDelayedTask( | 383 MessageLoop::current()->PostDelayedTask( |
380 FROM_HERE, | 384 FROM_HERE, |
381 base::Bind(&DownloadShelfGtk::Close, weak_factory_.GetWeakPtr()), | 385 base::Bind(&DownloadShelfGtk::Close, weak_factory_.GetWeakPtr()), |
382 kAutoCloseDelayMs); | 386 kAutoCloseDelayMs); |
383 } | 387 } |
384 | 388 |
385 void DownloadShelfGtk::MouseEnteredShelf() { | 389 void DownloadShelfGtk::MouseEnteredShelf() { |
386 weak_factory_.InvalidateWeakPtrs(); | 390 weak_factory_.InvalidateWeakPtrs(); |
387 } | 391 } |
OLD | NEW |