summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-05-05 13:16:19 +0100
committerTom Hacohen <tom@stosb.com>2015-05-06 15:46:46 +0100
commitc1f53db3c07d5f8c3bca9f4377a1fc3a6938b87c (patch)
tree2578c955c11c26971efc496656fccec1f27856cc
parentedc3ba59a5b1fcf1405b3a0badaa48c0e837903e (diff)
elm_photocam: use Efl.File in Elm_Photocam
Summary: Address the issue: - Elm photocam and the file interface clash on file_set. Specified in the page: https://phab.enlightenment.org/w/efl_interfaces/ Reviewers: felipealmeida, tasn Differential Revision: https://phab.enlightenment.org/D2351
-rw-r--r--src/lib/elm_photocam.c71
-rw-r--r--src/lib/elm_photocam.eo35
-rw-r--r--src/lib/elm_photocam_legacy.h32
3 files changed, 101 insertions, 37 deletions
diff --git a/src/lib/elm_photocam.c b/src/lib/elm_photocam.c
index 96e98af48..c4ae9b640 100644
--- a/src/lib/elm_photocam.c
+++ b/src/lib/elm_photocam.c
@@ -76,6 +76,13 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
76 {NULL, NULL} 76 {NULL, NULL}
77}; 77};
78 78
79static Eina_Error PHOTO_FILE_LOAD_ERROR_GENERIC;
80static Eina_Error PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST;
81static Eina_Error PHOTO_FILE_LOAD_ERROR_PERMISSION_DENIED;
82static Eina_Error PHOTO_FILE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
83static Eina_Error PHOTO_FILE_LOAD_ERROR_CORRUPT_FILE;
84static Eina_Error PHOTO_FILE_LOAD_ERROR_UNKNOWN_FORMAT;
85
79static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); 86static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
80static Eina_Bool _key_action_zoom(Evas_Object *obj, const char *params); 87static Eina_Bool _key_action_zoom(Evas_Object *obj, const char *params);
81 88
@@ -1617,8 +1624,8 @@ static const char *remote_uri[] = {
1617 "http://", "https://", "ftp://" 1624 "http://", "https://", "ftp://"
1618}; 1625};
1619 1626
1620EOLIAN static Evas_Load_Error 1627static Evas_Load_Error
1621_elm_photocam_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file) 1628_elm_photocam_file_set_internal(Eo *obj, Elm_Photocam_Data *sd, const char *file)
1622{ 1629{
1623 Evas_Load_Error ret = EVAS_LOAD_ERROR_NONE; 1630 Evas_Load_Error ret = EVAS_LOAD_ERROR_NONE;
1624 unsigned int i; 1631 unsigned int i;
@@ -1664,10 +1671,57 @@ _elm_photocam_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file)
1664 return ret; 1671 return ret;
1665} 1672}
1666 1673
1667EOLIAN static const char* 1674EOLIAN static Eina_Bool
1668_elm_photocam_file_get(Eo *obj EINA_UNUSED, Elm_Photocam_Data *sd) 1675_elm_photocam_efl_file_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file, const char *key EINA_UNUSED)
1669{ 1676{
1670 return sd->file; 1677 Evas_Load_Error ret = _elm_photocam_file_set_internal(obj, sd, file);
1678
1679 if (ret == EVAS_LOAD_ERROR_NONE) return EINA_TRUE;
1680
1681 eina_error_set(
1682 ret == EVAS_LOAD_ERROR_DOES_NOT_EXIST ? PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST :
1683 ret == EVAS_LOAD_ERROR_PERMISSION_DENIED ? PHOTO_FILE_LOAD_ERROR_PERMISSION_DENIED :
1684 ret == EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED ? PHOTO_FILE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED :
1685 ret == EVAS_LOAD_ERROR_CORRUPT_FILE ? PHOTO_FILE_LOAD_ERROR_CORRUPT_FILE :
1686 ret == EVAS_LOAD_ERROR_UNKNOWN_FORMAT ? PHOTO_FILE_LOAD_ERROR_UNKNOWN_FORMAT :
1687 PHOTO_FILE_LOAD_ERROR_GENERIC
1688 );
1689 return EINA_FALSE;
1690}
1691
1692EAPI Evas_Load_Error
1693elm_photocam_file_set(Elm_Photocam *obj, const char *file)
1694{
1695 Eina_Bool ret;
1696 if (eo_do_ret(obj, ret, efl_file_set(file, NULL))) return EVAS_LOAD_ERROR_NONE;
1697
1698 Eina_Error err = eina_error_get();
1699 return err == PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST ?
1700 EVAS_LOAD_ERROR_DOES_NOT_EXIST :
1701 err == PHOTO_FILE_LOAD_ERROR_PERMISSION_DENIED ?
1702 EVAS_LOAD_ERROR_PERMISSION_DENIED :
1703 err == PHOTO_FILE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED ?
1704 EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED :
1705 err == PHOTO_FILE_LOAD_ERROR_CORRUPT_FILE ?
1706 EVAS_LOAD_ERROR_CORRUPT_FILE :
1707 err == PHOTO_FILE_LOAD_ERROR_UNKNOWN_FORMAT ?
1708 EVAS_LOAD_ERROR_UNKNOWN_FORMAT :
1709 EVAS_LOAD_ERROR_GENERIC;
1710}
1711
1712EOLIAN static void
1713_elm_photocam_efl_file_file_get(Eo *obj EINA_UNUSED, Elm_Photocam_Data *sd, const char **file, const char **key)
1714{
1715 if (file) *file = sd->file;
1716 if (key) *key = NULL;
1717}
1718
1719EAPI const char*
1720elm_photocam_file_get(const Elm_Photocam *obj)
1721{
1722 const char *ret = NULL;
1723 eo_do(obj, efl_file_get(&ret, NULL));
1724 return ret;
1671} 1725}
1672 1726
1673EOLIAN static void 1727EOLIAN static void
@@ -2145,6 +2199,13 @@ static void
2145_elm_photocam_class_constructor(Eo_Class *klass) 2199_elm_photocam_class_constructor(Eo_Class *klass)
2146{ 2200{
2147 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 2201 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
2202
2203 PHOTO_FILE_LOAD_ERROR_GENERIC = eina_error_msg_static_register("Generic load error");
2204 PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST = eina_error_msg_static_register("File does not exist");
2205 PHOTO_FILE_LOAD_ERROR_PERMISSION_DENIED = eina_error_msg_static_register("Permission denied to an existing file");
2206 PHOTO_FILE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = eina_error_msg_static_register("Allocation of resources failure prevented load");
2207 PHOTO_FILE_LOAD_ERROR_CORRUPT_FILE = eina_error_msg_static_register("File corrupt (but was detected as a known format)");
2208 PHOTO_FILE_LOAD_ERROR_UNKNOWN_FORMAT = eina_error_msg_static_register("File is not a known format");
2148} 2209}
2149 2210
2150EOLIAN const Elm_Atspi_Action * 2211EOLIAN const Elm_Atspi_Action *
diff --git a/src/lib/elm_photocam.eo b/src/lib/elm_photocam.eo
index 166b4d636..7dc638b0f 100644
--- a/src/lib/elm_photocam.eo
+++ b/src/lib/elm_photocam.eo
@@ -1,5 +1,5 @@
1class Elm.Photocam (Elm.Widget, Elm_Interface_Scrollable, 1class Elm.Photocam (Elm.Widget, Elm_Interface_Scrollable,
2 Elm_Interface_Atspi_Widget_Action) 2 Elm_Interface_Atspi_Widget_Action, Efl.File)
3{ 3{
4 eo_prefix: elm_obj_photocam; 4 eo_prefix: elm_obj_photocam;
5 properties { 5 properties {
@@ -31,37 +31,6 @@ class Elm.Photocam (Elm.Widget, Elm_Interface_Scrollable,
31 bool paused; /*@ The pause state to set */ 31 bool paused; /*@ The pause state to set */
32 } 32 }
33 } 33 }
34 file {
35 set {
36 /*@
37 @brief Set the photo file to be shown
38
39 @return The return error (see EVAS_LOAD_ERROR_NONE, EVAS_LOAD_ERROR_GENERIC etc.)
40
41 This sets (and shows) the specified file (with a relative or absolute
42 path) and will return a load error (same error that
43 evas_object_image_load_error_get() will return). The image will change and
44 adjust its size at this point and begin a background load process for this
45 photo that at some time in the future will be displayed at the full
46 quality needed.
47
48 @ingroup Photocam */
49 return: Evas_Load_Error;
50 }
51 get {
52 /*@
53 @brief Returns the path of the current image file
54
55 @return Returns the path
56
57 @see elm_photocam_file_set()
58
59 @ingroup Photocam */
60 }
61 values {
62 const(char)* file; /*@ The photo file */
63 }
64 }
65 gesture_enabled { 34 gesture_enabled {
66 set { 35 set {
67 /*@ 36 /*@
@@ -266,6 +235,8 @@ class Elm.Photocam (Elm.Widget, Elm_Interface_Scrollable,
266 Elm.Widget.event; 235 Elm.Widget.event;
267 Elm_Interface_Scrollable.region_bring_in; 236 Elm_Interface_Scrollable.region_bring_in;
268 Elm_Interface_Atspi_Widget_Action.elm_actions.get; 237 Elm_Interface_Atspi_Widget_Action.elm_actions.get;
238 Efl.File.file.set;
239 Efl.File.file.get;
269 } 240 }
270 events { 241 events {
271 clicked; 242 clicked;
diff --git a/src/lib/elm_photocam_legacy.h b/src/lib/elm_photocam_legacy.h
index 246de4cc1..c4c206e1e 100644
--- a/src/lib/elm_photocam_legacy.h
+++ b/src/lib/elm_photocam_legacy.h
@@ -23,4 +23,36 @@ EAPI Evas_Object *elm_photocam_add(Evas_Object *parent);
23 */ 23 */
24EAPI void elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h); 24EAPI void elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h);
25 25
26/**
27 *
28 * @brief Set the photo file to be shown
29 *
30 * @return The return error (see EVAS_LOAD_ERROR_NONE, EVAS_LOAD_ERROR_GENERIC etc.)
31 *
32 * This sets (and shows) the specified file (with a relative or absolute
33 * path) and will return a load error (same error that
34 * evas_object_image_load_error_get() will return). The image will change and
35 * adjust its size at this point and begin a background load process for this
36 * photo that at some time in the future will be displayed at the full
37 * quality needed.
38 *
39 * @ingroup Photocam
40 *
41 * @param[in] file The photo file
42 */
43EAPI Evas_Load_Error elm_photocam_file_set(Evas_Object *obj, const char *file);
44
45/**
46 *
47 * @brief Returns the path of the current image file
48 *
49 * @return Returns the path
50 *
51 * @see elm_photocam_file_set()
52 *
53 * @ingroup Photocam
54 *
55 */
56EAPI const char *elm_photocam_file_get(const Evas_Object *obj);
57
26#include "elm_photocam.eo.legacy.h" \ No newline at end of file 58#include "elm_photocam.eo.legacy.h" \ No newline at end of file