summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2018-01-09 15:34:12 +0900
committerThiep Ha <thiepha@gmail.com>2018-01-11 17:56:24 +0900
commitf191d6821f0fd94389dc92c8353b769eaacad28a (patch)
treec44917a3ef1a7da2bbbdcd6cfc79a9407ac9254b
parent763daa870e4013361727be61798f11ffc9ad2594 (diff)
downloadefl-f191d6821f0fd94389dc92c8353b769eaacad28a.tar.gz
selection: add efl_selection interface
Efl_Selection is the object interface for selection api of elm_cnp. It allows get, set, clear, check selection.
-rw-r--r--src/Makefile_Elementary.am2
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/efl_selection.c62
-rw-r--r--src/lib/elementary/efl_selection.eo45
-rw-r--r--src/lib/elementary/efl_selection_manager.c4
-rw-r--r--src/lib/elementary/efl_ui_widget.eo2
6 files changed, 113 insertions, 3 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index b1ac2657ae..a1712eca5e 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -97,6 +97,7 @@ elm_public_eolian_files = \
lib/elementary/efl_access_window.eo \
lib/elementary/efl_config_global.eo \
lib/elementary/elm_code_widget.eo \
+ lib/elementary/efl_selection.eo \
$(NULL)
# More public files -- FIXME
@@ -761,6 +762,7 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/efl_ui_scroll_manager.c \
lib/elementary/efl_ui_pan.c \
lib/elementary/efl_selection_manager.c \
+ lib/elementary/efl_selection.c \
$(NULL)
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index b5c58c77f7..2e5e4cb5b7 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -324,6 +324,7 @@ EAPI extern Elm_Version *elm_version;
# include "efl_selection_types.eot.h"
# include "efl_ui_dnd_types.eot.h"
# include <efl_ui_pan.eo.h>
+# include "efl_selection.eo.h"
#endif
/* include deprecated calls last of all */
diff --git a/src/lib/elementary/efl_selection.c b/src/lib/elementary/efl_selection.c
new file mode 100644
index 0000000000..9f086e340e
--- /dev/null
+++ b/src/lib/elementary/efl_selection.c
@@ -0,0 +1,62 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#define EFL_SELECTION_MANAGER_BETA
+
+#include <Elementary.h>
+#include "elm_priv.h"
+
+#define MY_CLASS EFL_SELECTION_MIXIN
+#define MY_CLASS_NAME "Efl.Selection"
+
+static inline Eo*
+_selection_manager_get(Eo *obj)
+{
+ Eo *top = elm_widget_top_get(obj);
+ if (!top)
+ {
+ top = obj;
+ }
+ Eo *sel_man = efl_key_data_get(top, "__selection_manager");
+ if (!sel_man)
+ {
+ sel_man = efl_add(EFL_SELECTION_MANAGER_CLASS, top);
+ efl_key_data_set(top, "__selection_manager", sel_man);
+ }
+ return sel_man;
+}
+
+EOLIAN static void
+_efl_selection_selection_get(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format,
+ void *data_func_data, Efl_Selection_Data_Ready data_func, Eina_Free_Cb data_func_free_cb, unsigned int seat)
+{
+ Eo *sel_man = _selection_manager_get(obj);
+ efl_selection_manager_selection_get(sel_man, obj, type, format,
+ data_func_data, data_func,
+ data_func_free_cb, seat);
+}
+
+EOLIAN static Eina_Future *
+_efl_selection_selection_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data, unsigned int seat)
+{
+ Eo *sel_man = _selection_manager_get(obj);
+ return efl_selection_manager_selection_set(sel_man, obj, type, format, data, seat);
+}
+
+EOLIAN static void
+_efl_selection_selection_clear(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat)
+{
+ Eo *sel_man = _selection_manager_get(obj);
+ efl_selection_manager_selection_clear(sel_man, obj, type, seat);
+}
+
+EOLIAN static Eina_Bool
+_efl_selection_has_owner(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat)
+{
+ Eo *sel_man = _selection_manager_get(obj);
+ return efl_selection_manager_selection_has_owner(sel_man, obj, type, seat);
+}
+
+
+#include "efl_selection.eo.c"
diff --git a/src/lib/elementary/efl_selection.eo b/src/lib/elementary/efl_selection.eo
new file mode 100644
index 0000000000..2f836567a1
--- /dev/null
+++ b/src/lib/elementary/efl_selection.eo
@@ -0,0 +1,45 @@
+import efl_selection_types;
+
+mixin Efl.Selection {
+ [[Efl Selection class]]
+ data: null;
+ methods {
+ selection_set {
+ [[Set the selection data to the object]]
+ params {
+ @in type: Efl.Selection.Type; [[Selection Type]]
+ @in format: Efl.Selection.Format; [[Selection Format]]
+ @in data: Eina.Slice;
+ @in seat: uint;[[Specified seat for multiple seats case.]]
+ }
+ return: ptr(Eina.Future); [[Future for tracking when the selection is lost]]
+ }
+ selection_get {
+ [[Get the data from the object that has selection]]
+ params {
+ @in type: Efl.Selection.Type; [[Selection Type]]
+ @in format: Efl.Selection.Format; [[Selection Format]]
+ @in data_func: Efl.Selection.Data_Ready; [[Data ready function pointer]]
+ @in seat: uint;[[Specified seat for multiple seats case.]]
+ }
+ }
+ selection_clear {
+ [[Clear the selection data from the object]]
+ params {
+ @in type: Efl.Selection.Type; [[Selection Type]]
+ @in seat: uint; [[Specified seat for multiple seats case.]]
+ }
+ }
+ has_owner {
+ [[Determine whether the selection data has owner]]
+ params {
+ @in type: Efl.Selection.Type; [[Selection type]]
+ @in seat: uint; [[Specified seat for multiple seats case.]]
+ }
+ return: bool; [[EINA_TRUE if there is object owns selection, otherwise EINA_FALSE]]
+ }
+ }
+ events {
+ selection,changed; [[Called when display server's selection has changed]]
+ }
+}
diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c
index 23bde3bded..6aaf9d8eed 100644
--- a/src/lib/elementary/efl_selection_manager.c
+++ b/src/lib/elementary/efl_selection_manager.c
@@ -753,7 +753,7 @@ _x11_fixes_selection_notify(void *data, int t EINA_UNUSED, void *event)
e.type = type;
e.seat = 1; /* under x11 this is always the default seat */
e.exist = !!ev->owner;
- //efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e);
+ efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e);
//ecore_event_add(ELM_CNP_EVENT_SELECTION_CHANGED, e, NULL, NULL);
return ECORE_CALLBACK_RENEW;
@@ -2512,7 +2512,7 @@ _wl_selection_changed(void *data, int type EINA_UNUSED, void *event)
e.display = ecore_wl2_display_connect(ecore_wl2_display_name_get(ev->display));
e.exist = !!ecore_wl2_dnd_selection_get(seat);
//ecore_event_add(ELM_CNP_EVENT_SELECTION_CHANGED, e, _wl_selection_changed_free, ev->display);
- //efl_event_callback_call(sel->request_obj, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e);
+ efl_event_callback_call(sel->request_obj, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e);
return ECORE_CALLBACK_RENEW;
}
diff --git a/src/lib/elementary/efl_ui_widget.eo b/src/lib/elementary/efl_ui_widget.eo
index f4933d4438..d0c1797c80 100644
--- a/src/lib/elementary/efl_ui_widget.eo
+++ b/src/lib/elementary/efl_ui_widget.eo
@@ -17,7 +17,7 @@ struct Efl.Ui.Widget.Focus_State {
abstract Efl.Ui.Widget (Efl.Canvas.Group, Efl.Access,
Efl.Access.Component, Efl.Ui.Focus.User, Efl.Part,
Efl.Ui.Focus.Object, Efl.Ui.Base, Efl.Ui.Cursor,
- Efl.Ui.Translatable)
+ Efl.Ui.Translatable, Efl.Selection)
{
[[Elementary widget abstract class]]
legacy_prefix: elm_widget;