| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 overflow_button_.reset(new CustomDrawButton( | 385 overflow_button_.reset(new CustomDrawButton( |
| 386 theme_service_, | 386 theme_service_, |
| 387 IDR_BROWSER_ACTIONS_OVERFLOW, | 387 IDR_BROWSER_ACTIONS_OVERFLOW, |
| 388 IDR_BROWSER_ACTIONS_OVERFLOW_P, | 388 IDR_BROWSER_ACTIONS_OVERFLOW_P, |
| 389 IDR_BROWSER_ACTIONS_OVERFLOW_H, | 389 IDR_BROWSER_ACTIONS_OVERFLOW_H, |
| 390 0, | 390 0, |
| 391 gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE))); | 391 gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE))); |
| 392 | 392 |
| 393 GtkWidget* gripper = gtk_button_new(); | 393 GtkWidget* gripper = gtk_button_new(); |
| 394 gtk_widget_set_size_request(gripper, kResizeGripperWidth, -1); | 394 gtk_widget_set_size_request(gripper, kResizeGripperWidth, -1); |
| 395 gtk_widget_set_can_focus(gripper, FALSE); | 395 GTK_WIDGET_UNSET_FLAGS(gripper, GTK_CAN_FOCUS); |
| 396 | |
| 397 gtk_widget_add_events(gripper, GDK_POINTER_MOTION_MASK); | 396 gtk_widget_add_events(gripper, GDK_POINTER_MOTION_MASK); |
| 398 signals_.Connect(gripper, "motion-notify-event", | 397 signals_.Connect(gripper, "motion-notify-event", |
| 399 G_CALLBACK(OnGripperMotionNotifyThunk), this); | 398 G_CALLBACK(OnGripperMotionNotifyThunk), this); |
| 400 signals_.Connect(gripper, "expose-event", | 399 signals_.Connect(gripper, "expose-event", |
| 401 G_CALLBACK(OnGripperExposeThunk), this); | 400 G_CALLBACK(OnGripperExposeThunk), this); |
| 402 signals_.Connect(gripper, "enter-notify-event", | 401 signals_.Connect(gripper, "enter-notify-event", |
| 403 G_CALLBACK(OnGripperEnterNotifyThunk), this); | 402 G_CALLBACK(OnGripperEnterNotifyThunk), this); |
| 404 signals_.Connect(gripper, "leave-notify-event", | 403 signals_.Connect(gripper, "leave-notify-event", |
| 405 G_CALLBACK(OnGripperLeaveNotifyThunk), this); | 404 G_CALLBACK(OnGripperLeaveNotifyThunk), this); |
| 406 signals_.Connect(gripper, "button-release-event", | 405 signals_.Connect(gripper, "button-release-event", |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 int index) { | 590 int index) { |
| 592 overflow_menu_.reset(); | 591 overflow_menu_.reset(); |
| 593 | 592 |
| 594 CreateButtonForExtension(extension, index); | 593 CreateButtonForExtension(extension, index); |
| 595 | 594 |
| 596 // If we are still initializing the container, don't bother animating. | 595 // If we are still initializing the container, don't bother animating. |
| 597 if (!model_->extensions_initialized()) | 596 if (!model_->extensions_initialized()) |
| 598 return; | 597 return; |
| 599 | 598 |
| 600 // Animate the addition if we are showing all browser action buttons. | 599 // Animate the addition if we are showing all browser action buttons. |
| 601 if (!gtk_widget_get_visible(overflow_area_)) { | 600 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { |
| 602 AnimateToShowNIcons(button_count()); | 601 AnimateToShowNIcons(button_count()); |
| 603 model_->SetVisibleIconCount(button_count()); | 602 model_->SetVisibleIconCount(button_count()); |
| 604 } | 603 } |
| 605 } | 604 } |
| 606 | 605 |
| 607 void BrowserActionsToolbarGtk::BrowserActionRemoved( | 606 void BrowserActionsToolbarGtk::BrowserActionRemoved( |
| 608 const Extension* extension) { | 607 const Extension* extension) { |
| 609 overflow_menu_.reset(); | 608 overflow_menu_.reset(); |
| 610 | 609 |
| 611 if (drag_button_ != NULL) { | 610 if (drag_button_ != NULL) { |
| 612 // Break the current drag. | 611 // Break the current drag. |
| 613 gtk_grab_remove(button_hbox_.get()); | 612 gtk_grab_remove(button_hbox_.get()); |
| 614 } | 613 } |
| 615 | 614 |
| 616 RemoveButtonForExtension(extension); | 615 RemoveButtonForExtension(extension); |
| 617 | 616 |
| 618 if (!gtk_widget_get_visible(overflow_area_)) { | 617 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { |
| 619 AnimateToShowNIcons(button_count()); | 618 AnimateToShowNIcons(button_count()); |
| 620 model_->SetVisibleIconCount(button_count()); | 619 model_->SetVisibleIconCount(button_count()); |
| 621 } | 620 } |
| 622 } | 621 } |
| 623 | 622 |
| 624 void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension, | 623 void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension, |
| 625 int index) { | 624 int index) { |
| 626 // We initiated this move action, and have already moved the button. | 625 // We initiated this move action, and have already moved the button. |
| 627 if (drag_button_ != NULL) | 626 if (drag_button_ != NULL) |
| 628 return; | 627 return; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 gtk_chrome_shrinkable_hbox_get_visible_child_count( | 725 gtk_chrome_shrinkable_hbox_get_visible_child_count( |
| 727 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); | 726 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); |
| 728 if (showing_icon_count == 0) { | 727 if (showing_icon_count == 0) { |
| 729 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, 0, 0); | 728 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, 0, 0); |
| 730 } else { | 729 } else { |
| 731 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, | 730 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, |
| 732 kButtonChevronPadding, 0); | 731 kButtonChevronPadding, 0); |
| 733 } | 732 } |
| 734 | 733 |
| 735 if (button_count() > showing_icon_count) { | 734 if (button_count() > showing_icon_count) { |
| 736 if (!gtk_widget_get_visible(overflow_area_)) { | 735 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { |
| 737 if (drag_button_) { | 736 if (drag_button_) { |
| 738 // During drags, when the overflow chevron shows for the first time, | 737 // During drags, when the overflow chevron shows for the first time, |
| 739 // take that much space away from |button_hbox_| to make the drag look | 738 // take that much space away from |button_hbox_| to make the drag look |
| 740 // smoother. | 739 // smoother. |
| 741 GtkRequisition req; | 740 GtkRequisition req; |
| 742 gtk_widget_size_request(chevron(), &req); | 741 gtk_widget_size_request(chevron(), &req); |
| 743 gint overflow_width = req.width; | 742 gint overflow_width = req.width; |
| 744 gtk_widget_size_request(button_hbox_.get(), &req); | 743 gtk_widget_size_request(button_hbox_.get(), &req); |
| 745 gint button_hbox_width = req.width; | 744 gint button_hbox_width = req.width; |
| 746 button_hbox_width = std::max(button_hbox_width - overflow_width, 0); | 745 button_hbox_width = std::max(button_hbox_width - overflow_width, 0); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 | 950 |
| 952 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 951 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 953 event->time); | 952 event->time); |
| 954 return TRUE; | 953 return TRUE; |
| 955 } | 954 } |
| 956 | 955 |
| 957 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 956 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
| 958 if (!resize_animation_.is_animating()) | 957 if (!resize_animation_.is_animating()) |
| 959 UpdateChevronVisibility(); | 958 UpdateChevronVisibility(); |
| 960 } | 959 } |
| OLD | NEW |