efl: make Efl.File a mixin that implement file_set for everyone.
This commit is contained in:
parent
43b524eea2
commit
beb6bde166
|
@ -127,6 +127,7 @@ lib/efl/interfaces/efl_io_writer.c \
|
|||
lib/efl/interfaces/efl_io_buffer.c \
|
||||
lib/efl/interfaces/efl_io_queue.c \
|
||||
lib/efl/interfaces/efl_observer.c \
|
||||
lib/efl/interfaces/efl_file.c \
|
||||
lib/efl/interfaces/efl_text_markup_util.c \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Efl.h>
|
||||
|
||||
typedef struct _Efl_File_Data Efl_File_Data;
|
||||
struct _Efl_File_Data
|
||||
{
|
||||
Eo *vo;
|
||||
|
||||
Efl_Image_Load_Error error;
|
||||
};
|
||||
|
||||
static Eina_Bool
|
||||
_efl_file_file_set(Eo *obj, Efl_File_Data *pd, const char *file, const char *key)
|
||||
{
|
||||
Eina_File *f;
|
||||
Eina_Bool r = EINA_FALSE;
|
||||
|
||||
pd->error = EFL_IMAGE_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
|
||||
if (file)
|
||||
{
|
||||
pd->vo = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file);
|
||||
efl_vpath_file_do(pd->vo);
|
||||
// XXX:FIXME: allow this to be async
|
||||
efl_vpath_file_wait(pd->vo);
|
||||
file = efl_vpath_file_result_get(pd->vo);
|
||||
}
|
||||
|
||||
if (file)
|
||||
{
|
||||
f = eina_file_open(file, EINA_FALSE);
|
||||
if (!f) goto on_error;
|
||||
}
|
||||
|
||||
pd->error = EFL_IMAGE_LOAD_ERROR_NONE;
|
||||
|
||||
r = efl_file_mmap_set(obj, f, key);
|
||||
if (f) eina_file_close(f);
|
||||
|
||||
on_error:
|
||||
if (pd->vo && (!efl_vpath_file_keep_get(pd->vo)))
|
||||
{
|
||||
efl_del(pd->vo);
|
||||
pd->vo = NULL;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_file_file_get(Eo *obj, Efl_File_Data *pd EINA_UNUSED, const char **file, const char **key)
|
||||
{
|
||||
const Eina_File *f = NULL;
|
||||
|
||||
efl_file_mmap_get(obj, &f, key);
|
||||
|
||||
if (f && file) *file = eina_file_filename_get(f);
|
||||
}
|
||||
|
||||
static Efl_Image_Load_Error
|
||||
_efl_file_load_error_get(Eo *obj EINA_UNUSED, Efl_File_Data *pd)
|
||||
{
|
||||
return pd->error;
|
||||
}
|
||||
|
||||
#include "interfaces/efl_file.eo.c"
|
|
@ -1,10 +1,25 @@
|
|||
import eina_types;
|
||||
import efl_gfx_types;
|
||||
|
||||
interface Efl.File {
|
||||
mixin Efl.File {
|
||||
[[Efl file interface]]
|
||||
methods {
|
||||
@property load_error {
|
||||
get {
|
||||
[[Gets the (last) file loading error for a given Edje object
|
||||
|
||||
This function is meant to be used after an Edje EDJ file
|
||||
loading, what takes place with the $file_set() function. If that
|
||||
function does not return $true, one should check for the reason
|
||||
of failure with this one.
|
||||
]]
|
||||
}
|
||||
values {
|
||||
error: Efl.Image.Load.Error(Efl.Image.Load.Error.none); [[The load error code.]]
|
||||
}
|
||||
}
|
||||
@property mmap {
|
||||
set {
|
||||
set @pure_virtual {
|
||||
[[Set the source mmaped file from where an image object must fetch the real
|
||||
image data (it must be an Eina_File).
|
||||
|
||||
|
@ -16,7 +31,7 @@ interface Efl.File {
|
|||
|
||||
return: bool; [[$true on success, $false otherwise]]
|
||||
}
|
||||
get {
|
||||
get @pure_virtual {
|
||||
[[Get the source mmaped file from where an image object must fetch the real
|
||||
image data (it must be an Eina_File).
|
||||
|
||||
|
@ -80,7 +95,7 @@ interface Efl.File {
|
|||
$null, otherwise.]]
|
||||
}
|
||||
}
|
||||
save @const {
|
||||
save @const @pure_virtual {
|
||||
[[Save the given image object's contents to an (image) file.
|
||||
|
||||
The extension suffix on $file will determine which saver
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "interfaces/efl_config.eo.c"
|
||||
#include "interfaces/efl_control.eo.c"
|
||||
#include "interfaces/efl_file.eo.c"
|
||||
#include "interfaces/efl_image.eo.c"
|
||||
#include "interfaces/efl_image_animated.eo.c"
|
||||
#include "interfaces/efl_image_load.eo.c"
|
||||
|
|
Loading…
Reference in New Issue