| 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 extensions::CommandService::ACTIVE_ONLY); | 374 extensions::CommandService::ACTIVE_ONLY); |
| 375 if (command) { | 375 if (command) { |
| 376 // Found the browser action shortcut command, register it. | 376 // Found the browser action shortcut command, register it. |
| 377 keybinding_.reset(new ui::AcceleratorGtk( | 377 keybinding_.reset(new ui::AcceleratorGtk( |
| 378 command->accelerator().key_code(), | 378 command->accelerator().key_code(), |
| 379 command->accelerator().IsShiftDown(), | 379 command->accelerator().IsShiftDown(), |
| 380 command->accelerator().IsCtrlDown(), | 380 command->accelerator().IsCtrlDown(), |
| 381 command->accelerator().IsAltDown())); | 381 command->accelerator().IsAltDown())); |
| 382 | 382 |
| 383 gfx::NativeWindow window = | 383 gfx::NativeWindow window = |
| 384 toolbar_->browser()->window()->GetNativeHandle(); | 384 toolbar_->browser()->window()->GetNativeWindow(); |
| 385 accel_group_ = gtk_accel_group_new(); | 385 accel_group_ = gtk_accel_group_new(); |
| 386 gtk_window_add_accel_group(window, accel_group_); | 386 gtk_window_add_accel_group(window, accel_group_); |
| 387 | 387 |
| 388 gtk_accel_group_connect( | 388 gtk_accel_group_connect( |
| 389 accel_group_, | 389 accel_group_, |
| 390 keybinding_.get()->GetGdkKeyCode(), | 390 keybinding_.get()->GetGdkKeyCode(), |
| 391 keybinding_.get()->gdk_modifier_type(), | 391 keybinding_.get()->gdk_modifier_type(), |
| 392 GtkAccelFlags(0), | 392 GtkAccelFlags(0), |
| 393 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); | 393 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); |
| 394 | 394 |
| 395 // Since we've added an accelerator, we'll need to unregister it before | 395 // Since we've added an accelerator, we'll need to unregister it before |
| 396 // the window is closed, so we listen for the window being closed. | 396 // the window is closed, so we listen for the window being closed. |
| 397 registrar_.Add(this, | 397 registrar_.Add(this, |
| 398 chrome::NOTIFICATION_WINDOW_CLOSED, | 398 chrome::NOTIFICATION_WINDOW_CLOSED, |
| 399 content::Source<GtkWindow>(window)); | 399 content::Source<GtkWindow>(window)); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 // Disconnect the accelerator for the browser action popup and delete clean up | 403 // Disconnect the accelerator for the browser action popup and delete clean up |
| 404 // the accelerator group registration. | 404 // the accelerator group registration. |
| 405 void DisconnectBrowserActionPopupAccelerator() { | 405 void DisconnectBrowserActionPopupAccelerator() { |
| 406 if (accel_group_) { | 406 if (accel_group_) { |
| 407 gfx::NativeWindow window = | 407 gfx::NativeWindow window = |
| 408 toolbar_->browser()->window()->GetNativeHandle(); | 408 toolbar_->browser()->window()->GetNativeWindow(); |
| 409 gtk_accel_group_disconnect_key( | 409 gtk_accel_group_disconnect_key( |
| 410 accel_group_, | 410 accel_group_, |
| 411 keybinding_.get()->GetGdkKeyCode(), | 411 keybinding_.get()->GetGdkKeyCode(), |
| 412 static_cast<GdkModifierType>(keybinding_.get()->modifiers())); | 412 static_cast<GdkModifierType>(keybinding_.get()->modifiers())); |
| 413 gtk_window_remove_accel_group(window, accel_group_); | 413 gtk_window_remove_accel_group(window, accel_group_); |
| 414 g_object_unref(accel_group_); | 414 g_object_unref(accel_group_); |
| 415 accel_group_ = NULL; | 415 accel_group_ = NULL; |
| 416 keybinding_.reset(NULL); | 416 keybinding_.reset(NULL); |
| 417 } | 417 } |
| 418 } | 418 } |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 | 1064 |
| 1065 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 1065 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 1066 event->time); | 1066 event->time); |
| 1067 return TRUE; | 1067 return TRUE; |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 1070 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
| 1071 if (!resize_animation_.is_animating()) | 1071 if (!resize_animation_.is_animating()) |
| 1072 UpdateChevronVisibility(); | 1072 UpdateChevronVisibility(); |
| 1073 } | 1073 } |
| OLD | NEW |