summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-31 00:13:20 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-31 00:13:20 +0000
commit484e9ec2f6fb61d21f947af08b3f1bbc11a84124 (patch)
treecc9835a447efd9ed03a7d8453307c3f428e21588 /chrome/browser/gtk/browser_actions_toolbar_gtk.cc
parentdf63267a7b7a555619329b7834af3c8a3ad557de (diff)
downloadchromium_src-484e9ec2f6fb61d21f947af08b3f1bbc11a84124.zip
chromium_src-484e9ec2f6fb61d21f947af08b3f1bbc11a84124.tar.gz
chromium_src-484e9ec2f6fb61d21f947af08b3f1bbc11a84124.tar.bz2
Implement browser action context menu on linux.
BUG=30656 TEST=manual (right click on browser actions and test the actions) Review URL: http://codereview.chromium.org/521016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/browser_actions_toolbar_gtk.cc')
-rw-r--r--chrome/browser/gtk/browser_actions_toolbar_gtk.cc33
1 files changed, 30 insertions, 3 deletions
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
index 91782f2..cc43f3e 100644
--- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
@@ -9,12 +9,14 @@
#include "app/gfx/canvas_paint.h"
#include "app/gfx/gtk_util.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/extensions/extension_action_context_menu_model.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/browser/gtk/extension_popup_gtk.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
+#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/extensions/extension.h"
@@ -49,7 +51,8 @@ GtkTargetEntry GetDragTargetEntry() {
} // namespace
class BrowserActionButton : public NotificationObserver,
- public ImageLoadingTracker::Observer {
+ public ImageLoadingTracker::Observer,
+ public MenuGtk::Delegate {
public:
BrowserActionButton(BrowserActionsToolbarGtk* toolbar,
Extension* extension)
@@ -75,8 +78,10 @@ class BrowserActionButton : public NotificationObserver,
Extension::kBrowserActionIconMaxSize));
}
+ g_signal_connect(button_.get(), "button-press-event",
+ G_CALLBACK(OnButtonPress), this);
g_signal_connect(button_.get(), "clicked",
- G_CALLBACK(OnButtonClicked), this);
+ G_CALLBACK(OnClicked), this);
g_signal_connect_after(button_.get(), "expose-event",
G_CALLBACK(OnExposeEvent), this);
g_signal_connect(button_.get(), "drag-begin",
@@ -165,7 +170,25 @@ class BrowserActionButton : public NotificationObserver,
toolbar_->browser()->profile())->UseGtkTheme());
}
- static void OnButtonClicked(GtkWidget* widget, BrowserActionButton* action) {
+ static gboolean OnButtonPress(GtkWidget* widget,
+ GdkEvent* event,
+ BrowserActionButton* action) {
+ if (event->button.button != 3)
+ return FALSE;
+
+ if (!action->context_menu_model_.get()) {
+ action->context_menu_model_.reset(
+ new ExtensionActionContextMenuModel(action->extension_));
+ }
+
+ action->context_menu_.reset(
+ new MenuGtk(action, action->context_menu_model_.get()));
+
+ action->context_menu_->Popup(widget, event);
+ return TRUE;
+ }
+
+ static void OnClicked(GtkWidget* widget, BrowserActionButton* action) {
if (action->extension_->browser_action()->has_popup()) {
ExtensionPopupGtk::Show(
action->extension_->browser_action()->popup_url(),
@@ -224,6 +247,10 @@ class BrowserActionButton : public NotificationObserver,
NotificationRegistrar registrar_;
+ // The context menu view and model for this extension action.
+ scoped_ptr<MenuGtk> context_menu_;
+ scoped_ptr<ExtensionActionContextMenuModel> context_menu_model_;
+
friend class BrowserActionsToolbarGtk;
};