3 * @addtogroup CopyPaste
7 typedef struct _Elm_Selection_Data Elm_Selection_Data;
8 typedef Eina_Bool (*Elm_Drop_Cb)(void *d, Evas_Object *o, Elm_Selection_Data *data);
13 ELM_SEL_TYPE_SECONDARY,
14 ELM_SEL_TYPE_CLIPBOARD,
22 /** Targets: for matching every atom requesting */
23 ELM_SEL_FORMAT_TARGETS = -1,
24 /** they come from outside of elm */
25 ELM_SEL_FORMAT_NONE = 0x0,
26 /** Plain unformated text: Used for things that don't want rich markup */
27 ELM_SEL_FORMAT_TEXT = 0x01,
28 /** Edje textblock markup, including inline images */
29 ELM_SEL_FORMAT_MARKUP = 0x02,
31 ELM_SEL_FORMAT_IMAGE = 0x04,
33 ELM_SEL_FORMAT_VCARD = 0x08,
34 /** Raw HTMLish things for widgets that want that stuff (hello webkit!) */
35 ELM_SEL_FORMAT_HTML = 0x10,
40 struct _Elm_Selection_Data
44 * @defgroup CopyPaste CopyPaste
46 * Implements the following functionality
47 * a. select, copy/cut and paste
50 * in order to share data across application windows.
52 * Contains functions to select text or a portion of data,
53 * send it to a buffer, and paste the data into a target.
55 * elm_cnp provides a generic copy and paste facility based on its windowing system.
56 * It is not necessary to know the details of each windowing system,
57 * but some terms and behavior are common.
58 * Currently the X11 window system is widely used, and only X11 functionality is implemented.
60 * In X11R6 window system, CopyPaste works like a peer-to-peer communication.
61 * Copying is an operation on an object in an X server.
62 * X11 calls those objects 'selections' which have names.
63 * Generally, two selection types are needed for copy and paste:
64 * The Primary selection and the Clipboard selection.
65 * Primary selection is for selecting text (that means highlighted text).
66 * Clipboard selection is for explicit copying behavior
67 * (such as ctrl+c, or 'copy' in a menu).
68 * Thus, in applications most cases only use the clipboard selection.
69 * As stated before, taking ownership of a selection doesn't move any actual data.
70 * Copying and Pasting is described as follows:
71 * 1. Copy text in Program A : Program A takes ownership of the selection
72 * 2. Paste text in Program B : Program B notes that Program A owns the selection
73 * 3. Program B asks A for the text
74 * 4. Program A responds and sends the text to program B
75 * 5. Program B pastes the response
76 * More information is on
77 * - http://www.jwz.org/doc/x-cut-and-paste.html
78 * - X11R6 Inter-Client Communication Conventions Manual, section 2
80 * TODO: add for other window system.
86 * Defines the types of selection property names.
87 * @see http://www.x.org/docs/X11/xlib.pdf
92 ELM_SEL_TYPE_PRIMARY, /**< Primary text selection (highlighted or selected text) */
93 ELM_SEL_TYPE_SECONDARY, /**< Used when primary selection is in use */
94 ELM_SEL_TYPE_XDND, /**< Drag 'n' Drop */
95 ELM_SEL_TYPE_CLIPBOARD, /**< Clipboard selection (ctrl+C) */
99 * Defines the types of content.
103 /** For matching every possible atom */
104 ELM_SEL_FORMAT_TARGETS = -1,
105 /** Content is from outside of Elementary */
106 ELM_SEL_FORMAT_NONE = 0x0,
107 /** Plain unformatted text: Used for things that don't want rich markup */
108 ELM_SEL_FORMAT_TEXT = 0x01,
109 /** Edje textblock markup, including inline images */
110 ELM_SEL_FORMAT_MARKUP = 0x02,
112 ELM_SEL_FORMAT_IMAGE = 0x04,
114 ELM_SEL_FORMAT_VCARD = 0x08,
115 /** Raw HTML-like data (eg. webkit) */
116 ELM_SEL_FORMAT_HTML = 0x10,
120 * Structure holding the info about selected data.
122 struct _Elm_Selection_Data
125 >>>>>>> remotes/origin/upstream
126 Elm_Sel_Format format;
133 * @brief Set a data of a widget to copy and paste.
135 * Append the given callback to the list. This functions will be called
138 * @param selection selection type for copying and pasting
139 * @param widget The source widget pointer
140 * @param format Type of selection format
141 * @param buf The pointer of data source
142 * @return If EINA_TRUE, setting data is success.
144 typedef struct _Elm_Selection_Data Elm_Selection_Data;
147 * Callback invoked in when the selected data is 'dropped' at its destination.
149 * @param data Application specific data
150 * @param obj The evas object where selected data is 'dropped'.
151 * @param ev struct holding information about selected data
152 * FIXME: this should probably be a smart callback
154 typedef Eina_Bool (*Elm_Drop_Cb)(void *data, Evas_Object *obj, Elm_Selection_Data *ev);
158 * @brief Set copy data for a widget.
160 * Set copy data and take ownership of selection. Format is used for specifying the selection type,
161 * and this is used during pasting.
163 * @param selection Selection type for copying and pasting
164 * @param obj The source widget pointer
165 * @param format Selection format
166 * @param buf The data selected
167 * @param buflen The size of @p buf
168 * @return If EINA_TRUE, setting data was successful.
169 >>>>>>> remotes/origin/upstream
176 EAPI Eina_Bool elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const void *buf, size_t buflen);
179 * @brief Retrive the data from the widget which is set for copying and pasting.
181 * Getting the data from the widget which is set for copying and pasting.
182 * Mainly the widget is elm_entry. If then @p datacb and @p udata are
183 * can be NULL. If not, @p datacb and @p udata are used for retriving data.
185 * @see also elm_cnp_selection_set()
187 * @param selection selection type for copying and pasting
188 * @param widget The source widget pointer
189 * @param datacb The user data callback if the target widget isn't elm_entry
190 * @param udata The user data pointer for @p datacb
191 * @return If EINA_TRUE, getting data is success.
197 EAPI Eina_Bool elm_cnp_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, Evas_Object *widget, Elm_Drop_Cb datacb, void *udata);
200 * @brief Clear the data in the widget which is set for copying and pasting.
202 * Clear the data in the widget. Normally this function isn't need to call.
204 * @see also elm_cnp_selection_set()
206 * @param selection selection type for copying and pasting
207 * @param widget The source widget pointer
208 * @return If EINA_TRUE, clearing data is success.
210 EAPI Eina_Bool elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection,
211 Elm_Sel_Format format,
212 const void *buf, size_t buflen);
215 * @brief Retrieve data from a widget that has a selection.
217 * Gets the current selection data from a widget.
218 * The widget input here will usually be elm_entry,
219 * in which case @p datacb and @p udata can be NULL.
220 * If a different widget is passed, @p datacb and @p udata are used for retrieving data.
222 * @see also elm_cnp_selection_set()
224 * @param selection Selection type for copying and pasting
225 * @param format Selection format
226 * @param obj The source widget
227 * @param datacb The user data callback if the target widget isn't elm_entry
228 * @param udata The user data pointer for @p datacb
229 * @return If EINA_TRUE, getting selection data was successful.
233 EAPI Eina_Bool elm_cnp_selection_get(Evas_Object *obj, Elm_Sel_Type selection,
234 Elm_Sel_Format format,
235 Elm_Drop_Cb datacb, void *udata);
238 * @brief Clear the selection data of a widget.
240 * Clear all data from the selection which is owned by a widget.
242 * @see also elm_cnp_selection_set()
244 * @param obj The source widget
245 * @param selection Selection type for copying and pasting
246 * @return If EINA_TRUE, clearing data was successful.
247 >>>>>>> remotes/origin/upstream
254 EAPI Eina_Bool elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *widget);
256 EAPI Eina_Bool elm_object_cnp_selection_clear(Evas_Object *obj,
257 Elm_Sel_Type selection);
258 >>>>>>> remotes/origin/upstream