| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 signals_.Connect(button(), "button-press-event", | 123 signals_.Connect(button(), "button-press-event", |
| 124 G_CALLBACK(OnButtonPress), this); | 124 G_CALLBACK(OnButtonPress), this); |
| 125 signals_.Connect(button(), "clicked", | 125 signals_.Connect(button(), "clicked", |
| 126 G_CALLBACK(OnClicked), this); | 126 G_CALLBACK(OnClicked), this); |
| 127 signals_.Connect(button(), "drag-begin", | 127 signals_.Connect(button(), "drag-begin", |
| 128 G_CALLBACK(&OnDragBegin), this); | 128 G_CALLBACK(&OnDragBegin), this); |
| 129 signals_.ConnectAfter(widget(), "expose-event", | 129 signals_.ConnectAfter(widget(), "expose-event", |
| 130 G_CALLBACK(OnExposeEvent), this); | 130 G_CALLBACK(OnExposeEvent), this); |
| 131 | 131 |
| 132 registrar_.Add(this, NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, | 132 registrar_.Add(this, chrome::EXTENSION_BROWSER_ACTION_UPDATED, |
| 133 Source<ExtensionAction>(extension->browser_action())); | 133 Source<ExtensionAction>(extension->browser_action())); |
| 134 } | 134 } |
| 135 | 135 |
| 136 ~BrowserActionButton() { | 136 ~BrowserActionButton() { |
| 137 if (tab_specific_icon_) | 137 if (tab_specific_icon_) |
| 138 g_object_unref(tab_specific_icon_); | 138 g_object_unref(tab_specific_icon_); |
| 139 | 139 |
| 140 if (default_icon_) | 140 if (default_icon_) |
| 141 g_object_unref(default_icon_); | 141 g_object_unref(default_icon_); |
| 142 | 142 |
| 143 alignment_.Destroy(); | 143 alignment_.Destroy(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 GtkWidget* button() { return button_->widget(); } | 146 GtkWidget* button() { return button_->widget(); } |
| 147 | 147 |
| 148 GtkWidget* widget() { return alignment_.get(); } | 148 GtkWidget* widget() { return alignment_.get(); } |
| 149 | 149 |
| 150 const Extension* extension() { return extension_; } | 150 const Extension* extension() { return extension_; } |
| 151 | 151 |
| 152 // NotificationObserver implementation. | 152 // NotificationObserver implementation. |
| 153 void Observe(NotificationType type, | 153 void Observe(NotificationType type, |
| 154 const NotificationSource& source, | 154 const NotificationSource& source, |
| 155 const NotificationDetails& details) { | 155 const NotificationDetails& details) { |
| 156 if (type == NotificationType::EXTENSION_BROWSER_ACTION_UPDATED) | 156 if (type == chrome::EXTENSION_BROWSER_ACTION_UPDATED) |
| 157 UpdateState(); | 157 UpdateState(); |
| 158 else | 158 else |
| 159 NOTREACHED(); | 159 NOTREACHED(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 // ImageLoadingTracker::Observer implementation. | 162 // ImageLoadingTracker::Observer implementation. |
| 163 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, | 163 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, |
| 164 int index) { | 164 int index) { |
| 165 if (image) { | 165 if (image) { |
| 166 default_skbitmap_ = *image; | 166 default_skbitmap_ = *image; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 } | 443 } |
| 444 | 444 |
| 445 // We want to connect to "set-focus" on the toplevel window; we have to wait | 445 // We want to connect to "set-focus" on the toplevel window; we have to wait |
| 446 // until we are added to a toplevel window to do so. | 446 // until we are added to a toplevel window to do so. |
| 447 signals_.Connect(widget(), "hierarchy-changed", | 447 signals_.Connect(widget(), "hierarchy-changed", |
| 448 G_CALLBACK(OnHierarchyChangedThunk), this); | 448 G_CALLBACK(OnHierarchyChangedThunk), this); |
| 449 | 449 |
| 450 ViewIDUtil::SetID(button_hbox_.get(), VIEW_ID_BROWSER_ACTION_TOOLBAR); | 450 ViewIDUtil::SetID(button_hbox_.get(), VIEW_ID_BROWSER_ACTION_TOOLBAR); |
| 451 | 451 |
| 452 registrar_.Add(this, | 452 registrar_.Add(this, |
| 453 NotificationType::BROWSER_THEME_CHANGED, | 453 chrome::BROWSER_THEME_CHANGED, |
| 454 NotificationService::AllSources()); | 454 NotificationService::AllSources()); |
| 455 theme_service_->InitThemesFor(this); | 455 theme_service_->InitThemesFor(this); |
| 456 } | 456 } |
| 457 | 457 |
| 458 BrowserActionsToolbarGtk::~BrowserActionsToolbarGtk() { | 458 BrowserActionsToolbarGtk::~BrowserActionsToolbarGtk() { |
| 459 if (model_) | 459 if (model_) |
| 460 model_->RemoveObserver(this); | 460 model_->RemoveObserver(this); |
| 461 button_hbox_.Destroy(); | 461 button_hbox_.Destroy(); |
| 462 hbox_.Destroy(); | 462 hbox_.Destroy(); |
| 463 } | 463 } |
| 464 | 464 |
| 465 int BrowserActionsToolbarGtk::GetCurrentTabId() { | 465 int BrowserActionsToolbarGtk::GetCurrentTabId() { |
| 466 TabContentsWrapper* selected_tab = browser_->GetSelectedTabContentsWrapper(); | 466 TabContentsWrapper* selected_tab = browser_->GetSelectedTabContentsWrapper(); |
| 467 if (!selected_tab) | 467 if (!selected_tab) |
| 468 return -1; | 468 return -1; |
| 469 | 469 |
| 470 return selected_tab->restore_tab_helper()->session_id().id(); | 470 return selected_tab->restore_tab_helper()->session_id().id(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 void BrowserActionsToolbarGtk::Update() { | 473 void BrowserActionsToolbarGtk::Update() { |
| 474 for (ExtensionButtonMap::iterator iter = extension_button_map_.begin(); | 474 for (ExtensionButtonMap::iterator iter = extension_button_map_.begin(); |
| 475 iter != extension_button_map_.end(); ++iter) { | 475 iter != extension_button_map_.end(); ++iter) { |
| 476 iter->second->UpdateState(); | 476 iter->second->UpdateState(); |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 | 479 |
| 480 void BrowserActionsToolbarGtk::Observe(NotificationType type, | 480 void BrowserActionsToolbarGtk::Observe(NotificationType type, |
| 481 const NotificationSource& source, | 481 const NotificationSource& source, |
| 482 const NotificationDetails& details) { | 482 const NotificationDetails& details) { |
| 483 DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); | 483 DCHECK(chrome::BROWSER_THEME_CHANGED == type); |
| 484 gtk_widget_set_visible(separator_, theme_service_->UsingNativeTheme()); | 484 gtk_widget_set_visible(separator_, theme_service_->UsingNativeTheme()); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void BrowserActionsToolbarGtk::SetupDrags() { | 487 void BrowserActionsToolbarGtk::SetupDrags() { |
| 488 GtkTargetEntry drag_target = GetDragTargetEntry(); | 488 GtkTargetEntry drag_target = GetDragTargetEntry(); |
| 489 gtk_drag_dest_set(button_hbox_.get(), GTK_DEST_DEFAULT_DROP, &drag_target, 1, | 489 gtk_drag_dest_set(button_hbox_.get(), GTK_DEST_DEFAULT_DROP, &drag_target, 1, |
| 490 GDK_ACTION_MOVE); | 490 GDK_ACTION_MOVE); |
| 491 | 491 |
| 492 signals_.Connect(button_hbox_.get(), "drag-motion", | 492 signals_.Connect(button_hbox_.get(), "drag-motion", |
| 493 G_CALLBACK(OnDragMotionThunk), this); | 493 G_CALLBACK(OnDragMotionThunk), this); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 | 951 |
| 952 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 952 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 953 event->time); | 953 event->time); |
| 954 return TRUE; | 954 return TRUE; |
| 955 } | 955 } |
| 956 | 956 |
| 957 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 957 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
| 958 if (!resize_animation_.is_animating()) | 958 if (!resize_animation_.is_animating()) |
| 959 UpdateChevronVisibility(); | 959 UpdateChevronVisibility(); |
| 960 } | 960 } |
| OLD | NEW |