Ephoto: Move common editing code to one place.

This commit is contained in:
Stephen okra Houston 2016-03-23 15:13:38 -05:00
parent 247e7a9cb4
commit d5b7d24082
1 changed files with 100 additions and 0 deletions

100
src/bin/ephoto_editor.c Normal file
View File

@ -0,0 +1,100 @@
#include "ephoto.h"
static void
_editor_reset(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
ecore_event_add(EPHOTO_EVENT_EDITOR_RESET, NULL, NULL, NULL);
}
static void
_editor_apply(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
ecore_event_add(EPHOTO_EVENT_EDITOR_APPLY, NULL, NULL, NULL);
}
static void
_editor_cancel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
ecore_event_add(EPHOTO_EVENT_EDITOR_CANCEL, NULL, NULL, NULL);
}
Evas_Object *
ephoto_editor_add(Evas_Object *parent, const char *title, const char *data_name,
void *data)
{
Evas_Object *frame, *box, *ic, *button;
frame = elm_frame_add(parent);
elm_object_text_set(frame, title);
evas_object_size_hint_weight_set(frame, 0.3, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_data_set(frame, data_name, data);
elm_box_pack_end(parent, frame);
evas_object_show(frame);
box = elm_box_add(frame);
elm_box_horizontal_set(box, EINA_FALSE);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_data_set(box, data_name, data);
evas_object_data_set(box, "frame", frame);
elm_object_content_set(frame, box);
evas_object_show(box);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "edit-undo");
button = elm_button_add(box);
elm_object_text_set(button, _("Reset"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _editor_reset, box);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "document-save");
button = elm_button_add(box);
elm_object_text_set(button, _("Apply"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _editor_apply, box);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "window-close");
button = elm_button_add(box);
elm_object_text_set(button, _("Cancel"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _editor_cancel, box);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
return box;
}
void
ephoto_editor_del(Evas_Object *obj)
{
Evas_Object *frame = evas_object_data_get(obj, "frame");
if (frame)
evas_object_del(frame);
}