| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 14 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
| 15 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 15 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | |
| 17 #include "chrome/browser/ui/gtk/gtk_util.h" | 16 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 18 #include "chrome/browser/ui/gtk/menu_gtk.h" | 17 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 18 #include "chrome/browser/ui/gtk/theme_service_gtk.h" |
| 19 #include "content/public/browser/page_navigator.h" | 19 #include "content/public/browser/page_navigator.h" |
| 20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 22 #include "grit/ui_resources.h" | 22 #include "grit/ui_resources.h" |
| 23 #include "ui/base/dragdrop/gtk_dnd_util.h" | 23 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/gfx/gtk_util.h" | 25 #include "ui/gfx/gtk_util.h" |
| 26 #include "webkit/glue/window_open_disposition.h" | 26 #include "webkit/glue/window_open_disposition.h" |
| 27 | 27 |
| 28 using content::OpenURLParams; | 28 using content::OpenURLParams; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // The parent menu item might be removed during the drag. Ref it so |button| | 335 // The parent menu item might be removed during the drag. Ref it so |button| |
| 336 // won't get destroyed. | 336 // won't get destroyed. |
| 337 g_object_ref(menu_item->parent); | 337 g_object_ref(menu_item->parent); |
| 338 | 338 |
| 339 // Signal to any future OnButtonReleased calls that we're dragging instead of | 339 // Signal to any future OnButtonReleased calls that we're dragging instead of |
| 340 // pressing. | 340 // pressing. |
| 341 ignore_button_release_ = true; | 341 ignore_button_release_ = true; |
| 342 | 342 |
| 343 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(menu_item); | 343 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(menu_item); |
| 344 drag_icon_ = bookmark_utils::GetDragRepresentationForNode( | 344 drag_icon_ = bookmark_utils::GetDragRepresentationForNode( |
| 345 node, model_, GtkThemeService::GetFrom(profile_)); | 345 node, model_, ThemeServiceGtk::GetFrom(profile_)); |
| 346 gint x, y; | 346 gint x, y; |
| 347 gtk_widget_get_pointer(menu_item, &x, &y); | 347 gtk_widget_get_pointer(menu_item, &x, &y); |
| 348 gtk_drag_set_icon_widget(drag_context, drag_icon_, x, y); | 348 gtk_drag_set_icon_widget(drag_context, drag_icon_, x, y); |
| 349 | 349 |
| 350 // Hide our node. | 350 // Hide our node. |
| 351 gtk_widget_hide(menu_item); | 351 gtk_widget_hide(menu_item); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void BookmarkMenuController::OnMenuItemDragEnd(GtkWidget* menu_item, | 354 void BookmarkMenuController::OnMenuItemDragEnd(GtkWidget* menu_item, |
| 355 GdkDragContext* drag_context) { | 355 GdkDragContext* drag_context) { |
| 356 gtk_widget_show(menu_item); | 356 gtk_widget_show(menu_item); |
| 357 g_object_unref(menu_item->parent); | 357 g_object_unref(menu_item->parent); |
| 358 | 358 |
| 359 gtk_widget_destroy(drag_icon_); | 359 gtk_widget_destroy(drag_icon_); |
| 360 drag_icon_ = NULL; | 360 drag_icon_ = NULL; |
| 361 } | 361 } |
| 362 | 362 |
| 363 void BookmarkMenuController::OnMenuItemDragGet( | 363 void BookmarkMenuController::OnMenuItemDragGet( |
| 364 GtkWidget* widget, GdkDragContext* context, | 364 GtkWidget* widget, GdkDragContext* context, |
| 365 GtkSelectionData* selection_data, | 365 GtkSelectionData* selection_data, |
| 366 guint target_type, guint time) { | 366 guint target_type, guint time) { |
| 367 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); | 367 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); |
| 368 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, | 368 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, |
| 369 profile_); | 369 profile_); |
| 370 } | 370 } |
| OLD | NEW |