circle: add popup for wearable circle device 30/63930/3
authorTaeyoung Kim <ty317.kim@samsung.com>
Tue, 29 Mar 2016 01:12:29 +0000 (10:12 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Wed, 6 Apr 2016 02:56:08 +0000 (11:56 +0900)
- Popup for circle device needs to use theme for circle.

Change-Id: I41b94f245811cc1ad354ac363711ad5365d2aa05
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
CMakeLists.txt
circle_btn_check.png [new file with mode: 0644]
circle_btn_delete.png [new file with mode: 0644]
packaging/system-servant.spec
src/common/popup-ui-circle.c [new file with mode: 0755]
src/po/en_US.po
src/poweroff/CMakeLists.txt

index 19c1f86..062c067 100644 (file)
@@ -11,15 +11,24 @@ ADD_DEFINITIONS("-DPKGNAME=\"${PKGNAME}\"")
 ADD_DEFINITIONS("-DLOCALE_DIR=\"${LOCALE_DIR}\"")
 ADD_DEFINITIONS("-DLANG_DOMAIN=\"${LANG_DOMAIN}\"")
 ADD_DEFINITIONS("-DPROFILE=\"${PROFILE}\"")
+ADD_DEFINITIONS("-DFORMFACTOR=\"${FORMFACTOR}\"")
 
 SET(COMMON_DIR "${CMAKE_SOURCE_DIR}/src/common")
 SET(COMMON_SRCS
                ${COMMON_DIR}/core.c
                ${COMMON_DIR}/popup-common.c
                ${COMMON_DIR}/popup-ui.c
-               ${COMMON_DIR}/popup-ui-normal.c
 )
 
+IF("${FORMFACTOR}" STREQUAL "circle")
+       SET(COMMON_SRCS ${COMMON_SRCS}
+                       ${COMMON_DIR}/popup-ui-circle.c)
+ELSE()
+       SET(COMMON_SRCS ${COMMON_SRCS}
+                       ${COMMON_DIR}/popup-ui-normal.c)
+ENDIF()
+
+
 # DPMS
 IF("${DPMS}" STREQUAL "x")
 SET(COMMON_SRCS ${COMMON_SRCS}
diff --git a/circle_btn_check.png b/circle_btn_check.png
new file mode 100644 (file)
index 0000000..f20f62e
Binary files /dev/null and b/circle_btn_check.png differ
diff --git a/circle_btn_delete.png b/circle_btn_delete.png
new file mode 100644 (file)
index 0000000..5f346cb
Binary files /dev/null and b/circle_btn_delete.png differ
index bdc3270..d82bb9a 100755 (executable)
@@ -3,23 +3,29 @@
 %bcond_with emulator
 
 %define PROFILE common
+%define FORMFACTOR none
 
 #Main applications
 %define poweroff_popup on
 
-%if "%{?tizen_profile_name}" == "mobile"
+%if "%{?profile}" == "mobile"
 %define PROFILE mobile
 #Main applicaitons
 %define poweroff_popup on
 %endif
 
-%if "%{?tizen_profile_name}" == "wearable"
+%if "%{?profile}" == "wearable"
 %define PROFILE wearable
+%if "%_repository" == "target-circle" || "%_repository" == "emulator-circle"
+       %define FORMFACTOR circle
+%else
+       %define FORMFACTOR rectangle
+%endif
 #Main applicaitons
 %define poweroff_popup on
 %endif
 
-%if "%{?tizen_profile_name}" == "tv"
+%if "%{?profile}" == "tv"
 %define PROFILE tv
 %endif
 
@@ -89,6 +95,7 @@ cp %{SOURCE1001} .
                -DCMAKE_INSTALL_PREFIX=%{_prefix} \
                -DPKGNAME=%{name} \
                -DPROFILE=%{PROFILE} \
+               -DFORMFACTOR=%{FORMFACTOR} \
                -DDPMS=%{DPMS} \
                -DTZ_SYS_RO_APP=%{TZ_SYS_RO_APP} \
                -DTZ_SYS_RO_PACKAGES=%{TZ_SYS_RO_PACKAGES} \
@@ -96,7 +103,7 @@ cp %{SOURCE1001} .
                -DTZ_SYS_SHARE=%{TZ_SYS_SHARE} \
                -DTZ_SYS_RO_SHARE=%{TZ_SYS_RO_SHARE} \
                -DTZ_SYS_RO_APP=%{TZ_SYS_RO_APP} \
-               -DPOWEROFF_POPUP=%{poweroff_popup} \
+               -DPOWEROFF_POPUP=%{poweroff_popup}
 
 make %{?jobs:-j%jobs}
 
@@ -182,4 +189,6 @@ rm -rf %{buildroot}
 %defattr(-,root,root,-)
 %{TZ_SYS_RO_APP}/org.tizen.poweroff-syspopup/bin/poweroff-popup
 %{TZ_SYS_RO_SHARE}/packages/org.tizen.poweroff-syspopup.xml
+%{TZ_SYS_RO_APP}/org.tizen.poweroff-syspopup/res/circle_btn_check.png
+%{TZ_SYS_RO_APP}/org.tizen.poweroff-syspopup/res/circle_btn_delete.png
 %endif
diff --git a/src/common/popup-ui-circle.c b/src/common/popup-ui-circle.c
new file mode 100755 (executable)
index 0000000..74f5df2
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ *  system-popup
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "popup-ui.h"
+
+#define BUF_MAX 512
+
+int load_normal_popup(const struct popup_ops *ops)
+{
+       Evas_Object *btn;
+       Evas_Object *popup;
+       Evas_Object *layout;
+       Evas_Object *icon;
+       Evas_Object *win;
+       Evas_Smart_Cb clicked;
+       char *text;
+       char content[BUF_MAX];
+       struct object_ops *obj;
+       int ret;
+
+       if (!ops)
+               return -EINVAL;
+
+       ret = get_object_by_ops(ops, &obj);
+       if (ret < 0) {
+               _E("Failed to get object (%d)", ret);
+               return -EINVAL;
+       }
+
+       win = get_window();
+       if (!win)
+               return -ENOMEM;
+
+       evas_object_show(win);
+
+       popup = elm_popup_add(win);
+       if (!popup)
+               return -ENOMEM;
+
+       elm_object_style_set(popup, "circle");
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       layout = elm_layout_add(popup);
+       if (!layout)
+               return -ENOMEM;
+
+       if (!ops->left_text && !ops->right_text)
+               return -ENOENT;
+       if (ops->left_text && ops->right_text)
+               elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2");
+       else
+               elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1");
+       if (ops->title)
+               elm_object_part_text_set(layout, "elm.text.title", _(ops->title));
+
+       if (ops->content)
+               snprintf(content, sizeof(content), "%s", _(ops->content));
+       else if (ops->get_content) {
+               ret = ops->get_content(ops, content, sizeof(content));
+               if (ret < 0) {
+                       _E("Failed to get popup content");
+                       return ret;
+               }
+       } else
+               return -ENOENT;
+
+       text = elm_entry_utf8_to_markup(content);
+       if (!text)
+               return -ENOMEM;
+       elm_object_part_text_set(layout, "elm.text", text);
+       elm_object_content_set(popup, layout);
+       free(text);
+
+       if (ops->left_text && ops->right_text) { /* Two buttons */
+               /* Left button */
+               btn = elm_button_add(popup);
+               if (btn) {
+                       elm_object_style_set(btn, "popup/circle/left");
+                       evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+                       elm_object_part_content_set(popup, "button1", btn);
+                       evas_object_smart_callback_add(btn, "clicked", left_clicked, ops);
+
+                       icon = elm_image_add(btn);
+                       if (icon) {
+                               elm_image_file_set(icon, RESDIR"/circle_btn_delete.png", NULL);
+                               evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+                               elm_object_part_content_set(btn, "elm.swallow.content", icon);
+                               evas_object_show(icon);
+                       }
+               }
+
+               /* Right button */
+               btn = elm_button_add(popup);
+               if (btn) {
+                       elm_object_style_set(btn, "popup/circle/right");
+                       evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+                       elm_object_part_content_set(popup, "button2", btn);
+                       evas_object_smart_callback_add(btn, "clicked", right_clicked, ops);
+
+                       icon = elm_image_add(btn);
+                       if (icon) {
+                               elm_image_file_set(icon, RESDIR"/circle_btn_check.png", NULL);
+                               evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+                               elm_object_part_content_set(btn, "elm.swallow.content", icon);
+                               evas_object_show(icon);
+                       }
+               }
+       } else { /* One button */
+               if (ops->left_text) {
+                       text = ops->left_text;
+                       clicked = left_clicked;
+               } else {
+                       text = ops->right_text;
+                       clicked = right_clicked;
+               }
+
+               btn = elm_button_add(popup);
+               if (btn) {
+                       elm_object_style_set(btn, "bottom");
+                       elm_object_text_set(btn, _(text));
+                       evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+                       elm_object_part_content_set(popup, "button1", btn);
+                       evas_object_smart_callback_add(btn, "clicked", clicked, ops);
+               }
+       }
+
+       evas_object_show(popup);
+
+       obj->popup = popup;
+
+       return 0;
+}
index 8faf794..554b34c 100755 (executable)
@@ -206,7 +206,7 @@ msgid "IDS_SYNCML_POP_DM_REMOVE_CHARGER"
 msgstr "Remove charger."
 
 msgid "IDS_TPLATFORM_BODY_POWER_OFF_THE_DEVICE_Q"
-msgstr "Turn off the phone?"
+msgstr "Turn off the device?"
 
 msgid "IDS_USB_BODY_BROWSE_CAMERA_CONNECTED_VIA_USB_Q"
 msgstr "Browse camera connected via USB?"
index f7cec3e..12b9aa8 100755 (executable)
@@ -54,6 +54,7 @@ SET(CMAKE_C_FLAGS_RELEASE "-O2 -fpie")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
@@ -62,3 +63,6 @@ TARGET_LINK_LIBRARIES(${EXECNAME} ${poweroff_pkgs_LDFLAGS})
 
 INSTALL(TARGETS ${EXECNAME} DESTINATION ${TZ_SYS_RO_APP}/${PKGNAME}/bin)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/poweroff/${PKGNAME}.xml DESTINATION ${MANIFESTDIR})
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/circle_btn_check.png DESTINATION ${RESDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/circle_btn_delete.png DESTINATION ${RESDIR})