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_UNSET_FLAGS(gripper, GTK_CAN_FOCUS); | 395 gtk_widget_set_can_focus(gripper, FALSE); |
| 396 |
396 gtk_widget_add_events(gripper, GDK_POINTER_MOTION_MASK); | 397 gtk_widget_add_events(gripper, GDK_POINTER_MOTION_MASK); |
397 signals_.Connect(gripper, "motion-notify-event", | 398 signals_.Connect(gripper, "motion-notify-event", |
398 G_CALLBACK(OnGripperMotionNotifyThunk), this); | 399 G_CALLBACK(OnGripperMotionNotifyThunk), this); |
399 signals_.Connect(gripper, "expose-event", | 400 signals_.Connect(gripper, "expose-event", |
400 G_CALLBACK(OnGripperExposeThunk), this); | 401 G_CALLBACK(OnGripperExposeThunk), this); |
401 signals_.Connect(gripper, "enter-notify-event", | 402 signals_.Connect(gripper, "enter-notify-event", |
402 G_CALLBACK(OnGripperEnterNotifyThunk), this); | 403 G_CALLBACK(OnGripperEnterNotifyThunk), this); |
403 signals_.Connect(gripper, "leave-notify-event", | 404 signals_.Connect(gripper, "leave-notify-event", |
404 G_CALLBACK(OnGripperLeaveNotifyThunk), this); | 405 G_CALLBACK(OnGripperLeaveNotifyThunk), this); |
405 signals_.Connect(gripper, "button-release-event", | 406 signals_.Connect(gripper, "button-release-event", |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 int index) { | 597 int index) { |
597 overflow_menu_.reset(); | 598 overflow_menu_.reset(); |
598 | 599 |
599 CreateButtonForExtension(extension, index); | 600 CreateButtonForExtension(extension, index); |
600 | 601 |
601 // If we are still initializing the container, don't bother animating. | 602 // If we are still initializing the container, don't bother animating. |
602 if (!model_->extensions_initialized()) | 603 if (!model_->extensions_initialized()) |
603 return; | 604 return; |
604 | 605 |
605 // Animate the addition if we are showing all browser action buttons. | 606 // Animate the addition if we are showing all browser action buttons. |
606 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { | 607 if (!gtk_widget_get_visible(overflow_area_)) { |
607 AnimateToShowNIcons(button_count()); | 608 AnimateToShowNIcons(button_count()); |
608 model_->SetVisibleIconCount(button_count()); | 609 model_->SetVisibleIconCount(button_count()); |
609 } | 610 } |
610 } | 611 } |
611 | 612 |
612 void BrowserActionsToolbarGtk::BrowserActionRemoved( | 613 void BrowserActionsToolbarGtk::BrowserActionRemoved( |
613 const Extension* extension) { | 614 const Extension* extension) { |
614 overflow_menu_.reset(); | 615 overflow_menu_.reset(); |
615 | 616 |
616 if (drag_button_ != NULL) { | 617 if (drag_button_ != NULL) { |
617 // Break the current drag. | 618 // Break the current drag. |
618 gtk_grab_remove(button_hbox_.get()); | 619 gtk_grab_remove(button_hbox_.get()); |
619 } | 620 } |
620 | 621 |
621 RemoveButtonForExtension(extension); | 622 RemoveButtonForExtension(extension); |
622 | 623 |
623 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { | 624 if (!gtk_widget_get_visible(overflow_area_)) { |
624 AnimateToShowNIcons(button_count()); | 625 AnimateToShowNIcons(button_count()); |
625 model_->SetVisibleIconCount(button_count()); | 626 model_->SetVisibleIconCount(button_count()); |
626 } | 627 } |
627 } | 628 } |
628 | 629 |
629 void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension, | 630 void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension, |
630 int index) { | 631 int index) { |
631 // We initiated this move action, and have already moved the button. | 632 // We initiated this move action, and have already moved the button. |
632 if (drag_button_ != NULL) | 633 if (drag_button_ != NULL) |
633 return; | 634 return; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 gtk_chrome_shrinkable_hbox_get_visible_child_count( | 732 gtk_chrome_shrinkable_hbox_get_visible_child_count( |
732 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); | 733 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); |
733 if (showing_icon_count == 0) { | 734 if (showing_icon_count == 0) { |
734 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, 0, 0); | 735 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, 0, 0); |
735 } else { | 736 } else { |
736 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, | 737 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, |
737 kButtonChevronPadding, 0); | 738 kButtonChevronPadding, 0); |
738 } | 739 } |
739 | 740 |
740 if (button_count() > showing_icon_count) { | 741 if (button_count() > showing_icon_count) { |
741 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { | 742 if (!gtk_widget_get_visible(overflow_area_)) { |
742 if (drag_button_) { | 743 if (drag_button_) { |
743 // During drags, when the overflow chevron shows for the first time, | 744 // During drags, when the overflow chevron shows for the first time, |
744 // take that much space away from |button_hbox_| to make the drag look | 745 // take that much space away from |button_hbox_| to make the drag look |
745 // smoother. | 746 // smoother. |
746 GtkRequisition req; | 747 GtkRequisition req; |
747 gtk_widget_size_request(chevron(), &req); | 748 gtk_widget_size_request(chevron(), &req); |
748 gint overflow_width = req.width; | 749 gint overflow_width = req.width; |
749 gtk_widget_size_request(button_hbox_.get(), &req); | 750 gtk_widget_size_request(button_hbox_.get(), &req); |
750 gint button_hbox_width = req.width; | 751 gint button_hbox_width = req.width; |
751 button_hbox_width = std::max(button_hbox_width - overflow_width, 0); | 752 button_hbox_width = std::max(button_hbox_width - overflow_width, 0); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 | 957 |
957 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 958 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
958 event->time); | 959 event->time); |
959 return TRUE; | 960 return TRUE; |
960 } | 961 } |
961 | 962 |
962 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 963 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
963 if (!resize_animation_.is_animating()) | 964 if (!resize_animation_.is_animating()) |
964 UpdateChevronVisibility(); | 965 UpdateChevronVisibility(); |
965 } | 966 } |
OLD | NEW |