| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/bookmarks/bookmark_menu_controller_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_menu_controller_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 start_child_index < parent->child_count()); | 146 start_child_index < parent->child_count()); |
| 147 | 147 |
| 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->child_count(); ++i) { | 153 for (int i = start_child_index; i < parent->child_count(); ++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 GtkWidget* menu_item = gtk_image_menu_item_new_with_label( |
| 157 // boundaries. | 157 bookmark_utils::BuildMenuLabelFor(node).c_str()); |
| 158 string16 elided_name = l10n_util::TruncateString(node->GetTitle(), | |
| 159 kMaxChars); | |
| 160 GtkWidget* menu_item = | |
| 161 gtk_image_menu_item_new_with_label(UTF16ToUTF8(elided_name).c_str()); | |
| 162 g_object_set_data(G_OBJECT(menu_item), "bookmark-node", AsVoid(node)); | 158 g_object_set_data(G_OBJECT(menu_item), "bookmark-node", AsVoid(node)); |
| 163 SetImageMenuItem(menu_item, node, profile_->GetBookmarkModel()); | 159 SetImageMenuItem(menu_item, node, profile_->GetBookmarkModel()); |
| 164 gtk_util::SetAlwaysShowImage(menu_item); | 160 gtk_util::SetAlwaysShowImage(menu_item); |
| 165 | 161 |
| 166 signals_.Connect(menu_item, "button-release-event", | 162 signals_.Connect(menu_item, "button-release-event", |
| 167 G_CALLBACK(OnButtonReleasedThunk), this); | 163 G_CALLBACK(OnButtonReleasedThunk), this); |
| 168 if (node->is_url()) { | 164 if (node->is_url()) { |
| 169 signals_.Connect(menu_item, "activate", | 165 signals_.Connect(menu_item, "activate", |
| 170 G_CALLBACK(OnMenuItemActivatedThunk), this); | 166 G_CALLBACK(OnMenuItemActivatedThunk), this); |
| 171 } else if (node->is_folder()) { | 167 } else if (node->is_folder()) { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 } | 363 } |
| 368 | 364 |
| 369 void BookmarkMenuController::OnMenuItemDragGet( | 365 void BookmarkMenuController::OnMenuItemDragGet( |
| 370 GtkWidget* widget, GdkDragContext* context, | 366 GtkWidget* widget, GdkDragContext* context, |
| 371 GtkSelectionData* selection_data, | 367 GtkSelectionData* selection_data, |
| 372 guint target_type, guint time) { | 368 guint target_type, guint time) { |
| 373 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); | 369 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); |
| 374 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, | 370 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, |
| 375 profile_); | 371 profile_); |
| 376 } | 372 } |
| OLD | NEW |