forked from enlightenment/efl
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
This commit is contained in:
parent
9639418c59
commit
a4e9658e70
|
@ -76,6 +76,13 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Eina_Error PHOTO_FILE_LOAD_ERROR_GENERIC;
|
||||||
|
static Eina_Error PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST;
|
||||||
|
static Eina_Error PHOTO_FILE_LOAD_ERROR_PERMISSION_DENIED;
|
||||||
|
static Eina_Error PHOTO_FILE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||||
|
static Eina_Error PHOTO_FILE_LOAD_ERROR_CORRUPT_FILE;
|
||||||
|
static Eina_Error PHOTO_FILE_LOAD_ERROR_UNKNOWN_FORMAT;
|
||||||
|
|
||||||
static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
|
static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
|
||||||
static Eina_Bool _key_action_zoom(Evas_Object *obj, const char *params);
|
static Eina_Bool _key_action_zoom(Evas_Object *obj, const char *params);
|
||||||
|
|
||||||
|
@ -1617,8 +1624,8 @@ static const char *remote_uri[] = {
|
||||||
"http://", "https://", "ftp://"
|
"http://", "https://", "ftp://"
|
||||||
};
|
};
|
||||||
|
|
||||||
EOLIAN static Evas_Load_Error
|
static Evas_Load_Error
|
||||||
_elm_photocam_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file)
|
_elm_photocam_file_set_internal(Eo *obj, Elm_Photocam_Data *sd, const char *file)
|
||||||
{
|
{
|
||||||
Evas_Load_Error ret = EVAS_LOAD_ERROR_NONE;
|
Evas_Load_Error ret = EVAS_LOAD_ERROR_NONE;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -1664,10 +1671,57 @@ _elm_photocam_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static const char*
|
EOLIAN static Eina_Bool
|
||||||
_elm_photocam_file_get(Eo *obj EINA_UNUSED, Elm_Photocam_Data *sd)
|
_elm_photocam_efl_file_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file, const char *key EINA_UNUSED)
|
||||||
{
|
{
|
||||||
return sd->file;
|
Evas_Load_Error ret = _elm_photocam_file_set_internal(obj, sd, file);
|
||||||
|
|
||||||
|
if (ret == EVAS_LOAD_ERROR_NONE) return EINA_TRUE;
|
||||||
|
|
||||||
|
eina_error_set(
|
||||||
|
ret == EVAS_LOAD_ERROR_DOES_NOT_EXIST ? PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST :
|
||||||
|
ret == EVAS_LOAD_ERROR_PERMISSION_DENIED ? PHOTO_FILE_LOAD_ERROR_PERMISSION_DENIED :
|
||||||
|
ret == EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED ? PHOTO_FILE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED :
|
||||||
|
ret == EVAS_LOAD_ERROR_CORRUPT_FILE ? PHOTO_FILE_LOAD_ERROR_CORRUPT_FILE :
|
||||||
|
ret == EVAS_LOAD_ERROR_UNKNOWN_FORMAT ? PHOTO_FILE_LOAD_ERROR_UNKNOWN_FORMAT :
|
||||||
|
PHOTO_FILE_LOAD_ERROR_GENERIC
|
||||||
|
);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Evas_Load_Error
|
||||||
|
elm_photocam_file_set(Elm_Photocam *obj, const char *file)
|
||||||
|
{
|
||||||
|
Eina_Bool ret;
|
||||||
|
if (eo_do_ret(obj, ret, efl_file_set(file, NULL))) return EVAS_LOAD_ERROR_NONE;
|
||||||
|
|
||||||
|
Eina_Error err = eina_error_get();
|
||||||
|
return err == PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST ?
|
||||||
|
EVAS_LOAD_ERROR_DOES_NOT_EXIST :
|
||||||
|
err == PHOTO_FILE_LOAD_ERROR_PERMISSION_DENIED ?
|
||||||
|
EVAS_LOAD_ERROR_PERMISSION_DENIED :
|
||||||
|
err == PHOTO_FILE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED ?
|
||||||
|
EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED :
|
||||||
|
err == PHOTO_FILE_LOAD_ERROR_CORRUPT_FILE ?
|
||||||
|
EVAS_LOAD_ERROR_CORRUPT_FILE :
|
||||||
|
err == PHOTO_FILE_LOAD_ERROR_UNKNOWN_FORMAT ?
|
||||||
|
EVAS_LOAD_ERROR_UNKNOWN_FORMAT :
|
||||||
|
EVAS_LOAD_ERROR_GENERIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_elm_photocam_efl_file_file_get(Eo *obj EINA_UNUSED, Elm_Photocam_Data *sd, const char **file, const char **key)
|
||||||
|
{
|
||||||
|
if (file) *file = sd->file;
|
||||||
|
if (key) *key = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI const char*
|
||||||
|
elm_photocam_file_get(const Elm_Photocam *obj)
|
||||||
|
{
|
||||||
|
const char *ret = NULL;
|
||||||
|
eo_do(obj, efl_file_get(&ret, NULL));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
|
@ -2145,6 +2199,13 @@ static void
|
||||||
_elm_photocam_class_constructor(Eo_Class *klass)
|
_elm_photocam_class_constructor(Eo_Class *klass)
|
||||||
{
|
{
|
||||||
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
||||||
|
|
||||||
|
PHOTO_FILE_LOAD_ERROR_GENERIC = eina_error_msg_static_register("Generic load error");
|
||||||
|
PHOTO_FILE_LOAD_ERROR_DOES_NOT_EXIST = eina_error_msg_static_register("File does not exist");
|
||||||
|
PHOTO_FILE_LOAD_ERROR_PERMISSION_DENIED = eina_error_msg_static_register("Permission denied to an existing file");
|
||||||
|
PHOTO_FILE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = eina_error_msg_static_register("Allocation of resources failure prevented load");
|
||||||
|
PHOTO_FILE_LOAD_ERROR_CORRUPT_FILE = eina_error_msg_static_register("File corrupt (but was detected as a known format)");
|
||||||
|
PHOTO_FILE_LOAD_ERROR_UNKNOWN_FORMAT = eina_error_msg_static_register("File is not a known format");
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN const Elm_Atspi_Action *
|
EOLIAN const Elm_Atspi_Action *
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class Elm.Photocam (Elm.Widget, Elm_Interface_Scrollable,
|
class Elm.Photocam (Elm.Widget, Elm_Interface_Scrollable,
|
||||||
Elm_Interface_Atspi_Widget_Action)
|
Elm_Interface_Atspi_Widget_Action, Efl.File)
|
||||||
{
|
{
|
||||||
eo_prefix: elm_obj_photocam;
|
eo_prefix: elm_obj_photocam;
|
||||||
properties {
|
properties {
|
||||||
|
@ -31,37 +31,6 @@ class Elm.Photocam (Elm.Widget, Elm_Interface_Scrollable,
|
||||||
bool paused; /*@ The pause state to set */
|
bool paused; /*@ The pause state to set */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file {
|
|
||||||
set {
|
|
||||||
/*@
|
|
||||||
@brief Set the photo file to be shown
|
|
||||||
|
|
||||||
@return The return error (see EVAS_LOAD_ERROR_NONE, EVAS_LOAD_ERROR_GENERIC etc.)
|
|
||||||
|
|
||||||
This sets (and shows) the specified file (with a relative or absolute
|
|
||||||
path) and will return a load error (same error that
|
|
||||||
evas_object_image_load_error_get() will return). The image will change and
|
|
||||||
adjust its size at this point and begin a background load process for this
|
|
||||||
photo that at some time in the future will be displayed at the full
|
|
||||||
quality needed.
|
|
||||||
|
|
||||||
@ingroup Photocam */
|
|
||||||
return: Evas_Load_Error;
|
|
||||||
}
|
|
||||||
get {
|
|
||||||
/*@
|
|
||||||
@brief Returns the path of the current image file
|
|
||||||
|
|
||||||
@return Returns the path
|
|
||||||
|
|
||||||
@see elm_photocam_file_set()
|
|
||||||
|
|
||||||
@ingroup Photocam */
|
|
||||||
}
|
|
||||||
values {
|
|
||||||
const(char)* file; /*@ The photo file */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gesture_enabled {
|
gesture_enabled {
|
||||||
set {
|
set {
|
||||||
/*@
|
/*@
|
||||||
|
@ -266,6 +235,8 @@ class Elm.Photocam (Elm.Widget, Elm_Interface_Scrollable,
|
||||||
Elm.Widget.event;
|
Elm.Widget.event;
|
||||||
Elm_Interface_Scrollable.region_bring_in;
|
Elm_Interface_Scrollable.region_bring_in;
|
||||||
Elm_Interface_Atspi_Widget_Action.elm_actions.get;
|
Elm_Interface_Atspi_Widget_Action.elm_actions.get;
|
||||||
|
Efl.File.file.set;
|
||||||
|
Efl.File.file.get;
|
||||||
}
|
}
|
||||||
events {
|
events {
|
||||||
clicked;
|
clicked;
|
||||||
|
|
|
@ -23,4 +23,36 @@ EAPI Evas_Object *elm_photocam_add(Evas_Object *parent);
|
||||||
*/
|
*/
|
||||||
EAPI void elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h);
|
EAPI void elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @brief Set the photo file to be shown
|
||||||
|
*
|
||||||
|
* @return The return error (see EVAS_LOAD_ERROR_NONE, EVAS_LOAD_ERROR_GENERIC etc.)
|
||||||
|
*
|
||||||
|
* This sets (and shows) the specified file (with a relative or absolute
|
||||||
|
* path) and will return a load error (same error that
|
||||||
|
* evas_object_image_load_error_get() will return). The image will change and
|
||||||
|
* adjust its size at this point and begin a background load process for this
|
||||||
|
* photo that at some time in the future will be displayed at the full
|
||||||
|
* quality needed.
|
||||||
|
*
|
||||||
|
* @ingroup Photocam
|
||||||
|
*
|
||||||
|
* @param[in] file The photo file
|
||||||
|
*/
|
||||||
|
EAPI Evas_Load_Error elm_photocam_file_set(Evas_Object *obj, const char *file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @brief Returns the path of the current image file
|
||||||
|
*
|
||||||
|
* @return Returns the path
|
||||||
|
*
|
||||||
|
* @see elm_photocam_file_set()
|
||||||
|
*
|
||||||
|
* @ingroup Photocam
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
EAPI const char *elm_photocam_file_get(const Evas_Object *obj);
|
||||||
|
|
||||||
#include "elm_photocam.eo.legacy.h"
|
#include "elm_photocam.eo.legacy.h"
|
Loading…
Reference in New Issue