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

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: Fix was done by skare@ 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) 389 LocationBarViewGtk::LocationBarViewGtk(Browser* browser)
390 : zoom_image_(NULL), 390 : zoom_image_(NULL),
391 star_image_(NULL), 391 star_image_(NULL),
392 starred_(false), 392 starred_(false),
393 star_sized_(false),
393 site_type_alignment_(NULL), 394 site_type_alignment_(NULL),
394 site_type_event_box_(NULL), 395 site_type_event_box_(NULL),
395 location_icon_image_(NULL), 396 location_icon_image_(NULL),
396 drag_icon_(NULL), 397 drag_icon_(NULL),
397 enable_location_drag_(false), 398 enable_location_drag_(false),
398 security_info_label_(NULL), 399 security_info_label_(NULL),
399 web_intents_button_view_(new WebIntentsButtonViewGtk(this)), 400 web_intents_button_view_(new WebIntentsButtonViewGtk(this)),
400 tab_to_search_alignment_(NULL), 401 tab_to_search_alignment_(NULL),
401 tab_to_search_box_(NULL), 402 tab_to_search_box_(NULL),
402 tab_to_search_full_label_(NULL), 403 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. 551 // This offset corrects the strange offset of CustomDrawButton.
551 const int kMagicActionBoxYOffset = 3; 552 const int kMagicActionBoxYOffset = 3;
552 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 553 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
553 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 554 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
554 0, kMagicActionBoxYOffset, 555 0, kMagicActionBoxYOffset,
555 0, kInnerPadding); 556 0, kInnerPadding);
556 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget()); 557 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget());
557 558
558 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, 559 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment,
559 FALSE, FALSE, 0); 560 FALSE, FALSE, 0);
560 } else if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { 561 }
562
563 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) {
561 // Hide the star icon in popups, app windows, etc. 564 // Hide the star icon in popups, app windows, etc.
562 CreateStarButton(); 565 CreateStarButton();
563 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); 566 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0);
564 } 567 }
565 568
566 CreateZoomButton(); 569 CreateZoomButton();
567 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); 570 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0);
568 571
569 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); 572 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1));
570 gtk_widget_set_name(content_setting_hbox_.get(), 573 gtk_widget_set_name(content_setting_hbox_.get(),
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 0, 838 0,
836 OnZoomButtonPressThunk)); 839 OnZoomButtonPressThunk));
837 } 840 }
838 841
839 void LocationBarViewGtk::CreateStarButton() { 842 void LocationBarViewGtk::CreateStarButton() {
840 star_.Own(CreateIconButton(&star_image_, 843 star_.Own(CreateIconButton(&star_image_,
841 0, 844 0,
842 VIEW_ID_STAR_BUTTON, 845 VIEW_ID_STAR_BUTTON,
843 IDS_TOOLTIP_STAR, 846 IDS_TOOLTIP_STAR,
844 OnStarButtonPressThunk)); 847 OnStarButtonPressThunk));
848 // We need to track when the star button is resized to show any bubble
849 // attached to it at this time.
850 g_signal_connect(star_image_, "size-allocate",
851 G_CALLBACK(&OnStarButtonSizeAllocateThunk), this);
845 } 852 }
846 853
847 void LocationBarViewGtk::OnInputInProgress(bool in_progress) { 854 void LocationBarViewGtk::OnInputInProgress(bool in_progress) {
848 // This is identical to the Windows code, except that we don't proxy the call 855 // 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. 856 // back through the Toolbar, and just access the model here.
850 // The edit should make sure we're only notified when something changes. 857 // The edit should make sure we're only notified when something changes.
851 DCHECK(toolbar_model_->input_in_progress() != in_progress); 858 DCHECK(toolbar_model_->input_in_progress() != in_progress);
852 859
853 toolbar_model_->set_input_in_progress(in_progress); 860 toolbar_model_->set_input_in_progress(in_progress);
854 Update(NULL); 861 Update(NULL);
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 GdkEventButton* event) { 1459 GdkEventButton* event) {
1453 if (event->button == 1 && GetWebContents()) { 1460 if (event->button == 1 && GetWebContents()) {
1454 // If the zoom icon is clicked, show the zoom bubble and keep it open until 1461 // If the zoom icon is clicked, show the zoom bubble and keep it open until
1455 // it loses focus. 1462 // it loses focus.
1456 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), false); 1463 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), false);
1457 return TRUE; 1464 return TRUE;
1458 } 1465 }
1459 return FALSE; 1466 return FALSE;
1460 } 1467 }
1461 1468
1469 void LocationBarViewGtk::OnStarButtonSizeAllocate(GtkWidget* sender,
1470 GtkAllocation* allocation) {
1471 if (!on_star_sized_.is_null()) {
1472 on_star_sized_.Run();
1473 on_star_sized_.Reset();
1474 }
1475 star_sized_ = true;
1476 }
1477
1462 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, 1478 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget,
1463 GdkEventButton* event) { 1479 GdkEventButton* event) {
1464 if (event->button == 1) { 1480 if (event->button == 1) {
1465 chrome::ExecuteCommand(browser_, IDC_BOOKMARK_PAGE); 1481 chrome::ExecuteCommand(browser_, IDC_BOOKMARK_PAGE);
1466 return TRUE; 1482 return TRUE;
1467 } 1483 }
1468 return FALSE; 1484 return FALSE;
1469 } 1485 }
1470 1486
1471 void LocationBarViewGtk::ShowZoomBubble() { 1487 void LocationBarViewGtk::ShowZoomBubble() {
1472 if (!zoom_.get() || toolbar_model_->input_in_progress()) 1488 if (!zoom_.get() || toolbar_model_->input_in_progress())
1473 return; 1489 return;
1474 1490
1475 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); 1491 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true);
1476 } 1492 }
1477 1493
1478 void LocationBarViewGtk::ShowStarBubble(const GURL& url, 1494 void LocationBarViewGtk::ShowStarBubble(const GURL& url,
1479 bool newly_bookmarked) { 1495 bool newly_bookmarked) {
1480 if (!star_.get()) 1496 if (!star_.get())
1481 return; 1497 return;
1482 1498
1483 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, 1499 if (star_sized_) {
1484 newly_bookmarked); 1500 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url,
1501 newly_bookmarked);
1502 } else {
1503 on_star_sized_ = base::Bind(&BookmarkBubbleGtk::Show,
1504 star_.get(), browser_->profile(),
1505 url, newly_bookmarked);
1506 }
1485 } 1507 }
1486 1508
1487 void LocationBarViewGtk::ShowChromeToMobileBubble() { 1509 void LocationBarViewGtk::ShowChromeToMobileBubble() {
1488 // TODO(msw): Chrome to Mobile is currently disabled on GTK. 1510 // TODO(msw): Chrome to Mobile is currently disabled on GTK.
1489 // ChromeToMobileBubbleGtk::Show(GTK_WIDGET(action_box_button_->widget()), 1511 // ChromeToMobileBubbleGtk::Show(GTK_WIDGET(action_box_button_->widget()),
1490 // browser_); 1512 // browser_);
1491 } 1513 }
1492 1514
1493 void LocationBarViewGtk::SetStarred(bool starred) { 1515 void LocationBarViewGtk::SetStarred(bool starred) {
1494 if (starred == starred_) 1516 if (starred == starred_)
(...skipping 30 matching lines...) Expand all
1525 string16 tooltip = l10n_util::GetStringFUTF16Int( 1547 string16 tooltip = l10n_util::GetStringFUTF16Int(
1526 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); 1548 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent());
1527 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); 1549 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str());
1528 1550
1529 gtk_widget_show(zoom_.get()); 1551 gtk_widget_show(zoom_.get());
1530 } 1552 }
1531 1553
1532 void LocationBarViewGtk::UpdateStarIcon() { 1554 void LocationBarViewGtk::UpdateStarIcon() {
1533 if (!star_.get()) 1555 if (!star_.get())
1534 return; 1556 return;
1557 // Indicate the star icon is not correctly sized. It will be marked as sized
1558 // when the next size-allocate signal is received by the star widget.
1559 star_sized_ = false;
1535 bool star_enabled = !toolbar_model_->input_in_progress() && 1560 bool star_enabled = !toolbar_model_->input_in_progress() &&
1536 edit_bookmarks_enabled_.GetValue(); 1561 edit_bookmarks_enabled_.GetValue();
1537 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); 1562 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
1563 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableActionBox) &&
1564 !starred_) {
1565 star_enabled = false;
1566 }
1538 if (star_enabled) { 1567 if (star_enabled) {
1539 gtk_widget_show_all(star_.get()); 1568 gtk_widget_show_all(star_.get());
1540 int id = starred_ ? IDR_STAR_LIT : IDR_STAR; 1569 int id = starred_ ? IDR_STAR_LIT : IDR_STAR;
1541 gtk_image_set_from_pixbuf( 1570 gtk_image_set_from_pixbuf(GTK_IMAGE(star_image_),
1542 GTK_IMAGE(star_image_), 1571 theme_service_->GetImageNamed(id)->ToGdkPixbuf());
1543 theme_service_->GetImageNamed(id)->ToGdkPixbuf());
1544 } else { 1572 } else {
1545 gtk_widget_hide_all(star_.get()); 1573 gtk_widget_hide_all(star_.get());
1546 } 1574 }
1547 } 1575 }
1548 1576
1549 bool LocationBarViewGtk::ShouldOnlyShowLocation() { 1577 bool LocationBarViewGtk::ShouldOnlyShowLocation() {
1550 return !browser_->is_type_tabbed(); 1578 return !browser_->is_type_tabbed();
1551 } 1579 }
1552 1580
1553 void LocationBarViewGtk::AdjustChildrenVisibility() { 1581 void LocationBarViewGtk::AdjustChildrenVisibility() {
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 } 2111 }
2084 2112
2085 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2113 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
2086 ExtensionAction* action) { 2114 ExtensionAction* action) {
2087 ExtensionPopupGtk::Show( 2115 ExtensionPopupGtk::Show(
2088 action->GetPopupUrl(current_tab_id_), 2116 action->GetPopupUrl(current_tab_id_),
2089 owner_->browser_, 2117 owner_->browser_,
2090 event_box_.get(), 2118 event_box_.get(),
2091 ExtensionPopupGtk::SHOW_AND_INSPECT); 2119 ExtensionPopupGtk::SHOW_AND_INSPECT);
2092 } 2120 }
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