Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: chrome/browser/ui/gtk/custom_drag.cc

Issue 6250014: Move more dnd related files to ui/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/gtk/custom_drag.h" 5 #include "chrome/browser/gtk/custom_drag.h"
6 6
7 #include "app/gtk_dnd_util.h"
8 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/download/download_item.h" 8 #include "chrome/browser/download/download_item.h"
10 #include "chrome/browser/gtk/bookmark_utils_gtk.h" 9 #include "chrome/browser/gtk/bookmark_utils_gtk.h"
11 #include "gfx/gtk_util.h" 10 #include "gfx/gtk_util.h"
12 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
13 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/base/dragdrop/gtk_dnd_util.h"
15 15
16 namespace { 16 namespace {
17 17
18 const int kDownloadItemCodeMask = gtk_dnd_util::TEXT_URI_LIST | 18 const int kDownloadItemCodeMask = ui::TEXT_URI_LIST | ui::CHROME_NAMED_URL;
19 gtk_dnd_util::CHROME_NAMED_URL;
20 const GdkDragAction kDownloadItemDragAction = GDK_ACTION_COPY; 19 const GdkDragAction kDownloadItemDragAction = GDK_ACTION_COPY;
21 const GdkDragAction kBookmarkDragAction = 20 const GdkDragAction kBookmarkDragAction =
22 static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE); 21 static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE);
23 22
24 void OnDragDataGetForDownloadItem(GtkSelectionData* selection_data, 23 void OnDragDataGetForDownloadItem(GtkSelectionData* selection_data,
25 guint target_type, 24 guint target_type,
26 const DownloadItem* download_item) { 25 const DownloadItem* download_item) {
27 GURL url = net::FilePathToFileURL(download_item->full_path()); 26 GURL url = net::FilePathToFileURL(download_item->full_path());
28 gtk_dnd_util::WriteURLWithName(selection_data, url, 27 ui::WriteURLWithName(selection_data, url,
29 UTF8ToUTF16(download_item->GetFileNameToReportUser().value()), 28 UTF8ToUTF16(download_item->GetFileNameToReportUser().value()),
30 target_type); 29 target_type);
31 } 30 }
32 31
33 void OnDragDataGetStandalone(GtkWidget* widget, GdkDragContext* context, 32 void OnDragDataGetStandalone(GtkWidget* widget, GdkDragContext* context,
34 GtkSelectionData* selection_data, 33 GtkSelectionData* selection_data,
35 guint target_type, guint time, 34 guint target_type, guint time,
36 const DownloadItem* item) { 35 const DownloadItem* item) {
37 OnDragDataGetForDownloadItem(selection_data, target_type, item); 36 OnDragDataGetForDownloadItem(selection_data, target_type, item);
38 } 37 }
39 38
40 } // namespace 39 } // namespace
41 40
42 // CustomDrag ------------------------------------------------------------------ 41 // CustomDrag ------------------------------------------------------------------
43 42
44 CustomDrag::CustomDrag(SkBitmap* icon, int code_mask, GdkDragAction action) 43 CustomDrag::CustomDrag(SkBitmap* icon, int code_mask, GdkDragAction action)
45 : drag_widget_(gtk_invisible_new()), 44 : drag_widget_(gtk_invisible_new()),
46 pixbuf_(icon ? gfx::GdkPixbufFromSkBitmap(icon) : NULL) { 45 pixbuf_(icon ? gfx::GdkPixbufFromSkBitmap(icon) : NULL) {
47 g_signal_connect(drag_widget_, "drag-data-get", 46 g_signal_connect(drag_widget_, "drag-data-get",
48 G_CALLBACK(OnDragDataGetThunk), this); 47 G_CALLBACK(OnDragDataGetThunk), this);
49 g_signal_connect(drag_widget_, "drag-begin", 48 g_signal_connect(drag_widget_, "drag-begin",
50 G_CALLBACK(OnDragBeginThunk), this); 49 G_CALLBACK(OnDragBeginThunk), this);
51 g_signal_connect(drag_widget_, "drag-end", 50 g_signal_connect(drag_widget_, "drag-end",
52 G_CALLBACK(OnDragEndThunk), this); 51 G_CALLBACK(OnDragEndThunk), this);
53 52
54 GtkTargetList* list = gtk_dnd_util::GetTargetListFromCodeMask(code_mask); 53 GtkTargetList* list = ui::GetTargetListFromCodeMask(code_mask);
55 GdkEvent* event = gtk_get_current_event(); 54 GdkEvent* event = gtk_get_current_event();
56 gtk_drag_begin(drag_widget_, list, action, 1, event); 55 gtk_drag_begin(drag_widget_, list, action, 1, event);
57 if (event) 56 if (event)
58 gdk_event_free(event); 57 gdk_event_free(event);
59 gtk_target_list_unref(list); 58 gtk_target_list_unref(list);
60 } 59 }
61 60
62 CustomDrag::~CustomDrag() { 61 CustomDrag::~CustomDrag() {
63 if (pixbuf_) 62 if (pixbuf_)
64 g_object_unref(pixbuf_); 63 g_object_unref(pixbuf_);
(...skipping 26 matching lines...) Expand all
91 guint target_type, guint time) { 90 guint target_type, guint time) {
92 OnDragDataGetForDownloadItem(selection_data, target_type, download_item_); 91 OnDragDataGetForDownloadItem(selection_data, target_type, download_item_);
93 } 92 }
94 93
95 // static 94 // static
96 void DownloadItemDrag::SetSource(GtkWidget* widget, 95 void DownloadItemDrag::SetSource(GtkWidget* widget,
97 DownloadItem* item, 96 DownloadItem* item,
98 SkBitmap* icon) { 97 SkBitmap* icon) {
99 gtk_drag_source_set(widget, GDK_BUTTON1_MASK, NULL, 0, 98 gtk_drag_source_set(widget, GDK_BUTTON1_MASK, NULL, 0,
100 kDownloadItemDragAction); 99 kDownloadItemDragAction);
101 gtk_dnd_util::SetSourceTargetListFromCodeMask(widget, kDownloadItemCodeMask); 100 ui::SetSourceTargetListFromCodeMask(widget, kDownloadItemCodeMask);
102 101
103 // Disconnect previous signal handlers, if any. 102 // Disconnect previous signal handlers, if any.
104 g_signal_handlers_disconnect_by_func( 103 g_signal_handlers_disconnect_by_func(
105 widget, 104 widget,
106 reinterpret_cast<gpointer>(OnDragDataGetStandalone), 105 reinterpret_cast<gpointer>(OnDragDataGetStandalone),
107 item); 106 item);
108 // Connect new signal handlers. 107 // Connect new signal handlers.
109 g_signal_connect(widget, "drag-data-get", 108 g_signal_connect(widget, "drag-data-get",
110 G_CALLBACK(OnDragDataGetStandalone), item); 109 G_CALLBACK(OnDragDataGetStandalone), item);
111 110
(...skipping 28 matching lines...) Expand all
140 guint target_type, guint time) { 139 guint target_type, guint time) {
141 bookmark_utils::WriteBookmarksToSelection(nodes_, selection_data, 140 bookmark_utils::WriteBookmarksToSelection(nodes_, selection_data,
142 target_type, profile_); 141 target_type, profile_);
143 } 142 }
144 143
145 // static 144 // static
146 void BookmarkDrag::BeginDrag(Profile* profile, 145 void BookmarkDrag::BeginDrag(Profile* profile,
147 const std::vector<const BookmarkNode*>& nodes) { 146 const std::vector<const BookmarkNode*>& nodes) {
148 new BookmarkDrag(profile, nodes); 147 new BookmarkDrag(profile, nodes);
149 } 148 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_toolbar_gtk.cc ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698