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

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

Issue 5742006: wstrings: make l10n_util::TruncateString use string16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/gtk/bookmark_menu_controller_gtk.h" 5 #include "chrome/browser/gtk/bookmark_menu_controller_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/gtk_dnd_util.h" 9 #include "app/gtk_dnd_util.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 signals_.Connect(menu, "button-press-event", 148 signals_.Connect(menu, "button-press-event",
149 G_CALLBACK(OnMenuButtonPressedOrReleasedThunk), this); 149 G_CALLBACK(OnMenuButtonPressedOrReleasedThunk), this);
150 signals_.Connect(menu, "button-release-event", 150 signals_.Connect(menu, "button-release-event",
151 G_CALLBACK(OnMenuButtonPressedOrReleasedThunk), this); 151 G_CALLBACK(OnMenuButtonPressedOrReleasedThunk), this);
152 152
153 for (int i = start_child_index; i < parent->GetChildCount(); ++i) { 153 for (int i = start_child_index; i < parent->GetChildCount(); ++i) {
154 const BookmarkNode* node = parent->GetChild(i); 154 const BookmarkNode* node = parent->GetChild(i);
155 155
156 // This breaks on word boundaries. Ideally we would break on character 156 // This breaks on word boundaries. Ideally we would break on character
157 // boundaries. 157 // boundaries.
158 std::string elided_name = WideToUTF8( 158 string16 elided_name = l10n_util::TruncateString(node->GetTitle(),
159 l10n_util::TruncateString(UTF16ToWideHack(node->GetTitle()), 159 kMaxChars);
160 kMaxChars));
161 GtkWidget* menu_item = 160 GtkWidget* menu_item =
162 gtk_image_menu_item_new_with_label(elided_name.c_str()); 161 gtk_image_menu_item_new_with_label(UTF16ToUTF8(elided_name).c_str());
163 g_object_set_data(G_OBJECT(menu_item), "bookmark-node", AsVoid(node)); 162 g_object_set_data(G_OBJECT(menu_item), "bookmark-node", AsVoid(node));
164 SetImageMenuItem(menu_item, node, profile_->GetBookmarkModel()); 163 SetImageMenuItem(menu_item, node, profile_->GetBookmarkModel());
165 gtk_util::SetAlwaysShowImage(menu_item); 164 gtk_util::SetAlwaysShowImage(menu_item);
166 165
167 signals_.Connect(menu_item, "button-release-event", 166 signals_.Connect(menu_item, "button-release-event",
168 G_CALLBACK(OnButtonReleasedThunk), this); 167 G_CALLBACK(OnButtonReleasedThunk), this);
169 if (node->is_url()) { 168 if (node->is_url()) {
170 signals_.Connect(menu_item, "activate", 169 signals_.Connect(menu_item, "activate",
171 G_CALLBACK(OnMenuItemActivatedThunk), this); 170 G_CALLBACK(OnMenuItemActivatedThunk), this);
172 } else if (node->is_folder()) { 171 } else if (node->is_folder()) {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 366 }
368 367
369 void BookmarkMenuController::OnMenuItemDragGet( 368 void BookmarkMenuController::OnMenuItemDragGet(
370 GtkWidget* widget, GdkDragContext* context, 369 GtkWidget* widget, GdkDragContext* context,
371 GtkSelectionData* selection_data, 370 GtkSelectionData* selection_data,
372 guint target_type, guint time) { 371 guint target_type, guint time) {
373 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); 372 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget);
374 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, 373 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type,
375 profile_); 374 profile_);
376 } 375 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_menu_manager.cc ('k') | chrome/browser/gtk/bookmark_utils_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698