OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/browser_toolbar_gtk.h" | 5 #include "chrome/browser/gtk/browser_toolbar_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #include <X11/XF86keysym.h> | 9 #include <X11/XF86keysym.h> |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Amount of rounding on top corners of toolbar. Only used in Gtk theme mode. | 76 // Amount of rounding on top corners of toolbar. Only used in Gtk theme mode. |
77 const int kToolbarCornerSize = 3; | 77 const int kToolbarCornerSize = 3; |
78 | 78 |
79 // The offset in pixels of the upgrade dot on the app menu. | 79 // The offset in pixels of the upgrade dot on the app menu. |
80 const int kUpgradeDotOffset = 6; | 80 const int kUpgradeDotOffset = 6; |
81 | 81 |
82 // The duration of the upgrade notification animation (actually the duration | 82 // The duration of the upgrade notification animation (actually the duration |
83 // of a half-throb). | 83 // of a half-throb). |
84 const int kThrobDuration = 1000; | 84 const int kThrobDuration = 1000; |
85 | 85 |
| 86 void SetWidgetHeightRequest(GtkWidget* widget, gpointer user_data) { |
| 87 gtk_widget_set_size_request(widget, -1, GPOINTER_TO_INT(user_data)); |
| 88 } |
| 89 |
86 } // namespace | 90 } // namespace |
87 | 91 |
88 // BrowserToolbarGtk, public --------------------------------------------------- | 92 // BrowserToolbarGtk, public --------------------------------------------------- |
89 | 93 |
90 BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window) | 94 BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window) |
91 : toolbar_(NULL), | 95 : toolbar_(NULL), |
92 location_bar_(new LocationBarViewGtk(browser)), | 96 location_bar_(new LocationBarViewGtk(browser)), |
93 model_(browser->toolbar_model()), | 97 model_(browser->toolbar_model()), |
94 wrench_menu_model_(this, browser), | 98 wrench_menu_model_(this, browser), |
95 browser_(browser), | 99 browser_(browser), |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (type == NotificationType::PREF_CHANGED) { | 381 if (type == NotificationType::PREF_CHANGED) { |
378 NotifyPrefChanged(Details<std::wstring>(details).ptr()); | 382 NotifyPrefChanged(Details<std::wstring>(details).ptr()); |
379 } else if (type == NotificationType::BROWSER_THEME_CHANGED) { | 383 } else if (type == NotificationType::BROWSER_THEME_CHANGED) { |
380 // Update the spacing around the menu buttons | 384 // Update the spacing around the menu buttons |
381 bool use_gtk = theme_provider_->UseGtkTheme(); | 385 bool use_gtk = theme_provider_->UseGtkTheme(); |
382 int border = use_gtk ? 0 : 2; | 386 int border = use_gtk ? 0 : 2; |
383 gtk_container_set_border_width( | 387 gtk_container_set_border_width( |
384 GTK_CONTAINER(wrench_menu_button_->widget()), border); | 388 GTK_CONTAINER(wrench_menu_button_->widget()), border); |
385 | 389 |
386 // Force the height of the toolbar so we get the right amount of padding | 390 // Force the height of the toolbar so we get the right amount of padding |
387 // above and below the location bar. We always force the size of the hboxes | 391 // above and below the location bar. We always force the size of the widgets |
388 // to either side of the location box, but we only force the location box | 392 // to either side of the location box, but we only force the location box |
389 // size in chrome-theme mode because that's the only time we try to control | 393 // size in chrome-theme mode because that's the only time we try to control |
390 // the font size. | 394 // the font size. |
391 int toolbar_height = ShouldOnlyShowLocation() ? | 395 int toolbar_height = ShouldOnlyShowLocation() ? |
392 kToolbarHeightLocationBarOnly : kToolbarHeight; | 396 kToolbarHeightLocationBarOnly : kToolbarHeight; |
393 gtk_widget_set_size_request(toolbar_left_, -1, toolbar_height); | 397 gtk_container_foreach(GTK_CONTAINER(toolbar_), SetWidgetHeightRequest, |
| 398 GINT_TO_POINTER(toolbar_height)); |
394 gtk_widget_set_size_request(location_hbox_, -1, | 399 gtk_widget_set_size_request(location_hbox_, -1, |
395 use_gtk ? -1 : toolbar_height); | 400 use_gtk ? -1 : toolbar_height); |
396 | 401 |
397 // When using the GTK+ theme, we need to have the event box be visible so | 402 // When using the GTK+ theme, we need to have the event box be visible so |
398 // buttons don't get a halo color from the background. When using Chromium | 403 // buttons don't get a halo color from the background. When using Chromium |
399 // themes, we want to let the background show through the toolbar. | 404 // themes, we want to let the background show through the toolbar. |
400 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), use_gtk); | 405 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_), use_gtk); |
401 | 406 |
402 UpdateRoundedness(); | 407 UpdateRoundedness(); |
403 } else if (type == NotificationType::UPGRADE_RECOMMENDED) { | 408 } else if (type == NotificationType::UPGRADE_RECOMMENDED) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 715 |
711 return FALSE; | 716 return FALSE; |
712 } | 717 } |
713 | 718 |
714 bool BrowserToolbarGtk::UpgradeAnimationIsFaded() { | 719 bool BrowserToolbarGtk::UpgradeAnimationIsFaded() { |
715 return upgrade_reminder_animation_.cycles_remaining() > 0 && | 720 return upgrade_reminder_animation_.cycles_remaining() > 0 && |
716 // This funky looking math makes the badge throb for 2 seconds once | 721 // This funky looking math makes the badge throb for 2 seconds once |
717 // every 8 seconds. | 722 // every 8 seconds. |
718 ((upgrade_reminder_animation_.cycles_remaining() - 1) / 2) % 4 == 0; | 723 ((upgrade_reminder_animation_.cycles_remaining() - 1) / 2) % 4 == 0; |
719 } | 724 } |
OLD | NEW |