| 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_context_menu_gtk.h" | 5 #include "chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/download/download_item_model.h" | 8 #include "chrome/browser/download/download_item_model.h" |
| 9 #include "chrome/browser/ui/gtk/download/download_item_gtk.h" | 9 #include "chrome/browser/ui/gtk/download/download_item_gtk.h" |
| 10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
| 11 | 11 |
| 12 DownloadShelfContextMenuGtk::DownloadShelfContextMenuGtk( | 12 DownloadShelfContextMenuGtk::DownloadShelfContextMenuGtk( |
| 13 BaseDownloadItemModel* model, | 13 BaseDownloadItemModel* model, |
| 14 DownloadItemGtk* download_item) | 14 DownloadItemGtk* download_item) |
| 15 : DownloadShelfContextMenu(model), | 15 : DownloadShelfContextMenu(model), |
| 16 download_item_gtk_(download_item) { | 16 download_item_gtk_(download_item) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 DownloadShelfContextMenuGtk::~DownloadShelfContextMenuGtk() {} | 19 DownloadShelfContextMenuGtk::~DownloadShelfContextMenuGtk() {} |
| 20 | 20 |
| 21 void DownloadShelfContextMenuGtk::Popup(GtkWidget* widget, | 21 void DownloadShelfContextMenuGtk::Popup(GtkWidget* widget, |
| 22 GdkEventButton* event) { | 22 GdkEventButton* event) { |
| 23 if (download_item()->IsComplete()) | 23 menu_.reset(new MenuGtk(this, GetMenuModel())); |
| 24 menu_.reset(new MenuGtk(this, GetFinishedMenuModel())); | |
| 25 else | |
| 26 menu_.reset(new MenuGtk(this, GetInProgressMenuModel())); | |
| 27 | 24 |
| 28 if (widget) | 25 if (widget) |
| 29 menu_->PopupForWidget(widget, event->button, event->time); | 26 menu_->PopupForWidget(widget, event->button, event->time); |
| 30 else | 27 else |
| 31 menu_->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 28 menu_->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 32 event->time); | 29 event->time); |
| 33 } | 30 } |
| 34 | 31 |
| 35 void DownloadShelfContextMenuGtk::StoppedShowing() { | 32 void DownloadShelfContextMenuGtk::StoppedShowing() { |
| 36 download_item_gtk_->menu_showing_ = false; | 33 download_item_gtk_->menu_showing_ = false; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 case TOGGLE_PAUSE: | 51 case TOGGLE_PAUSE: |
| 55 stock = NULL; | 52 stock = NULL; |
| 56 break; | 53 break; |
| 57 | 54 |
| 58 default: | 55 default: |
| 59 NOTREACHED(); | 56 NOTREACHED(); |
| 60 break; | 57 break; |
| 61 } | 58 } |
| 62 return stock ? gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU) : NULL; | 59 return stock ? gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU) : NULL; |
| 63 } | 60 } |
| OLD | NEW |