--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(sticker-panel C)
+
+SET(VERSION 0.1.0)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(INCLUDEDIR "${PREFIX}/include/${PROJECT_NAME}")
+
+SET(LIBDIR "${LIB_INSTALL_DIR}")
+
+SET(ICONDIR "${SHAREDIR}/icons")
+SET(PANELDIR "${SHAREDIR}/${PROJECT_NAME}")
+
+SET(EDJEDIR "${PANELDIR}/edje")
+SET(IMAGEDIR "${PANELDIR}/images")
+SET(LOCALEDIR "${PANELDIR}/locale")
+SET(SAMPLEDIR "${PANELDIR}/sample")
+
+SET(INSTALL_HEADERS_DEVEL
+ sticker_panel.h
+)
+
+SET(SRCS
+ src/sticker_panel.c
+ src/grid.c
+ src/page.c
+ src/scroller.c
+ src/toolbar.c
+ src/ui_manager.c
+ src/naviframe.c
+ src/icon_info.c
+ src/db.c
+ src/gesture.c
+ src/group_icon_info.c
+ src/setting.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ capi-appfw-application
+ capi-base-common
+ appcore-efl
+ dlog
+ elementary
+ evas
+ feedback
+ isf
+ efl-extension
+ sqlite3
+ bundle
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -g -Wall -O2")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DPANELDIR=\"${PANELDIR}\"")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0.1.0)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/A01-1_icon_Menu.png DESTINATION ${ICONDIR})
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig)
+
+FOREACH(hfile ${INSTALL_HEADERS_DEVEL})
+ INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/${hfile} DESTINATION include/${PROJECT_NAME})
+ENDFOREACH(hfile)
+
+# subdir
+ADD_SUBDIRECTORY(res)
+ADD_SUBDIRECTORY(sample)
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ 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.
+
+ 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,
+ 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 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 in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) 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
+
+ (d) 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.
+
+ 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 Apache License to your work.
+
+ To apply the Apache 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 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.
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_DOC_H__
+#define __TIZEN_STICKER_PANEL_DOC_H__
+
+/**
+ * @ingroup CAPI_PANEL_MODULE
+ * @defgroup CAPI_PANEL_STICKER_MODULE Sticker panel
+ * @brief The Sticker Panel provides functions to attach stickers easily. Users can select stickers to attach into the caller app
+ * @section CAPI_PANEL_STICKER_MODULE_HEADER Required Header
+ * \#include <sticker_panel.h>
+ * @section CAPI_PANEL_STICKER_MODULE_OVERVIEW Overview
+ * It provides functions for adding an sticker panel (sticker_panel_create()) and deleting it (sticker_panel_destroy()) in an app.\n
+ * It is shown with (sticker_panel_show()) and hiden with (sticker_panel_hide()).\n
+ * The results can be returned into the result callback that is set (sticker_panel_set_result_cb()) or unset (sticker_panel_unset_result_cb()).\n
+ */
+
+#endif
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_CONF_H__
+#define __TIZEN_STICKER_PANEL_CONF_H__
+
+#define TOOLBAR_HEIGHT 54
+#define BASE_TRANSIT_HEIGHT_REL 0.34
+#define GRID_ITEM_PER_ROW 4
+#define GRID_ITEM_ICON_RATIO 0.75f
+#define CATEGORY_COUNT 1
+
+#define PATH_LEN 1024
+
+#define PRELOADED_PRESET_DIR_PATH "/usr/share/sticker-panel/images"
+#define DOWNLOADED_PRESET_DIR_PATH "/opt/usr/share/sticker-panel/images"
+#define USER_DEFINED_DIR_PATH "/usr/share/sticker-panel/images/.user"
+
+#endif
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_CONFORMANT_H__
+#define __TIZEN_STICKER_PANEL_CONFORMANT_H__
+
+Evas_Object *_conformant_create(Evas_Object *caller_conformant, Eina_Bool show_indicator);
+void _conformant_destroy(Evas_Object *conformant);
+
+#endif /* __TIZEN_STICKER_PANEL_CONFORMANT_H__ */
--- /dev/null
+/*
+ * Samsung API
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
+ *
+ * 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/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 __STICKER_PANEL_DB_H__
+#define __STICKER_PANEL_DB_H__
+
+#include <sqlite3.h>
+#include "sticker_panel.h"
+
+extern sqlite3 *_db_open(void);
+extern void _db_close(sqlite3 *db);
+
+extern sqlite3_stmt *_db_prepare(sqlite3 *db, const char *query);
+extern int _db_next(sqlite3 *db, sqlite3_stmt *stmt);
+extern sticker_panel_error_e _db_reset(sqlite3 *db, sqlite3_stmt *stmt);
+
+extern sticker_panel_error_e _db_bind_bool(sqlite3 *db, sqlite3_stmt *stmt, int idx, bool value);
+extern sticker_panel_error_e _db_bind_int(sqlite3 *db, sqlite3_stmt *stmt, int idx, int value);
+extern sticker_panel_error_e _db_bind_double(sqlite3 *db, sqlite3_stmt *stmt, int idx, double value);
+extern sticker_panel_error_e _db_bind_str(sqlite3 *db, sqlite3_stmt *stmt, int idx, const char *str);
+
+extern bool _db_get_bool(sqlite3_stmt *stmt, int index);
+extern int _db_get_int(sqlite3_stmt *stmt, int index);
+extern int _db_get_double(sqlite3_stmt *stmt, int index);
+extern const char *_db_get_str(sqlite3_stmt *stmt, int index);
+
+extern sticker_panel_error_e _db_finalize(sqlite3 *db, sqlite3_stmt *stmt);
+extern sticker_panel_error_e _db_exec(sqlite3 *db, const char *query);
+
+extern sticker_panel_error_e _db_create_table(sqlite3 *db);
+extern sticker_panel_error_e _db_drop_table(sqlite3 *db);
+
+extern sticker_panel_error_e _db_insert_version(sqlite3 *db, int version);
+extern sticker_panel_error_e _db_delete_version(sqlite3 *db, int version);
+extern sticker_panel_error_e _db_update_version(sqlite3 *db, int version);
+extern sticker_panel_error_e _db_count_version(sqlite3 *db);
+
+extern sticker_panel_error_e _db_count_recent_icon(sqlite3 *db, const char *id, int type, int *count);
+extern sticker_panel_error_e _db_touch_recent_icon(sqlite3 *db, const char *id, int type);
+extern sticker_panel_error_e _db_delete_recent_icon(sqlite3 *db, const char *id, int type);
+extern sticker_panel_error_e _db_list_recent_icon(sqlite3 *db, Eina_List **list, int limit);
+
+extern sticker_panel_error_e _db_initialize_group_icon(sqlite3 *db);
+extern sticker_panel_error_e _db_count_group_icon(sqlite3 *db, const char *id, int *count);
+extern sticker_panel_error_e _db_insert_group_icon(sqlite3 *db, const char *id, const char *name, const char *repository, int ordering, int category);
+extern sticker_panel_error_e _db_delete_group_icon(sqlite3 *db, const char *id);
+extern sticker_panel_error_e _db_update_group_icon(sqlite3 *db, const char *id, int ordering);
+extern sticker_panel_error_e _db_list_group_icon(sqlite3 *db, Eina_List **group_icon_info_list);
+extern sticker_panel_error_e _db_increment_group_icon(sqlite3 *db, int from, int to, int category);
+extern sticker_panel_error_e _db_decrement_group_icon(sqlite3 *db, int from, int to, int category);
+
+#endif /* __STICKER_PANEL_DB_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_GESTURE_H__
+#define __TIZEN_STICKER_PANEL_GESTURE_H__
+
+extern void _gesture_show(sticker_panel_h sticker_panel);
+extern void _gesture_hide(sticker_panel_h sticker_panel);
+
+#endif
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_GRID_H__
+#define __TIZEN_STICKER_PANEL_GRID_H__
+
+#include <Elementary.h>
+#include "sticker_panel.h"
+#include "icon_info.h"
+
+extern Evas_Object *_grid_create(Evas_Object *page, sticker_panel_h sticker_panel);
+extern void _grid_destroy(Evas_Object *grid);
+
+extern Elm_Object_Item *_grid_prepend_item(Evas_Object *grid, sticker_panel_h sticker_panel, icon_info_s *icon_info);
+extern Elm_Object_Item *_grid_append_item(Evas_Object *grid, sticker_panel_h sticker_panel, icon_info_s *icon_info);
+extern void _grid_remove_item(Evas_Object *grid, Elm_Object_Item *item);
+
+extern Elm_Object_Item *_grid_get_item(Evas_Object *grid, const char *id, int type);
+extern int _grid_count_item(Evas_Object *grid);
+
+#endif /* __TIZEN_STICKER_PANEL_GRID_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_GROUP_ICON_INFO_H__
+#define __TIZEN_STICKER_PANEL_GROUP_ICON_INFO_H__
+
+#include <Elementary.h>
+#include <sqlite3.h>
+
+struct _group_icon_info_s {
+ /* innate features */
+ char *id;
+ char *name;
+ char *repository;
+ int ordering;
+ int category;
+
+ /* acquired features */
+ Eina_List *list;
+ Evas_Object *item_view;
+ Elm_Object_Item *toolbar_item;
+ char *toolbar_icon_path;
+ int permutable;
+ int initialized;
+ int recent;
+ int removable;
+};
+typedef struct _group_icon_info_s group_icon_info_s;
+
+extern group_icon_info_s *_group_icon_info_create(const char *id, const char *name, const char *repository, int ordering, int category);
+extern void _group_icon_info_destroy(group_icon_info_s *group_icon_info);
+
+extern Eina_List *_group_icon_info_list_create(sqlite3 *db);
+extern void _group_icon_info_list_destroy(Eina_List *group_icon_info_list);
+extern Eina_List *_group_icon_info_list_sort(Eina_List *group_icon_info_list);
+extern Eina_List *_group_icon_info_list_trim(Eina_List *group_icon_info_list, sqlite3 *db);
+extern group_icon_info_s *_group_icon_info_list_get(Eina_List *group_icon_info_list, const char *id);
+
+#endif /* __TIZEN_STICKER_PANEL_GROUP_ICON_INFO_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_ICON_INFO_H__
+#define __TIZEN_STICKER_PANEL_ICON_INFO_H__
+
+typedef enum {
+ ICON_INFO_TYPE_NONE = 0,
+ ICON_INFO_TYPE_DIRECTORY = 1,
+ ICON_INFO_TYPE_FILE,
+ ICON_INFO_TYPE_ID,
+ ICON_INFO_TYPE_MAX,
+} icon_info_type_e;
+
+typedef struct _icon_info_s {
+ /* Primary key */
+ char *dir_path;
+ int type;
+
+ /* Innate features */
+ char *keyword;
+ char *thumbnail_file;
+ int repeat;
+ int interval;
+ int play_type;
+ int th_frame;
+ int width;
+ int height;
+ Eina_List *icon_info_image_list;
+ Eina_Bool animation;
+
+ /* Acquired features */
+ Elm_Object_Item *tabbar_item;
+ Evas_Object *icon;
+} icon_info_s;
+
+typedef struct _icon_info_image_s {
+ char *file;
+ int frame_order;
+ int diff_time;
+} icon_info_image_s;
+
+extern icon_info_s *_icon_info_create(const char *id, int type);
+extern icon_info_s *_icon_info_create_thumbnail(const char *thumbnail_file);
+extern void _icon_info_destroy(icon_info_s *icon_info);
+
+extern Eina_List *_icon_info_list_create_preset_package(const char *dir_path);
+extern Eina_List *_icon_info_list_create_user_defined(const char *dir_path);
+extern Eina_List *_icon_info_list_create_recent_package(sqlite3 *db);
+extern void _icon_info_list_destroy(Eina_List *list);
+
+#endif /* __TIZEN_STICKER_PANEL_ICON_INFO_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_LOG_H__
+#define __TIZEN_STICKER_PANEL_LOG_H__
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "STICKER_PANEL"
+
+#if !defined(_D)
+#define _D(fmt, arg...) LOGD(fmt"\n", ##arg)
+#endif
+
+#if !defined(_W)
+#define _W(fmt, arg...) LOGW(fmt"\n", ##arg)
+#endif
+
+#if !defined(_E)
+#define _E(fmt, arg...) LOGE(fmt"\n", ##arg)
+#endif
+
+#if !defined(_SD)
+#define _SD(fmt, arg...) SECURE_LOGD(fmt"\n", ##arg)
+#endif
+
+#if !defined(_SW)
+#define _SW(fmt, arg...) SECURE_LOGW(fmt"\n", ##arg)
+#endif
+
+#if !defined(_SE)
+#define _SE(fmt, arg...) SECURE_LOGE(fmt"\n", ##arg)
+#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; \
+ } \
+}
+
+#endif /* __TIZEN_STICKER_PANEL_LOG_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_NAVIFRAME_H__
+#define __TIZEN_STICKER_PANEL_NAVIFRAME_H__
+
+typedef enum sticker_panel_navi_btn_type {
+ STICKER_PANEL_NAVI_BTN_RIGHT = 1,
+ STICKER_PANEL_NAVI_BTN_LEFT = 2,
+ STICKER_PANEL_NAVI_BTN_MAX,
+} sticker_panel_navi_btn_type_e;
+
+typedef void (*btn_clicked_cb)(void *data, Evas_Object *obj, void *event_info);
+
+Evas_Object *_naviframe_create(Evas_Object *conformant);
+void _naviframe_destroy(Evas_Object *navi);
+
+void _naviframe_set_title(Evas_Object *navi, const char *title);
+Evas_Object *_naviframe_button_create(Evas_Object *navi, sticker_panel_navi_btn_type_e btn_type, const char *text, btn_clicked_cb clicked_cb, void *data);
+void _naviframe_button_destroy(Evas_Object *navi, sticker_panel_navi_btn_type_e btn_type);
+
+void _naviframe_show(Evas_Object *navi);
+void _naviframe_hide(Evas_Object *navi);
+
+#endif /* __TIZEN_STICKER_PANEL_NAVIFRAME_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_PAGE_H__
+#define __TIZEN_STICKER_PANEL_PAGE_H__
+
+#include <Elementary.h>
+
+extern Evas_Object *_page_create(Evas_Object *scroller, int width, int height);
+extern void _page_destroy(Evas_Object *page);
+
+extern void _page_resize(Evas_Object *page, int width, int height);
+
+#endif /* __TIZEN_STICKER_PANEL_PAGE_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_SCROLLER_H__
+#define __TIZEN_STICKER_PANEL_SCROLLER_H__
+
+#include <Elementary.h>
+
+typedef enum {
+ SCROLLER_EVENT_TYPE_INVALID = 0,
+ SCROLLER_EVENT_TYPE_SCROLL,
+ SCROLLER_EVENT_TYPE_MAX,
+} scroller_event_type_e;
+
+extern Evas_Object *_scroller_create(Evas_Object *ui_manager, sticker_panel_h sticker_panel);
+extern void _scroller_destroy(Evas_Object *scroller);
+
+extern void _scroller_append_page(Evas_Object *scroller, Evas_Object *page);
+extern void _scroller_remove_page(Evas_Object *scroller, Evas_Object *page);
+extern void _scroller_reorder_page(Evas_Object *scroller, Eina_List *group_icon_info_list);
+
+extern void _scroller_bring_in_page(Evas_Object *scroller, Evas_Object *page, int *cur_page_no);
+
+extern int _scroller_is_scrolling(Evas_Object *scroller);
+extern void _scroller_resize(Evas_Object *scroller, int width, int height);
+
+extern int _scroller_register_event_cb(Evas_Object *scroller, int event_type, void (*event_cb)(Evas_Object *scroller, int event_type, void *event_info, void *data), void *data);
+extern int _scroller_unregister_event_cb(Evas_Object *scroller, int event_type, void (*event_cb)(Evas_Object *scroller, int event_type, void *event_info, void *data));
+
+#endif /* __TIZEN_STICKER_PANEL_SCROLLER_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_SETTING_H__
+#define __TIZEN_STICKER_PANEL_SETTING_H__
+
+typedef enum setting_view_type {
+ SETTING_VIEW_NONE = 0,
+ SETTING_VIEW_REORDER,
+ SETTING_VIEW_DOWNLOAD,
+ SETTING_VIEW_DELETE,
+ SETTING_VIEW_MAX,
+} setting_view_type_e;
+
+extern Evas_Object *_setting_create(Evas_Object *parent, sticker_panel_h sticker_panel);
+extern void _setting_destroy(Evas_Object *setting);
+
+#endif /* __TIZEN_STICKER_PANEL_SETTING_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_H__
+#define __TIZEN_STICKER_PANEL_H__
+
+#include <Elementary.h>
+#include <tizen_error.h>
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file sticker_panel.h
+ * @brief Declares the API of the libsticker-panel library.
+ */
+
+/**
+ * @addtogroup CAPI_PANEL_STICKER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Definition for the sticker result type.
+ * @since_tizen 2.4
+ */
+#define STICKER_PANEL_RESULT_TYPE "__STICKER_PANEL_RESULT_TYPE__"
+
+/**
+ * @brief Definition for the sticker result value.
+ * @since_tizen 2.4
+ */
+#define STICKER_PANEL_RESULT_VALUE "__STICKER_PANEL_RESULT_VALUE__"
+
+/**
+ * @brief Definition for the sticker type : directory type for giving the directory path that includes sticker files.
+ * @since_tizen 2.4
+ */
+#define STICKER_PANEL_RESULT_TYPE_DIRECTORY "__STICKER_PANEL_RESULT_TYPE_DIRECTORY__"
+
+/**
+ * @brief Definition for the sticker type : file type for giving the file path.
+ * @since_tizen 2.4
+ */
+#define STICKER_PANEL_RESULT_TYPE_FILE "__STICKER_PANEL_RESULT_TYPE_FILE__"
+
+/**
+ * @brief Sticker panel handle.
+ * @since_tizen 2.4
+ */
+typedef struct _sticker_panel *sticker_panel_h;
+
+/**
+ * @brief Called when an user selects and confirms sticker(s) to attach on the caller app.
+ *
+ * @since_tizen 2.4
+ * @param[in] sticker_panel Sticker panel handler
+ * @param[in] result bundle.\n
+ * The sticker panel returns stickers loading a @a bundle\n
+ * if directory, the sticker panel makes two bundles\n
+ * key : #STICKER_PANEL_RESULT_TYPE, value : #STICKER_PANEL_RESULT_TYPE_DIRECTORY\n
+ * key : #STICKER_PANEL_RESULT_VALUE, value : a directory path\n
+ * if file, the sticker panel makes two bundle\n
+ * key : #STICKER_PANEL_RESULT_TYPE, value : #STICKER_PANEL_RESULT_TYPE_FILE\n
+ * key : #STICKER_PANEL_RESULT_VALUE, value : a file path\n
+ * @param[in] user_data user data
+ * @pre The callback must be registered using sticker_panel_set_result_cb()\n
+ * sticker_panel_show() must be called to invoke this callback.
+ *
+ * @see @ref CORE_LIB_BUNDLE_MODULE API bundle_get_str()
+ * @see sticker_panel_set_result_cb()
+ * @see sticker_panel_unset_result_cb()
+ */
+typedef void (*sticker_panel_result_cb)(sticker_panel_h sticker_panel, bundle *b, void *user_data);
+
+/**
+ * @brief Enumeration for values of the sticker panel response types.
+ * @since_tizen 2.4
+ */
+typedef enum sticker_panel_error {
+ STICKER_PANEL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successfully handled */
+ STICKER_PANEL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Request is not valid, invalid parameter or invalid argument value */
+ STICKER_PANEL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Memory is not enough to handle a new request */
+ STICKER_PANEL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Has no permission to attach contents */
+ STICKER_PANEL_ERROR_ALREADY_EXISTS = TIZEN_ERROR_PANEL | 0x01, /**< There is already a panel in the conformant */
+ STICKER_PANEL_ERROR_NOT_INITIALIZED = TIZEN_ERROR_PANEL | 0x02, /**< The panel is not initialized yet */
+ STICKER_PANEL_ERROR_DB_FAILED = TIZEN_ERROR_PANEL | 0x04, /**< The panel cannot access DB */
+ STICKER_PANEL_ERROR_ALREADY_REMOVED = TIZEN_ERROR_PANEL | 0x05, /**< The panel is already removed */
+} sticker_panel_error_e;
+
+/**
+ * @brief Enumeration for values of the sticker panel view mode.
+ * @since_tizen 2.4
+ */
+typedef enum sticker_panel_view_mode {
+ STICKER_PANEL_VIEW_MODE_HALF = 1, /**< Half mode */
+ STICKER_PANEL_VIEW_MODE_FULL, /**< Full mode */
+} sticker_panel_view_mode_e;
+
+/**
+ * @brief Creates an sticker panel.
+ *
+ * @since_tizen 2.4
+ *
+ * @privlevel public
+ *
+ * @remarks The caller app has to check the return value of this function.\n
+ * A conformant object can have only one @a sticker_panel_h.\n
+ * If a caller app try to add more than one sticker panel, it fails to add it.
+ *
+ * @param[in] conformant The caller's conformant
+ * @param[out] sticker_panel Sticker panel handler
+ * @return #STICKER_PANEL_ERROR_NONE on success,
+ * otherwise a negative error value
+ * @retval #STICKER_PANEL_ERROR_NONE Successful
+ * @retval #STICKER_PANEL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STICKER_PANEL_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STICKER_PANEL_ERROR_PERMISSION_DENIED permission denied
+ *
+ * @see sticker_panel_destroy()
+ * @see sticker_panel_set_result_cb()
+ * @see sticker_panel_unset_result_cb()
+ * @see sticker_panel_set_view_mode()
+ * @see sticker_panel_show()
+ * @see sticker_panel_hide()
+ *
+ * @par Example
+ * @code
+ * #include <sticker_panel.h>
+ *
+ * static struct appdata {
+ * Evas_Object *sticker_panel;
+ * Evas_Object *conformant;
+ * };
+ *
+ * static void _result_cb(sticker_panel_h sticker_panel, bundle *b, void *data)
+ * {
+ * int i = 0;
+ * int length = 0;
+ * int ret = APP_CONTROL_ERROR_NONE;
+ * char type[1024];
+ * char value[1024];
+ *
+ * if (!sticker_panel) {
+ * // Error handling
+ * }
+ *
+ * if (!b) {
+ * // Error handling
+ * }
+ *
+ * ret = bundle_get_str(b, STICKER_PANEL_RESULT_TYPE, &type);
+ * if (BUNDLE_ERROR_NONE != ret) {
+ * // Error handling
+ * } else if (!type) {
+ * // Error handling
+ * }
+ *
+ * ret = bundle_get_str(b, STICKER_PANEL_RESULT_VALUE, &value);
+ * if (BUNDLE_ERROR_NONE != ret) {
+ * // Error handling
+ * } else if (!value) {
+ * // Error handling
+ * }
+ *
+ * if (!strcmp(type, STICKER_PANEL_RESULT_TYPE_DIRECTORY)) {
+ * // Routines for the directory
+ * } else if (!strcmp(type, STICKER_PANEL_RESULT_TYPE_FILE)) {
+ * // Routines for the file
+ * } else {
+ * // Error handling
+ * }
+ * }
+ *
+ * static int app_control(void *data)
+ * {
+ * struct appdata *ad = data;
+ * int ret = STICKER_PANEL_ERROR_NONE;
+ *
+ * if (!ad) {
+ * // Error handling
+ * }
+ *
+ * if (!ad->conformant) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_create(ad->conformant, &ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_set_result_cb(ad->sticker_panel, _result_cb, NULL);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_show(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * return 0;
+ * }
+ *
+ * @endcode
+ */
+int sticker_panel_create(Evas_Object *conformant, sticker_panel_h *sticker_panel);
+
+/**
+ * @brief Destroys the sticker panel.
+ *
+ * @since_tizen 2.4
+ *
+ * @privlevel public
+ *
+ * @remarks The caller app has to check the return value of this function.\n
+ *
+ * @param[in] sticker_panel Sticker panel handler
+ * @return #STICKER_PANEL_ERROR_NONE on success,
+ * otherwise a negative error value
+ * @retval #STICKER_PANEL_ERROR_NONE Successful
+ * @retval #STICKER_PANEL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STICKER_PANEL_ERROR_ALREADY_REMOVED already removed
+ *
+ * @see sticker_panel_create()
+ * @see sticker_panel_set_result_cb()
+ * @see sticker_panel_unset_result_cb()
+ * @see sticker_panel_set_view_mode()
+ * @see sticker_panel_show()
+ * @see sticker_panel_hide()
+ *
+ * @par Example
+ * @code
+ * #include <sticker_panel.h>
+ *
+ * static struct appdata {
+ * Evas_Object *sticker_panel;
+ * Evas_Object *conformant;
+ * };
+ *
+ * static int app_terminate(void *data)
+ * {
+ * struct appdata *ad = data;
+ * int ret = 0;
+ *
+ * if (!ad) {
+ * // Error handling
+ * }
+ *
+ * if (!ad->sticker_panel) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_hide(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_unset_result_cb(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_destroy(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ * ad->sticker_panel = NULL;
+ *
+ * return 0;
+ * }
+ *
+ * @endcode
+ */
+int sticker_panel_destroy(sticker_panel_h sticker_panel);
+
+/**
+ * @brief Sets the result callback that will be called when an user selects and confirms something to sticker in the sticker panel.
+ *
+ * @since_tizen 2.4
+ *
+ * @privlevel public
+ *
+ * @remarks The caller app has to check the return value of this function.\n
+ * You can set only one callback function with this API.\n
+ * If you set multiple callbacks with this API,\n
+ * the last one is registered only.
+ *
+ * @param[in] sticker_panel Sticker panel handler
+ * @param[in] result_cb Sticker panel result callback
+ * @param[in] user_data User data
+ * @return #STICKER_PANEL_ERROR_NONE on success,
+ * otherwise a negative error value
+ * @retval #STICKER_PANEL_ERROR_NONE Successful
+ * @retval #STICKER_PANEL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STICKER_PANEL_ERROR_ALREADY_REMOVED already removed
+ *
+ * @pre Calls sticker_panel_create() before calling this function.
+ * @post The result_cb set with sticker_panel_set_result_cb() will be called after an user select something to attach.
+ * @see sticker_panel_create()
+ * @see sticker_panel_destroy()
+ * @see sticker_panel_unset_result_cb()
+ * @see sticker_panel_set_view_mode()
+ * @see sticker_panel_show()
+ * @see sticker_panel_hide()
+ * @see sticker_panel_result_cb
+ *
+ * @par Example
+ * @code
+ * #include <sticker_panel.h>
+ *
+ * static struct appdata {
+ * Evas_Object *sticker_panel;
+ * Evas_Object *conformant;
+ * };
+ *
+ * static void _result_cb(sticker_panel_h sticker_panel, bundle *b, void *data)
+ * {
+ * int i = 0;
+ * int length = 0;
+ * int ret = APP_CONTROL_ERROR_NONE;
+ * char type[1024];
+ * char value[1024];
+ *
+ * if (!sticker_panel) {
+ * // Error handling
+ * }
+ *
+ * if (!b) {
+ * // Error handling
+ * }
+ *
+ * ret = bundle_get_str(b, STICKER_PANEL_RESULT_TYPE, &type);
+ * if (BUNDLE_ERROR_NONE != ret) {
+ * // Error handling
+ * } else if (!type) {
+ * // Error handling
+ * }
+ *
+ * ret = bundle_get_str(b, STICKER_PANEL_RESULT_VALUE, &value);
+ * if (BUNDLE_ERROR_NONE != ret) {
+ * // Error handling
+ * } else if (!value) {
+ * // Error handling
+ * }
+ *
+ * if (!strcmp(type, STICKER_PANEL_RESULT_TYPE_DIRECTORY)) {
+ * // Routines for the directory
+ * } else if (!strcmp(type, STICKER_PANEL_RESULT_TYPE_FILE)) {
+ * // Routines for the file
+ * } else {
+ * // Error handling
+ * }
+ * }
+ *
+ * static int app_control(void *data)
+ * {
+ * struct appdata *ad = data;
+ * int ret = STICKER_PANEL_ERROR_NONE;
+ *
+ * if (!ad) {
+ * // Error handling
+ * }
+ *
+ * if (!ad->conformant) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_create(ad->conformant, &ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_set_result_cb(ad->sticker_panel, _result_cb, NULL);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_show(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * return 0;
+ * }
+ *
+ * @endcode
+ */
+int sticker_panel_set_result_cb(sticker_panel_h sticker_panel, sticker_panel_result_cb result_cb, void *user_data);
+
+/**
+ * @brief Unsets the result callback that will be called when an user selects and confirms something to sticker in the sticker panel.
+ *
+ * @since_tizen 2.4
+ *
+ * @privlevel public
+ *
+ * @remarks The caller app has to check the return value of this function.\n
+ *
+ * @param[in] sticker_panel Sticker panel handler
+ * @param[in] result_cb Sticker panel result callback
+ * @return #STICKER_PANEL_ERROR_NONE on success,
+ * otherwise a negative error value
+ * @retval #STICKER_PANEL_ERROR_NONE Successful
+ * @retval #STICKER_PANEL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STICKER_PANEL_ERROR_ALREADY_REMOVED already removed
+ *
+ * @pre Calls sticker_panel_create() before calling this function.
+ * @see sticker_panel_create()
+ * @see sticker_panel_destroy()
+ * @see sticker_panel_set_result_cb()
+ * @see sticker_panel_set_view_mode()
+ * @see sticker_panel_show()
+ * @see sticker_panel_hide()
+ *
+ * @par Example
+ * @code
+ * #include <sticker_panel.h>
+ *
+ * static struct appdata {
+ * Evas_Object *sticker_panel;
+ * Evas_Object *conformant;
+ * };
+ *
+ * static int app_terminate(void *data)
+ * {
+ * struct appdata *ad = data;
+ * int ret = 0;
+ *
+ * if (!ad) {
+ * // Error handling
+ * }
+ *
+ * if (!ad->sticker_panel) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_hide(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_unset_result_cb(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_destroy(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ * ad->sticker_panel = NULL;
+ *
+ * return 0;
+ * }
+ *
+ * @endcode
+ */
+int sticker_panel_unset_result_cb(sticker_panel_h sticker_panel);
+
+/**
+ * @brief Sets the view mode that has half and full modes.
+ *
+ * @since_tizen 2.4
+ *
+ * @privlevel public
+ *
+ * @remarks The caller app has to check the return value of this function.\n
+ * You need to set a mode with this API before using sticker_panel_show().\n
+ * The default mode is the half mode.
+ *
+ * @param[in] sticker_panel Sticker panel handler
+ * @param[in] view_mode Sticker panel view mode
+ * @return #STICKER_PANEL_ERROR_NONE on success,
+ * otherwise a negative error value
+ * @retval #STICKER_PANEL_ERROR_NONE Successful
+ * @retval #STICKER_PANEL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STICKER_PANEL_ERROR_ALREADY_REMOVED already removed
+ *
+ * @pre Calls sticker_panel_create() before calling this function.
+ * @see sticker_panel_create()
+ * @see sticker_panel_destroy()
+ * @see sticker_panel_set_result_cb()
+ * @see sticker_panel_unset_result_cb()
+ * @see sticker_panel_show()
+ * @see sticker_panel_hide()
+ *
+ * @par Example
+ * @code
+ * #include <sticker_panel.h>
+ *
+ * static struct appdata {
+ * Evas_Object *sticker_panel;
+ * Evas_Object *conformant;
+ * };
+ *
+ * static int app_control(void *data)
+ * {
+ * struct appdata *ad = data;
+ * int ret = STICKER_PANEL_ERROR_NONE;
+ *
+ * if (!ad) {
+ * // Error handling
+ * }
+ *
+ * if (!ad->conformant) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_create(ad->conformant, &ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_set_view_mode(ad->sticker_panel, STICKER_PANEL_VIEW_MODE_HALF);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_show(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * return 0;
+ * }
+ *
+ * @endcode
+ */
+int sticker_panel_set_view_mode(sticker_panel_h sticker_panel, sticker_panel_view_mode_e view_mode);
+
+/**
+ * @brief Shows the sticker panel, asynchronously.
+ *
+ * @since_tizen 2.4
+ *
+ * @privlevel public
+ *
+ * @remarks The caller app has to check the return value of this function.\n
+ *
+ * @param[in] sticker_panel Sticker panel handler
+ * @return #STICKER_PANEL_ERROR_NONE on success,
+ * otherwise a negative error value
+ * @retval #STICKER_PANEL_ERROR_NONE Successful
+ * @retval #STICKER_PANEL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STICKER_PANEL_ERROR_ALREADY_REMOVED already removed
+ *
+ * @pre Calls sticker_panel_create() before calling this function.
+ * @see sticker_panel_create()
+ * @see sticker_panel_destroy()
+ * @see sticker_panel_set_result_cb()
+ * @see sticker_panel_unset_result_cb()
+ * @see sticker_panel_set_view_mode()
+ * @see sticker_panel_hide()
+ *
+ * @par Example
+ * @code
+ * #include <sticker_panel.h>
+ *
+ * static struct appdata {
+ * Evas_Object *sticker_panel;
+ * Evas_Object *conformant;
+ * };
+ *
+ * static void _result_cb(sticker_panel_h sticker_panel, bundle *b, void *data)
+ * {
+ * int i = 0;
+ * int length = 0;
+ * int ret = APP_CONTROL_ERROR_NONE;
+ * char type[1024];
+ * char value[1024];
+ *
+ * if (!sticker_panel) {
+ * // Error handling
+ * }
+ *
+ * if (!b) {
+ * // Error handling
+ * }
+ *
+ * ret = bundle_get_str(b, STICKER_PANEL_RESULT_TYPE, &type);
+ * if (BUNDLE_ERROR_NONE != ret) {
+ * // Error handling
+ * } else if (!type) {
+ * // Error handling
+ * }
+ *
+ * ret = bundle_get_str(b, STICKER_PANEL_RESULT_VALUE, &value);
+ * if (BUNDLE_ERROR_NONE != ret) {
+ * // Error handling
+ * } else if (!value) {
+ * // Error handling
+ * }
+ *
+ * if (!strcmp(type, STICKER_PANEL_RESULT_TYPE_DIRECTORY)) {
+ * // Routines for the directory
+ * } else if (!strcmp(type, STICKER_PANEL_RESULT_TYPE_FILE)) {
+ * // Routines for the file
+ * } else {
+ * // Error handling
+ * }
+ * }
+ *
+ * static int app_control(void *data)
+ * {
+ * struct appdata *ad = data;
+ * int ret = STICKER_PANEL_ERROR_NONE;
+ *
+ * if (!ad) {
+ * // Error handling
+ * }
+ *
+ * if (!ad->conformant) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_create(ad->conformant, &ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_set_result_cb(ad->sticker_panel, _result_cb, NULL);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_show(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * return 0;
+ * }
+ *
+ * @endcode
+ */
+int sticker_panel_show(sticker_panel_h sticker_panel);
+
+/**
+ * @brief Hides the sticker panel, asynchronously.
+ *
+ * @since_tizen 2.4
+ *
+ * @privlevel public
+ *
+ * @remarks The caller app has to check the return value of this function.\n
+ *
+ * @param[in] sticker_panel Sticker panel handler
+ * @return #STICKER_PANEL_ERROR_NONE on success,
+ * otherwise a negative error value
+ * @retval #STICKER_PANEL_ERROR_NONE Successful
+ * @retval #STICKER_PANEL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STICKER_PANEL_ERROR_ALREADY_REMOVED already removed
+ *
+ * @pre Calls sticker_panel_create() before calling this function.
+ * @see sticker_panel_create()
+ * @see sticker_panel_destroy()
+ * @see sticker_panel_set_result_cb()
+ * @see sticker_panel_unset_result_cb()
+ * @see sticker_panel_set_view_mode()
+ * @see sticker_panel_show()
+ *
+ * @par Example
+ * @code
+ * #include <sticker_panel.h>
+ *
+ * static struct appdata {
+ * Evas_Object *sticker_panel;
+ * Evas_Object *conformant;
+ * };
+ *
+ * static int app_terminate(void *data)
+ * {
+ * struct appdata *ad = data;
+ * int ret = 0;
+ *
+ * if (!ad) {
+ * // Error handling
+ * }
+ *
+ * if (!ad->sticker_panel) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_hide(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_unset_result_cb(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ *
+ * ret = sticker_panel_destroy(ad->sticker_panel);
+ * if (STICKER_PANEL_ERROR_NONE != ret) {
+ * // Error handling
+ * }
+ * ad->sticker_panel = NULL;
+ *
+ * return 0;
+ * }
+ *
+ * @endcode
+ */
+int sticker_panel_hide(sticker_panel_h sticker_panel);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif // __TIZEN_STICKER_PANEL_H__
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_INTERNAL_H__
+#define __TIZEN_STICKER_PANEL_INTERNAL_H__
+
+#include <app_control.h>
+#include <Elementary.h>
+#include <sqlite3.h>
+#include "sticker_panel.h"
+#include "conf.h"
+
+#define DATA_KEY_STICKER_PANEL "__dkap__"
+#define DATA_KEY_STICKER_PANEL_INFO "__dkapi__"
+#define DATA_KEY_PAGE "__dkpg__"
+#define DATA_KEY_UG "__dkug__"
+#define DEFAULT_ICON "/usr/share/sticker-panel/images/sticker_tab_latest.png"
+#define RECENT_ID "__sticker_panel_recent_tabbar__"
+#define TAB_THUMBNAIL_DIR_PATH "@Tab_Thumbnail"
+#define FILE_LEN 1024
+
+
+
+typedef enum {
+ STICKER_PANEL_STATE_HIDE,
+ STICKER_PANEL_STATE_HALF,
+ STICKER_PANEL_STATE_FULL,
+} sticker_panel_state_e;
+
+
+
+struct _sticker_panel {
+ /* Innate features */
+ Evas_Object *win;
+ Evas_Object *conformant;
+
+ /* Acquired features */
+ sqlite3 *db;
+ Evas_Object *sticker_panel_rect;
+ Evas_Object *ui_manager;
+ Evas_Object *current_tab;
+ Evas_Object *recent_grid;
+ Evas_Object *toolbar[CATEGORY_COUNT];
+ Evas_Object *scroller[CATEGORY_COUNT];
+ int cur_page_no;
+
+ Eina_List *group_icon_info_list;
+ Ecore_Animator *animator;
+ Ecore_Animator *toolbar_animator;
+
+ sticker_panel_state_e sticker_panel_port_state;
+ sticker_panel_state_e sticker_panel_land_state;
+ sticker_panel_state_e sticker_panel_state;
+ sticker_panel_result_cb result_cb;
+ void *result_data;
+
+ Evas_Coord transit_width;
+ Evas_Coord transit_height;
+
+ Eina_Bool is_delete;
+ Eina_Bool rotate;
+ Eina_Bool flick;
+ int view_mode;
+ int current_category;
+};
+typedef struct _sticker_panel sticker_panel_s;
+
+
+
+extern void _sticker_panel_del(sticker_panel_h sticker_panel);
+
+
+
+#endif // __TIZEN_STICKER_PANEL_INTERNAL_H__
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_TOOLBAR_H__
+#define __TIZEN_STICKER_PANEL_TOOLBAR_H__
+
+#include <Elementary.h>
+
+typedef enum {
+ TOOLBAR_EVENT_TYPE_INVALID = 0,
+ TOOLBAR_EVENT_TYPE_CHANGE_TAB,
+ TOOLBAR_EVENT_TYPE_MAX,
+} toolbar_event_type_e;
+
+extern Evas_Object *_toolbar_create(Evas_Object *ui_manager, sticker_panel_h sticker_panel);
+extern void _toolbar_destroy(Evas_Object *toolbar);
+
+extern Elm_Object_Item *_toolbar_append_item(Evas_Object *toolbar, const char *icon_path, Evas_Object *item_view);
+extern Elm_Object_Item *_toolbar_append_setting_item(Evas_Object *toolbar, void (*cb_func)(void *user_data, Evas_Object *obj, void *event_info), sticker_panel_h sticker_panel);
+extern void _toolbar_remove_setting_item(Evas_Object *toolbar);
+extern void _toolbar_remove_item_by_item_view(Evas_Object *toolbar, Evas_Object *item_view);
+extern void _toolbar_remove_item(Elm_Object_Item *item);
+extern void _toolbar_remove_all_item(Evas_Object *toolbar);
+
+extern Elm_Object_Item *_toolbar_get_item(Evas_Object *toolbar, Evas_Object *item_view);
+extern Elm_Object_Item *_toolbar_insert_item_before(Evas_Object *toolbar, const char *icon_path, Evas_Object *item_view, Elm_Object_Item *before);
+extern void _toolbar_reorder_item(Evas_Object *toolbar, Eina_List *group_icon_info_list);
+
+extern void _toolbar_bring_in(Evas_Object *toolbar, Elm_Object_Item *tabbar_item);
+extern unsigned int _toolbar_count_item(Evas_Object *toolbar);
+
+
+extern int _toolbar_register_event_cb(Evas_Object *toolbar, int event_type, void (*event_cb)(Evas_Object *toolbar, int event_type, void *event_info, void *data), void *data);
+extern int _toolbar_unregister_event_cb(Evas_Object *toolbar, int event_type, void (*event_cb)(Evas_Object *toolbar, int event_type, void *event_info, void *data));
+
+#endif /* __TIZEN_STICKER_PANEL_TOOLBAR_H__ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef __TIZEN_STICKER_PANEL_UI_MANAGER_H__
+#define __TIZEN_STICKER_PANEL_UI_MANAGER_H__
+
+#include <Elementary.h>
+
+extern Evas_Object *_ui_manager_create(sticker_panel_h sticker_panel);
+extern void _ui_manager_destroy(Evas_Object *ui_manager);
+
+extern void _ui_manager_show_category(Evas_Object *ui_manager, sticker_panel_h sticker_panel, int category);
+
+#endif /* __TIZEN_STICKER_PANEL_UI_MANAGER_H__ */
--- /dev/null
+Name: sticker-panel
+Summary: Sticker Panel
+Version: 0.1.0
+Release: 0
+Group: Application
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+
+%if "%{?tizen_profile_name}" == "wearable"
+ExcludeArch: %{arm} %ix86 x86_64
+%endif
+
+%if "%{?tizen_profile_name}" == "tv"
+ExcludeArch: %{arm} %ix86 x86_64
+%endif
+
+BuildRequires: cmake
+BuildRequires: edje-tools
+BuildRequires: gettext-tools
+
+BuildRequires: pkgconfig(appcore-efl)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(feedback)
+BuildRequires: pkgconfig(isf)
+BuildRequires: pkgconfig(efl-extension)
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(bundle)
+
+%description
+Description: Sticker Panel
+
+%prep
+%setup -q
+
+%package devel
+Summary: Sticker panel library (devel)
+Group: Application
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Development files needed to build software that needs Sticker panel.
+
+%build
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
+
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DSHAREDIR=%{_datadir}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post
+sqlite3 /opt/dbspace/.sticker_panel.db "CREATE TABLE IF NOT EXISTS db_checksum (version INT);"
+sqlite3 /opt/dbspace/.sticker_panel.db "CREATE TABLE IF NOT EXISTS recent_icon (
+ id TEXT
+ , type INTEGER
+ , time INTEGER
+ , PRIMARY KEY(id, type)
+ );"
+sqlite3 /opt/dbspace/.sticker_panel.db "CREATE TABLE IF NOT EXISTS group_icon (
+ id TEXT PRIMARY KEY
+ , name TEXT
+ , repository TEXT
+ , ordering INTEGER
+ , category INTEGER
+ );"
+chsmack -a "sticker-panel::db" /opt/dbspace/.sticker_panel.db*
+chmod 666 /opt/dbspace/.sticker_panel.db*
+
+%files
+%manifest %{name}.manifest
+%{_prefix}/lib/*.so*
+%{_datadir}/sticker-panel/edje/*.edj
+%{_datadir}/sticker-panel/images/*
+%{_datadir}/sticker-panel/sample/*
+%{_datadir}/icons/*.png
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/sticker-panel/sticker_panel.h
+%{_libdir}/pkgconfig/%{name}.pc
--- /dev/null
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/images/ DESTINATION ${IMAGEDIR})
+ADD_SUBDIRECTORY(edje)
--- /dev/null
+FILE(GLOB edc_files ${CMAKE_CURRENT_SOURCE_DIR}/*.edc)
+FOREACH(edc_file ${edc_files})
+ GET_FILENAME_COMPONENT( FName ${edc_file} NAME_WE )
+ MESSAGE("${FName}")
+ ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${FName}.edj
+ COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/../images
+ ${CMAKE_CURRENT_SOURCE_DIR}/${FName}.edc ${FName}.edj ${EDJE_CFLAGS}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FName}.edc
+ )
+ ADD_CUSTOM_TARGET(${FName}.edj DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FName}.edj)
+ ADD_DEPENDENCIES(${PROJECT_NAME} ${FName}.edj)
+ENDFOREACH(edc_file)
+
+# install edc files
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${EDJEDIR} FILES_MATCHING PATTERN "*.edj")
--- /dev/null
+../../include/conf.h
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+collections {
+ base_scale: 2.6;
+ group {
+ name: "item";
+ parts {
+ part {
+ name: "bg";
+ type: SWALLOW;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 1.0; }
+ visible: 1;
+ }
+ }
+ part {
+ name: "icon";
+ type: SWALLOW;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.5 0.5; to, "bg"; }
+ rel2 { relative: 0.5 0.5; to, "bg"; }
+ fixed: 1 1;
+ visible: 1;
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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 "conf.h"
+
+collections {
+ base_scale: 2.6;
+ group {
+ name: "layout";
+ parts {
+ part {
+ name: "bg";
+ type: RECT;
+ scale: 1;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 1.0; }
+ color: 255 255 255 255;
+ visible: 1;
+ }
+ }
+ part {
+ name: "scroller";
+ type: SWALLOW;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; to: "bg"; }
+ rel2 { relative: 1.0 0.0; to: "bg"; }
+ fixed: 0 1;
+ align: 0.5 0.0;
+ visible: 1;
+ }
+ }
+ part {
+ name: "toolbar";
+ type: SWALLOW;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 1.0; to: "bg"; }
+ rel2 { relative: 1.0 1.0; to: "bg"; }
+ min: 0 TOOLBAR_HEIGHT;
+ fixed: 0 1;
+ align: 0.5 1.0;
+ visible: 1;
+ }
+ }
+ }
+ } // group
+} // collections
+
+
+
+// End of file
--- /dev/null
+/*
+ * 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.
+ */
+
+collections {
+ base_scale: 2.6;
+ group {
+ name: "page";
+ parts {
+ part {
+ name: "bg";
+ type: SWALLOW;
+ scale: 1;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 1.0; }
+ visible: 1;
+ }
+ }
+ 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"; }
+ fixed: 1 1;
+ visible: 1;
+ }
+ }
+ }
+ } // group
+} // collections
+
+
+
+// End of file
--- /dev/null
+/*
+ * 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 "conf.h"
+
+collections {
+ base_scale: 2.6;
+ group {
+ name: "layout";
+ parts {
+ part {
+ name: "naviframe";
+ type: SWALLOW;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 1.0; }
+ }
+ }
+ }
+ }
+}
--- /dev/null
+SET(SAMPLE "sample")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(sample_pkgs REQUIRED
+ dlog
+ elementary
+ appcore-efl
+)
+
+FOREACH(sample_flag ${sample_pkgs_CFLAGS})
+ SET(SAMPLE_EXTRA_CFLAGS "${SAMPLE_EXTRA_CFLAGS} ${sample_flag}")
+ENDFOREACH(sample_flag)
+
+SET(SAMPLE_EXTRA_CFLAGS, "${SAMPLE_EXTRA_CFALGS} -DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+ADD_EXECUTABLE(${SAMPLE}
+ sample.c
+ sticker_icon.c
+)
+
+TARGET_LINK_LIBRARIES(${SAMPLE} ${PROJECT_NAME} ${sample_pkgs_LDFLAGS} ${SAMPLE_EXTRA_LDFLAGS})
+
+# install edj
+ADD_CUSTOM_TARGET(sample.edj
+ COMMAND edje_cc ${CMAKE_CURRENT_SOURCE_DIR}/sample.edc sample.edj
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sample.edc
+)
+ADD_DEPENDENCIES(${SAMPLE} sample.edj)
+
+INSTALL(TARGETS ${SAMPLE} DESTINATION ${SAMPLEDIR})
+INSTALL(FILES sample.edj DESTINATION ${SAMPLEDIR})
+
--- /dev/null
+/*
+ * Samsung API
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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/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 <app.h>
+#include <app_control.h>
+#include <Elementary.h>
+#include <efl_extension.h>
+#include <bundle.h>
+
+#include <dirent.h>
+#include <sys/stat.h>
+#include <string.h>
+
+#include "sticker_panel.h"
+#include "sticker_icon.h"
+#include "sample.h"
+#include "log.h"
+
+const char *const KEY_BACK = "XF86Back";
+const char *const LAYOUT = "/usr/share/sticker-panel/sample/sample.edj";
+
+
+static struct {
+ Evas_Object *win;
+ Evas_Object *layout;
+ Evas_Object *bg;
+ Evas_Object *conformant;
+ Evas_Object *icon;
+ sticker_panel_h sticker_panel;
+
+ int root_w;
+ int root_h;
+} sample_info = {
+ .win = NULL,
+ .layout = NULL,
+ .bg = NULL,
+ .conformant = NULL,
+ .icon = NULL,
+ .sticker_panel = NULL,
+
+ .root_w = 0,
+ .root_h = 0,
+};
+
+
+
+static void _rotate_cb(void *data, Evas_Object *obj, void *event)
+{
+ ret_if(!obj);
+
+ int angle = 0;
+
+ angle = elm_win_rotation_get(obj);
+ _D("Angle is %d degree", angle);
+
+ switch (angle) {
+ case 0:
+ case 180:
+ evas_object_size_hint_min_set(obj, sample_info.root_w, sample_info.root_h);
+ evas_object_resize(obj, sample_info.root_w, sample_info.root_h);
+ evas_object_move(obj, 0, 0);
+ break;
+ case 90:
+ case 270:
+ evas_object_size_hint_min_set(obj, sample_info.root_h, sample_info.root_w);
+ evas_object_resize(obj, sample_info.root_h, sample_info.root_w);
+ evas_object_move(obj, 0, 0);
+ break;
+ default:
+ _E("cannot reach here");
+ }
+}
+
+
+
+static void _win_back_key_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (sample_info.sticker_panel) {
+ sticker_panel_hide(sample_info.sticker_panel);
+ sticker_panel_destroy(sample_info.sticker_panel);
+ sample_info.sticker_panel = NULL;
+ } else {
+ ui_app_exit();
+ }
+}
+
+
+
+static void _bg_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ if (sample_info.sticker_panel) {
+ sticker_panel_hide(sample_info.sticker_panel);
+ sticker_panel_destroy(sample_info.sticker_panel);
+ sample_info.sticker_panel = NULL;
+ }
+}
+
+
+static int _get_result_type(const char *result_type)
+{
+ int type = 0;
+
+ retv_if(!result_type, -1);
+
+ if (!strcmp(result_type, STICKER_PANEL_RESULT_TYPE_DIRECTORY)) {
+ type = ICON_INFO_TYPE_DIRECTORY;
+ } else if (!strcmp(result_type, STICKER_PANEL_RESULT_TYPE_FILE)) {
+ type = ICON_INFO_TYPE_FILE;
+ } else {
+ _E("Failed to get result type(%s)", result_type);
+ return -1;
+ }
+
+ _D("result type(%s) : %d", result_type, type);
+
+ return type;
+}
+
+
+
+static void _result_cb(sticker_panel_h sticker_panel, bundle *b, void *user_data)
+{
+ Evas_Object *new_icon = NULL;
+ Evas_Object *old_icon = NULL;
+ char *result_type = NULL;
+ char *result_path = NULL;
+ int type = 0;
+ int ret = BUNDLE_ERROR_NONE;
+
+ ret_if(!b);
+
+ ret = bundle_get_str(b, STICKER_PANEL_RESULT_TYPE, &result_type);
+ if (ret != BUNDLE_ERROR_NONE) {
+ _E("Failed to get bundle(type) : %d", ret);
+ return;
+ } else if (!result_type) {
+ _E("result_type is NULL");
+ return;
+ }
+
+ type = _get_result_type(result_type);
+ if (type == -1) {
+ _E("Failed to get result type");
+ return;
+ }
+
+ ret = bundle_get_str(b, STICKER_PANEL_RESULT_VALUE, &result_path);
+ if (ret != BUNDLE_ERROR_NONE) {
+ _E("Failed to get bundle(path) : %d", ret);
+ } else if (!result_path) {
+ _E("result_path is NULL");
+ return;
+ }
+
+ _D("bundle type(%s), path(%s)", result_type, result_path);
+
+ old_icon = elm_object_part_content_unset(sample_info.layout, "sw.icon");
+ if (old_icon) {
+ sticker_icon_destroy(old_icon);
+ }
+
+ new_icon = sticker_icon_create(sample_info.layout, type, result_path);
+ ret_if(!new_icon);
+ elm_object_part_content_set(sample_info.layout, "sw.icon", new_icon);
+}
+
+
+
+static void _click_sticker_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ sticker_panel_h sticker_panel = NULL;
+ int ret = STICKER_PANEL_ERROR_NONE;
+
+ if (sample_info.sticker_panel) {
+ _D("sticker panel already existed");
+ sticker_panel_show(sample_info.sticker_panel);
+ return;
+ }
+
+ ret = sticker_panel_create(sample_info.conformant, &sticker_panel);
+ ret_if(STICKER_PANEL_ERROR_NONE != ret);
+
+ sticker_panel_set_result_cb(sticker_panel, _result_cb, NULL);
+ sticker_panel_show(sticker_panel);
+
+ sample_info.sticker_panel = sticker_panel;
+}
+
+
+
+static Evas_Object *_create_button(Evas_Object *layout)
+{
+ Evas_Object *button = NULL;
+
+ retv_if(!layout, NULL);
+
+ button = elm_button_add(layout);
+ retv_if(!button, NULL);
+
+ elm_object_text_set(button, "sticker");
+ elm_object_part_content_set(layout, "button", button);
+ evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(button);
+
+ evas_object_smart_callback_add(button, "clicked", _click_sticker_button_cb, NULL);
+
+ return button;
+}
+
+
+
+static void _destroy_button(Evas_Object *layout)
+{
+ Evas_Object *button = NULL;
+
+ button = elm_object_part_content_unset(layout, "button");
+ if (!button) {
+ return;
+ }
+
+ evas_object_smart_callback_del(button, "clicked", _click_sticker_button_cb);
+ evas_object_del(button);
+}
+
+
+
+static void _destroy_layout(void)
+{
+ ret_if(!sample_info.layout);
+
+ _destroy_button(sample_info.layout);
+
+ elm_object_signal_callback_del(sample_info.layout, "bg,up", "bg", _bg_up_cb);
+
+ if (sample_info.conformant) {
+ elm_object_content_unset(sample_info.conformant);
+ }
+ evas_object_del(sample_info.layout);
+ sample_info.layout = NULL;
+}
+
+
+
+static Evas_Object *_create_layout(Evas_Object *parent)
+{
+ Evas_Object *layout = NULL;
+ Eina_Bool ret = EINA_FALSE;
+
+ retv_if(!parent, NULL);
+
+ layout = elm_layout_add(parent);
+ goto_if(!layout, ERROR);
+
+ ret = elm_layout_file_set(layout, LAYOUT, "layout");
+ goto_if(EINA_FALSE == ret, ERROR);
+
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(layout);
+ elm_object_signal_callback_add(layout, "bg,up", "bg", _bg_up_cb, NULL);
+
+ goto_if(!_create_button(layout), ERROR);
+
+ elm_object_content_set(parent, layout);
+
+ return layout;
+
+
+ERROR:
+ _destroy_layout();
+ return NULL;
+}
+
+
+
+static Evas_Object *_create_bg(Evas_Object *parent)
+{
+ Evas_Object *bg = NULL;
+ retv_if(!parent, NULL);
+
+ bg = elm_bg_add(parent);
+ retv_if(!bg, NULL);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(parent, bg);
+
+ evas_object_show(bg);
+
+ return bg;
+}
+
+
+
+static void _destroy_bg(void)
+{
+ ret_if(!sample_info.bg);
+ evas_object_del(sample_info.bg);
+ sample_info.bg = NULL;
+}
+
+
+
+static void _destroy_conformant(void)
+{
+ ret_if(!sample_info.conformant);
+ evas_object_del(sample_info.conformant);
+ sample_info.conformant = NULL;
+}
+
+
+
+static Evas_Object *_create_conformant(Evas_Object *parent)
+{
+ Evas_Object *conformant = NULL;
+ retv_if(!parent, NULL);
+
+ conformant = elm_conformant_add(parent);
+ retv_if(!conformant, NULL);
+
+ elm_win_indicator_mode_set(parent, ELM_WIN_INDICATOR_HIDE);
+ evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(parent, conformant);
+ elm_win_conformant_set(parent, EINA_TRUE);
+
+ evas_object_show(conformant);
+
+ return conformant;
+}
+
+
+
+static void __win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *win = obj;
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Evas_Coord w = 0;
+ Evas_Coord h = 0;
+
+ ret_if(!win);
+
+ evas_object_geometry_get(win, &x, &y, &w, &h);
+ _D("win resize(%d, %d, %d, %d)", x, y, w, h);
+}
+
+
+
+static void __conformant_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *conformant = obj;
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Evas_Coord w = 0;
+ Evas_Coord h = 0;
+
+ ret_if(!conformant);
+
+ evas_object_geometry_get(conformant, &x, &y, &w, &h);
+ _D("conformant resize(%d, %d, %d, %d)", x, y, w, h);
+}
+
+
+
+static void __layout_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *layout = obj;
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Evas_Coord w = 0;
+ Evas_Coord h = 0;
+
+ ret_if(!layout);
+
+ evas_object_geometry_get(layout, &x, &y, &w, &h);
+ _D("layout resize(%d, %d, %d, %d)", x, y, w, h);
+}
+
+
+static void _create_cb(void)
+{
+ Evas_Object *layout = NULL;
+ Evas_Object *conformant = NULL;
+ Evas_Object *bg = NULL;
+
+ sample_info.win = elm_win_add(NULL, "Sticker Panel Sample", ELM_WIN_BASIC);
+ ret_if(!sample_info.win);
+ evas_object_event_callback_add(sample_info.win, EVAS_CALLBACK_RESIZE, __win_resize_cb, NULL);
+
+ elm_app_base_scale_set(2.6);
+
+ elm_win_alpha_set(sample_info.win, EINA_FALSE);
+ elm_win_title_set(sample_info.win, "Sticker Panel");
+ elm_win_borderless_set(sample_info.win, EINA_TRUE);
+ elm_win_autodel_set(sample_info.win, EINA_TRUE);
+ elm_win_raise(sample_info.win);
+
+ evas_object_show(sample_info.win);
+
+ elm_win_screen_size_get(sample_info.win, NULL, NULL, &sample_info.root_w, &sample_info.root_h);
+ _D("screen size is (%d, %d)", sample_info.root_w, sample_info.root_h);
+
+
+ if (elm_win_wm_rotation_supported_get(sample_info.win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(sample_info.win, rots, 4);
+ }
+
+ eext_object_event_callback_add(sample_info.win, EEXT_CALLBACK_BACK, _win_back_key_cb, NULL);
+ evas_object_smart_callback_add(sample_info.win, "wm,rotation,changed", _rotate_cb, NULL);
+
+ bg = _create_bg(sample_info.win);
+ goto_if(!bg, ERROR);
+
+ conformant = _create_conformant(sample_info.win);
+ goto_if(!conformant, ERROR);
+ evas_object_event_callback_add(conformant, EVAS_CALLBACK_RESIZE, __conformant_resize_cb, NULL);
+
+ layout = _create_layout(conformant);
+ goto_if(!layout, ERROR);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_RESIZE, __layout_resize_cb, NULL);
+
+ sample_info.layout = layout;
+ sample_info.conformant = conformant;
+ sample_info.bg = bg;
+
+ return;
+
+ERROR:
+ _D("there is some error");
+ if (conformant) {
+ _destroy_conformant();
+ }
+
+ if (bg) {
+ _destroy_bg();
+ }
+
+ if (sample_info.win) {
+ evas_object_del(sample_info.win);
+ eext_object_event_callback_del(sample_info.win, EEXT_CALLBACK_BACK, _win_back_key_cb);
+ sample_info.win = NULL;
+ }
+}
+
+
+
+static void _terminate_cb(void)
+{
+ _destroy_layout();
+ _destroy_conformant();
+ _destroy_bg();
+
+ if (sample_info.win) {
+ eext_object_event_callback_del(sample_info.win, EEXT_CALLBACK_BACK, _win_back_key_cb);
+ evas_object_del(sample_info.win);
+ sample_info.win = NULL;
+ }
+}
+
+
+
+int main(int argc, char **argv)
+{
+ elm_init(argc, argv);
+ _create_cb();
+ elm_run();
+ _terminate_cb();
+ elm_shutdown();
+
+ return 0;
+}
--- /dev/null
+/*
+ * Samsung API
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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/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.
+ */
+
+
+
+styles {
+ style {
+ name: "text_style";
+ base: "font=Tizen:style=Bold font_size=24 color=#ffffff align=center style=shadow shadow_color=#000000bf wrap=mixed";
+ tag: "br" "\n";
+ tag: "hilight" "+ font_weight=Bold";
+ tag: "b" "+ font_weight=Bold";
+ tag: "tab" "\t";
+ }
+}
+
+collections {
+ base_scale: 2.6;
+ group {
+ name: "layout";
+ parts {
+ part {
+ name: "bg";
+ type: RECT;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 1.0; }
+ color: 255 255 255 255;
+ visible: 1;
+ }
+ }
+ part {
+ name: "button";
+ type: SWALLOW;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.1 0.1; to: "bg"; }
+ rel2 { relative: 0.9 0.2; to: "bg"; }
+ visible: 1;
+ }
+ }
+ part {
+ name: "sw.icon";
+ type: SWALLOW;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.05 0.25; to: "bg"; }
+ rel2 { relative: 0.95 1.0; to: "bg"; }
+ fixed: 0 1;
+ visible: 1;
+ }
+ }
+ }
+ programs {
+ program {
+ name: "bg,up";
+ signal: "mouse,up,1";
+ source: "bg";
+ action: SIGNAL_EMIT "bg,up" "bg";
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Samsung API
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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/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 __ATTACK_PANEL_SAMPLE_H__
+#define __ATTACK_PANEL_SAMPLE_H__
+
+#include <dlog.h>
+
+#define PATH_LEN 1024
+
+#define BASE_WIDTH 1280
+#define BASE_HEIGHT 720
+
+#define RESULT_TYPE_DIRECTORY "__STICKER_PANEL_RESULT_TYPE_DIRECTORY__"
+#define RESULT_TYPE_FILE "__STICKER_PANEL_RESULT_TYPE_FILE__"
+
+typedef enum {
+ ICON_INFO_TYPE_NONE = 0,
+ ICON_INFO_TYPE_DIRECTORY = 1,
+ ICON_INFO_TYPE_FILE = 2,
+ ICON_INFO_TYPE_MAX,
+} icon_info_type_e;
+
+
+//log
+#if !defined(_D)
+#define _D(fmt, arg...) LOGD(fmt"\n", ##arg)
+#endif
+
+#if !defined(_W)
+#define _W(fmt, arg...) LOGW(fmt"\n", ##arg)
+#endif
+
+#if !defined(_E)
+#define _E(fmt, arg...) LOGE(fmt"\n", ##arg)
+#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)
+
+
+#endif
--- /dev/null
+/*
+ * Samsung API
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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/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 <Elementary.h>
+#include <efl_extension.h>
+
+#include <dirent.h>
+#include <sys/stat.h>
+#include <string.h>
+
+#include "sticker_panel.h"
+#include "sample.h"
+#include "log.h"
+
+#define STICKER_ICON_INFO_KEY "__STICKER_icon_info_KEY__"
+
+#define STICKER_IMG_NAME_TOKEN_SUB "sub"
+#define STICKER_IMG_NAME_TOKEN_TH "th"
+#define STICKER_IMG_NAME_TOKEN_GIF ".gif"
+
+#define DEFAULT_INTERVAL 1000
+
+typedef struct _icon_info_s {
+ /* Innate features */
+ char *value;
+ char *dir_path;
+ char *keyword;
+ char *thumbnail_file;
+
+ int type;
+ int repeat;
+ int interval;
+ int play_type;
+ int th_frame;
+ int width;
+ int height;
+
+ Eina_List *icon_image_list;
+ Eina_Bool animation;
+
+ /* Acquired features */
+ Elm_Object_Item *item;
+ Evas_Object *icon;
+ Ecore_Animator *animator;
+
+ int current_repeat;
+ int current_frame;
+} icon_info_s;
+
+typedef struct _icon_image_s {
+ char *file;
+ int frame_order;
+ int diff_time;
+} icon_image_s;
+
+
+
+static int __icon_image_list_sort_cb(const void *d1, const void *d2)
+{
+ icon_image_s *tmp1 = (icon_image_s *) d1;
+ icon_image_s *tmp2 = (icon_image_s *) d2;
+
+ if (tmp1 == NULL || tmp1->file == NULL) {
+ return 1;
+ } else if (tmp2 == NULL || tmp2->file == NULL) {
+ return -1;
+ }
+
+ return strcmp(tmp1->file, tmp2->file);
+}
+
+
+
+static icon_info_s *_icon_info_create_directory(const char *dir_path)
+{
+ icon_info_s *icon_info = NULL;
+ DIR *dir_info = NULL;
+ struct dirent *dir_entry = NULL;
+ int ret = 0;
+
+ retv_if(!dir_path, NULL);
+
+ icon_info = calloc(1, sizeof(icon_info_s));
+ retv_if(!icon_info, NULL);
+
+ icon_info->type = ICON_INFO_TYPE_DIRECTORY;
+ icon_info->dir_path = strdup(dir_path);
+ goto_if(!icon_info->dir_path, error);
+
+ dir_info = opendir(dir_path);
+ goto_if(!dir_info, error);
+
+ while ((dir_entry = readdir(dir_info))) {
+ icon_image_s *icon_image = NULL;
+ char *d_name = NULL;
+ char *filename = NULL;
+ char *ext = NULL;
+ char *tmp = NULL;
+ char full_path[PATH_LEN] = {0, };
+ char thumbnail_file[PATH_LEN] = {0, };
+ struct stat stat_buf = {0, };
+
+ snprintf(full_path, sizeof(full_path), "%s/%s", dir_path, dir_entry->d_name);
+ lstat(full_path, &stat_buf);
+ if (S_ISDIR(stat_buf.st_mode))
+ continue;
+
+ if (strstr(dir_entry->d_name, ".gif")
+ || strstr(dir_entry->d_name, "_th.")) {
+ continue;
+ }
+
+ d_name = strdup(dir_entry->d_name);
+ continue_if(!d_name);
+
+ icon_image = calloc(1, sizeof(icon_image_s));
+ goto_if(!icon_image, not_sticker);
+
+ icon_image->file = strdup(full_path);
+ goto_if(!icon_image->file, not_sticker);
+
+ filename = strtok(d_name, ".");
+ goto_if(!filename, not_sticker);
+
+ ext = strtok(NULL, ".");
+ goto_if(!ext, not_sticker);
+
+ tmp = strtok(filename, "_");
+ goto_if(!tmp, not_sticker);
+
+ if (!icon_info->keyword) {
+ icon_info->keyword = strdup(tmp);
+ goto_if(!icon_info->keyword, not_sticker);
+ }
+
+ if ((tmp = strtok(NULL, "_"))) {
+ if (!strcmp(tmp, STICKER_IMG_NAME_TOKEN_SUB)) {
+ goto not_sticker;
+ } else if (!strcmp(tmp, STICKER_IMG_NAME_TOKEN_TH)) {
+ if (icon_info->thumbnail_file)
+ goto not_sticker;
+
+ snprintf(thumbnail_file
+ , sizeof(thumbnail_file)
+ , "%s/%s_%s.%s"
+ , icon_info->dir_path
+ , icon_info->keyword
+ , STICKER_IMG_NAME_TOKEN_TH
+ , ext);
+ icon_info->thumbnail_file = strdup(thumbnail_file);
+ goto_if(!icon_info->thumbnail_file, not_sticker);
+ } else {
+ icon_image->frame_order = atoi(tmp);
+ }
+ } else goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_image->diff_time = atoi(tmp);
+ else
+ goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info->repeat = atoi(tmp);
+ else
+ goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info->interval = atoi(tmp);
+ else
+ goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info->play_type = atoi(tmp);
+ else
+ goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info->th_frame = atoi(tmp);
+
+next:
+ icon_info->icon_image_list = eina_list_append(icon_info->icon_image_list, icon_image);
+ goto_if(!icon_info->icon_image_list, not_sticker);
+ free(d_name);
+ continue;
+
+not_sticker:
+ if (icon_image) {
+ free(icon_image->file);
+ free(icon_image);
+ }
+ free(d_name);
+ }
+
+ icon_info->icon_image_list = eina_list_sort(
+ icon_info->icon_image_list
+ , eina_list_count(icon_info->icon_image_list)
+ , __icon_image_list_sort_cb);
+
+ ret = closedir(dir_info);
+ if (ret != 0) {
+ _E("Failed to close directory(%s)", dir_path);
+ }
+ return icon_info;
+
+error:
+ if (icon_info) {
+ free(icon_info->dir_path);
+ free(icon_info);
+ }
+ return NULL;
+}
+
+
+
+static icon_info_s *_icon_info_create_file(const char *file_path)
+{
+ icon_info_s *icon_info = NULL;
+
+ retv_if(!file_path, NULL);
+
+ icon_info = calloc(1, sizeof(icon_info_s));
+ retv_if(!icon_info, NULL);
+
+ icon_info->thumbnail_file = strdup(file_path);
+ goto_if(!icon_info->thumbnail_file, error);
+
+ icon_info->type = ICON_INFO_TYPE_FILE;
+
+ return icon_info;
+
+error:
+ if (icon_info) {
+ free(icon_info->thumbnail_file);
+ free(icon_info);
+ }
+ return NULL;
+}
+
+
+
+static void _icon_info_destroy(icon_info_s *icon_info)
+{
+ icon_image_s *icon_image = NULL;
+
+ ret_if(!icon_info);
+
+ free(icon_info->dir_path);
+ free(icon_info->keyword);
+ free(icon_info->thumbnail_file);
+
+ EINA_LIST_FREE(icon_info->icon_image_list, icon_image) {
+ if (!icon_image) {
+ continue;
+ }
+
+ free(icon_image->file);
+ free(icon_image);
+ }
+
+ free(icon_info);
+}
+
+
+
+static Eina_Bool _animator_cb(void *data)
+{
+ icon_info_s *icon_info = data;
+ icon_image_s *icon_image = NULL;
+
+ goto_if(!icon_info, error);
+ goto_if(!icon_info->icon, error);
+ goto_if(!icon_info->icon_image_list, error);
+
+ icon_image = eina_list_nth(icon_info->icon_image_list, icon_info->current_frame);
+ if (!icon_image) {
+ if (icon_info->current_repeat < icon_info->repeat) {
+ /* restart animation */
+ icon_info->current_repeat++;
+ icon_info->current_frame = 0;
+ return ECORE_CALLBACK_RENEW;
+ }
+ icon_info->current_repeat = 0;
+ icon_info->current_frame = 0;
+ goto error;
+ }
+
+ ecore_animator_frametime_set((double) icon_image->diff_time / 1000);
+
+ if (!elm_image_file_set(icon_info->icon, icon_image->file, NULL)) {
+ _E("Failed to set icon");
+ }
+
+ icon_info->current_frame++;
+
+ return ECORE_CALLBACK_RENEW;
+
+error:
+ icon_info->animator = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+static void _del_animated_icon_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ icon_info_s *icon_info = data;
+
+ ret_if(!icon_info);
+
+ if (!icon_info->animator)
+ return;
+
+ ecore_animator_del(icon_info->animator);
+ icon_info->animator= NULL;
+}
+
+
+
+static Evas_Object *_create_animated_icon(Evas_Object *parent, icon_info_s *icon_info)
+{
+ icon_image_s *icon_image = NULL;
+ Evas_Object *icon = NULL;
+ int list_count = 0;
+
+ retv_if(!parent, NULL);
+ retv_if(!icon_info, NULL);
+
+ icon = elm_image_add(parent);
+ retv_if(!icon, NULL);
+
+ icon_image = eina_list_nth(icon_info->icon_image_list, 0);
+ retv_if(!icon_image, NULL);
+
+ if (!elm_image_file_set(icon, icon_image->file, NULL)) {
+ _E("Failed to set icon");
+ evas_object_del(icon);
+ return NULL;
+ }
+ evas_object_event_callback_add(icon, EVAS_CALLBACK_DEL, _del_animated_icon_cb, icon_info);
+
+ list_count = eina_list_count(icon_info->icon_image_list);
+ if (list_count > 1) {
+ icon_info->animator = ecore_animator_add(_animator_cb, icon_info);
+ if (!icon_info->animator) {
+ _E("Failed to add animator");
+ return NULL;
+ }
+ }
+
+ return icon;
+}
+
+
+
+static Evas_Object *_create_static_icon(Evas_Object *parent, const char *icon_path)
+{
+ Evas_Object *icon = NULL;
+
+ retv_if(!parent, NULL);
+ retv_if(!icon_path, NULL);
+
+ icon = elm_image_add(parent);
+ retv_if(!icon, NULL);
+
+ if (!elm_image_file_set(icon, icon_path, NULL)) {
+ _E("Failed to set icon");
+ evas_object_del(icon);
+ return NULL;
+ }
+
+ return icon;
+}
+
+
+
+void _destroy_icon(Evas_Object *icon)
+{
+ ret_if(!icon);
+ evas_object_del(icon);
+}
+
+
+
+static void _icon_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ icon_info_s *icon_info = (icon_info_s *) data;
+ int count = 0;
+
+ ret_if(!icon_info);
+
+ if (icon_info->animator) {
+ ecore_animator_del(icon_info->animator);
+ icon_info->animator = NULL;
+ }
+
+ count = eina_list_count(icon_info->icon_image_list);
+ if (count == 0)
+ return;
+
+ icon_info->animator = ecore_animator_add(_animator_cb, icon_info);
+ if (!icon_info->animator)
+ _E("Failed to add animator");
+}
+
+
+
+Evas_Object *sticker_icon_create(Evas_Object *parent, int type, const char *value)
+{
+ icon_info_s *icon_info = NULL;
+
+ retv_if(!parent, NULL);
+ retv_if(!type, NULL);
+ retv_if(!value, NULL);
+
+ _D("type : %d, value : %s", type, value);
+
+ if (type == ICON_INFO_TYPE_DIRECTORY) {
+ icon_info = _icon_info_create_directory(value);
+ retv_if(!icon_info, NULL);
+
+ icon_info->icon = _create_animated_icon(parent, icon_info);
+ goto_if(!icon_info->icon, error);
+ } else if (type == ICON_INFO_TYPE_FILE) {
+ icon_info = _icon_info_create_file(value);
+ retv_if(!icon_info, NULL);
+
+ icon_info->icon = _create_static_icon(parent, value);
+ goto_if(!icon_info->icon, error);
+ } else {
+ _E("type error(%d)", type);
+ goto error;
+ }
+
+ evas_object_data_set(icon_info->icon, STICKER_ICON_INFO_KEY, icon_info);
+ evas_object_smart_callback_add(icon_info->icon, "clicked", _icon_clicked_cb, icon_info);
+
+ return icon_info->icon;
+
+error:
+ if (icon_info) {
+ if (icon_info->icon) {
+ evas_object_data_del(icon_info->icon, STICKER_ICON_INFO_KEY);
+ evas_object_del(icon_info->icon);
+ }
+
+ _icon_info_destroy(icon_info);
+ }
+
+ return NULL;
+}
+
+
+
+void sticker_icon_destroy(Evas_Object *icon)
+{
+ icon_info_s *icon_info = NULL;
+
+ ret_if(!icon);
+
+ icon_info = evas_object_data_del(icon, STICKER_ICON_INFO_KEY);
+ ret_if(!icon_info);
+
+ _destroy_icon(icon_info->icon);
+ _icon_info_destroy(icon_info);
+}
--- /dev/null
+/*
+ * Samsung API
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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/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 __STICKER_ICON_SAMPLE_H__
+#define __STICKER_ICON_SAMPLE_H__
+
+Evas_Object *sticker_icon_create(Evas_Object *parent, int type, const char *value);
+void sticker_icon_destroy(Evas_Object *icon);
+
+#endif
--- /dev/null
+/*
+ * 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 <Elementary.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "conf.h"
+#include "ui_manager.h"
+#include "log.h"
+#include "conformant.h"
+
+Evas_Object *_conformant_create(Evas_Object *caller_conformant, Eina_Bool show_indicator)
+{
+ Evas_Object *conformant = NULL;
+
+ retv_if(!caller_conformant, NULL);
+
+ conformant = elm_conformant_add(caller_conformant);
+ retv_if(!conformant, NULL);
+
+ evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(caller_conformant, conformant);
+
+ if (show_indicator) {
+ _D("Show indicator");
+ elm_object_signal_emit(conformant, "elm,state,indicator,overlap", "elm");
+ } else {
+ _D("Hide indicator");
+ }
+
+ return conformant;
+}
+
+void _conformant_destroy(Evas_Object *conformant)
+{
+ ret_if(!conformant);
+
+ evas_object_del(conformant);
+}
--- /dev/null
+/*
+ * Samsung API
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
+ *
+ * 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/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 <Evas.h>
+#include <sqlite3.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "db.h"
+#include "log.h"
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "icon_info.h"
+#include "group_icon_info.h"
+#include "conf.h"
+
+#define STICKER_PANEL_DB_FILE "/opt/dbspace/.sticker_panel.db"
+
+
+
+
+sqlite3 *_db_open(void)
+{
+ sqlite3 *db = NULL;
+ int ret = SQLITE_OK;
+
+ ret = sqlite3_open(STICKER_PANEL_DB_FILE, &db);
+ if (SQLITE_OK != ret) {
+ _E("%s", sqlite3_errmsg(db));
+ return NULL;
+ }
+
+ return db;
+}
+
+
+
+void _db_close(sqlite3 *db)
+{
+ ret_if(!db);
+ sqlite3_close(db);
+}
+
+
+
+sqlite3_stmt *_db_prepare(sqlite3 *db, const char *query)
+{
+ sqlite3_stmt *stmt = NULL;
+ int ret = SQLITE_OK;
+
+ retv_if(!query, NULL);
+
+ ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+ if (SQLITE_OK != ret) {
+ _E("%s, %s", query, sqlite3_errmsg(db));
+ return NULL;
+ }
+
+ return stmt;
+}
+
+
+
+int _db_next(sqlite3 *db, sqlite3_stmt *stmt)
+{
+ int ret = SQLITE_OK;
+
+ retv_if(!stmt, -1);
+
+ ret = sqlite3_step(stmt);
+ switch (ret) {
+ case SQLITE_ROW: /* SQLITE_ROW : 100 */
+ return ret;
+ case SQLITE_DONE: /* SQLITE_ROW : 101 */
+ return ret;
+ default:
+ _E("%s", sqlite3_errmsg(db));
+ }
+
+ return -1;
+}
+
+
+
+sticker_panel_error_e _db_reset(sqlite3 *db, sqlite3_stmt *stmt)
+{
+ int ret = SQLITE_OK;
+
+ retv_if(!stmt, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_reset(stmt);
+ if (SQLITE_OK != ret) {
+ _E("%s", sqlite3_errmsg(db));
+ return STICKER_PANEL_ERROR_DB_FAILED;
+ }
+
+ sqlite3_clear_bindings(stmt);
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+sticker_panel_error_e _db_bind_bool(sqlite3 *db, sqlite3_stmt *stmt, int idx, bool value)
+{
+ int ret = SQLITE_OK;
+
+ retv_if(!stmt, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_bind_int(stmt, idx, (int) value);
+ if (SQLITE_OK != ret) {
+ _E("%s", sqlite3_errmsg(db));
+ return STICKER_PANEL_ERROR_DB_FAILED;
+ }
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+sticker_panel_error_e _db_bind_int(sqlite3 *db, sqlite3_stmt *stmt, int idx, int value)
+{
+ int ret = SQLITE_OK;
+
+ retv_if(!stmt, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_bind_int(stmt, idx, value);
+ if (SQLITE_OK != ret) {
+ _E("%s", sqlite3_errmsg(db));
+ return STICKER_PANEL_ERROR_DB_FAILED;
+ }
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+sticker_panel_error_e _db_bind_double(sqlite3 *db, sqlite3_stmt *stmt, int idx, double value)
+{
+ int ret = SQLITE_OK;
+
+ retv_if(!stmt, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_bind_double(stmt, idx, value);
+ if (SQLITE_OK != ret) {
+ _E("%s", sqlite3_errmsg(db));
+ return STICKER_PANEL_ERROR_DB_FAILED;
+ }
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+sticker_panel_error_e _db_bind_str(sqlite3 *db, sqlite3_stmt *stmt, int idx, const char *str)
+{
+ int ret = SQLITE_OK;
+
+ retv_if(!stmt, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (str) {
+ ret = sqlite3_bind_text(stmt, idx, str, -1, SQLITE_TRANSIENT);
+ } else {
+ ret = sqlite3_bind_null(stmt, idx);
+ }
+
+ if (SQLITE_OK != ret) {
+ _E("%s", sqlite3_errmsg(db));
+ return STICKER_PANEL_ERROR_DB_FAILED;
+ }
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+bool _db_get_bool(sqlite3_stmt *stmt, int index)
+{
+ retv_if(!stmt, false);
+ return (bool) (!!sqlite3_column_int(stmt, index));
+}
+
+
+
+int _db_get_int(sqlite3_stmt *stmt, int index)
+{
+ retv_if(!stmt, 0);
+ return sqlite3_column_int(stmt, index);
+}
+
+
+
+int _db_get_double(sqlite3_stmt *stmt, int index)
+{
+ retv_if(!stmt, 0);
+ return sqlite3_column_double(stmt, index);
+}
+
+
+
+const char *_db_get_str(sqlite3_stmt *stmt, int index)
+{
+ retv_if(!stmt, NULL);
+ return (const char *) sqlite3_column_text(stmt, index);
+}
+
+
+
+sticker_panel_error_e _db_finalize(sqlite3 *db, sqlite3_stmt *stmt)
+{
+ int ret = SQLITE_OK;
+
+ retv_if(!stmt, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_finalize(stmt);
+ if (SQLITE_OK != ret) {
+ _E("%s", sqlite3_errmsg(db));
+ return STICKER_PANEL_ERROR_DB_FAILED;
+ }
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+sticker_panel_error_e _db_exec(sqlite3 *db, const char *query)
+{
+ sqlite3_stmt *stmt = NULL;
+
+ retv_if(!query, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ stmt = _db_prepare(db, query);
+ retv_if(!stmt, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_next(db, stmt) == -1, ERROR);
+ goto_if(STICKER_PANEL_ERROR_NONE != _db_finalize(db, stmt), ERROR);
+
+ return STICKER_PANEL_ERROR_NONE;
+
+ERROR:
+ if (stmt) _db_finalize(db, stmt);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_create_table(sqlite3 *db)
+{
+ int count = 0;
+ int i = 0;
+ const char *const TABLES[] = {
+ "CREATE TABLE IF NOT EXISTS db_checksum (version INT);",
+ "CREATE TABLE IF NOT EXISTS recent_icon ("
+ "id TEXT"
+ ", type INTEGER"
+ ", time INTEGER"
+ ", PRIMARY KEY(id, type)"
+ ");",
+ "CREATE TABLE IF NOT EXISTS group_icon ("
+ "id TEXT PRIMARY KEY"
+ ", name TEXT"
+ ", repository TEXT"
+ ", ordering INTEGER"
+ ", category INTEGER"
+ ");",
+ };
+
+ count = sizeof(TABLES) / sizeof(char *);
+ for (; i < count; i++) {
+ break_if(_db_exec(db, TABLES[i]) != STICKER_PANEL_ERROR_NONE);
+ }
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+sticker_panel_error_e _db_drop_table(sqlite3 *db)
+{
+ int count = 0;
+ int i = 0;
+ const char *const TABLES[] = {
+ "DROP TABLE IF EXISTS db_checksum;",
+ "DROP TABLE IF EXISTS recent_icon;",
+ "DROP TABLE IF EXISTS group_icon;",
+ };
+
+ count = sizeof(TABLES) / sizeof(char *);
+ for (; i < count; i++) {
+ _D("Drop a table[%s]", TABLES[i]);
+ break_if(_db_exec(db, TABLES[i]) != STICKER_PANEL_ERROR_NONE);
+ }
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+sticker_panel_error_e _db_insert_version(sqlite3 *db, int version)
+{
+ const char *const QUERY_SYNTAX = "INSERT INTO db_checksum (version) VALUES (?);";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_int(db, st, 1, version) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_delete_version(sqlite3 *db, int version)
+{
+ const char *const QUERY_SYNTAX = "DELETE FROM db_checksum WHERE version = ?;";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_int(db, st, 1, version) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_update_version(sqlite3 *db, int version)
+{
+ const char *const QUERY_SYNTAX = "UPDATE db_checksum SET version = ?;";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_int(db, st, 1, version) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_count_version(sqlite3 *db)
+{
+ const char *const QUERY_SYNTAX = "SELECT COUNT(*) FROM db_checksum;";
+ sqlite3_stmt *st = NULL;
+ int count = 0;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ if (_db_next(db, st) == -1) {
+ _E("_db_next error");
+ _db_finalize(db, st);
+ return -1;
+ }
+
+ count = _db_get_int(st, 0);
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return count;
+}
+
+
+
+sticker_panel_error_e _db_count_recent_icon(sqlite3 *db, const char *id, int type, int *count)
+{
+ const char *const QUERY_SYNTAX = "SELECT COUNT(*) FROM recent_icon WHERE id = ? and type = ?;";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_str(db, st, 1, id) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 2, type) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ *count = _db_get_int(st, 0);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_touch_recent_icon(sqlite3 *db, const char *id, int type)
+{
+ const char *const QUERY_INSERT = "INSERT INTO recent_icon (id, type, time) VALUES (?, ?, DATETIME('now'));";
+ const char *const QUERY_UPDATE = "UPDATE recent_icon SET time = DATETIME('now') WHERE id = ? and type = ?;";
+ sqlite3_stmt *st = NULL;
+ int count = 0;
+ int ret = STICKER_PANEL_ERROR_NONE;
+
+ ret = _db_count_recent_icon(db, id, type, &count);
+ retv_if(ret != STICKER_PANEL_ERROR_NONE, STICKER_PANEL_ERROR_DB_FAILED);
+
+ if (count) {
+ st = _db_prepare(db, QUERY_UPDATE);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+ } else {
+ st = _db_prepare(db, QUERY_INSERT);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+ }
+
+ goto_if(_db_bind_str(db, st, 1, id) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 2, type) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_delete_recent_icon(sqlite3 *db, const char *id, int type)
+{
+ const char *const QUERY_SYNTAX = "DELETE FROM recent_icon WHERE id = ? and type = ?;";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_str(db, st, 1, id) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 2, type) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_list_recent_icon(sqlite3 *db, Eina_List **icon_list, int limit)
+{
+ const char *const QUERY_LIST = "SELECT id, type FROM recent_icon ORDER BY time DESC LIMIT ?";
+ const char *id = NULL;
+ icon_info_s *icon_info = NULL;
+ sqlite3_stmt *st = NULL;
+ int type = 0;
+ int ret = -1;
+
+ st = _db_prepare(db, QUERY_LIST);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_int(db, st, 1, limit) != STICKER_PANEL_ERROR_NONE, error);
+
+ do {
+ ret = _db_next(db, st);
+ if (SQLITE_DONE == ret) {
+ break;
+ } else if (-1 == ret) {
+ _E("_db_next() error");
+ goto error;
+ }
+
+ id = _db_get_str(st, 0);
+ goto_if(!id, error);
+
+ type = _db_get_int(st, 1);
+
+ icon_info = _icon_info_create(id, type);
+ continue_if(!icon_info);
+
+ *icon_list = eina_list_append(*icon_list, icon_info);
+ } while (SQLITE_ROW == ret);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ EINA_LIST_FREE(*icon_list, icon_info) {
+ _icon_info_destroy(icon_info);
+ }
+
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_initialize_group_icon(sqlite3 *db)
+{
+ const char *const QUERY_SYNTAX = "INSERT INTO group_icon (id, name, repository, ordering, category) VALUES (?, ?, ?, ?, ?);";
+ sqlite3_stmt *st = NULL;
+ /* FIXME : This part can be moved out to the text file */
+ /* ordering is from '1'. '0' is reserved for the recent tabbar. */
+ struct group_icon_info_s {
+ char *id;
+ char *name;
+ char *repository;
+ int ordering;
+ int category;
+ } group_icons[] = {
+ {
+ .id = PRELOADED_PRESET_DIR_PATH"/Animal_Body",
+ .name = "Animal body",
+ .repository = "",
+ .ordering = 1,
+ .category = 0,
+ },
+ {
+ .id = PRELOADED_PRESET_DIR_PATH"/Animal_Face",
+ .name = "Animal face",
+ .repository = "",
+ .ordering = 2,
+ .category = 0,
+ },
+ {
+ .id = PRELOADED_PRESET_DIR_PATH"/Couple",
+ .name = "Couple",
+ .repository = "",
+ .ordering = 3,
+ .category = 0,
+ },
+ {
+ .id = PRELOADED_PRESET_DIR_PATH"/Kids",
+ .name = "Kids",
+ .repository = "",
+ .ordering = 4,
+ .category = 0,
+ },
+ {
+ .id = PRELOADED_PRESET_DIR_PATH"/Office",
+ .name = "Office",
+ .repository = "",
+ .ordering = 5,
+ .category = 0,
+ },
+ {
+ .id = PRELOADED_PRESET_DIR_PATH"/Woman",
+ .name = "Woman",
+ .repository = "",
+ .ordering = 6,
+ .category = 0,
+ },
+ };
+ register int i = 0;
+ int count = 0;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ count = sizeof(group_icons) / sizeof(struct group_icon_info_s);
+ for (; i < count; i++) {
+ goto_if(_db_bind_str(db, st, 1, group_icons[i].id) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_str(db, st, 2, group_icons[i].name) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_str(db, st, 3, group_icons[i].repository) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 4, group_icons[i].ordering) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 5, group_icons[i].category) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+ _db_reset(db, st);
+ }
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_count_group_icon(sqlite3 *db, const char *id, int *count)
+{
+ const char *const QUERY_COUNT_ID = "SELECT COUNT(*) FROM group_icon WHERE id = ?;";
+ const char *const QUERY_COUNT_ALL = "SELECT COUNT(*) FROM group_icon;";
+ const char *query = NULL;
+ sqlite3_stmt *st = NULL;
+
+ retv_if(!db, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!count, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (id)
+ query = QUERY_COUNT_ID;
+ else
+ query = QUERY_COUNT_ALL;
+
+ st = _db_prepare(db, query);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ if (id)
+ goto_if(_db_bind_str(db, st, 1, id) != STICKER_PANEL_ERROR_NONE, error);
+
+ goto_if(_db_next(db, st) == -1, error);
+
+ *count = _db_get_int(st, 0);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_insert_group_icon(sqlite3 *db, const char *id, const char *name, const char *repository, int ordering, int category)
+{
+ const char *const QUERY_SYNTAX = "INSERT INTO group_icon (id, name, repository, ordering, category) VALUES (?, ?, ?, ?, ?);";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_str(db, st, 1, id) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_str(db, st, 2, name) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_str(db, st, 3, repository) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 4, ordering) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 5, category) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_delete_group_icon(sqlite3 *db, const char *id)
+{
+ const char *const QUERY_SYNTAX = "DELETE FROM group_icon WHERE id = ?;";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_str(db, st, 1, id) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_update_group_icon(sqlite3 *db, const char *id, int ordering)
+{
+ const char *const QUERY_SYNTAX = "UPDATE group_icon SET ordering = ? WHERE id = ?;";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_int(db, st, 1, ordering) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_str(db, st, 2, id) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_list_group_icon(sqlite3 *db, Eina_List **group_icon_info_list)
+{
+ const char *const QUERY_LIST = "SELECT id, name, repository, ordering, category FROM group_icon ORDER BY category, ordering";
+ group_icon_info_s *group_icon_info = NULL;
+ sqlite3_stmt *st = NULL;
+ int ret = -1;
+
+ st = _db_prepare(db, QUERY_LIST);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ do {
+ const char *id = NULL;
+ const char *name = NULL;
+ const char *repository = NULL;
+ int ordering = 0;
+ int category = 0;
+
+ ret = _db_next(db, st);
+ if (SQLITE_DONE == ret) {
+ break;
+ } else if (-1 == ret) {
+ _E("_db_next() error");
+ goto error;
+ }
+
+ id = _db_get_str(st, 0);
+ goto_if(!id, error);
+
+ name = _db_get_str(st, 1);
+ goto_if(!name, error);
+
+ /* repository can be NULL */
+ repository = _db_get_str(st, 2);
+ ordering = _db_get_int(st, 3);
+ category = _db_get_int(st, 4);
+
+ group_icon_info = _group_icon_info_create(id, name, repository, ordering, category);
+ continue_if(!group_icon_info);
+
+ *group_icon_info_list = eina_list_append(*group_icon_info_list, group_icon_info);
+ } while (SQLITE_ROW == ret);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ EINA_LIST_FREE(*group_icon_info_list, group_icon_info) {
+ _group_icon_info_destroy(group_icon_info);
+ }
+
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_increment_group_icon(sqlite3 *db, int from, int to, int category)
+{
+ const char *const QUERY_SYNTAX = "UPDATE group_icon SET ordering = ordering + 1 "
+ "WHERE ordering >= ? AND ordering <= ? AND category = ?;";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_int(db, st, 1, from) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 2, to) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 3, category) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
+
+
+
+sticker_panel_error_e _db_decrement_group_icon(sqlite3 *db, int from, int to, int category)
+{
+ const char *const QUERY_SYNTAX = "UPDATE group_icon SET ordering = ordering - 1 "
+ "WHERE ordering >= ? AND ordering <= ? AND category = ?;";
+ sqlite3_stmt *st = NULL;
+
+ st = _db_prepare(db, QUERY_SYNTAX);
+ retv_if(!st, STICKER_PANEL_ERROR_DB_FAILED);
+
+ goto_if(_db_bind_int(db, st, 1, from) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 2, to) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_bind_int(db, st, 3, category) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_next(db, st) == -1, error);
+
+ _db_reset(db, st);
+ _db_finalize(db, st);
+
+ /* keep the sticker panel DB opened */
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ _db_finalize(db, st);
+ return STICKER_PANEL_ERROR_DB_FAILED;
+}
--- /dev/null
+/*
+ * 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 <app_control.h>
+#include <Elementary.h>
+#include <tizen.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "conf.h"
+#include "grid.h"
+#include "group_icon_info.h"
+#include "icon_info.h"
+#include "log.h"
+#include "page.h"
+#include "scroller.h"
+#include "setting.h"
+#include "toolbar.h"
+
+#define TRANSIT_DURATION 0.5f
+
+
+
+static struct {
+ Elm_Transit *transit;
+ sticker_panel_state_e sticker_panel_state;
+} gesture_info_s = {
+ .transit = NULL,
+ .sticker_panel_state = STICKER_PANEL_STATE_HIDE,
+};
+
+struct _effect_factor {
+ Evas_Coord from_h;
+ Evas_Coord to_h;
+};
+typedef struct _effect_factor effect_factor_s;
+
+
+
+static Elm_Transit_Effect *__create_effect_factor(Evas_Coord from_h, Evas_Coord to_h)
+{
+ effect_factor_s *effect_factor = calloc(1, sizeof(effect_factor_s));
+
+ retv_if(!effect_factor, NULL);
+
+ effect_factor->from_h = from_h;
+ effect_factor->to_h = to_h;
+
+ return effect_factor;
+}
+
+
+
+static void __between_effect_factor(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
+{
+ effect_factor_s *effect_factor = effect;
+ const Eina_List *objs = NULL;
+ const Eina_List *l = NULL;
+ Evas_Object *obj = NULL;
+ Evas_Coord h = 0;
+
+ ret_if(!effect);
+
+ objs = elm_transit_objects_get(transit);
+ ret_if(!objs);
+
+ h = (Evas_Coord) ((effect_factor->from_h * (1.0 - progress)) + (effect_factor->to_h * progress));
+
+ EINA_LIST_FOREACH(objs, l, obj) {
+ evas_object_size_hint_min_set(obj, -1, h);
+ evas_object_size_hint_max_set(obj, -1, h);
+ }
+}
+
+
+
+static void __destroy_effect_factor(Elm_Transit_Effect *effect, Elm_Transit *transit)
+{
+ free(effect);
+}
+
+
+
+static void __click_setting_icon_cb(void *user_data, Evas_Object *obj, void *event_info)
+{
+ sticker_panel_h sticker_panel = NULL;
+ Elm_Object_Item *item = NULL;
+
+ sticker_panel = user_data;
+ ret_if(!sticker_panel);
+
+ ret_if(!obj);
+
+ if (!_setting_create(sticker_panel->conformant, sticker_panel)) {
+ _E("Failed to create setting layout");
+ return;
+ }
+
+ item = elm_toolbar_selected_item_get(obj);
+ goto_if(!item, out);
+
+ elm_toolbar_item_selected_set(item, EINA_FALSE);
+
+out:
+ elm_toolbar_item_selected_set(sticker_panel->current_tab, EINA_TRUE);
+}
+
+
+
+static Eina_Bool __animator_cb(void *data)
+{
+ group_icon_info_s *group_icon_info = NULL;
+ sticker_panel_h sticker_panel = data;
+ Elm_Object_Item *setting_item = NULL;
+ Evas_Object *grid = NULL;
+
+ const Eina_List *lm = NULL;
+ icon_info_s *icon_info = NULL;
+ static int i = 1;
+
+ goto_if(!sticker_panel, out);
+ goto_if(!sticker_panel->group_icon_info_list, out);
+
+ if (i >= eina_list_count(sticker_panel->group_icon_info_list)) {
+ /* UI Feature : Setting is only on the first category */
+ setting_item = _toolbar_append_setting_item(sticker_panel->toolbar[0], __click_setting_icon_cb, sticker_panel);
+ if (!setting_item) {
+ _E("cannot append a tabbar setting item");
+ }
+
+ _D("List is done to reload");
+ goto out;
+ }
+
+ group_icon_info = eina_list_nth(sticker_panel->group_icon_info_list, i);
+ if (!group_icon_info->list) {
+ group_icon_info->list = _icon_info_list_create_preset_package(group_icon_info->id);
+ if (!group_icon_info->list)
+ goto renew;
+ }
+
+ grid = elm_object_part_content_get(group_icon_info->item_view, "content");
+ goto_if(!grid, renew);
+
+ /* FIXME : We have an empty page for downloading stickers */
+ EINA_LIST_FOREACH(group_icon_info->list, lm, icon_info) {
+ if (icon_info->keyword && icon_info->thumbnail_file) {
+ Elm_Object_Item *item = NULL;
+ item = _grid_append_item(grid, sticker_panel, icon_info);
+ goto_if(!item, renew);
+ }
+ }
+
+renew:
+ i++;
+ return ECORE_CALLBACK_RENEW;
+
+out:
+ sticker_panel->toolbar_animator = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+static void __del_transit_cb(void *data, Elm_Transit *transit)
+{
+ sticker_panel_h sticker_panel = data;
+
+ gesture_info_s.transit = NULL;
+
+ if (gesture_info_s.sticker_panel_state == STICKER_PANEL_STATE_HIDE) {
+ elm_object_signal_emit(sticker_panel->conformant, "elm,state,attach_panel,hide,finished", "");
+
+ if (sticker_panel->is_delete)
+ _sticker_panel_del(sticker_panel);
+ } else {
+ elm_object_signal_emit(sticker_panel->conformant, "elm,state,attach_panel,show,finished", "");
+ sticker_panel->toolbar_animator = ecore_animator_add(__animator_cb, sticker_panel);
+ ret_if(!sticker_panel->toolbar_animator);
+ }
+}
+
+
+
+static void __set_transit(sticker_panel_h sticker_panel, Evas_Coord from_h, Evas_Coord to_h, double duration)
+{
+ Elm_Transit_Effect *effect_factor = NULL;
+
+ if (gesture_info_s.transit) {
+ _E("Transit is already activating");
+ return;
+ }
+
+ if (gesture_info_s.sticker_panel_state == STICKER_PANEL_STATE_HIDE) {
+ elm_object_signal_emit(sticker_panel->conformant, "elm,state,attach_panel,hide,started", "");
+ } else {
+ elm_object_signal_emit(sticker_panel->conformant, "elm,state,attach_panel,show,started", "");
+ }
+
+ gesture_info_s.transit = elm_transit_add();
+ ret_if(!gesture_info_s.transit);
+
+ elm_transit_object_add(gesture_info_s.transit, sticker_panel->sticker_panel_rect);
+ elm_transit_tween_mode_set(gesture_info_s.transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
+ elm_transit_smooth_set(gesture_info_s.transit, EINA_FALSE);
+ elm_transit_duration_set(gesture_info_s.transit, duration);
+
+ effect_factor = __create_effect_factor(from_h, to_h);
+ if (!effect_factor) {
+ _E("cannot create an effect factor");
+ elm_transit_del(gesture_info_s.transit);
+ gesture_info_s.transit = NULL;
+ return;
+ }
+ elm_transit_effect_add(gesture_info_s.transit, __between_effect_factor, effect_factor, __destroy_effect_factor);
+ elm_transit_del_cb_set(gesture_info_s.transit, __del_transit_cb, sticker_panel);
+ elm_transit_go(gesture_info_s.transit);
+}
+
+
+
+void _gesture_show(sticker_panel_h sticker_panel)
+{
+ gesture_info_s.sticker_panel_state = STICKER_PANEL_STATE_HALF;
+
+ if (sticker_panel->rotate) {
+ sticker_panel->sticker_panel_land_state = STICKER_PANEL_STATE_FULL;
+ __set_transit(sticker_panel, 0, sticker_panel->transit_height, TRANSIT_DURATION);
+ elm_object_signal_emit(sticker_panel->conformant, "elm,state,attach_panel,show,full", "");
+ } else {
+ sticker_panel->sticker_panel_port_state = STICKER_PANEL_STATE_HALF;
+ __set_transit(sticker_panel, 0, sticker_panel->transit_height, TRANSIT_DURATION);
+ }
+}
+
+
+
+void _gesture_hide(sticker_panel_h sticker_panel)
+{
+ if (sticker_panel->rotate) {
+ sticker_panel->sticker_panel_land_state = STICKER_PANEL_STATE_HIDE;
+ elm_object_signal_emit(sticker_panel->conformant, "elm,state,attach_panel,show,half", "");
+ } else {
+ if (STICKER_PANEL_STATE_FULL == sticker_panel->sticker_panel_port_state) {
+ elm_object_signal_emit(sticker_panel->conformant, "elm,state,attach_panel,show,half", "");
+ }
+ sticker_panel->sticker_panel_port_state = STICKER_PANEL_STATE_HIDE;
+ }
+ gesture_info_s.sticker_panel_state = STICKER_PANEL_STATE_HIDE;
+ __set_transit(sticker_panel, sticker_panel->transit_height, 0, TRANSIT_DURATION);
+}
--- /dev/null
+/*
+ * 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 <app_control.h>
+#include <Elementary.h>
+#include <bundle.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "group_icon_info.h"
+#include "icon_info.h"
+#include "grid.h"
+#include "log.h"
+#include "db.h"
+#include "conf.h"
+
+
+
+const char *const PRIVATE_DATA_KEY_GRID_INFO = "pdk_gi";
+const char *const PRIVATE_DATA_KEY_ICON_INFO = "pdk_ii";
+const char *const ITEM_EDJE_FILE = EDJEDIR"/item.edj";
+
+
+
+struct _grid_info_s {
+ Elm_Gengrid_Item_Class *gic;
+ int item_width;
+ int item_height;
+ int icon_width;
+ int icon_height;
+};
+typedef struct _grid_info_s grid_info_s;
+
+
+
+static Evas_Object *__add_icon(Evas_Object *parent, const char *file, int item_width, int item_height, int icon_width, int icon_height)
+{
+ Evas *e = NULL;
+ Evas_Object *item = NULL;
+ Evas_Object *bg = NULL;
+ Evas_Object *icon = NULL;
+
+ e = evas_object_evas_get(parent);
+ retv_if(!e, NULL);
+
+ item = elm_layout_add(parent);
+ retv_if(!item, NULL);
+ elm_layout_file_set(item, ITEM_EDJE_FILE, "item");
+ evas_object_size_hint_weight_set(item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(item, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(item);
+
+ bg = evas_object_rectangle_add(e);
+ goto_if(!bg, error);
+ evas_object_size_hint_min_set(bg, item_width, item_height);
+ evas_object_color_set(bg, 0, 0, 0, 0);
+ evas_object_show(bg);
+ elm_object_part_content_set(item, "bg", bg);
+
+ if (access(file, R_OK) != 0) {
+ _E("Failed to access an icon(%s)", file);
+ file = DEFAULT_ICON;
+ }
+
+ icon = elm_icon_add(parent);
+ goto_if(!icon, error);
+ goto_if(elm_image_file_set(icon, file, NULL) == EINA_FALSE, error);
+ elm_image_preload_disabled_set(icon, EINA_TRUE);
+ elm_image_smooth_set(icon, EINA_TRUE);
+ elm_image_no_scale_set(icon, EINA_FALSE);
+ evas_object_size_hint_min_set(icon, icon_width, icon_height);
+ evas_object_show(icon);
+ elm_object_part_content_set(item, "icon", icon);
+
+ return item;
+
+error:
+ if (icon)
+ evas_object_del(icon);
+
+ if (bg)
+ evas_object_del(bg);
+
+ if (item)
+ evas_object_del(item);
+
+ return NULL;
+}
+
+
+
+static Evas_Object *__content_get(void *data, Evas_Object *obj, const char *part)
+{
+ Evas_Object *grid = obj;
+ grid_info_s *grid_info = NULL;
+
+ retv_if(!data, NULL);
+
+ grid_info = evas_object_data_get(grid, PRIVATE_DATA_KEY_GRID_INFO);
+ retv_if(!grid_info, NULL);
+
+ if (!strcmp(part, "elm.swallow.icon")) {
+ return __add_icon(obj
+ , data
+ , grid_info->item_width
+ , grid_info->item_height
+ , grid_info->icon_width
+ , grid_info->icon_height);
+ } else if (!strcmp(part, "selected")) {
+ }
+
+ return NULL;
+}
+
+
+
+static void __del(void *data, Evas_Object *obj)
+{
+ ret_if(NULL == data);
+}
+
+
+
+static void __refresh_recent_grid(Evas_Object *grid, const char *id, int type, sticker_panel_h sticker_panel)
+{
+ Elm_Object_Item *recent_item = NULL;
+ icon_info_s *icon_info = NULL;
+ int ret = STICKER_PANEL_ERROR_NONE;
+
+ ret_if(!grid);
+ ret_if(!id);
+ ret_if(!sticker_panel);
+
+ ret = _db_touch_recent_icon(sticker_panel->db, id, type);
+ ret_if(ret != STICKER_PANEL_ERROR_NONE);
+
+ recent_item = _grid_get_item(grid, id, type);
+ if (recent_item) {
+ icon_info = evas_object_data_get(recent_item, PRIVATE_DATA_KEY_ICON_INFO);
+ _grid_remove_item(grid, recent_item);
+ } else {
+ group_icon_info_s *group_icon_info = _group_icon_info_list_get(sticker_panel->group_icon_info_list, RECENT_ID);
+ ret_if(!group_icon_info);
+
+ icon_info = _icon_info_create(id, type);
+ ret_if(!icon_info);
+ group_icon_info->list = eina_list_prepend(group_icon_info->list, icon_info);
+ }
+
+ recent_item = _grid_prepend_item(grid, sticker_panel, icon_info);
+ if (!recent_item)
+ _E("cannot prepend an item into the recent tab");
+}
+
+
+
+static void __select_item_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *selected_item = NULL;
+ bundle *b = NULL;
+ sticker_panel_h sticker_panel = data;
+ icon_info_s *icon_info = NULL;
+ char *result_type = NULL;
+
+ ret_if(!obj);
+ ret_if(!sticker_panel);
+ ret_if(!sticker_panel->result_cb);
+
+ selected_item = elm_gengrid_selected_item_get(obj);
+ ret_if(!selected_item);
+ elm_gengrid_item_selected_set(selected_item, EINA_FALSE);
+
+ icon_info = evas_object_data_get(selected_item, PRIVATE_DATA_KEY_ICON_INFO);
+ ret_if(!icon_info);
+
+ _D("Selected an item : %s", icon_info->thumbnail_file);
+
+ switch (icon_info->type) {
+ case ICON_INFO_TYPE_DIRECTORY:
+ result_type = STICKER_PANEL_RESULT_TYPE_DIRECTORY;
+ break;
+ case ICON_INFO_TYPE_FILE:
+ result_type = STICKER_PANEL_RESULT_TYPE_FILE;
+ break;
+ default:
+ _E("Failed to set result type");
+ return;
+ }
+
+ b = bundle_create();
+ ret_if(!b);
+
+ if (BUNDLE_ERROR_NONE != bundle_add_str(b, STICKER_PANEL_RESULT_TYPE, result_type))
+ _E("Failed to add bundle(type)");
+ if (BUNDLE_ERROR_NONE != bundle_add_str(b, STICKER_PANEL_RESULT_VALUE, icon_info->dir_path))
+ _E("Failed to add bundle(path)");
+
+ sticker_panel->result_cb(sticker_panel, b, sticker_panel->result_data);
+ bundle_free(b);
+
+ __refresh_recent_grid(sticker_panel->recent_grid
+ , icon_info->dir_path
+ , icon_info->type
+ , sticker_panel);
+}
+
+
+
+Evas_Object *_grid_create(Evas_Object *page, sticker_panel_h sticker_panel)
+{
+ Evas_Object *grid = NULL;
+ grid_info_s *grid_info = NULL;
+
+ int w = 0;
+ int icon_width = 0;
+
+ retv_if(!sticker_panel, NULL);
+
+ grid_info = calloc(1, sizeof(grid_info_s));
+ retv_if(!grid_info, NULL);
+
+ grid = elm_gengrid_add(page);
+ goto_if(!grid, ERROR);
+
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ w = sticker_panel->transit_width / GRID_ITEM_PER_ROW;
+ goto_if(!w, ERROR);
+
+ icon_width = (int) w * GRID_ITEM_ICON_RATIO;
+ goto_if(!icon_width, ERROR);
+
+ elm_gengrid_item_size_set(grid, w, w);
+ elm_gengrid_align_set(grid, 0.0, 0.0);
+ elm_gengrid_horizontal_set(grid, EINA_FALSE);
+ elm_gengrid_multi_select_set(grid, EINA_FALSE);
+
+ grid_info->gic = elm_gengrid_item_class_new();
+ goto_if(!grid_info->gic, ERROR);
+ grid_info->gic->func.content_get = __content_get;
+ grid_info->gic->func.del = __del;
+
+ grid_info->item_width = w;
+ grid_info->item_height = w;
+ grid_info->icon_width = icon_width;
+ grid_info->icon_height = icon_width;
+
+ evas_object_data_set(grid, PRIVATE_DATA_KEY_GRID_INFO, grid_info);
+ evas_object_show(grid);
+
+ return grid;
+
+ERROR:
+ _grid_destroy(grid);
+ free(grid_info);
+ return NULL;
+}
+
+
+
+void _grid_destroy(Evas_Object *grid)
+{
+ Eina_List *list = NULL;
+ Elm_Object_Item *item = NULL;
+ grid_info_s *grid_info = NULL;
+
+ ret_if(!grid);
+
+ grid_info = evas_object_data_del(grid, PRIVATE_DATA_KEY_GRID_INFO);
+ ret_if(!grid_info);
+
+ list = elm_grid_children_get(grid);
+ EINA_LIST_FREE(list, item) {
+ evas_object_data_del(item, PRIVATE_DATA_KEY_ICON_INFO);
+ elm_object_item_del(item);
+ }
+
+ evas_object_del(grid);
+}
+
+
+
+Elm_Object_Item *_grid_prepend_item(Evas_Object *grid, sticker_panel_h sticker_panel, icon_info_s *icon_info)
+{
+ grid_info_s *grid_info = NULL;
+ Elm_Object_Item *item = NULL;
+
+ retv_if(!grid, NULL);
+ retv_if(!sticker_panel, NULL);
+ retv_if(!icon_info, NULL);
+
+ grid_info = evas_object_data_get(grid, PRIVATE_DATA_KEY_GRID_INFO);
+ retv_if(!grid_info, NULL);
+ retv_if(!grid_info->gic, NULL);
+
+ item = elm_gengrid_item_prepend(grid, grid_info->gic, icon_info->thumbnail_file, __select_item_cb, sticker_panel);
+ retv_if(!item, NULL);
+
+ evas_object_data_set(item, PRIVATE_DATA_KEY_ICON_INFO, icon_info);
+
+ return item;
+}
+
+
+
+Elm_Object_Item *_grid_append_item(Evas_Object *grid, sticker_panel_h sticker_panel, icon_info_s *icon_info)
+{
+ grid_info_s *grid_info = NULL;
+ Elm_Object_Item *item = NULL;
+
+ retv_if(!grid, NULL);
+ retv_if(!sticker_panel, NULL);
+ retv_if(!icon_info, NULL);
+
+ grid_info = evas_object_data_get(grid, PRIVATE_DATA_KEY_GRID_INFO);
+ retv_if(!grid_info, NULL);
+ retv_if(!grid_info->gic, NULL);
+
+ item = elm_gengrid_item_append(grid, grid_info->gic, icon_info->thumbnail_file, __select_item_cb, sticker_panel);
+ retv_if(!item, NULL);
+
+ evas_object_data_set(item, PRIVATE_DATA_KEY_ICON_INFO, icon_info);
+
+ return item;
+}
+
+
+
+void _grid_remove_item(Evas_Object *grid, Elm_Object_Item *item)
+{
+ ret_if(!grid);
+ ret_if(!item);
+
+ evas_object_data_del(item, PRIVATE_DATA_KEY_ICON_INFO);
+
+ elm_object_item_del(item);
+}
+
+
+
+Elm_Object_Item *_grid_get_item(Evas_Object *grid, const char *id, int type)
+{
+ Elm_Object_Item *item = NULL;
+
+ retv_if(!grid, NULL);
+ retv_if(!id, NULL);
+
+ item = elm_gengrid_first_item_get(grid);
+ retv_if(!item, NULL);
+
+ while (item) {
+ icon_info_s *icon_info = evas_object_data_get(item, PRIVATE_DATA_KEY_ICON_INFO);
+ continue_if(!icon_info);
+ continue_if(!icon_info->dir_path);
+
+ if (!strcmp(icon_info->dir_path, id)
+ && icon_info->type == type) {
+ return item;
+ }
+
+ item = elm_gengrid_item_next_get(item);
+ }
+
+ return NULL;
+}
+
+
+
+int _grid_count_item(Evas_Object *grid)
+{
+ int count = 0;
+
+ retv_if(!grid, 0);
+
+ count = elm_gengrid_items_count(grid);
+
+ return count;
+}
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#include <sqlite3.h>
+
+#include "conf.h"
+#include "log.h"
+#include "sticker_panel_internal.h"
+#include "group_icon_info.h"
+#include "icon_info.h"
+#include "db.h"
+#include "conf.h"
+
+
+
+static const char *const RECENT_NAME = "Recent";
+static const char *const USER_DEFINED_ID = "__sticker_panel_user_defined_tabbar__";
+static const char *const USER_DEFINED_NAME = "User";
+static const char *const USER_DIR = "/usr";
+
+
+
+group_icon_info_s *_group_icon_info_create(const char *id, const char *name, const char *repository, int ordering, int category)
+{
+ group_icon_info_s *group_icon_info = NULL;
+
+ retv_if(!id, NULL);
+ retv_if(!name, NULL);
+
+ group_icon_info = calloc(1, sizeof(group_icon_info_s));
+ retv_if(!group_icon_info, NULL);
+
+ group_icon_info->id = strdup(id);
+ goto_if(!group_icon_info->id, error);
+
+ group_icon_info->name = strdup(name);
+ goto_if(!group_icon_info->name, error);
+
+ if (repository) {
+ group_icon_info->repository = strdup(repository);
+ goto_if(!group_icon_info->repository, error);
+ }
+
+ group_icon_info->ordering = ordering;
+ group_icon_info->category = category;
+ group_icon_info->removable = !!strncmp(USER_DIR, group_icon_info->id, strlen(USER_DIR));
+
+ return group_icon_info;
+
+error:
+ if (group_icon_info) {
+ free(group_icon_info->id);
+ free(group_icon_info->name);
+ free(group_icon_info->repository);
+ free(group_icon_info);
+ }
+
+ return NULL;
+}
+
+
+
+void _group_icon_info_destroy(group_icon_info_s *group_icon_info)
+{
+ ret_if(!group_icon_info);
+
+ free(group_icon_info->id);
+ free(group_icon_info->name);
+ free(group_icon_info->repository);
+ free(group_icon_info->toolbar_icon_path);
+ if (group_icon_info->list) {
+ _icon_info_list_destroy(group_icon_info->list);
+ }
+
+ free(group_icon_info);
+}
+
+
+
+static Eina_List *__create_recent_group_icon_info_list(sqlite3 *db)
+{
+ Eina_List *group_icon_info_list = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+
+ retv_if(!db, NULL);
+
+ group_icon_info = _group_icon_info_create(RECENT_ID, RECENT_NAME, NULL, 0, 0);
+ retv_if(!group_icon_info, NULL);
+
+ group_icon_info->list = _icon_info_list_create_recent_package(db);
+ if (!group_icon_info->list) {
+ _E("cannot create the recent list");
+ }
+ group_icon_info->permutable = 0;
+ group_icon_info->initialized = 1;
+ group_icon_info->recent = 1;
+ group_icon_info->toolbar_icon_path = strdup(DEFAULT_ICON);
+ if (!group_icon_info->toolbar_icon_path)
+ _E("cannot get toolbar's icon path");
+
+ group_icon_info_list = eina_list_append(group_icon_info_list, group_icon_info);
+
+ return group_icon_info_list;
+}
+
+
+
+static char *__strdup_tab_thumbnail_path(const char *dir_path)
+{
+ char file_path[PATH_LEN] = {0, };
+ char *tab_thumbnail = NULL;
+ DIR *dir_info = NULL;
+ struct dirent *dir_entry = NULL;
+ struct stat stat_buf = {0, };
+ int ret = 0;
+
+ retv_if(!dir_path, NULL);
+
+ dir_info = opendir(dir_path);
+ retv_if(!dir_info, NULL);
+
+ while ((dir_entry = readdir(dir_info))) {
+ if (!strcmp(".", dir_entry->d_name) || !strcmp("..", dir_entry->d_name))
+ continue;
+
+ snprintf(file_path, sizeof(file_path), "%s/%s", dir_path, dir_entry->d_name);
+ lstat(file_path, &stat_buf);
+ if (S_ISDIR(stat_buf.st_mode))
+ continue;
+
+ break;
+ }
+
+ ret = closedir(dir_info);
+ if (ret != 0) {
+ _E("Failed to close directory(%s)", dir_path);
+ }
+
+ tab_thumbnail = strdup(file_path);
+ if (!tab_thumbnail) {
+ _E("Failed to duplicate string");
+ return NULL;
+ }
+
+ return tab_thumbnail;
+}
+
+
+
+static Eina_List *__append_preset_group_icon_info_list(Eina_List *group_icon_info_list, const char *preset_dir_path, sqlite3 *db)
+{
+ DIR *dir_info = NULL;
+ struct dirent *dir_entry = NULL;
+ struct stat stat_buf;
+ int max = 0;
+ int ret = 0;
+
+ retv_if(!preset_dir_path, group_icon_info_list);
+
+ _D("preset dir path : %s", preset_dir_path);
+
+ dir_info = opendir(preset_dir_path);
+ retv_if(!dir_info, group_icon_info_list);
+
+ max = eina_list_count(group_icon_info_list);
+ while ((dir_entry = readdir(dir_info))) {
+ group_icon_info_s *group_icon_info = NULL;
+ char dir_path[PATH_LEN] = {0, };
+ char icon_path[PATH_LEN] = {0, };
+
+ snprintf(dir_path, sizeof(dir_path), "%s/%s", preset_dir_path, dir_entry->d_name);
+
+ memset(&stat_buf, 0, sizeof(struct stat));
+ lstat(dir_path, &stat_buf);
+
+ if (!S_ISDIR(stat_buf.st_mode)) {
+ continue;
+ }
+
+ if (!strcmp(".", dir_entry->d_name) || !strcmp("..", dir_entry->d_name)) {
+ continue;
+ }
+
+ group_icon_info = _group_icon_info_list_get(group_icon_info_list, dir_path);
+ if (!group_icon_info) {
+ group_icon_info = _group_icon_info_create(dir_path, dir_entry->d_name, NULL, max, 0);
+ break_if(!group_icon_info);
+ group_icon_info_list = eina_list_append(group_icon_info_list, group_icon_info);
+
+ ret = _db_insert_group_icon(db, dir_path, dir_entry->d_name, NULL, max, 0);
+ if (STICKER_PANEL_ERROR_NONE != ret)
+ _E("cannot insert a group icon");
+
+ max++;
+ }
+
+ /* OPTIMIZATION : We've postponed these routines to the animator */
+ //group_icon_info->list = _icon_info_list_create_preset_package(dir_path);
+
+ snprintf(icon_path, sizeof(icon_path), "%s/%s", dir_path, TAB_THUMBNAIL_DIR_PATH);
+ group_icon_info->toolbar_icon_path = __strdup_tab_thumbnail_path(icon_path);
+ if (!group_icon_info->toolbar_icon_path)
+ _E("cannot get toolbar's icon path");
+
+ group_icon_info->permutable = 1;
+ group_icon_info->initialized = 1;
+ }
+
+ ret = closedir(dir_info);
+ if (ret != 0) {
+ _E("Failed to close directory");
+ }
+
+ return group_icon_info_list;
+}
+
+
+
+static Eina_List *__append_user_group_icon_info_list(Eina_List *group_icon_info_list, sqlite3 *db)
+{
+ group_icon_info_s *group_icon_info = NULL;
+
+ retv_if(!db, group_icon_info_list);
+
+ group_icon_info = _group_icon_info_create(USER_DEFINED_ID, USER_DEFINED_NAME, NULL, 0, 0);
+ retv_if(!group_icon_info, group_icon_info_list);
+
+ group_icon_info->list = _icon_info_list_create_user_defined(USER_DEFINED_DIR_PATH);
+ if (!group_icon_info->list) {
+ _E("No user defined stickers");
+ _group_icon_info_destroy(group_icon_info);
+ return group_icon_info_list;
+ }
+ group_icon_info->permutable = 0;
+ group_icon_info->initialized = 1;
+ group_icon_info->toolbar_icon_path = strdup(DEFAULT_ICON);
+ if (!group_icon_info->toolbar_icon_path)
+ _E("cannot get toolbar's icon path");
+
+ group_icon_info_list = eina_list_append(group_icon_info_list, group_icon_info);
+
+ return group_icon_info_list;
+}
+
+
+
+Eina_List *_group_icon_info_list_create(sqlite3 *db)
+{
+ Eina_List *group_icon_info_list = NULL;
+ Eina_List *list = NULL;
+ int ret = STICKER_PANEL_ERROR_NONE;
+
+ ret = _db_list_group_icon(db, &group_icon_info_list);
+ retv_if(STICKER_PANEL_ERROR_NONE != ret, NULL);
+
+ list = __create_recent_group_icon_info_list(db);
+ goto_if(!list, error);
+ group_icon_info_list = eina_list_merge(list, group_icon_info_list);
+
+ list = __append_preset_group_icon_info_list(group_icon_info_list, PRELOADED_PRESET_DIR_PATH, db);
+ goto_if(!list, error);
+
+ list = __append_preset_group_icon_info_list(group_icon_info_list, DOWNLOADED_PRESET_DIR_PATH, db);
+ if (!list) {
+ _D("No downloaded preset");
+ }
+
+ list = __append_user_group_icon_info_list(group_icon_info_list, db);
+ if (!list) {
+ _D("No user defined preset");
+ }
+
+ group_icon_info_list = _group_icon_info_list_sort(group_icon_info_list);
+ group_icon_info_list = _group_icon_info_list_trim(group_icon_info_list, db);
+
+ return group_icon_info_list;
+
+error:
+ _group_icon_info_list_destroy(group_icon_info_list);
+ return NULL;
+}
+
+
+
+void _group_icon_info_list_destroy(Eina_List *group_icon_info_list)
+{
+ group_icon_info_s *group_icon_info = NULL;
+
+ ret_if(!group_icon_info_list);
+
+ EINA_LIST_FREE(group_icon_info_list, group_icon_info) {
+ _group_icon_info_destroy(group_icon_info);
+ }
+}
+
+
+
+static int __group_icon_info_list_sort_cb(const void *d1, const void *d2)
+{
+ const group_icon_info_s *tmp1 = d1;
+ const group_icon_info_s *tmp2 = d2;
+
+ if (!tmp1)
+ return 1;
+ else if (!tmp2)
+ return -1;
+
+ return tmp1->ordering - tmp2->ordering;
+}
+
+
+
+Eina_List *_group_icon_info_list_sort(Eina_List *group_icon_info_list)
+{
+ group_icon_info_list = eina_list_sort(group_icon_info_list
+ , eina_list_count(group_icon_info_list)
+ , __group_icon_info_list_sort_cb);
+
+ return group_icon_info_list;
+}
+
+
+
+Eina_List *_group_icon_info_list_trim(Eina_List *group_icon_info_list, sqlite3 *db)
+{
+ const Eina_List *l = NULL;
+ const Eina_List *ln = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+ int ordering = 0;
+
+ EINA_LIST_FOREACH_SAFE(group_icon_info_list, l, ln, group_icon_info) {
+ int ret = STICKER_PANEL_ERROR_NONE;
+
+ if (!group_icon_info->initialized) {
+ _D("Group icon[%s] is removed", group_icon_info->id);
+ ret = _db_delete_group_icon(db, group_icon_info->id);
+ if (STICKER_PANEL_ERROR_NONE != ret) {
+ _E("cannot delete a group icon in the DB");
+ }
+ group_icon_info_list = eina_list_remove(group_icon_info_list, group_icon_info);
+ _group_icon_info_destroy(group_icon_info);
+ } else if (group_icon_info->ordering != ordering) {
+ group_icon_info->ordering = ordering;
+ ret = _db_update_group_icon(db, group_icon_info->id, ordering);
+ if (STICKER_PANEL_ERROR_NONE != ret) {
+ _E("cannot update a group icon to the DB");
+ }
+ _D("Group icon[%s]'s ordering is %d", group_icon_info->id, group_icon_info->ordering);
+ ordering++;
+ } else {
+ _D("Group icon[%s]'s ordering is %d", group_icon_info->id, group_icon_info->ordering);
+ ordering++;
+ }
+ }
+
+ return group_icon_info_list;
+}
+
+
+
+group_icon_info_s *_group_icon_info_list_get(Eina_List *group_icon_info_list, const char *id)
+{
+ const Eina_List *l = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+
+ retv_if(!group_icon_info_list, NULL);
+ retv_if(!id, NULL);
+
+ EINA_LIST_FOREACH(group_icon_info_list, l, group_icon_info) {
+ continue_if(!group_icon_info->id);
+ if (!strcmp(group_icon_info->id, id)) {
+ return group_icon_info;
+ }
+ }
+
+ return NULL;
+}
--- /dev/null
+/*
+ * 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 <Evas.h>
+#include <Elementary.h>
+
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <string.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "conf.h"
+#include "ui_manager.h"
+#include "log.h"
+#include "icon_info.h"
+#include "db.h"
+
+#define STICKER_IMG_NAME_TOKEN_SUB "sub"
+#define STICKER_IMG_NAME_TOKEN_TH "th"
+
+
+
+static int __icon_info_image_list_sort_cb(const void *d1, const void *d2)
+{
+ icon_info_image_s *tmp1 = (icon_info_image_s *) d1;
+ icon_info_image_s *tmp2 = (icon_info_image_s *) d2;
+
+ if (tmp1 == NULL || tmp1->file == NULL) {
+ return 1;
+ } else if (tmp2 == NULL || tmp2->file == NULL) {
+ return -1;
+ }
+
+ return strcmp(tmp1->file, tmp2->file);
+}
+
+static icon_info_s *__icon_info_parse_directory(const char *dir_path)
+{
+ icon_info_s *icon_info = NULL;
+ DIR *dir_info = NULL;
+ struct dirent *dir_entry = NULL;
+ int ret = 0;
+
+ retv_if(!dir_path, NULL);
+
+ icon_info = calloc(1, sizeof(icon_info_s));
+ retv_if(!icon_info, NULL);
+
+ icon_info->dir_path = strdup(dir_path);
+ goto_if(!icon_info->dir_path, error);
+ icon_info->type = ICON_INFO_TYPE_DIRECTORY;
+
+ dir_info = opendir(dir_path);
+ goto_if(!dir_info, error);
+
+ while ((dir_entry = readdir(dir_info))) {
+ icon_info_image_s *icon_info_image = NULL;
+ char *d_name = NULL;
+ char *filename = NULL;
+ char *ext = NULL;
+ char *tmp = NULL;
+ char full_path[PATH_LEN] = {0, };
+ char thumbnail_file[PATH_LEN] = {0, };
+ struct stat stat_buf = {0, };
+
+ snprintf(full_path, sizeof(full_path), "%s/%s", dir_path, dir_entry->d_name);
+ lstat(full_path, &stat_buf);
+ if (S_ISDIR(stat_buf.st_mode))
+ continue;
+
+ d_name = strdup(dir_entry->d_name);
+ continue_if(!d_name);
+
+ icon_info_image = calloc(1, sizeof(icon_info_image_s));
+ goto_if(!icon_info_image, not_sticker);
+
+ icon_info_image->file = strdup(full_path);
+ goto_if(!icon_info_image->file, not_sticker);
+
+ filename = strtok(d_name, ".");
+ goto_if(!filename, not_sticker);
+
+ ext = strtok(NULL, ".");
+ goto_if(!ext, not_sticker);
+
+ tmp = strtok(filename, "_");
+ goto_if(!tmp, not_sticker);
+
+ if (!icon_info->keyword) {
+ icon_info->keyword = strdup(tmp);
+ goto_if(!icon_info->keyword, not_sticker);
+ }
+
+ if ((tmp = strtok(NULL, "_"))) {
+ if (!strcmp(tmp, STICKER_IMG_NAME_TOKEN_SUB)) {
+ goto not_sticker;
+ } else if (!strcmp(tmp, STICKER_IMG_NAME_TOKEN_TH)) {
+ if (icon_info->thumbnail_file) {
+ goto not_sticker;
+ }
+
+ snprintf(thumbnail_file
+ , sizeof(thumbnail_file)
+ , "%s/%s_%s.%s"
+ , icon_info->dir_path
+ , icon_info->keyword
+ , STICKER_IMG_NAME_TOKEN_TH
+ , ext);
+ icon_info->thumbnail_file = strdup(thumbnail_file);
+ goto_if(!icon_info->thumbnail_file, not_sticker);
+ } else {
+ icon_info_image->frame_order = atoi(tmp);
+ }
+ } else goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info_image->diff_time = atoi(tmp);
+ else goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info->repeat = atoi(tmp);
+ else goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info->interval = atoi(tmp);
+ else goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info->play_type = atoi(tmp);
+ else goto next;
+
+ if ((tmp = strtok(NULL, "_")))
+ icon_info->th_frame = atoi(tmp);
+
+next:
+ icon_info->icon_info_image_list = eina_list_append(icon_info->icon_info_image_list, icon_info_image);
+ goto_if(!icon_info->icon_info_image_list, not_sticker);
+ free(d_name);
+ continue;
+
+not_sticker:
+ if (icon_info_image) {
+ free(icon_info_image->file);
+ free(icon_info_image);
+ }
+ free(d_name);
+ }
+
+ icon_info->icon_info_image_list = eina_list_sort(
+ icon_info->icon_info_image_list
+ , eina_list_count(icon_info->icon_info_image_list)
+ , __icon_info_image_list_sort_cb);
+
+ ret = closedir(dir_info);
+ if (ret != 0) {
+ _E("Failed to close directory(%s)", dir_path);
+ }
+
+ return icon_info;
+
+error:
+ if (icon_info) {
+ free(icon_info->dir_path);
+ free(icon_info);
+ }
+
+ return NULL;
+}
+
+
+
+static icon_info_s *__icon_info_parse_file(const char *file_path)
+{
+ icon_info_s *icon_info = NULL;
+
+ retv_if(!file_path, NULL);
+
+ icon_info = calloc(1, sizeof(icon_info_s));
+ retv_if(!icon_info, NULL);
+
+ icon_info->dir_path = strdup(file_path);
+ goto_if(!icon_info->dir_path, error);
+ icon_info->type = ICON_INFO_TYPE_FILE;
+
+ return icon_info;
+
+error:
+ free(icon_info);
+ return NULL;
+}
+
+
+
+static icon_info_s *__icon_info_parse_id(const char *id)
+{
+ icon_info_s *icon_info = NULL;
+
+ /* FIXME */
+
+ return icon_info;
+}
+
+
+
+icon_info_s *_icon_info_create(const char *id, int type)
+{
+ icon_info_s *icon_info = NULL;
+
+ retv_if(!id, NULL);
+
+ switch (type) {
+ case ICON_INFO_TYPE_DIRECTORY:
+ icon_info = __icon_info_parse_directory(id);
+ break;
+ case ICON_INFO_TYPE_FILE:
+ icon_info = __icon_info_parse_file(id);
+ break;
+ case ICON_INFO_TYPE_ID:
+ icon_info = __icon_info_parse_id(id);
+ break;
+ default:
+ _E("Cannot reach here, %s, %d", id, type);
+ break;
+ }
+ retv_if(!icon_info, NULL);
+
+ return icon_info;
+}
+
+
+
+icon_info_s *_icon_info_create_thumbnail(const char *thumbnail_file)
+{
+ icon_info_s *icon_info = NULL;
+ char *tmp = NULL;
+
+ retv_if(!thumbnail_file, NULL);
+
+ icon_info = calloc(1, sizeof(icon_info_s));
+ retv_if(!icon_info, NULL);
+
+ tmp = strdup(thumbnail_file);
+ if (!tmp) {
+ free(icon_info);
+ return NULL;
+ }
+
+ icon_info->thumbnail_file = tmp;
+
+ return icon_info;
+}
+
+
+
+void _icon_info_destroy(icon_info_s *icon_info)
+{
+ icon_info_image_s *icon_info_image = NULL;
+
+ ret_if(!icon_info);
+
+ free(icon_info->dir_path);
+ free(icon_info->keyword);
+ free(icon_info->thumbnail_file);
+
+ EINA_LIST_FREE(icon_info->icon_info_image_list, icon_info_image) {
+ if (!icon_info_image) {
+ continue;
+ }
+
+ free(icon_info_image->file);
+ free(icon_info_image);
+ }
+
+ if (icon_info->icon) {
+ evas_object_del(icon_info->icon);
+ }
+
+ free(icon_info);
+}
+
+
+
+Eina_List *_icon_info_list_create_recent_package(sqlite3 *db)
+{
+ Eina_List *icon_info_list = NULL;
+ int ret = STICKER_PANEL_ERROR_NONE;
+
+ ret = _db_list_recent_icon(db, &icon_info_list, 40);
+ if (ret != STICKER_PANEL_ERROR_NONE) {
+ _D("There is no recent icons");
+ }
+
+ return icon_info_list;
+}
+
+
+
+Eina_List *_icon_info_list_create_preset_package(const char *dir_path)
+{
+ Eina_List *icon_info_list = NULL;
+ DIR *dir_info = NULL;
+ struct dirent *dir_entry = NULL;
+ struct stat stat_buf;
+ int ret = 0;
+
+ retv_if(!dir_path, NULL);
+
+ dir_info = opendir(dir_path);
+ retv_if(!dir_info, NULL);
+
+ while ((dir_entry = readdir(dir_info))) {
+ char icon_path[PATH_LEN] = {0, };
+ snprintf(icon_path, sizeof(icon_path), "%s/%s", dir_path, dir_entry->d_name);
+
+ memset(&stat_buf, 0, sizeof(struct stat));
+ lstat(icon_path, &stat_buf);
+
+ /* FIXME : We can get files */
+ if (!S_ISDIR(stat_buf.st_mode)) {
+ continue;
+ }
+
+ if (!strcmp(".", dir_entry->d_name) || !strcmp("..", dir_entry->d_name)) {
+ continue;
+ }
+
+ if (strcmp(TAB_THUMBNAIL_DIR_PATH, dir_entry->d_name)) {
+ icon_info_s *icon_info = NULL;
+ icon_info = _icon_info_create(icon_path, ICON_INFO_TYPE_DIRECTORY);
+ if (icon_info) {
+ icon_info_list = eina_list_append(icon_info_list, icon_info);
+ }
+ }
+ }
+
+ ret = closedir(dir_info);
+ if (ret != 0) {
+ _E("Failed to close directory(%s)", dir_path);
+ }
+
+ return icon_info_list;
+}
+
+
+
+Eina_List *_icon_info_list_create_user_defined(const char *dir_path)
+{
+ Eina_List *icon_info_list = NULL;
+
+ /* FIXME */
+
+ return icon_info_list;
+}
+
+
+
+void _icon_info_list_destroy(Eina_List *icon_info_list)
+{
+ icon_info_s *icon_info = NULL;
+
+ ret_if(!icon_info_list);
+
+ EINA_LIST_FREE(icon_info_list, icon_info) {
+ _icon_info_destroy(icon_info);
+ }
+}
--- /dev/null
+/*
+ * 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 <Elementary.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "conf.h"
+#include "ui_manager.h"
+#include "log.h"
+#include "naviframe.h"
+
+
+Evas_Object *_naviframe_create(Evas_Object *conformant)
+{
+ Evas_Object *navi = NULL;
+
+ retv_if(!conformant, NULL);
+
+ _D("Create sticker panel naviframe");
+
+ navi = elm_naviframe_add(conformant);
+ retv_if(!navi, NULL);
+
+ evas_object_size_hint_weight_set(navi, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_content_set(conformant, navi);
+
+ evas_object_show(navi);
+
+ return navi;
+}
+
+void _naviframe_destroy(Evas_Object *navi)
+{
+ Evas_Object *btn = NULL;
+
+ _D("Delete sticker panel naviframe");
+
+ ret_if(!navi);
+
+ btn = elm_object_part_content_unset(navi, "prev_btn");
+ if (btn) {
+ evas_object_del(btn);
+ btn = NULL;
+ }
+
+ btn = elm_object_part_content_unset(navi, "next_btn");
+ if (btn) {
+ evas_object_del(btn);
+ btn = NULL;
+ }
+
+ evas_object_del(navi);
+}
+
+void _naviframe_set_title(Evas_Object *navi, const char *title)
+{
+ ret_if(!navi);
+ ret_if(!title);
+
+ elm_object_part_text_set(navi, "default", title);
+}
+
+Evas_Object *_naviframe_button_create(Evas_Object *navi, sticker_panel_navi_btn_type_e btn_type, const char *text, btn_clicked_cb clicked_cb, void *data)
+{
+ Evas_Object *btn = NULL;
+ Evas_Object *old_btn = NULL;
+
+ retv_if(!navi, NULL);
+ retv_if(!text, NULL);
+ retv_if(!clicked_cb, NULL);
+
+ btn = elm_button_add(navi);
+ retv_if(!btn, NULL);
+
+ elm_object_text_set(btn, text);
+
+ switch (btn_type) {
+ case STICKER_PANEL_NAVI_BTN_LEFT:
+ old_btn = elm_object_part_content_unset(navi, "prev_btn");
+ if (old_btn) {
+ _D("Delete old button(left)");
+ evas_object_del(old_btn);
+ old_btn = NULL;
+ }
+
+ elm_object_part_content_set(navi, "prev_btn", btn);
+ break;
+ case STICKER_PANEL_NAVI_BTN_RIGHT:
+ old_btn = elm_object_part_content_unset(navi, "next_btn");
+ if (old_btn) {
+ _D("Delete old button(right)");
+ evas_object_del(old_btn);
+ old_btn = NULL;
+ }
+
+ elm_object_part_content_set(navi, "next_btn", btn);
+ break;
+ default:
+ _E("Failed to create naviframe button(type : %d", btn_type);
+ if (btn) {
+ evas_object_del(btn);
+ btn = NULL;
+ }
+ return NULL;
+ }
+
+ evas_object_smart_callback_add(btn, "clicked", clicked_cb, &data);
+
+ evas_object_show(btn);
+
+ return btn;
+}
+
+void _naviframe_button_destroy(Evas_Object *navi, sticker_panel_navi_btn_type_e btn_type)
+{
+ Evas_Object *btn = NULL;
+
+ ret_if(!navi);
+
+ switch (btn_type) {
+ case STICKER_PANEL_NAVI_BTN_LEFT:
+ btn = elm_object_part_content_unset(navi, "prev_btn");
+ if (btn) {
+ _D("Delete left button");
+ evas_object_del(btn);
+ btn = NULL;
+ }
+ break;
+ case STICKER_PANEL_NAVI_BTN_RIGHT:
+ btn = elm_object_part_content_unset(navi, "next_btn");
+ if (btn) {
+ _D("Delete right button");
+ evas_object_del(btn);
+ btn = NULL;
+ }
+ break;
+ default:
+ _E("Failed to delete naviframe button(type : %d)", btn_type);
+ return;
+ }
+}
+
+void _naviframe_show(Evas_Object *navi)
+{
+ ret_if(!navi);
+
+ evas_object_show(navi);
+}
+
+void _naviframe_hide(Evas_Object *navi)
+{
+ ret_if(!navi);
+
+ evas_object_hide(navi);
+}
--- /dev/null
+/*
+ * 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 <Elementary.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "conf.h"
+#include "log.h"
+#include "page.h"
+
+
+
+static void __resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *page = obj;
+
+ int x, y, w, h;
+
+ ret_if(!page);
+
+ evas_object_geometry_get(page, &x, &y, &w, &h);
+ _D("page(%s), resize(%d, %d, %d, %d)", data, x, y, w, h);
+}
+
+
+
+#define PAGE_EDJE_FILE EDJEDIR"/page.edj"
+Evas_Object *_page_create(Evas_Object *scroller, int width, int height)
+{
+ Evas_Object *page = NULL;
+ Evas_Object *page_bg = NULL;
+ Evas *e = NULL;
+
+ page = elm_layout_add(scroller);
+ retv_if(!page, NULL);
+ elm_layout_file_set(page, PAGE_EDJE_FILE, "page");
+
+ evas_object_size_hint_weight_set(page, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(page, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ e = evas_object_evas_get(scroller);
+ goto_if(!e, ERROR);
+
+ page_bg = evas_object_rectangle_add(e);
+ goto_if(!page_bg, ERROR);
+ evas_object_size_hint_weight_set(page_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(page_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_min_set(page_bg, width, height);
+ evas_object_color_set(page_bg, 0, 0, 0, 0);
+ evas_object_repeat_events_set(page_bg, EINA_TRUE);
+ evas_object_show(page_bg);
+ elm_object_part_content_set(page, "bg", page_bg);
+
+ evas_object_event_callback_add(page, EVAS_CALLBACK_RESIZE, __resize_cb, "PAGE");
+
+ evas_object_show(page);
+ return page;
+
+ERROR:
+ _page_destroy(page);
+ return NULL;
+}
+
+
+
+void _page_destroy(Evas_Object *page)
+{
+ Evas_Object *bg = NULL;
+
+ ret_if(!page);
+
+ evas_object_event_callback_del(page, EVAS_CALLBACK_RESIZE, __resize_cb);
+
+ bg = elm_object_part_content_unset(page, "bg");
+ if (bg) {
+ evas_object_del(bg);
+ }
+
+ evas_object_del(page);
+}
+
+
+
+void _page_resize(Evas_Object *page, int width, int height)
+{
+ Evas_Object *bg = NULL;
+
+ ret_if(!page);
+
+ bg = elm_object_part_content_get(page, "bg");
+ ret_if(!bg);
+
+ evas_object_size_hint_min_set(bg, width, height);
+ evas_object_size_hint_max_set(bg, width, height);
+}
--- /dev/null
+/*
+ * 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 <Elementary.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "group_icon_info.h"
+#include "conf.h"
+#include "log.h"
+#include "page.h"
+#include "scroller.h"
+
+#define PRIVATE_DATA_KEY_SCROLLER_IS_SCROLLING "p_is_sc"
+#define PRIVATE_DATA_KEY_SCROLLER_DRAG_START "p_dg_st"
+#define PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST "pdkec"
+
+
+
+struct _event_cb {
+ int event_type;
+ void (*event_cb)(Evas_Object *scroller, int event_type, void *event_info, void *user_data);
+ void *user_data;
+};
+typedef struct _event_cb event_cb_s;
+
+
+
+int _scroller_is_scrolling(Evas_Object *scroller)
+{
+ retv_if(!scroller, 0);
+ return (int)evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_IS_SCROLLING);
+}
+
+
+
+static void __anim_start_cb(void *data, Evas_Object *scroller, void *event_info)
+{
+ _D("start the scroller(%p) animation", scroller);
+ evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_IS_SCROLLING, (void *)1);
+}
+
+
+
+static void __anim_stop_cb(void *data, Evas_Object *scroller, void *event_info)
+{
+ _D("stop the scroller(%p) animation", scroller);
+ evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_IS_SCROLLING);
+ evas_object_data_del(scroller, PRIVATE_DATA_KEY_SCROLLER_DRAG_START);
+}
+
+
+
+static void __drag_start_cb(void *data, Evas_Object *scroller, void *event_info)
+{
+ _D("start to drag the scroller(%p)", scroller);
+ evas_object_data_set(scroller, PRIVATE_DATA_KEY_SCROLLER_DRAG_START, (void *)1);
+}
+
+
+
+static void __drag_stop_cb(void *data, Evas_Object *scroller, void *event_info)
+{
+ _D("stop to drag the scroller(%p)", scroller);
+}
+
+
+
+static void __scroll_cb(void *data, Evas_Object *scroller, void *event_info)
+{
+ sticker_panel_h sticker_panel = data;
+ Eina_List *event_cb_list = NULL;
+ const Eina_List *l = NULL;
+ const Eina_List *ln = NULL;
+ event_cb_s *event_cb_info = NULL;
+
+ int index = 0;
+ int x = 0;
+ int page_w = 0;
+
+ ret_if(!sticker_panel);
+ ret_if(!scroller);
+
+ if (!evas_object_data_get(scroller, PRIVATE_DATA_KEY_SCROLLER_DRAG_START)) {
+ return;
+ }
+
+ event_cb_list = evas_object_data_get(scroller, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST);
+ ret_if(!event_cb_list);
+
+ elm_scroller_region_get(scroller, &x, NULL, NULL, NULL);
+ elm_scroller_page_size_get(scroller, &page_w, NULL);
+
+ index = x / page_w;
+ x = x % page_w;
+ if (x > (page_w / 2)) {
+ index++;
+ }
+
+ sticker_panel->cur_page_no = index;
+
+ EINA_LIST_FOREACH_SAFE(event_cb_list, l, ln, event_cb_info) {
+ if (SCROLLER_EVENT_TYPE_SCROLL == event_cb_info->event_type) {
+ if (event_cb_info->event_cb) {
+ event_cb_info->event_cb(scroller, SCROLLER_EVENT_TYPE_SCROLL, (void *) index, event_cb_info->user_data);
+ }
+ }
+ }
+}
+
+
+
+static void __resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *scroller = obj;
+ sticker_panel_h sticker_panel = data;
+
+ int x, y, w, h;
+ int screen_w = 0, screen_h = 0;
+
+ ret_if(!scroller);
+ ret_if(!sticker_panel);
+
+ elm_win_screen_size_get(sticker_panel->win, NULL, NULL, &screen_w, &screen_h);
+
+ evas_object_geometry_get(scroller, &x, &y, &w, &h);
+ _D("scroller resize(%d, %d, %d, %d)", x, y, w, h);
+
+ if (w == screen_w || w == screen_h) {
+ _D("screen size(%d, %d)", screen_w, screen_h);
+ elm_scroller_page_show(scroller, sticker_panel->cur_page_no, 0);
+ }
+}
+
+
+
+Evas_Object *_scroller_create(Evas_Object *ui_manager, sticker_panel_h sticker_panel)
+{
+ Evas_Object *box = NULL;
+ Evas_Object *scroller = NULL;
+ int width = 0;
+
+ retv_if(!ui_manager, NULL);
+ retv_if(!sticker_panel, NULL);
+
+ scroller = elm_scroller_add(ui_manager);
+ retv_if(!scroller, NULL);
+
+ elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_FALSE);
+ elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+ elm_scroller_page_scroll_limit_set(scroller, 1, 1);
+ elm_scroller_content_min_limit(scroller, EINA_FALSE, EINA_TRUE);
+ elm_scroller_single_direction_set(scroller, ELM_SCROLLER_SINGLE_DIRECTION_HARD);
+
+ elm_scroller_page_size_set(scroller, sticker_panel->transit_width, sticker_panel->transit_height - ELM_SCALE_SIZE(TOOLBAR_HEIGHT));
+ evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_min_set(scroller, width, 0);
+
+ elm_object_style_set(scroller, "effect");
+ evas_object_show(scroller);
+ elm_object_scroll_lock_y_set(scroller, EINA_TRUE);
+
+ 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, sticker_panel);
+ evas_object_event_callback_add(scroller, EVAS_CALLBACK_RESIZE, __resize_cb, sticker_panel);
+
+ box = elm_box_add(scroller);
+ goto_if(!box, ERROR);
+
+ elm_box_horizontal_set(box, EINA_TRUE);
+ elm_box_align_set(box, 0.5, 0.0);
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(box);
+
+ elm_object_content_set(scroller, box);
+ sticker_panel->cur_page_no = 0;
+
+ return scroller;
+
+ERROR:
+ if (scroller) {
+ evas_object_del(scroller);
+ }
+ return NULL;
+}
+
+
+
+void _scroller_destroy(Evas_Object *scroller)
+{
+ Evas_Object *box = NULL;
+ ret_if(!scroller);
+
+ evas_object_event_callback_del(scroller, EVAS_CALLBACK_RESIZE, __resize_cb);
+ box = elm_object_content_unset(scroller);
+ if (box) {
+ evas_object_del(box);
+ }
+
+ evas_object_del(scroller);
+}
+
+
+
+void _scroller_append_page(Evas_Object *scroller, Evas_Object *page)
+{
+ Evas_Object *box = NULL;
+
+ box = elm_object_content_get(scroller);
+ ret_if(!box);
+
+ elm_box_pack_end(box, page);
+}
+
+
+
+void _scroller_remove_page(Evas_Object *scroller, Evas_Object *page)
+{
+ Evas_Object *box = NULL;
+ Evas_Object *tmp = NULL;
+ Eina_List *list = NULL;
+
+ int is_page_exist = 0;
+
+ box = elm_object_content_get(scroller);
+ ret_if(!box);
+
+ list = elm_box_children_get(box);
+ EINA_LIST_FREE(list, tmp) {
+ continue_if(!tmp);
+ if (page == tmp) {
+ is_page_exist = 1;
+ }
+ }
+
+ if (!is_page_exist) {
+ _D("No page to remove");
+ return;
+ }
+
+ elm_box_unpack(box, page);
+}
+
+
+
+void _scroller_reorder_page(Evas_Object *scroller, Eina_List *group_icon_info_list)
+{
+ Eina_List *l = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+
+ ret_if(!scroller);
+ ret_if(!group_icon_info_list);
+
+ EINA_LIST_FOREACH(group_icon_info_list, l, group_icon_info) {
+ if (!group_icon_info) {
+ continue;
+ }
+
+ if (group_icon_info->permutable == 0) {
+ continue;
+ }
+
+ _scroller_remove_page(scroller, group_icon_info->item_view);
+ _scroller_append_page(scroller, group_icon_info->item_view);
+ }
+}
+
+
+
+void _scroller_bring_in_page(Evas_Object *scroller, Evas_Object *page, int *cur_page_no)
+{
+ Evas_Object *box = NULL;
+ Evas_Object *tmp = NULL;
+ Eina_List *list = NULL;
+ int index = 0;
+ int exist = 1;
+
+ ret_if(!scroller);
+ ret_if(!page);
+
+ box = elm_object_content_get(scroller);
+ ret_if(!box);
+
+ list = elm_box_children_get(box);
+ ret_if(!list);
+
+ EINA_LIST_FREE(list, tmp) {
+ continue_if(!tmp);
+ if (page == tmp) {
+ exist = 0;
+ }
+ index += exist;
+ }
+
+ if (exist) {
+ index = 0;
+ }
+
+ *cur_page_no = index;
+
+ elm_scroller_page_bring_in(scroller, index, 0);
+}
+
+
+
+void _scroller_resize(Evas_Object *scroller, int width, int height)
+{
+ Evas_Object *box = NULL;
+ Evas_Object *page = NULL;
+ Eina_List *list = NULL;
+
+ ret_if(!scroller);
+
+ elm_scroller_page_size_set(scroller, width, height);
+
+ box = elm_object_content_get(scroller);
+ ret_if(!box);
+
+ list = elm_box_children_get(box);
+ ret_if(!list);
+
+ EINA_LIST_FREE(list, page) {
+ _page_resize(page, width, height);
+ }
+}
+
+
+
+int _scroller_register_event_cb(Evas_Object *scroller, int event_type, void (*event_cb)(Evas_Object *scroller, int event_type, void *event_info, void *user_data), void *user_data)
+{
+ Eina_List *event_cb_list = NULL;
+ event_cb_s *event_cb_info = NULL;
+
+ retv_if(!scroller, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(event_type <= SCROLLER_EVENT_TYPE_INVALID, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(event_type >= SCROLLER_EVENT_TYPE_MAX, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!event_cb, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ event_cb_info = calloc(1, sizeof(event_cb_s));
+ retv_if(!event_cb_info, STICKER_PANEL_ERROR_OUT_OF_MEMORY);
+
+ event_cb_info->event_type = event_type;
+ event_cb_info->event_cb = event_cb;
+ event_cb_info->user_data = user_data;
+
+ event_cb_list = evas_object_data_get(scroller, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST);
+ event_cb_list = eina_list_append(event_cb_list, event_cb_info);
+ evas_object_data_set(scroller, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST, event_cb_list);
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+int _scroller_unregister_event_cb(Evas_Object *scroller, int event_type, void (*event_cb)(Evas_Object *scroller, int event_type, void *event_info, void *user_data))
+{
+ Eina_List *event_cb_list = NULL;
+ const Eina_List *l = NULL;
+ const Eina_List *ln = NULL;
+ event_cb_s *event_cb_info = NULL;
+
+ retv_if(!scroller, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(event_type <= SCROLLER_EVENT_TYPE_INVALID, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(event_type >= SCROLLER_EVENT_TYPE_MAX, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!event_cb, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ event_cb_list = evas_object_data_get(scroller, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST);
+ retv_if(!event_cb_list, STICKER_PANEL_ERROR_NOT_INITIALIZED);
+
+ EINA_LIST_FOREACH_SAFE(event_cb_list, l, ln, event_cb_info) {
+ if (event_cb_info->event_type == event_type
+ && event_cb_info->event_cb == event_cb) {
+ event_cb_list = eina_list_remove(event_cb_list, event_cb_info);
+ break;
+ }
+ }
+
+ evas_object_data_set(scroller, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST, event_cb_list);
+
+ return STICKER_PANEL_ERROR_NONE;
+}
--- /dev/null
+/*
+ * 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 <Elementary.h>
+#include <efl_extension.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "setting.h"
+#include "conf.h"
+#include "log.h"
+#include "group_icon_info.h"
+#include "db.h"
+#include "icon_info.h"
+#include "toolbar.h"
+#include "scroller.h"
+#include "page.h"
+
+#define BUF_SIZE_1024 1024
+
+const char *const PRIVATE_DATA_KEY_SETTING_INFO = "__dksi__";
+const char *const PRIVATE_DATA_KEY_SELECT_ALL_ITEM = "__dksai__";
+const char *const PRIVATE_DATA_KEY_GROUP_ICON_INFO = "__dkgii__";
+const char *const KEY_NAME_MENU = "XF86Menu";
+const char *const KEY_NAME_BACK = "XF86Back";
+const char *const FILE_LAYOUT_EDJ = EDJEDIR"/setting.edj";
+const char *const GROUP_LAYOUT = "layout";
+//@TODO: need to change string
+const char *const STRING_SETTING = "Setting";
+const char *const STRING_REORDER = "Reorder";
+const char *const STRING_DELETE = "Delete";
+const char *const STRING_CANCEL = "Cancel";
+const char *const STRING_DONE = "Done";
+
+
+struct _setting_info_s {
+ sqlite3 *db;
+ Eina_List *group_icon_info_list;
+ Evas_Object *navi;
+ Evas_Object *toolbar;
+ Evas_Object *scroller;
+ Evas_Object *genlist;
+ Evas_Object *ctx_popup;
+ Ecore_Event_Handler *key_press;
+ Ecore_Event_Handler *key_release;
+ Eina_Bool show_ctx_popup;
+ setting_view_type_e view_type;
+};
+typedef struct _setting_info_s setting_info_s;
+
+
+
+static char *__get_label_cb(void *data, Evas_Object *obj, const char *part)
+{
+ group_icon_info_s *group_icon_info = NULL;
+ setting_info_s *setting_info = NULL;
+ char *ret_str = NULL;
+ int order = (int) data;
+
+ retv_if(!obj, NULL);
+ retv_if(!part, NULL);
+
+ setting_info = evas_object_data_get(obj, PRIVATE_DATA_KEY_SETTING_INFO);
+ retv_if(!setting_info, NULL);
+
+ if (order == -1 && setting_info->view_type == SETTING_VIEW_DELETE) {
+ if (!strcmp(part, "elm.text.main.left")) {
+ //@TODO: need to change string
+ ret_str = strdup("Select all");
+ if (!ret_str) {
+ _E("Failed to duplicate string");
+ return NULL;
+ }
+
+ return ret_str;
+ }
+ return NULL;
+ }
+
+ if (!strcmp(part, "elm.text.main") || !strcmp(part, "elm.text.main.left")) {
+ icon_info_s *icon_info = NULL;
+
+ group_icon_info = eina_list_nth(setting_info->group_icon_info_list, order);
+ goto_if(!group_icon_info, error);
+
+ icon_info = eina_list_nth(group_icon_info->list, 0);
+ goto_if(!icon_info, error);
+ goto_if(!icon_info->thumbnail_file, error);
+
+ ret_str = strdup(group_icon_info->name);
+ if (!ret_str) {
+ _E("Failed to duplicate string");
+ return NULL;
+ }
+
+ return ret_str;
+ }
+
+error:
+
+ return NULL;
+}
+
+
+
+static void __update_navi_title_with_count(Evas_Object *genlist, setting_info_s *setting_info)
+{
+ Elm_Object_Item *navi_item = NULL;
+ Elm_Object_Item *genlist_item = NULL;
+ Evas_Object *check = NULL;
+ Eina_Bool check_on = EINA_FALSE;
+ char title[BUF_SIZE_1024] = { 0, };
+ int max_count = 0;
+ int count = 0;
+
+ ret_if(!genlist);
+ ret_if(!setting_info);
+
+ max_count = elm_genlist_items_count(genlist);
+
+ /* Exclude 'Select all' item */
+ max_count--;
+
+ navi_item = elm_naviframe_top_item_get(setting_info->navi);
+ ret_if(!navi_item);
+
+ genlist_item = elm_genlist_first_item_get(genlist);
+ ret_if(!genlist_item);
+
+ /* Exclude 'Select all' item */
+ genlist_item = elm_genlist_item_next_get(genlist_item);
+
+ while (genlist_item) {
+ check = elm_object_item_part_content_get(genlist_item, "elm.icon.right");
+ ret_if(!check);
+
+ check_on = elm_check_state_get(check);
+ if (check_on) {
+ count++;
+ }
+
+ genlist_item = elm_genlist_item_next_get(genlist_item);
+ }
+
+ //@TODO: need to change string
+ snprintf(title, sizeof(title), "%d %s", count, "selected");
+
+ elm_object_item_part_text_set(navi_item, "default", title);
+
+ if (count == 0) {
+ genlist_item = elm_genlist_first_item_get(genlist);
+ ret_if(!genlist_item);
+
+ check = elm_object_item_part_content_get(genlist_item, "elm.icon.right");
+ ret_if(!check);
+
+ elm_check_state_set(check, EINA_FALSE);
+ } else if (count == max_count) {
+ genlist_item = elm_genlist_first_item_get(genlist);
+ ret_if(!genlist_item);
+
+ check = elm_object_item_part_content_get(genlist_item, "elm.icon.right");
+ ret_if(!check);
+
+ elm_check_state_set(check, EINA_TRUE);
+ }
+}
+
+
+
+static void __change_check_state_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *genlist = NULL;
+ Evas_Object *check = NULL;
+ Elm_Object_Item *genlist_item = NULL;
+ Eina_Bool is_select_all = EINA_FALSE;
+ Eina_Bool check_on = EINA_FALSE;
+ setting_info_s *setting_info = NULL;
+
+ genlist = data;
+ ret_if(!genlist);
+
+ ret_if(!obj);
+
+ setting_info = evas_object_data_get(genlist, PRIVATE_DATA_KEY_SETTING_INFO);
+ ret_if(!setting_info);
+
+ is_select_all = (Eina_Bool)(intptr_t) evas_object_data_get(obj, PRIVATE_DATA_KEY_SELECT_ALL_ITEM);
+ goto_if(!is_select_all, out);
+
+ genlist_item = elm_genlist_first_item_get(genlist);
+ ret_if(!genlist_item);
+
+ check = elm_object_item_part_content_get(genlist_item, "elm.icon.right");
+ ret_if(!check);
+
+ check_on = elm_check_state_get(check);
+
+ genlist_item = elm_genlist_item_next_get(genlist_item);
+
+ while (genlist_item) {
+ check = elm_object_item_part_content_get(genlist_item, "elm.icon.right");
+ ret_if(!check);
+
+ if (check_on) {
+ elm_check_state_set(check, EINA_TRUE);
+ } else {
+ elm_check_state_set(check, EINA_FALSE);
+ }
+
+ genlist_item = elm_genlist_item_next_get(genlist_item);
+ }
+
+out:
+ /* update naviframe title */
+ __update_navi_title_with_count(genlist, setting_info);
+}
+
+
+
+static Evas_Object *__create_delete_check(Evas_Object *parent, Eina_Bool is_select_all)
+{
+ Evas_Object *check = NULL;
+
+ retv_if(!parent, NULL);
+
+ check = elm_check_add(parent);
+ retv_if(!check, NULL);
+
+ elm_object_style_set(check, "default");
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ evas_object_show(check);
+
+ evas_object_data_set(check, PRIVATE_DATA_KEY_SELECT_ALL_ITEM, (void *)(intptr_t) is_select_all);
+
+ evas_object_smart_callback_add(check, "changed", __change_check_state_cb, parent);
+
+ return check;
+}
+
+
+
+static void __destroy_delete_check(Evas_Object *check)
+{
+ ret_if(!check);
+
+ evas_object_data_del(check, PRIVATE_DATA_KEY_SELECT_ALL_ITEM);
+ evas_object_smart_callback_del(check, "changed", __change_check_state_cb);
+ evas_object_del(check);
+}
+
+
+static Evas_Object *__create_genlist_left_icon(Evas_Object *parent, int order, setting_info_s *setting_info)
+{
+ Evas_Object *content = NULL;
+ Evas_Object *icon = NULL;
+ icon_info_s *icon_info = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+
+ retv_if(!parent, NULL);
+ retv_if(!setting_info, NULL);
+
+ content = elm_layout_add(parent);
+ retv_if(!content, NULL);
+
+ elm_layout_theme_set(content, "layout", "list/C/type.3", "default");
+
+ icon = elm_image_add(content);
+ goto_if(!icon, error);
+
+ group_icon_info = eina_list_nth(setting_info->group_icon_info_list, order);
+ goto_if(!group_icon_info, error);
+ goto_if(!group_icon_info->list, error);
+
+ icon_info = eina_list_nth(group_icon_info->list, 0);
+ goto_if(!icon_info, error);
+ goto_if(!icon_info->thumbnail_file, error);
+
+ if (!elm_image_file_set(icon, icon_info->thumbnail_file, NULL)) {
+ _E("Failed to set icon");
+ goto error;
+ }
+
+ elm_layout_content_set(content, "elm.swallow.content", icon);
+
+ evas_object_show(icon);
+ evas_object_show(content);
+
+ return content;
+
+error:
+ if (icon) {
+ evas_object_del(icon);
+ }
+
+ if (content) {
+ evas_object_del(content);
+ }
+
+ return NULL;
+}
+
+
+
+static void __destroy_genlist_left_icon(Evas_Object *left_icon)
+{
+ Evas_Object *icon = NULL;
+
+ ret_if(!left_icon);
+
+ icon = elm_layout_content_get(left_icon, "elm.swallow.content");
+ if (icon) {
+ evas_object_del(icon);
+ }
+
+ evas_object_del(left_icon);
+}
+
+
+
+static Evas_Object *__create_reorder_icon(Evas_Object *parent)
+{
+ Evas_Object *icon = NULL;
+
+ retv_if(!parent, NULL);
+
+ icon = elm_button_add(parent);
+ retv_if(!icon, NULL);
+
+ elm_object_style_set(icon, "icon_reorder");
+ evas_object_show(icon);
+
+ return icon;
+}
+
+
+
+static void __destroy_reorder_icon(Evas_Object *icon)
+{
+ ret_if(!icon);
+
+ evas_object_del(icon);
+}
+
+
+
+static Evas_Object *__get_content_cb(void *data, Evas_Object *obj, const char *part)
+{
+ setting_info_s *setting_info = NULL;
+
+ int order = (int) data;
+
+ retv_if(!obj, NULL);
+ retv_if(!part, NULL);
+
+ setting_info = evas_object_data_get(obj, PRIVATE_DATA_KEY_SETTING_INFO);
+ retv_if(!setting_info, NULL);
+
+ if (order == -1 && setting_info->view_type == SETTING_VIEW_DELETE) {
+ if (!strcmp(part, "elm.icon.right")) {
+ Evas_Object *check = NULL;
+
+ check = __create_delete_check(obj, EINA_TRUE);
+ retv_if(!check, NULL);
+
+ return check;
+ }
+ return NULL;
+ }
+
+ if (!strcmp(part, "elm.icon.1")) {
+ Evas_Object *left_icon = NULL;
+
+ left_icon = __create_genlist_left_icon(obj, order, setting_info);
+ retv_if(!left_icon, NULL);
+
+ return left_icon;
+ } else if (!strcmp(part, "elm.icon.right")) {
+ Evas_Object *right_btn = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+
+ switch(setting_info->view_type) {
+ case SETTING_VIEW_REORDER:
+ right_btn = __create_reorder_icon(obj);
+ retv_if(!right_btn, NULL);
+ break;
+ case SETTING_VIEW_DELETE:
+ group_icon_info = eina_list_nth(setting_info->group_icon_info_list, order);
+ if (!group_icon_info) {
+ _E("Failed to get group icon info");
+ return NULL;
+ }
+
+ if (group_icon_info->removable == 0) {
+ _E("This item is not removable");
+ return NULL;
+ }
+
+ right_btn = __create_delete_check(obj, EINA_FALSE);
+ retv_if(!right_btn, NULL);
+ break;
+ default:
+ _E("view type error : %d", setting_info->view_type);
+ return NULL;
+ }
+
+ return right_btn;
+ }
+
+ return NULL;
+}
+
+
+
+static void __select_item_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *selected_item = NULL;
+
+ setting_info_s *setting_info = data;
+ ret_if(!data);
+
+ ret_if(!obj);
+
+ selected_item = elm_genlist_selected_item_get(obj);
+ ret_if(!selected_item);
+
+ elm_genlist_item_selected_set(selected_item, EINA_FALSE);
+
+ if (setting_info->view_type == SETTING_VIEW_DELETE) {
+ Evas_Object *check = NULL;
+ Eina_Bool check_on = EINA_FALSE;
+
+ check = elm_object_item_part_content_get(selected_item, "elm.icon.right");
+ ret_if(!check);
+
+ check_on = elm_check_state_get(check);
+
+ if (check_on) {
+ elm_check_state_set(check, EINA_FALSE);
+ } else {
+ elm_check_state_set(check, EINA_TRUE);
+ }
+
+ /* update naviframe title */
+ __update_navi_title_with_count(obj, setting_info);
+ }
+
+ return;
+}
+
+
+
+static void __select_all_item_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *check = NULL;
+ Eina_Bool check_on = EINA_FALSE;
+ Elm_Object_Item *genlist_item = NULL;
+
+ setting_info_s *setting_info = data;
+ ret_if(!data);
+
+ ret_if(!obj);
+
+ genlist_item = elm_genlist_selected_item_get(obj);
+ ret_if(!genlist_item);
+
+ elm_genlist_item_selected_set(genlist_item, EINA_FALSE);
+
+ check = elm_object_item_part_content_get(genlist_item, "elm.icon.right");
+ ret_if(!check);
+
+ check_on = elm_check_state_get(check);
+
+ while (genlist_item) {
+ check = elm_object_item_part_content_get(genlist_item, "elm.icon.right");
+ ret_if(!check);
+
+ if (check_on) {
+ elm_check_state_set(check, EINA_FALSE);
+ } else {
+ elm_check_state_set(check, EINA_TRUE);
+ }
+
+ genlist_item = elm_genlist_item_next_get(genlist_item);
+ }
+
+ /* update naviframe title */
+ __update_navi_title_with_count(obj, setting_info);
+
+ return;
+}
+
+
+
+static void __destroy_genlist(Evas_Object *genlist)
+{
+ Evas_Object *left_icon = NULL;
+ Evas_Object *right_icon = NULL;
+ Elm_Object_Item *genlist_item = NULL;
+ Elm_Object_Item *genlist_next_item = NULL;
+ setting_info_s *setting_info = NULL;
+
+ ret_if(!genlist);
+
+ setting_info = evas_object_data_del(genlist, PRIVATE_DATA_KEY_SETTING_INFO);
+ ret_if(!setting_info);
+
+ genlist_item = elm_genlist_first_item_get(genlist);
+ ret_if(!genlist_item);
+
+ while (genlist_item) {
+ left_icon = elm_object_item_part_content_get(genlist_item, "elm.icon.1");
+ if (left_icon) {
+ __destroy_genlist_left_icon(left_icon);
+ }
+
+ right_icon = elm_object_item_part_content_get(genlist_item, "elm.icon.right");
+ goto_if(!right_icon, out);
+
+ if (setting_info->view_type == SETTING_VIEW_REORDER) {
+ __destroy_reorder_icon(right_icon);
+ } else if (setting_info->view_type == SETTING_VIEW_DELETE) {
+ __destroy_delete_check(right_icon);
+ }
+
+out:
+ evas_object_data_del(genlist_item, PRIVATE_DATA_KEY_GROUP_ICON_INFO);
+ genlist_next_item = elm_genlist_item_next_get(genlist_item);
+ elm_object_item_del(genlist_item);
+ genlist_item = genlist_next_item;
+ }
+
+ evas_object_del(genlist);
+}
+
+
+
+static void __append_genlist_item(Evas_Object *genlist, setting_view_type_e view_type, setting_info_s *setting_info)
+{
+ Elm_Genlist_Item_Class *itc = NULL;
+ int i = 0;
+ int count = 0;
+
+ ret_if(!genlist);
+ ret_if(!setting_info);
+
+ count = eina_list_count(setting_info->group_icon_info_list);
+ _D("group icon count : %d", count);
+ ret_if(count == 0);
+
+ itc = elm_genlist_item_class_new();
+ if (!itc) {
+ _E("Failed to create item class for genlist");
+ __destroy_genlist(genlist);
+ return;
+ }
+
+ itc->item_style = "1line";
+ itc->func.text_get = __get_label_cb;
+ itc->func.content_get = __get_content_cb;
+ itc->func.state_get = NULL;
+ itc->func.del = NULL;
+
+ for (i = 0; i < count; i++) {
+ Elm_Object_Item *item = NULL;
+ group_icon_info_s *group_icon_info = eina_list_nth(setting_info->group_icon_info_list, i);
+ if (!group_icon_info) {
+ continue;
+ }
+
+ if (group_icon_info->permutable == 0) {
+ continue;
+ }
+
+ item = elm_genlist_item_append(genlist, itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, __select_item_cb, setting_info);
+ if (!item) {
+ continue;
+ }
+
+ evas_object_data_set(item, PRIVATE_DATA_KEY_GROUP_ICON_INFO, group_icon_info);
+ }
+
+ if (view_type == SETTING_VIEW_DELETE) {
+ elm_genlist_item_prepend(genlist, itc, (void *) -1, NULL, ELM_GENLIST_ITEM_NONE, __select_all_item_cb, setting_info);
+ }
+
+ elm_genlist_item_class_free(itc);
+}
+
+
+
+static Evas_Object *__create_genlist(Evas_Object *parent, setting_info_s *setting_info, setting_view_type_e view_type)
+{
+ Evas_Object *genlist = NULL;
+
+ retv_if(!parent, NULL);
+ retv_if(!setting_info, NULL);
+
+ genlist = elm_genlist_add(parent);
+ retv_if(!genlist, NULL);
+
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+ elm_object_style_set(genlist, "dialogue");
+
+ evas_object_data_set(genlist, PRIVATE_DATA_KEY_SETTING_INFO, (void *) setting_info);
+
+ evas_object_show(genlist);
+
+ __append_genlist_item(genlist, view_type, setting_info);
+
+ if (view_type == SETTING_VIEW_REORDER) {
+ elm_genlist_reorder_mode_set(genlist, EINA_TRUE);
+ }
+
+ return genlist;
+}
+
+
+
+static void __update_genlist(setting_info_s *setting_info)
+{
+ ret_if(!setting_info);
+
+ elm_genlist_clear(setting_info->genlist);
+ __append_genlist_item(setting_info->genlist, setting_info->view_type, setting_info);
+}
+
+
+static Evas_Object *__create_layout(Evas_Object *parent)
+{
+ Evas_Object *layout = NULL;
+ int w = 0;
+ int h = 0;
+
+ retv_if(!parent, NULL);
+
+ layout = elm_layout_add(parent);
+ retv_if(!layout, NULL);
+
+ if (!elm_layout_file_set(layout, FILE_LAYOUT_EDJ, GROUP_LAYOUT)) {
+ _E("Failed to set edje file");
+ evas_object_del(layout);
+ return NULL;
+ }
+
+ evas_object_geometry_get(parent, NULL, NULL, &w, &h);
+ _D("conformant size : %dx%d", w, h);
+
+ evas_object_move(layout, 0, 0);
+ evas_object_resize(layout, w, h);
+
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 1.0);
+
+ evas_object_show(layout);
+
+ return layout;
+}
+
+
+
+static void __destroy_layout(Evas_Object *layout)
+{
+ ret_if(!layout);
+
+ evas_object_del(layout);
+}
+
+
+
+
+static Evas_Object *__create_navi_next_btn(Evas_Object *navi, const char *text)
+{
+ Evas_Object *next_btn = NULL;
+
+ retv_if(!navi, NULL);
+ retv_if(!text, NULL);
+
+ next_btn = elm_button_add(navi);
+ retv_if(!next_btn, NULL);
+
+ elm_object_style_set(next_btn, "naviframe/title_right");
+ elm_object_text_set(next_btn, text);
+
+ evas_object_show(next_btn);
+
+ return next_btn;
+}
+
+
+
+static Evas_Object *__create_navi_prev_btn(Evas_Object *navi)
+{
+ Evas_Object *prev_btn = NULL;
+
+ retv_if(!navi, NULL);
+
+ prev_btn = elm_button_add(navi);
+ retv_if(!prev_btn, NULL);
+
+ elm_object_style_set(prev_btn, "naviframe/back_btn/default");
+
+ evas_object_show(prev_btn);
+
+ return prev_btn;
+}
+
+
+
+static void __destroy_navi_btn(Evas_Object *btn)
+{
+ ret_if(!btn);
+
+ evas_object_del(btn);
+}
+
+
+
+static void __click_navi_prev_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *layout = data;
+ ret_if(!layout);
+
+ _setting_destroy(layout);
+
+ return;
+}
+
+
+
+static Evas_Object *__create_navi(Evas_Object *parent, sticker_panel_h sticker_panel)
+{
+ Evas_Object *navi = NULL;
+ Evas_Object *prev_btn = NULL;
+ Evas_Object *genlist = NULL;
+ Elm_Object_Item *navi_item = NULL;
+ setting_info_s *setting_info = NULL;
+
+ retv_if(!parent, NULL);
+ retv_if(!sticker_panel, NULL);
+
+ setting_info = evas_object_data_get(parent, PRIVATE_DATA_KEY_SETTING_INFO);
+ retv_if(!setting_info, NULL);
+
+ navi = elm_naviframe_add(parent);
+ retv_if(!navi, NULL);
+
+ evas_object_size_hint_weight_set(navi, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_naviframe_content_preserve_on_pop_set(navi, EINA_TRUE);
+
+ evas_object_show(navi);
+
+ prev_btn = __create_navi_prev_btn(navi);
+ goto_if(!prev_btn, error);
+
+ setting_info->group_icon_info_list = sticker_panel->group_icon_info_list;
+
+ genlist = __create_genlist(navi, setting_info, SETTING_VIEW_NONE);
+ goto_if(!genlist, error);
+
+ setting_info->genlist = genlist;
+
+ navi_item = elm_naviframe_item_push(navi, STRING_SETTING, prev_btn, NULL, genlist, NULL);
+ goto_if(!navi_item, error);
+
+ setting_info->db = sticker_panel->db;
+
+ evas_object_smart_callback_add(prev_btn, "clicked", __click_navi_prev_btn_cb, parent);
+
+ return navi;
+
+error:
+ if (genlist) {
+ __destroy_genlist(genlist);
+ }
+
+ if (prev_btn) {
+ __destroy_navi_btn(prev_btn);
+ }
+
+ if (navi) {
+ evas_object_del(navi);
+ }
+
+ return NULL;
+}
+
+
+
+static void __destroy_navi(Evas_Object *navi)
+{
+ Evas_Object *prev_btn = NULL;
+ Evas_Object *next_btn = NULL;
+ Evas_Object *genlist = NULL;
+
+ ret_if(!navi);
+
+ prev_btn = elm_object_part_content_unset(navi, "elm.swallow.prev_btn");
+ __destroy_navi_btn(prev_btn);
+
+ next_btn = elm_object_part_content_unset(navi, "elm.swallow.next_btn");
+ __destroy_navi_btn(next_btn);
+
+ genlist = elm_naviframe_item_pop(navi);
+ __destroy_genlist(genlist);
+
+ evas_object_del(navi);
+}
+
+
+
+static void __show_ctx_popup(setting_info_s *setting_info)
+{
+ ret_if(!setting_info);
+
+ evas_object_show(setting_info->ctx_popup);
+
+ setting_info->show_ctx_popup = EINA_TRUE;
+}
+
+
+
+static void __hide_ctx_popup(setting_info_s *setting_info)
+{
+ ret_if(!setting_info);
+
+ elm_ctxpopup_dismiss(setting_info->ctx_popup);
+
+ setting_info->show_ctx_popup = EINA_FALSE;
+}
+
+
+
+static void __destroy_ctx_popup(setting_info_s *setting_info)
+{
+ ret_if(!setting_info);
+
+ evas_object_del(setting_info->ctx_popup);
+
+ setting_info->ctx_popup = NULL;
+ setting_info->show_ctx_popup = EINA_FALSE;
+}
+
+
+
+static void __click_prev_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *genlist = NULL;
+ setting_info_s *setting_info = data;
+
+ ret_if(!setting_info);
+ ret_if(!obj);
+
+ genlist = elm_naviframe_item_pop(setting_info->navi);
+ ret_if(!genlist);
+
+ __destroy_genlist(genlist);
+
+ setting_info->view_type = SETTING_VIEW_NONE;
+}
+
+
+
+static void __update_toolbar_and_scroller(setting_info_s *setting_info)
+{
+ ret_if(!setting_info);
+
+ _toolbar_reorder_item(setting_info->toolbar, setting_info->group_icon_info_list);
+ _scroller_reorder_page(setting_info->scroller, setting_info->group_icon_info_list);
+}
+
+
+
+
+static void __reorder_group_icon_info_from_genlist(Evas_Object *genlist, setting_info_s *setting_info)
+{
+ Elm_Object_Item *item = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+
+ ret_if(!genlist);
+ ret_if(!setting_info);
+
+ item = elm_genlist_first_item_get(genlist);
+ ret_if(!item);
+
+ while (item) {
+ int index = 0;
+ index = elm_genlist_item_index_get(item);
+
+ group_icon_info = evas_object_data_get(item, PRIVATE_DATA_KEY_GROUP_ICON_INFO);
+ goto_if(!group_icon_info, out);
+
+ group_icon_info->ordering = index;
+
+out:
+ item= elm_genlist_item_next_get(item);
+ }
+}
+
+
+
+static void __delete_group_icon_info_from_genlist(Evas_Object *genlist, setting_info_s *setting_info)
+{
+ Elm_Object_Item *item = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+
+ ret_if(!genlist);
+ ret_if(!setting_info);
+
+ item = elm_genlist_first_item_get(genlist);
+ ret_if(!item);
+
+ item = elm_genlist_item_next_get(item);
+
+ while (item) {
+ Evas_Object *check = NULL;
+ Eina_Bool check_on = EINA_FALSE;
+ Eina_Bool ret = EINA_FALSE;
+
+ group_icon_info = evas_object_data_get(item, PRIVATE_DATA_KEY_GROUP_ICON_INFO);
+ goto_if(!group_icon_info, out);
+
+ if (group_icon_info->removable == 0) {
+ _E("This item is not removable");
+ goto out;
+ }
+
+ check = elm_object_item_part_content_get(item, "elm.icon.right");
+ goto_if(!check, out);
+
+ check_on = elm_check_state_get(check);
+ if (check_on) {
+ _toolbar_remove_item(group_icon_info->toolbar_item);
+ _scroller_remove_page(setting_info->scroller, group_icon_info->item_view);
+ _page_destroy(group_icon_info->item_view);
+ setting_info->group_icon_info_list = eina_list_remove(setting_info->group_icon_info_list, group_icon_info);
+
+ ret = ecore_file_recursive_rm(group_icon_info->id);
+ if (!ret) {
+ _E("Failed to remove group icon file");
+ }
+
+ _group_icon_info_destroy(group_icon_info);
+ }
+
+out:
+ item = elm_genlist_item_next_get(item);
+ }
+}
+
+
+
+static void __click_next_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *genlist = NULL;
+ setting_info_s *setting_info = data;
+
+ ret_if(!setting_info);
+ ret_if(!setting_info->group_icon_info_list);
+ ret_if(!setting_info->db);
+ ret_if(!obj);
+
+ genlist = elm_naviframe_item_pop(setting_info->navi);
+ ret_if(!genlist);
+
+ switch(setting_info->view_type) {
+ case SETTING_VIEW_REORDER:
+ __reorder_group_icon_info_from_genlist(genlist, setting_info);
+ break;
+ case SETTING_VIEW_DELETE:
+ __delete_group_icon_info_from_genlist(genlist, setting_info);
+ break;
+ default:
+ _E("view type error(%d)", setting_info->view_type);
+ return;
+ }
+
+ _group_icon_info_list_sort(setting_info->group_icon_info_list);
+ _group_icon_info_list_trim(setting_info->group_icon_info_list, setting_info->db);
+
+ __destroy_genlist(genlist);
+
+ setting_info->view_type = SETTING_VIEW_NONE;
+
+ /* update genlist */
+ __update_genlist(setting_info);
+
+ /* update toolbar & scroller */
+ __update_toolbar_and_scroller(setting_info);
+}
+
+
+
+//@TODO: If it is not necessary, remove this func.
+static Eina_Bool __naviframe_item_pop_cb(void *data, Elm_Object_Item *it)
+{
+ setting_info_s *setting_info = data;
+ retv_if(!setting_info, EINA_FALSE);
+
+ return EINA_TRUE;
+}
+
+
+
+static void __click_ctx_popup_item(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *next_btn = NULL;
+ Evas_Object *prev_btn = NULL;
+ Evas_Object *genlist = NULL;
+ Elm_Object_Item *navi_item = NULL;
+ setting_info_s *setting_info = NULL;
+ setting_view_type_e view_type = (setting_view_type_e) data;
+
+ ret_if(!obj);
+
+ setting_info = evas_object_data_get(obj, PRIVATE_DATA_KEY_SETTING_INFO);
+ ret_if(!setting_info);
+
+ setting_info->view_type = view_type;
+
+ genlist = __create_genlist(setting_info->navi, setting_info, view_type);
+ ret_if(!genlist);
+
+ prev_btn = __create_navi_prev_btn(setting_info->navi);
+ goto_if(!prev_btn, error);
+
+ evas_object_smart_callback_add(prev_btn, "clicked", __click_prev_btn_cb, setting_info);
+
+ switch(view_type) {
+ case SETTING_VIEW_REORDER:
+ _D("Reorder");
+
+ next_btn = __create_navi_next_btn(setting_info->navi, STRING_DONE);
+ goto_if(!next_btn, error);
+
+ navi_item = elm_naviframe_item_push(setting_info->navi, STRING_REORDER, prev_btn, NULL, genlist, NULL);
+ goto_if(!navi_item, error);
+ break;
+ case SETTING_VIEW_DELETE:
+ _D("Delete");
+
+ next_btn = __create_navi_next_btn(setting_info->navi, STRING_DELETE);
+ goto_if(!next_btn, error);
+
+ navi_item = elm_naviframe_item_push(setting_info->navi, STRING_DELETE, prev_btn, NULL, genlist, NULL);
+ goto_if(!navi_item, error);
+ break;
+ default:
+ _E("view type error : %d", view_type);
+ goto error;
+ }
+
+ evas_object_smart_callback_add(next_btn, "clicked", __click_next_btn_cb, setting_info);
+ elm_object_item_part_content_set(navi_item, "title_right_btn", next_btn);
+ elm_naviframe_item_pop_cb_set(navi_item, __naviframe_item_pop_cb, setting_info);
+
+ __hide_ctx_popup(setting_info);
+
+ return;
+
+error:
+ if (prev_btn) {
+ __destroy_navi_btn(prev_btn);
+ }
+
+ if (next_btn) {
+ __destroy_navi_btn(next_btn);
+ }
+
+ if (genlist) {
+ __destroy_genlist(genlist);
+ }
+}
+
+
+
+static Evas_Object *__create_ctx_popup(Evas_Object *parent)
+{
+ Evas_Object *ctx_popup = NULL;
+ Elm_Object_Item *item = NULL;
+ Evas_Coord x, y, w, h;
+ setting_info_s *setting_info = NULL;
+
+ retv_if(!parent, NULL);
+
+ setting_info = evas_object_data_get(parent, PRIVATE_DATA_KEY_SETTING_INFO);
+ retv_if(!setting_info, NULL);
+
+ ctx_popup = elm_ctxpopup_add(parent);
+ retv_if(!ctx_popup, NULL);
+
+ evas_object_data_set(ctx_popup, PRIVATE_DATA_KEY_SETTING_INFO, (void *) setting_info);
+
+ elm_object_style_set(ctx_popup, "more/default");
+ elm_ctxpopup_auto_hide_disabled_set(ctx_popup, EINA_TRUE);
+ eext_object_event_callback_add(ctx_popup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
+ eext_object_event_callback_add(ctx_popup, EEXT_CALLBACK_MORE, eext_ctxpopup_back_cb, NULL);
+
+ //@TODO: need to change string
+ item = elm_ctxpopup_item_append(ctx_popup, "Reorder", NULL, __click_ctx_popup_item, (void *) SETTING_VIEW_REORDER);
+ if (!item) {
+ _E("Failed to add ctx popup item : Reorder");
+ }
+
+ item = elm_ctxpopup_item_append(ctx_popup, "Delete", NULL, __click_ctx_popup_item, (void *) SETTING_VIEW_DELETE);
+ if (!item) {
+ _E("Failed to add ctx popup item : Delete");
+ }
+
+ elm_ctxpopup_direction_priority_set(ctx_popup, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN);
+
+ evas_object_geometry_get(parent, &x, &y, &w, &h);
+ evas_object_resize(ctx_popup, w, ELM_SCALE_SIZE(120 * 3));
+ evas_object_move(ctx_popup, ELM_SCALE_SIZE((x + w / 2)), ELM_SCALE_SIZE((y + h)));
+
+ return ctx_popup;
+}
+
+
+
+static Eina_Bool __key_press_cb(void *data, int type, void *event)
+{
+ Ecore_Event_Key *ev = event;
+ retv_if(!ev, ECORE_CALLBACK_CANCEL);
+
+ _D("Key press : %s", ev->keyname);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+static Eina_Bool __key_release_cb(void *data, int type, void *event)
+{
+ Evas_Object *layout = data;
+ Ecore_Event_Key *ev = event;
+ setting_info_s *setting_info = NULL;
+
+ retv_if(!layout, ECORE_CALLBACK_CANCEL);
+ retv_if(!ev, ECORE_CALLBACK_CANCEL);
+
+ layout = data;
+
+ setting_info = evas_object_data_get(layout, PRIVATE_DATA_KEY_SETTING_INFO);
+ retv_if(!setting_info, ECORE_CALLBACK_CANCEL);
+
+ _D("Key release : %s", ev->keyname);
+
+ if (!strcmp(ev->keyname, KEY_NAME_MENU)) {
+ if (setting_info->view_type != SETTING_VIEW_NONE) {
+ _E("setting view is not NONE");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (setting_info->show_ctx_popup) {
+ __hide_ctx_popup(setting_info);
+ } else {
+ __show_ctx_popup(setting_info);
+ }
+ } else if (!strcmp(ev->keyname, KEY_NAME_BACK)) {
+ //@TODO: add code for HW back key event
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+Evas_Object *_setting_create(Evas_Object *parent, sticker_panel_h sticker_panel)
+{
+ Evas_Object *layout = NULL;
+ Evas_Object *navi = NULL;
+ Evas_Object *ctx_popup = NULL;
+ setting_info_s *setting_info = NULL;
+
+ retv_if(!parent, NULL);
+ retv_if(!sticker_panel, NULL);
+
+ layout = __create_layout(parent);
+ retv_if(!layout, NULL);
+
+ setting_info = calloc(1, sizeof(setting_info_s));
+ goto_if(!setting_info, error);
+
+ evas_object_data_set(layout, PRIVATE_DATA_KEY_SETTING_INFO, setting_info);
+
+ setting_info->toolbar = sticker_panel->toolbar[sticker_panel->current_category];
+ setting_info->scroller = sticker_panel->scroller[sticker_panel->current_category];
+ setting_info->group_icon_info_list = sticker_panel->group_icon_info_list;
+
+ navi = __create_navi(layout, sticker_panel);
+ goto_if(!navi, error);
+ elm_object_part_content_set(layout, "naviframe", navi);
+
+ setting_info->navi = navi;
+
+ ctx_popup = __create_ctx_popup(layout);
+ goto_if(!ctx_popup, error);
+
+ setting_info->ctx_popup = ctx_popup;
+
+ setting_info->key_press = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __key_press_cb, NULL);
+ if (!setting_info->key_press) {
+ _E("Failed to add event handler : key press");
+ }
+
+ setting_info->key_release = ecore_event_handler_add(ECORE_EVENT_KEY_UP, __key_release_cb, layout);
+ if (!setting_info->key_release) {
+ _E("Failed to add event handler : key relase");
+ }
+
+ setting_info->view_type = SETTING_VIEW_NONE;
+
+ return layout;
+
+error:
+ _setting_destroy(layout);
+
+ return NULL;
+}
+
+
+
+void _setting_destroy(Evas_Object *setting)
+{
+ Evas_Object *navi = NULL;
+ setting_info_s *setting_info = NULL;
+
+ ret_if(!setting);
+
+ navi = elm_object_part_content_unset(setting, "naviframe");
+ ret_if(!navi);
+
+ setting_info = evas_object_data_del(setting, PRIVATE_DATA_KEY_SETTING_INFO);
+
+ if (setting_info) {
+ if (setting_info->ctx_popup) {
+ __destroy_ctx_popup(setting_info);
+ }
+
+ if (setting_info->key_press) {
+ ecore_event_handler_del(setting_info->key_press);
+ }
+
+ if (setting_info->key_release) {
+ ecore_event_handler_del(setting_info->key_release);
+ }
+
+ __destroy_navi(navi);
+ __destroy_layout(setting);
+
+ free(setting_info);
+ }
+}
--- /dev/null
+/*
+ * 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 <app_control.h>
+#include <Elementary.h>
+#include <isf_control.h>
+#include <tizen.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "conf.h"
+#include "ui_manager.h"
+#include "gesture.h"
+#include "log.h"
+#include "db.h"
+#include "scroller.h"
+
+
+
+const char *const STICKER_PANEL_DOMAIN = "share-panel";
+const char *const DIRECTORY_INHOUSE = PANELDIR"/res/images";
+const char *const DIRECTORY_3RD_PARTY = "/opt/"PANELDIR"/res/images";
+
+
+static void __resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ int width = 0;
+ int height = 0;
+
+ evas_object_geometry_get(obj, NULL, NULL, &width, &height);
+ _D("The rectangle of Sticker-panel (%d:%d)", width, height);
+}
+
+
+
+static Evas_Object *__create_sticker_panel_rect(Evas_Object *conformant, int height)
+{
+ Evas_Object *rect = NULL;
+
+ retv_if(!conformant, NULL);
+
+ _D("sticker panel rect create");
+
+ rect = evas_object_rectangle_add(evas_object_evas_get(conformant));
+ retv_if(!rect, NULL);
+
+ evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, 1.0);
+ evas_object_size_hint_min_set(rect, 0, height);
+ evas_object_color_set(rect, 0, 0, 0, 0);
+ evas_object_show(rect);
+
+ evas_object_event_callback_add(rect, EVAS_CALLBACK_RESIZE, __resize_cb, NULL);
+
+ return rect;
+}
+
+
+
+static void __destroy_sticker_panel_rect(Evas_Object *rect)
+{
+ ret_if(!rect);
+ evas_object_del(rect);
+}
+
+
+
+static void __rotate_cb(void *data, Evas_Object *obj, void *event)
+{
+ Evas_Object *win = obj;
+ sticker_panel_h sticker_panel = data;
+
+ int w, h;
+ int angle = 0;
+ int height = 0;
+ int i = 0;
+ int temp = 0;
+
+ ret_if(!sticker_panel);
+ ret_if(!sticker_panel->conformant);
+
+ angle = elm_win_rotation_get(win);
+ elm_win_screen_size_get(win, NULL, NULL, &w, &h);
+
+ switch (angle) {
+ case 90:
+ case 270:
+ temp = w;
+ w = h;
+ h = temp;
+ break;
+ case 0:
+ case 180:
+ break;
+ default:
+ _E("cannot reach here");
+ break;
+ }
+
+ _D("Angle is %d degree, win size is %d, %d", angle, w, h);
+
+ isf_control_get_recent_ime_geometry(NULL, NULL, NULL, &height);
+ if (!height) {
+ height = h;
+ }
+
+ _D("isf height : %d, toolbar : %d", height, ELM_SCALE_SIZE(TOOLBAR_HEIGHT));
+
+ for (; i < CATEGORY_COUNT; i++) {
+ _scroller_resize(sticker_panel->scroller[i], w, height - ELM_SCALE_SIZE(TOOLBAR_HEIGHT));
+ elm_scroller_page_show(sticker_panel->scroller[i], sticker_panel->cur_page_no, 0);
+ }
+}
+
+
+
+EXPORT_API int sticker_panel_create(Evas_Object *conformant, sticker_panel_h *sticker_panel)
+{
+ sticker_panel_h panel = NULL;
+ Evas_Object *win = NULL;
+ Evas_Object *old_panel = NULL;
+ const char *type = NULL;
+ int width = 0;
+ int height = 0;
+ int base_height = 0;
+ int count = 0;
+
+ retv_if(!sticker_panel, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!conformant, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ old_panel = elm_object_part_content_get(conformant, "elm.swallow.attach_panel");
+ retv_if(old_panel, STICKER_PANEL_ERROR_ALREADY_EXISTS);
+
+ type = elm_object_widget_type_get(conformant);
+ retv_if(!type, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (strcmp(type, "Elm_Conformant")) {
+ _E("No conformant, %s", elm_object_widget_type_get(conformant));
+ return STICKER_PANEL_ERROR_INVALID_PARAMETER;
+ } else {
+ Evas_Object *parent = conformant;
+ do {
+ const char *type = NULL;
+
+ parent = elm_object_parent_widget_get(parent);
+ break_if(!parent);
+
+ type = elm_object_widget_type_get(parent);
+ break_if(!type);
+ if (!strcmp(type, "Elm_Win")) {
+ win = parent;
+ break;
+ }
+ } while (parent);
+ retv_if(!win, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ }
+
+ bindtextdomain(STICKER_PANEL_DOMAIN, LOCALEDIR);
+
+ panel = calloc(1, sizeof(sticker_panel_s));
+ retv_if(!panel, STICKER_PANEL_ERROR_OUT_OF_MEMORY);
+ panel->win = win;
+ panel->conformant = conformant;
+
+ panel->db = _db_open();
+ goto_if(!panel->db, error);
+ goto_if(_db_create_table(panel->db) != STICKER_PANEL_ERROR_NONE, error);
+ goto_if(_db_count_group_icon(panel->db, NULL, &count) != STICKER_PANEL_ERROR_NONE, error);
+ if (!count)
+ goto_if(_db_initialize_group_icon(panel->db) != STICKER_PANEL_ERROR_NONE, error);
+
+ evas_object_geometry_get(conformant, NULL, NULL, &width, &base_height);
+ panel->transit_width = width;
+
+ if (width > base_height) {
+ base_height = width * BASE_TRANSIT_HEIGHT_REL;
+ } else {
+ base_height = base_height * BASE_TRANSIT_HEIGHT_REL;
+ }
+
+ isf_control_get_recent_ime_geometry(NULL, NULL, NULL, &height);
+ if (!height || height < base_height) {
+ _D("Fail to get the recent ime height");
+ height = base_height;
+ }
+ panel->transit_height = height;
+
+ panel->sticker_panel_rect = __create_sticker_panel_rect(conformant, height);
+ goto_if(!panel->sticker_panel_rect, error);
+ elm_object_part_content_set(conformant, "elm.swallow.attach_panel_base", panel->sticker_panel_rect);
+
+ panel->ui_manager = _ui_manager_create(panel);
+ goto_if(!panel->ui_manager, error);
+ elm_object_part_content_set(conformant, "elm.swallow.attach_panel", panel->ui_manager);
+
+ evas_object_smart_callback_add(panel->win, "wm,rotation,changed", __rotate_cb, panel);
+ __rotate_cb(panel, panel->win, NULL);
+
+ panel->is_delete = EINA_FALSE;
+ *sticker_panel = panel;
+
+ return STICKER_PANEL_ERROR_NONE;
+
+error:
+ if (panel->sticker_panel_rect) {
+ elm_object_part_content_unset(conformant, "elm.swallow.attach_panel_base");
+ __destroy_sticker_panel_rect(panel->sticker_panel_rect);
+ }
+ if (panel->db) {
+ _db_close(panel->db);
+ }
+ free(panel);
+
+ return STICKER_PANEL_ERROR_NOT_INITIALIZED;
+}
+
+
+
+void _sticker_panel_del(sticker_panel_h sticker_panel)
+{
+ ret_if(!sticker_panel);
+
+ if (sticker_panel->animator) {
+ ecore_animator_del(sticker_panel->animator);
+ sticker_panel->animator = NULL;
+ }
+
+ if (sticker_panel->toolbar_animator) {
+ ecore_animator_del(sticker_panel->toolbar_animator);
+ sticker_panel->toolbar_animator = NULL;
+ }
+
+ elm_object_part_content_unset(sticker_panel->conformant, "elm.swallow.attach_panel_base");
+ __destroy_sticker_panel_rect(sticker_panel->sticker_panel_rect);
+
+ elm_object_part_content_unset(sticker_panel->conformant, "elm.swallow.attach_panel");
+ _ui_manager_destroy(sticker_panel->ui_manager);
+
+ evas_object_smart_callback_del(sticker_panel->win, "wm,rotation,changed", __rotate_cb);
+
+ if (sticker_panel->db) {
+ _db_close(sticker_panel->db);
+ }
+
+ free(sticker_panel);
+}
+
+
+
+EXPORT_API int sticker_panel_destroy(sticker_panel_h sticker_panel)
+{
+ retv_if(!sticker_panel, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (EINA_TRUE == sticker_panel->is_delete) {
+ _E("Sticker panel is already removed");
+ return STICKER_PANEL_ERROR_ALREADY_REMOVED;
+ }
+
+ if (STICKER_PANEL_STATE_HIDE == sticker_panel->sticker_panel_state) {
+ _sticker_panel_del(sticker_panel);
+ } else {
+ sticker_panel->is_delete = EINA_TRUE;
+ }
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+EXPORT_API int sticker_panel_set_result_cb(sticker_panel_h sticker_panel, sticker_panel_result_cb result_cb, void *user_data)
+{
+ retv_if(!sticker_panel, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!result_cb, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (EINA_TRUE == sticker_panel->is_delete) {
+ _E("Sticker panel is already removed");
+ return STICKER_PANEL_ERROR_ALREADY_REMOVED;
+ }
+
+ sticker_panel->result_cb = result_cb;
+ sticker_panel->result_data = user_data;
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+EXPORT_API int sticker_panel_unset_result_cb(sticker_panel_h sticker_panel)
+{
+ retv_if(!sticker_panel, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (EINA_TRUE == sticker_panel->is_delete) {
+ _E("Sticker panel is already removed");
+ return STICKER_PANEL_ERROR_ALREADY_REMOVED;
+ }
+
+ sticker_panel->result_cb = NULL;
+ sticker_panel->result_data = NULL;
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+EXPORT_API int sticker_panel_set_view_mode(sticker_panel_h sticker_panel, sticker_panel_view_mode_e view_mode)
+{
+ retv_if(!sticker_panel, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(view_mode < STICKER_PANEL_VIEW_MODE_HALF, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(view_mode > STICKER_PANEL_VIEW_MODE_FULL, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (EINA_TRUE == sticker_panel->is_delete) {
+ _E("Sticker panel is already removed");
+ return STICKER_PANEL_ERROR_ALREADY_REMOVED;
+ }
+
+ sticker_panel->view_mode = view_mode;
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+EXPORT_API int sticker_panel_show(sticker_panel_h sticker_panel)
+{
+ retv_if(!sticker_panel, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!sticker_panel->ui_manager, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (EINA_TRUE == sticker_panel->is_delete) {
+ _E("Sticker panel is already removed");
+ return STICKER_PANEL_ERROR_ALREADY_REMOVED;
+ }
+
+ evas_object_show(sticker_panel->ui_manager);
+ _gesture_show(sticker_panel);
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+EXPORT_API int sticker_panel_hide(sticker_panel_h sticker_panel)
+{
+ retv_if(!sticker_panel, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!sticker_panel->ui_manager, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ if (EINA_TRUE == sticker_panel->is_delete) {
+ _E("Sticker panel is already removed");
+ return STICKER_PANEL_ERROR_ALREADY_REMOVED;
+ }
+
+ _gesture_hide(sticker_panel);
+
+ return STICKER_PANEL_ERROR_NONE;
+}
--- /dev/null
+/*
+ * 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 <Elementary.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "icon_info.h"
+#include "group_icon_info.h"
+#include "conf.h"
+#include "log.h"
+#include "toolbar.h"
+
+const char *const PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST = "pdkec";
+const char *const PRIVATE_DATA_TOOLBAR_ITEM = "pdti";
+const char *const SETTING_ICON_IMG_PATH = "/usr/share/sticker-panel/images/sticker_tab_settings.png";
+
+
+
+struct _event_cb {
+ int event_type;
+ void (*event_cb)(Evas_Object *toolbar, int event_type, void *event_info, void *user_data);
+ void *user_data;
+};
+typedef struct _event_cb event_cb_s;
+
+
+
+static void __resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *toolbar = obj;
+
+ int x, y, w, h;
+
+ ret_if(!toolbar);
+
+ evas_object_geometry_get(toolbar, &x, &y, &w, &h);
+ _D("toolbar resize(%d, %d, %d, %d)", x, y, w, h);
+}
+
+
+
+Evas_Object *_toolbar_create(Evas_Object *ui_manager, sticker_panel_h sticker_panel)
+{
+ Evas_Object *toolbar = NULL;
+
+ retv_if(!ui_manager, NULL);
+ retv_if(!sticker_panel, NULL);
+
+ toolbar = elm_toolbar_add(ui_manager);
+ goto_if(!toolbar, ERROR);
+
+ /* This will expand the transverse(horizontal) length of items according to the length of toolbar */
+ elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
+ elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL);
+ elm_toolbar_homogeneous_set(toolbar, EINA_FALSE);
+ elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
+
+ evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(toolbar);
+ evas_object_data_set(toolbar, DATA_KEY_STICKER_PANEL_INFO, sticker_panel);
+
+ evas_object_event_callback_add(toolbar, EVAS_CALLBACK_RESIZE, __resize_cb, NULL);
+
+ return toolbar;
+
+ERROR:
+ _toolbar_destroy(toolbar);
+ return NULL;
+}
+
+
+
+void _toolbar_destroy(Evas_Object *toolbar)
+{
+ sticker_panel_h sticker_panel = NULL;
+
+ ret_if(!toolbar);
+
+ sticker_panel = evas_object_data_del(toolbar, DATA_KEY_STICKER_PANEL_INFO);
+ ret_if(!sticker_panel);
+
+ evas_object_event_callback_del(toolbar, EVAS_CALLBACK_RESIZE, __resize_cb);
+ evas_object_del(toolbar);
+}
+
+
+
+static void __view_changed_cb(void *user_data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *toolbar = obj;
+ Evas_Object *item_view = user_data;
+ Eina_List *event_cb_list = NULL;
+ const Eina_List *l = NULL;
+ const Eina_List *ln = NULL;
+ event_cb_s *event_cb_info = NULL;
+
+ ret_if(!toolbar);
+ ret_if(!item_view);
+
+ event_cb_list = evas_object_data_get(toolbar, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST);
+ ret_if(!event_cb_list);
+
+ EINA_LIST_FOREACH_SAFE(event_cb_list, l, ln, event_cb_info) {
+ if (TOOLBAR_EVENT_TYPE_CHANGE_TAB == event_cb_info->event_type) {
+ if (event_cb_info->event_cb) {
+ event_cb_info->event_cb(toolbar, TOOLBAR_EVENT_TYPE_CHANGE_TAB, item_view, event_cb_info->user_data);
+ }
+ }
+ }
+}
+
+
+
+Elm_Object_Item *_toolbar_append_item(Evas_Object *toolbar, const char *icon_path, Evas_Object *item_view)
+{
+ Elm_Object_Item *tab_item = NULL;
+
+ retv_if(!toolbar, NULL);
+ retv_if(!icon_path, NULL);
+
+ tab_item = elm_toolbar_item_append(toolbar, icon_path, NULL, __view_changed_cb, item_view);
+ retv_if(!tab_item, NULL);
+ evas_object_data_set(item_view, PRIVATE_DATA_TOOLBAR_ITEM, tab_item);
+
+ return tab_item;
+}
+
+
+
+Elm_Object_Item *_toolbar_append_setting_item(Evas_Object *toolbar, void (*cb_func)(void *user_data, Evas_Object *obj, void *event_info), sticker_panel_h sticker_panel)
+{
+ Elm_Object_Item *tab_item = NULL;
+
+ retv_if(!toolbar, NULL);
+ retv_if(!sticker_panel, NULL);
+
+ tab_item = elm_toolbar_item_append(toolbar, SETTING_ICON_IMG_PATH, NULL, cb_func, sticker_panel);
+ retv_if(!tab_item, NULL);
+
+ return tab_item;
+}
+
+
+
+void _toolbar_remove_setting_item(Evas_Object *toolbar)
+{
+ Elm_Object_Item *setting_item = NULL;
+
+ ret_if(!toolbar);
+
+ setting_item = elm_toolbar_last_item_get(toolbar);
+ ret_if(!setting_item);
+
+ elm_object_item_del(setting_item);
+}
+
+
+
+void _toolbar_remove_item_by_item_view(Evas_Object *toolbar, Evas_Object *item_view)
+{
+ Elm_Object_Item *tabbar_item = NULL;
+
+ ret_if(!toolbar);
+ ret_if(!item_view);
+
+ evas_object_data_del(item_view, PRIVATE_DATA_TOOLBAR_ITEM);
+
+ tabbar_item = _toolbar_get_item(toolbar, item_view);
+ if (tabbar_item) {
+ elm_object_item_del(tabbar_item);
+ }
+
+ /* This data has to be kept because of _toolbar_get_item() */
+ evas_object_data_del(item_view, PRIVATE_DATA_TOOLBAR_ITEM);
+
+ /* FIXME : If the selected item is removed, we have to activate the current */
+}
+
+
+
+void _toolbar_remove_item(Elm_Object_Item *item)
+{
+ ret_if(!item);
+
+ elm_object_item_del(item);
+}
+
+
+
+void _toolbar_remove_all_item(Evas_Object *toolbar)
+{
+ Elm_Object_Item *item = NULL;
+
+ ret_if(!toolbar);
+
+ item = elm_toolbar_first_item_get(toolbar);
+ while (item) {
+ elm_object_item_del(item);
+ item = elm_toolbar_item_next_get(item);
+ }
+}
+
+
+
+Elm_Object_Item *_toolbar_get_item(Evas_Object *toolbar, Evas_Object *item_view)
+{
+ Elm_Object_Item *tabbar_item = NULL;
+
+ retv_if(!toolbar, NULL);
+ retv_if(!item_view, NULL);
+
+ tabbar_item = evas_object_data_get(item_view, PRIVATE_DATA_TOOLBAR_ITEM);
+ retv_if(!tabbar_item, NULL);
+
+ /* FIXME : check the tabbar is in the toolbar */
+
+ return tabbar_item;
+}
+
+
+
+Elm_Object_Item *_toolbar_insert_item_before(Evas_Object *toolbar, const char *icon_path, Evas_Object *item_view, Elm_Object_Item *before)
+{
+ Elm_Object_Item *tab_item = NULL;
+ retv_if(!toolbar, NULL);
+ retv_if(!icon_path, NULL);
+ retv_if(!item_view, NULL);
+ retv_if(!before, NULL);
+
+ tab_item = elm_toolbar_item_insert_before(toolbar, before, icon_path, NULL, __view_changed_cb, item_view);
+ retv_if(!tab_item, NULL);
+ evas_object_data_set(item_view, PRIVATE_DATA_TOOLBAR_ITEM, tab_item);
+
+ return tab_item;
+}
+
+
+
+void _toolbar_reorder_item(Evas_Object *toolbar, Eina_List *group_icon_info_list)
+{
+ Elm_Object_Item *last_item = NULL;
+ Eina_List *l = NULL;
+ group_icon_info_s *group_icon_info = NULL;
+
+ ret_if(!toolbar);
+ ret_if(!group_icon_info_list);
+
+ last_item = elm_toolbar_last_item_get(toolbar);
+ ret_if(!last_item);
+
+ EINA_LIST_FOREACH(group_icon_info_list, l, group_icon_info) {
+ icon_info_s *icon_info = NULL;
+
+ if (!group_icon_info) {
+ continue;
+ }
+
+ if (group_icon_info->permutable == 0) {
+ continue;
+ }
+
+ if (group_icon_info->toolbar_item) {
+ _toolbar_remove_item(group_icon_info->toolbar_item);
+ group_icon_info->toolbar_item = NULL;
+ }
+
+ icon_info = eina_list_nth(group_icon_info->list, 0);
+ if (!icon_info) {
+ _E("Failed to get icon info");
+ continue;
+ }
+
+ group_icon_info->toolbar_item = _toolbar_insert_item_before(toolbar, icon_info->thumbnail_file, group_icon_info->item_view, last_item);
+ if (!group_icon_info->toolbar_item) {
+ _E("Failed to insert toolbar item");
+ continue;
+ }
+
+ }
+
+}
+
+
+
+void _toolbar_bring_in(Evas_Object *toolbar, Elm_Object_Item *tabbar_item)
+{
+ Elm_Object_Item *selected_item = NULL;
+
+ ret_if(!toolbar);
+ ret_if(!tabbar_item);
+
+ selected_item = elm_toolbar_selected_item_get(toolbar);
+ if (selected_item && selected_item == tabbar_item) {
+ return;
+ }
+
+ elm_toolbar_item_selected_set(tabbar_item, EINA_TRUE);
+}
+
+
+
+unsigned int _toolbar_count_item(Evas_Object *toolbar)
+{
+ retv_if(!toolbar, 0);
+
+ return elm_toolbar_items_count(toolbar);
+}
+
+
+
+int _toolbar_register_event_cb(Evas_Object *toolbar, int event_type, void (*event_cb)(Evas_Object *toolbar, int event_type, void *event_info, void *user_data), void *user_data)
+{
+ Eina_List *event_cb_list = NULL;
+ event_cb_s *event_cb_info = NULL;
+
+ retv_if(!toolbar, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(event_type <= TOOLBAR_EVENT_TYPE_INVALID, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(event_type >= TOOLBAR_EVENT_TYPE_MAX, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!event_cb, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ event_cb_info = calloc(1, sizeof(event_cb_s));
+ retv_if(!event_cb_info, STICKER_PANEL_ERROR_OUT_OF_MEMORY);
+
+ event_cb_info->event_type = event_type;
+ event_cb_info->event_cb = event_cb;
+ event_cb_info->user_data = user_data;
+
+ event_cb_list = evas_object_data_get(toolbar, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST);
+ event_cb_list = eina_list_append(event_cb_list, event_cb_info);
+ evas_object_data_set(toolbar, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST, event_cb_list);
+
+ return STICKER_PANEL_ERROR_NONE;
+}
+
+
+
+int _toolbar_unregister_event_cb(Evas_Object *toolbar, int event_type, void (*event_cb)(Evas_Object *toolbar, int event_type, void *event_info, void *user_data))
+{
+ Eina_List *event_cb_list = NULL;
+ const Eina_List *l = NULL;
+ const Eina_List *ln = NULL;
+ event_cb_s *event_cb_info = NULL;
+
+ retv_if(!toolbar, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(event_type <= TOOLBAR_EVENT_TYPE_INVALID, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(event_type >= TOOLBAR_EVENT_TYPE_MAX, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+ retv_if(!event_cb, STICKER_PANEL_ERROR_INVALID_PARAMETER);
+
+ event_cb_list = evas_object_data_get(toolbar, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST);
+ retv_if(!event_cb_list, STICKER_PANEL_ERROR_NOT_INITIALIZED);
+
+ EINA_LIST_FOREACH_SAFE(event_cb_list, l, ln, event_cb_info) {
+ if (event_cb_info->event_type == event_type
+ && event_cb_info->event_cb == event_cb) {
+ event_cb_list = eina_list_remove(event_cb_list, event_cb_info);
+ break;
+ }
+ }
+
+ evas_object_data_set(toolbar, PRIVATE_DATA_KEY_EVENT_CALLBACK_LIST, event_cb_list);
+
+ return STICKER_PANEL_ERROR_NONE;
+}
--- /dev/null
+/*
+ * 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 <Elementary.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#include "sticker_panel.h"
+#include "sticker_panel_internal.h"
+#include "icon_info.h"
+#include "group_icon_info.h"
+#include "conf.h"
+#include "log.h"
+#include "page.h"
+#include "scroller.h"
+#include "toolbar.h"
+#include "grid.h"
+#include "setting.h"
+
+#define FILE_LAYOUT_EDJ EDJEDIR"/layout.edj"
+#define GROUP_LAYOUT "layout"
+
+
+
+static void __resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *ui_manager = obj;
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Evas_Coord w = 0;
+ Evas_Coord h = 0;
+
+ ret_if(!ui_manager);
+
+ evas_object_geometry_get(ui_manager, &x, &y, &w, &h);
+ _D("ui_manager resize(%d, %d, %d, %d)", x, y, w, h);
+}
+
+
+
+static void __change_tab_cb(Evas_Object *toolbar, int event_type, void *event_info, void *data)
+{
+ sticker_panel_h sticker_panel = data;
+ Evas_Object *page = event_info;
+
+ ret_if(!sticker_panel);
+ ret_if(!page);
+
+ _scroller_bring_in_page(sticker_panel->scroller[sticker_panel->current_category], page, &sticker_panel->cur_page_no);
+}
+
+
+
+static void __scroll_cb(Evas_Object *scroller, int event_type, void *event_info, void *data)
+{
+ sticker_panel_h sticker_panel = data;
+ group_icon_info_s *group_icon_info = NULL;
+ const Eina_List *l = NULL;
+ int index = (int) event_info;
+
+ ret_if(!sticker_panel);
+
+ EINA_LIST_FOREACH(sticker_panel->group_icon_info_list, l, group_icon_info) {
+ if (group_icon_info->category != sticker_panel->current_category)
+ continue;
+
+ if (group_icon_info->ordering == index) {
+ _toolbar_bring_in(sticker_panel->toolbar[group_icon_info->category]
+ , group_icon_info->toolbar_item);
+ return;
+ }
+ }
+
+ _E("cannot find ordering[%d] in the list", index);
+}
+
+
+
+static void __destroy_scroller_pages(Evas_Object *scroller)
+{
+ Evas_Object *box = NULL;
+ Evas_Object *page = NULL;
+ Eina_List *list = NULL;
+
+ ret_if(!scroller);
+
+ box = elm_object_content_get(scroller);
+ ret_if(!box);
+
+ list = elm_box_children_get(box);
+ ret_if(!list);
+
+ EINA_LIST_FREE(list, page) {
+ Evas_Object *grid = NULL;
+
+ continue_if(!page);
+
+ grid = elm_object_part_content_unset(page, "content");
+ if (grid) {
+ _grid_destroy(grid);
+ }
+
+ _page_destroy(page);
+ }
+}
+
+
+
+static Eina_Bool __animator_cb(void *data)
+{
+ group_icon_info_s *group_icon_info = NULL;
+ sticker_panel_h sticker_panel = data;
+ Evas_Object *grid = NULL;
+
+ const Eina_List *lm = NULL;
+ icon_info_s *icon_info = NULL;
+ static int i = 0;
+
+ goto_if(!sticker_panel, out);
+ goto_if(!sticker_panel->group_icon_info_list, out);
+
+ group_icon_info = eina_list_nth(sticker_panel->group_icon_info_list, i);
+ if (!group_icon_info)
+ goto out;
+
+ group_icon_info->item_view = _page_create(sticker_panel->scroller[group_icon_info->category]
+ , sticker_panel->transit_width
+ , (sticker_panel->transit_height - ELM_SCALE_SIZE(TOOLBAR_HEIGHT)));
+ goto_if(!group_icon_info->item_view, out);
+ _scroller_append_page(sticker_panel->scroller[group_icon_info->category], group_icon_info->item_view);
+
+ group_icon_info->toolbar_item = _toolbar_append_item(sticker_panel->toolbar[group_icon_info->category]
+ , group_icon_info->toolbar_icon_path
+ , group_icon_info->item_view);
+ goto_if(!group_icon_info->toolbar_item, error);
+
+ grid = _grid_create(group_icon_info->item_view, sticker_panel);
+ goto_if(!grid, error);
+ elm_object_part_content_set(group_icon_info->item_view, "content", grid);
+
+ if (group_icon_info->recent)
+ sticker_panel->recent_grid = grid;
+
+ if (!group_icon_info->list)
+ goto renew;
+
+ /* FIXME : We have an empty page for downloading stickers */
+ EINA_LIST_FOREACH(group_icon_info->list, lm, icon_info) {
+ if (icon_info->keyword && icon_info->thumbnail_file) {
+ Elm_Object_Item *item = NULL;
+ item = _grid_append_item(grid, sticker_panel, icon_info);
+ goto_if(!item, renew);
+ }
+ }
+
+renew:
+ i++;
+ return ECORE_CALLBACK_RENEW;
+
+error:
+ if (group_icon_info->toolbar_item) {
+ _toolbar_remove_item(group_icon_info->toolbar_item);
+ group_icon_info->toolbar_item = NULL;
+ }
+
+ _scroller_remove_page(sticker_panel->scroller[group_icon_info->category], group_icon_info->item_view);
+ _page_destroy(group_icon_info->item_view);
+ group_icon_info->item_view = NULL;
+
+out:
+ sticker_panel->animator = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+static void _mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ _D("mouse is down");
+}
+
+
+
+Evas_Object *_ui_manager_create(sticker_panel_h sticker_panel)
+{
+ Evas_Object *ui_manager = NULL;
+ int ret = STICKER_PANEL_ERROR_NONE;
+ int i = 0;
+
+ retv_if(!sticker_panel, NULL);
+ retv_if(!sticker_panel->conformant, NULL);
+
+ ui_manager = elm_layout_add(sticker_panel->conformant);
+ retv_if(!ui_manager, NULL);
+ elm_layout_file_set(ui_manager, FILE_LAYOUT_EDJ, GROUP_LAYOUT);
+ evas_object_size_hint_weight_set(ui_manager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ui_manager, EVAS_HINT_FILL, 1.0);
+ evas_object_event_callback_add(ui_manager, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, NULL);
+ evas_object_show(ui_manager);
+
+ evas_object_data_set(ui_manager, DATA_KEY_STICKER_PANEL_INFO, sticker_panel);
+ evas_object_event_callback_add(ui_manager, EVAS_CALLBACK_RESIZE, __resize_cb, NULL);
+
+ for (; i < CATEGORY_COUNT; i++) {
+ sticker_panel->toolbar[i] = _toolbar_create(ui_manager, sticker_panel);
+ goto_if(!sticker_panel->toolbar[i], ERROR);
+
+ ret = _toolbar_register_event_cb(sticker_panel->toolbar[i], TOOLBAR_EVENT_TYPE_CHANGE_TAB, __change_tab_cb, sticker_panel);
+ goto_if(STICKER_PANEL_ERROR_NONE != ret, ERROR);
+
+ sticker_panel->scroller[i] = _scroller_create(ui_manager, sticker_panel);
+ goto_if(!sticker_panel->scroller[i], ERROR);
+
+ ret = _scroller_register_event_cb(sticker_panel->scroller[i], SCROLLER_EVENT_TYPE_SCROLL, __scroll_cb, sticker_panel);
+ goto_if(STICKER_PANEL_ERROR_NONE != ret, ERROR);
+ }
+
+ /* Initialize with the first category */
+ elm_object_part_content_set(ui_manager, "toolbar", sticker_panel->toolbar[0]);
+ elm_object_part_content_set(ui_manager, "scroller", sticker_panel->scroller[0]);
+
+ sticker_panel->group_icon_info_list = _group_icon_info_list_create(sticker_panel->db);
+ goto_if(!sticker_panel->group_icon_info_list, ERROR);
+
+ sticker_panel->animator = ecore_animator_add(__animator_cb, sticker_panel);
+ if (!sticker_panel->animator) {
+ _E("cannot add an animator");
+ }
+
+ return ui_manager;
+
+ERROR:
+ elm_object_part_content_unset(ui_manager, "scroller");
+ elm_object_part_content_unset(ui_manager, "toolbar");
+
+ for (i = 0; i < CATEGORY_COUNT; i++) {
+ if (sticker_panel->scroller[i]) {
+ ret = _scroller_unregister_event_cb(sticker_panel->scroller[i], SCROLLER_EVENT_TYPE_SCROLL, __scroll_cb);
+ if (STICKER_PANEL_ERROR_NONE != ret) {
+ _E("cannot unregiter event_cb for scroller");
+ }
+
+ _scroller_destroy(sticker_panel->scroller[i]);
+ }
+
+ if (sticker_panel->toolbar[i]) {
+ ret = _toolbar_unregister_event_cb(sticker_panel->toolbar[i], TOOLBAR_EVENT_TYPE_CHANGE_TAB, __change_tab_cb);
+ if (STICKER_PANEL_ERROR_NONE != ret) {
+ _E("cannot unregiter event_cb for toolbar");
+ }
+
+ _toolbar_destroy(sticker_panel->toolbar[i]);
+ }
+ }
+
+ if (ui_manager) {
+ evas_object_data_del(ui_manager, DATA_KEY_STICKER_PANEL_INFO);
+ evas_object_del(ui_manager);
+ }
+
+ return NULL;
+}
+
+
+
+void _ui_manager_destroy(Evas_Object *ui_manager)
+{
+ sticker_panel_h sticker_panel = NULL;
+ int ret = STICKER_PANEL_ERROR_NONE;
+ int i = 0;
+
+ ret_if(!ui_manager);
+
+ sticker_panel = evas_object_data_del(ui_manager, DATA_KEY_STICKER_PANEL_INFO);
+ ret_if(!sticker_panel);
+
+ if (sticker_panel->animator) {
+ ecore_animator_del(sticker_panel->animator);
+ }
+
+ if (sticker_panel->group_icon_info_list) {
+ _group_icon_info_list_destroy(sticker_panel->group_icon_info_list);
+ }
+
+ elm_object_part_content_unset(ui_manager, "scroller");
+ elm_object_part_content_unset(ui_manager, "toolbar");
+
+ for (; i < CATEGORY_COUNT; i++) {
+ if (sticker_panel->scroller[i]) {
+ ret = _scroller_unregister_event_cb(sticker_panel->scroller[i], SCROLLER_EVENT_TYPE_SCROLL, __scroll_cb);
+ if (STICKER_PANEL_ERROR_NONE != ret) {
+ _E("cannot unregiter event_cb for scroller");
+ }
+
+ __destroy_scroller_pages(sticker_panel->scroller[i]);
+ _scroller_destroy(sticker_panel->scroller[i]);
+ }
+
+ if (sticker_panel->toolbar[i]) {
+ ret = _toolbar_unregister_event_cb(sticker_panel->toolbar[i], TOOLBAR_EVENT_TYPE_CHANGE_TAB, __change_tab_cb);
+ if (STICKER_PANEL_ERROR_NONE != ret) {
+ _E("cannot unregiter event_cb for toolbar[i]");
+ }
+
+ _toolbar_remove_all_item(sticker_panel->toolbar[i]);
+ _toolbar_destroy(sticker_panel->toolbar[i]);
+ }
+ }
+
+ if (sticker_panel->ui_manager) {
+ evas_object_event_callback_del(ui_manager, EVAS_CALLBACK_RESIZE, __resize_cb);
+ evas_object_del(ui_manager);
+ }
+}
+
+
+
+void _ui_manager_show_category(Evas_Object *ui_manager, sticker_panel_h sticker_panel, int category)
+{
+ Evas_Object *scroller = NULL;
+ Evas_Object *toolbar = NULL;
+
+ ret_if(!ui_manager);
+ ret_if(!sticker_panel);
+ ret_if(!sticker_panel->scroller[category]);
+ ret_if(!sticker_panel->toolbar[category]);
+
+ if (sticker_panel->current_category == category)
+ return;
+ else
+ sticker_panel->current_category = category;
+
+ scroller = elm_object_part_content_unset(ui_manager, "scroller");
+ if (scroller)
+ evas_object_hide(scroller);
+
+ toolbar = elm_object_part_content_unset(ui_manager, "toolbar");
+ if (toolbar)
+ evas_object_hide(toolbar);
+
+ evas_object_show(sticker_panel->scroller[category]);
+ elm_object_part_content_set(ui_manager, "scroller", sticker_panel->scroller[category]);
+
+ evas_object_show(sticker_panel->toolbar[category]);
+ elm_object_part_content_set(ui_manager, "toolbar", sticker_panel->toolbar[category]);
+}
--- /dev/null
+$1 pulseaudio rwxat
+$1 aul::launch x
+$1 isf rwx
+$1 syslogd w
+$1 tts-server rwx
+$1 ug.gallerry-efl include
+$1 ug.image-viewer-efl include
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/share/sticker-panel/sample/sample" exec_label="none" />
+ </assign>
+</manifest>
--- /dev/null
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: sticker-panel
+Description: sticker-panel supporting library
+Version: @VERSION@
+Requires: capi-base-common
+Libs: -L${libdir} -lsticker-panel
+Cflags: -I${includedir}