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

Side by Side Diff: chrome/browser/gtk/gtk_dnd_util.cc

Issue 151033: More web contents dragging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: more Dones Created 11 years, 5 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
« no previous file with comments | « chrome/browser/gtk/gtk_dnd_util.h ('k') | chrome/browser/gtk/tabs/tab_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "dnd_registry.h" 5 #include "chrome/browser/gtk/gtk_dnd_util.h"
6 6
7 namespace dnd { 7 #include "base/logging.h"
8 8
9 GtkTargetList* GetTargetListFromCodeMask(int code_mask) { 9 // static
10 GdkAtom GtkDndUtil::GetAtomForTarget(int target) {
11 switch (target) {
12 case X_CHROME_TAB:
13 static GdkAtom tab_atom = gdk_atom_intern(
14 const_cast<char*>("application/x-chrome-tab"), false);
15 return tab_atom;
16
17 case X_CHROME_TEXT_HTML:
18 static GdkAtom html_atom = gdk_atom_intern(
19 const_cast<char*>("text/html"), false);
20 return html_atom;
21
22 case X_CHROME_BOOKMARK_ITEM:
23 static GdkAtom bookmark_atom = gdk_atom_intern(
24 const_cast<char*>("application/x-chrome-bookmark-item"), false);
25 return bookmark_atom;
26
27 case X_CHROME_TEXT_PLAIN:
28 case X_CHROME_TEXT_URI_LIST:
29 return NULL;
30
31 default:
32 NOTREACHED();
33 }
34
35 return NULL;
36 }
37
38 // static
39 GtkTargetList* GtkDndUtil::GetTargetListFromCodeMask(int code_mask) {
10 GtkTargetList* targets = gtk_target_list_new(NULL, 0); 40 GtkTargetList* targets = gtk_target_list_new(NULL, 0);
11 41
12 if (code_mask & X_CHROME_TAB) { 42 if (code_mask & X_CHROME_TAB) {
13 GdkAtom tab_atom = gdk_atom_intern( 43 gtk_target_list_add(targets, GetAtomForTarget(X_CHROME_TAB),
14 const_cast<char*>("application/x-chrome-tab"), false); 44 GTK_TARGET_SAME_APP, X_CHROME_TAB);
15 gtk_target_list_add(targets, tab_atom, GTK_TARGET_SAME_APP,
16 X_CHROME_TAB);
17 } 45 }
18 46
19 if (code_mask & X_CHROME_TEXT_PLAIN) 47 if (code_mask & X_CHROME_TEXT_PLAIN)
20 gtk_target_list_add_text_targets(targets, X_CHROME_TEXT_PLAIN); 48 gtk_target_list_add_text_targets(targets, X_CHROME_TEXT_PLAIN);
21 49
22 if (code_mask & X_CHROME_TEXT_URI_LIST) 50 if (code_mask & X_CHROME_TEXT_URI_LIST)
23 gtk_target_list_add_uri_targets(targets, X_CHROME_TEXT_URI_LIST); 51 gtk_target_list_add_uri_targets(targets, X_CHROME_TEXT_URI_LIST);
24 52
53 if (code_mask & X_CHROME_TEXT_HTML) {
54 gtk_target_list_add(targets, GetAtomForTarget(X_CHROME_TEXT_PLAIN),
55 0, X_CHROME_TEXT_HTML);
56 }
57
25 if (code_mask & X_CHROME_BOOKMARK_ITEM) { 58 if (code_mask & X_CHROME_BOOKMARK_ITEM) {
26 GdkAtom bookmark_atom = gdk_atom_intern( 59 gtk_target_list_add(targets, GetAtomForTarget(X_CHROME_BOOKMARK_ITEM),
27 const_cast<char*>("application/x-chrome-bookmark-item"), false); 60 GTK_TARGET_SAME_APP, X_CHROME_BOOKMARK_ITEM);
28 gtk_target_list_add(targets, bookmark_atom, GTK_TARGET_SAME_APP,
29 X_CHROME_BOOKMARK_ITEM);
30 } 61 }
31 62
32 return targets; 63 return targets;
33 } 64 }
34 65
35 void SetDestTargetListFromCodeMask(GtkWidget* dest, int code_mask) { 66 // static
67 void GtkDndUtil::SetDestTargetListFromCodeMask(GtkWidget* dest,
68 int code_mask) {
36 GtkTargetList* targets = GetTargetListFromCodeMask(code_mask); 69 GtkTargetList* targets = GetTargetListFromCodeMask(code_mask);
37 gtk_drag_dest_set_target_list(dest, targets); 70 gtk_drag_dest_set_target_list(dest, targets);
38 gtk_target_list_unref(targets); 71 gtk_target_list_unref(targets);
39 } 72 }
40 73
41 void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask) { 74 // static
75 void GtkDndUtil::SetSourceTargetListFromCodeMask(GtkWidget* source,
76 int code_mask) {
42 GtkTargetList* targets = GetTargetListFromCodeMask(code_mask); 77 GtkTargetList* targets = GetTargetListFromCodeMask(code_mask);
43 gtk_drag_source_set_target_list(source, targets); 78 gtk_drag_source_set_target_list(source, targets);
44 gtk_target_list_unref(targets); 79 gtk_target_list_unref(targets);
45 } 80 }
46
47 } // namespace dnd
OLDNEW
« no previous file with comments | « chrome/browser/gtk/gtk_dnd_util.h ('k') | chrome/browser/gtk/tabs/tab_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698