Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / avatar_menu_item_gtk.h
blob058e1340c3c8f19a6e14329b527da39bd68fcb86
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_
8 #include <gtk/gtk.h>
10 #include "chrome/browser/profiles/avatar_menu.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "ui/base/gtk/gtk_signal.h"
14 #include "ui/base/gtk/owned_widget_gtk.h"
16 class GtkThemeService;
18 // This widget contains the profile icon, user name, and synchronization status
19 // to be displayed in the AvatarMenuBubble. Clicking the profile will open a new
20 // browser window, and when the user hovers over an active profile item, a link
21 // is displayed that will allow editing the profile.
22 class AvatarMenuItemGtk : public content::NotificationObserver {
23 public:
24 // Delegates opening or editing a profile.
25 class Delegate {
26 public:
27 // Open a new browser window using the profile at |profile_index|.
28 virtual void OpenProfile(size_t profile_index) = 0;
30 // Edit the profile given by |profile_index|.
31 virtual void EditProfile(size_t profile_index) = 0;
34 AvatarMenuItemGtk(Delegate* delegate,
35 const AvatarMenu::Item& item,
36 size_t item_index,
37 GtkThemeService* theme_service);
38 virtual ~AvatarMenuItemGtk();
40 // Returns the root widget for this menu item.
41 GtkWidget* widget() { return widget_.get(); }
43 // content::NotificationObserver implementation.
44 virtual void Observe(int type,
45 const content::NotificationSource& source,
46 const content::NotificationDetails& details) OVERRIDE;
48 private:
50 void ShowStatusLabel();
51 void ShowEditLink();
53 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileClick,
54 GdkEventButton*);
55 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileEnter,
56 GdkEventCrossing*);
57 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileLeave,
58 GdkEventCrossing*);
59 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileFocusIn,
60 GdkEventFocus*);
61 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileFocusOut,
62 GdkEventFocus*);
63 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileKeyPress,
64 GdkEventKey*);
65 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnEventBoxExpose,
66 GdkEventExpose*);
67 CHROMEGTK_CALLBACK_0(AvatarMenuItemGtk, void, OnEditProfileLinkClicked);
69 // Create all widgets in this menu item, using |theme_service|.
70 void Init(GtkThemeService* theme_service);
72 // A weak pointer to the item's delegate.
73 Delegate* delegate_;
75 // Profile information to display for this item, e.g. user name, sync status.
76 AvatarMenu::Item item_;
78 // The index of this profile. The delegate uses this value to distinguish
79 // which profile should be switched to.
80 size_t item_index_;
82 // The root widget for this menu item.
83 ui::OwnedWidgetGtk widget_;
85 // Provides colors.
86 GtkThemeService* theme_service_;
88 // A weak pointer to a label that displays the sync status. It is not shown
89 // when the user is hovering over the item if the profile is the active
90 // profile.
91 GtkWidget* status_label_;
93 // A weak pointer to a link button to edit the given profile. It is shown only
94 // when the user is hovering over the active profile.
95 GtkWidget* link_alignment_;
97 // A weak pointer to a GtkChromeLinkButton so we can keep the use_gtk_theme
98 // property up to date.
99 GtkWidget* edit_profile_link_;
101 // The highlighted color. Depending on the theme, this is either |widget|'s
102 // bg[GTK_STATE_SELECTED] or a static highlight.
103 GdkColor highlighted_color_;
105 // The unhighlighted color. Depending on the theme, this is either NULL or a
106 // pointer to static data.
107 const GdkColor* unhighlighted_color_;
109 content::NotificationRegistrar registrar_;
111 DISALLOW_COPY_AND_ASSIGN(AvatarMenuItemGtk);
114 #endif // CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_