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

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,6 +84,52 @@
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;
+}
+
+gboolean AvatarMenuItemGtk::OnProfileFocusIn(GtkWidget* widget,
+ GdkEventFocus* event) {
sail 2011/12/07 16:42:26 indentation looks wrong here
SanjoyPal 2011/12/08 06:38:55 Done.
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &highlighted_color_);
+ if (item_.active) {
sail 2011/12/07 16:42:26 can you refactor this with :OnProfileEnter
SanjoyPal 2011/12/08 06:38:55 Done.
+ gtk_widget_hide(status_label_);
+ gtk_widget_show(link_alignment_);
+ }
+
+ return FALSE;
+}
+
+gboolean AvatarMenuItemGtk::OnProfileFocusOut(GtkWidget* widget,
+ GdkEventFocus* event) {
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, unhighlighted_color_);
+ if (item_.active) {
sail 2011/12/07 16:42:26 can you refactor this with onprofileleave
SanjoyPal 2011/12/08 06:38:55 Done.
+ gtk_widget_show(status_label_);
+ gtk_widget_hide(link_alignment_);
+ }
+
+ return FALSE;
+}
+
gboolean AvatarMenuItemGtk::OnProfileEnter(GtkWidget* widget,
GdkEventCrossing* event) {
if (event->detail == GDK_NOTIFY_INFERIOR)
@@ -160,6 +208,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