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

Unified Diff: chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc

Issue 10959028: Make disabled browser actions on GTK right-clickable and draggable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
index b8114dcd8cd29647aa8f93ab510c88375979ea62..a76d34125f5ed2222e1a44e2633ec2bedbd42301 100644
--- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/gtk/browser_window_gtk.h"
+#include "chrome/browser/ui/gtk/custom_button.h"
#include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h"
#include "chrome/browser/ui/gtk/gtk_chrome_button.h"
#include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h"
@@ -47,6 +48,7 @@
#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/gtk_util.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia_operations.h"
using extensions::Extension;
@@ -124,7 +126,7 @@ class BrowserActionButton : public content::NotificationObserver,
signals_.Connect(button(), "clicked",
G_CALLBACK(OnClicked), this);
signals_.Connect(button(), "drag-begin",
- G_CALLBACK(&OnDragBegin), this);
+ G_CALLBACK(OnDragBegin), this);
signals_.ConnectAfter(widget(), "expose-event",
G_CALLBACK(OnExposeEvent), this);
if (toolbar_->browser()->window()) {
@@ -218,11 +220,18 @@ class BrowserActionButton : public content::NotificationObserver,
else
gtk_widget_set_tooltip_text(button(), tooltip.c_str());
- gfx::Image image = icon_factory_.GetIcon(tab_id);
- if (!image.IsEmpty())
- SetImage(image.ToGdkPixbuf());
- bool enabled = extension_->browser_action()->GetIsVisible(tab_id);
- gtk_widget_set_sensitive(button(), enabled);
+ enabled_ = extension_->browser_action()->GetIsVisible(tab_id);
+ if (!enabled_)
+ button_->SetPaintOverride(GTK_STATE_INSENSITIVE);
+ else
+ button_->UnsetPaintOverride();
+
+ gfx::ImageSkia image = icon_factory_.GetIcon(tab_id).AsImageSkia();
+ if (!image.isNull()) {
+ if (!enabled_)
+ image = gfx::ImageSkiaOperations::CreateTransparentImage(image, .25);
+ SetImage(gfx::Image(image).ToGdkPixbuf());
+ }
gtk_widget_queue_draw(button());
}
@@ -263,6 +272,8 @@ class BrowserActionButton : public content::NotificationObserver,
// MenuGtk::Delegate implementation.
virtual void StoppedShowing() {
button_->UnsetPaintOverride();
+ if (!enabled_)
Evan Stade 2012/09/21 12:35:12 why not if (enabled_) Unset else SetPaintOver
Yoyo Zhou 2012/09/21 18:20:09 Done.
+ button_->SetPaintOverride(GTK_STATE_INSENSITIVE);
// If the context menu was showing for the overflow menu, re-assert the
// grab that was shadowed.
@@ -295,22 +306,23 @@ class BrowserActionButton : public content::NotificationObserver,
static gboolean OnButtonPress(GtkWidget* widget,
GdkEventButton* event,
- BrowserActionButton* action) {
+ BrowserActionButton* button) {
if (event->button != 3)
return FALSE;
- MenuGtk* menu = action->GetContextMenu();
+ MenuGtk* menu = button->GetContextMenu();
if (!menu)
return FALSE;
- action->button_->SetPaintOverride(GTK_STATE_ACTIVE);
+ button->button_->SetPaintOverride(GTK_STATE_ACTIVE);
menu->PopupForWidget(widget, event->button, event->time);
return TRUE;
}
- static void OnClicked(GtkWidget* widget, BrowserActionButton* action) {
- action->Activate(widget);
+ static void OnClicked(GtkWidget* widget, BrowserActionButton* button) {
+ if (button->enabled_)
+ button->Activate(widget);
}
static gboolean OnExposeEvent(GtkWidget* widget,
@@ -430,6 +442,10 @@ class BrowserActionButton : public content::NotificationObserver,
// The button for this browser action.
scoped_ptr<CustomDrawButton> button_;
+ // Whether the browser action is enabled (equivalent to whether a page action
+ // is visible).
+ bool enabled_;
+
// The top level widget (parent of |button_|).
ui::OwnedWidgetGtk alignment_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698