block to delete user when type of user is ADMIN 61/43561/2
authorSoohye Shin <soohye.shin@samsung.com>
Fri, 10 Jul 2015 06:12:22 +0000 (15:12 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Fri, 10 Jul 2015 06:15:34 +0000 (15:15 +0900)
- add disable delete button
- separate data item type to manage in each view: recent_item_type or user_item_type

Change-Id: I40ecc0c2409ba645a04dcdc242c2f5194039e2b9
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
edje/view/useredit.edc
include/datamgr.h
include/defs.h
src/data/data_recent.c
src/data/data_user.c
src/view/view_recent.c
src/view/view_user_edit.c

index 20029f6..81934d5 100644 (file)
@@ -914,6 +914,11 @@ group {
                                inherit, "default" 0.0;
                                color, 0 119 246 255;
                        }
+                       description {
+                               state, "disable" 0.0;
+                               inherit, "default" 0.0;
+                               color, 87 87 87 125;
+                       }
                }
                part {
                        name, "icon";
@@ -943,6 +948,13 @@ group {
                        transition, LINEAR 0.5;
                        target, "bg";
                }
+               program {
+                       name, "sig,disable";
+                       signal, SIG_DISABLE;
+                       source, SRC_PROG;
+                       action, STATE_SET "disable" 0.0;
+                       target, "bg";
+               }
        }
 }
 
index b0e39ad..f2c5e90 100644 (file)
@@ -30,12 +30,6 @@ enum datamgr_item_select_action {
        ITEM_SELECT_ACTION_MAX
 };
 
-enum recent_item_type {
-       RECENT_ITEM_ICON,
-       RECENT_ITEM_PREVIEW,
-       RECENT_ITEM_MAX
-};
-
 struct datamgr {
        Eina_List *list;
        const char *view_id;
@@ -51,7 +45,7 @@ struct datamgr_item {
        char *parameter;
        bool noti;
        enum datamgr_item_select_action action;
-       enum recent_item_type rtype;
+       int type;
 };
 
 struct data_class {
index e4f9f8a..e87fc90 100644 (file)
 #define SIG_SHOW_RECENT "sig.show.recent"
 #define SIG_HIDE_RECENT "sig.hide.recent"
 #define SIG_HIDE_RECENT_DONE "sig.hide.recent.done"
+#define SIG_DISABLE "sig.disable"
 
 #define TITLE_WIDTH "title.width"
 
index 7a3c84d..3d231b0 100644 (file)
@@ -30,7 +30,7 @@
 #define THUMB_DEFAULT "/usr/share/icons/default/small/apps_img_app_default_4x2.png"
 
 static struct datamgr_item *_new_datamgr_item(char *title, char *thumb,
-               char *parameter, char *icon, enum recent_item_type type)
+               char *parameter, char *icon, int type)
 {
        struct datamgr_item *di;
 
@@ -43,7 +43,7 @@ static struct datamgr_item *_new_datamgr_item(char *title, char *thumb,
        di->title = strdup(title);
        di->icon = strdup(thumb);
        di->focus_icon = strdup(icon);
-       di->rtype = type;
+       di->type = type;
        di->parameter = strdup(parameter);
        di->action = ITEM_SELECT_ACTION_LAUNCH;
 
@@ -90,7 +90,7 @@ static void _app_list_foreach(gpointer data, gpointer user_data)
                thumb_land = THUMB_DEFAULT;
 
        di = _new_datamgr_item(label, thumb_land, rdata->id, IMAGE_RECENT_APP,
-                       RECENT_ITEM_ICON);
+                       0);
        if (di)
                dm->list = eina_list_append(dm->list, di);
 
index 1f34e5f..69de638 100644 (file)
@@ -214,7 +214,8 @@ static void _unload_user(struct datamgr *dm)
 }
 
 static struct datamgr_item *_pack_user(char *name, char *icon, char *focus_icon,
-               enum datamgr_item_select_action action, char *parameter)
+               enum datamgr_item_select_action action, char *parameter,
+               int type)
 {
        struct datamgr_item *di;
 
@@ -237,6 +238,7 @@ static struct datamgr_item *_pack_user(char *name, char *icon, char *focus_icon,
        di->icon = strdup(icon);
        di->focus_icon = strdup(focus_icon);
        di->action = action;
+       di->type = type;
 
        return di;
 }
@@ -248,6 +250,7 @@ static bool _load_login_user(Eina_List **list)
        uid_t uid;
        char *name, *icon;
        struct passwd *passwd;
+       GumUserType type;
 
        uid = getuid();
        user = gum_user_get_sync(uid, FALSE);
@@ -256,7 +259,7 @@ static bool _load_login_user(Eina_List **list)
                passwd = getpwuid(uid);
                di = _pack_user(passwd->pw_name, IMAGE_USER_DEFAULT,
                                IMAGE_USER_DEFAULT_FOCUS,
-                               ITEM_SELECT_ACTION_POP, NULL);
+                               ITEM_SELECT_ACTION_POP, NULL, 0);
                if (!di)
                        return false;
 
