group {
name, GRP_USER;
+ data.item, DATA_TITLE_WIDTH "114";
parts {
part {
name, "area";
}
min, 0 5;
align, 0.0 0.0;
- fixed, 0 0;
+ fixed, 0 1;
visible, 0;
}
}
group {
name, GRP_UBAR_ITEM;
+ data.item, DATA_TITLE_WIDTH "98";
parts {
part {
name, PART_BG;
}
min, 8 8;
align, 1.0 0.0;
- fixed, 0 0;
+ fixed, 1 1;
visible, 0;
}
}
scale, 1;
description {
state, "default" 0.0;
- min, 0 82;
+ min, 0 40;
fixed, 1 1;
rel1 {
- to, "area";
- relative, 0.5 1.0;
+ to, PART_POPUP_USER;
+ relative, 0.0 1.0;
}
rel2 {
- to, "area";
- relative, 0.5 1.0;
+ to, PART_POPUP_USER;
+ relative, 0.0 1.0;
}
- align, 0.5 1.0;
+ align, 0.0 0.0;
+ visible, 0;
}
}
part {
scale, 1;
description {
state, "default" 0.0;
- min, 456 59;
+ min, 327 59;
fixed, 1 1;
- rel1.to, "pad.entry";
- rel2 {
+ align, 0.0 0.0;
+ rel1 {
to, "pad.entry";
- relative, 0.0 0.0;
+ relative, 1.0 1.0;
}
+ rel2.to, "pad.entry";
color, 27 32 45 40;
}
}
part {
- name, "bg.entry.border";
+ name, "padding.border";
type, RECT;
scale, 1;
description {
state, "default" 0.0;
- min, 452 55;
+ min, 2 2;
fixed, 1 1;
- rel1.to, "pad.entry";
+ align, 0.0 0.0;
+ rel1.to, "bg.entry";
rel2 {
- to, "pad.entry";
+ to, "bg.entry";
relative, 0.0 0.0;
}
+ visible, 0;
+ }
+ }
+ part {
+ name, "bg.entry.border";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 323 55;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "padding.border";
+ relative, 1.0 1.0;
+ }
+ rel2 {
+ to, "padding.border";
+ relative, 1.0 1.0;
+ }
+ }
+ }
+ part {
+ name, PART_POPUP_ENTRY_NAME_DESC;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ rel1.to, "bg.entry.border";
+ rel2.to, "bg.entry.border";
+ text {
+ font, "TizenSans";
+ size, 22;
+ align, 0.5 0.5;
+ }
+ color, 27 32 45 100;
+ visible, 1;
+ }
+ description {
+ state, "hide" 0.0;
+ inherit, "default" 0.0;
+ visible, 0;
}
}
part {
- name, PART_POPUP_ENTRY;
+ name, PART_POPUP_ENTRY_NAME;
type, SWALLOW;
scale, 1;
description {
state, "default" 0.0;
- fixed, 0 0;
+ fixed, 1 1;
rel1.to, "bg.entry.border";
rel2.to, "bg.entry.border";
}
}
+ part {
+ name, "padding.pw";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 35 0;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "bg.entry";
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to, "bg.entry";
+ relative, 1.0 0.0;
+ }
+ }
+ }
+ part {
+ name, "bg.pw.entry";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 327 59;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "padding.pw";
+ relative, 1.0 1.0;
+ }
+ rel2.to, "padding.pw";
+ color, 27 32 45 40;
+ }
+ description {
+ state, "focus" 0.0;
+ inherit, "default" 0.0;
+ color, 69 143 255 255;
+ }
+ }
+ part {
+ name, "padding.pw.border";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 2 2;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1.to, "bg.pw.entry";
+ rel2 {
+ to, "bg.pw.entry";
+ relative, 0.0 0.0;
+ }
+ visible, 0;
+ }
+ }
+ part {
+ name, "bg.pw.entry.border";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 323 55;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "padding.pw.border";
+ relative, 1.0 1.0;
+ }
+ rel2.to, "padding.pw.border";
+ }
+ }
+ part {
+ name, PART_POPUP_ENTRY_PW_DESC;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ rel1.to, "bg.pw.entry.border";
+ rel2.to, "bg.pw.entry.border";
+ text {
+ font, "TizenSans";
+ size, 22;
+ align, 0.5 0.5;
+ }
+ color, 27 32 45 100;
+ visible, 1;
+ }
+ description {
+ state, "hide" 0.0;
+ inherit, "default" 0.0;
+ visible, 0;
+ }
+ description {
+ state, "wrongpw" 0.0;
+ inherit, "default" 0.0;
+ color, 220 0 0 255;
+ visible, 1;
+ }
+ }
+ part {
+ name, PART_POPUP_ENTRY_PW;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ rel1.to, PART_POPUP_ENTRY_PW_DESC;
+ rel2.to, PART_POPUP_ENTRY_PW_DESC;
+ }
+ }
+
}
}
state, "default" 0.0;
rel1.to, "area";
rel2.to, "area";
+ fixed, 1 1;
image.normal, "ico_arrow_left.png";
visible, 0;
}
state, "default" 0.0;
rel1.to, "area";
rel2.to, "area";
+ fixed, 1 1;
image.normal, "ico_arrow_right.png";
visible, 0;
}
}
}
}
+
+group {
+ name, GRP_UBAR_LOGIN;
+ images {
+ image, "ico_bg_98.png" COMP;
+ }
+ parts {
+ part {
+ name, "area";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ visible, 0;
+ }
+ }
+ part {
+ name, "padding.profile";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 100 30;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1.to, "area";
+ rel2 {
+ to, "area";
+ relative, 0.0 0.0;
+ }
+ visible, 0;
+ }
+ }
+ part {
+ name, "thumb.bg";
+ type, IMAGE;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 120 120;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "padding.profile";
+ relative, 1.0 1.0;
+ }
+ rel2 {
+ to, "padding.profile";
+ relative, 1.0 1.0;
+ }
+ image.normal, "ico_bg_98.png";
+ color, 27 32 45 40;
+ }
+ }
+ part {
+ name, PART_USER_LOGIN_THUMB;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 120 120;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1.to, "thumb.bg";
+ rel2.to, "thumb.bg";
+ }
+ }
+ part {
+ name, "padding.name";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 50 0;
+ fixed, 1 0;
+ align, 0.0 0.0;
+ rel1 {
+ to, PART_USER_LOGIN_THUMB;
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to, PART_USER_LOGIN_THUMB;
+ relative, 1.0 1.0;
+ }
+ visible, 0;
+ }
+ }
+ part {
+ name, PART_USER_LOGIN_NAME;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 310 50;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "padding.name";
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to, "padding.name";
+ relative, 1.0 0.0;
+ }
+ }
+ }
+ part {
+ name, "bg.entry";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 310 50;
+ fixed, 1 1;
+ align, 0.0 1.0;
+ rel1 {
+ to, "padding.name";
+ relative, 1.0 1.0;
+ }
+ rel2 {
+ to, "padding.name";
+ relative, 1.0 1.0;
+ }
+ color, 27 32 45 40;
+ }
+ description {
+ state, "focus" 0.0;
+ inherit, "default" 0.0;
+ color, 69 143 255 255;
+ }
+ }
+ part {
+ name, "padding.border";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 2 2;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1.to, "bg.entry";
+ rel2 {
+ to, "bg.entry";
+ relative, 0.0 0.0;
+ }
+ visible, 0;
+ }
+ }
+ part {
+ name, "bg.entry.border";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 306 46;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "padding.border";
+ relative, 1.0 1.0;
+ }
+ rel2 {
+ to, "padding.border";
+ relative, 1.0 1.0;
+ }
+ }
+ }
+ part {
+ name, PART_USER_LOGIN_PW_DESC;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ rel1.to, "bg.entry.border";
+ rel2.to, "bg.entry.border";
+ text {
+ font, "TizenSans";
+ size, 22;
+ align, 0.5 0.5;
+ }
+ color, 27 32 45 100;
+ visible, 1;
+ }
+ description {
+ state, "hide" 0.0;
+ inherit, "default" 0.0;
+ visible, 0;
+ }
+ description {
+ state, "wrongpw" 0.0;
+ inherit, "default" 0.0;
+ color, 220 0 0 255;
+ visible, 1;
+ }
+ }
+ part {
+ name, PART_USER_LOGIN_PW;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ rel1.to, PART_USER_LOGIN_PW_DESC;
+ rel2.to, PART_USER_LOGIN_PW_DESC;
+ }
+ }
+ }
+ programs {
+ program {
+ name, "show.pw";
+ signal, SIG_SHOW_PW;
+ source, SRC_PROG;
+ action, STATE_SET "default" 0.0;
+ transition, LINEAR 0.1;
+ target, PART_USER_LOGIN_PW_DESC;
+ }
+ program {
+ name, "hide.pw";
+ signal, SIG_HIDE_PW;
+ source, SRC_PROG;
+ action, STATE_SET "hide" 0.0;
+ transition, LINEAR 0.1;
+ target, PART_USER_LOGIN_PW_DESC;
+ }
+ program {
+ name, "show.long.pw";
+ signal, SIG_SHOW_WRONG_PW;
+ source, SRC_PROG;
+ action, STATE_SET "wrongpw" 0.0;
+ transition, LINEAR 0.1;
+ target, PART_USER_LOGIN_PW_DESC;
+ }
+ program {
+ name, "focus.pw";
+ signal, SIG_FOCUS;
+ source, SRC_PROG;
+ action, STATE_SET "focus" 0.0;
+ transition, LINEAR 0.1;
+ target, "bg.entry";
+ }
+ program {
+ name, "unfocus.pw";
+ signal, SIG_UNFOCUS;
+ source, SRC_PROG;
+ action, STATE_SET "default" 0.0;
+ transition, LINEAR 0.1;
+ target, "bg.entry";
+ }
+ }
+}
+
+group {
+ name, GRP_UBAR_DELETE;
+ parts {
+ part {
+ name, "area";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ visible, 0;
+ }
+ }
+ part {
+ name, "padding.text";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 25;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "area";
+ relative, 0.5 0.0;
+ }
+ rel2 {
+ to, "area";
+ relative, 0.5 0.0;
+ }
+ visible, 0;
+ }
+ }
+ part {
+ name, PART_USER_DELETE_MESSAGE;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 500 50;
+ fixed, 1 1;
+ align, 0.5 0.0;
+ rel1 {
+ to, "padding.text";
+ relative, 1.0 1.0;
+ }
+ rel2.to, "padding.text";
+ color, 0 0 0 255;
+ }
+ }
+ part {
+ name, "padding.entry";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 20;
+ fixed, 1 1;
+ align, 0.5 0.0;
+ rel1 {
+ to, PART_USER_DELETE_MESSAGE;
+ relative, 0.5 1.0;
+ }
+ rel2 {
+ to, PART_USER_DELETE_MESSAGE;
+ relative, 0.5 1.0;
+ }
+ visible, 0;
+ }
+ }
+ part {
+ name, "bg.entry";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 310 50;
+ fixed, 1 1;
+ align, 0.5 0.0;
+ rel1 {
+ to, "padding.entry";
+ relative, 1.0 1.0;
+ }
+ rel2.to, "padding.entry";
+ color, 27 32 45 40;
+ }
+ description {
+ state, "focus" 0.0;
+ inherit, "default" 0.0;
+ color, 69 143 255 255;
+ }
+ }
+ part {
+ name, "padding.border";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 2 2;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1.to, "bg.entry";
+ rel2 {
+ to, "bg.entry";
+ relative, 0.0 0.0;
+ }
+ visible, 0;
+ }
+ }
+ part {
+ name, "bg.entry.border";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 306 46;
+ fixed, 1 1;
+ align, 0.0 0.0;
+ rel1 {
+ to, "padding.border";
+ relative, 1.0 1.0;
+ }
+ rel2 {
+ to, "padding.border";
+ relative, 1.0 1.0;
+ }
+ }
+ }
+ part {
+ name, PART_USER_LOGIN_PW_DESC;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ rel1.to, "bg.entry.border";
+ rel2.to, "bg.entry.border";
+ text {
+ font, "TizenSans";
+ size, 22;
+ align, 0.5 0.5;
+ }
+ color, 27 32 45 100;
+ visible, 1;
+ }
+ description {
+ state, "hide" 0.0;
+ inherit, "default" 0.0;
+ visible, 0;
+ }
+ description {
+ state, "wrongpw" 0.0;
+ inherit, "default" 0.0;
+ color, 220 0 0 255;
+ visible, 1;
+ }
+ }
+ part {
+ name, PART_USER_LOGIN_PW;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ fixed, 1 1;
+ rel1.to, PART_USER_LOGIN_PW_DESC;
+ rel2.to, PART_USER_LOGIN_PW_DESC;
+ }
+ }
+ }
+ programs {
+ program {
+ name, "show.pw";
+ signal, SIG_SHOW_PW;
+ source, SRC_PROG;
+ action, STATE_SET "default" 0.0;
+ transition, LINEAR 0.1;
+ target, PART_USER_LOGIN_PW_DESC;
+ }
+ program {
+ name, "hide.pw";
+ signal, SIG_HIDE_PW;
+ source, SRC_PROG;
+ action, STATE_SET "hide" 0.0;
+ transition, LINEAR 0.1;
+ target, PART_USER_LOGIN_PW_DESC;
+ }
+ program {
+ name, "show.long.pw";
+ signal, SIG_SHOW_WRONG_PW;
+ source, SRC_PROG;
+ action, STATE_SET "wrongpw" 0.0;
+ transition, LINEAR 0.1;
+ target, PART_USER_LOGIN_PW_DESC;
+ }
+ program {
+ name, "focus.pw";
+ signal, SIG_FOCUS;
+ source, SRC_PROG;
+ action, STATE_SET "focus" 0.0;
+ transition, LINEAR 0.1;
+ target, "bg.entry";
+ }
+ program {
+ name, "unfocus.pw";
+ signal, SIG_UNFOCUS;
+ source, SRC_PROG;
+ action, STATE_SET "default" 0.0;
+ transition, LINEAR 0.1;
+ target, "bg.entry";
+ }
+ }
+}
#include "defs.h"
#include "dbg.h"
-#define BTN_MAX 2
+#define BTN_MAX 3
#define KEY_LONG_DUR 1.0
#define BANNER_DUR 3.0
#define CTXPOPUP_BTN_WIDTH 254
#define UBAR_POPUP_PADDING_X 30
#define BUF_MAX 128
+#define MESSAGE_ID "ID"
+#define MESSAGE_PW "Password"
+#define MESSAGE_WRONG_PW "Wrong Password"
#define TITLE_DELETE_POPUP "Delete User"
-#define MESSAGE_DELETE_POPUP "Are you sure you want to delete user?<br>(All histories will be deleted)"
-#define MESSAGE_DELETE_BANNER "is deleted"
-
+#define TITLE_LOGIN_POPUP "Login"
#define TITLE_EDIT_POPUP "Edit User"
+#define MESSAGE_DELETE_POPUP "Are you sure you want to delete"
+#define MESSAGE_DELETE_BANNER "is deleted"
#define MESSAGE_EDIT_BANNER "Editing is completed"
-
#define MESSAGE_KIDS "It is not available to use some content for over age 17~4, in Kids mode."
#define ASSERT(exp) if (!(exp)) { _ERR(#exp); abort(); }
UBAR_STATE_ITEM_POPUP
};
+enum _popup_state {
+ POPUP_STATE_NONE,
+ POPUP_STATE_LOGIN,
+ POPUP_STATE_ADD,
+ POPUP_STATE_EDIT,
+ POPUP_STATE_DELETE
+};
+
struct _ubar_item;
struct _ubar_data {
Evas_Object *bx;
Eina_List *list;
Evas_Object *base;
- Ecore_Timer *key_timer;
struct engine *eng;
struct _ubar_item *cur;
struct bar_cb focus_cb;
Evas_Object *ctxpopup;
Evas_Object *btn[BTN_MAX];
Evas_Object *popup;
+ Evas_Object *id_entry;
+ Evas_Object *pw_entry;
struct engine_ubar_item *it;
struct _ubar_data *bar;
+ enum _popup_state state;
};
struct _btn_info {
return 0;
}
+static Eina_Bool _create_ctxpopup(struct _ubar_item *);
+
+/* FIXME: check user status */
+static Eina_Bool _check_guest_user(struct _ubar_item *user)
+{
+ return EINA_TRUE;
+}
+
+static Eina_Bool _check_add_item(struct _ubar_item *item)
+{
+ return !engine_ubar_item_get_authority(item->it);
+}
+
+static void _clicked(void *data, Evas *e, Evas_Object *obj, void *ei)
+{
+ struct _ubar_data *bar;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ bar = data;
+ if (_check_guest_user(bar->user)) {
+ if (_check_add_item(bar->cur)){
+ /* FIXME: load add item */
+ } else {
+ _create_ctxpopup(bar->cur);
+ bar->state = UBAR_STATE_ITEM_CTXPOPUP;
+ }
+ }
+}
+
static struct _ubar_item *_pack_item(struct _ubar_data *bar,
struct engine_ubar_item *it)
{
thumb ? thumb : DEF_UBAR_ITEM_THUMB, NULL);
evas_object_event_callback_add(ly,
+ EVAS_CALLBACK_MOUSE_UP, _clicked, bar);
+ evas_object_event_callback_add(ly,
EVAS_CALLBACK_MOUSE_MOVE, _mouse_over, NULL);
evas_object_smart_callback_add(ly, "focused", _focused, item);
static void _destroy_popup(struct _ubar_item *item)
{
+ int i;
+
ASSERT(item);
evas_object_del(item->popup);
item->popup = NULL;
+ item->state = POPUP_STATE_NONE;
+
+ for (i = 0; i < BTN_MAX; i++) {
+ memset(item->btn, 0x00, sizeof(item->btn));
+ item->btn[i] = NULL;
+ }
switch (item->bar->state) {
case UBAR_STATE_USER_POPUP:
return r;
}
-static Eina_Bool _add_btn(Evas_Object *p, struct _ubar_item *item,
- struct _btn_info *btn_info)
+static Eina_Bool _add_popup_btn(Evas_Object *p, struct _ubar_item *item,
+ struct _btn_info *btn_info, int size)
{
Evas_Object *btn, *firstbtn;
int i;
- if (!p || !item) {
+ if (!p || !item || !btn_info) {
_ERR("Invalid argument");
return EINA_FALSE;
}
firstbtn = NULL;
- for (i = 0; i < BTN_MAX; i++) {
+ for (i = 0; i < size; i++) {
btn = elm_button_add(p);
if (!btn) {
_ERR("failed to create button");
static void _popup_cancel_clicked(void *data, Evas *e, Evas_Object *obj,
void *ei)
{
- _destroy_popup(data);
+ struct _ubar_item *item;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ item = data;
+
+ item->pw_entry = NULL;
+ _destroy_popup(item);
}
static Evas_Object *_add_popup(Evas_Object *base, const char *title,
evas_object_show(banner);
}
+static Eina_Bool _check_password(Evas_Object *entry,
+ struct engine_ubar_item *it)
+{
+ const char *password;
+ Evas_Object *ly;
+
+ if (!entry || !it) {
+ _ERR("Invalid argument");
+ return EINA_FALSE;
+ }
+
+ password = elm_entry_entry_get(entry);
+ if (!password)
+ return EINA_FALSE;
+
+ if (!engine_ubar_item_is_password(it, password)) {
+ elm_entry_entry_set(entry, "");
+ ly = elm_object_parent_widget_get(entry);
+ if (ly) {
+ elm_object_part_text_set(ly, PART_USER_LOGIN_PW_DESC,
+ MESSAGE_WRONG_PW);
+ elm_object_signal_emit(ly, SIG_SHOW_WRONG_PW, SRC_PROG);
+ }
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
+}
+
static void _popup_delete_clicked(void *data, Evas *e, Evas_Object *obj,
void *ei)
{
+ struct _ubar_item *item;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ item = data;
+
+ if (!_check_password(item->pw_entry, item->it))
+ return;
+
+ item->pw_entry = NULL;
_destroy_popup(data);
+
+ /* TODO: EFL patent
_add_banner(data);
+ */
}
static Eina_Bool _add_arrow(struct _ubar_item *item, Evas_Object *p,
elm_label_slide_go(data);
}
-static Evas_Object *_add_label(Evas_Object *ly, const char *name)
+static Evas_Object *_add_label(Evas_Object *ly, const char *name,
+ const char *style)
{
Evas_Object *lbl;
const char *s;
_ERR("failed to add label");
return NULL;
}
- elm_object_style_set(lbl, STYLE_LABEL_SLIDE_CENTER_22);
+ if (style)
+ elm_object_style_set(lbl, style);
s = edje_object_data_get(elm_layout_edje_get(ly),
DATA_TITLE_WIDTH);
if (s)
elm_object_signal_emit(ly, SIG_SHOW_AGE, SRC_PROG);
}
- lbl = _add_label(ly, name);
+ lbl = _add_label(ly, name, STYLE_LABEL_SLIDE_CENTER_22);
if (!lbl) {
_ERR("failed to create name");
evas_object_del(p);
return EINA_TRUE;
}
+static void _entry_focused(void *data, Evas_Object *obj, void *ei)
+{
+ elm_object_signal_emit(data, SIG_HIDE_PW, SRC_PROG);
+ elm_object_signal_emit(data, SIG_FOCUS, SRC_PROG);
+}
+
+static void _entry_unfocused(void *data, Evas_Object *obj, void *ei)
+{
+ if (elm_entry_is_empty(obj)) {
+ elm_object_signal_emit(data, SIG_SHOW_PW, SRC_PROG);
+ elm_object_part_text_set(data, PART_USER_LOGIN_PW_DESC,
+ MESSAGE_PW);
+ }
+ elm_object_signal_emit(data, SIG_UNFOCUS, SRC_PROG);
+}
+
+static Evas_Object *_add_password_entry(Evas_Object *p, const char *part)
+{
+ Evas_Object *entry;
+
+ if (!p || !part) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ entry = elm_entry_add(p);
+ if (!entry) {
+ _ERR("failed to create entry");
+ evas_object_del(p);
+ return NULL;
+ }
+ elm_entry_single_line_set(entry, EINA_TRUE);
+ elm_entry_input_panel_language_set(entry,
+ ELM_INPUT_PANEL_LANG_ALPHABET);
+ elm_entry_cursor_end_set(entry);
+ elm_entry_password_set(entry, EINA_TRUE);
+ /* FIXME: entry scroll style
+ elm_entry_scrollable_set(entry, EINA_TRUE);
+ */
+ elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF,
+ ELM_SCROLLER_POLICY_OFF);
+ elm_object_part_content_set(p, part, entry);
+ evas_object_show(entry);
+
+ return entry;
+}
+
static Eina_Bool _add_popup_items(struct _ubar_item *item, Evas_Object *popup)
{
- Evas_Object *ly, *entry;
+ Evas_Object *ly, *name_entry, *pw_entry;
if (!item || !popup) {
_ERR("Invalid argument");
return EINA_FALSE;
}
- entry = elm_entry_add(ly);
- if (!entry) {
- _ERR("failed to create entry");
+ name_entry = _add_password_entry(ly, PART_POPUP_ENTRY_NAME);
+ if (!name_entry) {
+ _ERR("failed to create name entry");
evas_object_del(ly);
return EINA_FALSE;
}
- elm_entry_single_line_set(entry, EINA_TRUE);
- elm_entry_input_panel_language_set(entry,
- ELM_INPUT_PANEL_LANG_ALPHABET);
- evas_object_size_hint_weight_set(entry,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(entry,
- EVAS_HINT_FILL, EVAS_HINT_FILL);
- /* FIXME: After fixing about IME, focusing should be handled */
- elm_object_focus_allow_set(entry, EINA_FALSE);
- elm_entry_cursor_end_set(entry);
- elm_object_part_content_set(ly, PART_POPUP_ENTRY, entry);
- evas_object_show(entry);
+ elm_object_part_text_set(ly, PART_POPUP_ENTRY_NAME_DESC, MESSAGE_ID);
+
+
+ pw_entry = _add_password_entry(ly, PART_POPUP_ENTRY_PW);
+ if (!pw_entry) {
+ _ERR("failed to create pw entry");
+ evas_object_del(ly);
+ return EINA_FALSE;
+ }
+ elm_object_part_text_set(ly, PART_POPUP_ENTRY_PW_DESC, MESSAGE_PW);
elm_object_part_text_set(ly, PART_KIDS, MESSAGE_KIDS);
evas_object_del(item->popup);
}
+static void _delete_ctxpopup(struct _ubar_data *bar)
+{
+ if (!bar) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ switch (bar->state) {
+ case UBAR_STATE_USER_CTXPOPUP:
+ _destroy_ctxpopup(bar->user);
+ bar->state = UBAR_STATE_USER_POPUP;
+ break;
+ case UBAR_STATE_ITEM_CTXPOPUP:
+ _destroy_ctxpopup(bar->cur);
+ bar->state = UBAR_STATE_ITEM_POPUP;
+ break;
+ default:
+ return;
+ }
+}
+
static Eina_Bool _load_edit_popup(struct _ubar_item *item)
{
struct _ubar_data *bar;
struct _btn_info btn_info[] = {
{
"button1",
- "Add",
+ "Edit",
_popup_add_clicked
},
{
}
bar = item->bar;
- popup = _add_popup(bar->base, TITLE_EDIT_POPUP, STYLE_POPUP_USER);
+ popup = _add_popup(bar->base, TITLE_EDIT_POPUP, NULL);
if (!popup) {
_ERR("failed to create popup");
return EINA_FALSE;
}
- if (!_add_btn(popup, item, btn_info)) {
+ if (!_add_popup_btn(popup, item, btn_info,
+ sizeof(btn_info) / sizeof(btn_info[0]))) {
_ERR("failed to create popup button");
evas_object_del(popup);
return EINA_FALSE;
elm_object_focus_set(cur->eo, EINA_TRUE);
}
- switch (bar->state) {
- case UBAR_STATE_USER_CTXPOPUP:
- _destroy_ctxpopup(bar->user);
- bar->state = UBAR_STATE_USER_POPUP;
- break;
- case UBAR_STATE_ITEM_CTXPOPUP:
- _destroy_ctxpopup(bar->cur);
- bar->state = UBAR_STATE_ITEM_POPUP;
- break;
- default:
- evas_object_del(popup);
+ _delete_ctxpopup(bar);
+ item->state = POPUP_STATE_EDIT;
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool _add_delete_item(Evas_Object *p, struct _ubar_item *item)
+{
+ Evas_Object *ly, *entry, *lbl;
+ const char *name;
+ char buf[BUF_MAX];
+
+ if (!p || !item || !item->it) {
+ _ERR("Invalid argument");
+ return EINA_FALSE;
+ }
+
+ ly = elm_layout_add(p);
+ if (!ly) {
+ _ERR("failed to create layout");
+ return EINA_FALSE;
+ }
+ elm_layout_file_set(ly, EDJEFILE, GRP_UBAR_DELETE);
+ elm_object_content_set(p, ly);
+ evas_object_show(ly);
+
+ engine_ubar_item_get_info(item->it, &name, NULL, NULL, NULL, NULL);
+ snprintf(buf, sizeof(buf), "%s %s?", MESSAGE_DELETE_POPUP,
+ name ? name : "");
+
+ lbl = elm_label_add(ly);
+ if (!lbl) {
+ _ERR("failed to create label");
+ evas_object_del(ly);
+ return EINA_FALSE;
+ }
+ elm_object_text_set(lbl, buf);
+ elm_object_style_set(lbl, STYLE_LABEL_SLIDE_CENTER_22);
+ elm_label_slide_speed_set(lbl, LABEL_SLIDE_SPEED);
+ elm_label_slide_mode_set(lbl, ELM_LABEL_SLIDE_MODE_AUTO);
+ elm_object_part_content_set(ly, PART_USER_DELETE_MESSAGE, lbl);
+
+ entry = _add_password_entry(ly, PART_USER_LOGIN_PW);
+ if (!entry) {
+ _ERR("failed to create entry");
+ evas_object_del(ly);
return EINA_FALSE;
}
+ elm_object_part_text_set(ly, PART_USER_LOGIN_PW_DESC, MESSAGE_PW);
+ evas_object_smart_callback_add(entry, "focused", _entry_focused, ly);
+ evas_object_smart_callback_add(entry, "unfocused", _entry_unfocused,
+ ly);
+
+ item->pw_entry = entry;
return EINA_TRUE;
}
_ERR("Invalid argument");
return EINA_FALSE;
}
+
bar = item->bar;
+ _delete_ctxpopup(bar);
- popup = _add_popup(bar->base, TITLE_DELETE_POPUP,
- STYLE_POPUP_1LINE_2BUTTON);
+ popup = _add_popup(bar->base, TITLE_DELETE_POPUP, NULL);
if (!popup) {
_ERR("failed to create popup");
return EINA_FALSE;
}
- elm_object_text_set(popup, MESSAGE_DELETE_POPUP);
- if (!_add_btn(popup, item, btn_info)) {
+ if (!_add_popup_btn(popup, item, btn_info,
+ sizeof(btn_info) / sizeof(btn_info[0]))) {
_ERR("failed to create popup button");
evas_object_del(popup);
return EINA_FALSE;
}
-
+ evas_object_show(popup);
item->popup = popup;
- switch (bar->state) {
- case UBAR_STATE_USER_CTXPOPUP:
- _destroy_ctxpopup(bar->user);
- bar->state = UBAR_STATE_USER_POPUP;
- break;
- case UBAR_STATE_ITEM_CTXPOPUP:
- _destroy_ctxpopup(item->bar->cur);
- bar->state = UBAR_STATE_ITEM_POPUP;
- break;
- default:
+ if (!_add_delete_item(popup, item)) {
+ _ERR("failed to create login item");
+ evas_object_del(popup);
+ return EINA_FALSE;
+ }
+ elm_object_signal_emit(item->eo, SIG_HLIGHT_FROM_POPOVER, SRC_PROG);
+ item->state = POPUP_STATE_DELETE;
+
+ return EINA_TRUE;
+}
+
+static void _cancel_clicked(void *data, Evas *e, Evas_Object *obj, void *ei)
+{
+ struct _ubar_item *item;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ item = data;
+
+ item->pw_entry = NULL;
+ _destroy_popup(item);
+}
+
+static void _login_clicked(void *data, Evas *e, Evas_Object *obj, void *ei)
+{
+ struct _ubar_item *item;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ item = data;
+
+ if (!_check_password(item->pw_entry, item->it))
+ return;
+
+ item->pw_entry = NULL;
+ _destroy_popup(item);
+}
+
+static Eina_Bool _add_login_item(Evas_Object *p, struct _ubar_item *item)
+{
+ Evas_Object *ly, *ic, *lbl, *entry;
+ bool visible;
+ const char *name, *thumb;
+
+ if (!p || !item || !item->it) {
+ _ERR("Invalid argument");
+ return EINA_FALSE;
+ }
+
+ engine_ubar_item_get_info(item->it, &name, NULL, &thumb, NULL, &visible);
+ if (!visible)
+ return EINA_FALSE;
+
+ ly = elm_layout_add(p);
+ if (!ly) {
+ _ERR("failed to create layout");
+ return EINA_FALSE;
+ }
+ elm_layout_file_set(ly, EDJEFILE, GRP_UBAR_LOGIN);
+ elm_object_content_set(p, ly);
+ evas_object_show(ly);
+
+ ic = elm_icon_add(ly);
+ if (!ic) {
+ _ERR("failed to create icon");
+ evas_object_del(ly);
+ return EINA_FALSE;
+ }
+ elm_image_file_set(ic, thumb ? thumb : DEF_UBAR_ITEM_THUMB, NULL);
+ evas_object_color_set(ic, 66, 71, 108, 255);
+ elm_object_part_content_set(ly, PART_USER_LOGIN_THUMB, ic);
+
+ lbl = elm_label_add(ly);
+ if (!lbl) {
+ _ERR("failed to create label");
+ evas_object_del(ly);
+ return EINA_FALSE;
+ }
+ elm_object_part_content_set(ly, PART_USER_LOGIN_NAME, lbl);
+ elm_object_text_set(lbl, name);
+ elm_object_style_set(lbl, STYLE_LABEL_SLIDE_LEFT_28);
+ elm_label_slide_speed_set(lbl, LABEL_SLIDE_SPEED);
+ elm_label_slide_mode_set(lbl, ELM_LABEL_SLIDE_MODE_AUTO);
+
+ entry = _add_password_entry(ly, PART_USER_LOGIN_PW);
+ if (!entry) {
+ _ERR("failed to create entry");
+ evas_object_del(ly);
+ return EINA_FALSE;
+ }
+ elm_object_part_text_set(ly, PART_USER_LOGIN_PW_DESC, MESSAGE_PW);
+ evas_object_smart_callback_add(entry, "focused", _entry_focused, ly);
+ evas_object_smart_callback_add(entry, "unfocused", _entry_unfocused,
+ ly);
+
+ item->pw_entry = entry;
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool _load_login_popup(struct _ubar_item *item)
+{
+ Evas_Object *popup;
+ struct _btn_info btn_info[] = {
+ {
+ "button1",
+ "Login",
+ _login_clicked
+ },
+ {
+ "button2",
+ "Cancel",
+ _cancel_clicked
+ }
+ };
+
+ if (!item) {
+ _ERR("Invalid argument");
+ return EINA_FALSE;
+ }
+
+ _delete_ctxpopup(item->bar);
+
+ popup = _add_popup(item->bar->base, TITLE_LOGIN_POPUP, NULL);
+ if (!popup) {
+ _ERR("failed to create popup");
+ return EINA_FALSE;
+ }
+
+ if (!_add_popup_btn(popup, item, btn_info,
+ sizeof(btn_info) / sizeof(btn_info[0]))) {
+ _ERR("failed to create popup button");
+ evas_object_del(popup);
+ return EINA_FALSE;
+ }
+ evas_object_show(popup);
+
+ if (!_add_login_item(popup, item)) {
+ _ERR("failed to create login item");
evas_object_del(popup);
return EINA_FALSE;
}
+ item->popup = popup;
+ item->state = POPUP_STATE_LOGIN;
+ elm_object_signal_emit(item->eo, SIG_HLIGHT_FROM_POPOVER, SRC_PROG);
+
return EINA_TRUE;
}
_load_delete_popup(data);
}
-static Eina_Bool _add_popup_btn(struct _ubar_item *item, Evas_Object *base)
+static void _ctxpopup_login_clicked(void *data, Evas *e, Evas_Object *obj,
+ void *ei)
+{
+ _load_login_popup(data);
+}
+
+static Eina_Bool _add_ctxpopup_btn(struct _ubar_item *item, Evas_Object *base)
{
Evas_Object *btn, *firstbtn;
int i;
struct _btn_info btn_info[] = {
{
NULL,
+ "Login",
+ _ctxpopup_login_clicked
+ },
+ {
+ NULL,
"Edit",
_ctxpopup_edit_clicked
},
return EINA_TRUE;
}
-static Eina_Bool _create_popup(struct _ubar_item *item)
+static Eina_Bool _create_ctxpopup(struct _ubar_item *item)
{
Evas_Object *ctxpopup, *box, *win;
Evas_Coord x, w;
+ const char *s;
if (!item) {
_ERR("Invalid argument");
elm_object_style_set(ctxpopup, STYLE_CTXPOPUP_HOVER);
elm_ctxpopup_direction_priority_set(ctxpopup, 0, 0, 0, 0);
evas_object_geometry_get(item->ic, &x, NULL, &w, NULL);
- evas_object_move(ctxpopup,
- (x - CTXPOPUP_BTN_WIDTH / 2 + w / 2) *
- elm_config_scale_get(),
- POSITION_CTXPOPUP_Y * elm_config_scale_get());
+ s = edje_object_data_get(elm_layout_edje_get(item->eo),
+ DATA_TITLE_WIDTH);
+ evas_object_move(ctxpopup, (x + atoi(s) / 2) * elm_config_scale_get(),
+ POSITION_CTXPOPUP_Y *elm_config_scale_get());
box = elm_box_add(ctxpopup);
if (!box) {
evas_object_show(box);
evas_object_show(ctxpopup);
- if (!_add_popup_btn(item, box)) {
+ if (!_add_ctxpopup_btn(item, box)) {
_ERR("failed to create popup button");
evas_object_del(ctxpopup);
return EINA_FALSE;
return EINA_TRUE;
}
-static Eina_Bool _long_key_cb(void *data)
+static Eina_Bool _check_popup_state(struct _ubar_item *item)
{
- struct _ubar_data *bar;
-
- if (!data) {
+ Eina_Bool r;
+ if (!item) {
_ERR("Invalid argument");
return EINA_FALSE;
}
- bar = data;
-
- switch (bar->state) {
- case UBAR_STATE_USER:
- _create_popup(bar->user);
- bar->state = UBAR_STATE_USER_CTXPOPUP;
+ r = EINA_FALSE;
+ switch (item->state) {
+ case POPUP_STATE_LOGIN:
+ case POPUP_STATE_DELETE:
+ if (elm_object_focus_get(item->btn[0])) {
+ if (_check_password(item->pw_entry, item->it))
+ r = EINA_TRUE;
+ } else if (elm_object_focus_get(item->btn[1]))
+ r = EINA_TRUE;
break;
- case UBAR_STATE_ITEM:
- _create_popup(bar->cur);
- bar->state = UBAR_STATE_ITEM_CTXPOPUP;
+ case POPUP_STATE_EDIT:
+ if (elm_object_focus_get(item->btn[0]) ||
+ elm_object_focus_get(item->btn[1]))
+ r = EINA_TRUE;
break;
default:
- break;
+ return EINA_FALSE;
}
- return EINA_TRUE;
+ return r;
}
static enum bar_event _enter(struct bar_info *info)
r = EINA_FALSE;
switch (bar->state) {
case UBAR_STATE_USER:
+ r = EINA_TRUE;
+ if (_check_guest_user(bar->user))
+ break;
+ break;
case UBAR_STATE_ITEM:
- if (!bar->key_timer)
- bar->key_timer = ecore_timer_add(KEY_LONG_DUR,
- _long_key_cb, bar);
r = EINA_TRUE;
+ if (_check_guest_user(bar->user)) {
+ if (_check_add_item(bar->cur)){
+ /* FIXME: load add item */
+ } else {
+ _create_ctxpopup(bar->cur);
+ bar->state = UBAR_STATE_ITEM_CTXPOPUP;
+ }
+ }
break;
case UBAR_STATE_USER_CTXPOPUP:
- if (!bar->user->ctxpopup)
- break;
-
- if (elm_object_focus_get(bar->user->btn[0]))
- r = _load_edit_popup(bar->user);
- else
- r = _load_delete_popup(bar->user);
+ r = EINA_TRUE;
break;
case UBAR_STATE_ITEM_CTXPOPUP:
if (!bar->cur->ctxpopup)
break;
if (elm_object_focus_get(bar->cur->btn[0]))
- r = _load_edit_popup(bar->cur);
- else
- r = _load_delete_popup(bar->cur);
+ r = _load_login_popup(bar->cur);
+ else if (elm_object_focus_get(bar->cur->btn[1])) {
+ if (_check_guest_user(bar->user))
+ r = _load_edit_popup(bar->cur);
+ } else if (elm_object_focus_get(bar->cur->btn[2])) {
+ if (_check_guest_user(bar->user))
+ r = _load_delete_popup(bar->cur);
+ }
break;
case UBAR_STATE_USER_POPUP:
if (!bar->user->popup)
if (!bar->cur->popup)
break;
- _destroy_popup(bar->cur);
+ if (_check_popup_state(bar->cur))
+ _destroy_popup(bar->cur);
r = EINA_TRUE;
break;
default:
return r ? BAR_EVENT_DONE : BAR_EVENT_PASS;
}
-static enum bar_event _key_up(struct bar_info *info, void *ei)
-{
- struct _ubar_data *bar;
- Ecore_Event_Key *ev;
-
- if (!info || !ei)
- return BAR_EVENT_ERROR;
-
- ev = ei;
- bar = info->data;
-
- if (!strcmp(ev->keyname, KEY_ENTER)) {
- if (!bar->key_timer)
- return BAR_EVENT_DONE;
-
- ecore_timer_del(bar->key_timer);
- bar->key_timer = NULL;
- }
-
- return BAR_EVENT_DONE;
-}
-
static enum bar_event _key_down(struct bar_info *info, void *ei)
{
Ecore_Event_Key *ev;
.is_move = _is_move,
.move = _move_user,
.key_down = _key_down,
- .key_up = _key_up,
.release = _release,
};