summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakuegel@chromium.org <akuegel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 16:05:45 +0000
committerakuegel@chromium.org <akuegel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 16:05:45 +0000
commit64759ec26b1af65e8a802cf32e9f8ac8df405721 (patch)
tree9b7de75a0e46ac3a9fc0b774f2f68bd31cb77fbb
parent6e9c15f61770c350be3064d20f55cf8b49201329 (diff)
downloadchromium_src-64759ec26b1af65e8a802cf32e9f8ac8df405721.zip
chromium_src-64759ec26b1af65e8a802cf32e9f8ac8df405721.tar.gz
chromium_src-64759ec26b1af65e8a802cf32e9f8ac8df405721.tar.bz2
Make managed user avatar label clickable.
This CL also includes two minor improvements: 1. Add a padding around the label to make the enclosing background rectangle bigger. 2. Only set the background color of the managed user info in the avatar menu if the native theme is used. A screenshot of the new managed user avatar label can be found at the end of the bug description. BUG=241387 Review URL: https://chromiumcodereview.appspot.com/16735002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206078 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/gtk/avatar_menu_bubble_gtk.cc2
-rw-r--r--chrome/browser/ui/gtk/browser_titlebar.cc19
-rw-r--r--chrome/browser/ui/gtk/browser_titlebar.h4
3 files changed, 24 insertions, 1 deletions
diff --git a/chrome/browser/ui/gtk/avatar_menu_bubble_gtk.cc b/chrome/browser/ui/gtk/avatar_menu_bubble_gtk.cc
index 96e0e4e..8d81513 100644
--- a/chrome/browser/ui/gtk/avatar_menu_bubble_gtk.cc
+++ b/chrome/browser/ui/gtk/avatar_menu_bubble_gtk.cc
@@ -125,7 +125,7 @@ void AvatarMenuBubbleGtk::OnSwitchProfileLinkClicked(GtkWidget* link) {
}
void AvatarMenuBubbleGtk::OnRealize(GtkWidget* parent_widget) {
- if (!managed_user_info_)
+ if (!managed_user_info_ || !theme_service_->UsingNativeTheme())
return;
// Use the same background color for the GtkTextView as the background color
diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc
index 0cd9a4c..1868a23 100644
--- a/chrome/browser/ui/gtk/browser_titlebar.cc
+++ b/chrome/browser/ui/gtk/browser_titlebar.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/gtk/accelerators_gtk.h"
+#include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h"
#include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h"
#include "chrome/browser/ui/gtk/browser_window_gtk.h"
#include "chrome/browser/ui/gtk/custom_button.h"
@@ -819,8 +820,11 @@ void BrowserTitlebar::UpdateAvatar() {
Profile* profile = browser_window_->browser()->profile();
if (ManagedUserService::ProfileIsManaged(profile)) {
avatar_label_ = gtk_label_new(NULL);
+ gtk_misc_set_padding(GTK_MISC(avatar_label_), 2, 2);
avatar_label_bg_ = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(avatar_label_bg_), avatar_label_);
+ g_signal_connect(avatar_label_bg_, "button-press-event",
+ G_CALLBACK(OnAvatarLabelButtonPressedThunk), this);
UpdateAvatarLabel();
gtk_widget_show(avatar_label_bg_);
gtk_widget_show(avatar_label_);
@@ -962,6 +966,21 @@ gboolean BrowserTitlebar::OnFaviconMenuButtonPressed(GtkWidget* widget,
return TRUE;
}
+gboolean BrowserTitlebar::OnAvatarLabelButtonPressed(GtkWidget* widget,
+ GdkEventButton* event) {
+ if (event->button != 1)
+ return FALSE;
+
+ // Show the avatar menu bubble with the upward arrow at the x position where
+ // the user has clicked.
+ gfx::Rect rect = gtk_util::WidgetBounds(widget);
+ rect.set_x(event->x);
+ rect.set_width(0);
+ new AvatarMenuBubbleGtk(
+ browser_window_->browser(), widget, BubbleGtk::ANCHOR_TOP_RIGHT, &rect);
+ return TRUE;
+}
+
void BrowserTitlebar::ShowContextMenu(GdkEventButton* event) {
if (!context_menu_.get()) {
context_menu_model_.reset(new ContextMenuModel(this));
diff --git a/chrome/browser/ui/gtk/browser_titlebar.h b/chrome/browser/ui/gtk/browser_titlebar.h
index 486c839..ce0ce94 100644
--- a/chrome/browser/ui/gtk/browser_titlebar.h
+++ b/chrome/browser/ui/gtk/browser_titlebar.h
@@ -148,6 +148,10 @@ class BrowserTitlebar : public content::NotificationObserver,
CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean,
OnFaviconMenuButtonPressed, GdkEventButton*);
+ // Callback for avatar menu label.
+ CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean,
+ OnAvatarLabelButtonPressed, GdkEventButton*);
+
// -- Context Menu -----------------------------------------------------------
// SimpleMenuModel::Delegate implementation: