| 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 #ifndef CHROME_BROWSER_GTK_GTK_DND_UTIL_H_ | 5 #ifndef CHROME_BROWSER_GTK_GTK_DND_UTIL_H_ |
| 6 #define CHROME_BROWSER_GTK_GTK_DND_UTIL_H_ | 6 #define CHROME_BROWSER_GTK_GTK_DND_UTIL_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 class GtkDndUtil { | 10 class GtkDndUtil { |
| 11 public: | 11 public: |
| 12 // Registry of all internal int codes for drag and drop. | 12 // Registry of all internal int codes for drag and drop. |
| 13 enum { | 13 enum { |
| 14 // Intra-application types. | 14 // Intra-application types. |
| 15 CHROME_TAB = 1 << 0, | 15 CHROME_TAB = 1 << 0, |
| 16 CHROME_BOOKMARK_ITEM = 1 << 1, | 16 CHROME_BOOKMARK_ITEM = 1 << 1, |
| 17 CHROME_WEBDROP_FILE_CONTENTS = 1 << 2, | 17 CHROME_WEBDROP_FILE_CONTENTS = 1 << 2, |
| 18 CHROME_NAMED_URL = 1 << 3, | 18 CHROME_NAMED_URL = 1 << 3, |
| 19 | 19 |
| 20 // Standard types. | 20 // Standard types. |
| 21 TEXT_PLAIN = 1 << 4, | 21 TEXT_PLAIN = 1 << 4, |
| 22 TEXT_URI_LIST = 1 << 5, | 22 TEXT_URI_LIST = 1 << 5, |
| 23 TEXT_HTML = 1 << 6, | 23 TEXT_HTML = 1 << 6, |
| 24 |
| 25 INVALID_TARGET = 1 << 7, |
| 24 }; | 26 }; |
| 25 | 27 |
| 26 // Get the atom for a given target (of the above enum type). Will return NULL | 28 // Get the atom for a given target (of the above enum type). Will return NULL |
| 27 // for non-custom targets, such as CHROME_TEXT_PLAIN. | 29 // for non-custom targets, such as CHROME_TEXT_PLAIN. |
| 28 static GdkAtom GetAtomForTarget(int target); | 30 static GdkAtom GetAtomForTarget(int target); |
| 29 | 31 |
| 30 // Creates a target list from the given mask. The mask should be an OR of | 32 // Creates a target list from the given mask. The mask should be an OR of |
| 31 // CHROME_* values. The target list is returned with ref count 1; the caller | 33 // CHROME_* values. The target list is returned with ref count 1; the caller |
| 32 // is responsible for unreffing it when it is no longer needed. | 34 // is responsible for unreffing it when it is no longer needed. |
| 33 // Since the MIME type for WEBDROP_FILE_CONTENTS depends on the file's | 35 // Since the MIME type for WEBDROP_FILE_CONTENTS depends on the file's |
| 34 // contents, that flag is ignored by this function. It is the responsibility | 36 // contents, that flag is ignored by this function. It is the responsibility |
| 35 // of the client code to do the right thing. | 37 // of the client code to do the right thing. |
| 36 static GtkTargetList* GetTargetListFromCodeMask(int code_mask); | 38 static GtkTargetList* GetTargetListFromCodeMask(int code_mask); |
| 37 | 39 |
| 38 // Set the drag target list for |dest| or |source| with the target list that | 40 // Set the drag target list for |source| with the target list that |
| 39 // corresponds to |code_mask|. | 41 // corresponds to |code_mask|. |
| 40 static void SetDestTargetListFromCodeMask(GtkWidget* dest, int code_mask); | |
| 41 static void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask); | 42 static void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask); |
| 42 | 43 |
| 44 // Set the accepted targets list for |dest|. The |target_codes| array should |
| 45 // be sorted in preference order and should be terminated with 0. |
| 46 static void SetDestTargetList(GtkWidget* dest, const int* target_codes); |
| 47 |
| 43 private: | 48 private: |
| 44 GtkDndUtil(); | 49 GtkDndUtil(); |
| 50 |
| 51 static void AddTargetToList(GtkTargetList* targets, int target_code); |
| 45 }; | 52 }; |
| 46 | 53 |
| 47 #endif // CHROME_BROWSER_GTK_GTK_DND_UTIL_H_ | 54 #endif // CHROME_BROWSER_GTK_GTK_DND_UTIL_H_ |
| OLD | NEW |