OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_actions_toolbar_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 SkBitmap image = extension_->browser_action()->GetIcon(tab_id); | 230 SkBitmap image = extension_->browser_action()->GetIcon(tab_id); |
231 if (!image.isNull()) { | 231 if (!image.isNull()) { |
232 GdkPixbuf* previous_gdk_icon = tab_specific_icon_; | 232 GdkPixbuf* previous_gdk_icon = tab_specific_icon_; |
233 tab_specific_icon_ = gfx::GdkPixbufFromSkBitmap(image); | 233 tab_specific_icon_ = gfx::GdkPixbufFromSkBitmap(image); |
234 SetImage(tab_specific_icon_); | 234 SetImage(tab_specific_icon_); |
235 if (previous_gdk_icon) | 235 if (previous_gdk_icon) |
236 g_object_unref(previous_gdk_icon); | 236 g_object_unref(previous_gdk_icon); |
237 } else if (default_icon_) { | 237 } else if (default_icon_) { |
238 SetImage(default_icon_); | 238 SetImage(default_icon_); |
239 } | 239 } |
| 240 UpdateEnabledness(tab_id); |
| 241 |
240 gtk_widget_queue_draw(button()); | 242 gtk_widget_queue_draw(button()); |
241 } | 243 } |
242 | 244 |
243 SkBitmap GetIcon() { | 245 SkBitmap GetIcon() { |
244 const SkBitmap& image = extension_->browser_action()->GetIcon( | 246 const SkBitmap& image = extension_->browser_action()->GetIcon( |
245 toolbar_->GetCurrentTabId()); | 247 toolbar_->GetCurrentTabId()); |
246 if (!image.isNull()) { | 248 if (!image.isNull()) { |
247 return image; | 249 return image; |
248 } else { | 250 } else { |
249 return default_skbitmap_; | 251 return default_skbitmap_; |
(...skipping 22 matching lines...) Expand all Loading... |
272 switch (model->ExecuteBrowserAction(extension, browser, &popup_url)) { | 274 switch (model->ExecuteBrowserAction(extension, browser, &popup_url)) { |
273 case ExtensionToolbarModel::ACTION_NONE: | 275 case ExtensionToolbarModel::ACTION_NONE: |
274 break; | 276 break; |
275 case ExtensionToolbarModel::ACTION_SHOW_POPUP: | 277 case ExtensionToolbarModel::ACTION_SHOW_POPUP: |
276 ExtensionPopupGtk::Show(popup_url, browser, widget, | 278 ExtensionPopupGtk::Show(popup_url, browser, widget, |
277 ExtensionPopupGtk::SHOW); | 279 ExtensionPopupGtk::SHOW); |
278 break; | 280 break; |
279 } | 281 } |
280 } | 282 } |
281 | 283 |
| 284 void UpdateEnabledness(int tab_id) { |
| 285 bool visible = extension_->browser_action()->GetIsVisible(tab_id); |
| 286 gtk_widget_set_sensitive(button(), visible ? TRUE : FALSE); |
| 287 } |
| 288 |
282 // MenuGtk::Delegate implementation. | 289 // MenuGtk::Delegate implementation. |
283 virtual void StoppedShowing() { | 290 virtual void StoppedShowing() { |
284 button_->UnsetPaintOverride(); | 291 button_->UnsetPaintOverride(); |
285 | 292 |
286 // If the context menu was showing for the overflow menu, re-assert the | 293 // If the context menu was showing for the overflow menu, re-assert the |
287 // grab that was shadowed. | 294 // grab that was shadowed. |
288 if (toolbar_->overflow_menu_.get()) | 295 if (toolbar_->overflow_menu_.get()) |
289 gtk_util::GrabAllInput(toolbar_->overflow_menu_->widget()); | 296 gtk_util::GrabAllInput(toolbar_->overflow_menu_->widget()); |
290 } | 297 } |
291 | 298 |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 | 1090 |
1084 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 1091 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
1085 event->time); | 1092 event->time); |
1086 return TRUE; | 1093 return TRUE; |
1087 } | 1094 } |
1088 | 1095 |
1089 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 1096 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
1090 if (!resize_animation_.is_animating()) | 1097 if (!resize_animation_.is_animating()) |
1091 UpdateChevronVisibility(); | 1098 UpdateChevronVisibility(); |
1092 } | 1099 } |
OLD | NEW |