OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "chrome/browser/download/download_item_model.h" |
| 9 #include "chrome/browser/ui/gtk/download/download_item_gtk.h" |
| 10 #include "ui/gfx/point.h" |
| 11 |
| 12 DownloadShelfContextMenuGtk::DownloadShelfContextMenuGtk( |
| 13 BaseDownloadItemModel* model, |
| 14 DownloadItemGtk* download_item) |
| 15 : DownloadShelfContextMenu(model), |
| 16 download_item_gtk_(download_item) { |
| 17 } |
| 18 |
| 19 DownloadShelfContextMenuGtk::~DownloadShelfContextMenuGtk() {} |
| 20 |
| 21 void DownloadShelfContextMenuGtk::Popup(GtkWidget* widget, |
| 22 GdkEventButton* event) { |
| 23 if (download_item()->IsComplete()) |
| 24 menu_.reset(new MenuGtk(this, GetFinishedMenuModel())); |
| 25 else |
| 26 menu_.reset(new MenuGtk(this, GetInProgressMenuModel())); |
| 27 |
| 28 if (widget) |
| 29 menu_->PopupForWidget(widget, event->button, event->time); |
| 30 else |
| 31 menu_->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 32 event->time); |
| 33 } |
| 34 |
| 35 void DownloadShelfContextMenuGtk::StoppedShowing() { |
| 36 download_item_gtk_->menu_showing_ = false; |
| 37 gtk_widget_queue_draw(download_item_gtk_->menu_button_); |
| 38 } |
| 39 |
| 40 GtkWidget* DownloadShelfContextMenuGtk::GetImageForCommandId( |
| 41 int command_id) const { |
| 42 const char* stock = NULL; |
| 43 switch (command_id) { |
| 44 case SHOW_IN_FOLDER: |
| 45 case OPEN_WHEN_COMPLETE: |
| 46 stock = GTK_STOCK_OPEN; |
| 47 break; |
| 48 |
| 49 case CANCEL: |
| 50 stock = GTK_STOCK_CANCEL; |
| 51 break; |
| 52 |
| 53 case ALWAYS_OPEN_TYPE: |
| 54 case TOGGLE_PAUSE: |
| 55 stock = NULL; |
| 56 break; |
| 57 |
| 58 default: |
| 59 NOTREACHED(); |
| 60 break; |
| 61 } |
| 62 return stock ? gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU) : NULL; |
| 63 } |
OLD | NEW |