From: Sehong Na Date: Sat, 31 May 2014 03:55:45 +0000 (+0900) Subject: Initialize Tizen 2.3 X-Git-Tag: 2.3a_release X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a60d722d1ef542f51dd435e053b2e36c44d76183;p=apps%2Fhome%2Fmenu-screen.git Initialize Tizen 2.3 --- a60d722d1ef542f51dd435e053b2e36c44d76183 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4f9114b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +.gitattributes export-ignore +.gitignore export-ignore +debian export-ignore diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..95e1254 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Jin Yoon +Youngjoo Park diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5fe2f0d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,98 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(menu-screen C) + +SET(PACKAGE_NAME "org.tizen.${PROJECT_NAME}") +SET(PREFIX "/usr/apps/${PACKAGE_NAME}") +SET(EXEC_PREFIX "${PREFIX}/bin") +SET(LIBDIR "${PREFIX}/lib") +SET(DATADIR "/opt${PREFIX}/data") +SET(RESDIR "${PREFIX}/res") +SET(IMAGEDIR "${RESDIR}/images") +SET(EDJEDIR "${RESDIR}/edje") +SET(LOCALEDIR "${RESDIR}/locale") +SET(VERSION 0.1.0) + +INCLUDE(FindPkgConfig) +pkg_check_modules(MENU_PKGS REQUIRED + ail + appsvc + aul + badge + bundle + capi-appfw-application + capi-system-info + dlog + ecore + ecore-evas + ecore-file + ecore-imf + ecore-input + ecore-x + edje + eet + eina + elementary + evas + heynoti + pkgmgr + pkgmgr-info + shortcut + sysman + syspopup-caller + utilX +) + +ADD_DEFINITIONS("-DENABLE_BGIMAGE") +ADD_DEFINITIONS("-DLOG_TAG=\"MENU_SCREEN\"") +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"") +ADD_DEFINITIONS("-DVERSION=\"${VERSION}\"") +ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"") +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") +ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGEDIR}\"") +ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"") +ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") + +FOREACH (flag ${MENU_PKGS_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +ADD_EXECUTABLE(${PROJECT_NAME} + src/db.c + src/index.c + src/item.c + src/item_badge.c + src/item_event.c + src/key.c + src/layout.c + src/list.c + src/mapbuf.c + src/menu_screen.c + src/mouse.c + src/page.c + src/page_scroller.c + src/pkgmgr.c + src/popup.c + src/util.c + src/all_apps/db.c + src/all_apps/layout.c + src/all_apps/list.c + src/all_apps/shortcut.c +) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${MENU_PKGS_LDFLAGS}) + +# Install +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${EXEC_PREFIX}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.Flora DESTINATION /usr/share/license RENAME ${PACKAGE_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.rule DESTINATION /opt/etc/smack/accesses.d) + +ADD_SUBDIRECTORY(data) + +# End of a file diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100644 index 0000000..571fe79 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.1, April, 2013 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Tizen Compliance Specification +and passes the Tizen Compliance Tests as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum + to the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. You may add Your own + copyright statement to Your modifications and may provide additional or + different license terms and conditions for use, reproduction, or + distribution of Your modifications, or for any such Derivative Works + as a whole, provided Your use, reproduction, and distribution of + the Work otherwise complies with the conditions stated in this License + and your own copyright statement or terms and conditions do not conflict + the conditions stated in the License including section 3. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.1 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..04443b1 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under the Flora License, Version 1.1. +Please, see the LICENCE.Flora file for the Flora License, Version 1.1 terms and conditions. diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt new file mode 100644 index 0000000..b491de5 --- /dev/null +++ b/data/CMakeLists.txt @@ -0,0 +1,11 @@ +SET(MANIFESTDIR "/usr/share/packages") + +# manifest +CONFIGURE_FILE(${PACKAGE_NAME}.xml.in ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.xml) +INSTALL(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.xml DESTINATION ${MANIFESTDIR}) + +ADD_SUBDIRECTORY(edje) +ADD_SUBDIRECTORY(images) +ADD_SUBDIRECTORY(po) + +# End of a file diff --git a/data/edje/CMakeLists.txt b/data/edje/CMakeLists.txt new file mode 100644 index 0000000..2e334a0 --- /dev/null +++ b/data/edje/CMakeLists.txt @@ -0,0 +1,61 @@ +ADD_CUSTOM_TARGET(index.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/../images ${EDJE_CFLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/index.edc index.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/index.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} index.edj) +INSTALL(FILES index.edj DESTINATION ${EDJEDIR}) + + + +ADD_CUSTOM_TARGET(item_4x4.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/../images ${EDJE_CFLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/item_4x4.edc item_4x4.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/item_4x4.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} item_4x4.edj) +INSTALL(FILES item_4x4.edj DESTINATION ${EDJEDIR}) + + + +ADD_CUSTOM_TARGET(group_4x4_portrait.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/../images ${EDJE_CFLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/group_4x4_portrait.edc group_4x4_portrait.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/group_4x4_portrait.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} group_4x4_portrait.edj) +INSTALL(FILES group_4x4_portrait.edj DESTINATION ${EDJEDIR}) + + + +ADD_CUSTOM_TARGET(all_apps_portrait.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/../images ${EDJE_CFLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/all_apps_portrait.edc all_apps_portrait.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/all_apps_portrait.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} all_apps_portrait.edj) +INSTALL(FILES all_apps_portrait.edj DESTINATION ${EDJEDIR}) + + + +ADD_CUSTOM_TARGET(layout_portrait.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/../images ${EDJE_CFLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/layout_portrait.edc layout_portrait.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/layout_portrait.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} layout_portrait.edj) +INSTALL(FILES layout_portrait.edj DESTINATION ${EDJEDIR}) + + + +ADD_CUSTOM_TARGET(button_edit.edj + COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/../images ${EDJE_CFLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/button_edit.edc button_edit.edj + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/button_edit.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} button_edit.edj) +INSTALL(FILES button_edit.edj DESTINATION ${EDJEDIR}) + + + +# End of a file diff --git a/data/edje/all_apps_portrait.edc b/data/edje/all_apps_portrait.edc new file mode 100644 index 0000000..b413286 --- /dev/null +++ b/data/edje/all_apps_portrait.edc @@ -0,0 +1,145 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +collections { + group { + name: "all_apps"; + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + visible: 0; + } + } + + part { + name: "index_bg"; + type: RECT; + scale: 1; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { relative: 0.0 20/1210; to, "bg";} // 1280 - 70(indicator) + rel2 { relative: 1.0 124/1210; to, "bg";} // 174 - 70 + color: 0 0 0 255; + visible: 0; + } + } + part { + name: "index"; + type: SWALLOW; + mouse_events: 0; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: 0.2 0.0; to, "index_bg";} + rel2 { relative: 0.8 1.0; to, "index_bg";} + visible: 1; + } + } + part { + name: "button_edit"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: 16/720 8/70; to, "index_bg";} + rel2 { relative: 144/720 62/70; to, "index_bg";} + fixed: 1 1; + visible: 1; + } + } + part { + name: "content_bg"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 134/1210; to, "bg"; } // 154 - 70 + rel2 { relative: 1.0 1164/1210; to, "bg"; } + color: 34 34 34 255; + visible: 0; + } + } + + part { + name: "content"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + align: 0.5 0.0; + rel1 { relative: 0.0 0.0; to, "content_bg";} + rel2 { relative: 1.0 1.0; to, "content_bg";} + visible: 1; + } + } + + part { + name: "content,blocker"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to, "bg";} + rel2 { relative: 1.0 1.0; to, "bg";} + color: 0 0 0 0; + visible: 0; + } + description { + state: "block" 0.0; + inherit: "default" 0.0; + color: 0 0 0 0; + visible: 1; + } + } + } + + programs { + program { + name: "block,content"; + signal: "block"; + source: "layout"; + action: STATE_SET "block" 0.0; + target: "content,blocker"; + } + program { + name: "unblock,content"; + signal: "unblock"; + source: "layout"; + action: STATE_SET "default" 0.0; + target: "content,blocker"; + } + } + } // group +} // collections + + + +// End of file diff --git a/data/edje/button_edit.edc b/data/edje/button_edit.edc new file mode 100644 index 0000000..982220c --- /dev/null +++ b/data/edje/button_edit.edc @@ -0,0 +1,294 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#define BUTTON_EDIT_BG_SIZE 98 56 +#define BUTTON_EDIT_IMAGE_SIZE 35 35 + + + +images { + image: "../images/btn_edit_nor.9.png" COMP; + image: "../images/btn_edit_press.9.png" COMP; + image: "../images/icon_btn_edit_press.png" COMP; + image: "../images/icon_btn_edit_nor.png" COMP; + image: "../images/icon_btn_done_press.png" COMP; + image: "../images/icon_btn_done_nor.png" COMP; +} + + + +collections { + group { + name: "button_edit"; + parts { + part { + name: "edit_button"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + visible: 0; + } + description { + state: "enable" 0.0; + inherit: "default" 0.0; + } + description { + state: "hide" 0.0; + inherit: "default" 0.0; + } + } + part { + name: "edit_button_bg"; + type: IMAGE; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.5 0.5; to, "edit_button"; } + rel2 { relative: 0.5 0.5; to, "edit_button"; } + min: BUTTON_EDIT_BG_SIZE; + max: BUTTON_EDIT_BG_SIZE; + fixed: 1 1; + image { + normal: "../images/btn_edit_nor.9.png"; + border: 30 30 0 0; + middle: DEFAULT; + border_scale: 1; + } + color: 255 255 255 255; + visible: 1; + } + description { + state: "edit" 0.0; + inherit: "default" 0.0; + } + description { + state: "enable" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + description { + state: "press" 0.0; + inherit: "default" 0.0; + image { + normal: "../images/btn_edit_press.9.png"; + } + } + description { + state: "hide" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { + name: "edit_button_image"; + type: IMAGE; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1 { relative: 0.5 0.5; to, "edit_button_bg";} + rel2 { relative: 0.5 0.5; to, "edit_button_bg";} + image { + normal: "../images/icon_btn_edit_nor.png"; + } + min: BUTTON_EDIT_IMAGE_SIZE; + max: BUTTON_EDIT_IMAGE_SIZE; + fixed: 1 1; + visible: 1; + } + description { + state: "edit" 0.0; + inherit: "default" 0.0; + image { + normal: "../images/icon_btn_done_nor.png"; + } + } + description { + state: "press" 0.0; + inherit: "default" 0.0; + image { + normal: "../images/icon_btn_edit_press.png"; + } + } + description { + state: "edit_press" 0.0; + inherit: "default" 0.0; + image { + normal: "../images/icon_btn_done_press.png"; + } + } + } + part { + name: "edit_button_event"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: -0.1 -0.1; to: "edit_button_bg"; } + rel2 { relative: 1.1 1.1; to: "edit_button_bg"; } + color: 0 0 0 0; + visible: 1; + } + description { + state: "hide" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { + name: "focus"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to: "edit_button_event"; } + rel2 { relative: 1.0 1.0; to: "edit_button_event"; } + fixed: 1 1; + visible: 1; + } + } + part { + name: "state_edit"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 0; + } + description { + state: "edit" 0.0; + inherit: "default" 0.0; + } + } + } + + programs { + program { + name: "edit_button,down"; + signal: "mouse,down,1"; + source: "edit_button_event"; + action: STATE_SET "press" 0.0; + target: "edit_button_bg"; + after: "press_state"; + } + program { + name: "press_state"; + script { + new st[31]; + new Float:vl; + get_state(PART:"state_edit", st, 30, vl); + if (!strcmp(st, "default")) + { + set_state(PART:"edit_button_image", "press", 0.0); + } + else + { + set_state(PART:"edit_button_image", "edit_press", 0.0); + } + } + after: "edit_button,down,after"; + } + program { + name: "edit_button,down,after"; + action: SIGNAL_EMIT "edit_button,down" "menu"; + } + + program { + name: "edit_button,up"; + signal: "mouse,up,1"; + source: "edit_button_event"; + action: STATE_SET "default" 0.0; + target: "edit_button_bg"; + after: "edit_button,up,after"; + } + program { // Edit or unedit in C codes. + name: "edit_button,up,after"; + action: SIGNAL_EMIT "edit_button,up" "menu"; + } + program { // This program is called from C. + name: "release_state"; + signal: "edit_button,release"; + source: "menu"; + script { + new st[31]; + new Float:vl; + get_state(PART:"state_edit", st, 30, vl); + if (!strcmp(st, "default")) // Normal mode + { + set_state(PART:"edit_button_image", "default", 0.0); + } + else // Edit mode + { + set_state(PART:"edit_button_image", "edit", 0.0); + } + } + } + + program { // Edit mode + name: "edit_button_state,edit"; + signal: "edit_button_state,edit"; + source: "menu"; + action: STATE_SET "edit" 0.0; + target: "state_edit"; + target: "edit_button_bg"; + target: "edit_button_image"; + } + program { // Normal mode + name: "edit_button_state,unedit"; + signal: "edit_button_state,unedit"; + source: "menu"; + action: STATE_SET "default" 0.0; + target: "state_edit"; + target: "edit_button_bg"; + target: "edit_button_image"; + } + + program { + name: "edit_button,show"; + signal: "edit_button,show"; + source: "menu"; + action: STATE_SET "default" 0.0; + target: "edit_button_bg"; + target: "edit_button_image"; + target: "edit_button_event"; + } + program { + name: "edit_button,hide"; + signal: "edit_button,hide"; + source: "menu"; + action: STATE_SET "hide" 0.0; + target: "edit_button_bg"; + target: "edit_button_image"; + target: "edit_button_event"; + } + } + } +} + + +// End of file diff --git a/data/edje/conf.edc b/data/edje/conf.edc new file mode 120000 index 0000000..de97229 --- /dev/null +++ b/data/edje/conf.edc @@ -0,0 +1 @@ +../../include/conf.h \ No newline at end of file diff --git a/data/edje/group_4x4_portrait.edc b/data/edje/group_4x4_portrait.edc new file mode 100644 index 0000000..de78a2a --- /dev/null +++ b/data/edje/group_4x4_portrait.edc @@ -0,0 +1,219 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#define MENU(part_name, p_relx, p_rely, relx, rely, n_relx, n_rely) \ + part { \ + name: "menu_swallow_"part_name; \ + type: SWALLOW; \ + scale: 1; \ + mouse_events: 1; \ + description { \ + state: "default" 0.0; \ + visible: 1; \ + fixed: 1 1; \ + rel1 { relative: (relx) (rely); to, "bg"; } \ + rel2 { relative: (relx) (rely); to, "bg"; } \ + } \ + description { \ + state: "prev" 0.0; \ + inherit: "default" 0.0; \ + rel1.relative: (p_relx) (p_rely); \ + rel2.relative: (p_relx) (p_rely); \ + } \ + description { \ + state: "next" 0.0; \ + inherit: "default" 0.0; \ + rel1.relative: (n_relx) (n_rely); \ + rel2.relative: (n_relx) (n_rely); \ + } \ + description { \ + state: "invisible" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + rel1.relative: (n_relx) (n_rely); \ + rel2.relative: (n_relx) (n_rely); \ + } \ + } \ + +#define MENU_PROGRAM(part_name) \ + program { \ + name: "menu_"part_name"_prev"; \ + signal: "move,prev"; \ + source: "menu"part_name; \ + action: STATE_SET "prev" 0.0; \ + target: "menu_swallow_"part_name; \ + } \ + program { \ + name: "menu_"part_name"_next"; \ + signal: "move,next"; \ + source: "menu"part_name; \ + action: STATE_SET "next" 0.0; \ + target: "menu_swallow_"part_name; \ + } \ + program { \ + name: "menu_"part_name"_ani"; \ + signal: "ani,return"; \ + source: "menu"part_name; \ + action: STATE_SET "default" 0.0; \ + target: "menu_swallow_"part_name; \ + transition: DECELERATE 0.4; \ + } \ + program { \ + name: "menu_"part_name"_invisible"; \ + signal: "invisible"; \ + source: "menu"part_name; \ + action: STATE_SET "invisible" 0.0; \ + target: "menu_swallow_"part_name; \ + } + +#define ITEM_00_X (1.0/8.0) +#define ITEM_00_Y (1.0/8.0) +#define ITEM_01_X (3.0/8.0) +#define ITEM_01_Y ITEM_00_Y +#define ITEM_02_X (5.0/8.0) +#define ITEM_02_Y ITEM_00_Y +#define ITEM_03_X (7.0/8.0) +#define ITEM_03_Y ITEM_00_Y + +#define ITEM_04_X ITEM_00_X +#define ITEM_04_Y (3.0/8.0) +#define ITEM_05_X ITEM_01_X +#define ITEM_05_Y ITEM_04_Y +#define ITEM_06_X ITEM_02_X +#define ITEM_06_Y ITEM_04_Y +#define ITEM_07_X ITEM_03_X +#define ITEM_07_Y ITEM_04_Y + +#define ITEM_08_X ITEM_00_X +#define ITEM_08_Y (5.0/8.0) +#define ITEM_09_X ITEM_01_X +#define ITEM_09_Y ITEM_08_Y +#define ITEM_10_X ITEM_02_X +#define ITEM_10_Y ITEM_08_Y +#define ITEM_11_X ITEM_03_X +#define ITEM_11_Y ITEM_08_Y + +#define ITEM_12_X ITEM_00_X +#define ITEM_12_Y (7.0/8.0) +#define ITEM_13_X ITEM_01_X +#define ITEM_13_Y ITEM_12_Y +#define ITEM_14_X ITEM_02_X +#define ITEM_14_Y ITEM_12_Y +#define ITEM_15_X ITEM_03_X +#define ITEM_15_Y ITEM_12_Y + +collections { + group { + name: "menu_bg"; + parts { + part { + name: "bg"; + type: SWALLOW; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + } + + MENU("0", ITEM_00_X, ITEM_00_Y, ITEM_00_X, ITEM_00_Y, ITEM_01_X, ITEM_01_Y) + MENU("1", ITEM_00_X, ITEM_00_Y, ITEM_01_X, ITEM_01_Y, ITEM_02_X, ITEM_02_Y) + MENU("2", ITEM_01_X, ITEM_01_Y, ITEM_02_X, ITEM_02_Y, ITEM_03_X, ITEM_03_Y) + MENU("3", ITEM_02_X, ITEM_02_Y, ITEM_03_X, ITEM_03_Y, ITEM_04_X, ITEM_04_Y) + MENU("4", ITEM_03_X, ITEM_03_Y, ITEM_04_X, ITEM_04_Y, ITEM_05_X, ITEM_05_Y) + MENU("5", ITEM_04_X, ITEM_04_Y, ITEM_05_X, ITEM_05_Y, ITEM_06_X, ITEM_06_Y) + MENU("6", ITEM_05_X, ITEM_05_Y, ITEM_06_X, ITEM_06_Y, ITEM_07_X, ITEM_07_Y) + MENU("7", ITEM_06_X, ITEM_06_Y, ITEM_07_X, ITEM_07_Y, ITEM_08_X, ITEM_08_Y) + MENU("8", ITEM_07_X, ITEM_07_Y, ITEM_08_X, ITEM_08_Y, ITEM_09_X, ITEM_09_Y) + MENU("9", ITEM_08_X, ITEM_08_Y, ITEM_09_X, ITEM_09_Y, ITEM_10_X, ITEM_10_Y) + MENU("10", ITEM_09_X, ITEM_09_Y, ITEM_10_X, ITEM_10_Y, ITEM_11_X, ITEM_11_Y) + MENU("11", ITEM_10_X, ITEM_10_Y, ITEM_11_X, ITEM_11_Y, ITEM_12_X, ITEM_12_Y) + MENU("12", ITEM_11_X, ITEM_11_Y, ITEM_12_X, ITEM_12_Y, ITEM_13_X, ITEM_13_Y) + MENU("13", ITEM_12_X, ITEM_12_Y, ITEM_13_X, ITEM_13_Y, ITEM_14_X, ITEM_14_Y) + MENU("14", ITEM_13_X, ITEM_13_Y, ITEM_14_X, ITEM_14_Y, ITEM_15_X, ITEM_15_Y) + MENU("15", ITEM_14_X, ITEM_14_Y, ITEM_15_X, ITEM_15_Y, ITEM_15_X, ITEM_15_Y) + + part { + name: "dim"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 0; + rel1 { relative: 0.0 0.0; to, "bg"; } + rel2 { relative: 1.0 1.0; to, "bg"; } + } + description { + state: "edit" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 0 0 0 102; + } + } + } + + programs { + MENU_PROGRAM("0") + MENU_PROGRAM("1") + MENU_PROGRAM("2") + MENU_PROGRAM("3") + MENU_PROGRAM("4") + MENU_PROGRAM("5") + MENU_PROGRAM("6") + MENU_PROGRAM("7") + MENU_PROGRAM("8") + MENU_PROGRAM("9") + MENU_PROGRAM("10") + MENU_PROGRAM("11") + MENU_PROGRAM("12") + MENU_PROGRAM("13") + MENU_PROGRAM("14") + MENU_PROGRAM("15") + + program { + name: "dim,on"; + signal: "dim,on"; + source: "menu"; + action: STATE_SET "edit" 0.0; + target: "dim"; + } + program { + name: "dim,off"; + signal: "dim,off"; + source: "menu"; + action: STATE_SET "default" 0.0; + target: "dim"; + } + + program { + name: "dim,down"; + signal: "mouse,down,1"; + source: "dim"; + action: SIGNAL_EMIT "dim,down" "menu"; + } + program { + name: "dim,up"; + signal: "mouse,up,1"; + source: "dim"; + action: SIGNAL_EMIT "dim,up" "menu"; + } + } + } // group +} // collections diff --git a/data/edje/index.edc b/data/edje/index.edc new file mode 100644 index 0000000..a5f2336 --- /dev/null +++ b/data/edje/index.edc @@ -0,0 +1,179 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define INDEX_PAGECONTROL_IND_INC 35 35 +#define INDEX_PAGECONTROL_IND_MIN_INC 35 35 +#define INDEX_PAGECONTROL_FONT_COLOR_INC 255 255 255 +#define INDEX_PAGECONTROL_FONT_SIZE_INC 18 + +collections { + group { + name: "elm/index/base/vertical/menuscreen/index"; + alias: "elm/index/base/horizontal/menuscreen/index"; + parts { + part { name: "clip"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + } + description { state: "active" 0.0; + visible: 1; + color: 255 255 255 255; + } + } + part { name: "elm.swallow.index.0"; + type: SWALLOW; + scale: 1; + mouse_events: 0; + clip_to: "clip"; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1.relative: 0 0; + rel2.relative: 1 1; + } + } + part { name: "elm.swallow.event.0"; + type: SWALLOW; + mouse_events: 0; + repeat_events: 0; + description { state: "default" 0.0; + align: 0.5 0.5; + } + } + } + programs { + program { name: "active"; + signal: "elm,state,active"; + source: "elm"; + action: STATE_SET "active" 0.0; + transition: DECELERATE 0.5; + target: "clip"; + } + program { name: "inactive"; + signal: "elm,state,inactive"; + source: "elm"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "clip"; + } + } + } + group { + name: "elm/index/item/vertical/menuscreen/index"; + alias: "elm/index/item_odd/vertical/menuscreen/index"; + alias: "elm/index/item/horizontal/menuscreen/index"; + alias: "elm/index/item_odd/horizontal/menuscreen/index"; + images { + image: "../images/page indicator.png" COMP; + image: "../images/page indicator_focus.png" COMP; + } + parts { + part { name:"bg"; + type : RECT; + scale: 1; + description { state: "default" 0.0; + min: INDEX_PAGECONTROL_IND_INC; + max: INDEX_PAGECONTROL_IND_INC; + visible: 0; + align: 0.5 0.5; + } + } + part { name: "indicator1"; + type: IMAGE; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + align: 0.5 0.5; + fixed: 1 1; + rel1.to: "bg"; + rel2.to: "bg"; + image { + normal: "../images/page indicator.png"; + } + } + description { state: "active" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { name: "indicator2"; + type: IMAGE; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + align: 0.5 0.5; + fixed: 1 1; + min: INDEX_PAGECONTROL_IND_MIN_INC; + max: INDEX_PAGECONTROL_IND_MIN_INC; + image.normal: "../images/page indicator_focus.png"; + visible: 0; + } + description { state: "active" 0.0; + inherit: "default" 0.0; + min: INDEX_PAGECONTROL_IND_INC; + max: INDEX_PAGECONTROL_IND_INC; + visible: 1; + } + } + part { name: "elm.text"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + fixed: 1 1; + color: INDEX_PAGECONTROL_FONT_COLOR_INC 0; + align: 0.5 0.5; + text { + font: "TIZEN:style=Bold"; + size: INDEX_PAGECONTROL_FONT_SIZE_INC; + min: 0 1; + //FIXME:values should be 0.5 0.5 when fonts are aligned correctly. + align: 0.53 0.56; + } + rel1 { to: "indicator2"; } + rel2 { to: "indicator2"; } + } + description { state: "active" 0.0; + inherit: "default" 0.0; + color: INDEX_PAGECONTROL_FONT_COLOR_INC 255; + } + } + } + programs { + program { name: "active"; + signal: "elm,state,active"; + source: "elm"; + action: STATE_SET "active" 0.0; + target: "indicator1"; + target: "indicator2"; + target: "elm.text"; + transition: LINEAR 0.2; + } + program { name: "inactive"; + signal: "elm,state,inactive"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "indicator1"; + target: "indicator2"; + target: "elm.text"; + transition: LINEAR 0.2; + } + } + } +} diff --git a/data/edje/item_4x4.edc b/data/edje/item_4x4.edc new file mode 100644 index 0000000..6d9716b --- /dev/null +++ b/data/edje/item_4x4.edc @@ -0,0 +1,345 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include "conf.edc" + + + +styles { + style { + name: "app_name_style"; + base: "font=TIZEN:style=MEDIUM font_size=27 align=center valign=top color=#FFFFFF style=soft_shadow shadow_color=#00000060 ellipsis=1"; + + tag: "br" "\n"; + } +} + +images { + image: "../images/RM06_App tray_Btn_Uninstall.png" COMP; + image: "../images/RM06_App tray_Btn_Uninstall_press.png" COMP; + image: "../images/menu_badge_01.png" COMP; +} + + + +collections { + group { + name: "icon"; + + parts { + part { + name: "bg"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + fixed: 1 1; + visible: 0; + } + } + part { + name: "icon_image"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.5 60/ITEM_HEIGHT; to: "bg"; } + rel2 { relative: 0.5 60/ITEM_HEIGHT; to: "bg"; } + align: 0.5 0.5; + min: 117 117; + fixed: 1 1; + } + } + part { + name: "icon_image_event"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + /* Enlarge the starting point of Y for tester's request */ + rel1 { relative: 0.0 0.0; to, "bg"; } //0.0 -0.1 + rel2 { relative: 1.0 1.0; to, "bg"; } + color: 0 0 0 0; + visible: 1; + } + } + part { + name: "badge"; + type: IMAGE; + scale: 1; + mouse_events: 0; + description { + state: "default" 0.0; + visible: 0; + rel1 { relative: 110/ITEM_WIDTH 0.0; to, "bg"; } + rel2 { relative: 170/ITEM_WIDTH 60/ITEM_HEIGHT; to, "bg"; } + image { + normal: "../images/menu_badge_01.png"; + } + } + description { + state: "badge" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + + part { + name: "badge,txt"; + type: TEXT; + scale: 1; + mouse_events: 0; + description { + state: "default" 0.0; + visible: 0; + rel1 { relative: 0.1 0.1; to, "badge"; } + rel2 { relative: 0.9 0.9; to, "badge"; } + align: 0.5 0.5; + color: 255 255 255 255; + color2: 0 0 0 35; + color3: 0 0 0 35; + text { + text_class: "tizen"; + font: "TIZEN:style=medium"; + size: 12; + text: "1"; + align: 0.5 0.5; + fit: 1 1; + } + } + description { + state: "badge" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "block_event"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 0; + rel1 { relative: 0.0 0.0; to, "bg"; } + rel2 { relative: 1.0 1.0; to, "bg"; } + color: 0 0 0 0; + } + description { + state: "edit,release" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { + name: "uninstall"; + type: IMAGE; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 40/ITEM_WIDTH 30/ITEM_HEIGHT; to, "bg"; } + rel2 { relative: 40/ITEM_WIDTH 30/ITEM_HEIGHT; to, "bg"; } + image { + normal: "../images/RM06_App tray_Btn_Uninstall.png"; + } + min: 54 54; + fixed: 1 1; + visible: 0; + } + description { + state: "edit,release" 0.0; + inherit: "default" 0.0; + visible: 1; + } + description { + state: "edit,press" 0.0; + inherit: "default" 0.0; + image { + normal: "../images/RM06_App tray_Btn_Uninstall_press.png"; + } + visible: 1; + } + } + part { + name: "txt"; + type: TEXT; + effect: SOFT_SHADOW; + scale: 1; + mouse_events: 1; + description + { + state: "default" 0.0; + rel1 { relative: 0.0 1.0; to_x, "bg"; to_y, "icon_image"; offset: 0 7; } + rel2 { relative: 1.0 1.0; to, "bg"; } + align: 0.5 0.0; + color: 255 255 255 255; + color2: 0 0 0 35; + color3: 0 0 0 35; + text { + text_class: "tizen"; + font: "TIZEN:style=medium"; + size: 16; + align: 0.5 0.1; + } + } + description + { + state: "hide" 0.0; + inherit: "default" 0.0; + visible: 0; + color: 0 0 0 0; + } + } + part { + name: "focus"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + /* Enlarge the starting point of Y for tester's request */ + rel1 { relative: 0.0 -0.1; to, "bg"; } + rel2 { relative: 1.0 1.0; to, "bg"; } + fixed: 1 1; + visible: 1; + } + } + part { + name: "uninstall_event"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: -0.2 -0.2; to, "uninstall"; } + rel2 { relative: 1.1 1.1; to, "uninstall"; } + color: 0 0 0 0; + visible: 0; + } + description { + state: "edit,release" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "uninstall_focus"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + repeat_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to, "uninstall_event"; } + rel2 { relative: 1.0 1.0; to, "uninstall_event"; } + visible: 0; + } + description { + state: "edit,release" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + } + + programs { + program { + name: "item,down"; + signal: "mouse,down,1"; + source: "icon_image_event"; + action: SIGNAL_EMIT "item,down" "menu"; + } + program { + name: "item,up"; + signal: "mouse,up,1"; + source: "icon_image_event"; + action: SIGNAL_EMIT "item,up" "menu"; + } + + // Badge + program { + name: "badge,on"; + signal: "badge,on"; + source: "menu"; + action: STATE_SET "badge" 0.0; + target: "badge"; + target: "badge,txt"; + } + program { + name: "badge,off"; + signal: "badge,off"; + source: "menu"; + action: STATE_SET "default" 0.0; + target: "badge"; + target: "badge,txt"; + } + + program { + name: "uninstall,on"; + signal: "uninstall,on"; + source: "menu"; + action: STATE_SET "edit,release" 0.0; + target: "block_event"; + target: "uninstall"; + target: "uninstall_event"; + target: "uninstall_focus"; + } + program { + name: "uninstall,off"; + signal: "uninstall,off"; + source: "menu"; + action: STATE_SET "default" 0.0; + target: "block_event"; + target: "uninstall"; + target: "uninstall_event"; + target: "uninstall_focus"; + } + program { + name: "uninstall,down"; + signal: "mouse,down,*"; + source: "uninstall_event"; + action: SIGNAL_EMIT "uninstall,down" "menu"; + after: "uninstall,down,after"; + } + program { + name: "uninstall,down,after"; + action: STATE_SET "edit,press" 0.0; + target: "uninstall"; + } + program { + name: "uninstall,up"; + signal: "mouse,up,*"; + source: "uninstall_event"; + action: SIGNAL_EMIT "uninstall,up" "menu"; + after: "uninstall,up,after"; + } + program { + name: "uninstall,up,after"; + action: STATE_SET "edit,release" 0.0; + target: "uninstall"; + } + } + } // group +} // collections diff --git a/data/edje/layout_portrait.edc b/data/edje/layout_portrait.edc new file mode 100644 index 0000000..50c40e2 --- /dev/null +++ b/data/edje/layout_portrait.edc @@ -0,0 +1,90 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +collections { + group { + name: "layout"; + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + color: 0 0 0 0; + visible: 0; + } + } + part { + name: "content"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; to, "bg";} + rel2 { relative: 1.0 1.0; to, "bg";} + visible: 1; + } + } + part { + name: "content,blocker"; + type: RECT; + scale: 1; + mouse_events: 1; + repeat_events: 0; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + color: 0 0 0 0; + visible: 0; + } + description { + state: "block" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + } + + programs { + program { + name: "block,content"; + signal: "block"; + source: "layout"; + action: STATE_SET "block" 0.0; + target: "content,blocker"; + } + program { + name: "unblock,content"; + signal: "unblock"; + source: "layout"; + action: STATE_SET "default" 0.0; + target: "content,blocker"; + } + } + } // group +} // collections + + + +// End of file diff --git a/data/images/CMakeLists.txt b/data/images/CMakeLists.txt new file mode 100644 index 0000000..cb60ac7 --- /dev/null +++ b/data/images/CMakeLists.txt @@ -0,0 +1 @@ +INSTALL(FILES default.png DESTINATION ${IMAGEDIR}) diff --git a/data/images/RM06_App tray_Btn_Uninstall.png b/data/images/RM06_App tray_Btn_Uninstall.png new file mode 100644 index 0000000..7145638 Binary files /dev/null and b/data/images/RM06_App tray_Btn_Uninstall.png differ diff --git a/data/images/RM06_App tray_Btn_Uninstall_press.png b/data/images/RM06_App tray_Btn_Uninstall_press.png new file mode 100644 index 0000000..2ac8311 Binary files /dev/null and b/data/images/RM06_App tray_Btn_Uninstall_press.png differ diff --git a/data/images/RM06_App_tray_edit_btn.png b/data/images/RM06_App_tray_edit_btn.png new file mode 100644 index 0000000..0674e9c Binary files /dev/null and b/data/images/RM06_App_tray_edit_btn.png differ diff --git a/data/images/RM06_App_tray_edit_btn_press.png b/data/images/RM06_App_tray_edit_btn_press.png new file mode 100644 index 0000000..eefc4f9 Binary files /dev/null and b/data/images/RM06_App_tray_edit_btn_press.png differ diff --git a/data/images/RM06_App_tray_setting.png b/data/images/RM06_App_tray_setting.png new file mode 100644 index 0000000..1b357fc Binary files /dev/null and b/data/images/RM06_App_tray_setting.png differ diff --git a/data/images/RM06_App_tray_setting_press.png b/data/images/RM06_App_tray_setting_press.png new file mode 100644 index 0000000..3858945 Binary files /dev/null and b/data/images/RM06_App_tray_setting_press.png differ diff --git a/data/images/btn_edit_nor.9.png b/data/images/btn_edit_nor.9.png new file mode 100644 index 0000000..1cb7440 Binary files /dev/null and b/data/images/btn_edit_nor.9.png differ diff --git a/data/images/btn_edit_press.9.png b/data/images/btn_edit_press.9.png new file mode 100644 index 0000000..8619ff3 Binary files /dev/null and b/data/images/btn_edit_press.9.png differ diff --git a/data/images/default.png b/data/images/default.png new file mode 100644 index 0000000..983c883 Binary files /dev/null and b/data/images/default.png differ diff --git a/data/images/icon_btn_done_nor.png b/data/images/icon_btn_done_nor.png new file mode 100644 index 0000000..a28bd95 Binary files /dev/null and b/data/images/icon_btn_done_nor.png differ diff --git a/data/images/icon_btn_done_press.png b/data/images/icon_btn_done_press.png new file mode 100644 index 0000000..cc9256f Binary files /dev/null and b/data/images/icon_btn_done_press.png differ diff --git a/data/images/icon_btn_edit_nor.png b/data/images/icon_btn_edit_nor.png new file mode 100644 index 0000000..f79ea92 Binary files /dev/null and b/data/images/icon_btn_edit_nor.png differ diff --git a/data/images/icon_btn_edit_press.png b/data/images/icon_btn_edit_press.png new file mode 100644 index 0000000..aaaa7fa Binary files /dev/null and b/data/images/icon_btn_edit_press.png differ diff --git a/data/images/menu_badge_01.png b/data/images/menu_badge_01.png new file mode 100644 index 0000000..f297f72 Binary files /dev/null and b/data/images/menu_badge_01.png differ diff --git a/data/images/page indicator.png b/data/images/page indicator.png new file mode 100644 index 0000000..28081e7 Binary files /dev/null and b/data/images/page indicator.png differ diff --git a/data/images/page indicator_focus.png b/data/images/page indicator_focus.png new file mode 100644 index 0000000..42beee6 Binary files /dev/null and b/data/images/page indicator_focus.png differ diff --git a/data/menu-screen-env.sh b/data/menu-screen-env.sh new file mode 100755 index 0000000..284a0ba --- /dev/null +++ b/data/menu-screen-env.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +export LAUNCHER_ENGINE=gl +export LAUNCHER_FPS=6000 + +# End of a file diff --git a/data/org.tizen.menu-screen.desktop.in b/data/org.tizen.menu-screen.desktop.in new file mode 100644 index 0000000..a762e53 --- /dev/null +++ b/data/org.tizen.menu-screen.desktop.in @@ -0,0 +1,7 @@ +Name=Simple Menu Screen +Type=Application +Exec=@EXEC_PREFIX@/@PROJECT_NAME@ +Icon=@PACKAGE_NAME@.png +NoDisplay=True +X-Tizen-TaskManage=False +X-Tizen-Removable=False diff --git a/data/org.tizen.menu-screen.xml.in b/data/org.tizen.menu-screen.xml.in new file mode 100755 index 0000000..a814e39 --- /dev/null +++ b/data/org.tizen.menu-screen.xml.in @@ -0,0 +1,11 @@ + + + + Jin Yoon + Youngjoo Park + Simple Menu-screen Application + + + + + diff --git a/data/po/CMakeLists.txt b/data/po/CMakeLists.txt new file mode 100644 index 0000000..794280d --- /dev/null +++ b/data/po/CMakeLists.txt @@ -0,0 +1,79 @@ +# for i18n + +SET(POFILES + ar.po + az.po + bg.po + ca.po + cs.po + da.po + de_DE.po + el_GR.po + en.po + en_PH.po + en_US.po + es_ES.po + es_MX.po + et.po + eu.po + fa.po + fi.po + fr_CA.po + fr_FR.po + ga.po + gl.po + hi.po + hr.po + hu.po + hy.po + is.po + it_IT.po + ja_JP.po + ka.po + kk.po + ko_KR.po + lt.po + lv.po + mk.po + nb.po + nl_NL.po + pl.po + pt_BR.po + pt_PT.po + ro.po + ru_RU.po + sk.po + sl.po + sr.po + sv.po + th.po + tr_TR.po + uk.po + ur.po + uz.po + zh_CN.po + zh_HK.po + zh_SG.po + zh_TW.po +) + +SET(MSGFMT "/usr/bin/msgfmt") + +MESSAGE(STATUS "po files ---") +FOREACH(pofile ${POFILES}) + SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile}) + MESSAGE(STATUS " ${pofile}") + GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE) + GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE) + SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo) + ADD_CUSTOM_COMMAND( + OUTPUT ${moFile} + COMMAND ${MSGFMT} -o ${moFile} ${absPofile} + DEPENDS ${absPofile} + ) + INSTALL(FILES ${moFile} + DESTINATION ${LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo) + SET(moFiles ${moFiles} ${moFile}) +ENDFOREACH(pofile) + +ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles}) diff --git a/data/po/ar.po b/data/po/ar.po new file mode 100644 index 0000000..31821ad --- /dev/null +++ b/data/po/ar.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "تم" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "هل تريد إلغاء تثبيت %s؟" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "إلغاء التثبيت" \ No newline at end of file diff --git a/data/po/az.po b/data/po/az.po new file mode 100644 index 0000000..991ce16 --- /dev/null +++ b/data/po/az.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Tamam" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s silinsin?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Quraşdırılma ləğv edilsin" \ No newline at end of file diff --git a/data/po/bg.po b/data/po/bg.po new file mode 100644 index 0000000..20cb7d5 --- /dev/null +++ b/data/po/bg.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Готово" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Деинсталиране на %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Деинсталиране" \ No newline at end of file diff --git a/data/po/ca.po b/data/po/ca.po new file mode 100644 index 0000000..a4bc2cb --- /dev/null +++ b/data/po/ca.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Realit" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Desinstal·lar %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Desinstal·lar" \ No newline at end of file diff --git a/data/po/cs.po b/data/po/cs.po new file mode 100644 index 0000000..71d1942 --- /dev/null +++ b/data/po/cs.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Hot." + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Odinstalovat %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Odinstalovat" \ No newline at end of file diff --git a/data/po/da.po b/data/po/da.po new file mode 100644 index 0000000..d99306a --- /dev/null +++ b/data/po/da.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Udført" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Afinstallér %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Afinstallér" \ No newline at end of file diff --git a/data/po/de_DE.po b/data/po/de_DE.po new file mode 100644 index 0000000..f5f4d32 --- /dev/null +++ b/data/po/de_DE.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Fertig" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s deinstallieren?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Deinstallieren" \ No newline at end of file diff --git a/data/po/el_GR.po b/data/po/el_GR.po new file mode 100644 index 0000000..be489f7 --- /dev/null +++ b/data/po/el_GR.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Τέλος" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Κατάργηση της εγκατάστασης του %s;" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Κατάργηση εγκατάστασης" \ No newline at end of file diff --git a/data/po/en.po b/data/po/en.po new file mode 100644 index 0000000..9536899 --- /dev/null +++ b/data/po/en.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Done" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Uninstall %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Uninstall" \ No newline at end of file diff --git a/data/po/en_PH.po b/data/po/en_PH.po new file mode 100644 index 0000000..9536899 --- /dev/null +++ b/data/po/en_PH.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Done" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Uninstall %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Uninstall" \ No newline at end of file diff --git a/data/po/en_US.po b/data/po/en_US.po new file mode 100644 index 0000000..9536899 --- /dev/null +++ b/data/po/en_US.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Done" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Uninstall %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Uninstall" \ No newline at end of file diff --git a/data/po/es_ES.po b/data/po/es_ES.po new file mode 100644 index 0000000..02cc757 --- /dev/null +++ b/data/po/es_ES.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Finalizado" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "¿Desinstalar %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Desinstalar" \ No newline at end of file diff --git a/data/po/es_MX.po b/data/po/es_MX.po new file mode 100644 index 0000000..279a111 --- /dev/null +++ b/data/po/es_MX.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Realiz." + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "¿Desinstalar %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Desinstalar" \ No newline at end of file diff --git a/data/po/et.po b/data/po/et.po new file mode 100644 index 0000000..be64f0c --- /dev/null +++ b/data/po/et.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Valmis" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Kas desinstallida %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Deinstalli" \ No newline at end of file diff --git a/data/po/eu.po b/data/po/eu.po new file mode 100644 index 0000000..13b5795 --- /dev/null +++ b/data/po/eu.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Egina" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Desinstalatu %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Desinstalatu" \ No newline at end of file diff --git a/data/po/fa.po b/data/po/fa.po new file mode 100755 index 0000000..e77e4a2 --- /dev/null +++ b/data/po/fa.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "انجام شد" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "لغو نصب %s؟" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "لغو نصب" diff --git a/data/po/fi.po b/data/po/fi.po new file mode 100644 index 0000000..0802515 --- /dev/null +++ b/data/po/fi.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Valmis" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Poistetaanko kohteen %s asennus?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Poista asennus" \ No newline at end of file diff --git a/data/po/fr_CA.po b/data/po/fr_CA.po new file mode 100644 index 0000000..7977fd8 --- /dev/null +++ b/data/po/fr_CA.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "OK" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Désinstaller %s ?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Désinstaller" \ No newline at end of file diff --git a/data/po/fr_FR.po b/data/po/fr_FR.po new file mode 100644 index 0000000..7977fd8 --- /dev/null +++ b/data/po/fr_FR.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "OK" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Désinstaller %s ?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Désinstaller" \ No newline at end of file diff --git a/data/po/ga.po b/data/po/ga.po new file mode 100644 index 0000000..36117b4 --- /dev/null +++ b/data/po/ga.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Déanta" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Díshuiteáil %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Díshuiteáil" \ No newline at end of file diff --git a/data/po/gl.po b/data/po/gl.po new file mode 100644 index 0000000..5c99a7f --- /dev/null +++ b/data/po/gl.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Feito" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Desexas desinstalar %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Desinstalar" \ No newline at end of file diff --git a/data/po/hi.po b/data/po/hi.po new file mode 100644 index 0000000..78e0813 --- /dev/null +++ b/data/po/hi.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "पूरा हुआ" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s की स्थापना रद्द करें?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "अस्थापित करें" \ No newline at end of file diff --git a/data/po/hr.po b/data/po/hr.po new file mode 100644 index 0000000..8a4cf42 --- /dev/null +++ b/data/po/hr.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Kraj" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Deinstalirati %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Deinstaliraj" \ No newline at end of file diff --git a/data/po/hu.po b/data/po/hu.po new file mode 100644 index 0000000..6140991 --- /dev/null +++ b/data/po/hu.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Kész" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Eltávolítja a(z) %s animált emotikont?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Eltávolítás" \ No newline at end of file diff --git a/data/po/hy.po b/data/po/hy.po new file mode 100644 index 0000000..ec74b44 --- /dev/null +++ b/data/po/hy.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Արված է" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Ապատեղադրե՞լ %s-ը:" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Ապատեղադրել" \ No newline at end of file diff --git a/data/po/is.po b/data/po/is.po new file mode 100644 index 0000000..0d5ee01 --- /dev/null +++ b/data/po/is.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Lokið" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Fjarlægja %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Fjarlægja" \ No newline at end of file diff --git a/data/po/it_IT.po b/data/po/it_IT.po new file mode 100644 index 0000000..81b02da --- /dev/null +++ b/data/po/it_IT.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Fatto" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Disinstallare %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Disinstalla" \ No newline at end of file diff --git a/data/po/ja_JP.po b/data/po/ja_JP.po new file mode 100644 index 0000000..bacd41c --- /dev/null +++ b/data/po/ja_JP.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "完了" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%sをアンインストールしますか?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "アンインストール" \ No newline at end of file diff --git a/data/po/ka.po b/data/po/ka.po new file mode 100644 index 0000000..31d2726 --- /dev/null +++ b/data/po/ka.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "შესრულდა" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "ამოინსტალირდეს %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "ინსტალაციის გაუქმება" \ No newline at end of file diff --git a/data/po/kk.po b/data/po/kk.po new file mode 100644 index 0000000..c1d9813 --- /dev/null +++ b/data/po/kk.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Дайын" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s жою керек пе?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Жою" \ No newline at end of file diff --git a/data/po/ko_KR.po b/data/po/ko_KR.po new file mode 100644 index 0000000..606c7c2 --- /dev/null +++ b/data/po/ko_KR.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "완료" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s을(를) 삭제할까요?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "삭제" \ No newline at end of file diff --git a/data/po/lt.po b/data/po/lt.po new file mode 100644 index 0000000..dd44366 --- /dev/null +++ b/data/po/lt.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Atlikta" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Pašalinti „%s“?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Pašalinti" \ No newline at end of file diff --git a/data/po/lv.po b/data/po/lv.po new file mode 100644 index 0000000..8160d6c --- /dev/null +++ b/data/po/lv.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Gatavs" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Vai atinstalēt %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Atinstalēt" \ No newline at end of file diff --git a/data/po/mk.po b/data/po/mk.po new file mode 100644 index 0000000..eb6aca3 --- /dev/null +++ b/data/po/mk.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Готово" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Да се деинсталира %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Деинсталирај" \ No newline at end of file diff --git a/data/po/nb.po b/data/po/nb.po new file mode 100644 index 0000000..e6961ca --- /dev/null +++ b/data/po/nb.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Utført" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Avinstallere %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Avinstaller" \ No newline at end of file diff --git a/data/po/nl_NL.po b/data/po/nl_NL.po new file mode 100644 index 0000000..f29bdb7 --- /dev/null +++ b/data/po/nl_NL.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Gereed" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s verwijderen?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Verwijderen" \ No newline at end of file diff --git a/data/po/pl.po b/data/po/pl.po new file mode 100644 index 0000000..c971254 --- /dev/null +++ b/data/po/pl.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Gotowe" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Odinstalować %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Odinstaluj" \ No newline at end of file diff --git a/data/po/pt_BR.po b/data/po/pt_BR.po new file mode 100644 index 0000000..28b996a --- /dev/null +++ b/data/po/pt_BR.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Concluído" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Desinstalar %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Desinstalar" \ No newline at end of file diff --git a/data/po/pt_PT.po b/data/po/pt_PT.po new file mode 100644 index 0000000..8140980 --- /dev/null +++ b/data/po/pt_PT.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Concluir" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Desinstalar %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Desinstalar" \ No newline at end of file diff --git a/data/po/ro.po b/data/po/ro.po new file mode 100644 index 0000000..a93f226 --- /dev/null +++ b/data/po/ro.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Efectuat" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Dezinstalaţi %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Dezinstalare" \ No newline at end of file diff --git a/data/po/ru_RU.po b/data/po/ru_RU.po new file mode 100644 index 0000000..83768b3 --- /dev/null +++ b/data/po/ru_RU.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Готово" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Удалить %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Удалить" \ No newline at end of file diff --git a/data/po/sk.po b/data/po/sk.po new file mode 100644 index 0000000..bd962da --- /dev/null +++ b/data/po/sk.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Hotovo" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Odinštalovať program %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Odinštalovať" \ No newline at end of file diff --git a/data/po/sl.po b/data/po/sl.po new file mode 100644 index 0000000..4b5555e --- /dev/null +++ b/data/po/sl.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Končano" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Želite odstraniti %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Odstrani" \ No newline at end of file diff --git a/data/po/sr.po b/data/po/sr.po new file mode 100644 index 0000000..a9fb721 --- /dev/null +++ b/data/po/sr.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Gotovo" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Deinstalirati %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Deinstaliraj" \ No newline at end of file diff --git a/data/po/sv.po b/data/po/sv.po new file mode 100644 index 0000000..330726d --- /dev/null +++ b/data/po/sv.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Klar" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Avinstallera %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Avinstallera" \ No newline at end of file diff --git a/data/po/th.po b/data/po/th.po new file mode 100755 index 0000000..57e613c --- /dev/null +++ b/data/po/th.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "เรียบร้อย" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "ถอนการติดตั้ง %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "ลบการติดตั้ง" diff --git a/data/po/tr_TR.po b/data/po/tr_TR.po new file mode 100644 index 0000000..32ce85c --- /dev/null +++ b/data/po/tr_TR.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Tamam" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s kaldırılsın mı?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Kaldır" \ No newline at end of file diff --git a/data/po/uk.po b/data/po/uk.po new file mode 100644 index 0000000..d50f5c5 --- /dev/null +++ b/data/po/uk.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Готово" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "Видалити %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Видалити" \ No newline at end of file diff --git a/data/po/ur.po b/data/po/ur.po new file mode 100755 index 0000000..08ede49 --- /dev/null +++ b/data/po/ur.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "مکمل" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s نا تنصیب کریں؟" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "نا تنصیب کریں" diff --git a/data/po/uz.po b/data/po/uz.po new file mode 100644 index 0000000..170b97a --- /dev/null +++ b/data/po/uz.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "Qilindi" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "%s olib tashlansinmi?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "Olib tashlash" \ No newline at end of file diff --git a/data/po/zh_CN.po b/data/po/zh_CN.po new file mode 100644 index 0000000..781b4f0 --- /dev/null +++ b/data/po/zh_CN.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "完成" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "是否卸载 %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "卸载" \ No newline at end of file diff --git a/data/po/zh_HK.po b/data/po/zh_HK.po new file mode 100644 index 0000000..708e6ef --- /dev/null +++ b/data/po/zh_HK.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "完成" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "解除安裝 %s 嗎?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "解除安裝" \ No newline at end of file diff --git a/data/po/zh_SG.po b/data/po/zh_SG.po new file mode 100644 index 0000000..781b4f0 --- /dev/null +++ b/data/po/zh_SG.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "完成" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "是否卸载 %s?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "卸载" \ No newline at end of file diff --git a/data/po/zh_TW.po b/data/po/zh_TW.po new file mode 100644 index 0000000..708e6ef --- /dev/null +++ b/data/po/zh_TW.po @@ -0,0 +1,8 @@ +msgid "IDS_HS_BUTTON_DONE" +msgstr "完成" + +msgid "IDS_AT_POP_UNINSTALL_PS_Q" +msgstr "解除安裝 %s 嗎?" + +msgid "IDS_AT_BODY_UNINSTALL" +msgstr "解除安裝" \ No newline at end of file diff --git a/include/all_apps/db.h b/include/all_apps/db.h new file mode 100644 index 0000000..60aeeb6 --- /dev/null +++ b/include/all_apps/db.h @@ -0,0 +1,47 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_ALL_APPS_DB_H__ +#define __MENU_SCREEN_ALL_APPS_DB_H__ + +#include "Elementary.h" +#include "util.h" + +typedef struct _db_info { + long long rowid; + int type; + + char *appid; + char *name; + char *content_info; + char *icon; +} db_info; + +extern menu_screen_error_e all_apps_db_init(void); +extern void all_apps_db_fini(void); + +extern Eina_List *all_apps_db_retrieve_all_info(void); +extern void all_apps_db_unretrieve_info(db_info *info); +extern void all_apps_db_unretrieve_all_info(Eina_List *list); + +extern long long all_apps_db_insert_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon); +extern menu_screen_error_e all_apps_db_delete_shortcut(long long rowid); +extern int all_apps_db_count_shortcut(const char *appid, const char *name); + +#endif // __MENU_SCREEN_ALL_APPS_DB_H__ +// End of file diff --git a/include/all_apps/layout.h b/include/all_apps/layout.h new file mode 100644 index 0000000..73cd023 --- /dev/null +++ b/include/all_apps/layout.h @@ -0,0 +1,35 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef _MENU_SCREEN_CONTROLBAR_ALL_APPS_H_ +#define _MENU_SCREEN_CONTROLBAR_ALL_APPS_H_ + +#include + +#define PAGE_MAX_APP 16 + +extern bool all_apps_layout_is_edited(Evas_Object *all_apps); +extern void all_apps_layout_edit(Evas_Object *all_apps); +extern void all_apps_layout_unedit(Evas_Object *all_apps); + +extern Evas_Object *all_apps_layout_create(Evas_Object *controlbar, int rotate); +extern void all_apps_layout_destroy(Evas_Object *all_apps); + +#endif // _MENU_SCREEN_CONTROLBAR_ALL_APPS_H_ + +// End of a file diff --git a/include/all_apps/list.h b/include/all_apps/list.h new file mode 100644 index 0000000..fe93e4f --- /dev/null +++ b/include/all_apps/list.h @@ -0,0 +1,27 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_LIST_ALL_APPS_H__ +#define __MENU_SCREEN_LIST_ALL_APPS_H__ + +extern app_list *all_apps_list_create(void); +extern void all_apps_list_destroy(app_list *list); + +#endif //__MENU_SCREEN_LIST_ALL_APPS_H__ + +// End of a file diff --git a/include/all_apps/shortcut.h b/include/all_apps/shortcut.h new file mode 100644 index 0000000..0d536bf --- /dev/null +++ b/include/all_apps/shortcut.h @@ -0,0 +1,35 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef _MENU_SCREEN_ALL_APPS_SHORTCUT_H_ +#define _MENU_SCREEN_ALL_APPS_SHORTCUT_H_ + +#include +#include + +extern Evas_Object *all_apps_shortcut_add(Evas_Object *scroller, long long rowid, const char *pkgname, const char *exec, const char *name, const char *icon, int type); +extern void all_apps_shortcut_remove(Evas_Object *item); + +extern menu_screen_error_e all_apps_shortcut_add_all(Evas_Object *scroller); + +extern bool all_apps_shortcut_init(Evas_Object *all_apps); +extern void all_apps_shortcut_fini(void); + +#endif // _MENU_SCREEN_ALL_APPS_SHORTCUT_H_ + +// End of a file diff --git a/include/conf.h b/include/conf.h new file mode 100644 index 0000000..50d40f8 --- /dev/null +++ b/include/conf.h @@ -0,0 +1,37 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef _MENU_SCREEN_CONF_H_ +#define _MENU_SCREEN_CONF_H_ + +#define MAX_PAGE_NO 9 + +#define BASE_HEIGHT 1280.0f +#define BASE_WIDTH 720.0f + +#define PAGE_PORTRAIT_HEIGHT 1030.0f +#define INDEX_HEIGHT 70 + +#define ITEM_WIDTH 180.0 +#define ITEM_WIDTH_PROP (ITEM_WIDTH/BASE_WIDTH) +#define ITEM_HEIGHT 198.0 +#define ITEM_HEIGHT_PROP (ITEM_HEIGHT/BASE_HEIGHT) + +#endif // _MENU_SCREEN_CONF_H_ + +// End of a file diff --git a/include/db.h b/include/db.h new file mode 100644 index 0000000..dd962f6 --- /dev/null +++ b/include/db.h @@ -0,0 +1,47 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MENU_SCREEN_DB_H__ +#define __MENU_SCREEN_DB_H__ + +#include + +#include "util.h" + +typedef struct stmt stmt_h; + +extern stmt_h *db_prepare(const char *query); +extern menu_screen_error_e db_bind_bool(stmt_h *handle, int idx, bool value); +extern menu_screen_error_e db_bind_int(stmt_h *handle, int idx, int value); +extern menu_screen_error_e db_bind_str(stmt_h *handle, int idx, const char *str); +extern menu_screen_error_e db_next(stmt_h *handle); +extern bool db_get_bool(stmt_h *handle, int index); +extern int db_get_int(stmt_h *handle, int index); +extern long long db_get_long_long(stmt_h *handle, int index); +extern const char *db_get_str(stmt_h *handle, int index); +extern menu_screen_error_e db_reset(stmt_h *handle); +extern menu_screen_error_e db_finalize(stmt_h *handle); +extern menu_screen_error_e db_exec(const char *query); +extern long long db_last_insert_rowid(void); + +extern menu_screen_error_e db_open(const char *db_file); +extern void db_close(void); + +extern menu_screen_error_e db_begin_transaction(void); +extern menu_screen_error_e db_end_transaction(bool success); + +#endif // __MENU_SCREEN_DB_H__ +// End of file diff --git a/include/index.h b/include/index.h new file mode 100644 index 0000000..fcc2454 --- /dev/null +++ b/include/index.h @@ -0,0 +1,35 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_PAGE_CONTROL_H__ +#define __MENU_SCREEN_PAGE_CONTROL_H__ + +#include + +extern void index_bring_in(Evas_Object *index, int idx); + +extern Evas_Object *index_create(Evas_Object *layout, unsigned int count, unsigned int current_idx); +extern Evas_Object *index_update(Evas_Object *layout, Evas_Object *index, unsigned int count); +extern void index_destroy(Evas_Object *index); + +extern void index_show(Evas_Object *index); +extern void index_hide(Evas_Object *index); + +#endif //__MENU_SCREEN_PAGE_CONTROL_H__ + +// End of the file diff --git a/include/item.h b/include/item.h new file mode 100644 index 0000000..ab7fe21 --- /dev/null +++ b/include/item.h @@ -0,0 +1,78 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_ITEM_H__ +#define __MENU_SCREEN_ITEM_H__ + +#include + +#include "list.h" +#include "util.h" + +extern char *item_get_icon(Evas_Object *item); +extern void item_set_icon(Evas_Object *item, char *icon, int sync); + +extern char *item_get_name(Evas_Object *item); +extern void item_set_name(Evas_Object *item, char *name, int sync); + +extern char *item_get_package(Evas_Object *item); +extern void item_set_package(Evas_Object *item, char *package, int sync); + +extern int item_get_removable(Evas_Object *item); +extern void item_set_removable(Evas_Object *item, int removable, int sync); + +extern Evas_Object *item_get_page(Evas_Object *edje); +extern void item_set_page(Evas_Object *edje, Evas_Object *page, int sync); + +extern char *item_get_desktop(Evas_Object *item); +extern void item_set_desktop(Evas_Object *item, char *name, int sync); + +extern int item_get_type(Evas_Object *item); +extern void item_set_type(Evas_Object *edje, int type, int sync); + +extern void item_enable_delete(Evas_Object *obj); +extern void item_disable_delete(Evas_Object *item); + +extern void item_show_badge(Evas_Object *obj, int value); +extern void item_hide_badge(Evas_Object *obj); +extern int item_is_enabled_badge(Evas_Object *obj); + +extern void item_edit(Evas_Object *item); +extern void item_unedit(Evas_Object *item); + +extern Evas_Object *item_create(Evas_Object *scroller, app_info_t* ai); +extern void item_update(Evas_Object *item, app_info_t *ai); +extern void item_destroy(Evas_Object *obj); + +extern void item_launch(Evas_Object *obj); + +extern void item_enable_progress(Evas_Object *obj); +extern int item_is_enabled_progress(Evas_Object *obj); +extern void item_update_progress(Evas_Object *obj, int value); +extern void item_disable_progress(Evas_Object *obj); + +extern menu_screen_error_e item_is_edje_icon(const char *icon); +extern int item_get_position(Evas_Object *item); + +extern void item_mark_dirty(Evas_Object *item); +extern void item_unmark_dirty(Evas_Object *item); +extern int item_is_dirty(Evas_Object *item); + +#endif //__MENU_SCREEN_ITEM_H__ + +// End of a file diff --git a/include/item_badge.h b/include/item_badge.h new file mode 100644 index 0000000..068d03b --- /dev/null +++ b/include/item_badge.h @@ -0,0 +1,35 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_BADGE_H__ +#define __MENU_SCREEN_BADGE_H__ + +#include + +#include "util.h" + +extern menu_screen_error_e item_badge_register(Evas_Object *item); +extern void item_badge_unregister(Evas_Object *item); +extern bool item_badge_is_registered(Evas_Object *item); +extern int item_badge_count(char *package); + +extern void item_badge_register_changed_cb(Evas_Object *scroller); +extern void item_badge_unregister_changed_cb(void); + +#endif +// End of a file diff --git a/include/item_event.h b/include/item_event.h new file mode 100644 index 0000000..547103a --- /dev/null +++ b/include/item_event.h @@ -0,0 +1,29 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_ITEM_EVENT_H__ +#define __MENU_SCREEN_ITEM_EVENT_H__ + +#include + +extern void item_event_register(Evas_Object *obj); +extern void item_event_unregister(Evas_Object *obj); + +#endif //__MENU_SCREEN_ITEM_EVENT_H__ + +// End of a file diff --git a/include/key.h b/include/key.h new file mode 100644 index 0000000..def465f --- /dev/null +++ b/include/key.h @@ -0,0 +1,29 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MENU_SCREEN_INPUT_KEY_H__ +#define __MENU_SCREEN_INPUT_KEY_H__ + +#include "util.h" + +HAPI void key_register(void); +HAPI void key_unregister(void); +HAPI void key_grab_home(void); +HAPI void key_ungrab_home(void); + +#endif //__MENU_SCREEN_INPUT_KEY_H__ + +// End of a file diff --git a/include/layout.h b/include/layout.h new file mode 100644 index 0000000..d24aad0 --- /dev/null +++ b/include/layout.h @@ -0,0 +1,36 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_LAYOUT_H__ +#define __MENU_SCREEN_LAYOUT_H__ + +#include +#include "util.h" + +extern Evas_Object *layout_create(Evas_Object *conformant, const char *file, const char *group, int rotate); +extern void layout_destroy(Evas_Object *layout); + +extern void layout_enable_block(Evas_Object *layout); +extern void layout_disable_block(Evas_Object *layout); + +extern Evas_Object* layout_load_edj(Evas_Object *parent, const char *edjname, const char *grpname); +extern void layout_unload_edj(Evas_Object *layout); + +#endif //__MENU_SCREEN_LAYOUT_H__ + +// End of a file diff --git a/include/list.h b/include/list.h new file mode 100644 index 0000000..e39d285 --- /dev/null +++ b/include/list.h @@ -0,0 +1,70 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_LIST_H__ +#define __MENU_SCREEN_LIST_H__ + +#include +#include + +#include "util.h" + +typedef struct +{ + char *package; + char *exec; + char *name; + char *icon; + char *desktop; + bool nodisplay; + bool enabled; + bool x_slp_removable; + bool x_slp_taskmanage; + pid_t pid; + Evas_Object *image; +} app_info_t; + +typedef struct _app_list { + Eina_List *list; + unsigned int cur_idx; +} app_list; + +typedef struct _app_list_item { + char *package; + pid_t pid; + time_t launch_time; + long long installed_time; + void *data; +} app_list_item; + +extern menu_screen_error_e list_count(app_list *list, int *count); +extern menu_screen_error_e list_first(app_list *list); +extern menu_screen_error_e list_next(app_list *list); +extern menu_screen_error_e list_is_ended(app_list *list, bool *flag); + +extern menu_screen_error_e list_get_item(app_list *list, app_list_item **item); +extern menu_screen_error_e list_get_values(const char *package, app_info_t *ai); +extern void list_free_values(app_info_t *ai); + +extern menu_screen_error_e list_append_item(app_list *list, app_list_item *item); +extern menu_screen_error_e list_remove_item(app_list *list, app_list_item *item); +extern menu_screen_error_e list_sort(app_list *list, int (*_sort_cb)(const void *d1, const void *d2)); + +#endif //__MENU_SCREEN_LIST_H__ + +// End of a file diff --git a/include/mapbuf.h b/include/mapbuf.h new file mode 100644 index 0000000..d42f1f5 --- /dev/null +++ b/include/mapbuf.h @@ -0,0 +1,40 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_MAPBUF_H__ +#define __MENU_SCREEN_MAPBUF_H__ + +#include + +#include "util.h" + +extern menu_screen_error_e mapbuf_enable(Evas_Object *obj, int force); +extern int mapbuf_disable(Evas_Object *obj, int force); + +extern Evas_Object *mapbuf_bind(Evas_Object *box, Evas_Object *page); +extern Evas_Object *mapbuf_unbind(Evas_Object *obj); + +extern Evas_Object *mapbuf_get_mapbuf(Evas_Object *obj); +extern Evas_Object *mapbuf_get_page(Evas_Object *obj); + +extern int mapbuf_is_enabled(Evas_Object *obj); + + +#endif //__MENU_SCREEN_MAPBUF_H__ + +// End of a file diff --git a/include/menu_screen.h b/include/menu_screen.h new file mode 100644 index 0000000..03848f3 --- /dev/null +++ b/include/menu_screen.h @@ -0,0 +1,38 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_H__ +#define __MENU_SCREEN_H__ + +#include +#include +#include + +extern int menu_screen_get_root_width(void); +extern int menu_screen_get_root_height(void); +extern Evas *menu_screen_get_evas(void); +extern Evas_Object *menu_screen_get_win(void); +extern Elm_Theme *menu_screen_get_theme(void); +extern bool menu_screen_get_done(void); +extern void menu_screen_set_done(bool is_done); +extern int menu_screen_get_state(void); +extern int menu_screen_is_tts(void); + +#endif //__MENU_SCREEN_H__ + +// End of a file diff --git a/include/mouse.h b/include/mouse.h new file mode 100644 index 0000000..50b3442 --- /dev/null +++ b/include/mouse.h @@ -0,0 +1,33 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_EVENT_H__ +#define __MENU_SCREEN_EVENT_H__ + +#include + +#include "util.h" + +extern bool mouse_is_scrolling(void); + +extern void mouse_register(void); +extern void mouse_unregister(void); + +#endif //__MENU_SCREEN_EVENT_H__ + +// End of a file diff --git a/include/page.h b/include/page.h new file mode 100644 index 0000000..990d860 --- /dev/null +++ b/include/page.h @@ -0,0 +1,50 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_PAGE_H__ +#define __MENU_SCREEN_PAGE_H__ + +#include +#include "util.h" +#include "list.h" + +extern void page_mark_dirty(Evas_Object *page); +extern void page_clean_dirty(Evas_Object *page); +extern void page_unmark_dirty(Evas_Object *page); +extern int page_is_dirty(Evas_Object *page); + +extern Evas_Object *page_get_item_at(Evas_Object *menu, unsigned int idx); + +extern menu_screen_error_e page_unpack_item(Evas_Object *page, Evas_Object *item); +extern Evas_Object *page_unpack_item_at(Evas_Object *page, int idx); + +extern void page_pack_item(Evas_Object *menu, int idx, Evas_Object *item); +extern void page_set_item(Evas_Object *page, int idx, Evas_Object *item); + +extern unsigned int page_count_item(Evas_Object *page); + +extern Evas_Object *page_create(Evas_Object *scroller, int idx, int rotate); +extern void page_destroy(Evas_Object *scroller, Evas_Object *page); + +extern int page_find_empty_near(Evas_Object *menu_edje, int pivot); +extern int page_find_first_empty(Evas_Object *page, int pivot); +extern void page_trim_items(Evas_Object *page); + +#endif //__MENU_SCREEN_PAGE_H__ +// End of a file + diff --git a/include/page_scroller.h b/include/page_scroller.h new file mode 100644 index 0000000..282a5f2 --- /dev/null +++ b/include/page_scroller.h @@ -0,0 +1,58 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_PAGE_SCROLLER_H__ +#define __MENU_SCREEN_PAGE_SCROLLER_H__ + +#include +#include +#include +#include "list.h" + +typedef enum { + PAGE_SCROLLER_SORT_BY_DEFAULT = 0, + PAGE_SCROLLER_SORT_BY_PACKAGE, + PAGE_SCROLLER_SORT_BY_NAME, + PAGE_SCROLLER_SORT_MAX, +} page_scroller_sort_type_e; + +extern Evas_Object *page_scroller_create(Evas_Object *tab, Evas_Object *index, page_scroller_sort_type_e sort_type, int rotate); +extern void page_scroller_destroy(Evas_Object *scroller); +extern void page_scroller_clean(Evas_Object *scroller); + +extern Evas_Object *page_scroller_get_page_at(Evas_Object *scroller, unsigned int idx); +extern unsigned int page_scroller_count_page(Evas_Object *scroller); +extern int page_scroller_get_page_no(Evas_Object* scroller, Evas_Object *page); + +extern Evas_Object *page_scroller_push_item(Evas_Object *scroller, app_info_t *ai); +extern int page_scroller_get_current_page_no(Evas_Object *scroller); +extern Evas_Object *page_scroller_find_item_by_package(Evas_Object *scroller, const char *package, int *page_no); +extern void page_scroller_trim_items(Evas_Object *scroller); +extern void page_scroller_bring_in(Evas_Object *scroller, int idx); +extern void page_scroller_show_region(Evas_Object *scroller, int idx); + +extern void page_scroller_edit(Evas_Object *scroller); +extern void page_scroller_unedit(Evas_Object *scroller); +extern bool page_scroller_is_edited(Evas_Object *scroller); + +extern void page_scroller_focus(Evas_Object *scroller); +extern void page_scroller_focus_into_vector(Evas_Object *scroller, int vector); + +#endif //__MENU_SCREEN_PAGE_SCROLLER_H__ + +// End of a file diff --git a/include/pkgmgr.h b/include/pkgmgr.h new file mode 100644 index 0000000..42b29c1 --- /dev/null +++ b/include/pkgmgr.h @@ -0,0 +1,66 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_PKGMGR_H__ +#define __MENU_SCREEN_PKGMGR_H__ + +#include + +#include "list.h" +#include "util.h" + + + +enum package_install_status { + UNKNOWN = 0x00, + DOWNLOAD_BEGIN, + DOWNLOADING, + DOWNLOAD_END, + INSTALL_BEGIN, + INSTALLING, + INSTALL_END, + UNINSTALL_BEGIN, + UNINSTALLING, + UNINSTALL_END, + UPDATE_BEGIN, + UPDATING, + UPDATE_END, + MAX_STATUS, +}; + + + +struct package_info { + enum package_install_status status; + app_info_t ai; + Evas_Object *item; + Evas_Object *page; + Eina_Bool desktop_file_found; + int error_count; +}; + + + +extern menu_screen_error_e pkgmgr_init(Evas_Object *scroller); +extern void pkgmgr_fini(void); +extern Evas_Object *pkgmgr_find_pended_object(const char *package, int with_desktop_file, Evas_Object *scroller, Evas_Object **page); +extern menu_screen_error_e pkgmgr_uninstall(Evas_Object *obj); + +#endif //__MENU_SCREEN_PKGMGR_H__ + +// End of a file diff --git a/include/popup.h b/include/popup.h new file mode 100644 index 0000000..b894376 --- /dev/null +++ b/include/popup.h @@ -0,0 +1,29 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_POPUP_H__ +#define __MENU_SCREEN_POPUP_H__ + +extern Evas_Object *popup_exist(void); +extern void popup_destroy_all(void); +extern Evas_Object *popup_create_confirm(Evas_Object *parent, const char *warning); +extern Evas_Object *popup_create_uninstall(Evas_Object *parent, Evas_Object *item); + +#endif //__MENU_SCREEN_POPUP_H__ + +// End of a file diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..44579b3 --- /dev/null +++ b/include/util.h @@ -0,0 +1,168 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#ifndef __MENU_SCREEN_UTIL_H__ +#define __MENU_SCREEN_UTIL_H__ +#include +#include + +#define STR_MOVE_PREV "move,prev" +#define STR_MOVE_NEXT "move,next" +#define STR_ANI_RETURN "ani,return" +#define STR_ENV_MAPBUF "BEATUX_MAPBUF" + +#define ALL_APPS_TABLE "all_apps" + +/* Accessibility */ +#define ACCESS_BUTTON "button" +#define ACCESS_EDIT "edit" + +/* Multi-language */ +#define D_(str) dgettext("sys_string", str) + +/* Log */ +#if !defined(_W) +#define _W(fmt, arg...) LOGW(fmt"\n", ##arg) +#endif + +#if !defined(_D) +#define _D(fmt, arg...) LOGD(fmt"\n", ##arg) +#endif + +#if !defined(_E) +#define _E(fmt, arg...) LOGE(fmt"\n", ##arg) +#endif + +#if !defined(_T) +#define _T(package) LOG(LOG_DEBUG, "LAUNCH", "[%s:Menuscreen:launch:done]", package); +#endif + +/* Multi-language */ +#ifndef _ +#define _(str) gettext(str) +#endif + +#define gettext_noop(str) (str) +#define N_(str) gettext_noop(str) +#define D_(str) dgettext("sys_string", str) + +/* Build */ +#define HAPI __attribute__((visibility("hidden"))) + +/* Packaging */ +#define DEFAULT_ICON IMAGEDIR"/default.png" + +#ifdef APPFWK_MEASUREMENT +#define PRINT_APPFWK() do { \ + struct timeval tv; \ + char str_time[64] = {0,}; \ + int re; \ + gettimeofday(&tv, NULL); \ + sprintf(str_time, "APP_START_TIME=%u %u", (int)tv.tv_sec, (int)tv.tv_usec); \ + re = putenv(str_time); \ +} while (0) +#else +#define PRINT_APPFWK() +#endif + +#if defined(TIME_CHECK) +#define PRINT_TIME() do { \ + struct timeval tv; \ + gettimeofday(&tv, NULL); \ + _D("[%s:%d] TIME=%u %u", __func__, __LINE__, (int)tv.tv_sec, (int)tv.tv_usec); \ +} while (0) +#else +#define PRINT_TIME() +#endif + +#define retv_if(expr, val) do { \ + if(expr) { \ + _E("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ +} while (0) + +#define ret_if(expr) do { \ + if(expr) { \ + _E("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ +} while (0) + +#define goto_if(expr, val) do { \ + if(expr) { \ + _E("(%s) -> goto", #expr); \ + goto val; \ + } \ +} while (0) + +#define break_if(expr) { \ + if(expr) { \ + _E("(%s) -> break", #expr); \ + break; \ + } \ +} + +#define continue_if(expr) { \ + if(expr) { \ + _E("(%s) -> continue", #expr); \ + continue; \ + } \ +} + +#if !defined(_EDJ) +#define _EDJ(a) elm_layout_edje_get(a) +#endif + +typedef enum { + MENU_SCREEN_ERROR_OK = 0, + MENU_SCREEN_ERROR_FAIL = -1, + MENU_SCREEN_ERROR_DB_FAILED = -2, + MENU_SCREEN_ERROR_OUT_OF_MEMORY = -3, + MENU_SCREEN_ERROR_INVALID_PARAMETER = -4, + MENU_SCREEN_ERROR_NO_DATA = -5, +} menu_screen_error_e; + +typedef enum { + TRAY_TYPE_ALL_APPS = 0, + TRAY_TYPE_RUNNING_APPS, + TRAY_TYPE_DOWNLOADED_APPS, + TRAY_TYPE_FAVORITE_APPS, + TRAY_TYPE_FREQUENTLY_USED_APPS, + TRAY_TYPE_MAX, +} tray_type_e; + +enum { + APP_STATE_PAUSE = 1, + APP_STATE_RESUME, +}; + +enum { + MENU_SCREEN_ROTATE_PORTRAIT = 0, + MENU_SCREEN_ROTATE_LANDSCAPE, +}; + + + +extern void _evas_object_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +extern void _evas_object_event_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +extern void _evas_object_event_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +extern void _evas_object_event_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); + + +#endif /* __MENU_SCREEN_UTIL_H__ */ diff --git a/org.tizen.menu-screen.manifest b/org.tizen.menu-screen.manifest new file mode 100644 index 0000000..af98acf --- /dev/null +++ b/org.tizen.menu-screen.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/org.tizen.menu-screen.rule b/org.tizen.menu-screen.rule new file mode 100644 index 0000000..fe79e16 --- /dev/null +++ b/org.tizen.menu-screen.rule @@ -0,0 +1,94 @@ +org.tizen.menu-screen pkgmgr::db rw +org.tizen.menu-screen ail::db rw +org.tizen.menu-screen system::homedir rwxat +org.tizen.menu-screen system::vconf rwxat +org.tizen.menu-screen system::media rwxat +org.tizen.menu-screen system::share rwxat +org.tizen.menu-screen system::use_internet r +org.tizen.menu-screen device::app_logging w +org.tizen.menu-screen device::camera rwx +org.tizen.menu-screen sys-assert::core rwxat +org.tizen.menu-screen pulseaudio rwxat +org.tizen.menu-screen net-config rx +org.tizen.menu-screen xorg rwx +org.tizen.menu-screen isf rwx +org.tizen.menu-screen dbus rwx +org.tizen.menu-screen ug-image-viewer-efl rx +org.tizen.menu-screen cbhm rx +org.tizen.menu-screen sound_server rwx +org.tizen.menu-screen svi-data rx +org.tizen.menu-screen data-provider-master rwx +org.tizen.menu-screen org.tizen.indicator rwx +org.tizen.menu-screen org.tizen.setting rx +org.tizen.menu-screen sqlfs rx +org.tizen.menu-screen e17 rwx +org.tizen.menu-screen dlogutil rx +org.tizen.menu-screen immvibed rwx +org.tizen.menu-screen rua::db rw +org.tizen.menu-screen org.tizen.clock w +org.tizen.menu-screen badge::db rw +org.tizen.menu-screen aul rwx +org.tizen.menu-screen system-server rx +org.tizen.menu-screen deviced rx +org.tizen.menu-screen sensor-framework rx +org.tizen.menu-screen secure-storage rx +org.tizen.menu-screen pkgmgr-client rx +org.tizen.menu-screen syslogd w +org.tizen.menu-screen system::vconf_multimedia rw +org.tizen.indicator org.tizen.menu-screen rwx +org.tizen.browser org.tizen.menu-screen rw +org.tizen.contact org.tizen.menu-screen rw +org.tizen.youtube-shortcut org.tizen.menu-screen rw +org.tizen.message org.tizen.menu-screen rw +org.tizen.voicerecorder org.tizen.menu-screen rw +org.tizen.calendar org.tizen.menu-screen rw +org.tizen.episode org.tizen.menu-screen rw +org.tizen.keepit org.tizen.menu-screen rw +org.tizen.calculator org.tizen.menu-screen rw +org.tizen.clock org.tizen.menu-screen rw +org.tizen.camera-app org.tizen.menu-screen rw +org.tizen.svoice org.tizen.menu-screen rw +org.tizen.group-cast org.tizen.menu-screen rw +org.tizen.phone org.tizen.menu-screen rw +org.tizen.smartsearch org.tizen.menu-screen rw +org.tizen.setting org.tizen.menu-screen rw +org.tizen.myfile org.tizen.menu-screen rw +org.tizen.rcs-im org.tizen.menu-screen rw +org.tizen.smemo org.tizen.menu-screen rw +org.tizen.facebook org.tizen.menu-screen rw +org.tizen.dailybriefing-ynews org.tizen.menu-screen rw +org.tizen.gallery org.tizen.menu-screen rw +org.tizen.email org.tizen.menu-screen rw +org.tizen.dailybriefing-yfinance org.tizen.menu-screen rw +org.tizen.music-player org.tizen.menu-screen rw +org.tizen.nfc-app org.tizen.menu-screen rw +org.tizen.dailybriefing-accuweather org.tizen.menu-screen rw +org.tizen.video-player org.tizen.menu-screen rw +org.tizen.contacts org.tizen.menu-screen rw +dbus org.tizen.menu-screen rwx +e17 org.tizen.menu-screen rwx +stest-service org.tizen.menu-screen rx +org.tizen.menu-screen stest-service w +org.tizen.menu-screen org.tizen.setting::default-resources rx +org.tizen.menu-screen pkgmgr::svc rx +org.tizen.menu-screen pkgmgr::info r +org.tizen.menu-screen system::vconf_system rw +org.tizen.menu-screen system::vconf_inhouse rw +org.tizen.menu-screen aul::launch x +org.tizen.menu-screen data-provider-master::shortcut rw +org.tizen.menu-screen data-provider-master::shortcut.shortcut w +org.tizen.menu-screen data-provider-master::notification rw +org.tizen.menu-screen data-provider-master::notification.client w +org.tizen.menu-screen data-provider-master::badge rw +org.tizen.menu-screen data-provider-master::badge.client w +org.tizen.menu-screen tts-server rwx +org.tizen.menu-screen idlescreen::vconf rwx +org.tizen.app-tray org.tizen.menu-screen rx +org.tizen.menu-screen factory-15 rx +org.tizen.menu-screen telephony_framework::api_manager r +org.tizen.menu-screen telephony_framework::api_modem r +org.tizen.menu-screen telephony_framework::api_network r +org.tizen.menu-screen atd-server r +org.tizen.menu-screen factory::vconf rw +org.tizen.menu-screen mobileprint x +org.tizen.menu-screen _ wx diff --git a/packaging/org.tizen.menu-screen.spec b/packaging/org.tizen.menu-screen.spec new file mode 100644 index 0000000..bb6eab5 --- /dev/null +++ b/packaging/org.tizen.menu-screen.spec @@ -0,0 +1,143 @@ +%define _optdir /opt +%define _usrdir /usr +%define _appdir %{_usrdir}/apps +%define _usr_datadir %{_usrdir}/share + +%define _project_name menu-screen +%define _package_name org.tizen.%{_project_name} + +%define _packagedir %{_appdir}/%{_package_name} +%define _bindir %{_packagedir}/bin +%define _datadir %{_optdir}%{_packagedir}/data +%define _resdir %{_packagedir}/res +%define _sharedir %{_packagedir}/share + +%define _localedir %{_resdir}/locale + +Name: org.tizen.menu-screen +Summary: An utility library of the menu screen +Version: 1.2.7 +Release: 1.1 +Group: TO_BE/FILLED_IN +License: Flora Software License +Source0: %{name}-%{version}.tar.gz +BuildRequires: pkgconfig(ail) +BuildRequires: pkgconfig(appcore-efl) +BuildRequires: pkgconfig(appsvc) +BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(badge) +BuildRequires: pkgconfig(bundle) +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ecore-evas) +BuildRequires: pkgconfig(ecore-file) +BuildRequires: pkgconfig(ecore-imf) +BuildRequires: pkgconfig(ecore-input) +BuildRequires: pkgconfig(edje) +BuildRequires: pkgconfig(eet) +BuildRequires: pkgconfig(eina) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(evas) +BuildRequires: pkgconfig(heynoti) +BuildRequires: pkgconfig(pkgmgr) +BuildRequires: pkgconfig(pkgmgr-info) +BuildRequires: pkgconfig(shortcut) +BuildRequires: pkgconfig(sysman) +BuildRequires: pkgconfig(syspopup-caller) +BuildRequires: pkgconfig(utilX) +BuildRequires: cmake +BuildRequires: edje-tools +BuildRequires: gettext-tools + + +%description +An utility library for developers of the menu screen. + + + +%package devel +Summary: An utility library of the menu screen (devel) +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +An utility library for developers of the menu screen (devel) + + +%prep +%setup -q + +%build +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} +CFLAGS="${CFLAGS} -Wall" LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed" +make %{?jobs:-j%jobs} + +%install +%make_install +mkdir -p %{buildroot}%{_datadir} +mkdir -p %{buildroot}/usr/share/license + +%post +INHOUSE_ID="5000" + +init_vconf() +{ + vconftool set -t int memory/idle-screen/top 0 -i -u 5000 -f + vconftool set -t string file/private/org.tizen.menu-screen/engine "gl" -i -u 5000 -f + vconftool set -t string db/setting/menuscreen/package_name "org.tizen.menu-screen" -i -u 5000 -f +} +init_vconf + +if [ ! -d %{_datadir}/dbspace ] +then + mkdir -p %{_datadir}/dbspace +fi + +if [ ! -d %{_datadir}/shortcut ] +then + mkdir -p %{_datadir}/shortcut +else + rm -rf %{_datadir}/shortcut/* +fi + +sqlite3 %{_datadir}/dbspace/.menu_screen.db 'PRAGMA journal_mode = PERSIST; + create table if not exists shortcut ( + ROWID INTEGER PRIMARY KEY AUTOINCREMENT, + appid TEXT, + name TEXT, + type INTEGER, + content_info TEXT, + icon TEXT + ); +' + +INHOUSE_ID="5000" +chown -R $INHOUSE_ID:$INHOUSE_ID %{_datadir} +chown root:$INHOUSE_ID %{_datadir}/dbspace/.menu_screen.db +chown root:$INHOUSE_ID %{_datadir}/dbspace/.menu_screen.db-journal + +chmod 660 %{_datadir}/dbspace/.menu_screen.db +chmod 660 %{_datadir}/dbspace/.menu_screen.db-journal + +if [ -f /usr/lib/rpm-plugins/msm.so ] +then + chsmack -a 'org.tizen.menu-screen' %{_datadir}/dbspace/.menu_screen.db* +fi + +%files +%manifest %{name}.manifest +%defattr(-,root,root,-) +%{_bindir}/menu-screen +%{_resdir}/edje/all_apps_portrait.edj +%{_resdir}/edje/button_edit.edj +%{_resdir}/edje/group_4x4_portrait.edj +%{_resdir}/edje/item_4x4.edj +%{_resdir}/edje/layout_portrait.edj +%{_resdir}/edje/index.edj +%{_resdir}/images/default.png +%{_localedir}/*/*/*.mo +%{_usr_datadir}/packages/org.tizen.menu-screen.xml +%{_usr_datadir}/license/%{name} +/opt/etc/smack/accesses.d/%{_package_name}.rule diff --git a/src/all_apps/db.c b/src/all_apps/db.c new file mode 100644 index 0000000..ffed9c7 --- /dev/null +++ b/src/all_apps/db.c @@ -0,0 +1,209 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include + +#include "db.h" +#include "util.h" +#include "all_apps/db.h" + +#define QUERY_LEN 1024 + +#define MENU_SCREEN_DB_FILE "/opt/usr/apps/com.samsung.menu-screen/data/dbspace/.menu_screen.db" +#define SHORTCUT_TABLE "shortcut" +#define QUERY_INSERT_SHORTCUT "INSERT INTO "SHORTCUT_TABLE" ("\ + "appid,"\ + "name,"\ + "type,"\ + "content_info,"\ + "icon"\ + ") VALUES ("\ + "'%s', '%s', %d, '%s', '%s');" +#define QUERY_DELETE_SHORTCUT "DELETE FROM "SHORTCUT_TABLE" WHERE ROWID=%lld" +#define QUERY_GET_ALL "SELECT ROWID, appid, name, type, content_info, icon FROM "SHORTCUT_TABLE +#define QUERY_COUNT_SHORTCUT "SELECT COUNT(*) FROM "SHORTCUT_TABLE" WHERE appid='%s' AND name='%s'" + + + +HAPI menu_screen_error_e all_apps_db_init(void) +{ + return db_open(MENU_SCREEN_DB_FILE); +} + + + +HAPI void all_apps_db_fini(void) +{ + db_close(); +} + + + +HAPI Eina_List *all_apps_db_retrieve_all_info(void) +{ + stmt_h *st; + Eina_List *list = NULL; + + retv_if(MENU_SCREEN_ERROR_OK != db_open(MENU_SCREEN_DB_FILE), NULL); + + st = db_prepare(QUERY_GET_ALL); + retv_if(NULL == st, NULL); + + menu_screen_error_e ret = MENU_SCREEN_ERROR_FAIL; + for (ret = db_next(st); MENU_SCREEN_ERROR_FAIL != ret && MENU_SCREEN_ERROR_NO_DATA != ret; ret = db_next(st)) { + db_info *info; + info = calloc(1, sizeof(db_info)); + break_if(NULL == info); + + info->rowid = db_get_long_long(st, 0); // 0 : ROWID + + char *tmp = NULL; + tmp = (char *) db_get_str(st, 1); // 1 : appid + if (tmp && strlen(tmp)) { + info->appid = strdup(tmp); + goto_if(NULL == info->appid, APP_ERROR); + } + + tmp = (char *) db_get_str(st, 2); // 2 : name + if (tmp && strlen(tmp)) { + info->name = strdup(tmp); + goto_if(NULL == info->name, APP_ERROR); + } + + info->type = db_get_int(st, 3); // 3 : type + + tmp = (char *) db_get_str(st, 4); // 4 : content_info + if (tmp && strlen(tmp)) { + info->content_info = strdup(tmp); + goto_if(NULL == info->content_info, APP_ERROR); + } + + tmp = (char *) db_get_str(st, 5); // 5 : icon + if (tmp && strlen(tmp)) { + info->icon = strdup(tmp); + goto_if(NULL == info->icon, APP_ERROR); + } + + list = eina_list_append(list, info); + + continue; +APP_ERROR: + if (info->appid) free(info->appid); + if (info->name) free(info->name); + if (info->content_info) free(info->content_info); + if (info->icon) free(info->icon); + if (info) free(info); + } + + db_finalize(st); + + return list; +} + + + +HAPI void all_apps_db_unretrieve_info(db_info *info) +{ + ret_if(NULL == info); + if (info->appid) free(info->appid); + if (info->name) free(info->name); + if (info->content_info) free(info->content_info); + if (info->icon) free(info->icon); + if (info) free(info); +} + + + +HAPI void all_apps_db_unretrieve_all_info(Eina_List *list) +{ + db_info *info = NULL; + + EINA_LIST_FREE(list, info) { + if (NULL == info) break; + if (info->appid) free(info->appid); + if (info->name) free(info->name); + if (info->content_info) free(info->content_info); + if (info->icon) free(info->icon); + if (info) free(info); + } + + eina_list_free(list); +} + + + +HAPI int all_apps_db_count_shortcut(const char *appid, const char *name) +{ + retv_if(MENU_SCREEN_ERROR_OK != db_open(MENU_SCREEN_DB_FILE), -1); + + char q[QUERY_LEN]; + snprintf(q, sizeof(q), QUERY_COUNT_SHORTCUT, appid, name); + + stmt_h *st; + st = db_prepare(q); + retv_if(NULL == st, -1); + + menu_screen_error_e ret = MENU_SCREEN_ERROR_FAIL; + ret = db_next(st); + retv_if(MENU_SCREEN_ERROR_FAIL == ret, -1); + + int count = -1; + count = db_get_int(st, 0); + + db_finalize(st); + + return count; +} + + + +HAPI long long all_apps_db_insert_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon) +{ + char q[QUERY_LEN]; + + retv_if(MENU_SCREEN_ERROR_OK != db_open(MENU_SCREEN_DB_FILE), -1l); + + snprintf(q, sizeof(q), QUERY_INSERT_SHORTCUT, appid, name, type, content_info, icon); + retv_if(db_exec(q) < 0, -1l); + + long long id = -1l; + id = db_last_insert_rowid(); + + return id; +} + + + +HAPI menu_screen_error_e all_apps_db_delete_shortcut(long long rowid) +{ + char q[QUERY_LEN]; + + retv_if(MENU_SCREEN_ERROR_OK != db_open(MENU_SCREEN_DB_FILE), MENU_SCREEN_ERROR_FAIL); + + snprintf(q, sizeof(q), QUERY_DELETE_SHORTCUT, rowid); + retv_if(db_exec(q) < 0, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +// END diff --git a/src/all_apps/layout.c b/src/all_apps/layout.c new file mode 100644 index 0000000..7182481 --- /dev/null +++ b/src/all_apps/layout.c @@ -0,0 +1,420 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include + +#include "menu_screen.h" +#include "conf.h" +#include "index.h" +#include "item_event.h" +#include "key.h" +#include "layout.h" +#include "list.h" +#include "page_scroller.h" +#include "popup.h" +#include "util.h" +#include "all_apps/layout.h" +#include "all_apps/list.h" +#include "all_apps/shortcut.h" + +#define ALL_APPS_EDJE_PORTRAIT EDJEDIR"/all_apps_portrait.edj" +#define ALL_APPS_GROUP "all_apps" + +#define GROUP_4X4_EDJE_PORTRAIT EDJEDIR"/group_4x4_portrait.edj"; + +#define ALL_APPS_EDIT_BUTTON_EDJE EDJEDIR"/button_edit.edj" +#define ALL_APPS_EDIT_BUTTON_GROUP "button_edit" +#define ALL_APPS_EDIT_BUTTON_PART "button_edit" + +#define IDS_HS_BUTTON_DONE "IDS_HS_BUTTON_DONE" + + + +HAPI bool all_apps_layout_is_edited(Evas_Object *all_apps) +{ + retv_if(NULL == all_apps, false); + return (bool) evas_object_data_get(all_apps, "is_edited"); +} + + + +HAPI void all_apps_layout_edit(Evas_Object *all_apps) +{ + Evas_Object *edit_button; + Evas_Object *scroller; + + //elm_object_tree_focus_allow_set(all_apps, EINA_FALSE); + evas_object_data_set(all_apps, "is_edited", (void *) true); + + edit_button = elm_object_part_content_get(all_apps, ALL_APPS_EDIT_BUTTON_PART); + ret_if(NULL == edit_button); + elm_object_signal_emit(edit_button, "edit_button_state,edit", "menu"); + + scroller = elm_object_part_content_get(all_apps, "content"); + ret_if(NULL == scroller); + page_scroller_edit(scroller); + + key_grab_home(); +} + + + +HAPI void all_apps_layout_unedit(Evas_Object *all_apps) +{ + Evas_Object *edit_button; + + ret_if(NULL == all_apps); + + //elm_object_tree_focus_allow_set(all_apps, EINA_TRUE); + key_ungrab_home(); + popup_destroy_all(); + + bool is_edited = (bool) evas_object_data_get(all_apps, "is_edited"); + if (false == is_edited) return; + + do { + edit_button = elm_object_part_content_get(all_apps, ALL_APPS_EDIT_BUTTON_PART); + ret_if(NULL == edit_button); + elm_object_signal_emit(edit_button, "edit_button_state,unedit", "menu"); + } while (0); + + do { + Evas_Object *scroller; + + scroller = elm_object_part_content_get(all_apps, "content"); + ret_if(NULL == scroller); + + page_scroller_unedit(scroller); + } while (0); +} + + + +static char *_access_info_cb(void *data, Evas_Object *obj) +{ + Evas_Object *scroller = data; + + char *info; + if (page_scroller_is_edited(scroller)) { + info = _(IDS_HS_BUTTON_DONE); + } else { + info = ACCESS_EDIT; + } + + char *tmp; + tmp = strdup(info); + if (!tmp) return NULL; + return tmp; +} + + + +static void _focus_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *scroller = data; + + _D("Edit button is up"); + + Evas_Object *all_apps; + all_apps = evas_object_data_get(scroller, "tab"); + ret_if(NULL == all_apps); + + if (page_scroller_is_edited(scroller)) { + _D("Go to the normal mode"); + all_apps_layout_unedit(all_apps); + } else { + _D("Go to the edit mode"); + all_apps_layout_edit(all_apps); + } + + elm_object_signal_emit(obj, "edit_button,release", "menu"); +} + + + + +static void _edit_button_down_cb(void *data, Evas_Object *obj, const char* emission, const char* source) +{ + _D("Edit button is down"); +} + + + +static void _edit_button_up_cb(void *data, Evas_Object *obj, const char* emission, const char* source) +{ + _D("Edit button is up"); + + elm_object_signal_emit(obj, "edit_button,release", "menu"); +} + + + +static Evas_Object *_add_edit_button(Evas_Object *parent, Evas_Object *scroller) +{ + Evas_Object *button; + + retv_if(NULL == parent, NULL); + retv_if(NULL == scroller, NULL); + + button = layout_load_edj(parent, ALL_APPS_EDIT_BUTTON_EDJE, ALL_APPS_EDIT_BUTTON_GROUP); + retv_if(NULL == button, NULL); + + edje_object_signal_callback_add(_EDJ(button), "edit_button,down", "menu", _edit_button_down_cb, scroller); + edje_object_signal_callback_add(_EDJ(button), "edit_button,up", "menu", _edit_button_up_cb, scroller); + + do { // focus + Evas_Object *focus= NULL; + focus = elm_button_add(button); + retv_if(NULL == focus, NULL); + + elm_object_style_set(focus, "focus"); + elm_object_part_content_set(button, "focus", focus); + elm_access_info_cb_set(focus, ELM_ACCESS_INFO, _access_info_cb, scroller); + evas_object_smart_callback_add(focus, "clicked", _focus_clicked_cb, scroller); + } while (0); + + return button; +} + + + +static void _remove_edit_button(Evas_Object *button) +{ + ret_if(NULL == button); + + do { + Evas_Object *focus = NULL; + focus = elm_object_part_content_unset(button, "focus"); + if (NULL == focus) break; + evas_object_smart_callback_del(focus, "clicked", _focus_clicked_cb); + evas_object_del(focus); + } while (0); + + edje_object_signal_callback_del(_EDJ(button), "edit_button,down", "menu", _edit_button_down_cb); + edje_object_signal_callback_del(_EDJ(button), "edit_button,up", "menu", _edit_button_up_cb); + + layout_unload_edj(button); +} + + + +static menu_screen_error_e _load_item(Evas_Object *scroller, app_list_item *item) +{ + app_info_t *ai; + + retv_if(NULL == item, MENU_SCREEN_ERROR_FAIL); + ai = item->data; + if (ai->nodisplay || !ai->enabled) { + return MENU_SCREEN_ERROR_OK; + } + + retv_if(NULL == page_scroller_push_item(scroller, ai), MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; + +} + + + +static Eina_Bool _push_items_idler_cb(void *all_apps) +{ + bool flag = true; + app_list *list; + app_list_item *item; + Evas_Object *scroller; + + list = evas_object_data_get(all_apps, "list"); + scroller = evas_object_data_get(all_apps, "scroller"); + + retv_if(NULL == list, ECORE_CALLBACK_CANCEL); + goto_if(NULL == scroller, ERROR); + goto_if(MENU_SCREEN_ERROR_OK != list_is_ended(list, &flag), ERROR); + goto_if(flag == true, ERROR); + goto_if(MENU_SCREEN_ERROR_OK != list_get_item(list, &item), ERROR); + goto_if(MENU_SCREEN_ERROR_OK != _load_item(scroller, item), ERROR); + goto_if(MENU_SCREEN_ERROR_OK != list_next(list), ERROR); + + return ECORE_CALLBACK_RENEW; + +ERROR: + all_apps_list_destroy(list); + evas_object_data_del(all_apps, "list"); + page_scroller_bring_in(scroller, 0); + page_scroller_focus(scroller); + menu_screen_set_done(true); + + return ECORE_CALLBACK_CANCEL; +} + + + +static menu_screen_error_e _push_items(Evas_Object *all_apps) +{ + app_list *list; + Ecore_Idler *idle_timer; + + list = all_apps_list_create(); + retv_if(MENU_SCREEN_ERROR_OK != list_first(list), MENU_SCREEN_ERROR_FAIL); + + evas_object_data_set(all_apps, "list", list); + idle_timer = ecore_idler_add(_push_items_idler_cb, all_apps); + retv_if(NULL == idle_timer, MENU_SCREEN_ERROR_FAIL); + + Evas_Object *scroller; + scroller = evas_object_data_get(all_apps, "scroller"); + if (MENU_SCREEN_ERROR_OK != all_apps_shortcut_add_all(scroller)) + _E("Cannot add shortcuts"); + + do { + Evas_Object *button; + button = _add_edit_button(all_apps, scroller); + if (NULL == button) { + _D("cannot make the edit button"); + } + elm_object_part_content_set(all_apps, ALL_APPS_EDIT_BUTTON_PART, button); + } while (0); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI Evas_Object *all_apps_layout_create(Evas_Object *controlbar, int rotate) +{ + Evas_Object *all_apps; + Evas_Object *index; + Evas_Object *scroller; + + static const char item_edje[] = EDJEDIR"/item_4x4.edj"; + static const char *page_edje; + static const char *all_apps_edje; + int item_width, item_height; + int width; + int height; + + all_apps = elm_layout_add(controlbar); + retv_if(NULL == all_apps, NULL); + + all_apps_edje = ALL_APPS_EDJE_PORTRAIT; + page_edje = GROUP_4X4_EDJE_PORTRAIT; + width = menu_screen_get_root_width(); + height = menu_screen_get_root_height() - INDEX_HEIGHT; + + item_width = ITEM_WIDTH_PROP * menu_screen_get_root_width(); + item_height = ITEM_HEIGHT_PROP * menu_screen_get_root_height(); + + if (EINA_FALSE == elm_layout_file_set(all_apps, all_apps_edje, ALL_APPS_GROUP)) { + evas_object_del(all_apps); + _E("cannot load layout"); + return NULL; + } + + evas_object_data_set(all_apps, "win", evas_object_data_get(controlbar, "win")); + evas_object_data_set(all_apps, "layout", evas_object_data_get(controlbar, "layout")); + evas_object_data_set(all_apps, "controlbar", controlbar); + evas_object_data_set(all_apps, "page_edje", (void *) page_edje); + evas_object_data_set(all_apps, "page_max_app", (void *) PAGE_MAX_APP); + evas_object_data_set(all_apps, "item_edje", (void *) item_edje); + evas_object_data_set(all_apps, "item_width", (void *) item_width); + evas_object_data_set(all_apps, "item_height", (void *) item_height); + evas_object_data_set(all_apps, "item_enable_long_press", (void *) true); + evas_object_data_set(all_apps, "item_text_dual_line", (void *) true); + evas_object_data_set(all_apps, "is_under_pkgmgr", (void *) true); + evas_object_data_set(all_apps, "rotate", (void *) rotate); + evas_object_data_set(all_apps, "enable_bg_image", (void *) true); + evas_object_data_set(all_apps, "is_edited", (void *) true); + evas_object_size_hint_min_set(all_apps, width, height); + evas_object_size_hint_max_set(all_apps, width, height); + evas_object_resize(all_apps, width, height); + + index = index_create(all_apps, 0, 0); + if (NULL == index) { + evas_object_del(all_apps); + _E("cannot create index."); + return NULL; + } + elm_object_part_content_set(all_apps, "index", index); + evas_object_data_set(all_apps, "index", index); + + scroller = page_scroller_create(all_apps, index, PAGE_SCROLLER_SORT_BY_PACKAGE, rotate); + if (NULL == scroller) { + evas_object_del(all_apps); + index_destroy(index); + _E("cannot create scroller."); + return NULL; + } + + elm_object_part_content_set(all_apps, "content", scroller); + evas_object_data_set(all_apps, "scroller", scroller); + if (!all_apps_shortcut_init(all_apps)) _E("Cannot initialize shortcut"); + retv_if(MENU_SCREEN_ERROR_FAIL == _push_items(all_apps), NULL); + + return all_apps; +} + + + +HAPI void all_apps_layout_destroy(Evas_Object *all_apps) +{ + Evas_Object *index; + Evas_Object *scroller; + + ret_if(NULL == all_apps); + + all_apps_shortcut_fini(); + + do { + Evas_Object *button; + if(all_apps) { + button = elm_object_part_content_unset(all_apps, ALL_APPS_EDIT_BUTTON_PART); + _remove_edit_button(button); + } else { + _D("cannot find the all_apps object"); + } + } while (0); + + scroller = evas_object_data_get(all_apps, "scroller"); + ret_if(NULL == scroller); + if (scroller) page_scroller_destroy(scroller); + + index = evas_object_data_get(scroller, "index"); + if (index) index_destroy(index); + + evas_object_data_del(all_apps, "win"); + evas_object_data_del(all_apps, "layout"); + evas_object_data_del(all_apps, "controlbar"); + evas_object_data_del(all_apps, "index"); + evas_object_data_del(all_apps, "scroller"); + evas_object_data_del(all_apps, "page_edje"); + evas_object_data_del(all_apps, "page_max_app"); + evas_object_data_del(all_apps, "item_edje"); + evas_object_data_del(all_apps, "item_width"); + evas_object_data_del(all_apps, "item_height"); + evas_object_data_del(all_apps, "item_enable_long_press"); + evas_object_data_del(all_apps, "item_text_dual_line"); + evas_object_data_del(all_apps, "is_under_pkgmgr"); + evas_object_data_del(all_apps, "rotate"); + evas_object_data_del(all_apps, "enable_bg_image"); + evas_object_data_del(all_apps, "is_edited"); + + evas_object_del(all_apps); +} + + + +// End of a file diff --git a/src/all_apps/list.c b/src/all_apps/list.c new file mode 100644 index 0000000..ee06cfc --- /dev/null +++ b/src/all_apps/list.c @@ -0,0 +1,149 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include + +#include "menu_screen.h" +#include "conf.h" +#include "list.h" + + + +static ail_cb_ret_e _all_apps_cb(ail_appinfo_h ai, void *data) +{ + app_list *list = data; + app_list_item *item; + char *value; + + retv_if(ail_appinfo_get_str(ai, AIL_PROP_PACKAGE_STR, &value) == AIL_ERROR_FAIL, AIL_CB_RET_CANCEL); + retv_if(NULL == (item = calloc(1, sizeof(struct _app_list_item))), AIL_CB_RET_CANCEL); + + if (NULL == (item->package = strdup(value))) { + free(item); + return AIL_CB_RET_CANCEL; + } + + if (NULL == (item->data = calloc(1, sizeof(app_info_t)))) { + free(item->package); + free(item); + return AIL_CB_RET_CANCEL; + } + + if (MENU_SCREEN_ERROR_OK != list_get_values(item->package, item->data)) { + free(item->data); + free(item->package); + free(item); + return AIL_CB_RET_CANCEL; + } + + if (list_append_item(list, item) != MENU_SCREEN_ERROR_OK) { + free(item->data); + free(item->package); + free(item); + return AIL_CB_RET_CANCEL; + } + + _D("[ALL Apps] package=%s", item->package); + + return AIL_CB_RET_CONTINUE; +} + + + +static int _all_apps_sort_cb(const void *d1, const void *d2) +{ + app_info_t *ai[2]; + app_list_item *item[2]; + + retv_if(NULL == d1, 0); + retv_if(NULL == d2, 0); + + item[0] = (app_list_item *) d1; + item[1] = (app_list_item *) d2; + + ai[0] = item[0]->data; + ai[1] = item[1]->data; + + return strcmp(ai[0]->name, ai[1]->name); +} + + + +HAPI app_list *all_apps_list_create(void) +{ + int count = 0; + app_list *list; + ail_filter_h f; + + list = calloc(1, sizeof(app_list)); + retv_if(NULL == list, NULL); + + if (ail_filter_new(&f) != AIL_ERROR_OK) { + free(list); + return NULL; + } + + if (ail_filter_add_bool(f, AIL_PROP_NODISPLAY_BOOL, false) != AIL_ERROR_OK){ + _E("Failed to add filter"); + ail_filter_destroy(f); + free(list); + return NULL; + } + + ail_filter_list_appinfo_foreach(f, _all_apps_cb, list); + ail_filter_destroy(f); + + if(MENU_SCREEN_ERROR_FAIL == list_sort(list, _all_apps_sort_cb)) { + _D("Cannot sort apps."); + } + + if(MENU_SCREEN_ERROR_FAIL == list_count(list, &count)) { + _D("Cannot count apps."); + } + _D("Total package count = %d", count); + + return list; +} + + + +HAPI void all_apps_list_destroy(app_list *list) +{ + app_list_item *item; + + ret_if(NULL == list); + ret_if(NULL == list->list); + + EINA_LIST_FREE(list->list, item) { + if (NULL == item) break; + if (item->package) free(item->package); + if (item->data) { + list_free_values(item->data); + free(item->data); + } + free(item); + } + + eina_list_free(list->list); + free(list); +} + + + +// End of a file diff --git a/src/all_apps/shortcut.c b/src/all_apps/shortcut.c new file mode 100644 index 0000000..fff1a61 --- /dev/null +++ b/src/all_apps/shortcut.c @@ -0,0 +1,236 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include + +#include "item.h" +#include "list.h" +#include "page_scroller.h" +#include "util.h" +#include "all_apps/db.h" + + + +HAPI Evas_Object *all_apps_shortcut_add( + Evas_Object *scroller, + long long rowid, + const char *pkgname, + const char *exec, + const char *name, + const char *content_info, + const char *icon, + int type) +{ + _D("Shortcut : pkgname(%s) exec(%s) name(%s) icon(%s)", pkgname, exec, name, icon); + + app_info_t ai = {0, }; + ai.package = (char *) pkgname; + ai.exec = (char *) exec; + ai.name = (char *) name; + ai.icon = (char *) icon; + ai.nodisplay = 0; + ai.enabled = 1; + ai.x_slp_removable = 1; + ai.x_slp_taskmanage = 0; + + if (ADD_TO_HOME_IS_LIVEBOX(type)) { + _D("This is a livebox"); + return NULL; + } + + Evas_Object *item = NULL; + retv_if(NULL == (item = page_scroller_push_item(scroller, &ai)), NULL); + + long long *tmp; + tmp = calloc(1, sizeof(long long)); + if (NULL == tmp) { + item_destroy(item); + return NULL; + } + + if (LAUNCH_BY_PACKAGE == type) { + _D("This is a package"); + evas_object_data_set(item, "shortcut_launch_package", (void *) true); + } else { + _D("This is a shortcut"); + evas_object_data_set(item, "shortcut_launch_package", (void *) false); + } + + *tmp = rowid; + evas_object_data_set(item, "is_shortcut", (void *) true); + evas_object_data_set(item, "rowid", tmp); + evas_object_data_set(item, "type", (void *) type); + evas_object_data_set(item, "content_info", content_info); + + return item; +} + + + +static Eina_Bool _push_items_idler_cb(void *data) +{ + Evas_Object *scroller = data; + Eina_List *list = evas_object_data_get(scroller, "list"); + Eina_List *n; + Eina_List *t; + db_info *info = NULL; + EINA_LIST_FOREACH_SAFE(list, n, t, info) { + goto_if(NULL == info, ERROR); + Evas_Object *item = NULL; + item = all_apps_shortcut_add( + scroller, + info->rowid, + info->appid, + NULL, + info->name, + info->content_info, + info->icon, + info->type); + + list = eina_list_remove(list, info); + evas_object_data_set(scroller, "list", list); + + all_apps_db_unretrieve_info(info); + break_if(NULL == item); + } + + return ECORE_CALLBACK_RENEW; +ERROR: + list = evas_object_data_del(scroller, "list"); + all_apps_db_unretrieve_all_info(list); + return ECORE_CALLBACK_CANCEL; +} + + + +HAPI menu_screen_error_e all_apps_shortcut_add_all(Evas_Object *scroller) +{ + Eina_List *list; + + list = all_apps_db_retrieve_all_info(); + if (NULL == list) { + _D("There is no shortcut"); + return MENU_SCREEN_ERROR_OK; + } + + evas_object_data_set(scroller, "list", list); + + Ecore_Idler *idle_timer = NULL; + idle_timer = ecore_idler_add(_push_items_idler_cb, scroller); + retv_if(NULL == idle_timer, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI void all_apps_shortcut_remove(Evas_Object *item) +{ + long long *tmp; + tmp = evas_object_data_del(item, "rowid"); + if (tmp) { + all_apps_db_delete_shortcut(*tmp); + free(tmp); + } + + Evas_Object *scroller; + scroller = evas_object_data_get(item, "scroller"); + + evas_object_data_del(item, "type"); + evas_object_data_del(item, "content_info"); + evas_object_data_del(item, "shortcut_launch_package"); + evas_object_data_del(item, "is_shortcut"); + item_destroy(item); + + if (scroller) page_scroller_trim_items(scroller); +} + + + +static int _shorcut_request_cb( + const char *pkgname, + const char *name, + int type, + const char *content_info, + const char *icon, + int pid, + double period, + int allow_duplicate, + void *data) +{ + Evas_Object *scroller = data; + + retv_if(NULL == pkgname, -1); + + _D("Package name: %s", pkgname); + _D("Name: %s", name); + _D("Type: %d", type); + _D("Content: %s", content_info); + _D("Icon: %s", icon); + _D("Requested from: %d", pid); + _D("period : %.2f", period); + _D("CBDATA: %p", data); + + if (!allow_duplicate) { + int count = 0; + count = all_apps_db_count_shortcut(pkgname, name); + if (0 < count) { + _D("There is already a package(%s:%s) in the Menu-screen", pkgname, name); + return -1; + } + } + + long long rowid = -1l; + rowid = all_apps_db_insert_shortcut(pkgname, name, type, content_info, icon); + retv_if(0l > rowid, -1); + + Evas_Object *item = NULL; + item = all_apps_shortcut_add(scroller, rowid, pkgname, NULL, name, content_info, icon, type); + retv_if(NULL == item, -1); + + return 0; +} + + + +HAPI bool all_apps_shortcut_init(Evas_Object *all_apps) +{ + retv_if(NULL == all_apps, false); + retv_if(MENU_SCREEN_ERROR_OK != all_apps_db_init(), false); + + Evas_Object *scroller; + scroller = evas_object_data_get(all_apps, "scroller"); + retv_if(NULL == scroller, false); + + int ret; + ret = shortcut_set_request_cb(_shorcut_request_cb, scroller); + + return 0 == ret ? true : false; +} + + + +HAPI void all_apps_shortcut_fini(void) +{ + all_apps_db_fini(); +} + + + +// End of file. diff --git a/src/db.c b/src/db.c new file mode 100644 index 0000000..58a489c --- /dev/null +++ b/src/db.c @@ -0,0 +1,316 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "db.h" + + + +#define retv_with_dbmsg_if(expr, val) do { \ + if (expr) { \ + _E("%s", sqlite3_errmsg(db_info.db)); \ + return (val); \ + } \ +} while (0) + + + +static struct { + sqlite3 *db; +} db_info = { + .db = NULL, +}; + +struct stmt { + sqlite3_stmt *stmt; +}; + + + +HAPI menu_screen_error_e db_open(const char *db_file) +{ + int ret; + + retv_if(NULL == db_file, MENU_SCREEN_ERROR_INVALID_PARAMETER); + if (db_info.db) { + return MENU_SCREEN_ERROR_OK; + } + + ret = db_util_open(db_file, &db_info.db, DB_UTIL_REGISTER_HOOK_METHOD); + retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI stmt_h *db_prepare(const char *query) +{ + int ret; + stmt_h *handle; + + retv_if(NULL == query, NULL); + + handle = calloc(1, sizeof(stmt_h)); + retv_if(NULL == handle, NULL); + + ret = sqlite3_prepare_v2(db_info.db, query, strlen(query), &(handle->stmt), NULL); + if (ret != SQLITE_OK) { + free(handle); + _E("%s", sqlite3_errmsg(db_info.db)); + return NULL; + } + + return handle; +} + + + +HAPI menu_screen_error_e db_bind_bool(stmt_h *handle, int idx, bool value) +{ + int ret; + + retv_if(NULL == handle, MENU_SCREEN_ERROR_FAIL); + + ret = sqlite3_bind_int(handle->stmt, idx, (int) value); + retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e db_bind_int(stmt_h *handle, int idx, int value) +{ + int ret; + + retv_if(NULL == handle, MENU_SCREEN_ERROR_FAIL); + + ret = sqlite3_bind_int(handle->stmt, idx, value); + retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e db_bind_str(stmt_h *handle, int idx, const char *str) +{ + int ret; + + retv_if(NULL == handle, MENU_SCREEN_ERROR_FAIL); + + ret = sqlite3_bind_text(handle->stmt, idx, str, strlen(str), SQLITE_TRANSIENT); + retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e db_next(stmt_h *handle) +{ + int ret; + + retv_if(NULL == handle, MENU_SCREEN_ERROR_FAIL); + + ret = sqlite3_step(handle->stmt); + switch (ret) { + case SQLITE_ROW: + return MENU_SCREEN_ERROR_OK; + case SQLITE_DONE: + return MENU_SCREEN_ERROR_NO_DATA; + default: + retv_with_dbmsg_if(1, MENU_SCREEN_ERROR_FAIL); + } +} + + + +HAPI bool db_get_bool(stmt_h *handle, int index) +{ + retv_if(NULL == handle, false); + return (bool) sqlite3_column_int(handle->stmt, index); +} + + + +HAPI int db_get_int(stmt_h *handle, int index) +{ + retv_if(NULL == handle, 0); + return sqlite3_column_int(handle->stmt, index); +} + + + +HAPI long long db_get_long_long(stmt_h *handle, int index) +{ + retv_if(NULL == handle, 0l); + return sqlite3_column_int64(handle->stmt, index); +} + + +HAPI const char *db_get_str(stmt_h *handle, int index) +{ + retv_if(NULL == handle, NULL); + return (const char *) sqlite3_column_text(handle->stmt, index); +} + + + +HAPI menu_screen_error_e db_reset(stmt_h *handle) +{ + int ret; + + retv_if(NULL == handle, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == handle->stmt, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + ret = sqlite3_reset(handle->stmt); + retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL); + + sqlite3_clear_bindings(handle->stmt); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e db_finalize(stmt_h *handle) +{ + int ret; + + retv_if(NULL == handle, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == handle->stmt, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + ret = sqlite3_finalize(handle->stmt); + retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL); + free(handle); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI long long db_last_insert_rowid(void) +{ + retv_if(NULL == db_info.db, -1l); + + long long rowid = sqlite3_last_insert_rowid(db_info.db); + + return rowid; +} + + + +HAPI menu_screen_error_e db_exec(const char *query) +{ + int ret; + char *errmsg; + + retv_if(NULL == query, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == db_info.db, MENU_SCREEN_ERROR_FAIL); + + ret = sqlite3_exec(db_info.db, query, NULL, NULL, &errmsg); + if (ret != SQLITE_OK) { + _E("Cannot execute this query - %s. because %s", + query, errmsg? errmsg:"uncatched error"); + sqlite3_free(errmsg); + return MENU_SCREEN_ERROR_FAIL; + } + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI void db_close(void) +{ + ret_if(!db_info.db); + sqlite3_close(db_info.db); + db_info.db = NULL; +} + + + +HAPI menu_screen_error_e db_begin_transaction(void) +{ + int ret = -1; + + ret = sqlite3_exec(db_info.db, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, NULL); + + while (SQLITE_BUSY == ret) { + sleep(1); + ret = sqlite3_exec(db_info.db, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, NULL); + } + + if (SQLITE_OK != ret) { + _E("sqlite3_exec() Failed(%d)", ret); + return MENU_SCREEN_ERROR_FAIL; + } + + return MENU_SCREEN_ERROR_OK; +} + + + +#define MENU_SCREEN_COMMIT_TRY_MAX 3 +HAPI menu_screen_error_e db_end_transaction(bool success) +{ + int ret = -1; + int i = 0; + char *errmsg = NULL; + + if (success) { + ret = sqlite3_exec(db_info.db, "COMMIT TRANSACTION", NULL, NULL, &errmsg); + if (SQLITE_OK != ret) { + _E("sqlite3_exec(COMMIT) Failed(%d, %s)", ret, errmsg); + sqlite3_free(errmsg); + + while (SQLITE_BUSY == ret && i < MENU_SCREEN_COMMIT_TRY_MAX) { + i++; + sleep(1); + ret = sqlite3_exec(db_info.db, "COMMIT TRANSACTION", NULL, NULL, NULL); + } + + if (SQLITE_OK != ret) { + _E("sqlite3_exec() Failed(%d)", ret); + ret = sqlite3_exec(db_info.db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); + if (SQLITE_OK != ret) { + _E("sqlite3_exec() Failed(%d)", ret); + } + + return MENU_SCREEN_ERROR_FAIL; + } + } + } else { + sqlite3_exec(db_info.db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); + } + + return MENU_SCREEN_ERROR_OK; +} + + + +// End of file. diff --git a/src/index.c b/src/index.c new file mode 100644 index 0000000..fb21705 --- /dev/null +++ b/src/index.c @@ -0,0 +1,145 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include + +#include "conf.h" +#include "util.h" +#include "page.h" +#include "layout.h" +#include "menu_screen.h" + +#define PAGE_CONTROLLER_GROUP_NAME "index" + + + +HAPI inline void index_bring_in(Evas_Object *index, int idx) +{ + Elm_Object_Item *idx_it; + + idx_it = elm_index_item_find(index, (void *) idx); + ret_if(NULL == idx_it); + elm_index_item_selected_set(idx_it, EINA_TRUE); +} + + + +HAPI void index_destroy(Evas_Object *index) +{ + ret_if(NULL == index); + + evas_object_data_del(index, "win"); + evas_object_data_del(index, "layout"); + evas_object_data_del(index, "controlbar"); + evas_object_data_del(index, "tab"); + evas_object_data_del(index, "count"); + elm_index_item_clear(index); + evas_object_del(index); +} + + + +HAPI Evas_Object *index_create(Evas_Object *tab, unsigned int count, unsigned int current_idx) +{ + Evas_Object *index; + Evas_Object *scroller; + register int i; + char *number; + + retv_if(NULL == tab, NULL); + index = elm_index_add(tab); + retv_if(NULL == index, NULL); + + elm_object_theme_set(index, menu_screen_get_theme()); + elm_object_style_set(index, "menuscreen/index"); + elm_index_horizontal_set(index, EINA_TRUE); + elm_index_autohide_disabled_set(index, EINA_TRUE); + + number = malloc(((size_t) log10((double) MAX_PAGE_NO)) + 2); + retv_if(NULL == number, NULL); + + for (i = 0; i < count; i++) { + sprintf(number, "%d", i + 1); + elm_index_item_append(index, number, NULL, (void *) i); + } + elm_index_level_go(index, 0); + + if (count > 0) { + index_bring_in(index, current_idx); + } + + elm_object_part_content_set(tab, PAGE_CONTROLLER_GROUP_NAME, index); + + // FIXME : This part will be removed when fixing Elementary API for index_update. + scroller = evas_object_data_get(tab, "scroller"); + if (scroller) { + evas_object_data_set(scroller, "index", index); + } + + evas_object_data_set(index, "win", evas_object_data_get(tab, "win")); + evas_object_data_set(index, "layout", evas_object_data_get(tab, "layout")); + evas_object_data_set(index, "controlbar", evas_object_data_get(tab, "controlbar")); + evas_object_data_set(index, "tab", tab); + evas_object_data_set(index, "count", (void *) count); + + evas_object_data_set(tab, "index", index); + _D("COUNT:%d", count); + + evas_object_show(index); + free(number); + + return index; +} + + + +HAPI Evas_Object *index_update(Evas_Object *layout, Evas_Object *index, unsigned int count) +{ + int idx = 0; + + int cur_count = (int) evas_object_data_get(index, "count"); + if (cur_count > 0) { + Elm_Object_Item *idx_it = elm_index_selected_item_get(index, 0); + if (idx_it) idx = (int) elm_object_item_data_get(idx_it); + } + + if(count == idx) idx--; + if(idx == -1) idx = 0; + + _D("Current index %d, Current count: %d", idx,count); + index_destroy(index); + return index_create(layout, count,idx); +} + + + +HAPI void index_hide(Evas_Object *index) +{ + edje_object_signal_emit(_EDJ(index), "hide", "index"); +} + + + +HAPI void index_show(Evas_Object *index) +{ + edje_object_signal_emit(_EDJ(index), "show", "index"); +} + + + +// End of the file diff --git a/src/item.c b/src/item.c new file mode 100644 index 0000000..b29b03d --- /dev/null +++ b/src/item.c @@ -0,0 +1,981 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include +#include + +#include "menu_screen.h" +#include "item_badge.h" +#include "conf.h" +#include "item.h" +#include "item_event.h" +#include "layout.h" +#include "list.h" +#include "mapbuf.h" +#include "page.h" +#include "page_scroller.h" +#include "pkgmgr.h" +#include "popup.h" +#include "util.h" + +#define LINE_SIZE 10 +#define LAYOUT_BLOCK_INTERVAL 1.0 +#define ITEM_GROUP_NAME "icon" + +#define STR_ATTRIBUTE_NAME "name" +#define STR_ATTRIBUTE_ICON "icon" +#define STR_ATTRIBUTE_PKG_NAME "package" +#define STR_ATTRIBUTE_REMOVABLE "removable" +#define STR_ATTRIBUTE_DESKTOP "desktop" +#define STR_ATTRIBUTE_TYPE "type" +#define STR_ATTRIBUTE_PAGE "pending,page" +#define STR_ICON_IMAGE_TYPE_OBJECT "object" +#define STR_ICON_IMAGE_TYPE_EDJE "edje" + +#define BUFSZE 1024 + + + +HAPI void item_set_icon(Evas_Object *edje, char *icon, int sync) +{ + char *tmp; + int changed; + + tmp = evas_object_data_get(edje, STR_ATTRIBUTE_ICON); + changed = (tmp && icon) ? strcmp(icon, tmp) : 1; + + if (!changed) { + return; + } + + free(tmp); + evas_object_data_del(edje, STR_ATTRIBUTE_ICON); + if (icon) { + tmp = strdup(icon); + if (tmp) { + evas_object_data_set(edje, STR_ATTRIBUTE_ICON, tmp); + }else { + _E("No more memory for allocating space \"%s\"", icon); + } + } +} + + + +HAPI char *item_get_icon(Evas_Object *edje) +{ + return evas_object_data_get(edje, STR_ATTRIBUTE_ICON); +} + + + +HAPI void item_set_name(Evas_Object *edje, char *name, int sync) +{ + char *tmp; + int changed; + + tmp = evas_object_data_get(edje, STR_ATTRIBUTE_NAME); + if (!(tmp||name)) return; + changed = (tmp && name) ? strcmp(name, tmp) : 1; + + if (!changed) { + return; + } + + if (tmp) free(tmp); + evas_object_data_del(edje, STR_ATTRIBUTE_NAME); + if (name && (strcmp(name, "(NULL)"))) { + tmp = strdup(name); + ret_if(NULL == tmp); + evas_object_data_set(edje, STR_ATTRIBUTE_NAME, tmp); + if (edje_object_part_text_set(_EDJ(edje), "txt", tmp) == EINA_FALSE){ + //_E("Failed to set text on the part"); + } + } +} + + + +HAPI inline char *item_get_name(Evas_Object *edje) +{ + return evas_object_data_get(edje, STR_ATTRIBUTE_NAME); +} + + + +HAPI void item_set_desktop(Evas_Object *edje, char *name, int sync) +{ + char *tmp; + int changed; + + tmp = evas_object_data_get(edje, STR_ATTRIBUTE_DESKTOP); + changed = (tmp && name) ? strcmp(name, tmp) : 1; // We have to do sync when an attribute is created + + if (!changed) { + return; + } + + free(tmp); // NOTE: I can accept this, "free" will not do anything for NULL + evas_object_data_del(edje, STR_ATTRIBUTE_DESKTOP); + if (name) { + tmp = strdup(name); + if (!tmp) { + _E("No more memory for allocating space \"%s\"", name); + } else { + evas_object_data_set(edje, STR_ATTRIBUTE_DESKTOP, tmp); + } + } +} + + + +HAPI inline char *item_get_desktop(Evas_Object *edje) +{ + return evas_object_data_get(edje, STR_ATTRIBUTE_DESKTOP); +} + + + +HAPI void item_set_type(Evas_Object *edje, int type, int sync) +{ + int tmp; + int changed; + + tmp = (int) evas_object_data_get(edje, STR_ATTRIBUTE_TYPE); + changed = (tmp == type ? 0 : 1); // We have to do sync when an attribute is created + + if (!changed) { + return ; + } + + evas_object_data_set(edje, STR_ATTRIBUTE_TYPE, (void *) type); +} + + + +HAPI inline int item_get_type(Evas_Object *edje) +{ + return (int) evas_object_data_get(edje, STR_ATTRIBUTE_TYPE); +} + + + +HAPI void item_set_package(Evas_Object *edje, char *package, int sync) +{ + char *tmp; + int changed; + + tmp = evas_object_data_get(edje, STR_ATTRIBUTE_PKG_NAME); + changed = (package && tmp) ? strcmp(tmp, package) : 1; + + if (!changed) { + return; + } + + free(tmp); + evas_object_data_del(edje, STR_ATTRIBUTE_PKG_NAME); + + if (package) { + tmp = strdup(package); + if (!tmp) { + _E("No more space for string \"%s\"", package); + } else { + evas_object_data_set(edje, STR_ATTRIBUTE_PKG_NAME, tmp); + } + } +} + + + +HAPI char *item_get_package(Evas_Object *edje) +{ + return evas_object_data_get(edje, STR_ATTRIBUTE_PKG_NAME); +} + + + +HAPI void item_set_removable(Evas_Object *edje, int removable, int sync) +{ + int value; + int changed; + + value = (int)evas_object_data_get(edje, STR_ATTRIBUTE_REMOVABLE); + changed = (int)(value != removable); + + if (!changed) { + return; + } + + evas_object_data_del(edje, STR_ATTRIBUTE_REMOVABLE); + + if (removable >= 0) { + evas_object_data_set(edje, STR_ATTRIBUTE_REMOVABLE, (void*) removable); + } +} + + + +HAPI int item_get_removable(Evas_Object *edje) +{ + return (int) evas_object_data_get(edje, STR_ATTRIBUTE_REMOVABLE); +} + + + +HAPI void item_set_page(Evas_Object *edje, Evas_Object *page, int sync) +{ + Evas_Object *value; + int changed; + + value = evas_object_data_get(edje, STR_ATTRIBUTE_PAGE); + changed = (int)(value != page); + + if (!changed) { + return; + } + + evas_object_data_del(edje, STR_ATTRIBUTE_PAGE); + + if (page) { + evas_object_data_set(edje, STR_ATTRIBUTE_PAGE, page); + } +} + + + +HAPI Evas_Object *item_get_page(Evas_Object *edje) +{ + return evas_object_data_get(edje, STR_ATTRIBUTE_PAGE); +} + + + + +HAPI void item_enable_delete(Evas_Object *item) +{ + if (item_get_removable(item) > 0) { + edje_object_signal_emit(_EDJ(item), "delete,on", "menu"); + } +} + + + +HAPI void item_disable_delete(Evas_Object *item) +{ + if (item_get_removable(item) > 0) { + edje_object_signal_emit(_EDJ(item), "delete,off", "menu"); + } +} + + + +HAPI void item_show_badge(Evas_Object *obj, int value) +{ + char str[BUFSZE]; + Evas_Object *scroller; + + ret_if(NULL == obj); + ret_if(value <= 0); + + sprintf(str, "%d", value); + if (edje_object_part_text_set(_EDJ(obj), "badge,txt", str) == EINA_FALSE) { + _E("Failed to set text on the part, edje:%p, part:%s, text:%s", _EDJ(obj), "badge,txt", str); + } + + scroller = evas_object_data_get(obj, "scroller"); + ret_if(NULL == scroller); + ret_if(page_scroller_is_edited(scroller)); + + edje_object_signal_emit(_EDJ(obj), "badge,on", "menu"); + evas_object_data_set(obj, "badge,enabled", (void*)1); + + _D("Badge is updated to %s", str); +} + + + +HAPI void item_hide_badge(Evas_Object *obj) +{ + ret_if(NULL == obj); + + edje_object_signal_emit(_EDJ(obj), "badge,off", "menu"); + evas_object_data_del(obj, "badge,enabled"); +} + + + +HAPI int item_is_enabled_badge(Evas_Object *obj) +{ + return evas_object_data_get(obj, "badge,enabled") != NULL; +} + + + +HAPI void item_enable_progress(Evas_Object *obj) +{ + Evas_Object *progress; + + ret_if(evas_object_data_get(obj, "progress,enabled")); + + progress = elm_object_part_content_unset(obj, "progress,swallow"); + if (progress) { + _D("Progress bar is already registered... Hmm.. just remove it"); + evas_object_del(progress); + } + + progress = elm_progressbar_add(obj); + ret_if(NULL == progress); + + elm_object_part_content_set(obj, "progress,swallow", progress); + + evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_progressbar_value_set(progress, 0.0f); + elm_progressbar_horizontal_set(progress, EINA_TRUE); + evas_object_show(progress); + + edje_object_signal_emit(_EDJ(obj), "progress,enable", "item"); + + evas_object_data_set(obj, "progress,enabled", "true"); +} + + + +HAPI void item_update_progress(Evas_Object *obj, int value) +{ + Evas_Object *progress; + + ret_if(NULL == evas_object_data_get(obj, "progress,enabled")); + + progress = edje_object_part_swallow_get(_EDJ(obj), "progress,swallow"); + ret_if(NULL == progress); + + elm_progressbar_value_set(progress, (float)value/100.0f); + + _D("progress is updated to %d", value); +} + + + +HAPI void item_disable_progress(Evas_Object *obj) +{ + Evas_Object *progress; + + ret_if(NULL == evas_object_data_get(obj, "progress,enabled")); + + edje_object_signal_emit(_EDJ(obj), "progress,disable", "item"); + + progress = elm_object_part_content_unset(obj, "progress,swallow"); + if (progress) { + evas_object_del(progress); + } + + evas_object_data_del(obj, "progress,enabled"); +} + + + +HAPI int item_is_enabled_progress(Evas_Object *obj) +{ + return evas_object_data_get(obj, "progress,enabled") != NULL; +} + + + +HAPI void item_edit(Evas_Object *item) +{ + if (item_get_removable(item)) { + edje_object_signal_emit(_EDJ(item), "uninstall,on", "menu"); + } + edje_object_signal_emit(_EDJ(item), "badge,off", "menu"); + item_unmark_dirty(item); +} + + + +HAPI void item_unedit(Evas_Object *item) +{ + char *package; + + edje_object_signal_emit(_EDJ(item), "uninstall,off", "menu"); + + package = item_get_package(item); + if (item_badge_is_registered(item) + && item_badge_count(package) > 0) + { + edje_object_signal_emit(_EDJ(item), "badge,on", "menu"); + } +} + + + +static Evas_Object *_add_icon_image(Evas_Object *item, const char *icon_file) +{ + Evas_Object *icon; + + retv_if(NULL == item, NULL); + retv_if(NULL == icon_file, NULL); + + icon = elm_icon_add(item); + retv_if(NULL == icon, NULL); + + if (elm_image_file_set(icon, icon_file, NULL) == EINA_FALSE) { + _E("Icon file is not accessible (%s)", icon_file); + evas_object_del(icon); + icon = NULL; + } + + elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE); + + if (menu_screen_get_root_height() > BASE_HEIGHT || menu_screen_get_root_width() > BASE_WIDTH) { + elm_image_no_scale_set(icon, EINA_TRUE); + } + + return icon; +} + + + +static Evas_Object *_add_edje_icon(Evas_Object *item, const char *icon_file) +{ + Evas_Object *icon; + + retv_if(NULL == item, NULL); + retv_if(NULL == icon_file, NULL); + + if (access(icon_file, R_OK) != 0) { + _E("Failed to get an icon"); + return NULL; + } + + icon = layout_load_edj(item, (char*)icon_file, ITEM_GROUP_NAME); + if (!icon) { + _E("Failed to load an edje, [%s] group icon", icon_file); + evas_object_del(icon); + icon = NULL; + } + + return icon; +} + + + +HAPI menu_screen_error_e item_is_edje_icon(const char *icon) +{ + int len; + const char *ext = "jde."; + + retv_if(!icon, MENU_SCREEN_ERROR_FAIL); + + len = strlen(icon) - 1; + + while (len >= 0 && *ext && icon[len] == *ext) { + len --; + ext ++; + } + + return *ext ? MENU_SCREEN_ERROR_FAIL : MENU_SCREEN_ERROR_OK; +} + + + +HAPI void item_update(Evas_Object *item, app_info_t *ai) +{ + Evas_Object *icon = NULL; + + ret_if(NULL == item); + ret_if(NULL == ai); + + if (!ai->image) { + if (ai->icon && 0 == access(ai->icon, R_OK)) { + ; + } else { + _E("Failed to access to [%s]", ai->icon); + if (ai->icon) free(ai->icon); + + ai->icon = strdup(DEFAULT_ICON); + if (!ai->icon) _E("Critical! strdup error"); + } + + if (ai->icon) { + FILE *fp; + fp = fopen(ai->icon, "rb"); + if (fp) { + fseek(fp, 0L, SEEK_END); + _D("Access to file [%s], size[%ld]", ai->icon, ftell(fp)); + fclose(fp); + } else _E("Cannot get the file pointer[%s]", ai->icon); + + if (item_is_edje_icon(ai->icon) == MENU_SCREEN_ERROR_OK) { + icon = _add_edje_icon(item, ai->icon); + evas_object_data_set(item, "icon_image_type", STR_ICON_IMAGE_TYPE_EDJE); + } else { + icon = _add_icon_image(item, ai->icon); + evas_object_data_set(item, "icon_image_type", STR_ICON_IMAGE_TYPE_OBJECT); + } + } + } else { + icon = ai->image; + evas_object_data_set(item, "icon_image_type", STR_ICON_IMAGE_TYPE_OBJECT); + } + + if (icon) { + Evas_Object *temp_item; + temp_item = elm_object_part_content_unset(item, "icon_image"); + if (temp_item) { + evas_object_del(temp_item); + } + + elm_object_part_content_set(item, "icon_image", icon); + evas_object_data_set(item, "icon_image", icon); + } + + item_set_package(item, ai->package, 0); + item_set_desktop(item, ai->desktop, 0); + item_set_name(item, ai->name, 0); + item_set_icon(item, ai->icon, 0); + evas_object_data_set(item, STR_ATTRIBUTE_REMOVABLE, (void*) ai->x_slp_removable); + evas_object_data_set(item, "pid", (void *) ai->pid); + + item_badge_register(item); + + do { + Evas_Object *scroller; + + scroller = evas_object_data_get(item, "scroller"); + break_if(NULL == scroller); + + if (false == page_scroller_is_edited(scroller)) break; + item_edit(item); + } while (0); +} + + + +static char *_access_info_cb(void *data, Evas_Object *obj) +{ + Evas_Object *item = data; + char *name = NULL; + name = item_get_name(item); + retv_if(NULL == name, NULL); + + char *tmp = NULL; + tmp = strdup(name); + retv_if(NULL == tmp, NULL); + return tmp; +} + + + +/* This function is similar to _item_up_cb. But it's apparently different */ +static void _focus_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *scroller; + + Evas_Object *item = data; + ret_if(NULL == item); + + _D("ITEM: mouse up event callback is invoked for %p", item); + PRINT_APPFWK(); + + scroller = evas_object_data_get(item, "scroller"); + ret_if(NULL == scroller); + + if (true == page_scroller_is_edited(scroller)) { + return; + } + item_launch(item); +} + + + +#define IDS_AT_BODY_UNINSTALL "IDS_AT_BODY_UNINSTALL" +static char *_access_uninstall_cb(void *data, Evas_Object *obj) +{ + char *info; + char *tmp; + info = _(IDS_AT_BODY_UNINSTALL); + if (!info) return NULL; + tmp = strdup(info); + if (!tmp) return NULL; + return tmp; +} + + + +/* This function is similar to _uninstall_up_cb in item_event.c */ +static void _uninstall_focus_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *win; + Evas_Object *scroller; + char *package; + + win = menu_screen_get_win(); + ret_if(NULL == win); + + _D("Uninstall button is up"); + + Evas_Object *item = data; + scroller = evas_object_data_get(item, "scroller"); + + package = item_get_package(item); + ret_if(!package || strlen(package) == 0); + ret_if(pkgmgr_find_pended_object(package, 0, scroller, NULL)); + + _D("Uninstalling... [%s]", package); + + popup_create_uninstall(win, item); +} + + + +HAPI Evas_Object *item_create(Evas_Object *scroller, app_info_t* ai) +{ + Evas_Object *item; + Evas_Object *bg; + + char *item_edje; + int item_width; + int item_height; + + item_edje = evas_object_data_get(scroller, "item_edje"); + item = layout_load_edj(scroller, item_edje, ITEM_GROUP_NAME); + if (!item) { + _E("Failed to load an item object"); + return NULL; + } + + Evas_Object *item_focus = NULL; + Evas_Object *focus = NULL; + + do { // focus + item_focus = elm_button_add(item); + retv_if(NULL == item_focus, NULL); + + elm_object_style_set(item_focus, "focus"); + elm_object_part_content_set(item, "focus", item_focus); + elm_access_info_cb_set(item_focus, ELM_ACCESS_INFO, _access_info_cb, item); + evas_object_smart_callback_add(item_focus, "clicked", _focus_clicked_cb, item); + } while (0); + + do { // make a button for a focus button of deleting. + focus = elm_button_add(item); + retv_if(NULL == focus, NULL); + + elm_object_style_set(focus, "focus"); + elm_object_part_content_set(item, "uninstall_focus", focus); + elm_access_info_cb_set(focus, ELM_ACCESS_INFO, _access_uninstall_cb, item); + evas_object_smart_callback_add(focus, "clicked", _uninstall_focus_clicked_cb, item); + } while (0); + + elm_object_focus_next_object_set(item_focus, focus, ELM_FOCUS_UP); + elm_object_focus_next_object_set(focus, item_focus, ELM_FOCUS_DOWN); + + bg = evas_object_rectangle_add(menu_screen_get_evas()); + if (!bg) { + _E("Cannot add an rectangle"); + evas_object_del(item); + return NULL; + } + + item_width = (int) evas_object_data_get(scroller, "item_width"); + item_height = (int) evas_object_data_get(scroller, "item_height"); + + evas_object_color_set(bg, 0, 0, 0, 0); + evas_object_resize(bg, item_width, item_height); + evas_object_size_hint_min_set(bg, item_width, item_height); + evas_object_size_hint_max_set(bg, item_width, item_height); + elm_object_part_content_set(item, "bg", bg); + + edje_object_text_class_set(_EDJ(item), "tizen", "TIZEN:style=medium", 24); + + evas_object_data_set(item, "win", evas_object_data_get(scroller, "win")); + evas_object_data_set(item, "layout", evas_object_data_get(scroller, "layout")); + evas_object_data_set(item, "controlbar", evas_object_data_get(scroller, "controlbar")); + evas_object_data_set(item, "tab", evas_object_data_get(scroller, "tab")); + evas_object_data_set(item, "scroller", scroller); + evas_object_data_set(item, "item_enable_long_press", evas_object_data_get(scroller, "item_enable_long_press")); + evas_object_data_set(item, "item_text_dual_line", evas_object_data_get(scroller, "item_text_dual_line")); + evas_object_data_set(item, "pending,idx", (void *) 0); + evas_object_data_set(item, "x", (void *) 0); + evas_object_data_set(item, "y", (void *) 0); + evas_object_data_set(item, "dirty", (void *) 0); + + item_update(item, ai); + item_event_register(item); + + return item; +} + + + +HAPI void item_destroy(Evas_Object *item) +{ + Evas_Object *icon; + Evas_Object *bg; + Evas_Object *page; + Eina_List *pending_list; + Eina_List *n; + Eina_List *t; + Evas_Object *pend_item; + int pending_idx; + const char *icon_image_type; + + ret_if(NULL == item); + + page = item_get_page(item); + pending_list = evas_object_data_get(page, "pending,list"); + EINA_LIST_FOREACH_SAFE(pending_list, n, t, pend_item) { + if (pend_item == item) { + pending_idx = (int)evas_object_data_get(pend_item, "pending,idx"); + pending_list = eina_list_remove(pending_list, pend_item); + evas_object_data_set(page, "pending,list", pending_list); + evas_object_data_del(pend_item, "pending,idx"); + } + } + + if (item_badge_is_registered(item)) { + item_badge_unregister(item); + } + item_event_unregister(item); + + item_set_package(item, NULL, 1); + item_set_desktop(item, NULL, 1); + item_set_name(item, NULL, 1); + item_set_icon(item, NULL, 1); + item_set_page(item, NULL, 1); + evas_object_data_del(item, STR_ATTRIBUTE_REMOVABLE); + evas_object_data_del(item, "pid"); + evas_object_data_del(_EDJ(item), "evas_object"); + bg = elm_object_part_content_unset(item, "bg"); + if (bg) { + evas_object_del(bg); + } + + elm_object_part_content_unset(item, "icon_image"); + icon = evas_object_data_del(item, "icon_image"); + icon_image_type = evas_object_data_get(item, "icon_image_type"); + if (icon_image_type) { + if (!strcmp(icon_image_type, STR_ICON_IMAGE_TYPE_OBJECT)) { + evas_object_del(icon); + } else if (!strcmp(icon_image_type, STR_ICON_IMAGE_TYPE_EDJE)) { + layout_unload_edj(icon); + } + } + + evas_object_data_del(item, "win"); + evas_object_data_del(item, "layout"); + evas_object_data_del(item, "controlbar"); + evas_object_data_del(item, "tab"); + evas_object_data_del(item, "scroller"); + evas_object_data_del(item, "item_enable_long_press"); + evas_object_data_del(item, "item_text_dual_line"); + evas_object_data_del(item, "pending,idx"); + evas_object_data_del(item, "x"); + evas_object_data_del(item, "y"); + evas_object_data_del(item, "dirty"); + + do { + Evas_Object *focus = NULL; + focus = elm_object_part_content_unset(item, "focus"); + if (NULL == focus) break; + evas_object_smart_callback_del(focus, "clicked", _focus_clicked_cb); + evas_object_del(focus); + } while (0); + + do { + Evas_Object *focus = NULL; + focus = elm_object_part_content_unset(item, "uninstall_focus"); + if (NULL == focus) break; + evas_object_smart_callback_del(focus, "clicked", _uninstall_focus_clicked_cb); + evas_object_del(focus); + } while (0); + + layout_unload_edj(item); +} + + + +static Eina_Bool _unblock_cb(void *data) +{ + Evas_Object *layout; + layout = evas_object_data_get(menu_screen_get_win(), "layout"); + layout_disable_block(layout); + return EINA_FALSE; +} + + + +static void _run_cb(bundle *b, int request_code, appsvc_result_val result, void *data) +{ +} + + + +HAPI void item_launch(Evas_Object *obj) +{ + char *package; + char *name; + int ret_aul; + Evas_Object *layout; + + ret_if(NULL == obj); + + name = item_get_name(obj); + package = item_get_package(obj); + ret_if(NULL == package); + + layout = evas_object_data_get(menu_screen_get_win(), "layout"); + layout_enable_block(layout); + + bool is_shortcut = (bool) evas_object_data_get(obj, "is_shortcut"); + bool shortcut_launch_package = (bool) evas_object_data_get(obj, "shortcut_launch_package"); + if (is_shortcut && !shortcut_launch_package) { + bundle *b = NULL; + b = bundle_create(); + ret_if(NULL == b); + + appsvc_set_operation(b, APPSVC_OPERATION_VIEW); + appsvc_set_uri(b, evas_object_data_get(obj, "content_info")); + + int ret = -1; + ret = appsvc_run_service(b, 0, _run_cb, NULL); + if (0 > ret) { + _E("cannot run service. ret [%d]", ret); + layout_disable_block(layout); + } else { + _D("Launch app's ret : [%d]", ret); + ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, NULL); + } + + bundle_free(b); + } else { + ret_aul = aul_open_app(package); + if (ret_aul == AUL_R_EINVAL) { + char* sinform; + int len; + + if (!name) { + name = package; + } + + // IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS : "Unable to launch %s" + len = strlen(D_("IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS")) + strlen(name) + 1; + + sinform = calloc(len, sizeof(char)); + if (!sinform) { + _E("cannot calloc for popup."); + return; + } + + snprintf(sinform, len, D_("IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS"), name); + popup_create_confirm(layout, sinform); + + free(sinform); + layout_disable_block(layout); + } else { + _D("Launch app's ret : [%d]", ret_aul); + _T(package); + ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, NULL); + } + } +} + + + +HAPI int item_get_position(Evas_Object *item) +{ + Evas_Object *scroller; + Evas_Object *layout; + + Evas_Coord item_x; + Evas_Coord item_y; + + Evas_Coord scroller_x; + Evas_Coord scroller_y; + Evas_Coord scroller_w; + Evas_Coord scroller_h; + + int layout_width; + + int items_per_line; + int nth_line; + int nth_item; + + int item_width; + int item_height; + + layout = evas_object_data_get(item, "layout"); + scroller = evas_object_data_get(item, "scroller"); + + layout_width = (int) evas_object_data_get(layout, "width"); + item_width = (int) evas_object_data_get(scroller, "item_width"); + item_height = (int) evas_object_data_get(scroller, "item_height"); + + evas_object_geometry_get(item, &item_x, &item_y, NULL, NULL); + evas_object_geometry_get(scroller, &scroller_x, &scroller_y, &scroller_w, &scroller_h); + + if (item_x < ((float) layout_width) * 0.005f) { + return -1; + } + + if (item_x + ((float) item_width * 0.85f) > ((float) layout_width) * 0.98f) { + return (int) evas_object_data_get(scroller, "page_max_app"); + } + + if (0 == item_width || 0 == item_height) { + _E("item_widht or item_heiht is zero."); + return 0; + } + + items_per_line = scroller_w / item_width; + nth_line = (item_y - (float) item_height * 0.3) / item_height; + nth_line = nth_line < 0 ? 0 : nth_line; + nth_item = (item_x + (float) item_width * 0.5) / item_width; + + return (nth_line * items_per_line) + nth_item; +} + + + +HAPI void item_mark_dirty(Evas_Object *item) +{ + evas_object_data_set(item, "dirty", (void *) 1); +} + + + +HAPI void item_unmark_dirty(Evas_Object *item) +{ + evas_object_data_set(item, "dirty", (void *) 0); +} + + + +HAPI int item_is_dirty(Evas_Object *item) +{ + return (int) evas_object_data_get(item, "dirty"); +} + + + +// End of a file diff --git a/src/item_badge.c b/src/item_badge.c new file mode 100644 index 0000000..aa95272 --- /dev/null +++ b/src/item_badge.c @@ -0,0 +1,180 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include + +#include "menu_screen.h" +#include "conf.h" +#include "item.h" +#include "page_scroller.h" +#include "util.h" + + + +HAPI int item_badge_count(char *package) +{ + unsigned int is_display = 0; + unsigned int count = 0; + badge_error_e err = BADGE_ERROR_NONE; + + err = badge_get_display(package, &is_display); + if (BADGE_ERROR_NONE != err) _D("cannot get badge display"); + + if (0 == is_display) return 0; + + err = badge_get_count(package, &count); + if (BADGE_ERROR_NONE != err) _D("cannot get badge count"); + + _D("Badge for package %s : %u", package, count); + + return (int) count; +} + + + +static Eina_Bool _idler_cb(void *data) +{ + char *package; + int count; + Evas_Object *item = data; + + package = item_get_package(item); + if (!package) { + _D("Failed to get a package name"); + evas_object_data_del(item, "idle_timer"); + return ECORE_CALLBACK_CANCEL; + } + + count = item_badge_count(package); + if (count) item_show_badge(item, count); + else item_hide_badge(item); + + evas_object_data_del(item, "idle_timer"); + + return ECORE_CALLBACK_CANCEL; +} + + + +HAPI bool item_badge_is_registered(Evas_Object *item) +{ + const char *pkgname; + badge_error_e err; + bool existing = false; + + pkgname = item_get_package(item); + retv_if(NULL == pkgname, false); + + err = badge_is_existing(pkgname, &existing); + if (BADGE_ERROR_NONE != err) _E("cannot know whether the badge for %s is or not.", pkgname); + + return existing? true : false; +} + + + +HAPI menu_screen_error_e item_badge_register(Evas_Object *item) +{ + Ecore_Idler *idle_timer; + bool is_registered; + + is_registered = item_badge_is_registered(item); + if (false == is_registered) return MENU_SCREEN_ERROR_OK; + + idle_timer = ecore_idler_add(_idler_cb, item); + retv_if(NULL == idle_timer, MENU_SCREEN_ERROR_FAIL); + evas_object_data_set(item, "idle_timer", idle_timer); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI void item_badge_unregister(Evas_Object *item) +{ + char *package; + Ecore_Idler *idle_timer; + + package = item_get_package(item); + if (!package) return; + + idle_timer = evas_object_data_get(item, "idle_timer"); + if (idle_timer) { + _D("Badge handler for package %s is not yet ready", package); + evas_object_data_del(item, "idle_timer"); + ecore_idler_del(idle_timer); + return; + } + + item_hide_badge(item); +} + + + +static void _badge_change_cb(unsigned int action, const char *pkgname, unsigned int count, void *data) +{ + Evas_Object *scroller = data; + Evas_Object *item; + unsigned int is_display = 0; + badge_error_e err; + + _D("Badge changed, action : %u, pkgname : %s, count : %u", action, pkgname, count); + + ret_if(NULL == pkgname); + + if (BADGE_ACTION_REMOVE == action) { + count = 0; + is_display = false; + } else { + err = badge_get_display(pkgname, &is_display); + if (BADGE_ERROR_NONE != err) _D("cannot get badge display"); + if (0 == is_display) count = 0; + } + + item = page_scroller_find_item_by_package(scroller, pkgname, NULL); + if (NULL == item) return; + + if (count) item_show_badge(item, count); + else item_hide_badge(item); +} + + + +HAPI void item_badge_register_changed_cb(Evas_Object *scroller) +{ + badge_error_e err; + + err = badge_register_changed_cb(_badge_change_cb, scroller); + ret_if(BADGE_ERROR_NONE != err); +} + + + +HAPI void item_badge_unregister_changed_cb(void) +{ + badge_error_e err; + + err = badge_unregister_changed_cb(_badge_change_cb); + ret_if(BADGE_ERROR_NONE != err); +} + + + +// End of a file diff --git a/src/item_event.c b/src/item_event.c new file mode 100644 index 0000000..4b9ef37 --- /dev/null +++ b/src/item_event.c @@ -0,0 +1,156 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include + +#include "menu_screen.h" +#include "conf.h" +#include "item.h" +#include "item_event.h" +#include "mapbuf.h" +#include "mouse.h" +#include "page.h" +#include "page_scroller.h" +#include "pkgmgr.h" +#include "popup.h" +#include "util.h" +#include "all_apps/layout.h" + +#define LONG_PRESS_TIME 1.0f +#define BUFSZE 1024 + + + +static struct { + Evas_Object *pressed_item; +} item_event_info = { + .pressed_item = NULL, +}; + + + +static void _item_down_cb(void *data, Evas_Object *obj, const char* emission, const char* source) +{ + Evas_Object *icon_image; + Evas_Object *item; + bool item_enable_long_press; + + item = evas_object_data_get(obj, "item"); + item_enable_long_press = (bool) evas_object_data_get(item, "item_enable_long_press"); + + _D("ITEM: mouse down event callback is invoked for %p", item); + + item_event_info.pressed_item = item; + + icon_image = evas_object_data_get(item, "icon_image"); + evas_object_color_set(icon_image, 100, 100, 100, 100); + + if (!item_enable_long_press) { + return; + } +} + + + +static void _item_up_cb(void *data, Evas_Object *obj, const char* emission, const char* source) +{ + Evas_Object *icon_image; + Evas_Object *item; + + item = evas_object_data_get(obj, "item"); + ret_if(NULL == item); + + _D("ITEM: mouse up event callback is invoked for %p", item); + PRINT_APPFWK(); + + icon_image = evas_object_data_get(item, "icon_image"); + evas_object_color_set(icon_image, 255, 255, 255, 255); + + ret_if(NULL == item_event_info.pressed_item); + if (item != item_event_info.pressed_item) { + item_event_info.pressed_item = NULL; + return; + } + item_event_info.pressed_item = NULL; +} + + + +static void _uninstall_down_cb(void *data, Evas_Object *obj, const char* emission, const char* source) +{ + _D("Uninstall button is down"); + obj = evas_object_data_get(obj, "evas_object"); + if (obj) evas_object_data_set(obj, "removing", (void*)1); +} + + + +static void _uninstall_up_cb(void *item, Evas_Object *obj, const char* emission, const char* source) +{ + Evas_Object *win; + + ret_if(mouse_is_scrolling()); + + win = menu_screen_get_win(); + ret_if(NULL == win); + + _D("Uninstall button is up"); + obj = evas_object_data_get(obj, "evas_object"); + ret_if(NULL == obj); + ret_if(NULL == evas_object_data_get(obj, "removing")); + + evas_object_data_del(obj, "removing"); +} + + + +HAPI void item_event_register(Evas_Object *item) +{ + Evas_Object *item_edje; + item_edje = _EDJ(item); + evas_object_data_set(item_edje, "item", item); + + edje_object_signal_callback_add(item_edje, "item,down", "menu", _item_down_cb, NULL); + edje_object_signal_callback_add(item_edje, "item,up", "menu", _item_up_cb, NULL); + + edje_object_signal_callback_add(item_edje, "uninstall,down", "menu", _uninstall_down_cb, NULL); + edje_object_signal_callback_add(item_edje, "uninstall,up", "menu", _uninstall_up_cb, item); +} + + + +HAPI void item_event_unregister(Evas_Object *item) +{ + Evas_Object *item_edje; + item_edje = _EDJ(item); + + edje_object_signal_callback_del(item_edje, "item,down", "menu", _item_down_cb); + edje_object_signal_callback_del(item_edje, "item,up", "menu", _item_up_cb); + + edje_object_signal_callback_del(item_edje, "uninstall,down", "menu", _uninstall_down_cb); + edje_object_signal_callback_del(item_edje, "uninstall,up", "menu", _uninstall_up_cb); + + evas_object_data_del(item_edje, "item"); +} + + + +// End of a file diff --git a/src/key.c b/src/key.c new file mode 100644 index 0000000..c8130fb --- /dev/null +++ b/src/key.c @@ -0,0 +1,230 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include + +#include "conf.h" +#include "key.h" +#include "menu_screen.h" +#include "page_scroller.h" +#include "popup.h" +#include "util.h" +#include "all_apps/layout.h" + + + +static struct { + Eina_Bool pressed; + Ecore_Event_Handler *press_handler; + Ecore_Event_Handler *release_handler; + Eina_Bool register_handler; + Ecore_Timer *long_press; + Eina_Bool home_grabbed; +} key_info = { + .pressed = 0, + .press_handler = NULL, + .release_handler = NULL, + .register_handler = EINA_FALSE, + .long_press = NULL, + .home_grabbed = EINA_FALSE, +}; + + + +#define KEY_LEFT "Left" +#define KEY_RIGHT "Right" +#define KEY_UP "Up" +#define KEY_DOWN "Down" +#define KEY_ESC "Escape" +static Eina_Bool _key_release_cb(void *data, int type, void *event) +{ + Evas_Event_Key_Up *ev = event; + + retv_if(EINA_FALSE == key_info.register_handler, ECORE_CALLBACK_CANCEL); + retv_if(NULL == ev, ECORE_CALLBACK_CANCEL); + + _D("Key(%s) released %d", ev->keyname, key_info.pressed); + + if (key_info.pressed == EINA_FALSE) return ECORE_CALLBACK_CANCEL; + + do { + Evas_Object *win; + win = menu_screen_get_win(); + break_if(NULL == win); + + Evas_Object *layout; + layout = evas_object_data_get(win, "layout"); + break_if(NULL == layout); + + Evas_Object *all_apps; + all_apps = evas_object_data_get(layout, "all_apps"); + break_if(NULL == all_apps); + + Evas_Object *scroller = evas_object_data_get(all_apps, "scroller"); + break_if(NULL == scroller); + + if (!strcmp(ev->keyname, KEY_SELECT) || !strcmp(ev->keyname, KEY_BACK)) { + if (popup_exist()) { + popup_destroy_all(); + break; + } + + if (all_apps_layout_is_edited(all_apps)) { + all_apps_layout_unedit(all_apps); + } + } else if (!strcmp(ev->keyname, KEY_LEFT) || + !strcmp(ev->keyname, KEY_RIGHT) || + !strcmp(ev->keyname, KEY_UP) || + !strcmp(ev->keyname, KEY_DOWN)) + { + int cur_idx = page_scroller_get_current_page_no(scroller); + int idx = 0, x = 0, w = 0; + elm_scroller_region_get(scroller, &x, NULL, &w, NULL); + + if (w) idx = x / w; + if (cur_idx != idx) { + page_scroller_bring_in(scroller, idx); + break; + } + + /* If there are no items to be focused after pressing keys, + Menu-screen forces to focus the first item of the other page */ + int rest = x % w; + if (rest) { + page_scroller_focus_into_vector(scroller, rest > w / 2 ? -1 : 1); + } + } + else if (!strcmp(ev->keyname, KEY_ESC)) + { + if (popup_exist()) + { + popup_destroy_all(); + break; + } + if (all_apps_layout_is_edited(all_apps)) { + all_apps_layout_unedit(all_apps); + } + } + } while (0); + + key_info.pressed = EINA_FALSE; + + return ECORE_CALLBACK_CANCEL; +} + + + +static Eina_Bool _key_press_cb(void *data, int type, void *event) +{ + Evas_Event_Key_Down *ev = event; + + retv_if(EINA_FALSE == key_info.register_handler, ECORE_CALLBACK_CANCEL); + retv_if(NULL == ev, ECORE_CALLBACK_CANCEL); + + key_info.pressed = EINA_TRUE; + _D("Key pressed %d", key_info.pressed); + + return ECORE_CALLBACK_CANCEL; +} + + + +HAPI void key_register(void) +{ + if (!key_info.release_handler) { + key_info.release_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, NULL); + if (!key_info.release_handler) { + _E("Failed to register a key up event handler"); + } + } + + if (!key_info.press_handler) { + key_info.press_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, NULL); + if (!key_info.press_handler) { + _E("Failed to register a key down event handler"); + } + } + + key_info.pressed = EINA_FALSE; + key_info.register_handler = EINA_TRUE; +} + + + +HAPI void key_unregister(void) +{ + if (key_info.long_press) { + ecore_timer_del(key_info.long_press); + key_info.long_press = NULL; + } + + if (key_info.release_handler) { + ecore_event_handler_del(key_info.release_handler); + key_info.release_handler = NULL; + } + + if (key_info.press_handler) { + ecore_event_handler_del(key_info.press_handler); + key_info.press_handler = NULL; + } + + key_info.register_handler = EINA_FALSE; +} + + + +HAPI void key_grab_home(void) +{ + if (EINA_TRUE == key_info.home_grabbed) return; + + Ecore_X_Window win = elm_win_xwindow_get(menu_screen_get_win()); + Display* dpy = ecore_x_display_get(); + + int ret = utilx_grab_key(dpy, win, KEY_SELECT, TOP_POSITION_GRAB); + ret_if(0 != ret); + + ret = utilx_grab_key(dpy, win, KEY_BACK, TOP_POSITION_GRAB); + ret_if(0 != ret); + + key_info.home_grabbed = EINA_TRUE; +} + + + +HAPI void key_ungrab_home(void) +{ + if (key_info.home_grabbed == EINA_FALSE) return; + + Ecore_X_Window win = elm_win_xwindow_get(menu_screen_get_win()); + Display* dpy = ecore_x_display_get(); + + int ret = utilx_ungrab_key(dpy, win, KEY_SELECT); + ret_if(0 != ret); + + ret = utilx_ungrab_key(dpy, win, KEY_BACK); + ret_if(0 != ret); + + key_info.home_grabbed = EINA_FALSE; +} + + + +// End of a file diff --git a/src/layout.c b/src/layout.c new file mode 100644 index 0000000..8ac7374 --- /dev/null +++ b/src/layout.c @@ -0,0 +1,151 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include + +#include "menu_screen.h" +#include "conf.h" +#include "item_event.h" +#include "layout.h" +#include "mapbuf.h" +#include "page.h" +#include "item.h" +#include "util.h" +#include "all_apps/layout.h" + + + +HAPI Evas_Object *layout_create(Evas_Object *conformant, const char *file, const char *group, int rotate) +{ + Evas_Object *layout; + + do { + int width; + int height; + + layout = layout_load_edj(conformant, file, group); + retv_if(NULL == layout, NULL); + + width = menu_screen_get_root_width(); + height = menu_screen_get_root_height() - INDEX_HEIGHT; + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_min_set(layout, width, height); + evas_object_size_hint_max_set(layout, width, height); + evas_object_resize(layout, width, height); + evas_object_show(layout); + + evas_object_data_set(layout, "win", menu_screen_get_win()); + evas_object_data_set(layout, "rotate", (void *) rotate); + evas_object_data_set(layout, "width", (void *) width); + evas_object_data_set(layout, "height", (void *) height); + } while (0); + + do { + Evas_Object *all_apps; + + all_apps = all_apps_layout_create(layout, rotate); + if (NULL == all_apps) { + _E("Failed to create scroller"); + layout_destroy(layout); + return NULL; + } + evas_object_data_set(layout, "all_apps", all_apps); + elm_object_part_content_set(layout, "content", all_apps); + } while (0); + + return layout; +} + + + +HAPI void layout_destroy(Evas_Object *layout) +{ + Evas_Object *all_apps; + + all_apps = evas_object_data_del(layout, "all_apps"); + all_apps_layout_destroy(all_apps); + + evas_object_data_del(layout, "win"); + evas_object_data_del(layout, "rotate"); + evas_object_data_del(layout, "width"); + evas_object_data_del(layout, "height"); + + layout_unload_edj(layout); +} + + + +HAPI void layout_enable_block(Evas_Object *layout) +{ + ret_if(NULL == layout); + + _D("Enable layout blocker"); + edje_object_signal_emit(_EDJ(layout), "block", "layout"); +} + + + +HAPI void layout_disable_block(Evas_Object *layout) +{ + ret_if(NULL == layout); + + _D("Disable layout blocker"); + edje_object_signal_emit(_EDJ(layout), "unblock", "layout"); +} + + + +HAPI Evas_Object* layout_load_edj(Evas_Object *parent, const char *edjname, const char *grpname) +{ + Evas_Object *eo; + + retv_if(NULL == parent, NULL); + + eo = elm_layout_add(parent); + retv_if(NULL == eo, NULL); + retv_if(EINA_FALSE == elm_layout_file_set(eo, edjname, grpname), NULL); + + evas_object_data_set(_EDJ(eo), "evas_object", eo); + evas_object_show(eo); + + return eo; +} + + + +HAPI void layout_unload_edj(Evas_Object *layout) +{ + Evas_Object *evas_object; + + ret_if(NULL == layout); + + evas_object = evas_object_data_get(_EDJ(layout), "evas_object"); + if (evas_object) { + evas_object_data_del(_EDJ(layout), "evas_object"); + } + + evas_object_del(layout); +} + + + +// End of file diff --git a/src/list.c b/src/list.c new file mode 100644 index 0000000..94fe8df --- /dev/null +++ b/src/list.c @@ -0,0 +1,209 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include + +#include "list.h" +#include "util.h" +#include "all_apps/list.h" + + + +HAPI menu_screen_error_e list_count(app_list *list, int *count) +{ + retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == count, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + *count = eina_list_count(list->list); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e list_first(app_list *list) +{ + retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + list->cur_idx = 0; + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e list_next(app_list *list) +{ + int count; + + retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + count = eina_list_count(list->list); + if (list->cur_idx + 1 == count) return MENU_SCREEN_ERROR_NO_DATA; + + list->cur_idx ++; + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e list_is_ended(app_list *list, bool *flag) +{ + int count; + + retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + count = eina_list_count(list->list); + *flag = (list->cur_idx == count) ? true : false; + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e list_get_item(app_list *list, app_list_item **item) +{ + retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + *item = eina_list_nth(list->list, list->cur_idx); + + return MENU_SCREEN_ERROR_OK; +} + + + + +HAPI menu_screen_error_e list_get_values(const char *package, app_info_t *ai) +{ + ail_appinfo_h appinfo_h; + char *exec; + char *name; + char *icon; + ail_error_e ret; + + retv_if(NULL == package, MENU_SCREEN_ERROR_FAIL); + retv_if(NULL == ai, MENU_SCREEN_ERROR_FAIL); + retv_if(NULL == (ai->package = strdup(package)), MENU_SCREEN_ERROR_FAIL); + + ret = ail_get_appinfo(ai->package, &appinfo_h); + if (AIL_ERROR_OK == ret) { + do { + break_if(ail_appinfo_get_str(appinfo_h, AIL_PROP_EXEC_STR, &exec) < 0); + break_if(ail_appinfo_get_str(appinfo_h, AIL_PROP_NAME_STR, &name) < 0); + break_if(ail_appinfo_get_str(appinfo_h, AIL_PROP_ICON_STR, &icon) < 0); + break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_NODISPLAY_BOOL, &ai->nodisplay) < 0); + break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_X_SLP_ENABLED_BOOL, &ai->enabled) < 0); + break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_X_SLP_REMOVABLE_BOOL, &ai->x_slp_removable) < 0); + break_if(ail_appinfo_get_bool(appinfo_h, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &ai->x_slp_taskmanage) < 0); + + break_if(NULL == exec || NULL == (ai->exec = strdup(exec))); + break_if(NULL == name || NULL == (ai->name = strdup(name))); + break_if(NULL == icon || NULL == (ai->icon = strdup(icon))); + + ail_destroy_appinfo(appinfo_h); + + return MENU_SCREEN_ERROR_OK; + } while(0); + + ail_destroy_appinfo(appinfo_h); + list_free_values(ai); + return MENU_SCREEN_ERROR_FAIL; + } else if (AIL_ERROR_NO_DATA == ret) { + return MENU_SCREEN_ERROR_OK; + } + + return MENU_SCREEN_ERROR_FAIL; +} + + + +HAPI void list_free_values(app_info_t *ai) +{ + ret_if(NULL == ai); + + /* Origin field */ + if (ai->package) { + free(ai->package); + ai->package = NULL; + } + + if (ai->exec) { + free(ai->exec); + ai->exec = NULL; + } + + if (ai->name) { + free(ai->name); + ai->name = NULL; + } + + if (ai->icon) { + free(ai->icon); + ai->icon = NULL; + } +} + + + +HAPI menu_screen_error_e list_append_item(app_list *list, app_list_item *item) +{ + retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == item, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + list->list = eina_list_append(list->list, item); + retv_if(NULL == list->list, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e list_remove_item(app_list *list, app_list_item *item) +{ + retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == list->list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == item, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + list->list = eina_list_remove(list->list, item); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI menu_screen_error_e list_sort(app_list *list, int (*_sort_cb)(const void *d1, const void *d2)) +{ + retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + list->list = eina_list_sort(list->list, eina_list_count(list->list), _sort_cb); + retv_if(NULL == list->list, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +// End of a file diff --git a/src/mapbuf.c b/src/mapbuf.c new file mode 100644 index 0000000..af31932 --- /dev/null +++ b/src/mapbuf.c @@ -0,0 +1,219 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include + +#include "menu_screen.h" +#include "conf.h" +#include "layout.h" +#include "mapbuf.h" +#include "util.h" + + + +HAPI Evas_Object *mapbuf_get_mapbuf(Evas_Object *obj) +{ + Evas_Object *mapbuf; + + if (obj == NULL) return NULL; + + mapbuf = evas_object_data_get(obj, "mapbuf"); + if (!mapbuf && evas_object_data_get(obj, "page")) { + mapbuf = obj; + } + + return mapbuf; +} + + + +HAPI Evas_Object *mapbuf_get_page(Evas_Object *obj) +{ + Evas_Object *page; + + if (obj == NULL) return NULL; + + page = evas_object_data_get(obj, "page"); + if (!page && evas_object_data_get(obj, "mapbuf")) { + page = obj; + } + + return page; +} + + + +static void _move_pages(Evas_Object *page) +{ + if(NULL == page) return; + + Evas_Object *scroller = evas_object_data_get(page, "scroller"); + if(NULL == scroller) return; + + Evas_Coord x, y; + evas_object_geometry_get(scroller, &x, &y, NULL, NULL); + evas_object_move(page, x, y); +} + + + +HAPI menu_screen_error_e mapbuf_enable(Evas_Object *obj, int force) +{ + Evas_Object *mapbuf; + int cnt; + + mapbuf = mapbuf_get_mapbuf(obj); + if (!mapbuf) { + _D("Failed to get the mapbuf object"); + return MENU_SCREEN_ERROR_FAIL; + } + + Evas_Object *page = mapbuf_get_page(obj); + if(!page) { + return MENU_SCREEN_ERROR_FAIL; + } + + if(menu_screen_is_tts()) { + evas_object_data_set(mapbuf, "mapbuf_enabled", (void*)0); + elm_mapbuf_enabled_set(mapbuf, 0); + return MENU_SCREEN_ERROR_OK; + } + + if (force) { + evas_object_data_set(mapbuf, "mapbuf_enabled", (void*)0); + _move_pages(page); + elm_mapbuf_enabled_set(mapbuf, 1); // Mapbuf has been disabled because of a mapbuf bug. + return MENU_SCREEN_ERROR_OK; + } + + cnt = (int)evas_object_data_get(mapbuf, "mapbuf_enabled"); + cnt ++; + evas_object_data_set(mapbuf, "mapbuf_enabled", (void*)cnt); + //_D("[%s] CNT = %d", __func__, cnt); + + if (cnt == 0) { + if (!elm_mapbuf_enabled_get(mapbuf)) { + _move_pages(page); + elm_mapbuf_enabled_set(mapbuf, 1); // Mapbuf has been disabled because of a mapbuf bug. + //_D("[%s] mapbuf enabled", __func__); + } + } + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI int mapbuf_is_enabled(Evas_Object *obj) +{ + Evas_Object *mapbuf; + mapbuf = mapbuf_get_mapbuf(obj); + if (!mapbuf) { + return 0; + } + + return elm_mapbuf_enabled_get(mapbuf); +} + + + +HAPI int mapbuf_disable(Evas_Object *obj, int force) +{ + Evas_Object *mapbuf; + int cnt; + + mapbuf = mapbuf_get_mapbuf(obj); + if (!mapbuf) { + _D("Failed to get the mapbuf object"); + return MENU_SCREEN_ERROR_FAIL; + } + + if (force) { + evas_object_data_set(mapbuf, "mapbuf_enabled", (void*)-1); + elm_mapbuf_enabled_set(mapbuf, 0); + return MENU_SCREEN_ERROR_OK; + } + + cnt = (int)evas_object_data_get(mapbuf, "mapbuf_enabled"); + if (cnt == 0) { + if (elm_mapbuf_enabled_get(mapbuf)) { + elm_mapbuf_enabled_set(mapbuf, 0); + //_D("[%s] disableld mapbuf", __func__); + } + } + + cnt --; + evas_object_data_set(mapbuf, "mapbuf_enabled", (void*)cnt); + //_D("[%s] CNT = %d", __func__, cnt); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI Evas_Object *mapbuf_bind(Evas_Object *box, Evas_Object *page) +{ + Evas_Object *mapbuf; + + mapbuf = elm_mapbuf_add(box); + if (!mapbuf) { + _D("Failed to create a new mapbuf"); + return NULL; + } + + elm_mapbuf_smooth_set(mapbuf, EINA_TRUE); + elm_mapbuf_alpha_set(mapbuf, EINA_TRUE); + elm_object_content_set(mapbuf, page); + + evas_object_data_set(page, "mapbuf", mapbuf); + evas_object_data_set(mapbuf, "page", page); + mapbuf_disable(mapbuf, 1); + evas_object_show(mapbuf); + + return mapbuf; +} + + + +HAPI Evas_Object *mapbuf_unbind(Evas_Object *obj) +{ + Evas_Object *page; + Evas_Object *mapbuf; + + page = evas_object_data_get(obj, "page"); + if (page) { + mapbuf = obj; + } else { + page = obj; + mapbuf = evas_object_data_get(obj, "mapbuf"); + } + + if (mapbuf) { + elm_mapbuf_enabled_set(mapbuf, 0); + evas_object_data_del(page, "mapbuf"); + evas_object_data_del(mapbuf, "page"); + evas_object_data_del(mapbuf, "mapbuf_enabled"); + page = elm_object_content_unset(mapbuf); + evas_object_del(mapbuf); + } + return page; +} + + + +// End of a file diff --git a/src/menu_screen.c b/src/menu_screen.c new file mode 100644 index 0000000..5ad84b9 --- /dev/null +++ b/src/menu_screen.c @@ -0,0 +1,627 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "conf.h" +#include "item.h" +#include "key.h" +#include "layout.h" +#include "mapbuf.h" +#include "menu_screen.h" +#include "mouse.h" +#include "page.h" +#include "page_scroller.h" +#include "util.h" + +#define MENU_SCREEN_ENGINE "file/private/org.tizen.menu-screen/engine" + +#define LAYOUT_EDJE_PORTRAIT EDJEDIR"/layout_portrait.edj" +#define LAYOUT_GROUP_NAME "layout" + + + +// Define prototype of the "hidden API of AUL" +extern int aul_listen_app_dead_signal(int (*func)(int signal, void *data), void *data); +static struct { + int state; + int root_width; + int root_height; + int is_tts; + Evas *evas; + Ecore_Evas *ee; + Evas_Object *win; + Elm_Theme *theme; + bool is_done; +} menu_screen_info = { + .state = APP_STATE_PAUSE, + .is_tts = false, + .evas = NULL, + .ee = NULL, + .win = NULL, + .theme = NULL, + .is_done = false, +}; + + + +HAPI Evas *menu_screen_get_evas(void) +{ + return menu_screen_info.evas; +} + + + +HAPI int menu_screen_get_root_width(void) +{ + return menu_screen_info.root_width; +} + + + +HAPI int menu_screen_get_root_height(void) +{ + return menu_screen_info.root_height; +} + + + +HAPI Evas_Object *menu_screen_get_win(void) +{ + return menu_screen_info.win; +} + + + +HAPI Elm_Theme *menu_screen_get_theme(void) +{ + return menu_screen_info.theme; +} + + + +HAPI bool menu_screen_get_done(void) +{ + return menu_screen_info.is_done; +} + + + +HAPI void menu_screen_set_done(bool is_done) +{ + menu_screen_info.is_done = is_done; +} + + + +HAPI int menu_screen_get_state(void) +{ + return menu_screen_info.state; +} + + + +HAPI int menu_screen_is_tts(void) +{ + return menu_screen_info.is_tts; +} + + + +static menu_screen_error_e _create_canvas(char *name, char *title) +{ + Ecore_X_Atom ATOM_WM_WINDOW_ROLE; + + menu_screen_info.win = elm_win_add(NULL, name, ELM_WIN_BASIC); + retv_if(NULL == menu_screen_info.win, MENU_SCREEN_ERROR_FAIL); + + if (title) { + elm_win_title_set(menu_screen_info.win, title); + } + elm_win_borderless_set(menu_screen_info.win, EINA_TRUE); + + ecore_x_icccm_name_class_set(elm_win_xwindow_get(menu_screen_info.win), "MENU_SCREEN", "MENU_SCREEN"); + ATOM_WM_WINDOW_ROLE = ecore_x_atom_get("WM_WINDOW_ROLE"); + if (ATOM_WM_WINDOW_ROLE) { + ecore_x_window_prop_string_set(elm_win_xwindow_get(menu_screen_info.win), ATOM_WM_WINDOW_ROLE, "MENU_SCREEN"); + } else { + _D("Failed to set the window role as MENU_SCREEN"); + } + + menu_screen_info.evas = evas_object_evas_get(menu_screen_info.win); + if (!menu_screen_info.evas) { + _E("[%s] Failed to get the evas object", __func__); + } + + menu_screen_info.ee = ecore_evas_ecore_evas_get(menu_screen_info.evas); + if (!menu_screen_info.ee) { + _E("[%s] Failed to get ecore_evas object", __func__); + } + + evas_object_size_hint_min_set(menu_screen_info.win, menu_screen_info.root_width, menu_screen_info.root_height); + evas_object_size_hint_max_set(menu_screen_info.win, menu_screen_info.root_width, menu_screen_info.root_height); + evas_object_resize(menu_screen_info.win, menu_screen_info.root_width, menu_screen_info.root_height); + evas_object_show(menu_screen_info.win); + + return MENU_SCREEN_ERROR_OK; +} + + + +static void _destroy_canvas(void) +{ + evas_object_del(menu_screen_info.win); +} + + + +static int _dead_cb(int pid, void *data) +{ + return EXIT_SUCCESS; +} + + + +static void _get_window_size(void) +{ + Ecore_X_Window focus_win; + Ecore_X_Window root_win; + + focus_win = ecore_x_window_focus_get(); + root_win = ecore_x_window_root_get(focus_win); + ecore_x_window_size_get(root_win, &menu_screen_info.root_width, &menu_screen_info.root_height); + + _D("width:%d, height:%d", menu_screen_info.root_width, menu_screen_info.root_height); +} + + + +static void _create_bg(void) +{ + char *buf; + Evas_Coord w; + Evas_Coord h; + Evas_Object *bg; + double f, wf, hf; + static int trigger = 0; + const char *key; + int width; + int height; + + buf = vconf_get_str(VCONFKEY_BGSET); + ret_if(NULL == buf); + + width = menu_screen_get_root_width(); + height = menu_screen_get_root_height(); + + bg = evas_object_data_get(menu_screen_get_win(), "bg"); + if (NULL == bg) { + Evas_Object *rect; + + rect = evas_object_rectangle_add(menu_screen_get_evas()); + ret_if(NULL == rect); + evas_object_data_set(menu_screen_get_win(), "rect", rect); + evas_object_color_set(rect, 0, 0, 0, 255); + evas_object_size_hint_min_set(rect, width, height); + evas_object_size_hint_max_set(rect, width, height); + evas_object_resize(rect, width, height); + evas_object_show(rect); + + bg = evas_object_image_add(menu_screen_get_evas()); + if (NULL == bg) { + free(buf); + return; + } + evas_object_image_load_orientation_set(bg, EINA_TRUE); + evas_object_data_set(menu_screen_get_win(), "bg", bg); + } + + if (trigger == 0) { + key = "/"; + trigger = 1; + } else { + key = NULL; + trigger = 0; + } + + evas_object_image_file_set(bg, buf, key); + evas_object_image_size_get(bg, &w, &h); + evas_object_image_filled_set(bg, 1); + + wf = (double) width / (double) w; + hf = (double) height / (double) h; + + f = wf < hf ? hf : wf; + + w = (int) ((double) f * (double) w); + h = (int) ((double) f * (double) h); + + evas_object_image_load_size_set(bg, w, h); + evas_object_image_fill_set(bg, 0, 0, w, h); + evas_object_move(bg, (width - w) / 2, (height - h) / 2); + evas_object_resize(bg, w, h); + evas_object_show(bg); + + free(buf); +} + + + + +static void _destroy_bg() +{ + Evas_Object *rect; + Evas_Object *bg; + + rect = evas_object_data_del(menu_screen_get_win(), "rect"); + evas_object_del(rect); + + bg = evas_object_data_del(menu_screen_get_win(), "bg"); + evas_object_del(bg); +} + + + +static void _change_bg_cb(keynode_t *node, void *data) +{ + _D("Background image is changed."); + _create_bg(); +} + + + +static void _init_theme(void) +{ + menu_screen_info.theme = elm_theme_new(); + elm_theme_ref_set(menu_screen_info.theme, NULL); + elm_theme_extension_add(menu_screen_info.theme, EDJEDIR"/index.edj"); +} + + + +static void _fini_theme(void) +{ + elm_theme_extension_del(menu_screen_info.theme, EDJEDIR"/index.edj"); + elm_theme_free(menu_screen_info.theme); + menu_screen_info.theme = NULL; + +} + + + +static Evas_Object *_create_conformant(Evas_Object *win) +{ + Evas_Object *conformant; + + conformant = elm_conformant_add(win); + retv_if(NULL == conformant, NULL); + + elm_object_style_set(conformant, "nokeypad"); + evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_data_set(conformant, "win", win); + evas_object_show(conformant); + + elm_win_resize_object_add(win, conformant); + elm_win_conformant_set(win, EINA_TRUE); + + return conformant; +} + + + +static void _destroy_conformant(Evas_Object *conformant) +{ + evas_object_data_del(conformant, "win"); + evas_object_del(conformant); +} + + + +static void _tts_cb(keynode_t *node, void *data) +{ + _D("change tts"); + + int val = -1; + if (0 == vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &val) && + menu_screen_info.is_tts != val) + { + menu_screen_info.is_tts = val; + } +} + + + +static bool _create_cb(void *data) +{ + Evas_Object *conformant; + + _get_window_size(); + _init_theme(); + retv_if(MENU_SCREEN_ERROR_FAIL == _create_canvas(PACKAGE, PACKAGE), false); + elm_win_indicator_mode_set(menu_screen_info.win, ELM_WIN_INDICATOR_SHOW); + + if (vconf_notify_key_changed(VCONFKEY_BGSET, _change_bg_cb, NULL) < 0) { + _E("Failed to register a vconf cb for %s\n", VCONFKEY_BGSET); + } + _create_bg(); + + conformant = _create_conformant(menu_screen_info.win); + retv_if(NULL == conformant, false); + evas_object_data_set(menu_screen_info.win, "conformant", conformant); + + Evas_Object *layout; + layout = layout_create(conformant, LAYOUT_EDJE_PORTRAIT, + LAYOUT_GROUP_NAME, MENU_SCREEN_ROTATE_PORTRAIT); + if (NULL == layout) { + _E("Failed to load an edje object"); + evas_object_del(menu_screen_info.win); + return false; + } + evas_object_data_set(menu_screen_info.win, "layout", layout); + +if (vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, _tts_cb, NULL) < 0) { + _E("Failed to register the tts callback"); + } + retv_if(vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &menu_screen_info.is_tts) < 0, MENU_SCREEN_ERROR_FAIL); + + elm_object_content_set(conformant, layout); + mouse_register(); + aul_listen_app_dead_signal(_dead_cb, NULL); + key_register(); + + return true; +} + + + +static void _terminate_cb(void *data) +{ + Evas_Object *conformant; + Evas_Object *layout; + + if (vconf_ignore_key_changed(VCONFKEY_BGSET, _change_bg_cb) < 0) { + _E("Failed to remove bgset [%s]\n", VCONFKEY_BGSET); + } + + if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, _tts_cb) < 0) { + _E("Failed to ignore the alpha callback"); + } + + evas_object_hide(menu_screen_info.win); + + key_unregister(); + mouse_unregister(); + + layout = evas_object_data_del(menu_screen_info.win, "layout"); + if (layout) layout_destroy(layout); + + conformant = evas_object_data_del(menu_screen_info.win, "conformant"); + if (conformant) _destroy_conformant(conformant); + + _destroy_bg(); + _destroy_canvas(); + _fini_theme(); + evas_object_del(menu_screen_info.win); +} + + + +static void _pause_cb(void *data) +{ + _D("Pause start"); + + if (vconf_set_int(VCONFKEY_IDLE_SCREEN_TOP, VCONFKEY_IDLE_SCREEN_TOP_FALSE) < 0) { + _E("Failed to set %s to 0", VCONFKEY_IDLE_SCREEN_TOP); + } + + menu_screen_info.state = APP_STATE_PAUSE; +} + + + +static void _resume_cb(void *data) +{ + _D("START RESUME"); + + if (vconf_set_int(VCONFKEY_IDLE_SCREEN_TOP, VCONFKEY_IDLE_SCREEN_TOP_TRUE) < 0) { + _E("Failed to set %s to 1", VCONFKEY_IDLE_SCREEN_TOP); + } + + do { // Focus + Evas_Object *layout = evas_object_data_get(menu_screen_info.win, "layout"); + break_if(NULL == layout); + + Evas_Object *all_apps = evas_object_data_get(layout, "all_apps"); + break_if(NULL == all_apps); + + Evas_Object *scroller = elm_object_part_content_get(all_apps, "content"); + break_if(NULL == scroller); + + page_scroller_focus(scroller); + } while (0); + + menu_screen_info.state = APP_STATE_RESUME; +} + + + +static void _service_cb(service_h service, void *data) +{ + _D("START RESET : %d", menu_screen_info.state); + + if (vconf_set_int(VCONFKEY_IDLE_SCREEN_TOP, VCONFKEY_IDLE_SCREEN_TOP_TRUE) < 0) { + _E("Failed to set %s to 1", VCONFKEY_IDLE_SCREEN_TOP); + } + + do { // Focus + Evas_Object *layout = evas_object_data_get(menu_screen_info.win, "layout"); + break_if(NULL == layout); + + Evas_Object *all_apps = evas_object_data_get(layout, "all_apps"); + break_if(NULL == all_apps); + + Evas_Object *scroller = elm_object_part_content_get(all_apps, "content"); + break_if(NULL == scroller); + + page_scroller_focus(scroller); + } while (0); +} + + + +static void _language_changed_cb(void *data) +{ + register unsigned int i; + register unsigned int j; + unsigned int count; + Evas_Object *layout; + Evas_Object *all_apps; + Evas_Object *scroller; + Evas_Object *page; + Evas_Object *item; + unsigned int page_max_app; + + _D("Language is changed"); + + if (false == menu_screen_info.is_done) { + elm_exit(); + } + + layout = evas_object_data_get(menu_screen_info.win, "layout"); + ret_if(NULL == layout); + all_apps = evas_object_data_get(layout, "all_apps"); + ret_if(NULL == all_apps); + scroller = elm_object_part_content_get(all_apps, "content"); + ret_if(NULL == scroller); + + count = page_scroller_count_page(scroller); + page_max_app = (unsigned int) evas_object_data_get(scroller, "page_max_app"); + for (i = 0; i < count; i ++) { + page = page_scroller_get_page_at(scroller, i); + if (!page) continue; + if (mapbuf_is_enabled(page)) { + mapbuf_disable(page, 1); + } + + for (j = 0; j < page_max_app; j ++) { + ail_appinfo_h ai; + char *name; + + item = page_get_item_at(page, j); + if (!item) continue; + + if (ail_get_appinfo(item_get_package(item), &ai) < 0) continue; + if (ail_appinfo_get_str(ai, AIL_PROP_NAME_STR, &name) < 0) { + ail_destroy_appinfo(ai); + continue; + } + + if (!name) { + _D("Failed to get name for %s", item_get_package(item)); + ail_destroy_appinfo(ai); + continue; + } + + item_set_name(item, name, 0); + ail_destroy_appinfo(ai); + } + + mapbuf_enable(page, 1); + } +} + + + +static void _init(app_event_callback_s *event_callback) +{ + event_callback->create = _create_cb; + event_callback->terminate = _terminate_cb; + event_callback->pause = _pause_cb; + event_callback->resume = _resume_cb; + event_callback->service = _service_cb; + event_callback->low_memory = NULL; + event_callback->low_battery = NULL; + event_callback->device_orientation = NULL; + event_callback->language_changed = _language_changed_cb; + event_callback->region_format_changed = NULL; +} + + + +static void _fini(void) +{ +} + + + +#define QP_EMUL_STR "Emulator" +static bool _is_emulator_on(void) +{ + char *info; + + if (system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &info) == 0) { + if (info == NULL) return false; + if (!strncmp(QP_EMUL_STR, info, strlen(info))) { + return true; + } + } + + return false; +} + + + +int main(int argc, char *argv[]) +{ + char *buf; + app_event_callback_s event_callback; + + if (_is_emulator_on()) { + _D("ELM_ENGINE is set as [software_x11]"); + setenv("ELM_ENGINE", "software_x11", 1); + } else { + buf = vconf_get_str(MENU_SCREEN_ENGINE); + if (buf) { + _D("ELM_ENGINE is set as [%s]", buf); + setenv("ELM_ENGINE", buf, 1); + free(buf); + } else { + _D("ELM_ENGINE is set as [gl]"); + setenv("ELM_ENGINE", "gl", 1); + } + } + + _init(&event_callback); + app_efl_main(&argc, &argv, &event_callback, NULL); + _fini(); + + return EXIT_SUCCESS; +} + + + + + +// End of a file diff --git a/src/mouse.c b/src/mouse.c new file mode 100644 index 0000000..e27d284 --- /dev/null +++ b/src/mouse.c @@ -0,0 +1,191 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include +#include +#include + +#include "menu_screen.h" +#include "conf.h" +#include "item.h" +#include "mouse.h" +#include "page.h" +#include "page_scroller.h" +#include "util.h" + +#define CHAGNE_POSITION_TIME 0.1f +#define CHANGE_POSITION_COUNT 5 +#define MOVE_THRESHOLD 10 + + + +static struct { + Ecore_Event_Handler *mouse_down; + Ecore_Event_Handler *mouse_up; + Ecore_Event_Handler *mouse_move; + bool pressed; + + Evas_Coord pre_x; + Evas_Coord pre_y; + bool is_initialized; + + Evas_Coord down_x; + Evas_Coord down_y; + Evas_Coord move_x; + Evas_Coord move_y; +} mouse_info = { + .mouse_down = NULL, + .mouse_up = NULL, + .mouse_move = NULL, + .pressed = false, + + .pre_x = 0, + .pre_y = 0, + .is_initialized = false, + + .down_x = 0, + .down_y = 0, + .move_x = 0, + .move_y = 0, +}; + + + +HAPI bool mouse_is_scrolling(void) +{ + bool scroll_x = false; + bool scroll_y = false; + + if (mouse_info.move_x > mouse_info.down_x + MOVE_THRESHOLD + || mouse_info.move_x < mouse_info.down_x - MOVE_THRESHOLD) + { + scroll_x = true; + } + + if (mouse_info.move_y > mouse_info.down_y + MOVE_THRESHOLD + || mouse_info.move_y < mouse_info.down_y - MOVE_THRESHOLD) + { + scroll_y = true; + } + + return scroll_x || scroll_y; +} + + + +static Eina_Bool _down_cb(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Button *move = event; + + retv_if(true == mouse_info.pressed, ECORE_CALLBACK_RENEW); + + _D("Mouse down (%d,%d)", move->root.x, move->root.y); + + mouse_info.pressed = true; + mouse_info.is_initialized = false; + + mouse_info.down_x = move->root.x; + mouse_info.down_y = move->root.y; + + return ECORE_CALLBACK_RENEW; +} + + + +static Eina_Bool _up_cb(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Button *move = event; + + _D("Mouse up (%d,%d)", move->root.x, move->root.y); + + retv_if(mouse_info.pressed == false, ECORE_CALLBACK_RENEW); + mouse_info.pressed = false; + mouse_info.pre_x = 0; + mouse_info.pre_y = 0; + + return ECORE_CALLBACK_RENEW; +} + + + +static Eina_Bool _move_cb(void *data, int type, void *event) +{ + Ecore_Event_Mouse_Move *move = event; + + mouse_info.move_x = move->root.x; + mouse_info.move_y = move->root.y; + + if (mouse_info.pressed == false) { + return ECORE_CALLBACK_RENEW; + } + + return ECORE_CALLBACK_RENEW; +} + + + +HAPI void mouse_register(void) +{ + mouse_info.mouse_down = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _down_cb, NULL); + if (!mouse_info.mouse_down) { + _D("Failed to register the mouse down event callback"); + } + + mouse_info.mouse_move = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _move_cb, NULL); + if (!mouse_info.mouse_move) { + _D("Failed to register the mouse move event callback"); + ecore_event_handler_del(mouse_info.mouse_down); + mouse_info.mouse_down = NULL; + } + + mouse_info.mouse_up = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _up_cb, NULL); + if (!mouse_info.mouse_up) { + _D("Failed to register the mouse up event callback"); + ecore_event_handler_del(mouse_info.mouse_down); + ecore_event_handler_del(mouse_info.mouse_move); + + mouse_info.mouse_down = NULL; + mouse_info.mouse_move = NULL; + } +} + + + +HAPI void mouse_unregister(void) +{ + if (mouse_info.mouse_down) { + ecore_event_handler_del(mouse_info.mouse_down); + mouse_info.mouse_down = NULL; + } + + if (mouse_info.mouse_up) { + ecore_event_handler_del(mouse_info.mouse_up); + mouse_info.mouse_up = NULL; + } + + if (mouse_info.mouse_move) { + ecore_event_handler_del(mouse_info.mouse_move); + mouse_info.mouse_move = NULL; + } +} + + + +// End of a file diff --git a/src/page.c b/src/page.c new file mode 100644 index 0000000..dffa633 --- /dev/null +++ b/src/page.c @@ -0,0 +1,568 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include + +#include "menu_screen.h" +#include "conf.h" +#include "index.h" +#include "item.h" +#include "item_event.h" +#include "layout.h" +#include "mapbuf.h" +#include "page.h" +#include "page_scroller.h" +#include "util.h" + +#define PAGE_GROUP_NAME "menu_bg" +#define PROP_PORTRAIT_HEIGHT (PAGE_PORTRAIT_HEIGHT / BASE_HEIGHT) + + + +HAPI inline void page_mark_dirty(Evas_Object *page) +{ + int value; + value = (int) evas_object_data_get(page, "dirty"); + evas_object_data_set(page, "dirty", (void*)(value + 1)); +} + + + +HAPI inline void page_unmark_dirty(Evas_Object *page) +{ + int value; + value = (int) evas_object_data_get(page, "dirty"); + if (value > 0) { + evas_object_data_set(page, "dirty", (void*)(value - 1)); + } +} + + + +HAPI inline void page_clean_dirty(Evas_Object *page) +{ + evas_object_data_set(page, "dirty", 0); +} + + + +HAPI inline int page_is_dirty(Evas_Object *page) +{ + return (int) evas_object_data_get(page, "dirty"); +} + + + +static menu_screen_error_e _insert_page_at(Evas_Object *scroller, Evas_Object *page, int index) +{ + unsigned int nr_of_pages; + Evas_Object *mapbuf; + Evas_Object *box; + + retv_if(NULL == page, MENU_SCREEN_ERROR_FAIL); + + if (index < 0) { + _D("Out of range"); + index = 0; + } + + box = evas_object_data_get(scroller, "box"); + retv_if(NULL == box, MENU_SCREEN_ERROR_FAIL); + + nr_of_pages = page_scroller_count_page(scroller); + if (index >= nr_of_pages) { + _D("Out of range. index : %d, total : %d", index, nr_of_pages); + mapbuf = evas_object_data_get(page, "mapbuf"); + if (mapbuf) { + elm_box_pack_end(box, mapbuf); + } else { + elm_box_pack_end(box, page); + } + } else { + Evas_Object *current; + Evas_Object *current_mapbuf; + const Eina_List *page_list; + + page_list = elm_box_children_get(box); + retv_if(NULL == page_list, MENU_SCREEN_ERROR_FAIL); + + current = eina_list_nth(page_list, index); + retv_if(NULL == current, MENU_SCREEN_ERROR_FAIL); + + current_mapbuf = mapbuf_get_mapbuf(current); + mapbuf = mapbuf_get_mapbuf(page); + + if (current_mapbuf && mapbuf) { + elm_box_pack_before(box, mapbuf, current_mapbuf); + } else if (!current_mapbuf && !mapbuf) { + elm_box_pack_before(box, page, current); + } else { + _D("Page has mapbuf, invalid"); + } + } + + page_mark_dirty(page); + + return MENU_SCREEN_ERROR_OK; +} + + + +static void _dim_down_cb(void *data, Evas_Object *obj, const char* emission, const char* source) +{ + _D("Dim down"); +} + + + +static void _dim_up_cb(void *data, Evas_Object *obj, const char* emission, const char* source) +{ + _D("Dim up"); +} + + + +HAPI Evas_Object *page_create(Evas_Object *scroller, int idx, int rotate) +{ + Evas_Object *page; + Evas_Object *bg; + Evas_Object *index; + Evas_Object *tab; + Evas_Object *mapbuf; + Evas_Object *box; + + char *page_edje; + bool enable_bg_image; + + unsigned int count; + int page_height; + int page_width; + + _D("Create a new page[%d]", idx); + + page_edje = evas_object_data_get(scroller, "page_edje"); + enable_bg_image = (bool) evas_object_data_get(scroller, "enable_bg_image"); + + page = layout_load_edj(scroller, page_edje, PAGE_GROUP_NAME); + retv_if(!page, NULL); + + edje_object_signal_callback_add(_EDJ(page), "dim,down", "menu", _dim_down_cb, NULL); + edje_object_signal_callback_add(_EDJ(page), "dim,up", "menu", _dim_up_cb, NULL); + + box = evas_object_data_get(scroller, "box"); + mapbuf = mapbuf_bind(box, page); + if (!mapbuf) { + _D("Failed to bind the object with mapbuf"); + } + + bg = evas_object_rectangle_add(menu_screen_get_evas()); + if (!bg) { + evas_object_del(page); + return NULL; + } + evas_object_color_set(bg, 0, 0, 0, 0); + + page_width = menu_screen_get_root_width(); + page_height = (int) ((double) PROP_PORTRAIT_HEIGHT * ((double) menu_screen_get_root_height())); + + evas_object_size_hint_min_set(bg, page_width, page_height); + evas_object_size_hint_max_set(bg, page_width, page_height); + + evas_object_size_hint_min_set(page, page_width, page_height); + evas_object_size_hint_max_set(page, page_width, page_height); + evas_object_resize(page, page_width, page_height); + + elm_object_part_content_set(page, "bg", bg); + + evas_object_data_set(page, "win", evas_object_data_get(scroller, "win")); + evas_object_data_set(page, "layout", evas_object_data_get(scroller, "layout")); + evas_object_data_set(page, "controlbar", evas_object_data_get(scroller, "controlbar")); + evas_object_data_set(page, "tab", evas_object_data_get(scroller, "tab")); + evas_object_data_set(page, "scroller", scroller); + evas_object_data_set(page, "page_edje", page_edje); + evas_object_data_set(page, "page_max_app", evas_object_data_get(scroller, "page_max_app")); + evas_object_data_set(page, "bg", bg); + evas_object_data_set(page, "pending,list", NULL); + evas_object_data_set(page, "dirty", (void *) 0); + + if (_insert_page_at(scroller, page, idx) != MENU_SCREEN_ERROR_OK) { + evas_object_del(bg); + evas_object_del(page); + return NULL; + } + + index = evas_object_data_get(scroller, "index"); + if (index) { + tab = evas_object_data_get(scroller, "tab"); + count = page_scroller_count_page(scroller); + index = index_update(tab, index, count); + evas_object_data_set(scroller, "index", index); + } + + return page; +} + + + +HAPI void page_destroy(Evas_Object *scroller, Evas_Object *page) +{ + Evas_Object *mapbuf; + Evas_Object *bg; + Evas_Object *item; + Evas_Object *box; + Evas_Object *index; + Evas_Object *tab; + Eina_List *pending_list; + + register unsigned int i; + int page_max_app; + unsigned int count; + + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + for (i = 0; i < page_max_app; i ++) { + item = page_unpack_item_at(page, i); + if (!item) continue; + + item_destroy(item); + } + + pending_list = evas_object_data_get(page, "pending,list"); + eina_list_free(pending_list); + + bg = evas_object_data_get(page, "bg"); + evas_object_del(bg); + + box = evas_object_data_get(scroller, "box"); + ret_if(NULL == box); + + mapbuf = mapbuf_get_mapbuf(page); + if (mapbuf) { + elm_box_unpack(box, mapbuf); + mapbuf_unbind(mapbuf); + } else { + elm_box_unpack(box, page); + } + + index = evas_object_data_get(scroller, "index"); + tab = evas_object_data_get(scroller, "tab"); + if (index && tab) { + count = page_scroller_count_page(scroller); + if (count) { + index = index_update(tab, index, count); + evas_object_data_set(scroller, "index", index); + } + else { + index_destroy(index); + evas_object_data_set(scroller, "index", NULL); + } + } + + evas_object_data_del(page, "win"); + evas_object_data_del(page, "layout"); + evas_object_data_del(page, "controlbar"); + evas_object_data_del(page, "tab"); + evas_object_data_del(page, "scroller"); + evas_object_data_del(page, "page_edje"); + evas_object_data_del(page, "page_max_app"); + evas_object_data_del(page, "bg"); + evas_object_data_del(page, "pending,list"); + evas_object_data_del(page, "dirty"); + layout_unload_edj(page); +} + + + +HAPI Evas_Object *page_get_item_at(Evas_Object *page, unsigned int idx) +{ + Eina_List *pending_list; + Eina_List *n; + Eina_List *t; + + Evas_Object *pending_item; + + char swallow_name[PATH_MAX]; + int pending_idx; + + pending_list = evas_object_data_get(page, "pending,list"); + EINA_LIST_FOREACH_SAFE(pending_list, n, t, pending_item) { + pending_idx = (int) evas_object_data_get(pending_item, "pending,idx"); + if (pending_idx == idx) { + return pending_item; + } + } + + snprintf(swallow_name, sizeof(swallow_name), "menu_swallow_%d", idx); + + return edje_object_part_swallow_get(_EDJ(page), swallow_name); +} + + + +HAPI menu_screen_error_e page_unpack_item(Evas_Object *page, Evas_Object *item) +{ + char tmp[PATH_MAX]; + Evas_Object *check_item; + + Eina_List *pending_list; + Eina_List *n; + Eina_List *t; + Evas_Object *pend_item; + int pending_idx = -1; + + retv_if(NULL == item, MENU_SCREEN_ERROR_FAIL); + + pending_list = evas_object_data_get(page, "pending,list"); + EINA_LIST_FOREACH_SAFE(pending_list, n, t, pend_item) { + if (pend_item == item) { + pending_idx = (int)evas_object_data_get(pend_item, "pending,idx"); + pending_list = eina_list_remove(pending_list, pend_item); + evas_object_data_set(page, "pending,list", pending_list); + } + } + + retv_if(pending_idx == -1, MENU_SCREEN_ERROR_FAIL); + sprintf(tmp, "menu_swallow_%d", pending_idx); + + check_item = edje_object_part_swallow_get(_EDJ(page), tmp); + retv_if(check_item != item, MENU_SCREEN_ERROR_FAIL); + + check_item = elm_object_part_content_unset(page, tmp); + if (check_item) { + elm_object_part_content_set(page, tmp, NULL); + page_mark_dirty(page); + } + + mapbuf_disable(page, 1); + mapbuf_enable(page, 1); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI Evas_Object *page_unpack_item_at(Evas_Object *page, int idx) +{ + Eina_List *pending_list; + Eina_List *n; + Eina_List *t; + + Evas_Object *object; + Evas_Object *pending_item; + + char tmp[PATH_MAX]; + int pending_idx; + + pending_list = evas_object_data_get(page, "pending,list"); + EINA_LIST_FOREACH_SAFE(pending_list, n, t, pending_item) { + pending_idx = (int) evas_object_data_get(pending_item, "pending,idx"); + if (pending_idx == idx) { + pending_list = eina_list_remove(pending_list, pending_item); + evas_object_data_set(page, "pending,list", pending_list); + } + } + + object = page_get_item_at(page, idx); + if (object) { + Evas_Object *check_object; + sprintf(tmp, "menu_swallow_%d", idx); + + check_object = elm_object_part_content_unset(page, tmp); + if (check_object != object) { + elm_object_part_content_set(page, tmp, NULL); + _D("page_unpack_item_at - different object is picked up"); + } + + page_mark_dirty(page); + } + + mapbuf_disable(page, 1); + mapbuf_enable(page, 1); + + return object; +} + + + +HAPI void page_pack_item(Evas_Object *page, int idx, Evas_Object *item) +{ + char tmp[PATH_MAX]; + Evas_Object *object; + Eina_List *list; + + ret_if(NULL == page); + ret_if(NULL == item); + + list = evas_object_data_get(page, "pending,list"); + if (NULL == eina_list_data_find(list, item)) { + list = eina_list_append(list, item); + evas_object_data_set(page, "pending,list", list); + } + evas_object_data_set(item, "pending,idx", (void*)idx); + + mapbuf_disable(page, 0); + + snprintf(tmp, sizeof(tmp), "menu_swallow_%d", idx); + object = elm_object_part_content_unset(page, tmp); + if (object) { + elm_object_part_content_set(page, tmp, NULL); + item_destroy(object); + } + + item_set_page(item, page, 1); + item_mark_dirty(item); + elm_object_part_content_set(page, tmp, item); + page_mark_dirty(page); + + mapbuf_disable(page, 1); + mapbuf_enable(page, 1); +} + + + +HAPI void page_set_item(Evas_Object *page, int idx, Evas_Object *item) +{ + Eina_List *list; + + ret_if(NULL == page); + ret_if(NULL == item); + + list = evas_object_data_get(page, "pending,list"); + if (NULL == eina_list_data_find(list, item)) { + list = eina_list_append(list, item); + evas_object_data_set(page, "pending,list", list); + } + evas_object_data_set(item, "pending,idx", (void *) idx); + + item_set_page(item, page, 1); + + mapbuf_disable(page, 1); + mapbuf_enable(page, 1); +} + + + +HAPI inline unsigned int page_count_item(Evas_Object *page) +{ + register unsigned int i; + unsigned int count = 0; + int page_max_app; + + page_max_app = (int) evas_object_data_get(page, "page_max_app"); + for (i = 0; i < page_max_app; i++) { + if (page_get_item_at(page, i)) { + count ++; + } + } + + return count; +} + + + +HAPI int page_find_empty_near(Evas_Object *page, int pivot) +{ + int pivot_saved = pivot; + Evas_Object *obj; + int page_max_app; + + retv_if(NULL == page, -1); + + obj = page_get_item_at(page, pivot); + if (NULL == obj) return pivot; + + for (pivot --; pivot >= 0; pivot --) { + obj = page_get_item_at(page, pivot); + if (!obj) { + break; + } + } + + if (pivot >= 0) { + return (int) pivot; + } + + page_max_app = (int) evas_object_data_get(page, "page_max_app"); + for (pivot = pivot_saved + 1; pivot < page_max_app; pivot ++) { + obj = page_get_item_at(page, pivot); + if (!obj) break; + } + + if (pivot < page_max_app) { + return pivot; + } + + return -1; +} + + + +HAPI int page_find_first_empty(Evas_Object *page, int pivot) +{ + Evas_Object *item; + Evas_Object *scroller; + int idx; + int page_max_app; + + scroller = evas_object_data_get(page, "tab"); + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + + for (idx = pivot; idx < page_max_app; idx ++) { + item = page_get_item_at(page, idx); + if (!item) { + break; + } + } + + return idx; +} + + + +HAPI void page_trim_items(Evas_Object *page) +{ + Evas_Object *item; + register unsigned int i; + char buf[32]; + int to = -1; + int page_max_app; + + page_max_app = (int) evas_object_data_get(page, "page_max_app"); + for (i = 0; i < page_max_app; i ++) { + item = page_get_item_at(page, i); + if (!item) { + if (to < 0) { + to = i; + } + continue; + } + + if (to >= 0) { + item = page_unpack_item_at(page, i); + page_pack_item(page, to, item); + snprintf(buf, 32, "menu%d", to); + edje_object_signal_emit(_EDJ(page), STR_MOVE_NEXT, buf); + edje_object_signal_emit(_EDJ(page), STR_ANI_RETURN, buf); + to ++; + } + } +} + + + + +// End of a file diff --git a/src/page_scroller.c b/src/page_scroller.c new file mode 100644 index 0000000..aefcc49 --- /dev/null +++ b/src/page_scroller.c @@ -0,0 +1,1309 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include + +#include "item_badge.h" +#include "conf.h" +#include "index.h" +#include "item.h" +#include "item_event.h" +#include "layout.h" +#include "list.h" +#include "mapbuf.h" +#include "menu_screen.h" +#include "page.h" +#include "page_scroller.h" +#include "pkgmgr.h" +#include "util.h" + +#define BUFSZE 1024 +#define PAGE_SCROLL_SENSITIVE 0.2 +#define PROP_PORTRAIT_HEIGHT (PAGE_PORTRAIT_HEIGHT / BASE_HEIGHT) + + + +HAPI void page_scroller_bring_in(Evas_Object *scroller, int idx) +{ + Evas_Object *index; + int w, h; + + _D("BRING IN TO %d", idx); + + evas_object_data_set(scroller, "current_idx", (void *) idx); + + evas_object_geometry_get(scroller, NULL, NULL, &w, &h); + elm_scroller_region_bring_in(scroller, idx * w, 0, w, h); + + index = evas_object_data_get(scroller, "index"); + if (!index) { + _E("cannot find index."); + } + _D("page index bring in to %d", idx); + index_bring_in(index, idx); +} + + + +HAPI void page_scroller_show_region(Evas_Object *scroller, int idx) +{ + Evas_Object *index; + int w, h; + + evas_object_geometry_get(scroller, NULL, NULL, &w, &h); + elm_scroller_region_show(scroller, idx * w, 0, w, h); + + index = evas_object_data_get(scroller, "index"); + if (!index) { + _E("cannot find index."); + } + _D("page index bring in to %d", idx); + index_bring_in(index, idx); +} + + + +static void _anim_stop_cb(void *data, Evas_Object *scroller, void *event_info) +{ + _D("stop the scroller(%p) animation", scroller); + + /* page_scroller_focus & index_bring_in in _drag_stop_cb & _anim_stop_cb */ + Evas_Coord x, y, w, h; + elm_scroller_region_get(scroller, &x, &y, &w, &h); + + if (x % w) return; + + if(evas_object_data_get(scroller, "mouse_wheel_scroller_start")) { + // "page_scroller_bring_in" was invoked in "_mouse_wheel_cb", + // so condition cur_idx == idx will be true and "page_scroller_focus" won't be executed + // so "page_scroller_focus" is executed here. + evas_object_data_set(scroller, "mouse_wheel_scroller_start", (void *) 0); + page_scroller_focus(scroller); + } + + int cur_idx = page_scroller_get_current_page_no(scroller); + int idx = 0; + if (w) idx = x / w; + if (cur_idx == idx) return; + + page_scroller_bring_in(scroller, idx); + page_scroller_focus(scroller); +} + + + +static void _anim_start_cb(void *data, Evas_Object *scroller, void *event_info) +{ + _D("start the scroller(%p) animation", scroller); + + int drag_start = (int) evas_object_data_get(scroller, "drag_start"); + if (drag_start == 0) return; + evas_object_data_set(scroller, "drag_start", (void *) 0); +} + + + + + + +static void _drag_start_cb(void *data, Evas_Object *scroller, void *event_info) +{ + int previous_x; + + _D("Invoked"); + + elm_scroller_region_get(scroller, &previous_x, NULL, NULL, NULL); + evas_object_data_set(scroller, "previous_x", (void *) previous_x); + evas_object_data_set(scroller, "drag_start", (void *) 1); +} + + + +static void _drag_stop_cb(void *data, Evas_Object *scroller, void *event_info) +{ + Evas_Coord x, y, w, h; + int previous_x; + + _D("Invoked"); + + elm_scroller_region_get(scroller, &x, &y, &w, &h); + previous_x = (int) evas_object_data_get(scroller, "previous_x"); + if (x == previous_x) { + _D("Hold scroller (previous) %d (current) %d", previous_x, x); + } + + /* page_scroller_focus & index_bring_in in _drag_stop_cb & _anim_stop_cb */ + if (x % w) return; + + int cur_idx = page_scroller_get_current_page_no(scroller); + int idx = 0; + if (w) idx = x / w; + + if (cur_idx == idx) return; + + page_scroller_bring_in(scroller, idx); + page_scroller_focus(scroller); +} + + +static void _scroll_cb(void *data, Evas_Object *scroller, void *event_info) +{ + _drag_stop_cb(data, scroller, event_info); +} + + + +static menu_screen_error_e _find_position_by_default(Evas_Object *scroller, int *candidate_page, int *candidate_pos, void *data) +{ + Evas_Object *page; + Evas_Object *item; + register unsigned int page_no; + register unsigned int position_no; + unsigned int nr_of_pages; + int page_max_app; + + retv_if(NULL == scroller, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == candidate_page, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == candidate_pos, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + *candidate_page = 0; + *candidate_pos = 0; + nr_of_pages = page_scroller_count_page(scroller); + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + for (page_no = 0; page_no < nr_of_pages; page_no ++) { + page = page_scroller_get_page_at(scroller, page_no); + if (!page) { + _D("Page is not found at %d", page_no); + return MENU_SCREEN_ERROR_FAIL; + } + + for (position_no = 0; position_no < page_max_app; position_no ++) { + item = page_get_item_at(page, position_no); + if (!item) { + *candidate_page = page_no; + *candidate_pos = position_no; + return MENU_SCREEN_ERROR_OK; + } + } + } + + *candidate_page = page_no; + *candidate_pos = 0; + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _find_position_by_package(Evas_Object *scroller, int *candidate_page, int *candidate_pos, void *data) +{ + Evas_Object *page; + Evas_Object *item; + register int page_no; + register int position_no; + unsigned int nr_of_pages; + int page_max_app; + app_info_t *ai = data; + + retv_if(NULL == scroller, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == candidate_page, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == candidate_pos, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == data, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == ai->package, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + *candidate_page = 0; + *candidate_pos = 0; + nr_of_pages = page_scroller_count_page(scroller); + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + for (page_no = 0; page_no < nr_of_pages; page_no ++) { + page = page_scroller_get_page_at(scroller, page_no); + if (!page) { + _D("Page is not found at %d", page_no); + return MENU_SCREEN_ERROR_FAIL; + } + + for (position_no = 0; position_no < page_max_app; position_no ++) { + char *package; + + item = page_get_item_at(page, position_no); + if (!item) { + *candidate_page = page_no; + *candidate_pos = position_no; + return MENU_SCREEN_ERROR_OK; + } else if ((package = item_get_package(item)) && strcmp(package, ai->package) > 0) { + *candidate_page = page_no; + *candidate_pos = position_no; + return MENU_SCREEN_ERROR_OK; + } + } + } + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _find_position_by_name(Evas_Object *scroller, int *candidate_page, int *candidate_pos, void *data) +{ + Evas_Object *page; + Evas_Object *item; + register int page_no; + register int position_no; + unsigned int nr_of_pages; + int page_max_app; + app_info_t *ai = data; + + retv_if(NULL == scroller, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == candidate_page, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == candidate_pos, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == data, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == ai->name, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + *candidate_page = 0; + *candidate_pos = 0; + nr_of_pages = page_scroller_count_page(scroller); + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + for (page_no = 0; page_no < nr_of_pages; page_no ++) { + page = page_scroller_get_page_at(scroller, page_no); + if (!page) { + _D("Page is not found at %d", page_no); + return MENU_SCREEN_ERROR_FAIL; + } + + for (position_no = 0; position_no < page_max_app; position_no ++) { + char *name; + + item = page_get_item_at(page, position_no); + if (!item) { + *candidate_page = page_no; + *candidate_pos = position_no; + return MENU_SCREEN_ERROR_OK; + } else if ((name = item_get_name(item)) && strcmp(name, ai->name) > 0) { + *candidate_page = page_no; + *candidate_pos = position_no; + return MENU_SCREEN_ERROR_OK; + } + } + } + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _animated_pack_item(Evas_Object *item, Evas_Object *scroller, Evas_Object *page, int from) +{ + Evas_Object *item_out_page = NULL; + char buf[32]; + int to; + int page_no; + + retv_if(NULL == item, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == scroller, MENU_SCREEN_ERROR_INVALID_PARAMETER); + retv_if(NULL == page, MENU_SCREEN_ERROR_INVALID_PARAMETER); + + page_no = page_scroller_get_page_no(scroller, page); + do { + to = page_find_empty_near(page, from); + if (to < 0) { + int page_max_app; + page_max_app = (int) evas_object_data_get(page, "page_max_app"); + to = page_max_app - 1; + item_out_page = page_unpack_item_at(page, to); + } + + for (to --; to >= from; to --) { + Evas_Object *item_in_page; + item_in_page = page_unpack_item_at(page, to); + page_pack_item(page, to + 1, item_in_page); + snprintf(buf, 32, "menu%d", to + 1); + edje_object_signal_emit(_EDJ(page), STR_MOVE_PREV, buf); + edje_object_signal_emit(_EDJ(page), STR_ANI_RETURN, buf); + } + + page_pack_item(page, from, item); + + if (!item_out_page) break; + + page_no ++; + page = page_scroller_get_page_at(scroller, page_no); + if (!page) { + int rotate; + rotate = (int) evas_object_data_get(scroller, "rotate"); + page = page_create(scroller, page_no, rotate); + retv_if(NULL == page, MENU_SCREEN_ERROR_FAIL); + mapbuf_enable(page, 0); + } + + from = 0; + item = item_out_page; + item_out_page = NULL; + } while (page && item); + + return MENU_SCREEN_ERROR_OK; +} + + + +static Evas_Object *_animated_unpack_item(Evas_Object *scroller, Evas_Object *page, unsigned int pos) +{ + Evas_Object *out = NULL; + Evas_Object *item; + Evas_Object *next_page; + + char buf[32]; + unsigned int page_max_app; + unsigned int page_no; + page_scroller_sort_type_e sort_type; + + out = page_unpack_item_at(page, pos); + retv_if(NULL == out, NULL); + + page_no = page_scroller_get_page_no(scroller, page); + page_max_app = (unsigned int) evas_object_data_get(scroller, "page_max_app"); + sort_type = (page_scroller_sort_type_e) evas_object_data_get(scroller, "sort_type"); + + pos ++; + while (page && page_no < MAX_PAGE_NO) { + if (0 == page_count_item(page)) { + page_destroy(scroller, page); + break; + } + + for (; pos < page_max_app; pos ++) { + item = page_unpack_item_at(page, pos); + if (NULL == item) continue; + + page_pack_item(page, pos - 1, item); + snprintf(buf, 32, "menu%d", pos - 1); + edje_object_signal_emit(_EDJ(page), STR_MOVE_NEXT, buf); + edje_object_signal_emit(_EDJ(page), STR_ANI_RETURN, buf); + } + + if (sort_type == PAGE_SCROLLER_SORT_MAX) { + return NULL; + } + + page_no ++; + next_page = page_scroller_get_page_at(scroller, page_no); + if (next_page) { + item = page_unpack_item_at(next_page, 0); + if (NULL == item) continue; + + page_pack_item(page, page_max_app - 1, item); + } else break; + + pos = 1; + page = next_page; + } + + return out; +} + + + +HAPI Evas_Object *page_scroller_push_item(Evas_Object *scroller, app_info_t *ai) +{ + Evas_Object *page; + Evas_Object *item; + unsigned int nr_of_pages; + int candidate_page = -1; + int candidate_pos = 0; + int sort_type; + register int i; + + struct { + page_scroller_sort_type_e sort_type; + menu_screen_error_e (*sort_func)(Evas_Object *scroller, int *candidate_page, int *candidate_pos, void *data); + } sort_type_map[] = { + { + .sort_type = PAGE_SCROLLER_SORT_BY_DEFAULT, + .sort_func = _find_position_by_default, + }, + { + .sort_type = PAGE_SCROLLER_SORT_BY_PACKAGE, + .sort_func = _find_position_by_package, + }, + { + .sort_type = PAGE_SCROLLER_SORT_BY_NAME, + .sort_func = _find_position_by_name, + }, + { + .sort_type = PAGE_SCROLLER_SORT_MAX, + .sort_func = NULL, + }, + }; + + sort_type = (int) evas_object_data_get(scroller, "sort_type"); + sort_type_map[sort_type].sort_func(scroller, &candidate_page, &candidate_pos, ai); + + nr_of_pages = page_scroller_count_page(scroller); + + for (i = nr_of_pages; i <= candidate_page; i ++) { + Evas_Object *new_page; + int rotate; + + rotate = (int) evas_object_data_get(scroller, "rotate"); + new_page = page_create(scroller, nr_of_pages, rotate); + retv_if(NULL == new_page, NULL); + mapbuf_enable(new_page, 0); + } + + item = item_create(scroller, ai); + retv_if(NULL == item, NULL); + + page = page_scroller_get_page_at(scroller, candidate_page); + if (!page) { + _D("Impossible, page is not found"); + item_destroy(item); + return NULL; + } + + retv_if(MENU_SCREEN_ERROR_OK != + _animated_pack_item(item, scroller, page, candidate_pos), + NULL); + + return item; +} + + + +static inline menu_screen_error_e _create_cb(const char *package, void *data) +{ + app_info_t ai = {0,}; + Evas_Object *item; + Evas_Object *scroller = data; + + if (MENU_SCREEN_ERROR_FAIL == list_get_values(package, &ai)) { + list_free_values(&ai); + return MENU_SCREEN_ERROR_FAIL; + } + + do { + if (!scroller) { + _D("Scroller is NULL."); + break; + } + + if (ai.nodisplay || !ai.enabled) + { + Evas_Object *page; + + _D("package %s is not visible", package); + item = pkgmgr_find_pended_object(ai.package, 1, scroller, &page); + if (item) { + if (page) { + page_unpack_item(page, item); + page_scroller_trim_items(scroller); + } + + item_destroy(item); + } + + break; + } + + item = pkgmgr_find_pended_object(ai.package, 1, scroller, NULL); + if (!item) { + item = page_scroller_find_item_by_package(scroller, ai.package, NULL); + if (!item) { + Evas_Object *item; + _D("package %s is installed directly", package); + item = page_scroller_push_item(scroller, &ai); + if (item) { + break; + } else { + list_free_values(&ai); + retv_if(1, MENU_SCREEN_ERROR_FAIL); + } + } + } + + _D("Package %s is found, update it!", package); + item_update(item, &ai); + } while(0); + + list_free_values(&ai); + return MENU_SCREEN_ERROR_OK; +} + + + +static inline menu_screen_error_e _update_cb(const char *package, void *data) +{ + Evas_Object *scroller = data; + Evas_Object *item; + int page_no = 0; + app_info_t ai = {0,}; + + if (MENU_SCREEN_ERROR_FAIL == list_get_values(package, &ai)) { + list_free_values(&ai); + return MENU_SCREEN_ERROR_FAIL; + } + + do { + if (!scroller) { + _D("Scroller is NULL."); + break; + } + + item = page_scroller_find_item_by_package(scroller, package, &page_no); + if (!item) { + Evas_Object *page; + _D("There is no loaded item is found"); + item = pkgmgr_find_pended_object(package, 1, scroller, &page); + if (item) { + if (!ai.nodisplay && ai.enabled) { + _D("Item is found for updating from the install list, Ignore this."); + item_update(item, &ai); + } else { + _D("Item is found for updating from the install list, But nodisplay"); + if (page) { + page_unpack_item(page, item); + page_scroller_trim_items(scroller); + } + item_destroy(item); + } + } else { + Evas_Object *item; + _D("Item is not found. Create a new one"); + item = ((!ai.nodisplay && ai.enabled) ? page_scroller_push_item(scroller, &ai) : NULL); + if (item) { + break; + } else { + list_free_values(&ai); + retv_if(1, MENU_SCREEN_ERROR_FAIL); + } + } + } else { + Evas_Object *page; + Evas_Object *pended_item; + + pended_item = pkgmgr_find_pended_object(package, 1, scroller, &page); + if (!pended_item ) { + _D("Cannot find package in the install list"); + } + + if (!ai.nodisplay && ai.enabled) { + item_update(item, &ai); + break; + } + + page = page_scroller_get_page_at(scroller, page_no); + if (page) { + page_unpack_item(page, item); + page_scroller_trim_items(scroller); + } + item_destroy(item); + } + } while (0); + + list_free_values(&ai); + return MENU_SCREEN_ERROR_OK; +} + + + +static inline menu_screen_error_e _delete_cb(const char *package, void *data) +{ + Evas_Object *item; + Evas_Object *page; + Evas_Object *scroller = data; + Evas_Object *tmp; + int page_no = 0; + register unsigned int i; + unsigned int page_max_app; + + do { + if (!scroller) { + _D("Scroller is NULL."); + break; + } + + tmp = pkgmgr_find_pended_object(package, 1, scroller, NULL); + + item = page_scroller_find_item_by_package(scroller, package, &page_no); + retv_if(NULL == item, MENU_SCREEN_ERROR_FAIL); + + if (tmp != item) { + _D("Pended item is %p, Found item is %p", tmp, item); + } + + page = page_scroller_get_page_at(scroller, page_no); + retv_if(NULL == page, MENU_SCREEN_ERROR_FAIL); + + page_max_app = (unsigned int) evas_object_data_get(scroller, "page_max_app"); + for (i = 0; i < page_max_app; i++) { + if (item == page_get_item_at(page, i)) { + break; + } + } + + item = _animated_unpack_item(scroller, page, i); + retv_if(NULL == item, MENU_SCREEN_ERROR_FAIL); + item_destroy(item); + } while (0); + + return MENU_SCREEN_ERROR_OK; +} + + + +static struct pkg_event_handler { + const char *event_name; + int (*event_handler)(const char *package, void *data); +} event_table[] = { + { + .event_name = "create", + .event_handler = _create_cb, + }, + { + .event_name = "update", + .event_handler = _update_cb, + }, + { + .event_name = "delete", + .event_handler = _delete_cb, + }, + { + .event_name = NULL, + .event_handler = NULL, + }, +}; + + + +static void _desktop_cb(keynode_t *node, void *data) +{ + char *event; + char type[10]; + char package[BUFSZE]; + register int i; + + event = vconf_get_str(vconf_keynode_get_name(node)); + ret_if(NULL == event); + + if (sscanf(event, "%10[^:]:%1023s", type, package) != 2) { + _D("Failed to parse the event format : [%s], [%s]", type, package); + } + + _D("command[%s], package[%s]", type, package); + + for (i = 0; event_table[i].event_name; i ++) { + if (!strcasecmp(type, event_table[i].event_name)) { + if (event_table[i].event_handler(package, data) == MENU_SCREEN_ERROR_FAIL) { + _E("Failed to handles the desktop notification event"); + } + + free(event); + return; + } + } + + _E("Failed to find a proper event handler"); + free(event); +} + + + +static void _mapbuf_cb(keynode_t *node, void *data) +{ + int value; + int nr_of_pages; + register int i; + Evas_Object *page; + + if (vconf_get_int("memory/menuscreen/mapbuf", &value) < 0) { + _D("Failed to get mapbuf status"); + return; + } + + nr_of_pages = page_scroller_count_page(data); + if (value) { + for (i = 0; i < nr_of_pages; i ++) { + page = page_scroller_get_page_at(data, i); + if (!page) continue; + + if (!mapbuf_is_enabled(page)) { + _D("Enable mapbuf %d", i); + mapbuf_enable(page, 1); + } + } + } else { + for (i = 0; i < nr_of_pages; i ++) { + page = page_scroller_get_page_at(data, i); + if (!page) continue; + + if (mapbuf_is_enabled(page)) { + _D("Disable mapbuf %d", i); + mapbuf_disable(page, 1); + } + } + } +} + + + +static void _mouse_wheel_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Wheel *ei = event_info; + Evas_Object *scroller = data; + int x, y, w, h; + int idx = -1; + + _D("Wheel's up or down(%d)", ei->z); + + elm_scroller_region_get(scroller, &x, &y, &w, &h); + if (ei->z > 0) { // Wheel's up + idx = x / w; + idx ++; + } else if (ei->z < 0) { // Wheel's down + idx = x / w; // Scroller got ECORE events at first, then Menu-screen gets EVAS events. + } else { // Wheel's not moving. + _D("Wheel's not moving"); + } + + if (idx >= page_scroller_count_page(scroller) || idx < 0) return; + evas_object_data_set(scroller, "mouse_wheel_scroller_start", (void *) 1); + page_scroller_bring_in(scroller, idx); +} + + + +HAPI Evas_Object *page_scroller_create(Evas_Object *tab, Evas_Object *index, page_scroller_sort_type_e sort_type, int rotate) +{ + Evas_Object *box; + Evas_Object *scroller; + int width; + int height; + + scroller = elm_scroller_add(tab); + retv_if(NULL == scroller, NULL); + + elm_scroller_content_min_limit(scroller, EINA_FALSE, EINA_FALSE); + elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_FALSE); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + + width = menu_screen_get_root_width(); + height = (int) ((double) PROP_PORTRAIT_HEIGHT * ((double) menu_screen_get_root_height())); + elm_scroller_page_size_set(scroller, width, height); + elm_scroller_page_scroll_limit_set(scroller, 1, 1); + + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_min_set(scroller, width, height); + evas_object_size_hint_max_set(scroller, width, height); + + box = elm_box_add(scroller); + if (!box) { + _D("Failed to create box"); + evas_object_del(scroller); + return NULL; + } + elm_box_horizontal_set(box, 1); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + evas_object_data_set(scroller, "win", evas_object_data_get(tab, "win")); + evas_object_data_set(scroller, "layout", evas_object_data_get(tab, "layout")); + evas_object_data_set(scroller, "controlbar", evas_object_data_get(tab, "controlbar")); + evas_object_data_set(scroller, "tab", tab); + evas_object_data_set(scroller, "page_edje", evas_object_data_get(tab, "page_edje")); + evas_object_data_set(scroller, "page_max_app", evas_object_data_get(tab, "page_max_app")); + evas_object_data_set(scroller, "item_edje", evas_object_data_get(tab, "item_edje")); + evas_object_data_set(scroller, "item_width", evas_object_data_get(tab, "item_width")); + evas_object_data_set(scroller, "item_height", evas_object_data_get(tab, "item_height")); + evas_object_data_set(scroller, "item_enable_long_press", evas_object_data_get(tab, "item_enable_long_press")); + evas_object_data_set(scroller, "item_text_dual_line", evas_object_data_get(tab, "item_text_dual_line")); + evas_object_data_set(scroller, "enable_bg_image", evas_object_data_get(tab, "enable_bg_image")); + evas_object_data_set(scroller, "box", box); + evas_object_data_set(scroller, "drag_start", (void *) 0); + evas_object_data_set(scroller, "previous_x", (void *) 0); + evas_object_data_set(scroller, "index", index); + evas_object_data_set(scroller, "sort_type", (void *) sort_type); + evas_object_data_set(scroller, "install_list", (void *) 0); + evas_object_data_set(scroller, "rotate", (void *) rotate); + evas_object_data_set(scroller, "is_edited", (void *) false); + elm_object_content_set(scroller, box); + + evas_object_smart_callback_add(scroller, "scroll,anim,start", _anim_start_cb, NULL); + evas_object_smart_callback_add(scroller, "scroll,anim,stop", _anim_stop_cb, NULL); + evas_object_smart_callback_add(scroller, "scroll,drag,start", _drag_start_cb, NULL); + evas_object_smart_callback_add(scroller, "scroll,drag,stop", _drag_stop_cb, NULL); + evas_object_smart_callback_add(scroller, "scroll", _scroll_cb, NULL); + evas_object_event_callback_add(box, EVAS_CALLBACK_DEL, _evas_object_event_del_cb, "BOX"); + evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, scroller); + + evas_object_show(box); + evas_object_show(scroller); + + if (vconf_notify_key_changed(VCONFKEY_AIL_INFO_STATE, _desktop_cb, scroller) < 0) { + _E("Failed to register a desktop change event handler"); + } + + if (vconf_notify_key_changed("memory/menuscreen/mapbuf", _mapbuf_cb, scroller) < 0) { + _E("Failed to register a vconf cb for %s", "memory/menuscreen/mapbuf"); + } + + // FIXME : This will be enabled after rebuilding the routine for appid <-> pkgid. + //pkgmgr_init(scroller); + item_badge_register_changed_cb(scroller); + + return scroller; +} + + + +HAPI void page_scroller_destroy(Evas_Object *scroller) +{ + Evas_Object *box; + Evas_Object *page; + Evas_Object *tmp; + + const Eina_List *page_list; + const Eina_List *l; + const Eina_List *ln; + + ret_if(NULL == scroller); + ret_if(NULL == (box = evas_object_data_get(scroller, "box"))); + ret_if(NULL == (page_list = elm_box_children_get(box))); + + item_badge_unregister_changed_cb(); + + // FIXME : This will be enabled after rebuilding the routine for appid <-> pkgid. + //pkgmgr_fini(); + + EINA_LIST_FOREACH_SAFE(page_list, l, ln, page) { + int count; + + if (!page) { + _D("page list contains nil item"); + continue; + } + + count = eina_list_count(page_list); + _D("page_list count : %d", count); + if (count < 1) { + elm_box_unpack(box, page); + } + + tmp = mapbuf_get_page(page); + if (tmp) page = tmp; + + page_destroy(scroller, page); + } + + box = elm_object_content_unset(scroller); + evas_object_del(box); + + evas_object_data_del(scroller, "win"); + evas_object_data_del(scroller, "layout"); + evas_object_data_del(scroller, "controlbar"); + evas_object_data_del(scroller, "tab"); + evas_object_data_del(scroller, "page_edje"); + evas_object_data_del(scroller, "page_max_app"); + evas_object_data_del(scroller, "item_edje"); + evas_object_data_del(scroller, "item_width"); + evas_object_data_del(scroller, "item_height"); + evas_object_data_del(scroller, "item_enable_long_press"); + evas_object_data_del(scroller, "item_text_dual_line"); + evas_object_data_del(scroller, "enable_bg_image"); + evas_object_data_del(scroller, "box"); + evas_object_data_del(scroller, "drag_start"); + evas_object_data_del(scroller, "previous_x"); + evas_object_data_del(scroller, "index"); + evas_object_data_del(scroller, "sort_type"); + evas_object_data_del(scroller, "rotate"); + evas_object_data_del(scroller, "is_edited"); + evas_object_data_del(scroller, "install_list"); + + evas_object_smart_callback_del(scroller, "scroll,anim,start", _anim_start_cb); + evas_object_smart_callback_del(scroller, "scroll,anim,stop", _anim_stop_cb); + evas_object_smart_callback_del(scroller, "scroll,drag,start", _drag_start_cb); + evas_object_smart_callback_del(scroller, "scroll,drag,stop", _drag_stop_cb); + evas_object_smart_callback_del(scroller, "scroll", _scroll_cb); + evas_object_event_callback_del(box, EVAS_CALLBACK_DEL, _evas_object_event_del_cb); + evas_object_event_callback_del(scroller, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb); + + evas_object_del(scroller); + + if (vconf_ignore_key_changed(VCONFKEY_AIL_INFO_STATE, _desktop_cb) < 0) { + _E("Failed to ignore the desktop event"); + } + + if (vconf_ignore_key_changed("memory/menuscreen/mapbuf", _mapbuf_cb) < 0) { + _E("Failed to remove vconf %s", "memory/menuscreen/mapbuf"); + } +} + + + +HAPI void page_scroller_clean(Evas_Object *scroller) +{ + Evas_Object *page; + Evas_Object *item; + + register unsigned int i; + unsigned int page_max_app; + unsigned int count; + + count = page_scroller_count_page(scroller); + if (count == 0) return; + + for (i = 1; i < MAX_PAGE_NO; i++) { + page = page_scroller_get_page_at(scroller, i); + if (NULL == page) break; + + page_destroy(scroller, page); + } + + page = page_scroller_get_page_at(scroller, 0); + ret_if(NULL == page); + + page_max_app = (unsigned int) evas_object_data_get(scroller, "page_max_app"); + for (i = 0; i < page_max_app; i++) { + item = page_get_item_at(page, i); + if (item) { + item_destroy(item); + } else break; + } +} + + + +HAPI Evas_Object *page_scroller_get_page_at(Evas_Object *scroller, unsigned int idx) +{ + const Eina_List *page_list; + Evas_Object *item; + Evas_Object *box; + + retv_if(idx >= MAX_PAGE_NO, NULL); + + box = evas_object_data_get(scroller, "box"); + retv_if(NULL == box, NULL); + + page_list = elm_box_children_get(box); + retv_if(NULL == page_list, NULL); + + item = eina_list_nth(page_list, idx); + if (item) { + item = mapbuf_get_page(item); + } + + return item; +} + + + +HAPI unsigned int page_scroller_count_page(Evas_Object *scroller) +{ + const Eina_List *page_list; + Evas_Object *box; + + box = evas_object_data_get(scroller, "box"); + retv_if(NULL == box, 0); + + page_list = elm_box_children_get(box); + retv_if(NULL == page_list, 0); + + return eina_list_count(page_list); +} + + + +HAPI int page_scroller_get_page_no(Evas_Object* scroller, Evas_Object *page) +{ + Evas_Object *item; + Evas_Object *box; + register int idx = 0; + const Eina_List *page_list; + const Eina_List *pos; + + box = evas_object_data_get(scroller, "box"); + retv_if(NULL == box, 0); + + page_list = elm_box_children_get(box); + EINA_LIST_FOREACH(page_list, pos, item) { + if (!item) { + _D("page list contains nil item"); + continue; + } + + item = mapbuf_get_page(item); + if (item == page) { + return idx; + } + + idx ++; + } + + return -1; +} + + + +HAPI int page_scroller_get_current_page_no(Evas_Object *scroller) +{ + return (int) evas_object_data_get(scroller, "current_idx"); +} + + + +HAPI Evas_Object *page_scroller_find_item_by_package(Evas_Object *scroller, const char *package, int *page_no) +{ + register int i; + register int j; + Evas_Object *page; + Evas_Object *item; + const char *tmp; + int local_page_no; + int page_max_app; + + if (!page_no) page_no = &local_page_no; + + retv_if(NULL == package, NULL); + + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + for (i = 0; i < page_scroller_count_page(scroller); i ++) { + page = page_scroller_get_page_at(scroller, i); + if (!page) continue; + + for (j = 0; j < page_max_app; j ++) { + item = page_get_item_at(page, j); + if (!item) continue; + + tmp = item_get_package(item); + if (!tmp) { + _D("Something goes wrong, this package has no name?"); + continue; + } + + if (!strcmp(tmp, package)) { + *page_no = i; + return item; + } + } + } + + return NULL; +} + + + +HAPI void page_scroller_trim_items(Evas_Object *scroller) +{ + register unsigned int i; + register unsigned int j; + int page_max_app; + int pos = 0; + + Evas_Object *page; + Evas_Object *item; + Eina_List *list = NULL; + + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + for (i = 0; i < MAX_PAGE_NO; i ++) { + page = page_scroller_get_page_at(scroller, i); + if (!page) break; + + for (j = 0; j < page_max_app; j++) { + item = page_unpack_item_at(page, j); + if (item) { + list = eina_list_append(list, item); + _D("LIST APPEND : %s", item_get_package(item)); + } + } + + } + + for (i = 0; i < eina_list_count(list); i++) { + if (i % page_max_app == 0) { + page = page_scroller_get_page_at(scroller, i / page_max_app); + _D("PAGE GET : 0x%x", page); + if (NULL == page) { + _E("Cannot get page"); + break; + } + } + + item = eina_list_nth(list, i); + if (NULL == item) { + _E("Cannot get item"); + break; + } + _D("LIST GET : [%d] %s", pos, item_get_package(item)); + + page_pack_item(page, pos % page_max_app, item); + pos++; + } + + for (i = pos / page_max_app; i < MAX_PAGE_NO; i++) { + int count; + + page = page_scroller_get_page_at(scroller, i); + if (NULL == page) { + break; + } + count = page_count_item(page); + if (count == 0) { + Evas_Coord w; + Evas_Coord h; + + _D("PAGE IS EMPTY : 0x%x", page); + + page_destroy(scroller, page); + evas_object_geometry_get(scroller, NULL, NULL, &w, &h); + elm_scroller_region_show(scroller, 0, 0, w, h); + } + } + pos --; + eina_list_free(list); +} + + + +HAPI void page_scroller_edit(Evas_Object *scroller) +{ + Evas_Object *page; + Evas_Object *item; + register unsigned int page_no; + register unsigned int position_no; + unsigned int nr_of_pages; + int page_max_app; + + nr_of_pages = page_scroller_count_page(scroller); + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + for (page_no = 0; page_no < nr_of_pages; page_no ++) { + page = page_scroller_get_page_at(scroller, page_no); + ret_if(NULL == page); + + for (position_no = 0; position_no < page_max_app; position_no ++) { + item = page_get_item_at(page, position_no); + if (!item) { + continue; + } + + item_edit(item); + } + } + evas_object_data_set(scroller, "is_edited", (void *) true); +} + + + +HAPI void page_scroller_unedit(Evas_Object *scroller) +{ + Evas_Object *all_apps; + Evas_Object *page; + Evas_Object *item; + register int page_no; + register unsigned int position_no; + unsigned int nr_of_pages; + int page_max_app; + + ret_if(NULL == scroller); + + all_apps = evas_object_data_get(scroller, "tab"); + ret_if(NULL == all_apps); + + nr_of_pages = page_scroller_count_page(scroller); + page_max_app = (int) evas_object_data_get(scroller, "page_max_app"); + + for (page_no = nr_of_pages - 1; page_no >= 0; page_no --) { + int count; + + page = page_scroller_get_page_at(scroller, page_no); + if (NULL == page) break; + count = page_count_item(page); + + page_scroller_trim_items(scroller); + + for (position_no = 0; position_no < page_max_app; position_no ++) { + item = page_get_item_at(page, position_no); + if (!item) { + break; + } + + item_unedit(item); + } + } + + evas_object_data_set(scroller, "is_edited", (void *) false); +} + + + +HAPI bool page_scroller_is_edited(Evas_Object *scroller) +{ + return (bool) evas_object_data_get(scroller, "is_edited"); +} + + + +HAPI void page_scroller_focus(Evas_Object *scroller) +{ + int idx = 0; + idx = page_scroller_get_current_page_no(scroller); + + Evas_Object *page = NULL; + page = page_scroller_get_page_at(scroller, (unsigned int) idx); + ret_if(NULL == page); + + Evas_Object *item = NULL; + item = page_get_item_at(page, 0); + ret_if(NULL == item); + + Evas_Object *focus_button = NULL; + focus_button = elm_object_part_content_get(item, "focus"); + ret_if(NULL == focus_button); + + _D("Focus set scroller(%p), page:%d, item:%s", scroller, idx, item_get_name(item)); + elm_object_focus_set(focus_button, EINA_TRUE); +} + + + +HAPI void page_scroller_focus_into_vector(Evas_Object *scroller, int vector) +{ + int idx = 0; + idx = page_scroller_get_current_page_no(scroller); + idx += vector; + + ret_if(0 > idx); + + Evas_Object *page = NULL; + page = page_scroller_get_page_at(scroller, (unsigned int) idx); + ret_if(NULL == page); + + Evas_Object *item = NULL; + item = page_get_item_at(page, 0); + ret_if(NULL == item); + + Evas_Object *focus_button = NULL; + focus_button = elm_object_part_content_get(item, "focus"); + ret_if(NULL == focus_button); + + _D("Focus set scroller(%p), page:%d, item:%s", scroller, idx, item_get_name(item)); + elm_object_focus_set(focus_button, EINA_TRUE); + + page_scroller_bring_in(scroller, idx); +} + + + +// End of a file diff --git a/src/pkgmgr.c b/src/pkgmgr.c new file mode 100644 index 0000000..d7fecc2 --- /dev/null +++ b/src/pkgmgr.c @@ -0,0 +1,865 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include +#include +#include + +#include "conf.h" +#include "index.h" +#include "item.h" +#include "list.h" +#include "page.h" +#include "page_scroller.h" +#include "mapbuf.h" +#include "pkgmgr.h" +#include "util.h" + + + +struct pkgmgr_handler { + const char *key; + int (*func)(const char *package, const char *val, void *data); +}; + + + +static struct { + pkgmgr_client *listen_pc; +} pkg_mgr_info = { + .listen_pc = NULL, +}; + + + +HAPI inline menu_screen_error_e pkgmgr_uninstall(Evas_Object *item) +{ + int ret = MENU_SCREEN_ERROR_OK; + + retv_if(NULL == item, MENU_SCREEN_ERROR_FAIL); + + char *pkgid = NULL; + char *appid = item_get_package(item); + retv_if(NULL == appid, MENU_SCREEN_ERROR_FAIL); + + pkgmgr_client *req_pc = NULL; + req_pc = pkgmgr_client_new(PC_REQUEST); + retv_if(NULL == req_pc, MENU_SCREEN_ERROR_FAIL); + + pkgmgrinfo_appinfo_h handle; + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_appinfo(appid, &handle)) { + if (PKGMGR_R_OK != pkgmgr_client_free(req_pc)) { + _E("cannot free pkgmgr_client for request."); + } + return MENU_SCREEN_ERROR_FAIL; + } + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid)) { + if (PMINFO_R_OK != pkgmgrinfo_appinfo_destroy_appinfo(handle)) { + _E("cannot destroy the appinfo"); + } + + if (PKGMGR_R_OK != pkgmgr_client_free(req_pc)) { + _E("cannot free pkgmgr_client for request."); + } + + return MENU_SCREEN_ERROR_FAIL; + } + + if (!pkgid) pkgid = appid; + + _D("Uninstall a package[%s] from an app[%s]", pkgid, appid); + if (pkgmgr_client_uninstall(req_pc, NULL, pkgid, PM_QUIET, NULL, NULL) < 0) { + _E("cannot uninstall %s.", item_get_package(item)); + ret = MENU_SCREEN_ERROR_FAIL; + } + + if (PMINFO_R_OK != pkgmgrinfo_appinfo_destroy_appinfo(handle)) { + _E("cannot destroy the appinfo"); + ret = MENU_SCREEN_ERROR_FAIL; + } + + if (PMINFO_R_OK != pkgmgr_client_free(req_pc)) { + _E("cannot free pkgmgr_client"); + ret = MENU_SCREEN_ERROR_FAIL; + } + + return ret; +} + + + +static menu_screen_error_e _start_download(const char *package, void *scroller) +{ + struct package_info *pi; + Eina_List *install_list; + + install_list = evas_object_data_get(scroller, "install_list"); + pi = calloc(1, sizeof(struct package_info)); + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + pi->status = DOWNLOAD_BEGIN; + pi->ai.package = strdup(package); + pi->ai.name = strdup("Download"); + + install_list = eina_list_append(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + _D("Package [%s] is jump into the downloading phase", package); + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _start_uninstall(const char *package, void *scroller) +{ + Eina_List *l; + Eina_List *tmp; + int page_no = 0; + struct package_info *pi = NULL; + Eina_List *install_list; + + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + break; + } + pi = NULL; + } + + retv_if(pi, MENU_SCREEN_ERROR_FAIL); + + pi = calloc(1, sizeof(struct package_info)); + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + pi->status = UNINSTALL_BEGIN; + pi->ai.package = strdup(package); + pi->ai.nodisplay = false; + pi->ai.enabled = true; + pi->item = page_scroller_find_item_by_package(scroller, package, &page_no); + pi->page = page_scroller_get_page_at(scroller, page_no); + + install_list = eina_list_append(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _start_update(const char *package, void *scroller) +{ + Eina_List *l; + Eina_List *tmp; + struct package_info *pi = NULL; + Eina_List *install_list; + + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + break; + } + pi = NULL; + } + + if (!pi) { + int page_no = 0; + _D("Package [%s] is starting update phase directly (without downloading phase)", package); + + pi = calloc(1, sizeof(struct package_info)); + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + pi->ai.package = strdup(package); + pi->item = page_scroller_find_item_by_package(scroller, package, &page_no); + if (pi->item) { + pi->page = page_scroller_get_page_at(scroller, page_no); + } + + if (pi->item && pi->page) { + pi->ai.nodisplay = false; + pi->ai.enabled = true; + } + + install_list = eina_list_append(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + } else { + if (pi->status != DOWNLOAD_END && pi->status != INSTALL_END) { + _D("Package [%s] is in invalid state (%d), cancel this", package, pi->status); + install_list = eina_list_remove(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + if (pi->item) { + page_unpack_item(pi->page, pi->item); + page_scroller_trim_items(scroller); + item_destroy(pi->item); + } + + list_free_values(&pi->ai); + free(pi); + return MENU_SCREEN_ERROR_FAIL; + } + } + + pi->status = UPDATE_BEGIN; + pi->ai.name = strdup("Update"); + if (pi->item) { + item_set_name(pi->item, pi->ai.name, 0); + } + + _D("Package [%s] is jump into the updating phase", package); + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _start_recover(const char *package, void *scroller) +{ + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _start_install(const char *package, void *scroller) +{ + Eina_List *l; + Eina_List *tmp; + struct package_info *pi = NULL; + Eina_List *install_list; + + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + break; + } + pi = NULL; + } + + if (!pi) { + int page_no = 0; + _D("Package [%s] is starting install phase directly (without downloading phase)", package); + pi = calloc(1, sizeof(struct package_info)); + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + pi->ai.package = strdup(package); + if (!pi->ai.package) { + free(pi); + return MENU_SCREEN_ERROR_FAIL; + } + + pi->ai.icon = strdup(DEFAULT_ICON); + if (!pi->ai.icon) { + free(pi->ai.package); + free(pi); + return MENU_SCREEN_ERROR_FAIL; + } + + pi->item = page_scroller_find_item_by_package(scroller, package, &page_no); + if (!pi->item) { + if (NULL == page_scroller_push_item(scroller, &pi->ai)) _E("Cannot push an item"); + } + pi->item = page_scroller_find_item_by_package(scroller, package, &page_no); + pi->page = page_scroller_get_page_at(scroller, page_no); + + if (pi->item && pi->page) { + pi->ai.nodisplay = false; + pi->ai.enabled = true; + } + + install_list = eina_list_append(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + } else { + if (pi->status != DOWNLOAD_END && pi->status != INSTALL_END) { + _D("Package [%s] is in invalid state (%d), cancel this", package, pi->status); + install_list = eina_list_remove(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + if (pi->item) { + page_unpack_item(pi->page, pi->item); + page_scroller_trim_items(scroller); + item_destroy(pi->item); + } + + list_free_values(&pi->ai); + free(pi); + return MENU_SCREEN_ERROR_FAIL; + } + } + + pi->status = INSTALL_BEGIN; + pi->ai.name = strdup("Install"); + if (pi->item) { + // Update app name to install + item_set_name(pi->item, pi->ai.name, 0); + } + _D("Package [%s] is jump into the installing phase", package); + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _start(const char *package, const char *val, void *scroller) +{ + struct start_cb_set { + const char *name; + int (*handler)(const char *package, void *scroller); + } start_cb[] = { + { + .name = "download", + .handler = _start_download, + }, + { + .name = "uninstall", + .handler = _start_uninstall, + }, + { + .name = "install", + .handler = _start_install, + }, + { + .name = "update", + .handler = _start_update, + }, + { + .name = "recover", + .handler = _start_recover, + }, + { + .name = NULL, + .handler = NULL, + }, + }; + + register unsigned int i; + + _D("package [%s]", package); + + for (i = 0; start_cb[i].name; i ++) { + if (!strcasecmp(val, start_cb[i].name) && start_cb[i].handler) { + return start_cb[i].handler(package, scroller); + } + } + + _D("Unknown status for starting phase signal'd from package manager"); + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _icon_path(const char *package, const char *val, void *scroller) +{ + Eina_List *l; + Eina_List *tmp; + struct package_info *pi = NULL; + Eina_List *install_list; + + install_list = evas_object_data_get(scroller, "install_list"); + retv_if(!package, MENU_SCREEN_ERROR_FAIL); + retv_if(!val, MENU_SCREEN_ERROR_FAIL); + + _D("package [%s] with %s", package, val); + + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + break; + } + pi = NULL; + } + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + if (strlen(val)) { + pi->ai.icon = strdup(val); + retv_if (NULL == pi->ai.icon, MENU_SCREEN_ERROR_OUT_OF_MEMORY); + + if (!pi->item) { + _D("There is no item for [%s]", package); + pi->ai.nodisplay = false; + pi->ai.enabled = true; + + if (NULL == page_scroller_push_item(scroller, &pi->ai)) { + _E("Failed to create a new item, remove this package from the installing list"); + list_free_values(&pi->ai); + install_list = eina_list_remove(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + free(pi); + } + } else { + _D("There is an item for [%s:%p]", package, pi->item); + item_update(pi->item, &pi->ai); + } + } + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _download_percent(const char *package, const char *val, void *scroller) +{ + Eina_List *l; + Eina_List *tmp; + struct package_info *pi = NULL; + Eina_List *install_list; + + _D("package [%s] with %s", package, val); + + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + break; + } + pi = NULL; + } + + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + if (pi->status == DOWNLOAD_BEGIN) { + pi->status = DOWNLOADING; + } else if (pi->status == DOWNLOADING) { + // Do nothing, just we are in proper state + } else { + _D("Invalid state for %s, This is not started from the download_begin state(%s)", package, val); + } + + if (!pi->ai.nodisplay && pi->ai.enabled && pi->item) { + if (!item_is_enabled_progress(pi->item)) { + item_enable_progress(pi->item); + } + + item_update_progress(pi->item, atoi(val)); + } + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _install_percent(const char *package, const char *val, void *scroller) +{ + Eina_List *l; + Eina_List *tmp; + struct package_info *pi; + int progress; + Eina_List *install_list; + + _D("package [%s] with %s", package, val); + + pi = NULL; + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + break; + } + + pi = NULL; + } + + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + progress = atoi(val); + + if (pi->status == INSTALL_BEGIN) { + pi->status = INSTALLING; + } else if (pi->status == UNINSTALL_BEGIN) { + progress = 100 - progress; + pi->status = UNINSTALLING; + } else if (pi->status == UPDATE_BEGIN) { + pi->status = UPDATING; + } else if (pi->status == INSTALLING) { + } else if (pi->status == UNINSTALLING) { + progress = 100 - progress; + } else if (pi->status == UPDATING) { + } else { + _D("Invalid state for %s, This is not the uninstall or install_begin state(%s)", package, val); + } + + if (!pi->ai.nodisplay && pi->ai.enabled && pi->item) { + if (!item_is_enabled_progress(pi->item)) { + item_enable_progress(pi->item); + } + + item_update_progress(pi->item, progress); + } + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _error(const char *package, const char *val, void *scroller) +{ + struct package_info *pi = NULL; + Eina_List *l; + Eina_List *tmp; + Eina_List *install_list; + + _D("package [%s] with %s", package, val); + + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + break; + } + + pi = NULL; + } + + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + pi->error_count ++; + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _end_downloading(const char *package, struct package_info *pi, void *scroller) +{ + pi->status = DOWNLOAD_END; + _D("Package downloading is complete, waiting install progress"); + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _end_installing(const char *package, struct package_info *pi, void *scroller) +{ + // This status will not be referenced from the others. + // because it will be freed right after set it. ;) + Eina_List *install_list; + + pi->status = INSTALL_END; + _D("Package installing is complete"); + + install_list = evas_object_data_get(scroller, "install_list"); + if (pi->desktop_file_found == 1) { + install_list = eina_list_remove(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + list_free_values(&pi->ai); + free(pi); + } + + + // TODO: Need to register a timer callback + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _end_updating(const char *package, struct package_info *pi, void *scroller) +{ + // This status will not be referenced from the others. + // because it will be freed right after set it. ;) + Eina_List *install_list; + + pi->status = UPDATE_END; + _D("Package updating is complete"); + + install_list = evas_object_data_get(scroller, "install_list"); + if (pi->desktop_file_found == 1) { + install_list = eina_list_remove(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + list_free_values(&pi->ai); + free(pi); + } + + + // TODO: Need to register a timer callback + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _end_uninstalling(const char *package, struct package_info *pi, void *scroller) +{ + Eina_List *install_list; + + pi->status = UNINSTALL_END; + _D("Package uninstalling is complete"); + + install_list = evas_object_data_get(scroller, "install_list"); + if (pi->desktop_file_found == 1) { + install_list = eina_list_remove(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + list_free_values(&pi->ai); + free(pi); + } + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _end_unknown(const char *package, struct package_info *pi, void *scroller) +{ + Eina_List *install_list; + + install_list = evas_object_data_get(scroller, "install_list"); + install_list = eina_list_remove(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + + if (pi->item) { + // Remove an item only if it is installing. + if ( + pi->status == INSTALL_BEGIN || pi->status == INSTALLING || pi->status == INSTALL_END || + pi->status == DOWNLOAD_BEGIN || pi->status == DOWNLOADING || pi->status == DOWNLOAD_END + ) + { + if (pi->page) { + page_unpack_item(pi->page, pi->item); + page_scroller_trim_items(scroller); + } else { + _D("Page is not valid (%s)", package); + } + item_destroy(pi->item); + page_scroller_trim_items(scroller); + } + } + + list_free_values(&pi->ai); + free(pi); + + return MENU_SCREEN_ERROR_OK; +} + + + +static menu_screen_error_e _end(const char *package, const char *val, void *scroller) +{ + Eina_List *l; + Eina_List *tmp; + struct package_info *pi; + register int i; + struct end_cb_set { + int status; + int (*handler)(const char *package, struct package_info *pi, void *scroller); + } end_cb[] = { + { + .status = DOWNLOADING, + .handler = _end_downloading, + }, + { + .status = INSTALLING, + .handler = _end_installing, + }, + { + .status = UNINSTALLING, + .handler = _end_uninstalling, + }, + { + .status = UPDATING, + .handler = _end_updating, + }, + { + .status = UNKNOWN, + .handler = _end_unknown, + }, + { + .status = MAX_STATUS, + .handler = NULL, + }, + }; + Eina_List *install_list; + + _D("package [%s], val [%s]", package, val); + + pi = NULL; + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + break; + } + pi = NULL; + } + + retv_if(NULL == pi, MENU_SCREEN_ERROR_FAIL); + + list_free_values(&pi->ai); + if (MENU_SCREEN_ERROR_OK != list_get_values(package, &pi->ai)) _E("Cannot get values"); + item_update(pi->item, &pi->ai); + + if (item_is_enabled_progress(pi->item)) { + item_disable_progress(pi->item); + } + + // NOTE: Don't release the 'pi' + // Release it from each handler + for (i = 0; end_cb[i].handler; i ++) { + if (end_cb[i].status == pi->status && end_cb[i].handler) { + int ret; + + if (strcasecmp(val, "ok")) { + ret = _end_unknown(package, pi, scroller); + } else { + ret = end_cb[i].handler(package, pi, scroller); + } + + return ret; + } + } + + return _end_unknown(package, pi, scroller); +} + + + +static menu_screen_error_e _change_pkg_name(const char *package, const char *val, void *scroller) +{ + Eina_List *l; + Eina_List *tmp; + struct package_info *pi; + Eina_List *install_list; + + _D("package [%s]", package); + + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (!pi) { + continue; + } + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + _D("Replace package name %s to %s", pi->ai.package, val); + free(pi->ai.package); + pi->ai.package = strdup(val); + if (!pi->ai.package) { + _E("cannot strdup"); + return MENU_SCREEN_ERROR_FAIL; + } + if (pi->item) { + item_set_package(pi->item, (char*) val, 0); + } + return MENU_SCREEN_ERROR_OK; + } + } + + return MENU_SCREEN_ERROR_FAIL; +} + + + +static struct pkgmgr_handler pkgmgr_cbs[] = { + { "start", _start }, + { "icon_path", _icon_path }, + { "download_percent", _download_percent }, + { "command", NULL }, + { "install_percent", _install_percent }, + { "error", _error }, + { "end", _end }, + { "change_pkg_name", _change_pkg_name }, +}; + + + +static menu_screen_error_e _pkgmgr_cb(int req_id, const char *pkg_type, const char *package, const char *key, const char *val, const void *pmsg, void *data) +{ + register unsigned int i; + Evas_Object *scroller = data; + + _D("pkgmgr request [%s] for %s, val(%s)", key, package, val); + + for (i = 0; i < sizeof(pkgmgr_cbs) / sizeof(struct pkgmgr_handler); i++) { + if (!strcasecmp(pkgmgr_cbs[i].key, key)) { + if (pkgmgr_cbs[i].func) { + if (MENU_SCREEN_ERROR_OK != pkgmgr_cbs[i].func(package, val, scroller)) { + _E("pkgmgr_cbs[%u].func has errors.", i); + } + } else { + _E("Cannot find pkgmgr_cbs[%u].func.", i); + } + return MENU_SCREEN_ERROR_OK; + } + } + + return MENU_SCREEN_ERROR_FAIL; +} + + + +HAPI menu_screen_error_e pkgmgr_init(Evas_Object *scroller) +{ + if (NULL != pkg_mgr_info.listen_pc) { + return MENU_SCREEN_ERROR_OK; + } + + pkg_mgr_info.listen_pc = pkgmgr_client_new(PC_LISTENING); + retv_if(NULL == pkg_mgr_info.listen_pc, MENU_SCREEN_ERROR_FAIL); + retv_if(pkgmgr_client_listen_status(pkg_mgr_info.listen_pc, + _pkgmgr_cb, scroller) != PKGMGR_R_OK, MENU_SCREEN_ERROR_FAIL); + + return MENU_SCREEN_ERROR_OK; +} + + + +HAPI void pkgmgr_fini(void) +{ + ret_if(NULL == pkg_mgr_info.listen_pc); + if (pkgmgr_client_free(pkg_mgr_info.listen_pc) != PKGMGR_R_OK) { + _E("cannot free pkgmgr_client for listen."); + } + pkg_mgr_info.listen_pc = NULL; +} + + + +HAPI Evas_Object *pkgmgr_find_pended_object(const char *package, int with_desktop_file, Evas_Object *scroller, Evas_Object **page) +{ + Eina_List *l; + Eina_List *tmp; + struct package_info *pi; + Eina_List *install_list; + + _D("package [%s]", package); + + retv_if(NULL == package, NULL); + install_list = evas_object_data_get(scroller, "install_list"); + EINA_LIST_FOREACH_SAFE(install_list, l, tmp, pi) { + if (!pi) { + continue; + } + if (pi->ai.package && !strcmp(pi->ai.package, package)) { + Evas_Object *item; + _D("Installing(Downloading) package is found (%p)", pi->item); + + item = pi->item; + + if (with_desktop_file) { + pi->desktop_file_found = 1; + + if (pi->status == INSTALL_END || pi->status == UNINSTALL_END || pi->status == UPDATE_END) { + install_list = eina_list_remove(install_list, pi); + evas_object_data_set(scroller, "install_list", install_list); + list_free_values(&pi->ai); + free(pi); + pi = NULL; + } + } + + if (page) { + *page = pi ? pi->page : NULL; + } + return item; + } + } + + _D("Failed to find a installing/downloading package"); + return NULL; +} + + + +// End of a file diff --git a/src/popup.c b/src/popup.c new file mode 100644 index 0000000..a3fa311 --- /dev/null +++ b/src/popup.c @@ -0,0 +1,249 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include + +#include "conf.h" +#include "item.h" +#include "menu_screen.h" +#include "pkgmgr.h" +#include "util.h" +#include "all_apps/shortcut.h" + +#define BUFSZE 1024 +#define ELLIPSIS "..." +#define STRSZE 128 + + + +static struct { + Evas_Object *popup; +} popup_info = { + .popup = NULL, +}; + + + +HAPI Evas_Object *popup_exist(void) +{ + return popup_info.popup; +} + + + +HAPI void popup_destroy_all(void) +{ + void (*_destroy_popup)(void *data, Evas_Object *obj, void *event_info); + + if (NULL == popup_info.popup) return; + + _destroy_popup = evas_object_data_get(popup_info.popup, "func_destroy_popup"); + if (_destroy_popup) _destroy_popup(popup_info.popup, NULL, NULL); + + popup_info.popup = NULL; +} + + + +static void _response_cb(void *data, Evas_Object *obj, void *event_info) +{ + ret_if(NULL == data); + + Evas_Object *popup = data; + evas_object_data_del(popup, "func_destroy_popup"); + popup_info.popup = NULL; + + evas_object_del(evas_object_data_del(popup, "button")); + evas_object_del(popup); +} + + + +HAPI Evas_Object *popup_create_confirm(Evas_Object *parent, const char *warning) +{ + Evas_Object *popup; + Evas_Object *btn; + + retv_if(NULL == warning, NULL); + + popup_destroy_all(); + + popup = elm_popup_add(parent); + retv_if(NULL == popup, NULL); + + btn = elm_button_add(popup); + if (NULL == btn) { + evas_object_del(popup); + return NULL; + } + + elm_object_text_set(btn, D_("IDS_COM_SK_OK")); + evas_object_data_set(popup, "button", btn); + + elm_object_part_content_set(popup, "button1", btn); + evas_object_smart_callback_add(btn, "clicked", _response_cb, popup); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_object_part_text_set(popup, "title,text", D_("IDS_COM_POP_WARNING")); + elm_object_text_set(popup, warning); + elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER); + evas_object_show(popup); + + evas_object_data_set(popup, "func_destroy_popup", _response_cb); + popup_info.popup = popup; + + return popup; +} + + + +static void _uninstall_no_cb(void *data, Evas_Object *obj, void *event_info) +{ + ret_if(NULL == data); + + Evas_Object *popup = data; + evas_object_data_del(popup, "func_destroy_popup"); + popup_info.popup = NULL; + + evas_object_del(evas_object_data_del(popup, "button1")); + evas_object_del(evas_object_data_del(popup, "button2")); + evas_object_data_del(popup, "item"); + evas_object_del(popup); +} + + + +static void _uninstall_yes_cb(void *data, Evas_Object *obj, void *event_info) +{ + ret_if(NULL == data); + + Evas_Object *popup = data; + evas_object_data_del(popup, "func_destroy_popup"); + popup_info.popup = NULL; + + Evas_Object *item; + item = evas_object_data_del(popup, "item"); + + evas_object_del(evas_object_data_del(popup, "button1")); + evas_object_del(evas_object_data_del(popup, "button2")); + evas_object_del(popup); + + bool is_shortcut = false; + is_shortcut = (bool) evas_object_data_get(item, "is_shortcut"); + + if (is_shortcut) { + all_apps_shortcut_remove(item); + } else { + if (MENU_SCREEN_ERROR_OK != pkgmgr_uninstall(item)) { + _E("Cannot communicate with the pkgmgr-server."); + } + } +} + + + +static char *_popup_set_name(Evas_Object *item) +{ + char *name; + char *get_name = item_get_name(item); + if(!get_name) get_name = item_get_package(item); + retv_if(NULL == get_name, NULL); + + name = calloc(strlen(get_name)+1, sizeof(char)); + retv_if(NULL == name, NULL); + strncpy(name, get_name, strlen(get_name)); + + if (strlen(name) > STRSZE) { + char *temp, *ellipsis = ELLIPSIS; + + name = realloc(name, (STRSZE + strlen(ellipsis) + 1)*sizeof(char)); + retv_if(NULL == name, NULL); + + temp = name + STRSZE; + + while (*ellipsis) *temp++ = *ellipsis++; + *temp = '\0'; + } + return name; +} + + + +#define IDS_AT_POP_UNINSTALL_PS_Q "IDS_AT_POP_UNINSTALL_PS_Q" +HAPI Evas_Object *popup_create_uninstall(Evas_Object *parent, Evas_Object *item) +{ + Evas_Object *popup; + Evas_Object *btn1; + Evas_Object *btn2; + char warning[BUFSZE]; + + popup_destroy_all(); + + popup = elm_popup_add(parent); + retv_if(NULL == popup, NULL); + + evas_object_data_set(popup, "item", item); + + btn1 = elm_button_add(popup); + if (NULL == btn1) { + evas_object_del(popup); + return NULL; + } + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, D_("IDS_COM_SK_CANCEL")); + evas_object_data_set(popup, "button1", btn1); + elm_object_part_content_set(popup, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", _uninstall_no_cb, popup); + + btn2 = elm_button_add(popup); + if (NULL == btn2) { + evas_object_del(popup); + return NULL; + } + elm_object_style_set(btn2, "popup_button/default"); + elm_object_text_set(btn2, D_("IDS_COM_SK_OK")); + evas_object_data_set(popup, "button2", btn2); + elm_object_part_content_set(popup, "button2", btn2); + evas_object_smart_callback_add(btn2, "clicked", _uninstall_yes_cb, popup); + + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_data_set(popup, "func_destroy_popup", _uninstall_no_cb); + popup_info.popup = popup; + evas_object_show(popup); + char *name = _popup_set_name(item); + retv_if(NULL == name, popup); + + char *markup_name = elm_entry_utf8_to_markup(name); + if (NULL == markup_name) { + _E("(NULL == markup_name) -> %s() return", __func__); + free(name); + return popup; + } + + snprintf(warning, sizeof(warning), _(IDS_AT_POP_UNINSTALL_PS_Q), markup_name); + free(name); + free(markup_name); + + elm_object_text_set(popup, warning); + + return popup; +} + + + +// End of a file diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..864cb1e --- /dev/null +++ b/src/util.c @@ -0,0 +1,71 @@ + /* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +#include + +#include "util.h" + + + +HAPI void _evas_object_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Coord x; + Evas_Coord y; + Evas_Coord w; + Evas_Coord h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + _D("%s is resized to (%d, %d, %d, %d)", data, x, y, w, h); +} + + + +HAPI void _evas_object_event_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + _D("%s IS REMOVED!", (const char *) data); +} + + + +HAPI void _evas_object_event_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Coord x; + Evas_Coord y; + Evas_Coord w; + Evas_Coord h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + _D("%s's GEOMETRY : [%d, %d, %d, %d]", (const char *) data, x, y, w, h); +} + + + +HAPI void _evas_object_event_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Coord x; + Evas_Coord y; + Evas_Coord w; + Evas_Coord h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + _D("%s's GEOMETRY : [%d, %d, %d, %d]", (const char *) data, x, y, w, h); +} + + + +// End of a file