fix code to allow visualization of the "save needed" popup .
Summary: in a situation where you were trying to close the application without saving, the program made it appear an empty pop-up, this prevents the user to save any unsaved data. This is because a box was used to create popup's content and popup's buttons. elm_object_part_content_set and elm_object_part_text_set should be used instead to properly populate the popup @fix Reviewers: cedric, tasn Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2612
This commit is contained in:
parent
e89d8b4f13
commit
46cf0abf84
|
@ -49,50 +49,32 @@ _cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
|||
void
|
||||
ui_alert_need_saving(Evas_Object *entry, void (*done)(void *data), void *data)
|
||||
{
|
||||
Evas_Object *popup, *bx, *hbx, *btn, *lbl;
|
||||
Evas_Object *popup, *btn1, *btn2, *btn3;
|
||||
popup = elm_popup_add(elm_object_top_widget_get(entry));
|
||||
evas_object_show(popup);
|
||||
|
||||
done_cb = done;
|
||||
done_data = data;
|
||||
|
||||
bx = elm_box_add(popup);
|
||||
elm_object_content_set(popup, bx);
|
||||
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.0);
|
||||
evas_object_show(bx);
|
||||
|
||||
lbl = elm_label_add(popup);
|
||||
elm_object_text_set(lbl,
|
||||
elm_object_part_text_set(popup, "title,text", "Unsaved Changes");
|
||||
elm_object_text_set(popup,
|
||||
_("<align=center>Would you like to save changes to document?<br>"
|
||||
"Any unsaved changes will be lost."));
|
||||
evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(bx, lbl);
|
||||
evas_object_show(lbl);
|
||||
|
||||
hbx = elm_box_add(popup);
|
||||
elm_box_horizontal_set(hbx, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, 0.0);
|
||||
elm_box_pack_end(bx, hbx);
|
||||
evas_object_show(hbx);
|
||||
btn1 = elm_button_add(popup);
|
||||
elm_object_text_set(btn1, _("Save"));
|
||||
elm_object_part_content_set(popup, "button1", btn1);
|
||||
evas_object_smart_callback_add(btn1, "clicked", _save, popup);
|
||||
|
||||
btn = elm_button_add(popup);
|
||||
elm_object_text_set(btn, _("Save"));
|
||||
elm_box_pack_end(hbx, btn);
|
||||
evas_object_show(btn);
|
||||
evas_object_smart_callback_add(btn, "clicked", _save, popup);
|
||||
btn2 = elm_button_add(popup);
|
||||
elm_object_text_set(btn2, _("Discard"));
|
||||
elm_object_part_content_set(popup, "button2", btn2);
|
||||
evas_object_smart_callback_add(btn2, "clicked", _discard, popup);
|
||||
|
||||
btn = elm_button_add(popup);
|
||||
elm_object_text_set(btn, _("Discard"));
|
||||
elm_box_pack_end(hbx, btn);
|
||||
evas_object_show(btn);
|
||||
evas_object_smart_callback_add(btn, "clicked", _discard, popup);
|
||||
btn3 = elm_button_add(popup);
|
||||
elm_object_text_set(btn3, _("Cancel"));
|
||||
elm_object_part_content_set(popup, "button3", btn3);
|
||||
evas_object_smart_callback_add(btn3, "clicked", _cancel, popup);
|
||||
|
||||
btn = elm_button_add(popup);
|
||||
elm_object_text_set(btn, _("Cancel"));
|
||||
elm_box_pack_end(hbx, btn);
|
||||
evas_object_show(btn);
|
||||
evas_object_smart_callback_add(btn, "clicked", _cancel, popup);
|
||||
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue