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