Commit d5650de1 authored by ncj674@motorola.com's avatar ncj674@motorola.com

Linux/Gtk: Drawing a focus-ring around the avatar menu items to highlight selection.

BUG=None.
TEST=Click avatar menu and press Tab key to navigate through the menu.
Selected menu items should have a focus ring.

Review URL: http://codereview.chromium.org/8921003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114086 0039d316-1c4b-4281-b951-d872f2087c98
parent 194e48de
...@@ -120,7 +120,6 @@ void AvatarMenuItemGtk::ShowEditLink() { ...@@ -120,7 +120,6 @@ void AvatarMenuItemGtk::ShowEditLink() {
gboolean AvatarMenuItemGtk::OnProfileFocusIn(GtkWidget* widget, gboolean AvatarMenuItemGtk::OnProfileFocusIn(GtkWidget* widget,
GdkEventFocus* event) { GdkEventFocus* event) {
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &highlighted_color_);
if (item_.active) if (item_.active)
ShowEditLink(); ShowEditLink();
...@@ -129,7 +128,6 @@ gboolean AvatarMenuItemGtk::OnProfileFocusIn(GtkWidget* widget, ...@@ -129,7 +128,6 @@ gboolean AvatarMenuItemGtk::OnProfileFocusIn(GtkWidget* widget,
gboolean AvatarMenuItemGtk::OnProfileFocusOut(GtkWidget* widget, gboolean AvatarMenuItemGtk::OnProfileFocusOut(GtkWidget* widget,
GdkEventFocus* event) { GdkEventFocus* event) {
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, unhighlighted_color_);
if (item_.active) if (item_.active)
ShowStatusLabel(); ShowStatusLabel();
...@@ -201,6 +199,22 @@ void AvatarMenuItemGtk::OnEditProfileLinkClicked(GtkWidget* link) { ...@@ -201,6 +199,22 @@ void AvatarMenuItemGtk::OnEditProfileLinkClicked(GtkWidget* link) {
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
gboolean AvatarMenuItemGtk::OnEventBoxExpose(GtkWidget* widget,
GdkEventExpose* event) {
// Draw the focus rectangle.
if (gtk_widget_has_focus(widget)) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
gtk_paint_focus(widget->style, widget->window,
gtk_widget_get_state(widget),
&event->area, widget, NULL,
0, 0,
allocation.width, allocation.height);
}
return TRUE;
}
void AvatarMenuItemGtk::Init(GtkThemeService* theme_service) { void AvatarMenuItemGtk::Init(GtkThemeService* theme_service) {
widget_.Own(gtk_event_box_new()); widget_.Own(gtk_event_box_new());
...@@ -216,6 +230,8 @@ void AvatarMenuItemGtk::Init(GtkThemeService* theme_service) { ...@@ -216,6 +230,8 @@ void AvatarMenuItemGtk::Init(GtkThemeService* theme_service) {
G_CALLBACK(OnProfileFocusOutThunk), this); G_CALLBACK(OnProfileFocusOutThunk), this);
g_signal_connect(widget_.get(), "key-press-event", g_signal_connect(widget_.get(), "key-press-event",
G_CALLBACK(OnProfileKeyPressThunk), this); G_CALLBACK(OnProfileKeyPressThunk), this);
g_signal_connect_after(widget_.get(), "expose-event",
G_CALLBACK(OnEventBoxExposeThunk), this);
GtkWidget* item_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); GtkWidget* item_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
GdkPixbuf* avatar_pixbuf = NULL; GdkPixbuf* avatar_pixbuf = NULL;
......
...@@ -67,6 +67,8 @@ class AvatarMenuItemGtk : public content::NotificationObserver { ...@@ -67,6 +67,8 @@ class AvatarMenuItemGtk : public content::NotificationObserver {
GdkEventFocus*); GdkEventFocus*);
CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileKeyPress, CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileKeyPress,
GdkEventKey*); GdkEventKey*);
CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnEventBoxExpose,
GdkEventExpose*);
CHROMEGTK_CALLBACK_0(AvatarMenuItemGtk, void, OnEditProfileLinkClicked); CHROMEGTK_CALLBACK_0(AvatarMenuItemGtk, void, OnEditProfileLinkClicked);
// Create all widgets in this menu item, using |theme_service|. // Create all widgets in this menu item, using |theme_service|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment