summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/Makefile.am4
-rw-r--r--src/lib/elm_button.c2
-rw-r--r--src/lib/elm_button.eo2
-rw-r--r--src/lib/elm_focusable.eo24
-rw-r--r--src/lib/elm_focuswidget.c73
-rw-r--r--src/lib/elm_focuswidget.eo7
6 files changed, 106 insertions, 6 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index cc5f5a8bd..1729e88b1 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -506,6 +506,7 @@ elm_helper.c \
506els_box.c \ 506els_box.c \
507els_cursor.c \ 507els_cursor.c \
508els_tooltip.c \ 508els_tooltip.c \
509elm_focuswidget.c \
509elu_ews_wm.c 510elu_ews_wm.c
510 511
511libelementary_la_CFLAGS = @ELEMENTARY_CFLAGS@ 512libelementary_la_CFLAGS = @ELEMENTARY_CFLAGS@
@@ -638,7 +639,8 @@ elm_toolbar_item.eo \
638elm_diskselector_item.eo \ 639elm_diskselector_item.eo \
639elm_popup_item.eo \ 640elm_popup_item.eo \
640elm_focus_manager.eo \ 641elm_focus_manager.eo \
641elm_focusable.eo 642elm_focusable.eo \
643elm_focuswidget.eo
642 644
643elm_eolian_type_files = \ 645elm_eolian_type_files = \
644elm_general.eot 646elm_general.eot
diff --git a/src/lib/elm_button.c b/src/lib/elm_button.c
index 43fb45b71..a3c2598e0 100644
--- a/src/lib/elm_button.c
+++ b/src/lib/elm_button.c
@@ -10,6 +10,8 @@
10#include "elm_widget_button.h" 10#include "elm_widget_button.h"
11#include "elm_widget_layout.h" 11#include "elm_widget_layout.h"
12 12
13#include "elm_focuswidget.eo.h"
14
13#define MY_CLASS ELM_BUTTON_CLASS 15#define MY_CLASS ELM_BUTTON_CLASS
14 16
15#define MY_CLASS_NAME "Elm_Button" 17#define MY_CLASS_NAME "Elm_Button"
diff --git a/src/lib/elm_button.eo b/src/lib/elm_button.eo
index f1b1164e3..5d27e99a4 100644
--- a/src/lib/elm_button.eo
+++ b/src/lib/elm_button.eo
@@ -1,4 +1,4 @@
1class Elm.Button (Elm.Layout, Evas.Clickable_Interface, 1class Elm.Button (Elm.Focuswidget, Evas.Clickable_Interface,
2 Elm.Interface_Atspi_Widget_Action) 2 Elm.Interface_Atspi_Widget_Action)
3{ 3{
4 eo_prefix: elm_obj_button; 4 eo_prefix: elm_obj_button;
diff --git a/src/lib/elm_focusable.eo b/src/lib/elm_focusable.eo
index d868c6f7a..4d8a831fa 100644
--- a/src/lib/elm_focusable.eo
+++ b/src/lib/elm_focusable.eo
@@ -2,13 +2,29 @@ interface Elm.Focusable {
2 [[Implemented by objects which may be focusable]] 2 [[Implemented by objects which may be focusable]]
3 legacy_prefix: null; 3 legacy_prefix: null;
4 methods { 4 methods {
5 focusable { 5 @property focusable {
6 [[returns true if this object is focusable]] 6 [[returns true if this object is focusable]]
7 return : bool; 7 values {
8 focusable : bool;
9 }
10 set {
11
12 }
13 get {
14
15 }
8 } 16 }
9 focus { 17 @property focus {
10 [[returnds if this object is currently focused]] 18 [[returnds if this object is currently focused]]
11 return : bool; 19 values {
20 focus : bool;
21 }
22 set {
23
24 }
25 get {
26
27 }
12 } 28 }
13 } 29 }
14 events { 30 events {
diff --git a/src/lib/elm_focuswidget.c b/src/lib/elm_focuswidget.c
new file mode 100644
index 000000000..0cfc8adc4
--- /dev/null
+++ b/src/lib/elm_focuswidget.c
@@ -0,0 +1,73 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4#include "elm_focuswidget.eo.h"
5#include "elm_focusable.eo.h"
6#include "elm_focus_manager.eo.h"
7#include "elm_layout.eo.h"
8typedef struct {
9 Eina_Bool focusable;
10 Eina_Bool focus;
11} Elm_Focuswidget_Data;
12
13
14EOLIAN static void
15_elm_focuswidget_elm_focusable_focus_set(Eo *obj, Elm_Focuswidget_Data *pd, Eina_Bool focus)
16{
17 if (!pd->focusable) return;
18
19 pd->focus = focus;
20
21 eo_do(obj, eo_event_callback_call(pd->focus ? ELM_FOCUSABLE_EVENT_FOCUS_ON : ELM_FOCUSABLE_EVENT_FOCUS_OFF, NULL));
22}
23
24
25EOLIAN static Eina_Bool
26_elm_focuswidget_elm_focusable_focus_get(Eo *obj, Elm_Focuswidget_Data *pd)
27{
28 return pd->focus;
29}
30
31
32EOLIAN static void
33_elm_focuswidget_elm_focusable_focusable_set(Eo *obj, Elm_Focuswidget_Data *pd, Eina_Bool focusable)
34{
35 pd->focusable = focusable;
36
37 if (!focusable)
38 eo_do(obj, elm_focusable_focus_set(EINA_FALSE));
39}
40
41
42EOLIAN static Eina_Bool
43_elm_focuswidget_elm_focusable_focusable_get(Eo *obj, Elm_Focuswidget_Data *pd)
44{
45 return pd->focusable;
46}
47
48EOLIAN static Eo*
49_elm_focuswidget_eo_base_finalize(Eo *obj, Elm_Focuswidget_Data *pd)
50{
51 Eo *eo;
52 Eo *nextParent;
53 eo_do_super(obj, ELM_FOCUSWIDGET_CLASS, eo = eo_finalize());
54
55 eo_do(obj, nextParent = eo_parent_get());
56
57 do {
58 if (eo_isa(nextParent, ELM_FOCUS_MANAGER_INTERFACE))
59 {
60 eo_do(nextParent, elm_focus_manager_register_simple(obj));
61 break;
62 }
63 eo_do(nextParent, nextParent = eo_parent_get());
64 } while (nextParent);
65
66 if (!nextParent)
67 printf("Failed to find the highest focus manager\n");
68
69 return eo;
70}
71
72
73#include "elm_focuswidget.eo.c" \ No newline at end of file
diff --git a/src/lib/elm_focuswidget.eo b/src/lib/elm_focuswidget.eo
new file mode 100644
index 000000000..63f36f898
--- /dev/null
+++ b/src/lib/elm_focuswidget.eo
@@ -0,0 +1,7 @@
1class Elm.Focuswidget (Elm.Layout, Elm.Focusable) {
2 implements {
3 Elm.Focusable.focus;
4 Elm.Focusable.focusable;
5 Eo.Base.finalize;
6 }
7} \ No newline at end of file