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/bookmark_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmark_bar_gtk.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "app/gtk_dnd_util.h" | |
10 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
11 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 11 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
13 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
14 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/bookmarks/bookmark_utils.h" |
15 #include "chrome/browser/browser_shutdown.h" | 14 #include "chrome/browser/browser_shutdown.h" |
16 #include "chrome/browser/importer/importer_data_types.h" | 15 #include "chrome/browser/importer/importer_data_types.h" |
17 #include "chrome/browser/metrics/user_metrics.h" | 16 #include "chrome/browser/metrics/user_metrics.h" |
18 #include "chrome/browser/ntp_background_util.h" | 17 #include "chrome/browser/ntp_background_util.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 19 matching lines...) Expand all Loading... |
39 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" | 38 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" |
40 #include "chrome/browser/ui/gtk/view_id_util.h" | 39 #include "chrome/browser/ui/gtk/view_id_util.h" |
41 #include "chrome/common/notification_service.h" | 40 #include "chrome/common/notification_service.h" |
42 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
43 #include "gfx/canvas_skia_paint.h" | 42 #include "gfx/canvas_skia_paint.h" |
44 #include "gfx/gtk_util.h" | 43 #include "gfx/gtk_util.h" |
45 #include "grit/app_resources.h" | 44 #include "grit/app_resources.h" |
46 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
47 #include "grit/theme_resources.h" | 46 #include "grit/theme_resources.h" |
48 #include "ui/base/animation/slide_animation.h" | 47 #include "ui/base/animation/slide_animation.h" |
| 48 #include "ui/base/dragdrop/gtk_dnd_util.h" |
49 | 49 |
50 namespace { | 50 namespace { |
51 | 51 |
52 // The showing height of the bar. | 52 // The showing height of the bar. |
53 const int kBookmarkBarHeight = 29; | 53 const int kBookmarkBarHeight = 29; |
54 | 54 |
55 // Padding for when the bookmark bar is floating. | 55 // Padding for when the bookmark bar is floating. |
56 const int kTopBottomNTPPadding = 12; | 56 const int kTopBottomNTPPadding = 12; |
57 const int kLeftRightNTPPadding = 8; | 57 const int kLeftRightNTPPadding = 8; |
58 | 58 |
(...skipping 10 matching lines...) Expand all Loading... |
69 const int kBookmarkBarMinimumHeight = 3; | 69 const int kBookmarkBarMinimumHeight = 3; |
70 | 70 |
71 // Left-padding for the instructional text. | 71 // Left-padding for the instructional text. |
72 const int kInstructionsPadding = 6; | 72 const int kInstructionsPadding = 6; |
73 | 73 |
74 // Padding around the "Other Bookmarks" button. | 74 // Padding around the "Other Bookmarks" button. |
75 const int kOtherBookmarksPaddingHorizontal = 2; | 75 const int kOtherBookmarksPaddingHorizontal = 2; |
76 const int kOtherBookmarksPaddingVertical = 1; | 76 const int kOtherBookmarksPaddingVertical = 1; |
77 | 77 |
78 // The targets accepted by the toolbar and folder buttons for DnD. | 78 // The targets accepted by the toolbar and folder buttons for DnD. |
79 const int kDestTargetList[] = { gtk_dnd_util::CHROME_BOOKMARK_ITEM, | 79 const int kDestTargetList[] = { ui::CHROME_BOOKMARK_ITEM, |
80 gtk_dnd_util::CHROME_NAMED_URL, | 80 ui::CHROME_NAMED_URL, |
81 gtk_dnd_util::TEXT_URI_LIST, | 81 ui::TEXT_URI_LIST, |
82 gtk_dnd_util::NETSCAPE_URL, | 82 ui::NETSCAPE_URL, |
83 gtk_dnd_util::TEXT_PLAIN, -1 }; | 83 ui::TEXT_PLAIN, -1 }; |
84 | 84 |
85 // Acceptable drag actions for the bookmark bar drag destinations. | 85 // Acceptable drag actions for the bookmark bar drag destinations. |
86 const GdkDragAction kDragAction = | 86 const GdkDragAction kDragAction = |
87 GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY); | 87 GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY); |
88 | 88 |
89 void SetToolBarStyle() { | 89 void SetToolBarStyle() { |
90 static bool style_was_set = false; | 90 static bool style_was_set = false; |
91 | 91 |
92 if (style_was_set) | 92 if (style_was_set) |
93 return; | 93 return; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 gtk_alignment_set_padding(GTK_ALIGNMENT(instructions_), 0, 0, | 205 gtk_alignment_set_padding(GTK_ALIGNMENT(instructions_), 0, 0, |
206 kInstructionsPadding, 0); | 206 kInstructionsPadding, 0); |
207 instructions_gtk_.reset(new BookmarkBarInstructionsGtk(this, profile)); | 207 instructions_gtk_.reset(new BookmarkBarInstructionsGtk(this, profile)); |
208 gtk_container_add(GTK_CONTAINER(instructions_), instructions_gtk_->widget()); | 208 gtk_container_add(GTK_CONTAINER(instructions_), instructions_gtk_->widget()); |
209 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), instructions_, | 209 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), instructions_, |
210 TRUE, TRUE, 0); | 210 TRUE, TRUE, 0); |
211 | 211 |
212 gtk_drag_dest_set(instructions_, | 212 gtk_drag_dest_set(instructions_, |
213 GtkDestDefaults(GTK_DEST_DEFAULT_DROP | GTK_DEST_DEFAULT_MOTION), | 213 GtkDestDefaults(GTK_DEST_DEFAULT_DROP | GTK_DEST_DEFAULT_MOTION), |
214 NULL, 0, kDragAction); | 214 NULL, 0, kDragAction); |
215 gtk_dnd_util::SetDestTargetList(instructions_, kDestTargetList); | 215 ui::SetDestTargetList(instructions_, kDestTargetList); |
216 g_signal_connect(instructions_, "drag-data-received", | 216 g_signal_connect(instructions_, "drag-data-received", |
217 G_CALLBACK(&OnDragReceivedThunk), this); | 217 G_CALLBACK(&OnDragReceivedThunk), this); |
218 | 218 |
219 g_signal_connect(event_box_.get(), "expose-event", | 219 g_signal_connect(event_box_.get(), "expose-event", |
220 G_CALLBACK(&OnEventBoxExposeThunk), this); | 220 G_CALLBACK(&OnEventBoxExposeThunk), this); |
221 UpdateEventBoxPaintability(); | 221 UpdateEventBoxPaintability(); |
222 | 222 |
223 bookmark_toolbar_.Own(gtk_toolbar_new()); | 223 bookmark_toolbar_.Own(gtk_toolbar_new()); |
224 SetToolBarStyle(); | 224 SetToolBarStyle(); |
225 gtk_widget_set_name(bookmark_toolbar_.get(), "chrome-bookmark-toolbar"); | 225 gtk_widget_set_name(bookmark_toolbar_.get(), "chrome-bookmark-toolbar"); |
226 gtk_util::SuppressDefaultPainting(bookmark_toolbar_.get()); | 226 gtk_util::SuppressDefaultPainting(bookmark_toolbar_.get()); |
227 g_signal_connect(bookmark_toolbar_.get(), "size-allocate", | 227 g_signal_connect(bookmark_toolbar_.get(), "size-allocate", |
228 G_CALLBACK(&OnToolbarSizeAllocateThunk), this); | 228 G_CALLBACK(&OnToolbarSizeAllocateThunk), this); |
229 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), bookmark_toolbar_.get(), | 229 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), bookmark_toolbar_.get(), |
230 TRUE, TRUE, 0); | 230 TRUE, TRUE, 0); |
231 | 231 |
232 overflow_button_ = theme_provider_->BuildChromeButton(); | 232 overflow_button_ = theme_provider_->BuildChromeButton(); |
233 g_object_set_data(G_OBJECT(overflow_button_), "left-align-popup", | 233 g_object_set_data(G_OBJECT(overflow_button_), "left-align-popup", |
234 reinterpret_cast<void*>(true)); | 234 reinterpret_cast<void*>(true)); |
235 SetOverflowButtonAppearance(); | 235 SetOverflowButtonAppearance(); |
236 ConnectFolderButtonEvents(overflow_button_, false); | 236 ConnectFolderButtonEvents(overflow_button_, false); |
237 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), overflow_button_, | 237 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), overflow_button_, |
238 FALSE, FALSE, 0); | 238 FALSE, FALSE, 0); |
239 | 239 |
240 gtk_drag_dest_set(bookmark_toolbar_.get(), GTK_DEST_DEFAULT_DROP, | 240 gtk_drag_dest_set(bookmark_toolbar_.get(), GTK_DEST_DEFAULT_DROP, |
241 NULL, 0, kDragAction); | 241 NULL, 0, kDragAction); |
242 gtk_dnd_util::SetDestTargetList(bookmark_toolbar_.get(), kDestTargetList); | 242 ui::SetDestTargetList(bookmark_toolbar_.get(), kDestTargetList); |
243 g_signal_connect(bookmark_toolbar_.get(), "drag-motion", | 243 g_signal_connect(bookmark_toolbar_.get(), "drag-motion", |
244 G_CALLBACK(&OnToolbarDragMotionThunk), this); | 244 G_CALLBACK(&OnToolbarDragMotionThunk), this); |
245 g_signal_connect(bookmark_toolbar_.get(), "drag-leave", | 245 g_signal_connect(bookmark_toolbar_.get(), "drag-leave", |
246 G_CALLBACK(&OnDragLeaveThunk), this); | 246 G_CALLBACK(&OnDragLeaveThunk), this); |
247 g_signal_connect(bookmark_toolbar_.get(), "drag-data-received", | 247 g_signal_connect(bookmark_toolbar_.get(), "drag-data-received", |
248 G_CALLBACK(&OnDragReceivedThunk), this); | 248 G_CALLBACK(&OnDragReceivedThunk), this); |
249 | 249 |
250 GtkWidget* vseparator = theme_provider_->CreateToolbarSeparator(); | 250 GtkWidget* vseparator = theme_provider_->CreateToolbarSeparator(); |
251 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), vseparator, | 251 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), vseparator, |
252 FALSE, FALSE, 0); | 252 FALSE, FALSE, 0); |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 } | 833 } |
834 | 834 |
835 GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { | 835 GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { |
836 GtkWidget* button = theme_provider_->BuildChromeButton(); | 836 GtkWidget* button = theme_provider_->BuildChromeButton(); |
837 bookmark_utils::ConfigureButtonForNode(node, model_, button, theme_provider_); | 837 bookmark_utils::ConfigureButtonForNode(node, model_, button, theme_provider_); |
838 | 838 |
839 // The tool item is also a source for dragging | 839 // The tool item is also a source for dragging |
840 gtk_drag_source_set(button, GDK_BUTTON1_MASK, NULL, 0, | 840 gtk_drag_source_set(button, GDK_BUTTON1_MASK, NULL, 0, |
841 static_cast<GdkDragAction>(GDK_ACTION_MOVE | GDK_ACTION_COPY)); | 841 static_cast<GdkDragAction>(GDK_ACTION_MOVE | GDK_ACTION_COPY)); |
842 int target_mask = bookmark_utils::GetCodeMask(node->is_folder()); | 842 int target_mask = bookmark_utils::GetCodeMask(node->is_folder()); |
843 gtk_dnd_util::SetSourceTargetListFromCodeMask(button, target_mask); | 843 ui::SetSourceTargetListFromCodeMask(button, target_mask); |
844 g_signal_connect(button, "drag-begin", | 844 g_signal_connect(button, "drag-begin", |
845 G_CALLBACK(&OnButtonDragBeginThunk), this); | 845 G_CALLBACK(&OnButtonDragBeginThunk), this); |
846 g_signal_connect(button, "drag-end", | 846 g_signal_connect(button, "drag-end", |
847 G_CALLBACK(&OnButtonDragEndThunk), this); | 847 G_CALLBACK(&OnButtonDragEndThunk), this); |
848 g_signal_connect(button, "drag-data-get", | 848 g_signal_connect(button, "drag-data-get", |
849 G_CALLBACK(&OnButtonDragGetThunk), this); | 849 G_CALLBACK(&OnButtonDragGetThunk), this); |
850 // We deliberately don't connect to "drag-data-delete" because the action of | 850 // We deliberately don't connect to "drag-data-delete" because the action of |
851 // moving a button will regenerate all the contents of the bookmarks bar | 851 // moving a button will regenerate all the contents of the bookmarks bar |
852 // anyway. | 852 // anyway. |
853 | 853 |
(...skipping 28 matching lines...) Expand all Loading... |
882 void BookmarkBarGtk::ConnectFolderButtonEvents(GtkWidget* widget, | 882 void BookmarkBarGtk::ConnectFolderButtonEvents(GtkWidget* widget, |
883 bool is_tool_item) { | 883 bool is_tool_item) { |
884 // For toolbar items (i.e. not the overflow button or other bookmarks | 884 // For toolbar items (i.e. not the overflow button or other bookmarks |
885 // button), we handle motion and highlighting manually. | 885 // button), we handle motion and highlighting manually. |
886 gtk_drag_dest_set(widget, | 886 gtk_drag_dest_set(widget, |
887 is_tool_item ? GTK_DEST_DEFAULT_DROP : | 887 is_tool_item ? GTK_DEST_DEFAULT_DROP : |
888 GTK_DEST_DEFAULT_ALL, | 888 GTK_DEST_DEFAULT_ALL, |
889 NULL, | 889 NULL, |
890 0, | 890 0, |
891 kDragAction); | 891 kDragAction); |
892 gtk_dnd_util::SetDestTargetList(widget, kDestTargetList); | 892 ui::SetDestTargetList(widget, kDestTargetList); |
893 g_signal_connect(widget, "drag-data-received", | 893 g_signal_connect(widget, "drag-data-received", |
894 G_CALLBACK(&OnDragReceivedThunk), this); | 894 G_CALLBACK(&OnDragReceivedThunk), this); |
895 if (is_tool_item) { | 895 if (is_tool_item) { |
896 g_signal_connect(widget, "drag-motion", | 896 g_signal_connect(widget, "drag-motion", |
897 G_CALLBACK(&OnFolderDragMotionThunk), this); | 897 G_CALLBACK(&OnFolderDragMotionThunk), this); |
898 g_signal_connect(widget, "drag-leave", | 898 g_signal_connect(widget, "drag-leave", |
899 G_CALLBACK(&OnDragLeaveThunk), this); | 899 G_CALLBACK(&OnDragLeaveThunk), this); |
900 } | 900 } |
901 | 901 |
902 g_signal_connect(widget, "button-press-event", | 902 g_signal_connect(widget, "button-press-event", |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 // TODO(erg): Maybe somehow figure out the real size for the drop target? | 1109 // TODO(erg): Maybe somehow figure out the real size for the drop target? |
1110 toolbar_drop_item_ = | 1110 toolbar_drop_item_ = |
1111 CreateBookmarkToolItem(model_->other_node()); | 1111 CreateBookmarkToolItem(model_->other_node()); |
1112 g_object_ref_sink(GTK_OBJECT(toolbar_drop_item_)); | 1112 g_object_ref_sink(GTK_OBJECT(toolbar_drop_item_)); |
1113 } | 1113 } |
1114 } | 1114 } |
1115 | 1115 |
1116 gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(bookmark_toolbar_.get()), | 1116 gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(bookmark_toolbar_.get()), |
1117 GTK_TOOL_ITEM(toolbar_drop_item_), | 1117 GTK_TOOL_ITEM(toolbar_drop_item_), |
1118 index); | 1118 index); |
1119 if (target_type == | 1119 if (target_type == ui::GetAtomForTarget(ui::CHROME_BOOKMARK_ITEM)) { |
1120 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_BOOKMARK_ITEM)) { | |
1121 gdk_drag_status(context, GDK_ACTION_MOVE, time); | 1120 gdk_drag_status(context, GDK_ACTION_MOVE, time); |
1122 } else { | 1121 } else { |
1123 gdk_drag_status(context, GDK_ACTION_COPY, time); | 1122 gdk_drag_status(context, GDK_ACTION_COPY, time); |
1124 } | 1123 } |
1125 | 1124 |
1126 return TRUE; | 1125 return TRUE; |
1127 } | 1126 } |
1128 | 1127 |
1129 gboolean BookmarkBarGtk::OnToolbarDragMotion(GtkWidget* toolbar, | 1128 gboolean BookmarkBarGtk::OnToolbarDragMotion(GtkWidget* toolbar, |
1130 GdkDragContext* context, | 1129 GdkDragContext* context, |
(...skipping 25 matching lines...) Expand all Loading... |
1156 GdkAtom target_type = gtk_drag_dest_find_target(button, context, NULL); | 1155 GdkAtom target_type = gtk_drag_dest_find_target(button, context, NULL); |
1157 if (target_type == GDK_NONE) | 1156 if (target_type == GDK_NONE) |
1158 return FALSE; | 1157 return FALSE; |
1159 | 1158 |
1160 int index = GetToolbarIndexForDragOverFolder(button, x); | 1159 int index = GetToolbarIndexForDragOverFolder(button, x); |
1161 if (index < 0) { | 1160 if (index < 0) { |
1162 ClearToolbarDropHighlighting(); | 1161 ClearToolbarDropHighlighting(); |
1163 | 1162 |
1164 // Drag is over middle of folder. | 1163 // Drag is over middle of folder. |
1165 gtk_drag_highlight(button); | 1164 gtk_drag_highlight(button); |
1166 if (target_type == | 1165 if (target_type == ui::GetAtomForTarget(ui::CHROME_BOOKMARK_ITEM)) { |
1167 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_BOOKMARK_ITEM)) { | |
1168 gdk_drag_status(context, GDK_ACTION_MOVE, time); | 1166 gdk_drag_status(context, GDK_ACTION_MOVE, time); |
1169 } else { | 1167 } else { |
1170 gdk_drag_status(context, GDK_ACTION_COPY, time); | 1168 gdk_drag_status(context, GDK_ACTION_COPY, time); |
1171 } | 1169 } |
1172 | 1170 |
1173 return TRUE; | 1171 return TRUE; |
1174 } | 1172 } |
1175 | 1173 |
1176 // Remove previous highlighting. | 1174 // Remove previous highlighting. |
1177 gtk_drag_unhighlight(button); | 1175 gtk_drag_unhighlight(button); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 index = 0; | 1228 index = 0; |
1231 } else { | 1229 } else { |
1232 index = GetToolbarIndexForDragOverFolder(widget, x); | 1230 index = GetToolbarIndexForDragOverFolder(widget, x); |
1233 if (index < 0) { | 1231 if (index < 0) { |
1234 dest_node = GetNodeForToolButton(widget); | 1232 dest_node = GetNodeForToolButton(widget); |
1235 index = dest_node->GetChildCount(); | 1233 index = dest_node->GetChildCount(); |
1236 } | 1234 } |
1237 } | 1235 } |
1238 | 1236 |
1239 switch (target_type) { | 1237 switch (target_type) { |
1240 case gtk_dnd_util::CHROME_BOOKMARK_ITEM: { | 1238 case ui::CHROME_BOOKMARK_ITEM: { |
1241 std::vector<const BookmarkNode*> nodes = | 1239 std::vector<const BookmarkNode*> nodes = |
1242 bookmark_utils::GetNodesFromSelection(context, selection_data, | 1240 bookmark_utils::GetNodesFromSelection(context, selection_data, |
1243 target_type, | 1241 target_type, |
1244 profile_, | 1242 profile_, |
1245 &delete_selection_data, | 1243 &delete_selection_data, |
1246 &dnd_success); | 1244 &dnd_success); |
1247 DCHECK(!nodes.empty()); | 1245 DCHECK(!nodes.empty()); |
1248 for (std::vector<const BookmarkNode*>::iterator it = nodes.begin(); | 1246 for (std::vector<const BookmarkNode*>::iterator it = nodes.begin(); |
1249 it != nodes.end(); ++it) { | 1247 it != nodes.end(); ++it) { |
1250 model_->Move(*it, dest_node, index); | 1248 model_->Move(*it, dest_node, index); |
1251 index = dest_node->IndexOfChild(*it) + 1; | 1249 index = dest_node->IndexOfChild(*it) + 1; |
1252 } | 1250 } |
1253 break; | 1251 break; |
1254 } | 1252 } |
1255 | 1253 |
1256 case gtk_dnd_util::CHROME_NAMED_URL: { | 1254 case ui::CHROME_NAMED_URL: { |
1257 dnd_success = bookmark_utils::CreateNewBookmarkFromNamedUrl( | 1255 dnd_success = bookmark_utils::CreateNewBookmarkFromNamedUrl( |
1258 selection_data, model_, dest_node, index); | 1256 selection_data, model_, dest_node, index); |
1259 break; | 1257 break; |
1260 } | 1258 } |
1261 | 1259 |
1262 case gtk_dnd_util::TEXT_URI_LIST: { | 1260 case ui::TEXT_URI_LIST: { |
1263 dnd_success = bookmark_utils::CreateNewBookmarksFromURIList( | 1261 dnd_success = bookmark_utils::CreateNewBookmarksFromURIList( |
1264 selection_data, model_, dest_node, index); | 1262 selection_data, model_, dest_node, index); |
1265 break; | 1263 break; |
1266 } | 1264 } |
1267 | 1265 |
1268 case gtk_dnd_util::NETSCAPE_URL: { | 1266 case ui::NETSCAPE_URL: { |
1269 dnd_success = bookmark_utils::CreateNewBookmarkFromNetscapeURL( | 1267 dnd_success = bookmark_utils::CreateNewBookmarkFromNetscapeURL( |
1270 selection_data, model_, dest_node, index); | 1268 selection_data, model_, dest_node, index); |
1271 break; | 1269 break; |
1272 } | 1270 } |
1273 | 1271 |
1274 case gtk_dnd_util::TEXT_PLAIN: { | 1272 case ui::TEXT_PLAIN: { |
1275 guchar* text = gtk_selection_data_get_text(selection_data); | 1273 guchar* text = gtk_selection_data_get_text(selection_data); |
1276 if (!text) | 1274 if (!text) |
1277 break; | 1275 break; |
1278 GURL url(reinterpret_cast<char*>(text)); | 1276 GURL url(reinterpret_cast<char*>(text)); |
1279 g_free(text); | 1277 g_free(text); |
1280 // TODO(estade): It would be nice to head this case off at drag motion, | 1278 // TODO(estade): It would be nice to head this case off at drag motion, |
1281 // so that it doesn't look like we can drag onto the bookmark bar. | 1279 // so that it doesn't look like we can drag onto the bookmark bar. |
1282 if (!url.is_valid()) | 1280 if (!url.is_valid()) |
1283 break; | 1281 break; |
1284 std::string title = bookmark_utils::GetNameForURL(url); | 1282 std::string title = bookmark_utils::GetNameForURL(url); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 | 1407 |
1410 // Find the GtkWidget* for the actual target button. | 1408 // Find the GtkWidget* for the actual target button. |
1411 int shift = dir == GTK_MENU_DIR_PARENT ? -1 : 1; | 1409 int shift = dir == GTK_MENU_DIR_PARENT ? -1 : 1; |
1412 button_idx = (button_idx + shift + folder_list.size()) % folder_list.size(); | 1410 button_idx = (button_idx + shift + folder_list.size()) % folder_list.size(); |
1413 PopupForButton(folder_list[button_idx]); | 1411 PopupForButton(folder_list[button_idx]); |
1414 } | 1412 } |
1415 | 1413 |
1416 void BookmarkBarGtk::CloseMenu() { | 1414 void BookmarkBarGtk::CloseMenu() { |
1417 current_context_menu_->Cancel(); | 1415 current_context_menu_->Cancel(); |
1418 } | 1416 } |
OLD | NEW |