| 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/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/gfx/gtk_util.h" | 11 #include "base/gfx/gtk_util.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/browser/gtk/bookmark_context_menu.h" | 13 #include "chrome/browser/gtk/bookmark_context_menu.h" |
| 14 #include "chrome/browser/gtk/bookmark_utils_gtk.h" | 14 #include "chrome/browser/gtk/bookmark_utils_gtk.h" |
| 15 #include "chrome/browser/gtk/gtk_dnd_util.h" | 15 #include "chrome/browser/gtk/gtk_dnd_util.h" |
| 16 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 16 #include "chrome/browser/gtk/menu_gtk.h" | 17 #include "chrome/browser/gtk/menu_gtk.h" |
| 17 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
| 18 #include "chrome/browser/tab_contents/page_navigator.h" | 19 #include "chrome/browser/tab_contents/page_navigator.h" |
| 19 #include "chrome/common/gtk_util.h" | 20 #include "chrome/common/gtk_util.h" |
| 20 #include "grit/app_resources.h" | 21 #include "grit/app_resources.h" |
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 23 #include "webkit/glue/window_open_disposition.h" | 24 #include "webkit/glue/window_open_disposition.h" |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 BookmarkMenuController* controller) { | 218 BookmarkMenuController* controller) { |
| 218 // The parent menu item might be removed during the drag. Ref it so |button| | 219 // The parent menu item might be removed during the drag. Ref it so |button| |
| 219 // won't get destroyed. | 220 // won't get destroyed. |
| 220 g_object_ref(menu_item->parent); | 221 g_object_ref(menu_item->parent); |
| 221 | 222 |
| 222 // Signal to any future OnButtonReleased calls that we're dragging instead of | 223 // Signal to any future OnButtonReleased calls that we're dragging instead of |
| 223 // pressing. | 224 // pressing. |
| 224 controller->ignore_button_release_ = true; | 225 controller->ignore_button_release_ = true; |
| 225 | 226 |
| 226 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(menu_item); | 227 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(menu_item); |
| 227 GtkWidget* window = bookmark_utils::GetDragRepresentation(node, | 228 GtkThemeProperties properties(controller->profile_); |
| 228 controller->model_); | 229 GtkWidget* window = bookmark_utils::GetDragRepresentation( |
| 230 node, controller->model_, &properties); |
| 229 gint x, y; | 231 gint x, y; |
| 230 gtk_widget_get_pointer(menu_item, &x, &y); | 232 gtk_widget_get_pointer(menu_item, &x, &y); |
| 231 gtk_drag_set_icon_widget(drag_context, window, x, y); | 233 gtk_drag_set_icon_widget(drag_context, window, x, y); |
| 232 | 234 |
| 233 // Hide our node. | 235 // Hide our node. |
| 234 gtk_widget_hide(menu_item); | 236 gtk_widget_hide(menu_item); |
| 235 } | 237 } |
| 236 | 238 |
| 237 // static | 239 // static |
| 238 void BookmarkMenuController::OnMenuItemDragEnd( | 240 void BookmarkMenuController::OnMenuItemDragEnd( |
| 239 GtkWidget* menu_item, | 241 GtkWidget* menu_item, |
| 240 GdkDragContext* drag_context, | 242 GdkDragContext* drag_context, |
| 241 BookmarkMenuController* controller) { | 243 BookmarkMenuController* controller) { |
| 242 gtk_widget_show(menu_item); | 244 gtk_widget_show(menu_item); |
| 243 g_object_unref(menu_item->parent); | 245 g_object_unref(menu_item->parent); |
| 244 } | 246 } |
| 245 | 247 |
| 246 // static | 248 // static |
| 247 void BookmarkMenuController::OnMenuItemDragGet( | 249 void BookmarkMenuController::OnMenuItemDragGet( |
| 248 GtkWidget* widget, GdkDragContext* context, | 250 GtkWidget* widget, GdkDragContext* context, |
| 249 GtkSelectionData* selection_data, | 251 GtkSelectionData* selection_data, |
| 250 guint target_type, guint time, | 252 guint target_type, guint time, |
| 251 BookmarkMenuController* controller) { | 253 BookmarkMenuController* controller) { |
| 252 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); | 254 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); |
| 253 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, | 255 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, |
| 254 controller->profile_); | 256 controller->profile_); |
| 255 } | 257 } |
| OLD | NEW |