@@ -267,9 +270,8 @@ static bool _load_login_user(Eina_List **list)
        name = NULL;
        icon = NULL;
        g_object_get(G_OBJECT(user), GUM_ATTR_NAME, &name, GUM_ATTR_ICON, &icon,
-                       NULL);
-
-       di = _pack_user(name, icon, icon, ITEM_SELECT_ACTION_POP, NULL);
+                       GUM_ATTR_USERTYPE, &type, NULL);
+       di = _pack_user(name, icon, icon, ITEM_SELECT_ACTION_POP, NULL, type);
        if (!di) {
                g_object_unref(user);
                return false;
@@ -313,6 +315,7 @@ static bool _load_users(Eina_List **list)
        GumUserList *ulist;
        GumUser *user;
        GumUserService *service;
+       GumUserType type;
        struct datamgr_item *di;
        char *name, *icon;
        gchar **strv;
@@ -340,9 +343,10 @@ static bool _load_users(Eina_List **list)
                        continue;
 
                g_object_get(G_OBJECT(user), GUM_ATTR_NAME, &name,
-                               GUM_ATTR_ICON, &icon, NULL);
+                               GUM_ATTR_ICON, &icon,
+                               GUM_ATTR_USERTYPE, &type, NULL);
                di = _pack_user(name, icon, icon, ITEM_SELECT_ACTION_SWITCH,
-                               NULL);
+                               NULL, type);
                if (!di)
                        continue;
 
@@ -360,7 +364,7 @@ static bool _load_add_user(Eina_List **list)
        struct datamgr_item *di;
 
        di = _pack_user(NULL, IMAGE_USER_ADD, IMAGE_USER_ADD_FOCUS,
-                       ITEM_SELECT_ACTION_PUSH, VIEW_USER_EDIT);
+                       ITEM_SELECT_ACTION_PUSH, VIEW_USER_EDIT, 1);
        if (!di)
                return false;
 
index c644ce2..a993ac0 100644 (file)
 #define MESSAGE_NO_CONTENTS "No Contents"
 #define PADDING_BOX 26
 
+enum recent_item_type {
+       RECENT_ITEM_ICON = 0x00,
+       RECENT_ITEM_PREVIEW = 0x01
+};
+
 struct _priv {
        Evas_Object *win;
        Evas_Object *base;
@@ -244,7 +249,7 @@ static struct _bar_item *_pack_item(struct _priv *priv, Evas_Object *box,
        struct _bar_item *bi;
        const char *group;
 
-       switch (di->rtype) {
+       switch (di->type) {
        case RECENT_ITEM_PREVIEW:
                group = GRP_RECENT_PREVIEW;
                break;
index fc80dfc..15f3ce4 100644 (file)
 #define CTXPOPUP_Y 310
 #define MAX_BUF 128
 
+enum user_item_type {
+       USER_ITEM_NONE = 0x00,
+       USER_ITEM_ADD = 0x01,
+       USER_ITEM_ADMIN = 0x02,
+       USER_ITEM_NORMAL = 0x08
+};
+
 struct _icon_info {
        const char *file;
        const char *focus_file;
@@ -570,10 +577,22 @@ static void _load_del_btn(struct _priv *priv)
 {
        Evas_Object *btn;
 
+       if (priv->di->type == USER_ITEM_ADMIN) {
+               btn = utils_add_layout(priv->ly, GRP_USER_EDIT_DELETE, false,
+                               PART_USER_EDIT_CONTENTS_DELETE);
+               if (!btn) {
+                       _ERR("failed to add delete button");
+                       return;
+               }
+               elm_object_signal_emit(btn, SIG_DISABLE, SRC_PROG);
+               return;
+       }
+
+
        btn = utils_add_layout(priv->ly, GRP_USER_EDIT_DELETE, true,
                        PART_USER_EDIT_CONTENTS_DELETE);
        if (!btn) {
-               _ERR("failed toa add delete button");
+               _ERR("failed to add delete button");
                return;
        }
        inputmgr_add_callback(btn, 0, &del_handler, priv);
@@ -612,6 +631,7 @@ static void _show(void *data)
        }
 
        evas_object_show(priv->base);
+       elm_object_focus_set(priv->cancel, EINA_TRUE);
 }
 
 static void _hide(void *data)