Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc

Issue 7484035: Reapplies r91761. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 int index) { 591 int index) {
591 overflow_menu_.reset(); 592 overflow_menu_.reset();
592 593
593 CreateButtonForExtension(extension, index); 594 CreateButtonForExtension(extension, index);
594 595
595 // If we are still initializing the container, don't bother animating. 596 // If we are still initializing the container, don't bother animating.
596 if (!model_->extensions_initialized()) 597 if (!model_->extensions_initialized())
597 return; 598 return;
598 599
599 // Animate the addition if we are showing all browser action buttons. 600 // Animate the addition if we are showing all browser action buttons.
600 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { 601 if (!gtk_widget_get_visible(overflow_area_)) {
601 AnimateToShowNIcons(button_count()); 602 AnimateToShowNIcons(button_count());
602 model_->SetVisibleIconCount(button_count()); 603 model_->SetVisibleIconCount(button_count());
603 } 604 }
604 } 605 }
605 606
606 void BrowserActionsToolbarGtk::BrowserActionRemoved( 607 void BrowserActionsToolbarGtk::BrowserActionRemoved(
607 const Extension* extension) { 608 const Extension* extension) {
608 overflow_menu_.reset(); 609 overflow_menu_.reset();
609 610
610 if (drag_button_ != NULL) { 611 if (drag_button_ != NULL) {
611 // Break the current drag. 612 // Break the current drag.
612 gtk_grab_remove(button_hbox_.get()); 613 gtk_grab_remove(button_hbox_.get());
613 } 614 }
614 615
615 RemoveButtonForExtension(extension); 616 RemoveButtonForExtension(extension);
616 617
617 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { 618 if (!gtk_widget_get_visible(overflow_area_)) {
618 AnimateToShowNIcons(button_count()); 619 AnimateToShowNIcons(button_count());
619 model_->SetVisibleIconCount(button_count()); 620 model_->SetVisibleIconCount(button_count());
620 } 621 }
621 } 622 }
622 623
623 void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension, 624 void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension,
624 int index) { 625 int index) {
625 // We initiated this move action, and have already moved the button. 626 // We initiated this move action, and have already moved the button.
626 if (drag_button_ != NULL) 627 if (drag_button_ != NULL)
627 return; 628 return;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 gtk_chrome_shrinkable_hbox_get_visible_child_count( 726 gtk_chrome_shrinkable_hbox_get_visible_child_count(
726 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); 727 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get()));
727 if (showing_icon_count == 0) { 728 if (showing_icon_count == 0) {
728 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, 0, 0); 729 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, 0, 0);
729 } else { 730 } else {
730 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0, 731 gtk_alignment_set_padding(GTK_ALIGNMENT(overflow_alignment_), 0, 0,
731 kButtonChevronPadding, 0); 732 kButtonChevronPadding, 0);
732 } 733 }
733 734
734 if (button_count() > showing_icon_count) { 735 if (button_count() > showing_icon_count) {
735 if (!GTK_WIDGET_VISIBLE(overflow_area_)) { 736 if (!gtk_widget_get_visible(overflow_area_)) {
736 if (drag_button_) { 737 if (drag_button_) {
737 // During drags, when the overflow chevron shows for the first time, 738 // During drags, when the overflow chevron shows for the first time,
738 // take that much space away from |button_hbox_| to make the drag look 739 // take that much space away from |button_hbox_| to make the drag look
739 // smoother. 740 // smoother.
740 GtkRequisition req; 741 GtkRequisition req;
741 gtk_widget_size_request(chevron(), &req); 742 gtk_widget_size_request(chevron(), &req);
742 gint overflow_width = req.width; 743 gint overflow_width = req.width;
743 gtk_widget_size_request(button_hbox_.get(), &req); 744 gtk_widget_size_request(button_hbox_.get(), &req);
744 gint button_hbox_width = req.width; 745 gint button_hbox_width = req.width;
745 button_hbox_width = std::max(button_hbox_width - overflow_width, 0); 746 button_hbox_width = std::max(button_hbox_width - overflow_width, 0);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 951
951 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), 952 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root),
952 event->time); 953 event->time);
953 return TRUE; 954 return TRUE;
954 } 955 }
955 956
956 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { 957 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) {
957 if (!resize_animation_.is_animating()) 958 if (!resize_animation_.is_animating())
958 UpdateChevronVisibility(); 959 UpdateChevronVisibility();
959 } 960 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc ('k') | chrome/browser/ui/gtk/browser_toolbar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698