| 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_DND_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_GTK_GTK_DND_UTIL_H_ |
| 6 #define CHROME_BROWSER_GTK_DND_REGISTRY_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 // We wrap all of these constants in a namespace to prevent pollution. | 10 class GtkDndUtil { |
| 11 namespace dnd { | 11 public: |
| 12 // Registry of all internal int codes for drag and drop. |
| 13 enum { |
| 14 X_CHROME_TAB = 1 << 0, |
| 15 X_CHROME_TEXT_PLAIN = 1 << 1, |
| 16 X_CHROME_TEXT_URI_LIST = 1 << 2, |
| 17 X_CHROME_TEXT_HTML = 1 << 3, |
| 18 X_CHROME_BOOKMARK_ITEM = 1 << 4, |
| 19 X_CHROME_WEBDROP_FILE_CONTENTS = 1 << 5, |
| 20 }; |
| 12 | 21 |
| 13 // Registry of all internal int codes for drag and drop. | 22 // Get the atom for a given target (of the above enum type). Will return NULL |
| 14 // | 23 // for non-custom targets, such as X_CHROME_TEXT_PLAIN. |
| 15 // These ids need to be unique app wide. Simply adding a GtkTargetEntry with an | 24 static GdkAtom GetAtomForTarget(int target); |
| 16 // id of 0 should be an error and it will conflict with X_CHROME_TAB below. | 25 |
| 17 enum { | 26 // Creates a target list from the given mask. The mask should be an OR of |
| 18 X_CHROME_TAB = 1 << 0, | 27 // X_CHROME_* values. The target list is returned with ref count 1; the caller |
| 19 X_CHROME_TEXT_PLAIN = 1 << 1, | 28 // is responsible for unreffing it when it is no longer needed. |
| 20 X_CHROME_TEXT_URI_LIST = 1 << 2, | 29 // Since the MIME type for WEBDROP_FILE_CONTENTS depends on the file's |
| 21 X_CHROME_BOOKMARK_ITEM = 1 << 3, | 30 // contents, that flag is ignored by this function. It is the responsibility |
| 31 // of the client code to do the right thing. |
| 32 static GtkTargetList* GetTargetListFromCodeMask(int code_mask); |
| 33 |
| 34 // Set the drag target list for |dest| or |source| with the target list that |
| 35 // corresponds to |code_mask|. |
| 36 static void SetDestTargetListFromCodeMask(GtkWidget* dest, int code_mask); |
| 37 static void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask); |
| 38 |
| 39 private: |
| 40 GtkDndUtil(); |
| 22 }; | 41 }; |
| 23 | 42 |
| 24 // Creates a target list from the given mask. The mask should be an OR of | 43 #endif // CHROME_BROWSER_GTK_GTK_DND_UTIL_H_ |
| 25 // X_CHROME_* values. The target list is returned with ref count 1; the caller | |
| 26 // is responsible for unreffing it when it is no longer needed. | |
| 27 GtkTargetList* GetTargetListFromCodeMask(int code_mask); | |
| 28 | |
| 29 // Set the drag target list for |dest| or |source| with the target list that | |
| 30 // corresponds to |code_mask|. | |
| 31 void SetDestTargetListFromCodeMask(GtkWidget* dest, int code_mask); | |
| 32 void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask); | |
| 33 | |
| 34 } // namespace dnd | |
| 35 | |
| 36 #endif // CHROME_BROWSER_GTK_DND_REGISTRY_H_ | |
| OLD | NEW |