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

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

Issue 5339014: [gtk] tab in omnibox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better comment Created 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <algorithm> 10 #include <algorithm>
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 #if GTK_CHECK_VERSION(2, 20, 0) 506 #if GTK_CHECK_VERSION(2, 20, 0)
507 // We need to treat the text currently being composed by the input method as 507 // We need to treat the text currently being composed by the input method as
508 // part of the text content, so that omnibox can work correctly in the middle 508 // part of the text content, so that omnibox can work correctly in the middle
509 // of composition. 509 // of composition.
510 if (preedit_.size()) { 510 if (preedit_.size()) {
511 GtkTextMark* mark = gtk_text_buffer_get_insert(text_buffer_); 511 GtkTextMark* mark = gtk_text_buffer_get_insert(text_buffer_);
512 gtk_text_buffer_get_iter_at_mark(text_buffer_, &start, mark); 512 gtk_text_buffer_get_iter_at_mark(text_buffer_, &start, mark);
513 out.insert(gtk_text_iter_get_offset(&start), preedit_); 513 out.insert(gtk_text_iter_get_offset(&start), preedit_);
514 } 514 }
515 #endif 515 #endif
516
516 return out; 517 return out;
517 } 518 }
518 519
519 bool AutocompleteEditViewGtk::IsEditingOrEmpty() const { 520 bool AutocompleteEditViewGtk::IsEditingOrEmpty() const {
520 return model_->user_input_in_progress() || (GetTextLength() == 0); 521 return model_->user_input_in_progress() || (GetTextLength() == 0);
521 } 522 }
522 523
523 int AutocompleteEditViewGtk::GetIcon() const { 524 int AutocompleteEditViewGtk::GetIcon() const {
524 return IsEditingOrEmpty() ? 525 return IsEditingOrEmpty() ?
525 AutocompleteMatch::TypeToIcon(model_->CurrentTextType()) : 526 AutocompleteMatch::TypeToIcon(model_->CurrentTextType()) :
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 // of the text. Delete the selected keyword. 1379 // of the text. Delete the selected keyword.
1379 model_->ClearKeyword(GetText()); 1380 model_->ClearKeyword(GetText());
1380 1381
1381 // Stop propagating the signal emission into GtkTextView. 1382 // Stop propagating the signal emission into GtkTextView.
1382 static guint signal_id = g_signal_lookup("backspace", GTK_TYPE_TEXT_VIEW); 1383 static guint signal_id = g_signal_lookup("backspace", GTK_TYPE_TEXT_VIEW);
1383 g_signal_stop_emission(text_view_, signal_id, 0); 1384 g_signal_stop_emission(text_view_, signal_id, 0);
1384 } 1385 }
1385 1386
1386 void AutocompleteEditViewGtk::HandleViewMoveFocus(GtkWidget* widget, 1387 void AutocompleteEditViewGtk::HandleViewMoveFocus(GtkWidget* widget,
1387 GtkDirectionType direction) { 1388 GtkDirectionType direction) {
1389 if (!tab_was_pressed_)
1390 return;
1391
1392 // If special behavior is triggered, then stop the signal emission to
1393 // prevent the focus from being moved.
1394 bool handled = false;
1395
1388 // Trigger Tab to search behavior only when Tab key is pressed. 1396 // Trigger Tab to search behavior only when Tab key is pressed.
1389 if (tab_was_pressed_ && enable_tab_to_search_ && 1397 if (model_->is_keyword_hint() && !model_->keyword().empty()) {
1390 model_->is_keyword_hint() && !model_->keyword().empty()) { 1398 if (enable_tab_to_search_) {
1391 model_->AcceptKeyword(); 1399 model_->AcceptKeyword();
1400 handled = true;
1401 }
1402 } else {
1403 if (GTK_WIDGET_VISIBLE(instant_view_))
1404 controller_->OnCommitSuggestedText(GetText());
1405 else
1406 controller_->AcceptCurrentInstantPreview();
1392 1407
1393 // If Tab to search behavior is triggered, then stop the signal emission to 1408 handled = true;
James Su 2010/12/01 02:18:33 Should handled always be set to true here? Looks l
Evan Stade 2010/12/01 04:00:58 thanks for pointing that out. Fixed. I also fixed
1394 // prevent the focus from being moved. 1409 }
1410
1411 if (handled) {
1395 static guint signal_id = g_signal_lookup("move-focus", GTK_TYPE_WIDGET); 1412 static guint signal_id = g_signal_lookup("move-focus", GTK_TYPE_WIDGET);
1396 g_signal_stop_emission(widget, signal_id, 0); 1413 g_signal_stop_emission(widget, signal_id, 0);
1397 } 1414 }
1398
1399 // Propagate the signal so that focus can be moved as normal.
1400 } 1415 }
1401 1416
1402 void AutocompleteEditViewGtk::HandleCopyClipboard(GtkWidget* sender) { 1417 void AutocompleteEditViewGtk::HandleCopyClipboard(GtkWidget* sender) {
1403 HandleCopyOrCutClipboard(true); 1418 HandleCopyOrCutClipboard(true);
1404 } 1419 }
1405 1420
1406 void AutocompleteEditViewGtk::HandleCutClipboard(GtkWidget* sender) { 1421 void AutocompleteEditViewGtk::HandleCutClipboard(GtkWidget* sender) {
1407 HandleCopyOrCutClipboard(false); 1422 HandleCopyOrCutClipboard(false);
1408 } 1423 }
1409 1424
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 // baseline, so we need to move the |instant_view_| down to make sure it 1973 // baseline, so we need to move the |instant_view_| down to make sure it
1959 // has the same baseline as the |text_view_|. 1974 // has the same baseline as the |text_view_|.
1960 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 1975 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
1961 int height; 1976 int height;
1962 pango_layout_get_size(layout, NULL, &height); 1977 pango_layout_get_size(layout, NULL, &height);
1963 PangoLayoutIter* iter = pango_layout_get_iter(layout); 1978 PangoLayoutIter* iter = pango_layout_get_iter(layout);
1964 int baseline = pango_layout_iter_get_baseline(iter); 1979 int baseline = pango_layout_iter_get_baseline(iter);
1965 pango_layout_iter_free(iter); 1980 pango_layout_iter_free(iter);
1966 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 1981 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
1967 } 1982 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit.h ('k') | chrome/browser/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698