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