OLD | NEW |
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/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/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/gfx/gtk_util.h" | 10 #include "base/gfx/gtk_util.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // Padding around the container. | 29 // Padding around the container. |
30 const int kBarPaddingTopBottom = 4; | 30 const int kBarPaddingTopBottom = 4; |
31 const int kEntryPaddingLeft = 6; | 31 const int kEntryPaddingLeft = 6; |
32 const int kCloseButtonPaddingLeft = 3; | 32 const int kCloseButtonPaddingLeft = 3; |
33 const int kBarPaddingRight = 4; | 33 const int kBarPaddingRight = 4; |
34 | 34 |
35 // The height of the findbar dialog, as dictated by the size of the background | 35 // The height of the findbar dialog, as dictated by the size of the background |
36 // images. | 36 // images. |
37 const int kFindBarHeight = 32; | 37 const int kFindBarHeight = 32; |
38 | 38 |
| 39 // The width of the text entry field. |
| 40 const int kTextEntryWidth = 220; |
| 41 |
39 // Get the ninebox that draws the background of |container_|. It is also used | 42 // Get the ninebox that draws the background of |container_|. It is also used |
40 // to change the shape of |container_|. The pointer is shared by all instances | 43 // to change the shape of |container_|. The pointer is shared by all instances |
41 // of FindBarGtk. | 44 // of FindBarGtk. |
42 const NineBox* GetDialogBackground() { | 45 const NineBox* GetDialogBackground() { |
43 static NineBox* dialog_background = NULL; | 46 static NineBox* dialog_background = NULL; |
44 if (!dialog_background) { | 47 if (!dialog_background) { |
45 dialog_background = new NineBox( | 48 dialog_background = new NineBox( |
46 IDR_FIND_DLG_LEFT_BACKGROUND, | 49 IDR_FIND_DLG_LEFT_BACKGROUND, |
47 IDR_FIND_DLG_MIDDLE_BACKGROUND, | 50 IDR_FIND_DLG_MIDDLE_BACKGROUND, |
48 IDR_FIND_DLG_RIGHT_BACKGROUND, | 51 IDR_FIND_DLG_RIGHT_BACKGROUND, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 G_CALLBACK(OnClicked), this); | 151 G_CALLBACK(OnClicked), this); |
149 gtk_widget_set_tooltip_text(find_previous_button_->widget(), | 152 gtk_widget_set_tooltip_text(find_previous_button_->widget(), |
150 l10n_util::GetStringUTF8(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP).c_str()); | 153 l10n_util::GetStringUTF8(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP).c_str()); |
151 gtk_box_pack_end(GTK_BOX(hbox), find_previous_button_->widget(), | 154 gtk_box_pack_end(GTK_BOX(hbox), find_previous_button_->widget(), |
152 FALSE, FALSE, 0); | 155 FALSE, FALSE, 0); |
153 | 156 |
154 // Make a box for the edit and match count widgets. This is fixed size since | 157 // Make a box for the edit and match count widgets. This is fixed size since |
155 // we want the widgets inside to resize themselves rather than making the | 158 // we want the widgets inside to resize themselves rather than making the |
156 // dialog bigger. | 159 // dialog bigger. |
157 GtkWidget* content_hbox = gtk_hbox_new(false, 0); | 160 GtkWidget* content_hbox = gtk_hbox_new(false, 0); |
158 gtk_widget_set_size_request(content_hbox, 300, -1); | 161 gtk_widget_set_size_request(content_hbox, kTextEntryWidth, -1); |
159 | 162 |
160 text_entry_ = gtk_entry_new(); | 163 text_entry_ = gtk_entry_new(); |
161 match_count_label_ = gtk_label_new(NULL); | 164 match_count_label_ = gtk_label_new(NULL); |
162 | 165 |
163 // Force the text widget height so it lines up with the buttons regardless of | 166 // Force the text widget height so it lines up with the buttons regardless of |
164 // font size. | 167 // font size. |
165 gtk_widget_set_size_request(text_entry_, -1, 20); | 168 gtk_widget_set_size_request(text_entry_, -1, 20); |
166 gtk_entry_set_has_frame(GTK_ENTRY(text_entry_), FALSE); | 169 gtk_entry_set_has_frame(GTK_ENTRY(text_entry_), FALSE); |
167 | 170 |
168 gtk_box_pack_end(GTK_BOX(content_hbox), match_count_label_, FALSE, FALSE, 0); | 171 gtk_box_pack_end(GTK_BOX(content_hbox), match_count_label_, FALSE, FALSE, 0); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } | 412 } |
410 | 413 |
411 // static | 414 // static |
412 gboolean FindBarGtk::OnButtonPress(GtkWidget* text_entry, GdkEventButton* e, | 415 gboolean FindBarGtk::OnButtonPress(GtkWidget* text_entry, GdkEventButton* e, |
413 FindBarGtk* find_bar) { | 416 FindBarGtk* find_bar) { |
414 find_bar->StoreOutsideFocus(); | 417 find_bar->StoreOutsideFocus(); |
415 | 418 |
416 // Continue propagating the event. | 419 // Continue propagating the event. |
417 return FALSE; | 420 return FALSE; |
418 } | 421 } |
OLD | NEW |