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

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

Issue 175004: Ellipsize long entries in bookmark menus and the back/forward menus.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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) 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/go_button_gtk.h" 5 #include "chrome/browser/gtk/go_button_gtk.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
11 #include "chrome/browser/browser.h" 11 #include "chrome/browser/browser.h"
12 #include "chrome/browser/gtk/gtk_chrome_button.h" 12 #include "chrome/browser/gtk/gtk_chrome_button.h"
13 #include "chrome/browser/gtk/gtk_theme_provider.h" 13 #include "chrome/browser/gtk/gtk_theme_provider.h"
14 #include "chrome/browser/gtk/location_bar_view_gtk.h" 14 #include "chrome/browser/gtk/location_bar_view_gtk.h"
15 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
16 #include "chrome/browser/search_engines/template_url_model.h" 16 #include "chrome/browser/search_engines/template_url_model.h"
17 #include "chrome/common/gtk_util.h" 17 #include "chrome/common/gtk_util.h"
18 #include "chrome/common/notification_service.h" 18 #include "chrome/common/notification_service.h"
19 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
21 21
22 // Limit the length of the tooltip text. This applies only to the text in the
23 // omnibox (e.g. X in "Go to X");
24 const size_t kMaxTooltipTextLength = 400;
25
22 GoButtonGtk::GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser) 26 GoButtonGtk::GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser)
23 : location_bar_(location_bar), 27 : location_bar_(location_bar),
24 browser_(browser), 28 browser_(browser),
25 button_delay_(0), 29 button_delay_(0),
26 stop_timer_(this), 30 stop_timer_(this),
27 intended_mode_(MODE_GO), 31 intended_mode_(MODE_GO),
28 visible_mode_(MODE_GO), 32 visible_mode_(MODE_GO),
29 state_(BS_NORMAL), 33 state_(BS_NORMAL),
30 theme_provider_(browser ? 34 theme_provider_(browser ?
31 GtkThemeProvider::GetFrom(browser->profile()) : NULL), 35 GtkThemeProvider::GetFrom(browser->profile()) : NULL),
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 gboolean GoButtonGtk::OnQueryTooltip(GtkTooltip* tooltip) { 190 gboolean GoButtonGtk::OnQueryTooltip(GtkTooltip* tooltip) {
187 // |location_bar_| can be NULL in tests. 191 // |location_bar_| can be NULL in tests.
188 if (!location_bar_) 192 if (!location_bar_)
189 return FALSE; 193 return FALSE;
190 194
191 std::string text; 195 std::string text;
192 if (visible_mode_ == MODE_GO) { 196 if (visible_mode_ == MODE_GO) {
193 std::wstring current_text_wstr(location_bar_->location_entry()->GetText()); 197 std::wstring current_text_wstr(location_bar_->location_entry()->GetText());
194 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) 198 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
195 l10n_util::WrapStringWithLTRFormatting(&current_text_wstr); 199 l10n_util::WrapStringWithLTRFormatting(&current_text_wstr);
196 string16 current_text = WideToUTF16Hack(current_text_wstr); 200 string16 current_text = WideToUTF16Hack(
201 l10n_util::TruncateString(current_text_wstr, kMaxTooltipTextLength));
197 202
198 AutocompleteEditModel* edit_model = 203 AutocompleteEditModel* edit_model =
199 location_bar_->location_entry()->model(); 204 location_bar_->location_entry()->model();
200 if (edit_model->CurrentTextIsURL()) { 205 if (edit_model->CurrentTextIsURL()) {
201 text = l10n_util::GetStringFUTF8(IDS_TOOLTIP_GO_SITE, current_text); 206 text = l10n_util::GetStringFUTF8(IDS_TOOLTIP_GO_SITE, current_text);
202 } else { 207 } else {
203 std::wstring keyword(edit_model->keyword()); 208 std::wstring keyword(edit_model->keyword());
204 TemplateURLModel* template_url_model = 209 TemplateURLModel* template_url_model =
205 browser_->profile()->GetTemplateURLModel(); 210 browser_->profile()->GetTemplateURLModel();
206 const TemplateURL* provider = 211 const TemplateURL* provider =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 gdk_pixbuf_get_height(go_.pixbufs(0))); 250 gdk_pixbuf_get_height(go_.pixbufs(0)));
246 251
247 gtk_widget_set_app_paintable(widget_.get(), TRUE); 252 gtk_widget_set_app_paintable(widget_.get(), TRUE);
248 // We effectively double-buffer by virtue of having only one image... 253 // We effectively double-buffer by virtue of having only one image...
249 gtk_widget_set_double_buffered(widget_.get(), FALSE); 254 gtk_widget_set_double_buffered(widget_.get(), FALSE);
250 } 255 }
251 256
252 gtk_chrome_button_set_use_gtk_rendering( 257 gtk_chrome_button_set_use_gtk_rendering(
253 GTK_CHROME_BUTTON(widget_.get()), use_gtk); 258 GTK_CHROME_BUTTON(widget_.get()), use_gtk);
254 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698