| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUTTON_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUTTON_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUTTON_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUTTON_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 12 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 12 #include "ui/base/gtk/gtk_signal.h" | 13 #include "ui/base/gtk/gtk_signal.h" |
| 13 #include "ui/base/gtk/owned_widget_gtk.h" | 14 #include "ui/base/gtk/owned_widget_gtk.h" |
| 14 | 15 |
| 15 class Browser; | 16 class Browser; |
| 16 class SkBitmap; | 17 class SkBitmap; |
| 17 | 18 |
| 19 namespace gfx { |
| 20 class Image; |
| 21 } |
| 22 |
| 18 // A button used to show the profile avatar. When clicked, it opens the | 23 // A button used to show the profile avatar. When clicked, it opens the |
| 19 // AvatarMenuBubbleGtk. | 24 // AvatarMenuBubbleGtk. |
| 20 class AvatarMenuButtonGtk { | 25 class AvatarMenuButtonGtk { |
| 21 public: | 26 public: |
| 22 explicit AvatarMenuButtonGtk(Browser* browser); | 27 explicit AvatarMenuButtonGtk(Browser* browser); |
| 23 | 28 |
| 24 ~AvatarMenuButtonGtk(); | 29 ~AvatarMenuButtonGtk(); |
| 25 | 30 |
| 26 // Returns the button widget. | 31 // Returns the button widget. |
| 27 GtkWidget* widget() const { return widget_.get(); } | 32 GtkWidget* widget() const { return widget_.get(); } |
| 28 | 33 |
| 29 // Sets the location the arrow should be displayed on the menu bubble. | 34 // Sets the location the arrow should be displayed on the menu bubble. |
| 30 void set_menu_arrow_location(BubbleGtk::ArrowLocationGtk arrow_location) { | 35 void set_menu_arrow_location(BubbleGtk::ArrowLocationGtk arrow_location) { |
| 31 arrow_location_ = arrow_location; | 36 arrow_location_ = arrow_location; |
| 32 } | 37 } |
| 33 | 38 |
| 34 // Sets the image to display on the button, typically the profile icon. | 39 // Sets the image to display on the button, typically the profile icon. |
| 35 void SetIcon(const SkBitmap &icon); | 40 void SetIcon(const gfx::Image& icon, bool is_gaia_picture); |
| 36 | 41 |
| 37 // Show the avatar bubble. | 42 // Show the avatar bubble. |
| 38 void ShowAvatarBubble(); | 43 void ShowAvatarBubble(); |
| 39 | 44 |
| 40 private: | 45 private: |
| 41 CHROMEGTK_CALLBACK_1(AvatarMenuButtonGtk, gboolean, OnButtonPressed, | 46 CHROMEGTK_CALLBACK_1(AvatarMenuButtonGtk, gboolean, OnButtonPressed, |
| 42 GdkEventButton*); | 47 GdkEventButton*); |
| 48 CHROMEGTK_CALLBACK_1(AvatarMenuButtonGtk, void, OnSizeAllocate, |
| 49 GtkAllocation*); |
| 50 |
| 51 void UpdateButtonIcon(); |
| 43 | 52 |
| 44 // The button widget. | 53 // The button widget. |
| 45 ui::OwnedWidgetGtk widget_; | 54 ui::OwnedWidgetGtk widget_; |
| 46 | 55 |
| 47 // A weak pointer to the image widget displayed on the button. | 56 // A weak pointer to the image widget displayed on the button. |
| 48 GtkWidget* image_; | 57 GtkWidget* image_; |
| 49 | 58 |
| 50 // A weak pointer to a browser. Used to create the bubble menu. | 59 // A weak pointer to a browser. Used to create the bubble menu. |
| 51 Browser* browser_; | 60 Browser* browser_; |
| 52 | 61 |
| 53 // Which side of the bubble to display the arrow. | 62 // Which side of the bubble to display the arrow. |
| 54 BubbleGtk::ArrowLocationGtk arrow_location_; | 63 BubbleGtk::ArrowLocationGtk arrow_location_; |
| 55 | 64 |
| 65 scoped_ptr<gfx::Image> icon_; |
| 66 bool is_gaia_picture_; |
| 67 int old_height_; |
| 68 |
| 56 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButtonGtk); | 69 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButtonGtk); |
| 57 }; | 70 }; |
| 58 | 71 |
| 59 #endif // CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUTTON_GTK_H_ | 72 #endif // CHROME_BROWSER_UI_GTK_AVATAR_MENU_BUTTON_GTK_H_ |
| OLD | NEW |