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)
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 = \
97 lib/elementary/efl_access_window.eo \ 97 lib/elementary/efl_access_window.eo \
98 lib/elementary/efl_config_global.eo \ 98 lib/elementary/efl_config_global.eo \
99 lib/elementary/elm_code_widget.eo \ 99 lib/elementary/elm_code_widget.eo \
100 lib/elementary/efl_selection.eo \
100 $(NULL) 101 $(NULL)
101 102
102# More public files -- FIXME 103# More public files -- FIXME
@@ -761,6 +762,7 @@ lib_elementary_libelementary_la_SOURCES = \
761 lib/elementary/efl_ui_scroll_manager.c \ 762 lib/elementary/efl_ui_scroll_manager.c \
762 lib/elementary/efl_ui_pan.c \ 763 lib/elementary/efl_ui_pan.c \
763 lib/elementary/efl_selection_manager.c \ 764 lib/elementary/efl_selection_manager.c \
765 lib/elementary/efl_selection.c \
764 $(NULL) 766 $(NULL)
765 767
766 768
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;
324# include "efl_selection_types.eot.h" 324# include "efl_selection_types.eot.h"
325# include "efl_ui_dnd_types.eot.h" 325# include "efl_ui_dnd_types.eot.h"
326# include <efl_ui_pan.eo.h> 326# include <efl_ui_pan.eo.h>
327# include "efl_selection.eo.h"
327#endif 328#endif
328 329
329/* include deprecated calls last of all */ 330/* 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 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define EFL_SELECTION_MANAGER_BETA
6
7#include <Elementary.h>
8#include "elm_priv.h"
9
10#define MY_CLASS EFL_SELECTION_MIXIN
11#define MY_CLASS_NAME "Efl.Selection"
12
13static inline Eo*
14_selection_manager_get(Eo *obj)
15{
16 Eo *top = elm_widget_top_get(obj);
17 if (!top)
18 {
19 top = obj;
20 }
21 Eo *sel_man = efl_key_data_get(top, "__selection_manager");
22 if (!sel_man)
23 {
24 sel_man = efl_add(EFL_SELECTION_MANAGER_CLASS, top);
25 efl_key_data_set(top, "__selection_manager", sel_man);
26 }
27 return sel_man;
28}
29
30EOLIAN static void
31_efl_selection_selection_get(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format,
32 void *data_func_data, Efl_Selection_Data_Ready data_func, Eina_Free_Cb data_func_free_cb, unsigned int seat)
33{
34 Eo *sel_man = _selection_manager_get(obj);
35 efl_selection_manager_selection_get(sel_man, obj, type, format,
36 data_func_data, data_func,
37 data_func_free_cb, seat);
38}
39
40EOLIAN static Eina_Future *
41_efl_selection_selection_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data, unsigned int seat)
42{
43 Eo *sel_man = _selection_manager_get(obj);
44 return efl_selection_manager_selection_set(sel_man, obj, type, format, data, seat);
45}
46
47EOLIAN static void
48_efl_selection_selection_clear(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat)
49{
50 Eo *sel_man = _selection_manager_get(obj);
51 efl_selection_manager_selection_clear(sel_man, obj, type, seat);
52}
53
54EOLIAN static Eina_Bool
55_efl_selection_has_owner(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat)
56{
57 Eo *sel_man = _selection_manager_get(obj);
58 return efl_selection_manager_selection_has_owner(sel_man, obj, type, seat);
59}
60
61
62#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 @@
1import efl_selection_types;
2
3mixin Efl.Selection {
4 [[Efl Selection class]]
5 data: null;
6 methods {
7 selection_set {
8 [[Set the selection data to the object]]
9 params {
10 @in type: Efl.Selection.Type; [[Selection Type]]
11 @in format: Efl.Selection.Format; [[Selection Format]]
12 @in data: Eina.Slice;
13 @in seat: uint;[[Specified seat for multiple seats case.]]
14 }
15 return: ptr(Eina.Future); [[Future for tracking when the selection is lost]]
16 }
17 selection_get {
18 [[Get the data from the object that has selection]]
19 params {
20 @in type: Efl.Selection.Type; [[Selection Type]]
21 @in format: Efl.Selection.Format; [[Selection Format]]
22 @in data_func: Efl.Selection.Data_Ready; [[Data ready function pointer]]
23 @in seat: uint;[[Specified seat for multiple seats case.]]
24 }
25 }
26 selection_clear {
27 [[Clear the selection data from the object]]
28 params {
29 @in type: Efl.Selection.Type; [[Selection Type]]
30 @in seat: uint; [[Specified seat for multiple seats case.]]
31 }
32 }
33 has_owner {
34 [[Determine whether the selection data has owner]]
35 params {
36 @in type: Efl.Selection.Type; [[Selection type]]
37 @in seat: uint; [[Specified seat for multiple seats case.]]
38 }
39 return: bool; [[EINA_TRUE if there is object owns selection, otherwise EINA_FALSE]]
40 }
41 }
42 events {
43 selection,changed; [[Called when display server's selection has changed]]
44 }
45}
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)
753 e.type = type; 753 e.type = type;
754 e.seat = 1; /* under x11 this is always the default seat */ 754 e.seat = 1; /* under x11 this is always the default seat */
755 e.exist = !!ev->owner; 755 e.exist = !!ev->owner;
756 //efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e); 756 efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e);
757 //ecore_event_add(ELM_CNP_EVENT_SELECTION_CHANGED, e, NULL, NULL); 757 //ecore_event_add(ELM_CNP_EVENT_SELECTION_CHANGED, e, NULL, NULL);
758 758
759 return ECORE_CALLBACK_RENEW; 759 return ECORE_CALLBACK_RENEW;
@@ -2512,7 +2512,7 @@ _wl_selection_changed(void *data, int type EINA_UNUSED, void *event)
2512 e.display = ecore_wl2_display_connect(ecore_wl2_display_name_get(ev->display)); 2512 e.display = ecore_wl2_display_connect(ecore_wl2_display_name_get(ev->display));
2513 e.exist = !!ecore_wl2_dnd_selection_get(seat); 2513 e.exist = !!ecore_wl2_dnd_selection_get(seat);
2514 //ecore_event_add(ELM_CNP_EVENT_SELECTION_CHANGED, e, _wl_selection_changed_free, ev->display); 2514 //ecore_event_add(ELM_CNP_EVENT_SELECTION_CHANGED, e, _wl_selection_changed_free, ev->display);
2515 //efl_event_callback_call(sel->request_obj, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e); 2515 efl_event_callback_call(sel->request_obj, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e);
2516 2516
2517 return ECORE_CALLBACK_RENEW; 2517 return ECORE_CALLBACK_RENEW;
2518} 2518}
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 {
17abstract Efl.Ui.Widget (Efl.Canvas.Group, Efl.Access, 17abstract Efl.Ui.Widget (Efl.Canvas.Group, Efl.Access,
18 Efl.Access.Component, Efl.Ui.Focus.User, Efl.Part, 18 Efl.Access.Component, Efl.Ui.Focus.User, Efl.Part,
19 Efl.Ui.Focus.Object, Efl.Ui.Base, Efl.Ui.Cursor, 19 Efl.Ui.Focus.Object, Efl.Ui.Base, Efl.Ui.Cursor,
20 Efl.Ui.Translatable) 20 Efl.Ui.Translatable, Efl.Selection)
21{ 21{
22 [[Elementary widget abstract class]] 22 [[Elementary widget abstract class]]
23 legacy_prefix: elm_widget; 23 legacy_prefix: elm_widget;