Add a delete method of ecore event handler to dpm-syspopup 08/109708/1
authorseolheui,kim <s414.kim@samsung.com>
Wed, 11 Jan 2017 08:16:24 +0000 (17:16 +0900)
committerseolheui,kim <s414.kim@samsung.com>
Wed, 11 Jan 2017 08:23:30 +0000 (17:23 +0900)
Change-Id: Ibcc9eb3cdce796e87dbb5c9a2f553614e6566f21
Signed-off-by: seolheui,kim <s414.kim@samsung.com>
tools/syspopup/include/dpm-syspopup.h
tools/syspopup/src/main.c
tools/syspopup/src/ui.c
tools/syspopup/src/widget.c

index 7bae5c0..296b3d6 100644 (file)
@@ -77,6 +77,10 @@ typedef struct {
        char *right_btn;
 } popup_info_s;
 
+typedef struct {
+       Ecore_Event_Handler *key_event_handler;
+} ui_data_s;
+
 app_control_h create_syspopup_app_control(appcontrol_s *list, const char *id);
 int create_syspopup_notification(notification_s *list, const char *id, app_control_h app_control);
 popup_info_s *get_popup_info(const char *id);
@@ -85,6 +89,6 @@ Evas_Object *create_default_popup(Evas_Object *parent, popup_info_s *info, void
 Evas_Object *create_toast_popup(Evas_Object *parent, popup_info_s *body, void *user_data);
 Evas_Object *create_password_enforce_change_popup(Evas_Object *parent, popup_info_s *info, void *user_data);
 
-void create_syspopup(const char *id, void *user_data);
+void create_syspopup(const char *id, void *user_data, ui_data_s *ui_data);
 
 #endif /* __DPM_SYSPOPUP_H__ */
index a45f5cc..94bc33f 100644 (file)
@@ -29,6 +29,7 @@ static void app_control(app_control_h app_control, void *data)
        int ret = 0;
        char *id = NULL;
        char *user_data = NULL;
+       ui_data_s *ui_data = (ui_data_s *)data;
 
        ret = app_control_get_extra_data(app_control, "id", &id);
        if (ret != APP_CONTROL_ERROR_NONE) {
@@ -47,7 +48,7 @@ static void app_control(app_control_h app_control, void *data)
                return;
        }
 
-       create_syspopup(id, user_data);
+       create_syspopup(id, user_data, ui_data);
 
        free(id);
        free(user_data);
@@ -57,6 +58,13 @@ static void app_control(app_control_h app_control, void *data)
 
 static void app_terminate(void *data)
 {
+       ui_data_s *ui_data = (ui_data_s *)data;
+
+       if (ui_data->key_event_handler) {
+               dlog_print(DLOG_INFO, LOG_TAG, "delete key event handler");
+               ecore_event_handler_del(ui_data->key_event_handler);
+               ui_data->key_event_handler = NULL;
+       }
        return;
 }
 
@@ -91,6 +99,7 @@ int main(int argc, char *argv[])
        int ret = 0;
        ui_app_lifecycle_callback_s event_callback = {0, };
        app_event_handler_h handlers[5] = {NULL, };
+       ui_data_s ui_data = {0,};
 
        event_callback.create = app_create;
        event_callback.terminate = app_terminate;
@@ -98,9 +107,9 @@ int main(int argc, char *argv[])
        event_callback.resume = app_resume;
        event_callback.app_control = app_control;
 
-       ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, NULL);
+       ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ui_data);
 
-       ret = ui_app_main(argc, argv, &event_callback, NULL);
+       ret = ui_app_main(argc, argv, &event_callback, &ui_data);
        if (ret != APP_ERROR_NONE)
                dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
 
index 507be65..db92c68 100644 (file)
@@ -34,7 +34,7 @@ static Eina_Bool key_event_cb(void *data, int type, void *event)
        return EINA_TRUE;
 }
 
-void create_syspopup(const char *id, void *user_data)
+void create_syspopup(const char *id, void *user_data, ui_data_s *ui_data)
 {
        Evas_Object *window = NULL, *popup = NULL;
        popup_info_s *info = NULL;
@@ -61,14 +61,16 @@ void create_syspopup(const char *id, void *user_data)
                        popup = create_password_enforce_change_popup(window, info, NULL);
                } else {
                        popup = create_default_popup(window, info, user_data);
-                       ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
+                       if (strcmp(id, "password-enforce-change")) {
+                               ui_data->key_event_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
+                       }
                }
 
                free(manufacturer);
                break;
        case DPM_SYSPOPUP_TOAST:
                popup = create_toast_popup(window, info, NULL);
-               ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
+               ui_data->key_event_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
                break;
        default:
                dlog_print(DLOG_ERROR, LOG_TAG, "Invalid view type");
index 33f1bf8..ccdf8b2 100644 (file)
@@ -39,6 +39,7 @@ Evas_Object *create_window(const char *pkg_name)
        elm_win_title_set(window, pkg_name);
        elm_win_borderless_set(window, EINA_TRUE);
        elm_win_alpha_set(window, EINA_TRUE);
+       elm_win_autodel_set(window, EINA_TRUE);
 
        evas_object_smart_callback_add(window, "delete,request", win_delete_request_cb, NULL);
        evas_object_show(window);