From: raster Date: Mon, 26 Dec 2011 04:08:45 +0000 (+0000) Subject: From: Hyoyoung Chang X-Git-Tag: REL_F_I9500_20120323_1~17^2~1051 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a10ca423502c3f05baf510e74a89f4fbd70be8d0;p=framework%2Fuifw%2Felementary.git From: Hyoyoung Chang Subject: [E-devel] [patch] elm_cnp_helper - make some cnp apis as public EAPI As I suggested, I made a patch for some cnp apis. I think copying and pasting APIs are pretty mature to be public Those are elm_selection_set, elm_selection_clear, elm_selection_get. And adding cnp prefix for distinction from word, or char selections. elm_selection_set --> elm_cnp_selection_set elm_selection_clear --> elm_cnp_selection_clear elm_selection_get --> elm_cnp_selection_get And drag and drop APIs should be remained as private. It has many flaws. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@66505 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 9adc573..b55c715 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -30394,6 +30394,112 @@ extern "C" { * @} */ + /** + * @addtogroup CopyPaste + * @{ + */ + + typedef struct _Elm_Selection_Data Elm_Selection_Data; + typedef Eina_Bool (*Elm_Drop_Cb) (void *d, Evas_Object *o, Elm_Selection_Data *data); + + typedef enum _Elm_Sel_Type + { + ELM_SEL_PRIMARY, + ELM_SEL_SECONDARY, + ELM_SEL_CLIPBOARD, + ELM_SEL_XDND, + + ELM_SEL_MAX, + } Elm_Sel_Type; + + typedef enum _Elm_Sel_Format + { + /** Targets: for matching every atom requesting */ + ELM_SEL_TARGETS = -1, + /** they come from outside of elm */ + ELM_SEL_FORMAT_NONE = 0x0, + /** Plain unformated text: Used for things that don't want rich markup */ + ELM_SEL_FORMAT_TEXT = 0x01, + /** Edje textblock markup, including inline images */ + ELM_SEL_FORMAT_MARKUP = 0x02, + /** Images */ + ELM_SEL_FORMAT_IMAGE = 0x04, + /** Vcards */ + ELM_SEL_FORMAT_VCARD = 0x08, + /** Raw HTMLish things for widgets that want that stuff (hello webkit!) */ + ELM_SEL_FORMAT_HTML = 0x10, + + ELM_SEL_FORMAT_MAX + } Elm_Sel_Format; + + struct _Elm_Selection_Data + { + int x, y; + Elm_Sel_Format format; + void *data; + int len; + }; + + /** + * @brief Set a data of a widget to copy and paste. + * + * Append the given callback to the list. This functions will be called + * called. + * + * @param selection selection type for copying and pasting + * @param widget The source widget pointer + * @param format Type of selection format + * @param buf The pointer of data source + * @return If EINA_TRUE, setting data is success. + * + * @ingroup CopyPaste + * + */ + + EAPI Eina_Bool elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const char *buf); + + /** + * @brief Retrive the data from the widget which is set for copying and pasting. + * + * Getting the data from the widget which is set for copying and pasting. + * Mainly the widget is elm_entry. If then @p datacb and @p udata are + * can be NULL. If not, @p datacb and @p udata are used for retriving data. + * + * @see also elm_cnp_selection_set() + * + * @param selection selection type for copying and pasting + * @param widget The source widget pointer + * @param datacb The user data callback if the target widget isn't elm_entry + * @param udata The user data pointer for @p datacb + * @return If EINA_TRUE, getting data is success. + * + * @ingroup CopyPaste + * + */ + + EAPI Eina_Bool elm_cnp_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, Evas_Object *widget, Elm_Drop_Cb datacb, void *udata); + + /** + * @brief Clear the data in the widget which is set for copying and pasting. + * + * Clear the data in the widget. Normally this function isn't need to call. + * + * @see also elm_cnp_selection_set() + * + * @param selection selection type for copying and pasting + * @param widget The source widget pointer + * @return If EINA_TRUE, clearing data is success. + * + * @ingroup CopyPaste + * + */ + + EAPI Eina_Bool elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *widget); + + /** + * @} + */ + #ifdef __cplusplus } #endif diff --git a/src/lib/elm_cnp_helper.c b/src/lib/elm_cnp_helper.c index 62256e7..92a622d 100644 --- a/src/lib/elm_cnp_helper.c +++ b/src/lib/elm_cnp_helper.c @@ -408,7 +408,7 @@ elm_selection_selection_has_owner(void) } Eina_Bool -elm_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const char *selbuf) +elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const char *selbuf) { #ifdef HAVE_ELEMENTARY_X Evas_Object *top = elm_widget_top_get(widget); @@ -421,7 +421,7 @@ elm_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format fo if ((unsigned int)selection >= (unsigned int)ELM_SEL_MAX) return EINA_FALSE; if (!_elm_cnp_init_count) _elm_cnp_init(); if ((!selbuf) && (format != ELM_SEL_FORMAT_IMAGE)) - return elm_selection_clear(selection, widget); + return elm_cnp_selection_clear(selection, widget); sel = selections + selection; @@ -439,7 +439,7 @@ elm_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format fo } Eina_Bool -elm_selection_clear(Elm_Sel_Type selection, Evas_Object *widget) +elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *widget) { #ifdef HAVE_ELEMENTARY_X Cnp_Selection *sel; @@ -463,7 +463,7 @@ elm_selection_clear(Elm_Sel_Type selection, Evas_Object *widget) } Eina_Bool -elm_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, +elm_cnp_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, Evas_Object *widget, Elm_Drop_Cb datacb, void *udata) { #ifdef HAVE_ELEMENTARY_X diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index 08b42b0..e7ca4e4 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -1126,7 +1126,7 @@ _paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) formats = ELM_SEL_FORMAT_MARKUP; if (!wd->textonly) formats |= ELM_SEL_FORMAT_IMAGE; - elm_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL); + elm_cnp_selection_get(ELM_SEL_CLIPBOARD, formats, data, NULL, NULL); #endif } } @@ -1140,7 +1140,7 @@ _store_selection(Elm_Sel_Type seltype, Evas_Object *obj) if (!wd) return; sel = edje_object_part_text_selection_get(wd->ent, "elm.text"); if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */ - elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel); + elm_cnp_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel); if (seltype == ELM_SEL_CLIPBOARD) eina_stringshare_replace(&wd->cut_sel, sel); } @@ -1531,7 +1531,7 @@ _signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emi top = elm_widget_top_get(data); if ((top) && (elm_win_xwindow_get(top))) - elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt); + elm_cnp_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt); } #endif } @@ -1579,7 +1579,7 @@ _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *e top = elm_widget_top_get(data); if ((top) && (elm_win_xwindow_get(top))) - elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, + elm_cnp_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, wd->cut_sel); #endif eina_stringshare_del(wd->cut_sel); @@ -1592,7 +1592,7 @@ _signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *e top = elm_widget_top_get(data); if ((top) && (elm_win_xwindow_get(top))) - elm_selection_clear(ELM_SEL_PRIMARY, data); + elm_cnp_selection_clear(ELM_SEL_PRIMARY, data); #endif } } @@ -1614,7 +1614,7 @@ _signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char if ((top) && (elm_win_xwindow_get(top))) { wd->selection_asked = EINA_TRUE; - elm_selection_get(type, ELM_SEL_FORMAT_MARKUP, data, + elm_cnp_selection_get(type, ELM_SEL_FORMAT_MARKUP, data, NULL, NULL); } #endif diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index a0de55b..1bbbbb2 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -711,51 +711,6 @@ EAPI Eina_Bool _elm_widget_item_disabled_get(const Elm_Widget_Item *item) * And yes, elm_widget, should probably be elm_experimental... * Complaints about this code should go to /dev/null, or failing that nash. */ -typedef struct _Elm_Selection_Data Elm_Selection_Data; - -typedef Eina_Bool (*Elm_Drop_Cb) (void *d, Evas_Object *o, Elm_Selection_Data *data); - -typedef enum _Elm_Sel_Type -{ - ELM_SEL_PRIMARY, - ELM_SEL_SECONDARY, - ELM_SEL_CLIPBOARD, - ELM_SEL_XDND, - - ELM_SEL_MAX, -} Elm_Sel_Type; - -typedef enum _Elm_Sel_Format -{ - /** Targets: for matching every atom requesting */ - ELM_SEL_TARGETS = -1, - /** they come from outside of elm */ - ELM_SEL_FORMAT_NONE = 0x0, - /** Plain unformated text: Used for things that don't want rich markup */ - ELM_SEL_FORMAT_TEXT = 0x01, - /** Edje textblock markup, including inline images */ - ELM_SEL_FORMAT_MARKUP = 0x02, - /** Images */ - ELM_SEL_FORMAT_IMAGE = 0x04, - /** Vcards */ - ELM_SEL_FORMAT_VCARD = 0x08, - /** Raw HTMLish things for widgets that want that stuff (hello webkit!) */ - ELM_SEL_FORMAT_HTML = 0x10, - - ELM_SEL_FORMAT_MAX -} Elm_Sel_Format; - -struct _Elm_Selection_Data -{ - int x, y; - Elm_Sel_Format format; - void *data; - int len; -}; - -Eina_Bool elm_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const char *buf); -Eina_Bool elm_selection_clear(Elm_Sel_Type selection, Evas_Object *widget); -Eina_Bool elm_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, Evas_Object *widget, Elm_Drop_Cb datacb, void *udata); Eina_Bool elm_selection_selection_has_owner(void); Eina_Bool elm_drop_target_add(Evas_Object *widget, Elm_Sel_Type, Elm_Drop_Cb, void *); Eina_Bool elm_drop_target_del(Evas_Object *widget);