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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc

Issue 151209: Initial work on Linux tab to search. (Closed)
Patch Set: Dan's comments. Created 11 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 452
453 gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget, 453 gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget,
454 GdkEventKey* event) { 454 GdkEventKey* event) {
455 // This is very similar to the special casing of the return key in the 455 // This is very similar to the special casing of the return key in the
456 // GtkTextView key_press default handler. TODO(deanm): We do however omit 456 // GtkTextView key_press default handler. TODO(deanm): We do however omit
457 // some IME related code, this might become a problem if an IME wants to 457 // some IME related code, this might become a problem if an IME wants to
458 // handle enter. We can get at the im_context and do it ourselves if needed. 458 // handle enter. We can get at the im_context and do it ourselves if needed.
459 if (event->keyval == GDK_Return || 459 if (event->keyval == GDK_Return ||
460 event->keyval == GDK_ISO_Enter || 460 event->keyval == GDK_ISO_Enter ||
461 event->keyval == GDK_KP_Enter || 461 event->keyval == GDK_KP_Enter ||
462 event->keyval == GDK_Tab ||
462 (event->keyval == GDK_Escape && event->state == 0)) { 463 (event->keyval == GDK_Escape && event->state == 0)) {
463 // Handle IME. This is basically taken from GtkTextView and reworked a bit. 464 // Handle IME. This is basically taken from GtkTextView and reworked a bit.
464 GtkTextIter iter; 465 GtkTextIter iter;
465 GtkTextView* text_view = GTK_TEXT_VIEW(text_view_); 466 GtkTextView* text_view = GTK_TEXT_VIEW(text_view_);
466 GtkTextMark* insert = gtk_text_buffer_get_insert(text_buffer_); 467 GtkTextMark* insert = gtk_text_buffer_get_insert(text_buffer_);
467 gtk_text_buffer_get_iter_at_mark(text_buffer_, &iter, insert); 468 gtk_text_buffer_get_iter_at_mark(text_buffer_, &iter, insert);
468 gboolean can_insert = gtk_text_iter_can_insert(&iter, text_view->editable); 469 gboolean can_insert = gtk_text_iter_can_insert(&iter, text_view->editable);
469 if (gtk_im_context_filter_keypress(text_view->im_context, event)) { 470 if (gtk_im_context_filter_keypress(text_view->im_context, event)) {
470 // The IME handled it, do the follow up IME handling. 471 // The IME handled it, do the follow up IME handling.
471 if (!can_insert) { 472 if (!can_insert) {
472 gtk_im_context_reset(text_view->im_context); 473 gtk_im_context_reset(text_view->im_context);
473 } else { 474 } else {
474 text_view->need_im_reset = TRUE; 475 text_view->need_im_reset = TRUE;
475 } 476 }
476 } else { 477 } else {
477 // Ok, not handled by the IME, we can handle it. 478 // Ok, not handled by the IME, we can handle it.
478 if (event->keyval == GDK_Escape) { 479 if (event->keyval == GDK_Tab) {
480 if (model_->is_keyword_hint() && !model_->keyword().empty()) {
481 model_->AcceptKeyword();
482 } else {
483 return FALSE; // Let GtkTextView handle the tab focus change.
484 }
485 } else if (event->keyval == GDK_Escape) {
479 model_->OnEscapeKeyPressed(); 486 model_->OnEscapeKeyPressed();
480 } else { 487 } else {
481 bool alt_held = (event->state & GDK_MOD1_MASK); 488 bool alt_held = (event->state & GDK_MOD1_MASK);
482 model_->AcceptInput(alt_held ? NEW_FOREGROUND_TAB : CURRENT_TAB, false); 489 model_->AcceptInput(alt_held ? NEW_FOREGROUND_TAB : CURRENT_TAB, false);
483 } 490 }
484 } 491 }
485 return TRUE; // Don't propagate into GtkTextView. 492 return TRUE; // Don't propagate into GtkTextView.
486 } 493 }
487 494
488 return FALSE; // Propagate into GtkTextView. 495 return FALSE; // Propagate into GtkTextView.
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 const std::string& selected_text) { 751 const std::string& selected_text) {
745 GtkClipboard* clipboard = 752 GtkClipboard* clipboard =
746 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); 753 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY);
747 DCHECK(clipboard); 754 DCHECK(clipboard);
748 if (!clipboard) 755 if (!clipboard)
749 return; 756 return;
750 757
751 gtk_clipboard_set_text( 758 gtk_clipboard_set_text(
752 clipboard, selected_text.data(), selected_text.size()); 759 clipboard, selected_text.data(), selected_text.size());
753 } 760 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698