| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 browser_->command_updater()->RemoveCommandObserver(IDC_FORWARD, this); | 119 browser_->command_updater()->RemoveCommandObserver(IDC_FORWARD, this); |
| 120 browser_->command_updater()->RemoveCommandObserver(IDC_HOME, this); | 120 browser_->command_updater()->RemoveCommandObserver(IDC_HOME, this); |
| 121 browser_->command_updater()->RemoveCommandObserver(IDC_BOOKMARK_PAGE, this); | 121 browser_->command_updater()->RemoveCommandObserver(IDC_BOOKMARK_PAGE, this); |
| 122 | 122 |
| 123 offscreen_entry_.Destroy(); | 123 offscreen_entry_.Destroy(); |
| 124 | 124 |
| 125 page_menu_.reset(); | 125 page_menu_.reset(); |
| 126 app_menu_.reset(); | 126 app_menu_.reset(); |
| 127 page_menu_button_.Destroy(); | 127 page_menu_button_.Destroy(); |
| 128 app_menu_button_.Destroy(); | 128 app_menu_button_.Destroy(); |
| 129 app_menu_image_.Destroy(); |
| 129 } | 130 } |
| 130 | 131 |
| 131 void BrowserToolbarGtk::Init(Profile* profile, | 132 void BrowserToolbarGtk::Init(Profile* profile, |
| 132 GtkWindow* top_level_window) { | 133 GtkWindow* top_level_window) { |
| 133 // Make sure to tell the location bar the profile before calling its Init. | 134 // Make sure to tell the location bar the profile before calling its Init. |
| 134 SetProfile(profile); | 135 SetProfile(profile); |
| 135 | 136 |
| 136 theme_provider_ = GtkThemeProvider::GetFrom(profile); | 137 theme_provider_ = GtkThemeProvider::GetFrom(profile); |
| 137 offscreen_entry_.Own(gtk_entry_new()); | 138 offscreen_entry_.Own(gtk_entry_new()); |
| 138 | 139 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 219 |
| 219 page_menu_.reset(new MenuGtk(this, &page_menu_model_)); | 220 page_menu_.reset(new MenuGtk(this, &page_menu_model_)); |
| 220 gtk_box_pack_start(GTK_BOX(menus_hbox), page_menu, FALSE, FALSE, 0); | 221 gtk_box_pack_start(GTK_BOX(menus_hbox), page_menu, FALSE, FALSE, 0); |
| 221 } | 222 } |
| 222 | 223 |
| 223 GtkWidget* chrome_menu = BuildToolbarMenuButton( | 224 GtkWidget* chrome_menu = BuildToolbarMenuButton( |
| 224 l10n_util::GetStringFUTF8(IDS_APPMENU_TOOLTIP, | 225 l10n_util::GetStringFUTF8(IDS_APPMENU_TOOLTIP, |
| 225 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))), | 226 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))), |
| 226 &app_menu_button_); | 227 &app_menu_button_); |
| 227 menu_bar_helper_.Add(app_menu_button_.get()); | 228 menu_bar_helper_.Add(app_menu_button_.get()); |
| 228 app_menu_image_ = gtk_image_new_from_pixbuf( | 229 app_menu_image_.Own(gtk_image_new_from_pixbuf( |
| 229 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_CHROME)); | 230 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_CHROME))); |
| 230 gtk_container_add(GTK_CONTAINER(chrome_menu), app_menu_image_); | 231 gtk_container_add(GTK_CONTAINER(chrome_menu), app_menu_image_.get()); |
| 231 g_signal_connect_after(app_menu_image_, "expose-event", | 232 g_signal_connect_after(app_menu_image_.get(), "expose-event", |
| 232 G_CALLBACK(OnAppMenuImageExposeThunk), this); | 233 G_CALLBACK(OnAppMenuImageExposeThunk), this); |
| 233 | 234 |
| 234 if (use_wrench_menu) | 235 if (use_wrench_menu) |
| 235 app_menu_.reset(new MenuGtk(this, &wrench_menu_model_)); | 236 app_menu_.reset(new MenuGtk(this, &wrench_menu_model_)); |
| 236 else | 237 else |
| 237 app_menu_.reset(new MenuGtk(this, &app_menu_model_)); | 238 app_menu_.reset(new MenuGtk(this, &app_menu_model_)); |
| 238 gtk_box_pack_start(GTK_BOX(menus_hbox), chrome_menu, FALSE, FALSE, 0); | 239 gtk_box_pack_start(GTK_BOX(menus_hbox), chrome_menu, FALSE, FALSE, 0); |
| 239 gtk_box_pack_start(GTK_BOX(toolbar_right_), menus_hbox, FALSE, FALSE, | 240 gtk_box_pack_start(GTK_BOX(toolbar_right_), menus_hbox, FALSE, FALSE, |
| 240 kToolbarWidgetSpacing); | 241 kToolbarWidgetSpacing); |
| 241 g_signal_connect(app_menu_->widget(), "show", | 242 g_signal_connect(app_menu_->widget(), "show", |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 GTK_CONTAINER(page_menu_button_.get()), border); | 419 GTK_CONTAINER(page_menu_button_.get()), border); |
| 419 } | 420 } |
| 420 gtk_container_set_border_width( | 421 gtk_container_set_border_width( |
| 421 GTK_CONTAINER(app_menu_button_.get()), border); | 422 GTK_CONTAINER(app_menu_button_.get()), border); |
| 422 | 423 |
| 423 // Update the menu button images. | 424 // Update the menu button images. |
| 424 if (page_menu_button_.get()) { | 425 if (page_menu_button_.get()) { |
| 425 gtk_image_set_from_pixbuf(GTK_IMAGE(page_menu_image_), | 426 gtk_image_set_from_pixbuf(GTK_IMAGE(page_menu_image_), |
| 426 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_PAGE)); | 427 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_PAGE)); |
| 427 } | 428 } |
| 428 gtk_image_set_from_pixbuf(GTK_IMAGE(app_menu_image_), | 429 gtk_image_set_from_pixbuf(GTK_IMAGE(app_menu_image_.get()), |
| 429 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_CHROME)); | 430 theme_provider_->GetRTLEnabledPixbufNamed(IDR_MENU_CHROME)); |
| 430 | 431 |
| 431 // Force the height of the toolbar so we get the right amount of padding | 432 // Force the height of the toolbar so we get the right amount of padding |
| 432 // above and below the location bar. We always force the size of the hboxes | 433 // above and below the location bar. We always force the size of the hboxes |
| 433 // to either side of the location box, but we only force the location box | 434 // to either side of the location box, but we only force the location box |
| 434 // size in chrome-theme mode because that's the only time we try to control | 435 // size in chrome-theme mode because that's the only time we try to control |
| 435 // the font size. | 436 // the font size. |
| 436 int toolbar_height = ShouldOnlyShowLocation() ? | 437 int toolbar_height = ShouldOnlyShowLocation() ? |
| 437 kToolbarHeightLocationBarOnly : kToolbarHeight; | 438 kToolbarHeightLocationBarOnly : kToolbarHeight; |
| 438 gtk_widget_set_size_request(toolbar_left_, -1, toolbar_height); | 439 gtk_widget_set_size_request(toolbar_left_, -1, toolbar_height); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 if (other_button) | 777 if (other_button) |
| 777 PopupForButton(other_button); | 778 PopupForButton(other_button); |
| 778 } | 779 } |
| 779 | 780 |
| 780 void BrowserToolbarGtk::AnimationEnded(const Animation* animation) { | 781 void BrowserToolbarGtk::AnimationEnded(const Animation* animation) { |
| 781 AnimationProgressed(animation); | 782 AnimationProgressed(animation); |
| 782 } | 783 } |
| 783 | 784 |
| 784 void BrowserToolbarGtk::AnimationProgressed(const Animation* animation) { | 785 void BrowserToolbarGtk::AnimationProgressed(const Animation* animation) { |
| 785 DCHECK_EQ(animation, &upgrade_reminder_animation_); | 786 DCHECK_EQ(animation, &upgrade_reminder_animation_); |
| 786 gtk_widget_queue_draw(app_menu_image_); | 787 gtk_widget_queue_draw(app_menu_image_.get()); |
| 787 } | 788 } |
| 788 | 789 |
| 789 void BrowserToolbarGtk::AnimationCanceled(const Animation* animation) { | 790 void BrowserToolbarGtk::AnimationCanceled(const Animation* animation) { |
| 790 AnimationProgressed(animation); | 791 AnimationProgressed(animation); |
| 791 } | 792 } |
| 792 | 793 |
| 793 void BrowserToolbarGtk::OnAppMenuShow(GtkWidget* sender) { | 794 void BrowserToolbarGtk::OnAppMenuShow(GtkWidget* sender) { |
| 794 upgrade_reminder_animation_.Reset(); | 795 upgrade_reminder_animation_.Reset(); |
| 795 } | 796 } |
| 796 | 797 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 817 int x_offset = base::i18n::IsRTL() ? | 818 int x_offset = base::i18n::IsRTL() ? |
| 818 sender->allocation.width - kUpgradeDotOffset - badge.width() : | 819 sender->allocation.width - kUpgradeDotOffset - badge.width() : |
| 819 kUpgradeDotOffset; | 820 kUpgradeDotOffset; |
| 820 canvas.DrawBitmapInt( | 821 canvas.DrawBitmapInt( |
| 821 badge, | 822 badge, |
| 822 sender->allocation.x + x_offset, | 823 sender->allocation.x + x_offset, |
| 823 sender->allocation.y + sender->allocation.height - badge.height()); | 824 sender->allocation.y + sender->allocation.height - badge.height()); |
| 824 | 825 |
| 825 return FALSE; | 826 return FALSE; |
| 826 } | 827 } |
| OLD | NEW |