From: lokilee73 Date: Mon, 12 Dec 2016 14:29:18 +0000 (+0900) Subject: powerkey popup : change sub option according to telephony X-Git-Tag: accepted/tizen/3.0/common/20161216.124317~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6abaa1bc70804210d8a6f3dcbd3b04ac9b3c39de;p=platform%2Fcore%2Fsystem%2Fsystem-popup.git powerkey popup : change sub option according to telephony Change-Id: I4c20a31a7675225e02227e1431a55b0931ba91a9 Signed-off-by: lokilee73 --- diff --git a/src/powerkey/powerkey-wearable.c b/src/powerkey/powerkey-wearable.c index 6194d00..abffe1a 100755 --- a/src/powerkey/powerkey-wearable.c +++ b/src/powerkey/powerkey-wearable.c @@ -58,11 +58,13 @@ static void register_handlers(const struct popup_ops *ops); static void unregister_handlers(const struct popup_ops *ops); static void poweroff_clicked(const struct popup_ops *ops); static void create_list_view(appdata_s *application_info, const struct popup_ops *ops); +static void create_poweroff_view(appdata_s *application_info, const struct popup_ops *ops); static void set_flight_icon(int value); static __attribute__ ((constructor)) void powerkey_register_popup(void); static const struct popup_ops powerkey_ops; static const struct popup_ops flightmode_ops; -static const struct popup_ops poweroff_ops; + +static int telephony_supported = -1; static int is_supported(const char *path) { @@ -333,7 +335,10 @@ create_base_gui(appdata_s *application_info, const struct popup_ops *ops) /* Naviframe */ ad->nf = elm_naviframe_add(ad->layout); - create_list_view(ad, ops); + if (telephony_supported) + create_list_view(ad, ops); + else + create_poweroff_view(ad, ops); elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->nf); /* Show window after base gui is set up */ @@ -364,7 +369,14 @@ create_list_view(appdata_s *application_info, const struct popup_ops *ops) int i; ad = (appdata_s *)application_info; - if (ad == NULL) return; + if (ad == NULL) { + elm_genlist_item_class_free(itc); + elm_genlist_item_class_free(ttc); + elm_genlist_item_class_free(utc); + elm_genlist_item_class_free(ptc); + + return; + } genlist = elm_genlist_add(ad->nf); elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); @@ -418,6 +430,66 @@ create_list_view(appdata_s *application_info, const struct popup_ops *ops) elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win); } +static void +create_poweroff_view(appdata_s *application_info, const struct popup_ops *ops) +{ + appdata_s *ad = NULL; + Evas_Object *genlist = NULL; + Evas_Object *circle_genlist; + Elm_Object_Item *nf_it; + Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new(); + Elm_Genlist_Item_Class *ttc = elm_genlist_item_class_new(); + Elm_Genlist_Item_Class *ptc = elm_genlist_item_class_new(); + Item_Data *id; + int i; + + ad = (appdata_s *)application_info; + if (ad == NULL) { + elm_genlist_item_class_free(itc); + elm_genlist_item_class_free(ttc); + elm_genlist_item_class_free(ptc); + + return; + }; + + genlist = elm_genlist_add(ad->nf); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + + circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface); + eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE); + + ttc->item_style = "title"; + ttc->func.text_get = _gl_menu_title_text_get; + ttc->func.del = NULL; + + itc->item_style = "1text.1icon"; + itc->func.text_get = _gl_menu_text_get_poweroff; + itc->func.content_get = _gl_menu_contents_get_poweroff; + itc->func.del = NULL; + + ptc->item_style = "padding"; + ptc->func.del = NULL; + + /* back key */ + eext_object_event_callback_add(genlist, EEXT_CALLBACK_BACK, event_back_key_up, (void*)ops); + elm_genlist_item_append(genlist, ttc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + + i = 0; + id = calloc(sizeof(Item_Data), 1); + id->index = i; + id->item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_poweroff_cb, ops); + + elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + + elm_genlist_item_class_free(itc); + elm_genlist_item_class_free(ttc); + elm_genlist_item_class_free(ptc); + + nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); + elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win); +} + static int powerkey_list(bundle *b, const struct popup_ops *ops) { struct object_ops *obj; @@ -483,24 +555,6 @@ static void flight_mode_terminate(const struct popup_ops *ops) unregister_handlers(ops); } -static void remove_other_poweroff_popups(const struct popup_ops *ops) -{ - if (ops != &poweroff_ops) - unload_simple_popup(&poweroff_ops); -} - -static int poweroff_launch(bundle *b, const struct popup_ops *ops) -{ - remove_other_poweroff_popups(ops); - register_handlers(ops); - return 0; -} - -static void poweroff_terminate(const struct popup_ops *ops) -{ - unregister_handlers(ops); -} - static const struct popup_ops powerkey_ops = { .name = "powerkey", .show = powerkey_list, @@ -521,22 +575,8 @@ static const struct popup_ops flightmode_ops = { .terminate = flight_mode_terminate, }; -static const struct popup_ops poweroff_ops = { - .name = "powerkey", - .show = load_simple_popup, - .title = "IDS_ST_BODY_POWER_OFF", - .content = "IDS_TPLATFORM_BODY_POWER_OFF_THE_DEVICE_Q", - .left_text = "IDS_COM_SK_CANCEL", - .right_text = "IDS_HS_BUTTON_POWER_OFF_ABB2", - .right = poweroff_clicked, - .pre = poweroff_launch, - .terminate = poweroff_terminate, -}; - static __attribute__ ((constructor)) void powerkey_register_popup(void) { - int telephony_supported = -1; - telephony_supported = is_supported(TELEPHONY_PATH); _I("TELEPHONY = %d", telephony_supported); if (telephony_supported > 1 || telephony_supported < 0) { @@ -544,9 +584,7 @@ static __attribute__ ((constructor)) void powerkey_register_popup(void) telephony_supported = 0; } - if (telephony_supported) { - register_popup(&powerkey_ops); + register_popup(&powerkey_ops); + if (telephony_supported) register_popup(&flightmode_ops); - } else - register_popup(&poweroff_ops); }