| 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/custom_drag.h" | 5 #include "chrome/browser/ui/gtk/custom_drag.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 9 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
| 10 #include "content/public/browser/download_item.h" | 10 #include "content/public/browser/download_item.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 gdk_event_free(event); | 61 gdk_event_free(event); |
| 62 gtk_target_list_unref(list); | 62 gtk_target_list_unref(list); |
| 63 } | 63 } |
| 64 | 64 |
| 65 CustomDrag::~CustomDrag() { | 65 CustomDrag::~CustomDrag() { |
| 66 gtk_widget_destroy(drag_widget_); | 66 gtk_widget_destroy(drag_widget_); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void CustomDrag::OnDragBegin(GtkWidget* widget, GdkDragContext* drag_context) { | 69 void CustomDrag::OnDragBegin(GtkWidget* widget, GdkDragContext* drag_context) { |
| 70 if (image_) | 70 if (image_) |
| 71 gtk_drag_set_icon_pixbuf(drag_context, *image_, 0, 0); | 71 gtk_drag_set_icon_pixbuf(drag_context, image_->ToGdkPixbuf(), 0, 0); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void CustomDrag::OnDragEnd(GtkWidget* widget, GdkDragContext* drag_context) { | 74 void CustomDrag::OnDragEnd(GtkWidget* widget, GdkDragContext* drag_context) { |
| 75 delete this; | 75 delete this; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // DownloadItemDrag ------------------------------------------------------------ | 78 // DownloadItemDrag ------------------------------------------------------------ |
| 79 | 79 |
| 80 DownloadItemDrag::DownloadItemDrag(const DownloadItem* item, | 80 DownloadItemDrag::DownloadItemDrag(const DownloadItem* item, |
| 81 gfx::Image* icon) | 81 gfx::Image* icon) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 104 // Disconnect previous signal handlers, if any. | 104 // Disconnect previous signal handlers, if any. |
| 105 g_signal_handlers_disconnect_by_func( | 105 g_signal_handlers_disconnect_by_func( |
| 106 widget, | 106 widget, |
| 107 reinterpret_cast<gpointer>(OnDragDataGetStandalone), | 107 reinterpret_cast<gpointer>(OnDragDataGetStandalone), |
| 108 item); | 108 item); |
| 109 // Connect new signal handlers. | 109 // Connect new signal handlers. |
| 110 g_signal_connect(widget, "drag-data-get", | 110 g_signal_connect(widget, "drag-data-get", |
| 111 G_CALLBACK(OnDragDataGetStandalone), item); | 111 G_CALLBACK(OnDragDataGetStandalone), item); |
| 112 | 112 |
| 113 if (icon) | 113 if (icon) |
| 114 gtk_drag_source_set_icon_pixbuf(widget, *icon); | 114 gtk_drag_source_set_icon_pixbuf(widget, icon->ToGdkPixbuf()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // static | 117 // static |
| 118 void DownloadItemDrag::BeginDrag(const DownloadItem* item, gfx::Image* icon) { | 118 void DownloadItemDrag::BeginDrag(const DownloadItem* item, gfx::Image* icon) { |
| 119 new DownloadItemDrag(item, icon); | 119 new DownloadItemDrag(item, icon); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // BookmarkDrag ---------------------------------------------------------------- | 122 // BookmarkDrag ---------------------------------------------------------------- |
| 123 | 123 |
| 124 BookmarkDrag::BookmarkDrag(Profile* profile, | 124 BookmarkDrag::BookmarkDrag(Profile* profile, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 138 guint target_type, guint time) { | 138 guint target_type, guint time) { |
| 139 bookmark_utils::WriteBookmarksToSelection(nodes_, selection_data, | 139 bookmark_utils::WriteBookmarksToSelection(nodes_, selection_data, |
| 140 target_type, profile_); | 140 target_type, profile_); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // static | 143 // static |
| 144 void BookmarkDrag::BeginDrag(Profile* profile, | 144 void BookmarkDrag::BeginDrag(Profile* profile, |
| 145 const std::vector<const BookmarkNode*>& nodes) { | 145 const std::vector<const BookmarkNode*>& nodes) { |
| 146 new BookmarkDrag(profile, nodes); | 146 new BookmarkDrag(profile, nodes); |
| 147 } | 147 } |
| OLD | NEW |