ui.text: Use proper EO type for cnp mode
authorJean-Philippe Andre <jp.andre@samsung.com>
Thu, 18 Jan 2018 07:19:01 +0000 (16:19 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 3 Apr 2018 04:28:24 +0000 (13:28 +0900)
It's not working. Just "fixing" the API for consistency.
Also, we're lacking a proper hint for "markup without images".

So I think EFL_SELECTION_FORMAT_MARKUP should be without images, while
EFL_SELECTION_FORMAT_MARKUP | EFL_SELECTION_FORMAT_IMAGE would allow
markup with images.

Ping @thiep.ha

Ref T5329

src/lib/elementary/Elementary.h
src/lib/elementary/efl_ui_multibuttonentry.c
src/lib/elementary/efl_ui_text.c
src/lib/elementary/efl_ui_text.eo

index 9e45171..026016a 100644 (file)
@@ -283,6 +283,7 @@ typedef Eo Efl_Ui_Focus_Manager;
 #include <elm_win.h>
 
 #ifdef EFL_EO_API_SUPPORT
+# include <efl_selection_types.eot.h>
 # include <efl_ui_list_segarray.h>
 # include <efl_config_global.eo.h>
 # include <efl_ui_widget.eo.h>
@@ -329,7 +330,6 @@ typedef Eo Efl_Ui_Focus_Manager;
 # include <efl_ui_list_pan.eo.h>
 # include <efl_ui_scroll_manager.eo.h>
 # include <efl_ui_scroller.eo.h>
-# include <efl_selection_types.eot.h>
 # include <efl_ui_dnd_types.eot.h>
 # include <efl_ui_pan.eo.h>
 # include <efl_selection.eo.h>
index 4b9cb6c..c186463 100644 (file)
@@ -1572,7 +1572,7 @@ _view_init(Evas_Object *obj, Efl_Ui_Multibuttonentry_Data *sd)
    sd->entry = efl_add(EFL_UI_TEXT_CLASS, sd->box,
                        efl_text_multiline_set(efl_added, EINA_FALSE),
                        efl_text_set(efl_added, ""),
-                       efl_ui_text_cnp_mode_set(efl_added, EINA_FALSE),
+                       efl_ui_text_cnp_mode_set(efl_added, EFL_SELECTION_FORMAT_MARKUP),
                        efl_ui_text_input_panel_enabled_set(efl_added, EINA_FALSE),
                        efl_ui_text_interactive_editable_set(efl_added, EINA_TRUE),
                        efl_composite_attach(obj, efl_added));
index 0a7af70..e1f1bc1 100644 (file)
@@ -3606,24 +3606,36 @@ _efl_ui_text_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, const
 }
 
 EOLIAN static void
-_efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Elm_Cnp_Mode cnp_mode)
+_efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Efl_Selection_Format cnp_mode)
 {
-   Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
+   /* FIXME: CnP format handling really odd... */
 
+   Elm_Sel_Format dnd_format = ELM_SEL_FORMAT_MARKUP;
+   Elm_Sel_Format cnp_format = cnp_mode;
 
-   if (sd->cnp_mode == cnp_mode) return;
-   sd->cnp_mode = cnp_mode;
-   if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
-     format = ELM_SEL_FORMAT_TEXT;
-   else if (cnp_mode == ELM_CNP_MODE_MARKUP)
-     format |= ELM_SEL_FORMAT_IMAGE;
+   if (cnp_mode != EFL_SELECTION_FORMAT_TARGETS)
+     {
+        if (cnp_mode & EFL_SELECTION_FORMAT_VCARD)
+          ERR("VCARD format not supported for copy & paste!");
+        else if (cnp_mode & EFL_SELECTION_FORMAT_HTML)
+          ERR("HTML format not supported for copy & paste!");
+        cnp_mode &= ~EFL_SELECTION_FORMAT_VCARD;
+        cnp_mode &= ~EFL_SELECTION_FORMAT_HTML;
+     }
+
+   if (sd->cnp_mode == cnp_format) return;
+   sd->cnp_mode = cnp_format;
+   if (sd->cnp_mode == EFL_SELECTION_FORMAT_TEXT)
+     dnd_format = ELM_SEL_FORMAT_TEXT;
+   else if (cnp_mode == EFL_SELECTION_FORMAT_IMAGE)
+     dnd_format |= ELM_SEL_FORMAT_IMAGE;
 
    elm_drop_target_del(obj, sd->drop_format,
                        _dnd_enter_cb, NULL,
                        _dnd_leave_cb, NULL,
                        _dnd_pos_cb, NULL,
                        _dnd_drop_cb, NULL);
-   sd->drop_format = format;
+   sd->drop_format = dnd_format;
    elm_drop_target_add(obj, sd->drop_format,
                        _dnd_enter_cb, NULL,
                        _dnd_leave_cb, NULL,
@@ -3631,7 +3643,7 @@ _efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Elm_Cnp_Mode cnp_mode)
                        _dnd_drop_cb, NULL);
 }
 
-EOLIAN static Elm_Cnp_Mode
+EOLIAN static Efl_Selection_Format
 _efl_ui_text_cnp_mode_get(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
 {
    return sd->cnp_mode;
index 7df95db..341a951 100644 (file)
@@ -59,6 +59,7 @@ class Efl.Ui.Text (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
          }
       }
       @property cnp_mode {
+         /* FIXME: Efl.Selection.Format does not allow markup without images! */
          set {
             [[Control pasting of text and images for the widget.
 
@@ -77,7 +78,7 @@ class Efl.Ui.Text (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
             ]]
          }
          values {
-            cnp_mode: Elm.Cnp_Mode; [[One of #Elm_Cnp_Mode: #ELM_CNP_MODE_MARKUP, #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT.]]
+            format: Efl.Selection.Format; [[Format for copy & paste.]]
          }
       }
       @property input_panel_language {