| 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/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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 const BookmarkNode* node = parent->GetChild(i); | 156 const BookmarkNode* node = parent->GetChild(i); |
| 157 | 157 |
| 158 // This breaks on word boundaries. Ideally we would break on character | 158 // This breaks on word boundaries. Ideally we would break on character |
| 159 // boundaries. | 159 // boundaries. |
| 160 std::wstring elided_name = | 160 std::wstring elided_name = |
| 161 l10n_util::TruncateString(node->GetTitle(), kMaxChars); | 161 l10n_util::TruncateString(node->GetTitle(), kMaxChars); |
| 162 GtkWidget* menu_item = | 162 GtkWidget* menu_item = |
| 163 gtk_image_menu_item_new_with_label(WideToUTF8(elided_name).c_str()); | 163 gtk_image_menu_item_new_with_label(WideToUTF8(elided_name).c_str()); |
| 164 g_object_set_data(G_OBJECT(menu_item), "bookmark-node", AsVoid(node)); | 164 g_object_set_data(G_OBJECT(menu_item), "bookmark-node", AsVoid(node)); |
| 165 SetImageMenuItem(menu_item, node, profile_->GetBookmarkModel()); | 165 SetImageMenuItem(menu_item, node, profile_->GetBookmarkModel()); |
| 166 gtk_util::SetAlwaysShowImage(menu_item); |
| 166 | 167 |
| 167 if (node->is_url()) { | 168 if (node->is_url()) { |
| 168 g_signal_connect(G_OBJECT(menu_item), "activate", | 169 g_signal_connect(G_OBJECT(menu_item), "activate", |
| 169 G_CALLBACK(OnMenuItemActivated), this); | 170 G_CALLBACK(OnMenuItemActivated), this); |
| 170 g_signal_connect(G_OBJECT(menu_item), "button-release-event", | 171 g_signal_connect(G_OBJECT(menu_item), "button-release-event", |
| 171 G_CALLBACK(OnButtonReleased), this); | 172 G_CALLBACK(OnButtonReleased), this); |
| 172 } else if (node->is_folder()) { | 173 } else if (node->is_folder()) { |
| 173 GtkWidget* submenu = gtk_menu_new(); | 174 GtkWidget* submenu = gtk_menu_new(); |
| 174 BuildMenu(node, 0, submenu); | 175 BuildMenu(node, 0, submenu); |
| 175 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu); | 176 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // static | 339 // static |
| 339 void BookmarkMenuController::OnMenuItemDragGet( | 340 void BookmarkMenuController::OnMenuItemDragGet( |
| 340 GtkWidget* widget, GdkDragContext* context, | 341 GtkWidget* widget, GdkDragContext* context, |
| 341 GtkSelectionData* selection_data, | 342 GtkSelectionData* selection_data, |
| 342 guint target_type, guint time, | 343 guint target_type, guint time, |
| 343 BookmarkMenuController* controller) { | 344 BookmarkMenuController* controller) { |
| 344 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); | 345 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); |
| 345 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, | 346 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, |
| 346 controller->profile_); | 347 controller->profile_); |
| 347 } | 348 } |
| OLD | NEW |