Re: [E-devel] [patch] elm_cnp_helper - add type checking for non-elm cnp datas

2011-12-20 Thread Michael Blumenkrantz
On Fri, 16 Dec 2011 17:14:23 +0900
Hyoyoung Chang  wrote:

> Oops i omitted file attaching.
> sorry.
> 
> On Fri, Dec 16, 2011 at 5:09 PM, Hyoyoung Chang  wrote:
> > Dear developers
> >
> > elm_cnp_helper supports rich types for copying & pasting.
> > but it doesn't extend like x11 way.
> > this patch introduces to reduce mismatch for checking selection type format.
> > now elm can live in harmony with non-elm cnp datas
> >
> > Thanks
in

--
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [patch] elm_cnp_helper - add type checking for non-elm cnp datas

2011-12-16 Thread Hyoyoung Chang
Oops i omitted file attaching.
sorry.

On Fri, Dec 16, 2011 at 5:09 PM, Hyoyoung Chang  wrote:
> Dear developers
>
> elm_cnp_helper supports rich types for copying & pasting.
> but it doesn't extend like x11 way.
> this patch introduces to reduce mismatch for checking selection type format.
> now elm can live in harmony with non-elm cnp datas
>
> Thanks
Index: elementary/src/lib/elm_widget.h
===
--- elementary/src/lib/elm_widget.h (리비전 66266)
+++ elementary/src/lib/elm_widget.h (작업 사본)
@@ -727,16 +727,20 @@
 
 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,
+   ELM_SEL_FORMAT_IMAGE  = 0x04,
/** Vcards */
-   ELM_SEL_FORMAT_VCARD =  0x08,
+   ELM_SEL_FORMAT_VCARD  = 0x08,
/** Raw HTMLish things for widgets that want that stuff (hello webkit!) */
-   ELM_SEL_FORMAT_HTML = 0x10,
+   ELM_SEL_FORMAT_HTML   = 0x10,
 } Elm_Sel_Format;
 
 struct _Elm_Selection_Data
Index: elementary/src/lib/elm_cnp_helper.c
===
--- elementary/src/lib/elm_cnp_helper.c (리비전 66266)
+++ elementary/src/lib/elm_cnp_helper.c (작업 사본)
@@ -168,15 +168,15 @@
 static Cnp_Atom atoms[CNP_N_ATOMS] = {
  [CNP_ATOM_TARGETS] = {
   "TARGETS",
-  (Elm_Sel_Format) -1, // everything
+  ELM_SEL_TARGETS,
   targets_converter,
   response_handler_targets,
   notify_handler_targets,
   0
  },
  [CNP_ATOM_ATOM] = {
-  "ATOM",
-  (Elm_Sel_Format) -1, // everything
+  "ATOM", // for opera browser
+  ELM_SEL_TARGETS,
   targets_converter,
   response_handler_targets,
   notify_handler_targets,
@@ -425,7 +425,7 @@
 
sel = selections + selection;
 
-   sel->active = 1;
+   sel->active = EINA_TRUE;
sel->widget = widget;
 
sel->set(xwin, &selection, sizeof(Elm_Sel_Type));
@@ -452,7 +452,7 @@
/* No longer this selection: Consider it gone! */
if ((!sel->active) || (sel->widget != widget)) return EINA_TRUE;
 
-   sel->active = 0;
+   sel->active = EINA_FALSE;
sel->widget = NULL;
sel->clear();
 
@@ -587,8 +587,19 @@
return ECORE_CALLBACK_PASS_ON;
 }
 
+static Elm_Sel_Format
+_get_selection_type(void *data, int size)
+{
+   if (size == sizeof(Elm_Sel_Type))
+ {
+Cnp_Selection *sel;
+sel = selections + *((int *)data);
+if (sel->active)
+  return sel->format;
+ }
+   return ELM_SEL_FORMAT_NONE;
+}
 
-
 static Eina_Bool
 targets_converter(char *target __UNUSED__, void *data, int size, void 
**data_ret, int *size_ret, Ecore_X_Atom *ttype, int *typesize)
 {
@@ -598,7 +609,7 @@
 
if (!data_ret) return EINA_FALSE;
 
-   if (size != sizeof(int))
+   if (_get_selection_type(data, size) == ELM_SEL_FORMAT_NONE)
  {
 if (data_ret)
   {
@@ -987,7 +998,7 @@
Cnp_Selection *sel;
 
cnp_debug("text converter\n");
-   if (size != sizeof(int))
+   if (_get_selection_type(data, size) == ELM_SEL_FORMAT_NONE)
  {
 if (data_ret)
   {
@@ -1026,16 +1037,8 @@
 static Eina_Bool
 general_converter(char *target __UNUSED__, void *data, int size, void 
**data_ret, int *size_ret, Ecore_X_Atom *ttype __UNUSED__, int *typesize 
__UNUSED__)
 {
-   if (size == sizeof(int))
+   if (_get_selection_type(data, size) == ELM_SEL_FORMAT_NONE)
  {
-Cnp_Selection *sel;
-
-sel = selections + *((int *)data);
-if (data_ret) *data_ret = strdup(sel->selbuf);
-if (size_ret) *size_ret = strlen(sel->selbuf);
- }
-   else if (size)
- {
 if (data_ret)
   {
  *data_ret = malloc(size * sizeof(char) + 1);
@@ -1044,6 +1047,14 @@
   }
 if (size_ret) *size_ret = size;
  }
+   else
+ {
+Cnp_Selection *sel;
+
+sel = selections + *((int *)data);
+if (data_ret) *data_ret = strdup(sel->selbuf);
+if (size_ret) *size_ret = strlen(sel->selbuf);
+ }
return EINA_TRUE;
 }
 
--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/

[E-devel] [patch] elm_cnp_helper - add type checking for non-elm cnp datas

2011-12-16 Thread Hyoyoung Chang
Dear developers

elm_cnp_helper supports rich types for copying & pasting.
but it doesn't extend like x11 way.
this patch introduces to reduce mismatch for checking selection type format.
now elm can live in harmony with non-elm cnp datas

Thanks

--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel