elm cnp: Reviewed cnp APIs. Many things need to be changed.
authorDaniel Juyung Seo <juyung.seo@samsung.com>
Thu, 16 Feb 2012 07:06:13 +0000 (07:06 +0000)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Thu, 16 Feb 2012 07:06:13 +0000 (07:06 +0000)
Signed-off-by: Daniel Juyung Seo <juyung.seo@samsung.com>
SVN revision: 68007

src/lib/Elementary.h.in
src/lib/elm_cnp.h
src/lib/elm_cnp_helper.c

index b85a4e7..53b4162 100644 (file)
@@ -184,7 +184,7 @@ EAPI extern Elm_Version *elm_version;
 #include <elm_calendar.h>
 #include <elm_check.h>
 #include <elm_clock.h>
-#include <elm_cnp.h>
+#include <elm_cnp.h> // comments in elm_cnp.h
 #include <elm_colorselector.h>
 #include <elm_config.h>
 #include <elm_conform.h>
index b5e9a95..f7adaca 100644 (file)
@@ -45,13 +45,13 @@ struct _Elm_Selection_Data
 };
 
 /**
- * @brief Set a data of a widget to copy and paste.
+ * @brief Set copy and paste data to a widget.
  *
- * Append the given callback to the list. This functions will be called
- * called.
+ * XXX: need to be rewritten.
+ * Append the given callback to the list. This functions will be called.
  *
- * @param selection selection type for copying and pasting
- * @param widget The source widget pointer
+ * @param selection Selection type for copying and pasting
+ * @param obj 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.
@@ -59,20 +59,24 @@ struct _Elm_Selection_Data
  * @ingroup CopyPaste
  *
  */
-
-EAPI Eina_Bool elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const void *buf, size_t buflen);
+// XXX: EAPI void elm_object_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection,
+//                                             Elm_Sel_Format format, const void *buf,
+//                                             size_t buflen);
+EAPI Eina_Bool elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *obj,
+                                     Elm_Sel_Format format, const void *buf,
+                                     size_t buflen);
 
 /**
- * @brief Retrieve the data from the widget which is set for copying and pasting.
+ * @brief Retrieve the copy and paste data from the widget.
  *
- * 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 retrieving data.
+ * Gets 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 can be NULL.
+ * If not, @p datacb and @p udata are used for retrieving data.
  *
  * @see also elm_cnp_selection_set()
  *
- * @param selection selection type for copying and pasting
- * @param widget The source widget pointer
+ * @param selection Selection type for copying and pasting
+ * @param obj 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.
@@ -80,25 +84,37 @@ EAPI Eina_Bool elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *widget
  * @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);
+// XXX: This api needs to be refined by cnp experts.
+//      I suggest:
+//         1. return copy and paste data.
+//         2. call cnp callback regardless of widget type.
+//         3. apps insert text data into entry manually.
+// XXX: EAPI void *elm_object_cnp_selection_get(Evas_Object *obj,
+//                                              Elm_Sel_Type selection,
+//                                              Elm_Sel_Format format,
+//                                              Elm_Cnp_Cb datacb);
+EAPI Eina_Bool elm_cnp_selection_get(Elm_Sel_Type selection,
+                                     Elm_Sel_Format format, Evas_Object *obj,
+                                     Elm_Drop_Cb datacb, void *udata);
 
 /**
- * @brief Clear the data in the widget which is set for copying and pasting.
+ * @brief Clear the copy and paste data in the widget.
  *
  * 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 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);
+// XXX: EAPI void elm_object_cnp_selection_clear(Evas_Object *obj,
+//                                               Elm_Sel_Type selection);
+EAPI Eina_Bool elm_cnp_selection_clear(Elm_Sel_Type selection,
+                                       Evas_Object *obj);
 
 /**
  * @}
index 28fa89c..41c8f52 100644 (file)
@@ -389,27 +389,27 @@ elm_selection_selection_has_owner(void)
 #endif
 }
 
-Eina_Bool
-elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *widget,
+EAPI Eina_Bool
+elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *obj,
                       Elm_Sel_Format format, const void *selbuf, size_t buflen)
 {
 #ifdef HAVE_ELEMENTARY_X
-   Evas_Object *top = elm_widget_top_get(widget);
+   Evas_Object *top = elm_widget_top_get(obj);
    Ecore_X_Window xwin;
    Cnp_Selection *sel;
 
    if (top) xwin = elm_win_xwindow_get(top);
-   else xwin = elm_win_xwindow_get(widget);
+   else xwin = elm_win_xwindow_get(obj);
    if ((!xwin) || (selection >= ELM_SEL_TYPE_MAX))
      return EINA_FALSE;
    if (!_elm_cnp_init_count) _elm_cnp_init();
    if ((!selbuf) && (format != ELM_SEL_FORMAT_IMAGE))
-     return elm_cnp_selection_clear(selection, widget);
+     return elm_cnp_selection_clear(selection, obj);
 
    sel = selections + selection;
 
    sel->active = EINA_TRUE;
-   sel->widget = widget;
+   sel->widget = obj;
    sel->set(xwin, &selection, sizeof(Elm_Sel_Type));
    sel->format = format;
 
@@ -432,8 +432,8 @@ elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *widget,
 #endif
 }
 
-Eina_Bool
-elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *widget)
+EAPI Eina_Bool
+elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *obj)
 {
 #ifdef HAVE_ELEMENTARY_X
    Cnp_Selection *sel;
@@ -445,7 +445,7 @@ elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *widget)
    sel = selections + selection;
 
    /* No longer this selection: Consider it gone! */
-   if ((!sel->active) || (sel->widget != widget)) return EINA_TRUE;
+   if ((!sel->active) || (sel->widget != obj)) return EINA_TRUE;
 
    sel->active = EINA_FALSE;
    sel->widget = NULL;
@@ -462,9 +462,9 @@ elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *widget)
 #endif
 }
 
-Eina_Bool
+EAPI Eina_Bool
 elm_cnp_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format,
-                      Evas_Object *widget, Elm_Drop_Cb datacb, void *udata)
+                      Evas_Object *obj, Elm_Drop_Cb datacb, void *udata)
 {
 #ifdef HAVE_ELEMENTARY_X
    Evas_Object *top;
@@ -475,11 +475,11 @@ elm_cnp_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format,
    if (!_elm_cnp_init_count) _elm_cnp_init();
 
    sel = selections + selection;
-   top = elm_widget_top_get(widget);
+   top = elm_widget_top_get(obj);
    if (!top) return EINA_FALSE;
 
    sel->requestformat = format;
-   sel->requestwidget = widget;
+   sel->requestwidget = obj;
    sel->request(elm_win_xwindow_get(top), ECORE_X_SELECTION_TARGET_TARGETS);
    sel->datacb = datacb;
    sel->udata = udata;