| OLD | NEW |
| 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/avatar_menu_button_gtk.h" | 5 #include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/command_updater.h" | 9 #include "chrome/browser/command_updater.h" |
| 10 #include "chrome/browser/managed_mode.h" | 10 #include "chrome/browser/managed_mode.h" |
| 11 #include "chrome/browser/profiles/profile_metrics.h" | 11 #include "chrome/browser/profiles/profile_metrics.h" |
| 12 #include "chrome/browser/profiles/profile_info_util.h" | 12 #include "chrome/browser/profiles/profile_info_util.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h" | 15 #include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h" |
| 15 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 16 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 16 #include "ui/gfx/gtk_util.h" | 17 #include "ui/gfx/gtk_util.h" |
| 17 | 18 |
| 18 AvatarMenuButtonGtk::AvatarMenuButtonGtk(Browser* browser) | 19 AvatarMenuButtonGtk::AvatarMenuButtonGtk(Browser* browser) |
| 19 : image_(NULL), | 20 : image_(NULL), |
| 20 browser_(browser), | 21 browser_(browser), |
| 21 arrow_location_(BubbleGtk::ARROW_LOCATION_TOP_LEFT), | 22 arrow_location_(BubbleGtk::ARROW_LOCATION_TOP_LEFT), |
| 22 is_gaia_picture_(false), | 23 is_gaia_picture_(false), |
| 23 old_height_(0) { | 24 old_height_(0) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return TRUE; | 61 return TRUE; |
| 61 } | 62 } |
| 62 | 63 |
| 63 void AvatarMenuButtonGtk::OnSizeAllocate(GtkWidget* widget, | 64 void AvatarMenuButtonGtk::OnSizeAllocate(GtkWidget* widget, |
| 64 GtkAllocation* allocation) { | 65 GtkAllocation* allocation) { |
| 65 if (allocation->height != old_height_) | 66 if (allocation->height != old_height_) |
| 66 UpdateButtonIcon(); | 67 UpdateButtonIcon(); |
| 67 } | 68 } |
| 68 | 69 |
| 69 void AvatarMenuButtonGtk::ShowAvatarBubble() { | 70 void AvatarMenuButtonGtk::ShowAvatarBubble() { |
| 70 DCHECK(browser_->command_updater()->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 71 DCHECK(chrome::IsCommandEnabled(browser_, IDC_SHOW_AVATAR_MENU)); |
| 71 // Only show the avatar bubble if the avatar button is in the title bar. | 72 // Only show the avatar bubble if the avatar button is in the title bar. |
| 72 if (gtk_widget_get_parent_window(widget_.get())) | 73 if (gtk_widget_get_parent_window(widget_.get())) |
| 73 new AvatarMenuBubbleGtk(browser_, widget_.get(), arrow_location_, NULL); | 74 new AvatarMenuBubbleGtk(browser_, widget_.get(), arrow_location_, NULL); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void AvatarMenuButtonGtk::UpdateButtonIcon() { | 77 void AvatarMenuButtonGtk::UpdateButtonIcon() { |
| 77 if (!icon_.get()) | 78 if (!icon_.get()) |
| 78 return; | 79 return; |
| 79 | 80 |
| 80 GtkAllocation allocation; | 81 GtkAllocation allocation; |
| 81 gtk_widget_get_allocation(widget(), &allocation); | 82 gtk_widget_get_allocation(widget(), &allocation); |
| 82 old_height_ = allocation.height; | 83 old_height_ = allocation.height; |
| 83 gfx::Image icon = profiles::GetAvatarIconForTitleBar(*icon_, is_gaia_picture_, | 84 gfx::Image icon = profiles::GetAvatarIconForTitleBar(*icon_, is_gaia_picture_, |
| 84 profiles::kAvatarIconWidth, old_height_); | 85 profiles::kAvatarIconWidth, old_height_); |
| 85 gtk_image_set_from_pixbuf(GTK_IMAGE(image_), icon.ToGdkPixbuf()); | 86 gtk_image_set_from_pixbuf(GTK_IMAGE(image_), icon.ToGdkPixbuf()); |
| 86 gtk_misc_set_alignment(GTK_MISC(image_), 0.0, 1.0); | 87 gtk_misc_set_alignment(GTK_MISC(image_), 0.0, 1.0); |
| 87 gtk_widget_set_size_request(image_, -1, 0); | 88 gtk_widget_set_size_request(image_, -1, 0); |
| 88 } | 89 } |
| OLD | NEW |