summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2014-05-27 16:23:13 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-05-27 16:23:13 +0900
commit0c26825eb931c80aa17b5caa1cec76e4cd08c960 (patch)
tree3af45ee9f30c2b2e25936d1f09106b2582856403
parent35021cfd6e87704971bc3005d1e500e05f206212 (diff)
atspi: add AtspiImage interface support.
Summary: Sample implementation for elm_image added. Reviewers: raster, seoz Differential Revision: https://phab.enlightenment.org/D794
-rw-r--r--src/lib/Makefile.am5
-rw-r--r--src/lib/elm_atspi_bridge.c118
-rw-r--r--src/lib/elm_image.c27
-rw-r--r--src/lib/elm_image.eo3
-rw-r--r--src/lib/elm_interface_atspi_image.c43
-rw-r--r--src/lib/elm_interface_atspi_image.eo43
6 files changed, 238 insertions, 1 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 075becc1a..f012fb516 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -452,6 +452,7 @@ elm_index.c \
452elm_interface_atspi_accessible.c \ 452elm_interface_atspi_accessible.c \
453elm_interface_atspi_action.c \ 453elm_interface_atspi_action.c \
454elm_interface_atspi_component.c \ 454elm_interface_atspi_component.c \
455elm_interface_atspi_image.c \
455elm_interface_atspi_value.c \ 456elm_interface_atspi_value.c \
456elm_interface_atspi_widget.c \ 457elm_interface_atspi_widget.c \
457elm_interface_atspi_widget_action.c \ 458elm_interface_atspi_widget_action.c \
@@ -658,6 +659,8 @@ BUILT_SOURCES = \
658 elm_interface_atspi_action.eo.h \ 659 elm_interface_atspi_action.eo.h \
659 elm_interface_atspi_component.eo.c \ 660 elm_interface_atspi_component.eo.c \
660 elm_interface_atspi_component.eo.h \ 661 elm_interface_atspi_component.eo.h \
662 elm_interface_atspi_image.eo.c \
663 elm_interface_atspi_image.eo.h \
661 elm_interface_atspi_value.eo.c \ 664 elm_interface_atspi_value.eo.c \
662 elm_interface_atspi_value.eo.h \ 665 elm_interface_atspi_value.eo.h \
663 elm_interface_atspi_widget.eo.c \ 666 elm_interface_atspi_widget.eo.c \
@@ -789,6 +792,7 @@ elementaryeolianfiles_DATA = \
789 elm_interface_atspi_accessible.eo \ 792 elm_interface_atspi_accessible.eo \
790 elm_interface_atspi_action.eo \ 793 elm_interface_atspi_action.eo \
791 elm_interface_atspi_component.eo \ 794 elm_interface_atspi_component.eo \
795 elm_interface_atspi_image.eo \
792 elm_interface_atspi_value.eo \ 796 elm_interface_atspi_value.eo \
793 elm_interface_atspi_widget.eo \ 797 elm_interface_atspi_widget.eo \
794 elm_interface_atspi_widget_action.eo \ 798 elm_interface_atspi_widget_action.eo \
@@ -881,6 +885,7 @@ nodist_includesunstable_HEADERS = \
881 elm_interface_atspi_accessible.eo.h \ 885 elm_interface_atspi_accessible.eo.h \
882 elm_interface_atspi_action.eo.h \ 886 elm_interface_atspi_action.eo.h \
883 elm_interface_atspi_component.eo.h \ 887 elm_interface_atspi_component.eo.h \
888 elm_interface_atspi_image.eo.h \
884 elm_interface_atspi_value.eo.h \ 889 elm_interface_atspi_value.eo.h \
885 elm_interface_atspi_widget.eo.h \ 890 elm_interface_atspi_widget.eo.h \
886 elm_interface_atspi_widget_action.eo.h \ 891 elm_interface_atspi_widget_action.eo.h \
diff --git a/src/lib/elm_atspi_bridge.c b/src/lib/elm_atspi_bridge.c
index 216fdfd04..a488c6283 100644
--- a/src/lib/elm_atspi_bridge.c
+++ b/src/lib/elm_atspi_bridge.c
@@ -6,6 +6,7 @@
6#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED 6#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
7#define ELM_INTERFACE_ATSPI_ACTION_PROTECTED 7#define ELM_INTERFACE_ATSPI_ACTION_PROTECTED
8#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED 8#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED
9#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED
9#include "atspi/atspi-constants.h" 10#include "atspi/atspi-constants.h"
10 11
11#include <stdint.h> 12#include <stdint.h>
@@ -19,6 +20,7 @@
19#include "elm_interface_atspi_window.eo.h" 20#include "elm_interface_atspi_window.eo.h"
20#include "elm_interface_atspi_action.eo.h" 21#include "elm_interface_atspi_action.eo.h"
21#include "elm_interface_atspi_value.eo.h" 22#include "elm_interface_atspi_value.eo.h"
23#include "elm_interface_atspi_image.eo.h"
22 24
23/* 25/*
24 * Accessibility Bus info not defined in atspi-constants.h 26 * Accessibility Bus info not defined in atspi-constants.h
@@ -706,6 +708,80 @@ static const Eldbus_Method action_methods[] = {
706 { NULL, NULL, NULL, NULL, 0 } 708 { NULL, NULL, NULL, NULL, 0 }
707}; 709};
708 710
711static Eldbus_Message *
712_image_extents_get(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
713{
714 AtspiCoordType type;
715 Eldbus_Message *ret;
716 const char *obj_path = eldbus_service_object_path_get(iface);
717 int x, y, w, h;
718 Eina_Bool screen_coords;
719 Eo *obj = _access_object_from_path(obj_path);
720
721 x = y = w = h = -1;
722
723 if (!eldbus_message_arguments_get(msg, "u", &type))
724 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
725
726 ret = eldbus_message_method_return_new(msg);
727 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
728
729 screen_coords = type == ATSPI_COORD_TYPE_SCREEN ? EINA_TRUE : EINA_FALSE;
730 eo_do(obj, elm_interface_atspi_image_extents_get(screen_coords, &x, &y, &w, &h));
731 eldbus_message_arguments_append(ret, "iiii", x, y, w, h);
732
733 return ret;
734}
735
736static Eldbus_Message *
737_image_position_get(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
738{
739 AtspiCoordType type;
740 Eldbus_Message *ret;
741 const char *obj_path = eldbus_service_object_path_get(iface);
742 Eo *obj = _access_object_from_path(obj_path);
743 int x = -1, y = -1;
744 Eina_Bool screen_coords;
745
746 if (!eldbus_message_arguments_get(msg, "u", &type))
747 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
748
749 ret = eldbus_message_method_return_new(msg);
750 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
751
752 screen_coords = type == ATSPI_COORD_TYPE_SCREEN ? EINA_TRUE : EINA_FALSE;
753 eo_do(obj, elm_interface_atspi_image_extents_get(screen_coords, &x, &y, NULL, NULL));
754 eldbus_message_arguments_append(ret, "i", x);
755 eldbus_message_arguments_append(ret, "i", y);
756
757 return ret;
758}
759
760static Eldbus_Message *
761_image_size_get(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
762{
763 Eldbus_Message *ret;
764 const char *obj_path = eldbus_service_object_path_get(iface);
765 Eo *obj = _access_object_from_path(obj_path);
766 int w = -1, h = -1;
767
768 ret = eldbus_message_method_return_new(msg);
769 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
770
771 eo_do(obj, elm_interface_atspi_image_extents_get(EINA_FALSE, NULL, NULL, &w, &h));
772 eldbus_message_arguments_append(ret, "i", w);
773 eldbus_message_arguments_append(ret, "i", h);
774
775 return ret;
776}
777
778static const Eldbus_Method image_methods[] = {
779 { "GetImageExtents", ELDBUS_ARGS({"u", "coordType"}), ELDBUS_ARGS({"iiii", "extents"}), _image_extents_get, 0 },
780 { "GetImagePosition", ELDBUS_ARGS({"u", "coordType"}), ELDBUS_ARGS({"i", "x"}, {"i", "y"}), _image_position_get, 0 },
781 { "GetImageSize", NULL, ELDBUS_ARGS({"i", "width"}, {"i", "height"}), _image_size_get, 0 },
782 { NULL, NULL, NULL, NULL, 0 }
783};
784
709static Eo * 785static Eo *
710_access_object_from_path(const char *path) 786_access_object_from_path(const char *path)
711{ 787{
@@ -875,6 +951,34 @@ _value_properties_get(const Eldbus_Service_Interface *interface, const char *pro
875 return EINA_FALSE; 951 return EINA_FALSE;
876} 952}
877 953
954static Eina_Bool
955_image_properties_get(const Eldbus_Service_Interface *interface, const char *property,
956 Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED,
957 Eldbus_Message **error EINA_UNUSED)
958{
959 const char *value;
960 const char *obj_path = eldbus_service_object_path_get(interface);
961 Eo *obj = _access_object_from_path(obj_path);
962
963 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
964
965 if (!strcmp(property, "ImageDescription"))
966 {
967 eo_do(obj, value = elm_interface_atspi_image_description_get());
968 value = value ? value : "";
969 eldbus_message_iter_basic_append(iter, 's', value);
970 return EINA_TRUE;
971 }
972 if (!strcmp(property, "ImageLocale"))
973 {
974 eo_do(obj, value = elm_interface_atspi_image_locale_get());
975 value = value ? value : "";
976 eldbus_message_iter_basic_append(iter, 's', value);
977 return EINA_TRUE;
978 }
979 return EINA_FALSE;
980}
981
878static const Eldbus_Property accessible_properties[] = { 982static const Eldbus_Property accessible_properties[] = {
879 { "Name", "s", _accessible_property_get, NULL, 0 }, 983 { "Name", "s", _accessible_property_get, NULL, 0 },
880 { "Description", "s", _accessible_property_get, NULL, 0 }, 984 { "Description", "s", _accessible_property_get, NULL, 0 },
@@ -896,6 +1000,12 @@ static const Eldbus_Property value_properties[] = {
896 { NULL, NULL, NULL, NULL, 0 } 1000 { NULL, NULL, NULL, NULL, 0 }
897}; 1001};
898 1002
1003static const Eldbus_Property image_properties[] = {
1004 { "ImageDescription", "s", NULL, NULL, 0 },
1005 { "ImageLocale", "s", NULL, NULL, 0 },
1006 { NULL, NULL, NULL, NULL, 0 }
1007};
1008
899static const Eldbus_Service_Interface_Desc accessible_iface_desc = { 1009static const Eldbus_Service_Interface_Desc accessible_iface_desc = {
900 ATSPI_DBUS_INTERFACE_ACCESSIBLE, accessible_methods, NULL, accessible_properties, _accessible_property_get, NULL 1010 ATSPI_DBUS_INTERFACE_ACCESSIBLE, accessible_methods, NULL, accessible_properties, _accessible_property_get, NULL
901}; 1011};
@@ -916,6 +1026,10 @@ static const Eldbus_Service_Interface_Desc value_iface_desc = {
916 ATSPI_DBUS_INTERFACE_VALUE, NULL, NULL, value_properties, _value_properties_get, _value_properties_set 1026 ATSPI_DBUS_INTERFACE_VALUE, NULL, NULL, value_properties, _value_properties_get, _value_properties_set
917}; 1027};
918 1028
1029static const Eldbus_Service_Interface_Desc image_iface_desc = {
1030 ATSPI_DBUS_INTERFACE_IMAGE, image_methods, NULL, image_properties, _image_properties_get, NULL
1031};
1032
919static void 1033static void
920_object_append_reference(Eldbus_Message_Iter *iter, Eo *obj) 1034_object_append_reference(Eldbus_Message_Iter *iter, Eo *obj)
921{ 1035{
@@ -994,6 +1108,8 @@ _append_item_fn(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
994 eldbus_message_iter_basic_append(iter_sub_array, 's', ATSPI_DBUS_INTERFACE_ACTION); 1108 eldbus_message_iter_basic_append(iter_sub_array, 's', ATSPI_DBUS_INTERFACE_ACTION);
995 if (eo_isa(data, ELM_INTERFACE_ATSPI_VALUE_CLASS)) 1109 if (eo_isa(data, ELM_INTERFACE_ATSPI_VALUE_CLASS))
996 eldbus_message_iter_basic_append(iter_sub_array, 's', ATSPI_DBUS_INTERFACE_VALUE); 1110 eldbus_message_iter_basic_append(iter_sub_array, 's', ATSPI_DBUS_INTERFACE_VALUE);
1111 if (eo_isa(data, ELM_INTERFACE_ATSPI_IMAGE_CLASS))
1112 eldbus_message_iter_basic_append(iter_sub_array, 's', ATSPI_DBUS_INTERFACE_IMAGE);
997 1113
998 eldbus_message_iter_container_close(iter_struct, iter_sub_array); 1114 eldbus_message_iter_container_close(iter_struct, iter_sub_array);
999 1115
@@ -1887,6 +2003,8 @@ static void _object_register(Eo *obj, char *path)
1887 eldbus_service_interface_register(_a11y_bus, path, &action_iface_desc); 2003 eldbus_service_interface_register(_a11y_bus, path, &action_iface_desc);
1888 if (eo_isa(obj, ELM_INTERFACE_ATSPI_VALUE_CLASS)) 2004 if (eo_isa(obj, ELM_INTERFACE_ATSPI_VALUE_CLASS))
1889 eldbus_service_interface_register(_a11y_bus, path, &value_iface_desc); 2005 eldbus_service_interface_register(_a11y_bus, path, &value_iface_desc);
2006 if (eo_isa(obj, ELM_INTERFACE_ATSPI_IMAGE_CLASS))
2007 eldbus_service_interface_register(_a11y_bus, path, &image_iface_desc);
1890 } 2008 }
1891} 2009}
1892 2010
diff --git a/src/lib/elm_image.c b/src/lib/elm_image.c
index ac90ce880..7125fe3df 100644
--- a/src/lib/elm_image.c
+++ b/src/lib/elm_image.c
@@ -7,6 +7,9 @@
7#include "elm_priv.h" 7#include "elm_priv.h"
8#include "elm_widget_image.h" 8#include "elm_widget_image.h"
9 9
10#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED
11#include "elm_interface_atspi_image.eo.h"
12
10#define FMT_SIZE_T "%zu" 13#define FMT_SIZE_T "%zu"
11 14
12#define MY_CLASS ELM_OBJ_IMAGE_CLASS 15#define MY_CLASS ELM_OBJ_IMAGE_CLASS
@@ -1313,4 +1316,28 @@ _elm_image_class_constructor(Eo_Class *klass)
1313 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 1316 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
1314} 1317}
1315 1318
1319// A11Y
1320
1321EOLIAN static void
1322_elm_image_elm_interface_atspi_image_extents_get(Eo *obj, Elm_Image_Data *sd EINA_UNUSED, Eina_Bool screen_coords, int *x, int *y, int *w, int *h)
1323{
1324 int ee_x, ee_y;
1325 Evas_Object *image = elm_image_object_get(obj);
1326 if (!image) return;
1327
1328 evas_object_geometry_get(image, x, y, NULL, NULL);
1329 if (screen_coords)
1330 {
1331 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(image));
1332 if (!ee) return;
1333 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
1334 if (x) *x += ee_x;
1335 if (y) *y += ee_y;
1336 }
1337 elm_image_object_size_get(obj, w, h);
1338}
1339
1340
1341// A11Y - END
1342
1316#include "elm_image.eo.c" 1343#include "elm_image.eo.c"
diff --git a/src/lib/elm_image.eo b/src/lib/elm_image.eo
index 812b0ad3c..5e4a49820 100644
--- a/src/lib/elm_image.eo
+++ b/src/lib/elm_image.eo
@@ -1,4 +1,4 @@
1class Elm_Image (Elm_Widget, Evas_Clickable_Interface) 1class Elm_Image (Elm_Widget, Evas_Clickable_Interface, Elm_Interface_Atspi_Image)
2{ 2{
3 eo_prefix: elm_obj_image; 3 eo_prefix: elm_obj_image;
4 properties { 4 properties {
@@ -547,6 +547,7 @@ class Elm_Image (Elm_Widget, Evas_Clickable_Interface)
547 Evas_Smart::resize; 547 Evas_Smart::resize;
548 Elm_Widget::theme_apply; 548 Elm_Widget::theme_apply;
549 Elm_Widget::event; 549 Elm_Widget::event;
550 Elm_Interface_Atspi_Image::extents::get;
550 } 551 }
551 events { 552 events {
552 drop; 553 drop;
diff --git a/src/lib/elm_interface_atspi_image.c b/src/lib/elm_interface_atspi_image.c
new file mode 100644
index 000000000..bc4df190a
--- /dev/null
+++ b/src/lib/elm_interface_atspi_image.c
@@ -0,0 +1,43 @@
1#ifdef HAVE_CONFIG_H
2 #include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_widget.h"
7#include "elm_priv.h"
8
9#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED
10
11#include "elm_interface_atspi_image.eo.h"
12
13static void
14_free_desc(void *data)
15{
16 eina_stringshare_del(data);
17}
18
19EOLIAN static const char*
20_elm_interface_atspi_image_description_get(Eo *obj, void *sd EINA_UNUSED)
21{
22 const char *descr = NULL;
23
24 eo_do(obj, descr = eo_key_data_get("atspi_image_description"));
25 return descr;
26}
27
28EOLIAN static void
29_elm_interface_atspi_image_description_set(Eo *obj, void *sd EINA_UNUSED, const char *description)
30{
31 const char *descr = eina_stringshare_add(description);
32 eo_do(obj, eo_key_data_set("atspi_image_description", descr, _free_desc));
33}
34
35EOLIAN static const char*
36_elm_interface_atspi_image_locale_get(Eo *obj EINA_UNUSED, void *sd EINA_UNUSED)
37{
38 // by default assume that descriptions are given in language of current
39 // locale.
40 return getenv("LANG");
41}
42
43#include "elm_interface_atspi_image.eo.c"
diff --git a/src/lib/elm_interface_atspi_image.eo b/src/lib/elm_interface_atspi_image.eo
new file mode 100644
index 000000000..3d072a8d9
--- /dev/null
+++ b/src/lib/elm_interface_atspi_image.eo
@@ -0,0 +1,43 @@
1mixin Elm_Interface_Atspi_Image ()
2{
3 legacy_prefix: null;
4 eo_prefix: elm_interface_atspi_image;
5 data: null;
6 properties {
7 protected extents {
8 get {
9 /*@ Gets an image extents. */
10 }
11 keys {
12 Eina_Bool screen_coords;
13 }
14 values {
15 int x;
16 int y;
17 int width;
18 int height;
19 }
20 }
21 description {
22 get {
23 /* Gets textual description of image */
24 }
25 set {
26 }
27 values {
28 const char *description;
29 }
30 }
31 protected locale {
32 get {
33 /* Gets locale of the image description. */
34 }
35 values {
36 const char *locale;
37 }
38 }
39 }
40 implements {
41 virtual::extents::get;
42 }
43}