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

Side by Side Diff: chrome/browser/gtk/find_bar_gtk.cc

Issue 660137: Allow users to close the find session and activate the current link via ctrl-... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | 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/gtk/find_bar_gtk.h" 5 #include "chrome/browser/gtk/find_bar_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include "app/gfx/gtk_util.h" 9 #include "app/gfx/gtk_util.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (!tab_contents) 532 if (!tab_contents)
533 return; 533 return;
534 534
535 std::string new_contents(gtk_entry_get_text(GTK_ENTRY(text_entry_))); 535 std::string new_contents(gtk_entry_get_text(GTK_ENTRY(text_entry_)));
536 536
537 if (new_contents.length() > 0) { 537 if (new_contents.length() > 0) {
538 tab_contents->StartFinding(UTF8ToUTF16(new_contents), forward_search, 538 tab_contents->StartFinding(UTF8ToUTF16(new_contents), forward_search,
539 false); // Not case sensitive. 539 false); // Not case sensitive.
540 } else { 540 } else {
541 // The textbox is empty so we reset. 541 // The textbox is empty so we reset.
542 tab_contents->StopFinding(true); // true = clear selection on page. 542 tab_contents->StopFinding(FindBarController::kClearSelection);
543 UpdateUIForFindResult(find_bar_controller_->tab_contents()->find_result(), 543 UpdateUIForFindResult(find_bar_controller_->tab_contents()->find_result(),
544 string16()); 544 string16());
545 } 545 }
546 } 546 }
547 547
548 void FindBarGtk::UpdateMatchLabelAppearance(bool failure) { 548 void FindBarGtk::UpdateMatchLabelAppearance(bool failure) {
549 match_label_failure_ = failure; 549 match_label_failure_ = failure;
550 bool use_gtk = theme_provider_->UseGtkTheme(); 550 bool use_gtk = theme_provider_->UseGtkTheme();
551 551
552 if (use_gtk) { 552 if (use_gtk) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 688
689 return FALSE; 689 return FALSE;
690 } 690 }
691 691
692 // static 692 // static
693 gboolean FindBarGtk::OnKeyPressEvent(GtkWidget* widget, GdkEventKey* event, 693 gboolean FindBarGtk::OnKeyPressEvent(GtkWidget* widget, GdkEventKey* event,
694 FindBarGtk* find_bar) { 694 FindBarGtk* find_bar) {
695 if (find_bar->MaybeForwardKeyEventToRenderer(event)) { 695 if (find_bar->MaybeForwardKeyEventToRenderer(event)) {
696 return TRUE; 696 return TRUE;
697 } else if (GDK_Escape == event->keyval) { 697 } else if (GDK_Escape == event->keyval) {
698 find_bar->find_bar_controller_->EndFindSession(); 698 find_bar->find_bar_controller_->EndFindSession(
699 FindBarController::kKeepSelection);
699 return TRUE; 700 return TRUE;
700 } else if (GDK_Return == event->keyval || 701 } else if (GDK_Return == event->keyval ||
701 GDK_KP_Enter == event->keyval) { 702 GDK_KP_Enter == event->keyval) {
703 if ((event->state & gtk_accelerator_get_default_mod_mask()) ==
704 GDK_CONTROL_MASK) {
705 find_bar->find_bar_controller_->EndFindSession(
706 FindBarController::kActivateSelection);
707 return TRUE;
708 }
709
702 bool forward = (event->state & gtk_accelerator_get_default_mod_mask()) != 710 bool forward = (event->state & gtk_accelerator_get_default_mod_mask()) !=
703 GDK_SHIFT_MASK; 711 GDK_SHIFT_MASK;
704 find_bar->FindEntryTextInContents(forward); 712 find_bar->FindEntryTextInContents(forward);
705 return TRUE; 713 return TRUE;
706 } 714 }
707 return FALSE; 715 return FALSE;
708 } 716 }
709 717
710 // static 718 // static
711 gboolean FindBarGtk::OnKeyReleaseEvent(GtkWidget* widget, GdkEventKey* event, 719 gboolean FindBarGtk::OnKeyReleaseEvent(GtkWidget* widget, GdkEventKey* event,
712 FindBarGtk* find_bar) { 720 FindBarGtk* find_bar) {
713 return find_bar->MaybeForwardKeyEventToRenderer(event); 721 return find_bar->MaybeForwardKeyEventToRenderer(event);
714 } 722 }
715 723
716 // static 724 // static
717 void FindBarGtk::OnClicked(GtkWidget* button, FindBarGtk* find_bar) { 725 void FindBarGtk::OnClicked(GtkWidget* button, FindBarGtk* find_bar) {
718 if (button == find_bar->close_button_->widget()) { 726 if (button == find_bar->close_button_->widget()) {
719 find_bar->find_bar_controller_->EndFindSession(); 727 find_bar->find_bar_controller_->EndFindSession(
728 FindBarController::kKeepSelection);
720 } else if (button == find_bar->find_previous_button_->widget() || 729 } else if (button == find_bar->find_previous_button_->widget() ||
721 button == find_bar->find_next_button_->widget()) { 730 button == find_bar->find_next_button_->widget()) {
722 find_bar->FindEntryTextInContents( 731 find_bar->FindEntryTextInContents(
723 button == find_bar->find_next_button_->widget()); 732 button == find_bar->find_next_button_->widget());
724 } else { 733 } else {
725 NOTREACHED(); 734 NOTREACHED();
726 } 735 }
727 } 736 }
728 737
729 // static 738 // static
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 910
902 // static 911 // static
903 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event, 912 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event,
904 FindBarGtk* find_bar) { 913 FindBarGtk* find_bar) {
905 g_signal_handlers_disconnect_by_func( 914 g_signal_handlers_disconnect_by_func(
906 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), 915 gdk_keymap_get_for_display(gtk_widget_get_display(entry)),
907 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), find_bar); 916 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), find_bar);
908 917
909 return FALSE; // Continue propagation. 918 return FALSE; // Continue propagation.
910 } 919 }
OLDNEW
« no previous file with comments | « chrome/browser/find_bar_host_browsertest.cc ('k') | chrome/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698