Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4302)

Unified Diff: chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.cc

Issue 7051021: gtk: Split DownloadShelfContextMenuGtk out to its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asanka review Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.cc
diff --git a/chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.cc b/chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bd19d5f2bc3185cb8244d3e3ab49513b301ed6a3
--- /dev/null
+++ b/chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h"
+
+#include "base/logging.h"
+#include "chrome/browser/download/download_item_model.h"
+#include "chrome/browser/ui/gtk/download/download_item_gtk.h"
+#include "ui/gfx/point.h"
+
+DownloadShelfContextMenuGtk::DownloadShelfContextMenuGtk(
+ BaseDownloadItemModel* model,
+ DownloadItemGtk* download_item)
+ : DownloadShelfContextMenu(model),
+ download_item_gtk_(download_item) {
+}
+
+DownloadShelfContextMenuGtk::~DownloadShelfContextMenuGtk() {}
+
+void DownloadShelfContextMenuGtk::Popup(GtkWidget* widget,
+ GdkEventButton* event) {
+ if (download_item()->IsComplete())
+ menu_.reset(new MenuGtk(this, GetFinishedMenuModel()));
+ else
+ menu_.reset(new MenuGtk(this, GetInProgressMenuModel()));
+
+ if (widget)
+ menu_->PopupForWidget(widget, event->button, event->time);
+ else
+ menu_->PopupAsContext(gfx::Point(event->x_root, event->y_root),
+ event->time);
+}
+
+void DownloadShelfContextMenuGtk::StoppedShowing() {
+ download_item_gtk_->menu_showing_ = false;
+ gtk_widget_queue_draw(download_item_gtk_->menu_button_);
+}
+
+GtkWidget* DownloadShelfContextMenuGtk::GetImageForCommandId(
+ int command_id) const {
+ const char* stock = NULL;
+ switch (command_id) {
+ case SHOW_IN_FOLDER:
+ case OPEN_WHEN_COMPLETE:
+ stock = GTK_STOCK_OPEN;
+ break;
+
+ case CANCEL:
+ stock = GTK_STOCK_CANCEL;
+ break;
+
+ case ALWAYS_OPEN_TYPE:
+ case TOGGLE_PAUSE:
+ stock = NULL;
+ break;
+
+ default:
+ NOTREACHED();
+ break;
+ }
+ return stock ? gtk_image_new_from_stock(stock, GTK_ICON_SIZE_MENU) : NULL;
+}
« no previous file with comments | « chrome/browser/ui/gtk/download/download_shelf_context_menu_gtk.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698