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

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

Issue 10889052: Display action box menu on Linux/gtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed incorrectly positioned bubble problem. Created 8 years, 3 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
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/location_bar_view_gtk.h" 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 379
380 } // namespace 380 } // namespace
381 381
382 //////////////////////////////////////////////////////////////////////////////// 382 ////////////////////////////////////////////////////////////////////////////////
383 // LocationBarViewGtk 383 // LocationBarViewGtk
384 384
385 // static 385 // static
386 const GdkColor LocationBarViewGtk::kBackgroundColor = 386 const GdkColor LocationBarViewGtk::kBackgroundColor =
387 GDK_COLOR_RGB(255, 255, 255); 387 GDK_COLOR_RGB(255, 255, 255);
388 388
389 class LocationBarViewGtk::ShowStarBubbleAction {
Evan Stade 2012/08/30 22:32:25 I'd just use a pair. At the very least it should b
390 public:
391 ShowStarBubbleAction(GURL url, bool newly_bookmarked);
392
393 GURL url_;
394 bool newly_bookmarked_;
395 };
396
397 LocationBarViewGtk::ShowStarBubbleAction::ShowStarBubbleAction(
398 GURL url,
399 bool newly_bookmarked)
400 : url_(url), newly_bookmarked_(newly_bookmarked) {}
401
389 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) 402 LocationBarViewGtk::LocationBarViewGtk(Browser* browser)
390 : zoom_image_(NULL), 403 : zoom_image_(NULL),
391 star_image_(NULL), 404 star_image_(NULL),
392 starred_(false), 405 starred_(false),
406 star_sized_(false),
393 site_type_alignment_(NULL), 407 site_type_alignment_(NULL),
394 site_type_event_box_(NULL), 408 site_type_event_box_(NULL),
395 location_icon_image_(NULL), 409 location_icon_image_(NULL),
396 drag_icon_(NULL), 410 drag_icon_(NULL),
397 enable_location_drag_(false), 411 enable_location_drag_(false),
398 security_info_label_(NULL), 412 security_info_label_(NULL),
399 web_intents_button_view_(new WebIntentsButtonViewGtk(this)), 413 web_intents_button_view_(new WebIntentsButtonViewGtk(this)),
400 tab_to_search_alignment_(NULL), 414 tab_to_search_alignment_(NULL),
401 tab_to_search_box_(NULL), 415 tab_to_search_box_(NULL),
402 tab_to_search_full_label_(NULL), 416 tab_to_search_full_label_(NULL),
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // This offset corrects the strange offset of CustomDrawButton. 564 // This offset corrects the strange offset of CustomDrawButton.
551 const int kMagicActionBoxYOffset = 3; 565 const int kMagicActionBoxYOffset = 3;
552 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 566 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
553 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 567 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
554 0, kMagicActionBoxYOffset, 568 0, kMagicActionBoxYOffset,
555 0, kInnerPadding); 569 0, kInnerPadding);
556 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget()); 570 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget());
557 571
558 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, 572 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment,
559 FALSE, FALSE, 0); 573 FALSE, FALSE, 0);
560 } else if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { 574 }
575
576 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) {
561 // Hide the star icon in popups, app windows, etc. 577 // Hide the star icon in popups, app windows, etc.
562 CreateStarButton(); 578 CreateStarButton();
563 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); 579 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0);
564 } 580 }
565 581
566 CreateZoomButton(); 582 CreateZoomButton();
567 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); 583 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0);
568 584
569 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); 585 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1));
570 gtk_widget_set_name(content_setting_hbox_.get(), 586 gtk_widget_set_name(content_setting_hbox_.get(),
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 0, 851 0,
836 OnZoomButtonPressThunk)); 852 OnZoomButtonPressThunk));
837 } 853 }
838 854
839 void LocationBarViewGtk::CreateStarButton() { 855 void LocationBarViewGtk::CreateStarButton() {
840 star_.Own(CreateIconButton(&star_image_, 856 star_.Own(CreateIconButton(&star_image_,
841 0, 857 0,
842 VIEW_ID_STAR_BUTTON, 858 VIEW_ID_STAR_BUTTON,
843 IDS_TOOLTIP_STAR, 859 IDS_TOOLTIP_STAR,
844 OnStarButtonPressThunk)); 860 OnStarButtonPressThunk));
861 // We need to track when the star button is resized to show any bubble
862 // attached to it at this time.
863 g_signal_connect(star_image_, "size-allocate",
864 G_CALLBACK(&OnStarButtonSizeAllocateThunk), this);
845 } 865 }
846 866
847 void LocationBarViewGtk::OnInputInProgress(bool in_progress) { 867 void LocationBarViewGtk::OnInputInProgress(bool in_progress) {
848 // This is identical to the Windows code, except that we don't proxy the call 868 // This is identical to the Windows code, except that we don't proxy the call
849 // back through the Toolbar, and just access the model here. 869 // back through the Toolbar, and just access the model here.
850 // The edit should make sure we're only notified when something changes. 870 // The edit should make sure we're only notified when something changes.
851 DCHECK(toolbar_model_->input_in_progress() != in_progress); 871 DCHECK(toolbar_model_->input_in_progress() != in_progress);
852 872
853 toolbar_model_->set_input_in_progress(in_progress); 873 toolbar_model_->set_input_in_progress(in_progress);
854 Update(NULL); 874 Update(NULL);
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 GdkEventButton* event) { 1472 GdkEventButton* event) {
1453 if (event->button == 1 && GetWebContents()) { 1473 if (event->button == 1 && GetWebContents()) {
1454 // If the zoom icon is clicked, show the zoom bubble and keep it open until 1474 // If the zoom icon is clicked, show the zoom bubble and keep it open until
1455 // it loses focus. 1475 // it loses focus.
1456 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), false); 1476 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), false);
1457 return TRUE; 1477 return TRUE;
1458 } 1478 }
1459 return FALSE; 1479 return FALSE;
1460 } 1480 }
1461 1481
1482 void LocationBarViewGtk::OnStarButtonSizeAllocate(GtkWidget* sender,
1483 GtkAllocation* allocation) {
1484 if (show_star_bubble_action_.get()) {
1485 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(),
1486 show_star_bubble_action_->url_,
1487 show_star_bubble_action_->newly_bookmarked_);
1488 show_star_bubble_action_.reset();
1489 }
1490 star_sized_ = true;
1491 }
1492
1462 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, 1493 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget,
1463 GdkEventButton* event) { 1494 GdkEventButton* event) {
1464 if (event->button == 1) { 1495 if (event->button == 1) {
1465 chrome::ExecuteCommand(browser_, IDC_BOOKMARK_PAGE); 1496 chrome::ExecuteCommand(browser_, IDC_BOOKMARK_PAGE);
1466 return TRUE; 1497 return TRUE;
1467 } 1498 }
1468 return FALSE; 1499 return FALSE;
1469 } 1500 }
1470 1501
1471 void LocationBarViewGtk::ShowZoomBubble() { 1502 void LocationBarViewGtk::ShowZoomBubble() {
1472 if (!zoom_.get() || toolbar_model_->input_in_progress()) 1503 if (!zoom_.get() || toolbar_model_->input_in_progress())
1473 return; 1504 return;
1474 1505
1475 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); 1506 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true);
1476 } 1507 }
1477 1508
1478 void LocationBarViewGtk::ShowStarBubble(const GURL& url, 1509 void LocationBarViewGtk::ShowStarBubble(const GURL& url,
1479 bool newly_bookmarked) { 1510 bool newly_bookmarked) {
1480 if (!star_.get()) 1511 if (!star_.get())
1481 return; 1512 return;
1482 1513
1483 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, 1514 if (star_sized_)
Evan Stade 2012/08/30 22:32:25 curlies
beaudoin 2012/08/31 13:27:09 Done.
1484 newly_bookmarked); 1515 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url,
1516 newly_bookmarked);
1517 else
1518 show_star_bubble_action_.reset(
1519 new ShowStarBubbleAction(url, newly_bookmarked));
1485 } 1520 }
1486 1521
1487 void LocationBarViewGtk::ShowChromeToMobileBubble() { 1522 void LocationBarViewGtk::ShowChromeToMobileBubble() {
1488 // TODO(msw): Chrome to Mobile is currently disabled on GTK. 1523 // TODO(msw): Chrome to Mobile is currently disabled on GTK.
1489 // ChromeToMobileBubbleGtk::Show(GTK_WIDGET(action_box_button_->widget()), 1524 // ChromeToMobileBubbleGtk::Show(GTK_WIDGET(action_box_button_->widget()),
1490 // browser_); 1525 // browser_);
1491 } 1526 }
1492 1527
1493 void LocationBarViewGtk::SetStarred(bool starred) { 1528 void LocationBarViewGtk::SetStarred(bool starred) {
1494 if (starred == starred_) 1529 if (starred == starred_)
(...skipping 30 matching lines...) Expand all
1525 string16 tooltip = l10n_util::GetStringFUTF16Int( 1560 string16 tooltip = l10n_util::GetStringFUTF16Int(
1526 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); 1561 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent());
1527 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); 1562 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str());
1528 1563
1529 gtk_widget_show(zoom_.get()); 1564 gtk_widget_show(zoom_.get());
1530 } 1565 }
1531 1566
1532 void LocationBarViewGtk::UpdateStarIcon() { 1567 void LocationBarViewGtk::UpdateStarIcon() {
1533 if (!star_.get()) 1568 if (!star_.get())
1534 return; 1569 return;
1570 // Indicate the star icon is not correctly sized. It will be marked as sized
1571 // when the next size-allocate signal is received by the star widget.
1572 star_sized_ = false;
1535 bool star_enabled = !toolbar_model_->input_in_progress() && 1573 bool star_enabled = !toolbar_model_->input_in_progress() &&
1536 edit_bookmarks_enabled_.GetValue(); 1574 edit_bookmarks_enabled_.GetValue();
1537 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); 1575 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
1576 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableActionBox) &&
1577 !starred_)
Evan Stade 2012/08/30 22:32:25 curlies
beaudoin 2012/08/31 13:27:09 Done.
1578 star_enabled = false;
1538 if (star_enabled) { 1579 if (star_enabled) {
1539 gtk_widget_show_all(star_.get()); 1580 gtk_widget_show_all(star_.get());
1540 int id = starred_ ? IDR_STAR_LIT : IDR_STAR; 1581 int id = starred_ ? IDR_STAR_LIT : IDR_STAR;
1541 gtk_image_set_from_pixbuf( 1582 gtk_image_set_from_pixbuf(GTK_IMAGE(star_image_),
1542 GTK_IMAGE(star_image_), 1583 theme_service_->GetImageNamed(id)->ToGdkPixbuf());
1543 theme_service_->GetImageNamed(id)->ToGdkPixbuf());
1544 } else { 1584 } else {
1545 gtk_widget_hide_all(star_.get()); 1585 gtk_widget_hide_all(star_.get());
1546 } 1586 }
1547 } 1587 }
1548 1588
1549 bool LocationBarViewGtk::ShouldOnlyShowLocation() { 1589 bool LocationBarViewGtk::ShouldOnlyShowLocation() {
1550 return !browser_->is_type_tabbed(); 1590 return !browser_->is_type_tabbed();
1551 } 1591 }
1552 1592
1553 void LocationBarViewGtk::AdjustChildrenVisibility() { 1593 void LocationBarViewGtk::AdjustChildrenVisibility() {
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 } 2123 }
2084 2124
2085 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2125 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
2086 ExtensionAction* action) { 2126 ExtensionAction* action) {
2087 ExtensionPopupGtk::Show( 2127 ExtensionPopupGtk::Show(
2088 action->GetPopupUrl(current_tab_id_), 2128 action->GetPopupUrl(current_tab_id_),
2089 owner_->browser_, 2129 owner_->browser_,
2090 event_box_.get(), 2130 event_box_.get(),
2091 ExtensionPopupGtk::SHOW_AND_INSPECT); 2131 ExtensionPopupGtk::SHOW_AND_INSPECT);
2092 } 2132 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698