Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8158)

Unified Diff: chrome/browser/ui/gtk/avatar_menu_item_gtk.cc

Issue 8834010: Linux GTK: Support keyboard navigation in avatar menu. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/avatar_menu_item_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/avatar_menu_item_gtk.cc
===================================================================
--- chrome/browser/ui/gtk/avatar_menu_item_gtk.cc (revision 112677)
+++ chrome/browser/ui/gtk/avatar_menu_item_gtk.cc (working copy)
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/gtk/avatar_menu_item_gtk.h"
+#include <gdk/gdkkeysyms.h>
+
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
@@ -82,16 +84,66 @@
return FALSE;
}
+gboolean AvatarMenuItemGtk::OnProfileKeyPress(GtkWidget* widget,
+ GdkEventKey* event) {
+ // delegate_->EditProfile() will close the avatar bubble which in turn
+ // try to destroy this AvatarMenuItemGtk.
+ // This is not OK to do this from the signal handler, so we'll
+ // defer it.
+ if (event->keyval == GDK_Return ||
+ event->keyval == GDK_ISO_Enter ||
+ event->keyval == GDK_KP_Enter) {
+ if (item_.active)
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&AvatarMenuItemGtk::EditProfile,
+ weak_factory_.GetWeakPtr()));
+ else
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&AvatarMenuItemGtk::OpenProfile,
+ weak_factory_.GetWeakPtr()));
+ }
+
+ return FALSE;
+}
+
+void AvatarMenuItemGtk::ShowStatusLabel() {
+ gtk_widget_show(status_label_);
+ gtk_widget_hide(link_alignment_);
+}
+
+void AvatarMenuItemGtk::ShowEditLink() {
+ gtk_widget_hide(status_label_);
+ gtk_widget_show(link_alignment_);
+}
+
+gboolean AvatarMenuItemGtk::OnProfileFocusIn(GtkWidget* widget,
+ GdkEventFocus* event) {
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &highlighted_color_);
+ if (item_.active)
+ ShowEditLink();
+
+ return FALSE;
+}
+
+gboolean AvatarMenuItemGtk::OnProfileFocusOut(GtkWidget* widget,
+ GdkEventFocus* event) {
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, unhighlighted_color_);
+ if (item_.active)
+ ShowStatusLabel();
+
+ return FALSE;
+}
+
gboolean AvatarMenuItemGtk::OnProfileEnter(GtkWidget* widget,
GdkEventCrossing* event) {
if (event->detail == GDK_NOTIFY_INFERIOR)
return FALSE;
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &highlighted_color_);
- if (item_.active) {
- gtk_widget_hide(status_label_);
- gtk_widget_show(link_alignment_);
- }
+ if (item_.active)
+ ShowEditLink();
return FALSE;
}
@@ -102,10 +154,8 @@
return FALSE;
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, unhighlighted_color_);
- if (item_.active) {
- gtk_widget_show(status_label_);
- gtk_widget_hide(link_alignment_);
- }
+ if (item_.active)
+ ShowStatusLabel();
return FALSE;
}
@@ -160,6 +210,12 @@
G_CALLBACK(OnProfileEnterThunk), this);
g_signal_connect(widget_.get(), "leave-notify-event",
G_CALLBACK(OnProfileLeaveThunk), this);
+ g_signal_connect(widget_.get(), "focus-in-event",
+ G_CALLBACK(OnProfileFocusInThunk), this);
+ g_signal_connect(widget_.get(), "focus-out-event",
+ G_CALLBACK(OnProfileFocusOutThunk), this);
+ g_signal_connect(widget_.get(), "key-press-event",
+ G_CALLBACK(OnProfileKeyPressThunk), this);
GtkWidget* item_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
GdkPixbuf* avatar_pixbuf = NULL;
« no previous file with comments | « chrome/browser/ui/gtk/avatar_menu_item_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698