summaryrefslogtreecommitdiff
path: root/src/lib/efl
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-10-04 20:58:06 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-10-04 20:58:06 -0700
commitbeb6bde166e8402ec0daa92c04fac9c4a69b0549 (patch)
tree97df826a002b20fb4fab632182f5076f5417fe8f /src/lib/efl
parent43b524eea2114055f5609011d398806e6226ca37 (diff)
efl: make Efl.File a mixin that implement file_set for everyone.
Diffstat (limited to 'src/lib/efl')
-rw-r--r--src/lib/efl/interfaces/efl_file.c69
-rw-r--r--src/lib/efl/interfaces/efl_file.eo23
-rw-r--r--src/lib/efl/interfaces/efl_interfaces_main.c1
3 files changed, 88 insertions, 5 deletions
diff --git a/src/lib/efl/interfaces/efl_file.c b/src/lib/efl/interfaces/efl_file.c
new file mode 100644
index 0000000000..116e49d5b0
--- /dev/null
+++ b/src/lib/efl/interfaces/efl_file.c
@@ -0,0 +1,69 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Efl.h>
6
7typedef struct _Efl_File_Data Efl_File_Data;
8struct _Efl_File_Data
9{
10 Eo *vo;
11
12 Efl_Image_Load_Error error;
13};
14
15static Eina_Bool
16_efl_file_file_set(Eo *obj, Efl_File_Data *pd, const char *file, const char *key)
17{
18 Eina_File *f;
19 Eina_Bool r = EINA_FALSE;
20
21 pd->error = EFL_IMAGE_LOAD_ERROR_DOES_NOT_EXIST;
22
23 if (file)
24 {
25 pd->vo = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file);
26 efl_vpath_file_do(pd->vo);
27 // XXX:FIXME: allow this to be async
28 efl_vpath_file_wait(pd->vo);
29 file = efl_vpath_file_result_get(pd->vo);
30 }
31
32 if (file)
33 {
34 f = eina_file_open(file, EINA_FALSE);
35 if (!f) goto on_error;
36 }
37
38 pd->error = EFL_IMAGE_LOAD_ERROR_NONE;
39
40 r = efl_file_mmap_set(obj, f, key);
41 if (f) eina_file_close(f);
42
43 on_error:
44 if (pd->vo && (!efl_vpath_file_keep_get(pd->vo)))
45 {
46 efl_del(pd->vo);
47 pd->vo = NULL;
48 }
49
50 return r;
51}
52
53static void
54_efl_file_file_get(Eo *obj, Efl_File_Data *pd EINA_UNUSED, const char **file, const char **key)
55{
56 const Eina_File *f = NULL;
57
58 efl_file_mmap_get(obj, &f, key);
59
60 if (f && file) *file = eina_file_filename_get(f);
61}
62
63static Efl_Image_Load_Error
64_efl_file_load_error_get(Eo *obj EINA_UNUSED, Efl_File_Data *pd)
65{
66 return pd->error;
67}
68
69#include "interfaces/efl_file.eo.c"
diff --git a/src/lib/efl/interfaces/efl_file.eo b/src/lib/efl/interfaces/efl_file.eo
index c8c4627a58..35ac1fa4ec 100644
--- a/src/lib/efl/interfaces/efl_file.eo
+++ b/src/lib/efl/interfaces/efl_file.eo
@@ -1,10 +1,25 @@
1import eina_types; 1import eina_types;
2import efl_gfx_types;
2 3
3interface Efl.File { 4mixin Efl.File {
4 [[Efl file interface]] 5 [[Efl file interface]]
5 methods { 6 methods {
7 @property load_error {
8 get {
9 [[Gets the (last) file loading error for a given Edje object
10
11 This function is meant to be used after an Edje EDJ file
12 loading, what takes place with the $file_set() function. If that
13 function does not return $true, one should check for the reason
14 of failure with this one.
15 ]]
16 }
17 values {
18 error: Efl.Image.Load.Error(Efl.Image.Load.Error.none); [[The load error code.]]
19 }
20 }
6 @property mmap { 21 @property mmap {
7 set { 22 set @pure_virtual {
8 [[Set the source mmaped file from where an image object must fetch the real 23 [[Set the source mmaped file from where an image object must fetch the real
9 image data (it must be an Eina_File). 24 image data (it must be an Eina_File).
10 25
@@ -16,7 +31,7 @@ interface Efl.File {
16 31
17 return: bool; [[$true on success, $false otherwise]] 32 return: bool; [[$true on success, $false otherwise]]
18 } 33 }
19 get { 34 get @pure_virtual {
20 [[Get the source mmaped file from where an image object must fetch the real 35 [[Get the source mmaped file from where an image object must fetch the real
21 image data (it must be an Eina_File). 36 image data (it must be an Eina_File).
22 37
@@ -80,7 +95,7 @@ interface Efl.File {
80 $null, otherwise.]] 95 $null, otherwise.]]
81 } 96 }
82 } 97 }
83 save @const { 98 save @const @pure_virtual {
84 [[Save the given image object's contents to an (image) file. 99 [[Save the given image object's contents to an (image) file.
85 100
86 The extension suffix on $file will determine which saver 101 The extension suffix on $file will determine which saver
diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c
index fc80036fb4..778108e699 100644
--- a/src/lib/efl/interfaces/efl_interfaces_main.c
+++ b/src/lib/efl/interfaces/efl_interfaces_main.c
@@ -6,7 +6,6 @@
6 6
7#include "interfaces/efl_config.eo.c" 7#include "interfaces/efl_config.eo.c"
8#include "interfaces/efl_control.eo.c" 8#include "interfaces/efl_control.eo.c"
9#include "interfaces/efl_file.eo.c"
10#include "interfaces/efl_image.eo.c" 9#include "interfaces/efl_image.eo.c"
11#include "interfaces/efl_image_animated.eo.c" 10#include "interfaces/efl_image_animated.eo.c"
12#include "interfaces/efl_image_load.eo.c" 11#include "interfaces/efl_image_load.eo.c"