#define MESSAGE_BTN_CANCEL "Cancel"
#define MESSAGE_ADD_USER "Add user"
#define MESSAGE_EDIT_USER "Edit user"
+#define MESSAGE_DELETE_USER "Delete user"
+#define MESSAGE_DELETE_CONTENTS "If you delete this user, their data will also be deleted."
+#define MESSAGE_DELETE "Delete"
+#define MESSAGE_CANCEL "Cancel"
+
#define MESSAGE_ENTRY_NAME "User Name"
#define MESSAGE_ENTRY_ACCOUNT "sample@tizen.com"
#define MESSAGE_ENTRY_PIN "Pin code"
#define CTXPOPUP_X 294
#define CTXPOPUP_Y 310
+#define MAX_BUF 128
struct _icon_info {
const char *file;
Evas_Object *done;
Evas_Object *cancel;
Evas_Object *ctxpopup;
+ Evas_Object *del;
+ Evas_Object *popup;
struct datamgr *dm;
};
return base;
}
+static void _delete_user_key_down(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ if (!strcmp(ev->keyname, KEY_ENTER) ||
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
+ evas_object_del(priv->popup);
+ priv->popup = NULL;
+ /* TODO: datamgr_select_item for deleting user */
+ } else if (!strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
+ evas_object_del(priv->popup);
+ priv->popup = NULL;
+ }
+}
+
+static input_handler delete_user_handler = {
+ .key_down = _delete_user_key_down
+};
+
+static void _cancel_user_key_down(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ if (!strcmp(ev->keyname, KEY_ENTER) ||
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE) ||
+ !strcmp(ev->keyname, KEY_BACK) ||
+ !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
+ evas_object_del(priv->popup);
+ priv->popup = NULL;
+ }
+}
+
+static input_handler cancel_user_handler = {
+ .key_down = _cancel_user_key_down
+};
+
+static void _add_delete_popup(struct _priv *priv)
+{
+ Evas_Object *popup, *delete_btn, *cancel_btn;
+ char buf[MAX_BUF];
+
+ popup = elm_popup_add(priv->base);
+ if (!popup) {
+ _ERR("failed to add popup");
+ return;
+ }
+ elm_object_part_text_set(popup, PART_TITLE_TEXT, MESSAGE_DELETE_USER);
+ elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
+ evas_object_show(popup);
+ priv->popup = popup;
+
+ /* TODO: put the user name */
+ snprintf(buf, sizeof(buf), "%s %s?<br> %s", MESSAGE_DELETE,
+ "", MESSAGE_DELETE_CONTENTS);
+ elm_object_text_set(popup, buf);
+
+ delete_btn = utils_add_button(popup, MESSAGE_DELETE,
+ PART_POPUP_BUTTON_1);
+ if (!delete_btn) {
+ _ERR("failed to add delete btn");
+ evas_object_del(popup);
+ return;
+ }
+ inputmgr_add_callback(delete_btn, 0, &delete_user_handler, priv);
+
+ cancel_btn = utils_add_button(popup, MESSAGE_CANCEL,
+ PART_POPUP_BUTTON_2);
+ if (!cancel_btn) {
+ _ERR("failed to add cancel btn");
+ evas_object_del(popup);
+ return;
+ }
+ inputmgr_add_callback(cancel_btn, 0, &cancel_user_handler, priv);
+ elm_object_focus_set(cancel_btn, EINA_TRUE);
+}
+
+static void _del_key_down(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ if (!strcmp(ev->keyname, KEY_ENTER) ||
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
+ _add_delete_popup(data);
+ }
+}
+
+static input_handler del_handler = {
+ .focused = _focused,
+ .unfocused = _unfocused,
+ .key_down = _del_key_down
+};
+
+static void _load_del_btn(struct _priv *priv)
+{
+ Evas_Object *btn;
+
+ btn = utils_add_layout(priv->ly, GRP_USER_EDIT_DELETE, true,
+ PART_USER_EDIT_CONTENTS_DELETE);
+ if (!btn) {
+ _ERR("failed toa add delete button");
+ return;
+ }
+ inputmgr_add_callback(btn, 0, &del_handler, priv);
+
+ priv->del = btn;
+}
+
static void _show(void *data)
{
struct _priv *priv;
MESSAGE_ADD_USER);
_load_user_icon(priv, IMAGE_USER_CURRENT_DEFAULT,
IMAGE_USER_CURRENT_DEFAULT_FOCUS);
+ _load_del_btn(priv);
}
static void _hide(void *data)
}
priv = data;
+ if (priv->del) {
+ inputmgr_remove_callback(priv->del, &del_handler);
+ evas_object_del(priv->del);
+ priv->del = NULL;
+ }
evas_object_hide(priv->base);
}